ostream& ostream::operator<<(const unsigned i) { wchar_t buf[10] = {0}; sztoa(i, buf, iosbase); if(minIntDigits) { if(minIntDigits>9) minIntDigits = 9; register unsigned n = 0; while(buf[n]) n++; //unsigned orgSize = n; unsigned zeros = 0; while(n<minIntDigits) { zeros++; n++; } n=0; char tmp[10] = {0}; for(register int x = 0;x<10;x++) { tmp[x] = buf[x]; } for(register int y = 0;y<10;y++) { buf[y] = 0; } while(n<zeros) { buf[n] = '0'; n++; } for(register int z = 0;z<10;z++) { if(!tmp[z]) break; buf[z+zeros] = tmp[z]; /*if((z+zeros)==9) //should be impossible break;*/ } } if(iosbase == BS_HEX) printfunc(L"0x"); else if(iosbase == BS_OCTAL) printfunc(L"0o"); else if(iosbase == BS_BINARY) printfunc(L"0b"); printfunc(buf); return *this; }
ostream& ostream::operator<<(const wchar_t c) { wchar_t buf[2] = {0}; buf[0] = c; printfunc(buf); return *this; }
ostream& ostream::operator<<(const wchar_t* str) { //char* string = new char[strlen(str)+1]; //convertASCII(string,(wchar_t*)str); printfunc(str); return *this; }
ostream& ostream::operator<<(const char* str) { wchar_t* string = new wchar_t[strlen(str) + 1]; convertUnicode(string, str); printfunc(string); delete[] string; return *this; }
int main(int argc, char argv[]) { static unsigned char array[5] = {0x00, 0x01, 0x02, 0x03, 0x04}; printfunc(&array[1]); return 0; }
void Node::suggest(string localStr, int posistion , class Node *root) { if( (localStr != root->NodeStr) && (root->ptrs[localStr[posistion]] != NULL ) ) { suggest(localStr,posistion+1,root->ptrs[localStr[posistion]]); } else { printfunc(root); } }
ostream& ostream::operator<<(const int i) { unsigned val = 0; val = ((unsigned)i); if(i<0) { val = 0-i; printfunc(L"-"); } this->operator<<(val); return *this; }
int main(int argc, char** argv) { unsigned long func = -1; long sz; int i = 0; FILE* f; int findex = 1; // Argv index of file. const char **func_table = bg_intrinsic_table; int funsize = bg_intrinsic_size; if(argc<2) { fprintf(stderr, "Usage\n%s [-s] usecode_file [func_num]\n", argv[0]); return -1; } // Serpent Isle? if (strcmp(argv[1], "-s") == 0) { findex++; func_table = si_intrinsic_table; funsize = si_intrinsic_size; } f = fopen(argv[findex], "rb"); if( f == NULL ) { fprintf(stderr,"Failed to open %s\n\n", argv[findex]); return 0; } fseek(f, 0, SEEK_END); sz = ftell(f); fseek(f, 0, SEEK_SET); if( argc > findex + 1 ) { char* stopstr; if (strcmp(argv[findex + 1], "-a") == 0) func = -2; // Print ALL functions. else func = strtoul(argv[findex + 1], &stopstr, 16); } while( ftell(f) < sz ) { printfunc(f, func, i, func_table, funsize); i++; } if( func == -1 ) { if( ftell(f) != sz ) fprintf(stderr,"Problem, tell = %ld!\n", ftell(f)); printf("Functions: %d\n", i); } fclose(f); return 0; }
void printfunc(char *offstr,char *start) { unsigned int p;char *newstr; while(*offstr != 0) { if( ((*offstr) & ((uint8_t)0xC0)) ) { newstr = start + ((ntohs(*((uint16_t*)(offstr)))) & (uint16_t)0x3fff) ; printfunc(newstr,start); return; } for(p=0;p<(uint8_t)*offstr;p++) printf("%c",*(offstr+p+1)); printf("."); offstr+=*offstr+1; } }
/*! @brief Print contents of a pointer. @ingroup print_high @param ptr Pointer to Vars object. @param fp Stream. */ void v_print(void *ptr, FILE *fp) { void (*func)(void *ptr, FILE *fp); char *key, buf[V_HEXSTRING_SIZE]; vtype *type; v_print_start(); if (ptr != NULL) key = vh_pkey_buf(ptr, buf); if (ptr == NULL) { fprintf(fp, "NULL\n"); } else if (vh_exists(visited, key)) { fprintf(fp, "REUSED ADDRESS"); if (printaddr) fprintf(fp, " (%s)", v_hexstring(ptr, NULL)); fprintf(fp, "\n"); } else { vh_istore(visited, key, 1); type = v_type(ptr); if (type != NULL && !v_unknown(ptr)) { if (type->print != NULL) type->print(ptr, fp); else v_print_type(type, ptr, fp); } else if (print_funcs != NULL) { /*@-type@*/ if ((func = vh_pget(print_funcs, key)) != NULL) func(ptr, fp); /*@=type@*/ } else if (printfunc != NULL) { printfunc(ptr, fp); } else { fprintf(fp, "UNKNOWN"); if (printaddr) fprintf(fp, " (%s)", v_hexstring(ptr, NULL)); fprintf(fp, "\n"); } } v_print_finish(); }
void Node::printfunc(class Node *root) { //cout<<"\nprintfunc"; for(int i = 0; i < 256 ; i++) { if(root->ptrs[i] != NULL) { printfunc(root->ptrs[i]); } } if( root->NodeStr!= "") cout<<"------------------------------------>"<<root->NodeStr<<endl; }
int main(int argc, char *argv[]) { Testcase *t; int seed; if(argc == 1) seed = getseed(); else seed = strtoul(argv[1], 0, 10); printf("/* seed %u */\n", seed); srand(seed); t = randtestcase(); printf("void abort(void);\n"); printfunc(t); printmain(t); return 0; }
int main(int argc, char** argv) { unsigned long func = -1; long sz; int i = 0; FILE* f; if(argc<2) { fprintf(stderr, "Usage\n%s usecode_file [func_num]\n", argv[0]); return -1; } f = fopen(argv[1], "rb"); if( f == NULL ) { fprintf(stderr,"Failed to open %s\n\n", argv[1]); return 0; } fseek(f, 0, SEEK_END); sz = ftell(f); fseek(f, 0, SEEK_SET); if( argc > 2 ) { char* stopstr; func = strtoul(argv[2], &stopstr, 16); } while( ftell(f) < sz ) { printfunc(f, func, i); i++; } if( func == -1 ) { if( ftell(f) != sz ) fprintf(stderr,"Problem, tell = %d!\n", ftell(f)); printf("Functions: %d\n", i); } fclose(f); return 0; }
int main(int argc, char **argv) { int ii, jj; if(argc < 7) { printf("Usage: %s xsize ysize fill (r1 r2 count)+\n", argv[0]); return 1; } size_x = atoi(argv[1]); size_y = atoi(argv[2]); fillprob = atoi(argv[3]); generations = (argc-4)/3; printf("gen: %d, %d\n",argc,generations); params = params_set = (generation_params*)malloc( sizeof(generation_params) * generations ); for(ii=4; ii+2<argc; ii+=3) { params->r1_cutoff = atoi(argv[ii]); params->r2_cutoff = atoi(argv[ii+1]); params->reps = atoi(argv[ii+2]); params++; } srand(time(NULL)); initmap(); for(ii=0; ii<generations; ii++) { params = ¶ms_set[ii]; for(jj=0; jj<params->reps; jj++) generation(); } printfunc(); printmap(); return 0; }
static void yasm_list_one_module(yasm_module_type type, void *data, void (*printfunc) (const char *name, const char *keyword)) { yasm_arch_module *arch; yasm_dbgfmt_module *dbgfmt; yasm_objfmt_module *objfmt; yasm_listfmt_module *listfmt; yasm_parser_module *parser; yasm_preproc_module *preproc; switch (type) { case YASM_MODULE_ARCH: arch = data; printfunc(arch->name, arch->keyword); break; case YASM_MODULE_DBGFMT: dbgfmt = data; printfunc(dbgfmt->name, dbgfmt->keyword); break; case YASM_MODULE_OBJFMT: objfmt = data; printfunc(objfmt->name, objfmt->keyword); break; case YASM_MODULE_LISTFMT: listfmt = data; printfunc(listfmt->name, listfmt->keyword); break; case YASM_MODULE_PARSER: parser = data; printfunc(parser->name, parser->keyword); break; case YASM_MODULE_PREPROC: preproc = data; printfunc(preproc->name, preproc->keyword); break; } }
char* printAnswerSection(char* recv,int answer_offset) { //RR* recv+=answer_offset; char* start =recv; uint16_t id = ntohs(*((uint16_t*)recv)); recv+=2; //printf("Id : %d\n",id ); uint16_t param = ntohs(*((uint16_t*)recv)); recv+=2; //printf("%d\n",param ); uint16_t noques = ntohs(*((uint16_t*)recv)); recv+=2; //printf("No ques %d\n", noques); uint16_t noans = ntohs(*((uint16_t*)recv)); printf("No of answer records: %d\n",noans); recv+=2; uint16_t noauth = ntohs(*((uint16_t*)recv)); printf("No of authority seciton records %d\n", noauth); recv+=2; uint16_t noadd = ntohs(*((uint16_t*)recv)); printf("No of additional seciton records %d\n", noadd); char* ans = start+answer_offset; char* addr_ptr=NULL; int i,p; printf("ANSWER SECTION\n"); for(i=0;i<noans;i++) { char* offstr; int flag; printf("Owner Name: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; uint16_t type = ntohs(*((uint16_t*)ans)); ans+=2; printf("TYPE: %d ",type); uint16_t mclass = ntohs(*((uint16_t*)ans)); ans+=2; printf("CLASS: %d ",mclass); uint32_t ttl = ntohs(*((uint16_t*)ans)); ans+=4; printf("TTL: %d ",ttl); uint16_t rdlen= ntohs(*((uint16_t*)ans)); ans+=2; printf("RDLENGTH: %d ",rdlen); printf("RDATA: "); if(type==1) { struct in_addr inaddr; inaddr.s_addr = *((int32_t*)ans); printf("%s\n",inet_ntoa(inaddr) ); // addr_ptr=ans; ans+=4; } else if(type==2) { printfunc(ans,start); printf("\n"); ans+=rdlen; } else if(type==6) { char* offstr; int flag; printf("MNAME: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; printf("RNAME: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; printf(" SERIAL : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" REFRESH : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" RETRY : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" EXPIRE : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" MINIMUM : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; } else { ans+=rdlen; } } //print auth section printf("AUTHORITY SECTION\n"); for(i=0;i<noauth;i++) { char* offstr; int flag; printf("Owner Name: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr = start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; uint16_t type = ntohs(*((uint16_t*)ans)); ans+=2; printf("TYPE: %d ",type); uint16_t mclass = ntohs(*((uint16_t*)ans)); ans+=2; printf("CLASS: %d ",mclass); uint32_t ttl = ntohs(*((uint16_t*)ans)); ans+=4; printf("TTL: %d ",ttl); uint16_t rdlen= ntohs(*((uint16_t*)ans)); ans+=2; printf("RDLENGTH: %d ",rdlen); printf("RDATA: "); if(type==1) { struct in_addr inaddr; inaddr.s_addr = *((int32_t*)ans); printf("%s\n",inet_ntoa(inaddr) ); // addr_ptr=ans; ans+=4; } else if(type==2) { printfunc(ans,start); printf("\n"); ans+=rdlen; } else if(type==6) { char* offstr; int flag; printf("MNAME: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; printf("RNAME: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; printf(" SERIAL : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" REFRESH : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" RETRY : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" EXPIRE : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" MINIMUM : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; } else ans+=rdlen; } printf("ADDITIONAL SECTION\n"); for(i=0;i<noadd;i++) { int flag; char* offstr; printf("Owner name:"); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr = start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; uint16_t type = ntohs(*((uint16_t*)ans)); ans+=2; printf("TYPE: %d ",type); uint16_t mclass = ntohs(*((uint16_t*)ans)); ans+=2; printf("CLASS: %d ",mclass); uint32_t ttl = ntohs(*((uint16_t*)ans)); ans+=4; printf("TTL: %d ",ttl); uint16_t rdlen= ntohs(*((uint16_t*)ans)); ans+=2; printf("RDLENGTH: %d ",rdlen); printf("RDATA: "); if(type==1) { struct in_addr inaddr; inaddr.s_addr = *((int32_t*)ans); printf("%s\n",inet_ntoa(inaddr) ); ipaddresses[num]=ans; num++; cur++; ans+=4; } else if(type==2) { printfunc(ans,start); printf("\n"); ans+=rdlen; } else if(type==6) { char* offstr; int flag; printf("MNAME: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; printf("RNAME: "); flag=1; while(*ans != 0) { if( ((*ans) & ((uint8_t)0xC0)) ) { flag=0; offstr =start + ((ntohs(*((uint16_t*)(ans)))) & (uint16_t)0x3fff) ; printfunc(offstr,start); ans+=2; break; } for(p=0;p<(uint8_t)*ans;p++) printf("%c",*(ans+p+1)); printf("."); ans+=*ans+1; } printf(", "); if(flag) ans++; printf(" SERIAL : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" REFRESH : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" RETRY : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" EXPIRE : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; printf(" MINIMUM : %d\n",ntohl(*((uint32_t*)ans))); ans+=4; } else ans+=rdlen; } return addr_ptr; }
/** * display all file entries from traverse * entry list is iterated twcie, first time it analyses how and what to print * second one it calls printfunc to print it */ static void display(FTSENT *p, FTSENT *list) { FTSENT *cur; FTSENT_PRT prt; prt.s_inode=0; prt.s_block=0; prt.t_block=0; prt.s_link=0; prt.s_name=0; prt.s_uid=0; prt.s_uname=0; prt.s_gid=0; prt.s_gname=0; prt.s_size=0; prt.s_major=0; prt.s_minor=0; prt.s_float=0; prt.s_read=0; prt.entries=0; prt.col_length=0; for (cur=list; cur; cur=cur->fts_link) { /* if -d is not specified, only print files */ if (!p && !f_plaintext && cur->fts_info==FTS_D) { cur->fts_number=NO_PRINT; continue; } if (p && cur->fts_name[0]=='.' && !f_allentry) { cur->fts_number=NO_PRINT; continue; } format(cur, &prt); more=1; } if (f_longfmt) { if (p) printf("total %lld\n", prt.t_block); } else if (f_dispblock && f_terminal) if (p) printf("total %lld\n", prt.t_block); /* columnized ouput or other */ if ((f_column || f_sortacross) && prt.col_length) { if (f_displgd) prt.col_length+=1; if (f_inodenum) prt.col_length+=prt.s_inode+1; if (f_dispblock) prt.col_length+=prt.s_block+1; /** * calculate columns and rows using this simple fomular * t_width=col_length*i+inter*i */ int col=0, row=0; int inter=MAX_INTERVAL; int max=t_width/prt.col_length; for (int i=max; i>0; i--) { int t=t_width-prt.col_length*i; if (t/i>=MIN_INTERVAL) { col=i; inter=MIN(inter, t/i); break; } } if (col==0) { for (cur=list; cur; cur=cur->fts_link) { if (IS_NOPRT(cur)) continue; printfunc(cur); putchar('\n'); } } else { row=prt.entries/col; if (prt.entries%col!=0) row++; /* arranges all entries into a matrix */ FTSENT **o_matrix=NULL, **matrix; if ((matrix=(FTSENT**)realloc(o_matrix, sizeof(FTSENT*)*row*col))==(void*)NULL) err(-1, NULL); for (int i=0; i<row; i++) for (int j=0; j<col; j++) matrix[i*col+j]=NULL; int i, rid=0, cid=0; char interval[inter]; for (i=0; i<inter; i++) interval[i]=' '; interval[i]='\0'; if (!f_sortacross) { /* -C */ for (cur=list; cur; cur=cur->fts_link) { if (IS_NOPRT(cur)) continue; matrix[(rid++)*col+cid]=cur; if (rid==row) { rid=0; cid++; } } } else { /* -x */ for (cur=list; cur; cur=cur->fts_link) { if (IS_NOPRT(cur)) continue; matrix[rid*col+(cid++)]=cur; if (cid==col) { cid=0; rid++; } } } for (int i=0; i<row; i++) { for (int j=0; j<col; j++) if (matrix[i*col+j]==NULL) { // do nothing } else { printfunc(matrix[i*col+j]); printf("%s", interval); } putchar('\n'); } } } else { for (cur=list; cur; cur=cur->fts_link) { if (IS_NOPRT(cur)) continue; printfunc(cur); putchar('\n'); } } }