Changeset 4331
- Timestamp:
- 01/05/11 21:58:47 (13 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/globals.h
r4329 r4331 1264 1264 extern void create_rand_str(char *dst, int size); 1265 1265 #endif 1266 extern void sidtabbits2bitchar(SIDTABBITS value, char *result); 1267 extern void long2bitchar(long value, char *result); 1268 extern void uint642bitchar(uint64 value, char *result); 1266 extern void uint64ToBitchar(uint64 value, int size, char *result); 1269 1267 extern int file_exists(const char * filename); 1270 1268 extern void clear_sip(struct s_ip **sip); -
trunk/oscam-config.c
r4329 r4331 2199 2199 if ((account->sidtabok + account->sidtabno > 0) || ((account->sidtabok + account->sidtabno == 0) && cfg->http_full_cfg)) { 2200 2200 fprintf_conf(f, CONFVARWIDTH, "services", ""); 2201 char sidok[MAX_SIDBITS+1]; sidtabbits2bitchar(account->sidtabok,sidok);2202 char sidno[MAX_SIDBITS+1]; sidtabbits2bitchar(account->sidtabno,sidno);2201 char sidok[MAX_SIDBITS+1]; uint64ToBitchar((uint64)account->sidtabok, MAX_SIDBITS, sidok); 2202 char sidno[MAX_SIDBITS+1]; uint64ToBitchar((uint64)account->sidtabno, MAX_SIDBITS, sidno); 2203 2203 struct s_sidtab *sidtab = cfg->sidtab; 2204 2204 i=0; dot = ""; … … 2346 2346 2347 2347 fprintf_conf(f, CONFVARWIDTH, "services", ""); 2348 char sidok[MAX_SIDBITS+1]; sidtabbits2bitchar(rdr->sidtabok, sidok);2349 char sidno[MAX_SIDBITS+1]; sidtabbits2bitchar(rdr->sidtabno, sidno);2348 char sidok[MAX_SIDBITS+1]; uint64ToBitchar((uint64)rdr->sidtabok, MAX_SIDBITS, sidok); 2349 char sidno[MAX_SIDBITS+1]; uint64ToBitchar((uint64)rdr->sidtabno, MAX_SIDBITS, sidno); 2350 2350 struct s_sidtab *sidtab = cfg->sidtab; 2351 2351 j=0; dot = ""; … … 4232 4232 int i = 0, needed = 1, pos = 0, dot = 0; 4233 4233 char grpbit[65]; 4234 uint64 2bitchar(grp, grpbit);4234 uint64ToBitchar(grp, 64, grpbit); 4235 4235 4236 4236 for(i = 0; i < 64; i++){ -
trunk/oscam-http-helpers.c
r4313 r4331 156 156 157 157 if(strlen(cfg->http_tpl) > 0){ 158 char path[2 00];159 if(strlen(tpl_getTplPath(name, cfg->http_tpl, path, 2 00)) > 0 && file_exists(path)){158 char path[255]; 159 if(strlen(tpl_getTplPath(name, cfg->http_tpl, path, 255)) > 0 && file_exists(path)){ 160 160 FILE *fp; 161 161 char buffer[1024]; -
trunk/oscam-http.c
r4330 r4331 979 979 //services 980 980 char sidok[MAX_SIDBITS+1]; 981 sidtabbits2bitchar(rdr->sidtabok, sidok);981 uint64ToBitchar((uint64)rdr->sidtabok, MAX_SIDBITS, sidok); 982 982 char sidno[MAX_SIDBITS+1]; 983 sidtabbits2bitchar(rdr->sidtabno,sidno);983 uint64ToBitchar((uint64)rdr->sidtabno,MAX_SIDBITS, sidno); 984 984 struct s_sidtab *sidtab = cfg->sidtab; 985 985 //build matrix … … 1488 1488 //services - first we have to move the long sidtabok/sidtabno to a binary array 1489 1489 char sidok[MAX_SIDBITS+1]; 1490 sidtabbits2bitchar(account->sidtabok,sidok);1490 uint64ToBitchar((uint64)account->sidtabok, MAX_SIDBITS, sidok); 1491 1491 char sidno[MAX_SIDBITS+1]; 1492 sidtabbits2bitchar(account->sidtabno,sidno);1492 uint64ToBitchar((uint64)account->sidtabno, MAX_SIDBITS, sidno); 1493 1493 struct s_sidtab *sidtab = cfg->sidtab; 1494 1494 //build matrix … … 1799 1799 if (rcc && rcc->cards) { 1800 1800 pthread_mutex_lock(&rcc->cards_busy); 1801 char *buf = malloc(4000);1801 char buf[4000]; 1802 1802 uint8 serbuf[8]; 1803 1803 … … 1915 1915 1916 1916 ll_iter_release(it); 1917 free(buf);1917 1918 1918 pthread_mutex_unlock(&rcc->cards_busy); 1919 1919 -
trunk/oscam-simples.c
r4309 r4331 627 627 /* Encode values in a http url. Note: Be sure to free() the returned string after use */ 628 628 char *urlencode(char *str){ 629 char *pstr = str, *buf = (char *) malloc((strlen(str) * 3 + 1) * sizeof(char)), *pbuf = buf; 629 char buf[strlen(str) * 3 + 1]; 630 char *pstr = str, *pbuf = buf; 630 631 while (*pstr) { 631 632 if (isalnum(*pstr) || *pstr == '-' || *pstr == '_' || *pstr == '.' || *pstr == '~') *pbuf++ = *pstr; … … 641 642 pbuf = (char *) malloc((strlen(buf) + 1) * sizeof(char)); 642 643 strcpy(pbuf, buf); 643 free(buf);644 644 return pbuf; 645 645 } … … 672 672 #endif 673 673 674 /* Converts a long64 value to a char array in bitwise representation. 675 Note that the result array MUST be at least 65 bit large and that 676 this function assumes long values to hold only values up to 64bits and to be positive! 677 the result of e.g. long 7 is 1110000000000000000000000000000000000000000000000000000000000000 this means the array 678 is reversed */ 679 void sidtabbits2bitchar(SIDTABBITS value, char *result){ 674 /* Converts a uint64 value (you may also cast smaller types) to a char array in bitwise representation. 675 Note that the result array MUST be at least size+1 bit large and that this function assumes values 676 to be only positive! The result of e.g. uint64 7 is 677 11100000000000000000000000000000000000000000000000000000000000000 this means the array is reversed */ 678 void uint64ToBitchar(uint64 value, int size, char *result){ 680 679 int pos; 681 for (pos=0;pos< MAX_SIDBITS;pos++) result[pos]='0';680 for (pos=0;pos<size;pos++) result[pos]='0'; 682 681 result[pos] = '\0'; 683 682 684 683 pos=0; 685 while (value > 0 && pos < MAX_SIDBITS){ 686 if(value % 2 == 1) result[pos]='1'; 687 else result[pos]='0'; 688 value=value / (SIDTABBITS)2; 689 pos++; 690 } 691 } 692 693 694 /* Converts a long value to a char array in bitwise representation. 695 Note that the result array MUST be at least 33 bit large and that 696 this function assumes long values to hold only values up to 32bits and to be positive! 697 the result of e.g. long 7 is 11100000000000000000000000000000 this means the array 698 is reversed */ 699 void long2bitchar(long value, char *result){ 700 int pos; 701 for (pos=0;pos<32;pos++) result[pos]='0'; 702 result[pos] = '\0'; 703 704 pos=0; 705 while (value > 0 && pos < 32){ 706 if(value % 2 == 1) result[pos]='1'; 707 else result[pos]='0'; 708 value=value / 2; 709 pos++; 710 } 711 } 712 713 /* Converts a uint64 value to a char array in bitwise representation. 714 Note that the result array MUST be at least 65 bit large and that 715 this function assumes long values to hold only values up to 64bits and to be positive! 716 the result of e.g. long 7 is 11100000000000000000000000000000000000000000000000000000000000000 this means the array 717 is reversed */ 718 void uint642bitchar(uint64 value, char *result){ 719 int pos; 720 for (pos=0;pos<64;pos++) result[pos]='0'; 721 result[pos] = '\0'; 722 723 pos=0; 724 while (value > 0 && pos < 64){ 684 while (value > 0 && pos < size){ 725 685 if(value % 2 == 1) result[pos]='1'; 726 686 else result[pos]='0';
Note:
See TracChangeset
for help on using the changeset viewer.