1 | #include "globals.h"
|
---|
2 | #include "oscam-string.h"
|
---|
3 |
|
---|
4 | /* Gets the servicename. Make sure that buf is at least 32 bytes large. */
|
---|
5 | char *get_servicename(struct s_client *cl, uint16_t srvid, uint16_t caid, char *buf){
|
---|
6 | int32_t i;
|
---|
7 | struct s_srvid *this;
|
---|
8 | buf[0] = '\0';
|
---|
9 |
|
---|
10 | if (!srvid || (srvid>>12) >= 16) //cfg.srvid[16]
|
---|
11 | return(buf);
|
---|
12 |
|
---|
13 | if (cl && cl->last_srvidptr && cl->last_srvidptr->srvid==srvid)
|
---|
14 | for (i=0; i < cl->last_srvidptr->ncaid; i++)
|
---|
15 | if (cl->last_srvidptr->caid[i] == caid && cl->last_srvidptr->name){
|
---|
16 | cs_strncpy(buf, cl->last_srvidptr->name, 32);
|
---|
17 | return(buf);
|
---|
18 | }
|
---|
19 |
|
---|
20 | for (this = cfg.srvid[srvid>>12]; this; this = this->next)
|
---|
21 | if (this->srvid == srvid)
|
---|
22 | for (i=0; i < this->ncaid; i++)
|
---|
23 | if (this->caid[i] == caid && this->name && cl) {
|
---|
24 | cs_strncpy(buf, this->name, 32);
|
---|
25 | cl->last_srvidptr = this;
|
---|
26 | return(buf);
|
---|
27 | }
|
---|
28 |
|
---|
29 | if (!buf[0]) {
|
---|
30 | snprintf(buf, 32, "%04X:%04X unknown", caid, srvid);
|
---|
31 | if (cl) cl->last_srvidptr = NULL;
|
---|
32 | }
|
---|
33 | return(buf);
|
---|
34 | }
|
---|
35 |
|
---|
36 | /* Gets the tier name. Make sure that buf is at least 83 bytes long. */
|
---|
37 | char *get_tiername(uint16_t tierid, uint16_t caid, char *buf){
|
---|
38 | int32_t i;
|
---|
39 | struct s_tierid *this = cfg.tierid;
|
---|
40 |
|
---|
41 | for (buf[0] = 0; this && (!buf[0]); this = this->next)
|
---|
42 | if (this->tierid == tierid)
|
---|
43 | for (i=0; i<this->ncaid; i++)
|
---|
44 | if (this->caid[i] == caid)
|
---|
45 | cs_strncpy(buf, this->name, 32);
|
---|
46 |
|
---|
47 | if (!tierid) buf[0] = '\0';
|
---|
48 | return(buf);
|
---|
49 | }
|
---|
50 |
|
---|
51 | /* Gets the provider name. */
|
---|
52 | char *get_provider(uint16_t caid, uint32_t provid, char *buf, uint32_t buflen){
|
---|
53 | struct s_provid *this = cfg.provid;
|
---|
54 |
|
---|
55 | for (buf[0] = 0; this && (!buf[0]); this = this->next) {
|
---|
56 | if (this->caid == caid && this->provid == provid) {
|
---|
57 | snprintf(buf, buflen, "%s%s%s%s%s", this->prov,
|
---|
58 | this->sat[0] ? " / " : "", this->sat,
|
---|
59 | this->lang[0] ? " / " : "", this->lang);
|
---|
60 | }
|
---|
61 | }
|
---|
62 |
|
---|
63 | if (!buf[0]) snprintf(buf, buflen, "%04X:%06X unknown", caid, provid);
|
---|
64 | if (!caid) buf[0] = '\0';
|
---|
65 | return(buf);
|
---|
66 | }
|
---|
67 |
|
---|
68 | // Add provider description. If provider was already present, do nothing.
|
---|
69 | void add_provider(uint16_t caid, uint32_t provid, const char *name, const char *sat, const char *lang)
|
---|
70 | {
|
---|
71 | struct s_provid **ptr;
|
---|
72 | for (ptr = &cfg.provid; *ptr; ptr = &(*ptr)->next) {
|
---|
73 | if ((*ptr)->caid == caid && (*ptr)->provid == provid)
|
---|
74 | return;
|
---|
75 | }
|
---|
76 |
|
---|
77 | struct s_provid *prov;
|
---|
78 | if (!cs_malloc(&prov, sizeof(struct s_provid)))
|
---|
79 | return;
|
---|
80 |
|
---|
81 | prov->provid = provid;
|
---|
82 | prov->caid = caid;
|
---|
83 | cs_strncpy(prov->prov, name, sizeof(prov->prov));
|
---|
84 | cs_strncpy(prov->sat, sat, sizeof(prov->sat));
|
---|
85 | cs_strncpy(prov->lang, lang, sizeof(prov->lang));
|
---|
86 | *ptr = prov;
|
---|
87 | }
|
---|