source: trunk/oscam-config.c@ 57

Last change on this file since 57 was 57, checked in by polo, 12 years ago

Add UnLockParental option to disable seca pin code request for adult movie.
Impletent seca_card_info to log card info when SIGUSR3 is sent

File size: 34.2 KB
Line 
1#include "globals.h"
2#ifdef CS_WITH_BOXKEYS
3# include "oscam-boxkeys.np"
4#endif
5
6static char *cs_conf="oscam.conf";
7static char *cs_user="oscam.user";
8static char *cs_srvr="oscam.server";
9static char *cs_srid="oscam.srvid";
10static char *cs_l4ca="oscam.guess";
11static char *cs_cert="oscam.cert";
12static char *cs_sidt="oscam.services";
13//static char *cs_ird="oscam.ird";
14#ifdef CS_ANTICASC
15static char *cs_ac="oscam.ac";
16#endif
17
18static char token[4096];
19
20typedef enum cs_proto_type
21{
22 TAG_GLOBAL, // must be first !
23 TAG_MONITOR, // monitor
24 TAG_CAMD33, // camd 3.3x
25 TAG_CAMD35, // camd 3.5x UDP
26 TAG_NEWCAMD, // newcamd
27 TAG_RADEGAST, // radegast
28 TAG_SERIAL, // serial (static)
29 TAG_CS357X, // camd 3.5x UDP
30 TAG_CS378X, // camd 3.5x TCP
31 TAG_GBOX // gbox
32#ifdef CS_ANTICASC
33 ,TAG_ANTICASC // anti-cascading
34#endif
35} cs_proto_type_t;
36
37static char *cctag[]={"global", "monitor", "camd33", "camd35",
38 "newcamd", "radegast", "serial", "cs357x", "cs378x", "gbox",
39#ifdef CS_ANTICASC
40 "anticasc",
41#endif
42 NULL};
43
44#ifdef DEBUG_SIDTAB
45static void show_sidtab(struct s_sidtab *sidtab)
46{
47 for (; sidtab; sidtab=sidtab->next)
48 {
49 int i;
50 char buf[1024];
51 cs_log("label=%s", sidtab->label);
52 sprintf(buf, "caid(%d)=", sidtab->num_caid);
53 for (i=0; i<sidtab->num_caid; i++)
54 sprintf(buf+strlen(buf), "%04X ", sidtab->caid[i]);
55 cs_log("%s", buf);
56 sprintf(buf, "provider(%d)=", sidtab->num_provid);
57 for (i=0; i<sidtab->num_provid; i++)
58 sprintf(buf+strlen(buf), "%08X ", sidtab->provid[i]);
59 cs_log("%s", buf);
60 sprintf(buf, "services(%d)=", sidtab->num_srvid);
61 for (i=0; i<sidtab->num_srvid; i++)
62 sprintf(buf+strlen(buf), "%04X ", sidtab->srvid[i]);
63 cs_log("%s", buf);
64 }
65}
66#endif
67
68static void chk_iprange(char *value, struct s_ip **base)
69{
70 //int i;
71 char *ptr1, *ptr2;
72 struct s_ip *lip, *cip;
73
74 for (cip=lip=*base; cip; cip=cip->next)
75 lip=cip;
76 if (!(cip=malloc(sizeof(struct s_ip))))
77 {
78 fprintf(stderr, "Error allocating memory (errno=%d)\n", errno);
79 exit(1);
80 }
81 if (*base)
82 lip->next=cip;
83 else
84 *base=cip;
85
86 memset(cip, 0, sizeof(struct s_ip));
87 for (ptr1=strtok(value, ","); ptr1; ptr1=strtok(NULL, ","))
88 {
89 if( (ptr2=strchr(trim(ptr1), '-')) )
90 {
91 *ptr2++='\0';
92 cip->ip[0]=cs_inet_addr(trim(ptr1));
93 cip->ip[1]=cs_inet_addr(trim(ptr2));
94 }
95 else
96 cip->ip[0]=cip->ip[1]=cs_inet_addr(ptr1);
97 }
98}
99
100static void chk_caidtab(char *caidasc, CAIDTAB *ctab)
101{
102 int i;
103 char *ptr1, *ptr2, *ptr3;
104 for (i=0, ptr1=strtok(caidasc, ","); (i<CS_MAXCAIDTAB) && (ptr1); ptr1=strtok(NULL, ","))
105 {
106 ulong caid, mask, cmap;
107 if( (ptr3=strchr(trim(ptr1), ':')) )
108 *ptr3++='\0';
109 else
110 ptr3="";
111 if( (ptr2=strchr(trim(ptr1), '&')) )
112 *ptr2++='\0';
113 else
114 ptr2="";
115 if (((caid=a2i(ptr1, 2))|(mask=a2i(ptr2,-2))|(cmap=a2i(ptr3, 2))) < 0x10000)
116 {
117 ctab->caid[i]=caid;
118 ctab->mask[i]=mask;
119 ctab->cmap[i++]=cmap;
120 }
121// else
122// cs_log("WARNING: wrong CAID in %s -> ignored", cs_user);
123 }
124}
125
126static void chk_tuntab(char *tunasc, TUNTAB *ttab)
127{
128 int i;
129 char *ptr1, *ptr2, *ptr3;
130 for (i=0, ptr1=strtok(tunasc, ","); (i<CS_MAXTUNTAB) && (ptr1); ptr1=strtok(NULL, ","))
131 {
132 ulong bt_caidfrom, bt_caidto, bt_srvid;
133 if( (ptr3=strchr(trim(ptr1), ':')) )
134 *ptr3++='\0';
135 else
136 ptr3="";
137 if( (ptr2=strchr(trim(ptr1), '.')) )
138 *ptr2++='\0';
139 else
140 ptr2="";
141 if ((bt_caidfrom=a2i(ptr1, 2))|(bt_srvid=a2i(ptr2,-2))|(bt_caidto=a2i(ptr3, 2)))
142 {
143 ttab->bt_caidfrom[i]=bt_caidfrom;
144 ttab->bt_caidto[i]=bt_caidto;
145 ttab->bt_srvid[i++]=bt_srvid;
146 }
147// else
148// cs_log("WARNING: wrong Betatunnel in %s -> ignored", cs_user);
149 }
150}
151
152static void chk_services(char *labels, ulong *sidok, ulong *sidno)
153{
154 int i;
155 char *ptr;
156 SIDTAB *sidtab;
157 *sidok=*sidno=0;
158 for (ptr=strtok(labels, ","); ptr; ptr=strtok(NULL, ","))
159 for (trim(ptr), i=0, sidtab=cfg->sidtab; sidtab; sidtab=sidtab->next, i++)
160 {
161 if (!strcmp(sidtab->label, ptr)) *sidok|=(1<<i);
162 if ((ptr[0]=='!') && (!strcmp(sidtab->label, ptr+1))) *sidno|=(1<<i);
163 }
164}
165
166static
167void chk_ftab(char *zFilterAsc, FTAB *ftab, const char *zType, const char *zName,
168 const char *zFiltName)
169{
170 int i,j;
171 char *ptr1,*ptr2,*ptr3;
172 char *ptr[CS_MAXFILTERS] = {0};
173
174 memset(ftab, 0, sizeof(FTAB));
175 for( i=0, ptr1=strtok(zFilterAsc, ";"); (i<CS_MAXFILTERS) && (ptr1); ptr1=strtok(NULL, ";"), i++ )
176 {
177 //cs_log("ptr1=%s", ptr1);
178 ptr[i] = ptr1;
179 if( (ptr2=strchr(trim(ptr1), ':')) )
180 {
181 //cs_log("ptr2=%s", ptr2);
182 *ptr2++='\0';
183 //cs_log("ptr2=%s", ptr2);
184 ftab->filts[i].caid = (ushort)a2i(ptr1, 4);
185 //cs_log("caid=%04X", ftab->filts[i].caid);
186 ptr[i] = ptr2;
187 }
188 else if (zFiltName && zFiltName[0]=='c')
189 {
190 cs_log("PANIC: CAID field not found in CHID parameter!");
191 cs_exit(1);
192 }
193 ftab->nfilts++;
194 }
195
196 if( ftab->nfilts ) cs_debug("%s '%s' %s filter(s):", zType, zName, zFiltName);
197 for( i=0; i<ftab->nfilts; i++ )
198 {
199 cs_debug("CAID #%d: %04X", i, ftab->filts[i].caid);
200 for( j=0, ptr3=strtok(ptr[i], ","); (j<CS_MAXPROV) && (ptr3); ptr3=strtok(NULL, ","), j++ )
201 {
202 ftab->filts[i].prids[j] = a2i(ptr3,6);
203 ftab->filts[i].nprids++;
204 cs_debug("%s #%d: %06X", zFiltName, j, ftab->filts[i].prids[j]);
205 }
206 }
207 //cs_log("exit chk_ftab");
208}
209
210static void chk_cltab(char *classasc, CLASSTAB *clstab)
211{
212 int i;
213 char *ptr1;
214 for( i=0, ptr1=strtok(classasc, ","); (i<CS_MAXCAIDTAB) && (ptr1); ptr1=strtok(NULL, ",") )
215 {
216 ptr1=trim(ptr1);
217 if( ptr1[0] == '!' )
218 clstab->bclass[clstab->bn++] = (uchar)a2i(ptr1+1, 2);
219 else
220 clstab->aclass[clstab->an++] = (uchar)a2i(ptr1, 2);
221 }
222}
223
224static void chk_port_tab(char *portasc, PTAB *ptab)
225{
226 int i,j,nfilts,ifilt,iport;
227 char *ptr1,*ptr2,*ptr3;
228 char *ptr[CS_MAXPORTS] = {0};
229 int port[CS_MAXPORTS] = {0};
230 int previous_nports = ptab->nports;
231
232 for (nfilts=i=previous_nports, ptr1=strtok(portasc, ";"); (i<CS_MAXCAIDTAB) && (ptr1); ptr1=strtok(NULL, ";"), i++)
233 {
234 ptr[i] = ptr1;
235 if( (ptr2=strchr(trim(ptr1), '@')) )
236 {
237 *ptr2++='\0';
238 ptab->ports[i].s_port = atoi(ptr1);
239 ptr[i] = ptr2;
240 port[i] = ptab->ports[i].s_port;
241 ptab->nports++;
242 }
243 nfilts++;
244 }
245
246 if( nfilts==1 && strlen(portasc)<6 && ptab->ports[0].s_port == 0 ) {
247 ptab->ports[0].s_port = atoi(portasc);
248 ptab->nports = 1;
249 }
250
251 iport=ifilt = previous_nports;
252 for (i=previous_nports; i<nfilts; i++)
253 {
254 if( port[i]!=0 ) iport = i;
255 for (j=0, ptr3=strtok(ptr[i], ","); (j<CS_MAXPROV) && (ptr3); ptr3=strtok(NULL, ","), j++)
256 {
257 if( (ptr2=strchr(trim(ptr3), ':')) )
258 {
259 *ptr2++='\0';
260 ptab->ports[iport].ftab.nfilts++;
261 ifilt = ptab->ports[iport].ftab.nfilts-1;
262 ptab->ports[iport].ftab.filts[ifilt].caid = (ushort)a2i(ptr3, 4);
263 ptab->ports[iport].ftab.filts[ifilt].prids[j] = a2i(ptr2, 6);
264 } else {
265 ptab->ports[iport].ftab.filts[ifilt].prids[j] = a2i(ptr3, 6);
266 }
267 ptab->ports[iport].ftab.filts[ifilt].nprids++;
268 }
269 }
270}
271
272#ifdef NOTUSED
273static void chk_srvip(char *value, in_addr_t *ip)
274{
275 int i;
276 char *ptr;
277 for (i=0, ptr=strtok(value, ","); ptr; ptr=strtok(NULL, ","))
278 if (i<8) ip[i++]=inet_addr(ptr);
279}
280#endif
281
282static void chk_t_global(char *token, char *value)
283{
284 if (!strcmp(token, "serverip")) cfg->srvip=inet_addr(value);
285 if (!strcmp(token, "logfile")) strncpy(logfile, value, sizeof(logfile)-1);
286 if (!strcmp(token, "pidfile")) strncpy(cfg->pidfile, value, sizeof(cfg->pidfile)-1);
287 if (!strcmp(token, "usrfile")) strncpy(cfg->usrfile, value, sizeof(cfg->usrfile)-1);
288 if (!strcmp(token, "clienttimeout")) cfg->ctimeout=atoi(value);
289 if (!strcmp(token, "fallbacktimeout")) cfg->ftimeout=atoi(value);
290 if (!strcmp(token, "clientmaxidle")) cfg->cmaxidle=atoi(value);
291 if (!strcmp(token, "cachedelay")) cfg->delay=atoi(value);
292 if (!strcmp(token, "bindwait")) cfg->bindwait=atoi(value);
293 if (!strcmp(token, "netprio")) cfg->netprio=atoi(value);
294 if (!strcmp(token, "resolvedelay")) cfg->resolvedelay=atoi(value);
295 if (!strcmp(token, "sleep")) cfg->tosleep=atoi(value);
296 if (!strcmp(token, "unlockparental")) cfg->ulparent=atoi(value);
297 if (!strcmp(token, "nice"))
298 {
299 cfg->nice=atoi(value);
300 if ((cfg->nice<-20) || (cfg->nice>20)) cfg->nice=99;
301 if (cfg->nice!=99) cs_setpriority(cfg->nice); // ignore errors
302 }
303 if (!strcmp(token, "serialreadertimeout"))
304 {
305 cfg->srtimeout=atoi(value)*1000;
306 if( cfg->srtimeout <=0 )
307 cfg->srtimeout=1500;
308 }
309 if (!strcmp(token, "maxlogsize"))
310 {
311 cfg->max_log_size=atoi(value);
312 if( cfg->max_log_size <=10 )
313 cfg->max_log_size=10;
314 }
315 if( !strcmp(token, "showecmdw") )
316 cfg->show_ecm_dw = atoi(value);
317}
318
319#ifdef CS_ANTICASC
320static void chk_t_ac(char *token, char *value)
321{
322 if (!strcmp(token, "enabled"))
323 {
324 cfg->ac_enabled=atoi(value);
325 if( cfg->ac_enabled<=0 ) cfg->ac_enabled=0;
326 else cfg->ac_enabled=1;
327 }
328
329 if (!strcmp(token, "numusers"))
330 {
331 cfg->ac_users=atoi(value);
332 if( cfg->ac_users<0 ) cfg->ac_users=0;
333 }
334 if (!strcmp(token, "sampletime"))
335 {
336 cfg->ac_stime=atoi(value);
337 if( cfg->ac_stime<0 ) cfg->ac_stime=2;
338 }
339 if (!strcmp(token, "samples"))
340 {
341 cfg->ac_samples=atoi(value);
342 if( cfg->ac_samples<2 || cfg->ac_samples>10) cfg->ac_samples=10;
343 }
344 if (!strcmp(token, "penalty"))
345 {
346 cfg->ac_penalty=atoi(value);
347 if( cfg->ac_penalty<0 ) cfg->ac_penalty=0;
348
349 }
350 if (!strcmp(token, "aclogfile"))
351 strncpy(cfg->ac_logfile, value, sizeof(cfg->ac_logfile)-1);
352 if( !strcmp(token, "fakedelay") )
353 {
354 cfg->ac_fakedelay=atoi(value);
355 if( cfg->ac_fakedelay<100 || cfg->ac_fakedelay>1000 )
356 cfg->ac_fakedelay=1000;
357 }
358 if( !strcmp(token, "denysamples") )
359 {
360 cfg->ac_denysamples=atoi(value);
361 if( cfg->ac_denysamples<2 || cfg->ac_denysamples>cfg->ac_samples-1 )
362 cfg->ac_denysamples=cfg->ac_samples-1;
363 }
364#endif
365}
366
367static void chk_t_monitor(char *token, char *value)
368{
369 if (!strcmp(token, "port")) cfg->mon_port=atoi(value);
370 if (!strcmp(token, "serverip")) cfg->mon_srvip=inet_addr(value);
371 if (!strcmp(token, "nocrypt")) chk_iprange(value, &cfg->mon_allowed);
372 if (!strcmp(token, "aulow")) cfg->mon_aulow=atoi(value);
373 if (!strcmp(token, "monlevel")) cfg->mon_level=atoi(value);
374 if (!strcmp(token, "hideclient_to")) cfg->mon_hideclient_to=atoi(value);
375}
376
377static void chk_t_camd33(char *token, char *value)
378{
379 if (!strcmp(token, "port")) cfg->c33_port=atoi(value);
380 if (!strcmp(token, "serverip")) cfg->c33_srvip=inet_addr(value);
381 if (!strcmp(token, "nocrypt")) chk_iprange(value, &cfg->c33_plain);
382 if (!strcmp(token, "passive")) cfg->c33_passive=(value[0]!='0');
383 if (!strcmp(token, "key"))
384 {
385 if (key_atob(value, cfg->c33_key))
386 {
387 fprintf(stderr, "Configuration camd3.3x: Error in Key\n");
388 exit(1);
389 }
390 cfg->c33_crypted=1;
391 }
392}
393
394static void chk_t_camd35(char *token, char *value)
395{
396 if (!strcmp(token, "port")) cfg->c35_port=atoi(value);
397 if (!strcmp(token, "serverip")) cfg->c35_tcp_srvip=inet_addr(value);
398}
399
400static void chk_t_camd35_tcp(char *token, char *value)
401{
402 if (!strcmp(token, "port")) chk_port_tab(value, &cfg->c35_tcp_ptab);
403 if (!strcmp(token, "serverip")) cfg->c35_tcp_srvip=inet_addr(value);
404}
405
406static void chk_t_newcamd(char *token, char *value)
407{
408 if (!strcmp(token, "port")) chk_port_tab(value, &cfg->ncd_ptab);
409 if (!strcmp(token, "serverip")) cfg->ncd_srvip=inet_addr(value);
410 if (!strcmp(token, "key"))
411 {
412 if (key_atob14(value, cfg->ncd_key))
413 {
414 fprintf(stderr, "Configuration newcamd: Error in Key\n");
415 exit(1);
416 }
417 }
418
419}
420
421static void chk_t_radegast(char *token, char *value)
422{
423 if (!strcmp(token, "port")) cfg->rad_port=atoi(value);
424 if (!strcmp(token, "serverip")) cfg->rad_srvip=inet_addr(value);
425 if (!strcmp(token, "allowed")) chk_iprange(value, &cfg->rad_allowed);
426 if (!strcmp(token, "user")) strncpy(cfg->rad_usr, value, sizeof(cfg->rad_usr)-1);
427}
428
429static void chk_t_serial(char *token, char *value)
430{
431 if (!strcmp(token, "device"))
432 {
433 int l;
434 l=strlen(cfg->ser_device);
435 if (l) cfg->ser_device[l++]=1; // use ctrl-a as delimiter
436 strncpy(cfg->ser_device+l, value, sizeof(cfg->ser_device)-1-l);
437 }
438}
439
440static void chk_t_gbox(char *token, char *value)
441{
442// if (!strcmp(token, "password")) strncpy(cfg->gbox_pwd, i2b(4, a2i(value, 4)), 4);
443 if (!strcmp(token, "password")) cs_atob(cfg->gbox_pwd, value, 4);
444 if (!strcmp(token, "maxdist")) cfg->maxdist=atoi(value);
445 if (!strcmp(token, "ignorelist")) strncpy(cfg->ignorefile, value, sizeof(cfg->ignorefile)-1);
446 if (!strcmp(token, "onlineinfos")) strncpy(cfg->gbxShareOnl, value, sizeof(cfg->gbxShareOnl)-1);
447 if (!strcmp(token, "cardinfos")) strncpy(cfg->cardfile, value, sizeof(cfg->cardfile)-1);
448 if (!strcmp(token, "locals"))
449 {
450 char *ptr1;
451 int n=0, i;
452 for (i=0, ptr1=strtok(value, ","); (i<CS_MAXLOCALS) && (ptr1); ptr1=strtok(NULL, ","))
453 {
454 cfg->locals[n++]=a2i(ptr1, 8);
455 //printf("%i %08X",n,cfg->locals[n-1]);
456 }
457 cfg->num_locals=n;
458 }
459}
460
461static void chk_token(char *token, char *value, int tag)
462{
463 switch(tag)
464 {
465 case TAG_GLOBAL : chk_t_global(token, value); break;
466 case TAG_MONITOR : chk_t_monitor(token, value); break;
467 case TAG_CAMD33 : chk_t_camd33(token, value); break;
468 case TAG_CAMD35 :
469 case TAG_CS357X : chk_t_camd35(token, value); break;
470 case TAG_NEWCAMD : chk_t_newcamd(token, value); break;
471 case TAG_RADEGAST: chk_t_radegast(token, value); break;
472 case TAG_SERIAL : chk_t_serial(token, value); break;
473 case TAG_CS378X : chk_t_camd35_tcp(token, value); break;
474 case TAG_GBOX : chk_t_gbox(token, value); break;
475#ifdef CS_ANTICASC
476 case TAG_ANTICASC: chk_t_ac(token, value); break;
477#endif
478 }
479}
480
481void init_len4caid()
482{
483 int nr;
484 FILE *fp;
485 char *value;
486
487 memset(len4caid, 0, sizeof(ushort)<<8);
488 sprintf(token, "%s%s", cs_confdir, cs_l4ca);
489 if (!(fp=fopen(token, "r")))
490 return;
491 for(nr=0; fgets(token, sizeof(token), fp);)
492 {
493 int i, c;
494 char *ptr;
495 if (!(value=strchr(token, ':'))) continue;
496 *value++='\0';
497 if( (ptr=strchr(value, '#')) )
498 *ptr='\0';
499 if (strlen(trim(token))!=2) continue;
500 if (strlen(trim(value))!=4) continue;
501 if ((i=byte_atob(token))<0) continue;
502 if ((c=word_atob(value))<0) continue;
503//printf("idx %02X = %04X\n", i, c); fflush(stdout);
504 len4caid[i]=c;
505 nr++;
506 }
507 fclose(fp);
508 cs_log("%d lengths for caid guessing loaded", nr);
509 return;
510}
511
512int search_boxkey(ushort caid, ulong provid, char *key)
513{
514 int i, rc=0;
515 FILE *fp;
516 char c_caid[512];
517
518 sprintf(c_caid, "%s%s", cs_confdir, cs_cert);
519 if (fp=fopen(c_caid, "r"))
520 {
521 for (; (!rc) && fgets(c_caid, sizeof(c_caid), fp);)
522 {
523 char *c_provid, *c_key;
524 if (c_provid=strchr(c_caid, '#'))
525 *c_provid='\0';
526 if (!(c_provid=strchr(c_caid, ':'))) continue;
527 *c_provid++='\0';
528 if (!(c_key=strchr(c_provid, ':'))) continue;
529 *c_key++='\0';
530 if (word_atob(trim(c_caid))!=caid) continue;
531 if ((i=(strlen(trim(c_key))>>1))>256) continue;
532 if (cs_atob(key, c_key, i)<0)
533 {
534 cs_log("wrong key in \"%s\"", cs_cert);
535 continue;
536 }
537 rc=1;
538 }
539 fclose(fp);
540 }
541#ifdef OSCAM_INBUILD_KEYS
542 for(i=0; (!rc) && (npkey[i].keylen); i++)
543 if (rc=((caid==npkey[i].caid) && (provid==npkey[i].provid)))
544 memcpy(key, npkey[i].key, npkey[i].keylen);
545#endif
546 return(rc);
547}
548
549int init_config()
550{
551 int tag=TAG_GLOBAL;
552 FILE *fp;
553 char *value;
554
555#ifndef CS_EMBEDDED
556#ifdef PRIO_PROCESS
557 errno=0;
558 if ((cfg->nice=getpriority(PRIO_PROCESS, 0))==(-1))
559 if (errno)
560#endif
561#endif
562 cfg->nice=99;
563 cfg->ctimeout=CS_CLIENT_TIMEOUT;
564 cfg->ftimeout=2;
565 cfg->cmaxidle=CS_CLIENT_MAXIDLE;
566 cfg->delay=CS_DELAY;
567 cfg->bindwait=CS_BIND_TIMEOUT;
568 cfg->resolvedelay=CS_RESOLVE_DELAY;
569 cfg->mon_level=2;
570 cfg->mon_hideclient_to=0;
571 cfg->srtimeout=1500;
572 cfg->ulparent=0;
573#ifdef CS_ANTICASC
574 cfg->ac_enabled=0;
575 cfg->ac_users=0;
576 cfg->ac_stime=2;
577 cfg->ac_samples=10;
578 cfg->ac_denysamples=8;
579 cfg->ac_fakedelay=1000;
580 strcpy(cfg->ac_logfile, "./oscam_ac.log");
581#endif
582 sprintf(token, "%s%s", cs_confdir, cs_conf);
583 if (!(fp=fopen(token, "r")))
584 {
585 fprintf(stderr, "Cannot open config file '%s' (errno=%d)\n", token, errno);
586 exit(1);
587 }
588 while (fgets(token, sizeof(token), fp))
589 {
590 int i, l;
591 //void *ptr;
592 if ((l=strlen(trim(token)))<3) continue;
593 if ((token[0]=='[') && (token[l-1]==']'))
594 {
595 for (token[l-1]=0, tag=-1, i=TAG_GLOBAL; cctag[i]; i++)
596 if (!strcmp(cctag[i], strtolower(token+1)))
597 tag=i;
598 continue;
599 }
600 if (!(value=strchr(token, '='))) continue;
601 *value++='\0';
602 chk_token(trim(strtolower(token)), trim(value), tag);
603 }
604 fclose(fp);
605 cs_init_log(logfile);
606 if (cfg->ftimeout>=cfg->ctimeout)
607 {
608 cfg->ftimeout=cfg->ctimeout+1;
609 cs_log("WARNING: fallbacktimeout adjusted to %d", cfg->ftimeout);
610 }
611 if( cfg->ftimeout<(cfg->srtimeout/1000) )
612 {
613 cfg->ftimeout=(cfg->srtimeout/1000)+1;
614 cs_log("WARNING: fallbacktimeout adjusted to %d", cfg->ftimeout);
615 }
616 if( cfg->ctimeout<(cfg->srtimeout/1000) )
617 {
618 cfg->ctimeout=(cfg->srtimeout/1000)+1;
619 cs_log("WARNING: clienttimeout adjusted to %d", cfg->ctimeout);
620 }
621#ifdef CS_ANTICASC
622 if( cfg->ac_denysamples+1>cfg->ac_samples )
623 {
624 cfg->ac_denysamples=cfg->ac_samples-1;
625 cs_log("WARNING: DenySamples adjusted to %d", cfg->ac_denysamples);
626 }
627#endif
628 return 0;
629}
630
631static void chk_account(char *token, char *value, struct s_auth *account)
632{
633 int i;
634 char *ptr1;//, *ptr2;
635 if (!strcmp(token, "user")) strncpy(account->usr, value, sizeof(account->usr)-1);
636 if (!strcmp(token, "pwd")) strncpy(account->pwd, value, sizeof(account->pwd)-1);
637 if (!strcmp(token, "hostname")) strncpy(account->dyndns, value, sizeof(account->dyndns)-1);
638 if (!strcmp(token, "betatunnel")) chk_tuntab(value, &account->ttab);
639 if (!strcmp(token, "uniq")) account->uniq=atoi(value);
640 if (!strcmp(token, "sleep")) account->tosleep=atoi(value);
641 if (!strcmp(token, "monlevel")) account->monlvl=atoi(value);
642 if (!strcmp(token, "caid")) chk_caidtab(value, &account->ctab);
643 /*
644 * case insensitive
645 */
646 strtolower(value);
647 if (!strcmp(token, "au"))
648 for (i=0; i<CS_MAXREADER; i++)
649 if ((reader[i].label[0]) &&
650 (!strncmp(reader[i].label, value, strlen(reader[i].label))))
651 account->au=i;
652 if (!strcmp(token, "group"))
653 for (ptr1=strtok(value, ","); ptr1; ptr1=strtok(NULL, ","))
654 {
655 int g;
656 g=atoi(ptr1);
657 if ((g>0) && (g<33)) account->grp|=(1<<(g-1));
658 }
659 if(!strcmp(token, "services")) chk_services(value, &account->sidtabok, &account->sidtabno);
660 if(!strcmp(token, "ident")) chk_ftab(value, &account->ftab, "user", account->usr, "provid");
661 if(!strcmp(token, "class")) chk_cltab(value, &account->cltab);
662 if(!strcmp(token, "chid")) chk_ftab(value, &account->fchid, "user", account->usr, "chid");
663
664#ifdef CS_ANTICASC
665 if( !strcmp(token, "numusers") )
666 account->ac_users = atoi(value);
667 if( !strcmp(token, "penalty") )
668 account->ac_penalty = atoi(value);
669#endif
670
671// if (!strcmp(token, "caid"))
672// {
673// for (i=0, ptr1=strtok(value, ","); (i<CS_MAXCAIDTAB) && (ptr1); ptr1=strtok(NULL, ","))
674// {
675// ulong caid, mask;
676// if (ptr2=strchr(trim(ptr1), '&'))
677// *ptr2++='\0';
678// else
679// ptr2="";
680// if (((caid=a2i(ptr1, 2))|(mask=a2i(ptr2,-2))) < 0x10000)
681// {
682// account->caidtab[i][0]=caid;
683// account->caidtab[i++][1]=mask;
684// }
685// else
686// cs_log("WARNING: wrong CAID in %s -> ignored", cs_user);
687// }
688// }
689}
690
691int init_userdb()
692{
693 int tag=0, nr, nro;
694 //int first=1;
695 FILE *fp;
696 char *value;
697 struct s_auth *ptr;
698 /*static */struct s_auth *account=(struct s_auth *)0;
699
700 sprintf(token, "%s%s", cs_confdir, cs_user);
701 if (!(fp=fopen(token, "r")))
702 {
703 cs_log("Cannot open file \"%s\" (errno=%d)", token, errno);
704 return(1);
705 }
706 for (nro=0, ptr=cfg->account; ptr; nro++)
707 {
708 struct s_auth *ptr_next;
709 ptr_next=ptr->next;
710 free(ptr);
711 ptr=ptr_next;
712 }
713 nr=0;
714 while (fgets(token, sizeof(token), fp))
715 {
716 int i, l;
717 void *ptr;
718 if ((l=strlen(trim(token)))<3) continue;
719 if ((token[0]=='[') && (token[l-1]==']'))
720 {
721 token[l-1]=0;
722 tag=(!strcmp("account", strtolower(token+1)));
723 if (!(ptr=malloc(sizeof(struct s_auth))))
724 {
725 cs_log("Error allocating memory (errno=%d)", errno);
726 return(1);
727 }
728 if (account)
729 account->next=ptr;
730 else
731 cfg->account=ptr;
732 account=ptr;
733 memset(account, 0, sizeof(struct s_auth));
734 account->au=(-1);
735 account->monlvl=cfg->mon_level;
736 account->tosleep=cfg->tosleep;
737 for (i=1; i<CS_MAXCAIDTAB; account->ctab.mask[i++]=0xffff);
738 for (i=1; i<CS_MAXTUNTAB; account->ttab.bt_srvid[i++]=0x0000);
739 nr++;
740#ifdef CS_ANTICASC
741 account->ac_users=cfg->ac_users;
742 account->ac_penalty=cfg->ac_penalty;
743 account->ac_idx = nr;
744#endif
745 continue;
746 }
747 if (!tag) continue;
748 if (!(value=strchr(token, '='))) continue;
749 *value++='\0';
750 chk_account(trim(strtolower(token)), trim(value), account);
751 }
752 fclose(fp);
753 cs_log("userdb reloaded: %d accounts freed, %d accounts loaded", nro, nr);
754 return(0);
755}
756
757static ushort *chk_entry4sidtab(char *value, struct s_sidtab *sidtab, int what)
758{
759 int i, b;
760 char *ptr;
761 ushort *slist=(ushort *) 0;
762 ulong *llist=(ulong *) 0;
763 ulong caid;
764 char buf[512];
765 strncpy(buf, value, sizeof(buf));
766 b=(what==1) ? sizeof(ulong) : sizeof(ushort);
767 for (i=0, ptr=strtok(value, ","); ptr; ptr=strtok(NULL, ","))
768 {
769 caid=a2i(ptr, b);
770 if (!errno) i++;
771 }
772 if (!i) return(0);
773 if (b==sizeof(ushort))
774 slist=malloc(i*sizeof(ushort));
775 else
776 llist=malloc(i*sizeof(ulong));
777 strcpy(value, buf);
778 for (i=0, ptr=strtok(value, ","); ptr; ptr=strtok(NULL, ","))
779 {
780 caid=a2i(ptr, b);
781 if (errno) continue;
782 if (b==sizeof(ushort))
783 slist[i++]=(ushort) caid;
784 else
785 llist[i++]=caid;
786 }
787 switch (what)
788 {
789 case 0: sidtab->caid=slist;
790 sidtab->num_caid=i;
791 break;
792 case 1: sidtab->provid=llist;
793 sidtab->num_provid=i;
794 break;
795 case 2: sidtab->srvid=slist;
796 sidtab->num_srvid=i;
797 break;
798 }
799}
800
801static void chk_sidtab(char *token, char *value, struct s_sidtab *sidtab)
802{
803 if (!strcmp(token, "caid")) chk_entry4sidtab(value, sidtab, 0);
804 if (!strcmp(token, "provid")) chk_entry4sidtab(value, sidtab, 1);
805 if (!strcmp(token, "ident")) chk_entry4sidtab(value, sidtab, 1);
806 if (!strcmp(token, "srvid")) chk_entry4sidtab(value, sidtab, 2);
807}
808
809int init_sidtab()
810{
811 int tag=0, nr, nro;
812 FILE *fp;
813 char *value;
814 struct s_sidtab *ptr;
815 struct s_sidtab *sidtab=(struct s_sidtab *)0;
816
817 sprintf(token, "%s%s", cs_confdir, cs_sidt);
818 if (!(fp=fopen(token, "r")))
819 {
820 cs_log("Cannot open file \"%s\" (errno=%d)", token, errno);
821 return(1);
822 }
823 for (nro=0, ptr=cfg->sidtab; ptr; nro++)
824 {
825 struct s_sidtab *ptr_next;
826 ptr_next=ptr->next;
827 if (ptr->caid) free(ptr->caid);
828 if (ptr->provid) free(ptr->provid);
829 if (ptr->srvid) free(ptr->srvid);
830 free(ptr);
831 ptr=ptr_next;
832 }
833 nr=0;
834 while (fgets(token, sizeof(token), fp))
835 {
836 int i, l;
837 void *ptr;
838 if ((l=strlen(trim(token)))<3) continue;
839 if ((token[0]=='[') && (token[l-1]==']'))
840 {
841 token[l-1]=0;
842 if (!(ptr=malloc(sizeof(struct s_sidtab))))
843 {
844 cs_log("Error allocating memory (errno=%d)", errno);
845 return(1);
846 }
847 if (sidtab)
848 sidtab->next=ptr;
849 else
850 cfg->sidtab=ptr;
851 sidtab=ptr;
852 nr++;
853 memset(sidtab, 0, sizeof(struct s_sidtab));
854 strncpy(sidtab->label, strtolower(token+1), sizeof(sidtab->label));
855 continue;
856 }
857 if (!sidtab) continue;
858 if (!(value=strchr(token, '='))) continue;
859 *value++='\0';
860 chk_sidtab(trim(strtolower(token)), trim(strtolower(value)), sidtab);
861 }
862 fclose(fp);
863
864#ifdef DEBUG_SIDTAB
865 show_sidtab(cfg->sidtab);
866#endif
867 cs_log("services reloaded: %d services freed, %d services loaded", nro, nr);
868 return(0);
869}
870
871int init_srvid()
872{
873 int nr;
874 FILE *fp;
875 char *value;
876 static struct s_srvid *srvid=(struct s_srvid *)0;
877
878 sprintf(token, "%s%s", cs_confdir, cs_srid);
879 if (!(fp=fopen(token, "r")))
880 {
881 cs_log("can't open file \"%s\" (err=%d), no service-id's loaded",
882 token, errno);
883 return(0);
884 }
885 nr=0;
886 while (fgets(token, sizeof(token), fp))
887 {
888 int l;
889 void *ptr;
890 if ((l=strlen(trim(token)))<6) continue;
891 if (!(value=strchr(token, ':'))) continue;
892 *value++='\0';
893 if (strlen(token)!=4) continue;
894 if (!(ptr=malloc(sizeof(struct s_srvid))))
895 {
896 cs_log("Error allocating memory (errno=%d)", errno);
897 return(1);
898 }
899 if (srvid)
900 srvid->next=ptr;
901 else
902 cfg->srvid=ptr;
903 srvid=ptr;
904 memset(srvid, 0, sizeof(struct s_srvid));
905 srvid->srvid=word_atob(token);
906 strncpy(srvid->name, value, sizeof(srvid->name)-1);
907 nr++;
908 }
909 fclose(fp);
910 cs_log("%d service-id's loaded", nr);
911 return(0);
912}
913
914static void chk_reader(char *token, char *value, struct s_reader *rdr)
915{
916 int i;
917 char *ptr;
918 unsigned long tmp;
919 /*
920 * case sensitive first
921 */
922 if (!strcmp(token, "device"))
923 for (i=0, ptr=strtok(value, ","); (i<3)&&(ptr); ptr=strtok(NULL, ","), i++)
924 {
925 trim(ptr);
926 switch(i)
927 {
928 case 0: strncpy(rdr->device, ptr, sizeof(rdr->device)-1); break;
929 case 1: rdr->r_port=atoi(ptr); break;
930 case 2: rdr->l_port=atoi(ptr); break;
931 }
932 }
933 if (!strcmp(token, "key"))
934 {
935 if (key_atob14(value, rdr->ncd_key))
936 {
937 fprintf(stderr, "Configuration newcamd: Error in Key\n");
938 exit(1);
939 }
940 }
941 if (!strcmp(token, "password")) strncpy(rdr->gbox_pwd, i2b(4, a2i(value, 4)), 4);
942 if (!strcmp(token, "premium")) rdr->gbox_prem=1;
943 if (!strcmp(token, "account"))
944 for (i=0, ptr=strtok(value, ","); (i<2)&&(ptr); ptr=strtok(NULL, ","), i++)
945 {
946 trim(ptr);
947 switch(i)
948 {
949 case 0: strncpy(rdr->r_usr, ptr, sizeof(rdr->r_usr)-1); break;
950 case 1: strncpy(rdr->r_pwd, ptr, sizeof(rdr->r_pwd)-1); break;
951 }
952 }
953 if( !strcmp(token, "pincode") )
954 strncpy(rdr->pincode, value, sizeof(rdr->pincode)-1);
955 /*
956 * case insensitive
957 */
958 strtolower(value);
959
960 if (!strcmp(token, "services")) chk_services(value, &rdr->sidtabok, &rdr->sidtabno);
961 if (!strcmp(token, "inactivitytimeout")) rdr->tcp_ito = atoi(value);
962 if (!strcmp(token, "reconnecttimeout")) rdr->tcp_rto = atoi(value);
963 if (!strcmp(token, "disableserverfilter")) rdr->ncd_disable_server_filt = atoi(value);
964
965 if (!strcmp(token, "label")) strncpy(rdr->label, value, sizeof(rdr->label)-1);
966 if (!strcmp(token, "fallback")) rdr->fallback=atoi(value) ? 1 : 0;
967 if (!strcmp(token, "logport")) rdr->log_port=atoi(value);
968 if (!strcmp(token, "caid")) chk_caidtab(value, &rdr->ctab);
969 if (!strcmp(token, "detect"))
970 for (i=0; RDR_CD_TXT[i]; i++)
971 {
972 if (!strcmp(value, RDR_CD_TXT[i]))
973 rdr->detect=i;
974 else
975 if ((value[0]=='!') && (!strcmp(value+1, RDR_CD_TXT[i])))
976 rdr->detect=i|0x80;
977 }
978 if (!strcmp(token, "mhz"))
979 {
980 if (!strcmp(value, "600")) rdr->mhz=600;
981 if (!strcmp(value, "357")) rdr->mhz=357;
982 if (!strcmp(value, "358")) rdr->mhz=358;
983 }
984 if (!strcmp(token, "customspeed"))
985 {
986 if (!strcmp(value, "0")) rdr->custom_speed=0;
987 if (!strcmp(value, "1"))rdr->custom_speed=1;
988 }
989 if (!strcmp(token, "protocol"))
990 {
991 if (!strcmp(value, "mouse")) rdr->typ=R_MOUSE;
992 if (!strcmp(value, "internal")) rdr->typ=R_INTERN;
993 if (!strcmp(value, "intern")) rdr->typ=R_INTERN;
994 if (!strcmp(value, "serial")) rdr->typ=R_SERIAL;
995 if (!strcmp(value, "camd35")) rdr->typ=R_CAMD35;
996 if (!strcmp(value, "cs378x")) rdr->typ=R_CS378X;
997 if (!strcmp(value, "cs357x")) rdr->typ=R_CAMD35;
998 if (!strcmp(value, "gbox")) rdr->typ=R_GBOX;
999 if (!strcmp(value, "newcamd") ||
1000 !strcmp(value, "newcamd525")) {rdr->typ=R_NEWCAMD;
1001 rdr->ncd_proto=NCD_525;}
1002 if (!strcmp(value, "newcamd524")) {rdr->typ=R_NEWCAMD;
1003 rdr->ncd_proto=NCD_524;}
1004 }
1005 if (!strcmp(token, "ident")) chk_ftab(value, &rdr->ftab,"reader",rdr->label,"provid");
1006 if (!strcmp(token, "class")) chk_cltab(value, &rdr->cltab);
1007 if (!strcmp(token, "chid")) chk_ftab(value, &rdr->fchid,"reader",rdr->label,"chid");
1008 if (!strcmp(token, "showcls")) rdr->show_cls = atoi(value);
1009 if (!strcmp(token, "maxqlen")) rdr->maxqlen = atoi(value);
1010 if( rdr->maxqlen<0 || rdr->maxqlen>CS_MAXQLEN ) rdr->maxqlen=CS_MAXQLEN;
1011
1012 if (!strcmp(token, "group"))
1013 for (ptr=strtok(value, ","); ptr; ptr=strtok(NULL, ","))
1014 {
1015 int g;
1016 g=atoi(ptr);
1017 if ((g>0) && (g<33)) rdr->grp|=(1<<(g-1));
1018 }
1019 if (!strcmp(token, "emmcache"))
1020 for (i=0, ptr=strtok(value, ","); (i<3)&&(ptr); ptr=strtok(NULL, ","), i++)
1021 switch(i)
1022 {
1023 case 0: rdr->cachemm=atoi(ptr); break;
1024 case 1: rdr->rewritemm=atoi(ptr); break;
1025 case 2: rdr->logemm=atoi(ptr); break;
1026 }
1027 if (!strcmp(token, "blocknano"))
1028 for (ptr=strtok(value, ","); ptr; ptr=strtok(NULL, ","))
1029 if ((i=byte_atob(ptr))>=0)
1030 rdr->b_nano[i]=1;
1031}
1032
1033int init_readerdb()
1034{
1035 int tag=0, nr;
1036 FILE *fp;
1037 char *value;
1038
1039 sprintf(token, "%s%s", cs_confdir, cs_srvr);
1040 if (!(fp=fopen(token, "r")))
1041 {
1042 cs_log("can't open file \"%s\" (errno=%d)\n", token, errno);
1043 return(1);
1044 }
1045 nr=0;
1046 while (fgets(token, sizeof(token), fp))
1047 {
1048 int i, l;
1049 if ((l=strlen(trim(token)))<3) continue;
1050 if ((token[0]=='[') && (token[l-1]==']'))
1051 {
1052 token[l-1]=0;
1053 tag=(!strcmp("reader", strtolower(token+1)));
1054 if (reader[nr].label[0] && reader[nr].typ) nr++;
1055 memset(&reader[nr], 0, sizeof(struct s_reader));
1056 reader[nr].tcp_rto = 30;
1057 reader[nr].show_cls = 10;
1058 reader[nr].maxqlen = CS_MAXQLEN;
1059 reader[nr].mhz = 357;
1060 reader[nr].custom_speed = 1;
1061 strcpy(reader[nr].pincode, "none");
1062 for (i=1; i<CS_MAXCAIDTAB; reader[nr].ctab.mask[i++]=0xffff);
1063 continue;
1064 }
1065 if (!tag) continue;
1066 if (!(value=strchr(token, '='))) continue;
1067 *value++='\0';
1068 chk_reader(trim(strtolower(token)), trim(value), &reader[nr]);
1069 }
1070 fclose(fp);
1071 return(0);
1072}
1073
1074/*
1075int init_irdeto_guess_tab()
1076{
1077 int i, j, skip;
1078 int b47;
1079 FILE *fp;
1080 char token[128], *value, *ptr;
1081 char zSid[5];
1082 uchar b3;
1083 ushort caid, sid;
1084 struct s_irdeto_quess *ird_row, *head;
1085
1086 memset(cfg->itab, 0, sizeof(cfg->itab));
1087 sprintf(token, "%s%s", cs_confdir, cs_ird);
1088 if (!(fp=fopen(token, "r")))
1089 {
1090 cs_log("can't open file \"%s\" (errno=%d) irdeto guessing not loaded",
1091 token, errno);
1092 return(1);
1093 }
1094 while (fgets(token, sizeof(token), fp))
1095 {
1096 if( strlen(token)<20 ) continue;
1097 for( i=b3=b47=caid=sid=skip=0, ptr=strtok(token, ":"); (i<4)&&(ptr); ptr=strtok(NULL, ":"), i++ )
1098 {
1099 trim(ptr);
1100 if( *ptr==';' || *ptr=='#' || *ptr=='-' ) {
1101 skip=1;
1102 break;
1103 }
1104 switch(i)
1105 {
1106 case 0: b3 = a2i(ptr, 2); break;
1107 case 1: b47 = a2i(ptr, 8); break;
1108 case 2: caid = a2i(ptr, 4); break;
1109 case 3:
1110 for( j=0; j<4; j++ )
1111 zSid[j]=ptr[j];
1112 zSid[4]=0;
1113 sid = a2i(zSid, 4);
1114 break;
1115 }
1116 }
1117 if( !skip )
1118 {
1119 if (!(ird_row=(struct s_irdeto_quess*)malloc(sizeof(struct s_irdeto_quess))))
1120 {
1121 cs_log("Error allocating memory (errno=%d)", errno);
1122 return;
1123 }
1124 ird_row->b47 = b47;
1125 ird_row->caid = caid;
1126 ird_row->sid = sid;
1127 ird_row->next = 0;
1128
1129 head = cfg->itab[b3];
1130 if( head ) {
1131 while( head->next )
1132 head=head->next;
1133 head->next=ird_row;
1134 }
1135 else
1136 cfg->itab[b3]=ird_row;
1137
1138 //cs_debug("%02X:%08X:%04X:%04X", b3, b47, caid, sid);
1139 }
1140 }
1141 fclose(fp);
1142
1143 for( i=0; i<0xff; i++ )
1144 {
1145 head=cfg->itab[i];
1146 while(head)
1147 {
1148 cs_debug("itab[%02X]: b47=%08X, caid=%04X, sid=%04X",
1149 i, head->b47, head->caid, head->sid);
1150 head=head->next;
1151 }
1152 }
1153 return(0);
1154}
1155*/
1156
1157#ifdef CS_ANTICASC
1158void init_ac()
1159{
1160 int nr;
1161 FILE *fp;
1162 //char *value;
1163
1164 sprintf(token, "%s%s", cs_confdir, cs_ac);
1165 if (!(fp=fopen(token, "r")))
1166 {
1167 cs_log("can't open file \"%s\" (errno=%d) anti-cascading table not loaded",
1168 token, errno);
1169 return;
1170 }
1171
1172 for(nr=0; fgets(token, sizeof(token), fp);)
1173 {
1174 int i, skip;
1175 ushort caid, sid, chid, dwtime;
1176 ulong provid;
1177 char *ptr, *ptr1;
1178 struct s_cpmap *ptr_cpmap;
1179 static struct s_cpmap *cpmap=(struct s_cpmap *)0;
1180
1181 if( strlen(token)<4 ) continue;
1182
1183 caid=sid=chid=dwtime=0;
1184 provid=0;
1185 skip=0;
1186 ptr1=0;
1187 for( i=0, ptr=strtok(token, "="); (i<2)&&(ptr); ptr=strtok(NULL, "="), i++ )
1188 {
1189 trim(ptr);
1190 if( *ptr==';' || *ptr=='#' || *ptr=='-' ) {
1191 skip=1;
1192 break;
1193 }
1194 switch( i )
1195 {
1196 case 0:
1197 ptr1=ptr;
1198 break;
1199 case 1:
1200 dwtime = atoi(ptr);
1201 break;
1202 }
1203 }
1204
1205 if( !skip )
1206 {
1207 for( i=0, ptr=strtok(ptr1, ":"); (i<4)&&(ptr); ptr=strtok(NULL, ":"), i++ )
1208 {
1209 trim(ptr);
1210 switch( i )
1211 {
1212 case 0:
1213 if( *ptr=='*' ) caid = 0;
1214 else caid = a2i(ptr, 4);
1215 break;
1216 case 1:
1217 if( *ptr=='*' ) provid = 0;
1218 else provid = a2i(ptr, 6);
1219 break;
1220 case 2:
1221 if( *ptr=='*' ) sid = 0;
1222 else sid = a2i(ptr, 4);
1223 break;
1224 case 3:
1225 if( *ptr=='*' ) chid = 0;
1226 else chid = a2i(ptr, 4);
1227 break;
1228 }
1229 }
1230 if (!(ptr_cpmap=(struct s_cpmap*)malloc(sizeof(struct s_cpmap))))
1231 {
1232 cs_log("Error allocating memory (errno=%d)", errno);
1233 return;
1234 }
1235 if( cpmap )
1236 cpmap->next=ptr_cpmap;
1237 else
1238 cfg->cpmap=ptr_cpmap;
1239 cpmap=ptr_cpmap;
1240
1241 cpmap->caid = caid;
1242 cpmap->provid = provid;
1243 cpmap->sid = sid;
1244 cpmap->chid = chid;
1245 cpmap->dwtime = dwtime;
1246 cpmap->next = 0;
1247
1248 cs_debug("nr=%d, caid=%04X, provid=%06X, sid=%04X, chid=%04X, dwtime=%d",
1249 nr, caid, provid, sid, chid, dwtime);
1250 nr++;
1251 }
1252 }
1253 fclose(fp);
1254 //cs_log("%d lengths for caid guessing loaded", nr);
1255 return;
1256}
1257#endif
Note: See TracBrowser for help on using the repository browser.