int handle_ccn_content_obj(unsigned char **buf, int *len, int offset, FILE *stream){ int num, typ; if(dehead(buf, len, &num, &typ)) return -1; print_offset(offset); printf("<CONTENTOBJ>\n"); while(typ != 2){ dehead(buf, len, &num, &typ); } while(1) { switch(num) { case CCN_DTAG_NAME: handle_ccn_name(buf, len, offset+4, stream); break; case CCN_DTAG_SIGNATURE: handle_ccn_signature(buf, len, offset+4, stream); break; case CCN_DTAG_CONTENT: handle_ccn_content(buf, len, offset+4, stream); break; default: goto Bail; break; } if(dehead(buf, len, &num, &typ)) break; } Bail: print_offset(offset); printf("</CONTENTOBJ>\n"); return 0; }
int handle_ccn_debugrequest(unsigned char **buf, int *len, int offset, FILE *stream) { int num, typ; print_offset(offset); printf("<DEBUGREQUEST>\n"); while(1) { if(dehead(buf, len, &num, &typ)) goto Bail; switch(num) { case CCN_DTAG_ACTION: handle_ccn_action(buf, len, offset+4, stream); break; case CCNL_DTAG_DEBUGACTION: handle_ccn_debugaction(buf, len, offset+4, stream); break; default: goto Bail; } } Bail: print_offset(offset); printf("</DEBUGREQUEST>\n"); return 0; }
FormattedOutput& FormattedOutput::print(const char* str, size_t len) { for (size_t i = 0; i < len; ++i) { if (str[i] == '{') { line_ << '{'; ++offset_; endl(); } else if (str[i] == '}') { endl(); --offset_; print_offset(); line_ << '}'; endl(); } else { if (line_.str().empty() && !std::isspace(str[i])) { print_offset(); line_ << str[i]; } else if (!line_.str().empty()) line_ << str[i]; } } return *this; }
int handle_ccn_debugreply(unsigned char **buf, int *len, int offset, FILE *stream) { int num, typ; print_offset(offset); printf("<DEBUGREPLY>\n"); while(1) { if(dehead(buf, len, &num, &typ)) return -1; switch(num) { case CCNL_DTAG_INTERFACE: handle_ccn_debugreply_content(buf, len, offset+4, "INTERFACE", stream); break; case CCN_DTAG_FACEINSTANCE: handle_ccn_debugreply_content(buf, len, offset+4, "FACEINSTANCE", stream); break; case CCN_DTAG_FWDINGENTRY: handle_ccn_debugreply_content(buf, len, offset+4, "FWDINGENTRY", stream); break; case CCN_DTAG_INTEREST: handle_ccn_debugreply_content(buf, len, offset+4, "INTEREST", stream); break; case CCN_DTAG_CONTENT: handle_ccn_debugreply_content(buf, len, offset+4, "CONTENT", stream); break; default: goto Bail; } } Bail: print_offset(offset); printf("</DEBUGREPLY>\n"); return 0; }
static void print_end_block(void) { indent--; print_offset(); printf("}\n"); print_offset(); printf("\n"); }
int handle_ccn_name(unsigned char **buf, int *len, int offset, FILE *stream){ int num, typ, i; if(dehead(buf, len, &num, &typ)) return -1; print_offset(offset); printf("<NAME>\n"); for(i = 0; i < 3; ++i) { if(num != CCN_DTAG_COMPONENT) return -1; handle_ccn_component_content(buf, len, offset+4, stream); if(dehead(buf, len, &num, &typ)) return -1; } print_offset(offset); printf("</NAME>\n"); return 0; }
static BOOL dump_msft_custdata(seg_t *seg) { unsigned short vt; unsigned i, n; print_begin_block("CustData"); for(i=0; offset < seg->offset+seg->length; i++) { print_offset(); vt = tlb_read_short(); printf("vt %d", vt); n = tlb_read_int(); switch(vt) { case 8 /* VT_BSTR */: printf(" len %d: ", n); dump_string(n, 2); printf("\n"); break; default: printf(": %x ", n); printf("\\%2.2x \\%2.2x\n", tlb_read_byte(), tlb_read_byte()); } } print_end_block(); return TRUE; }
static int print_dec(const char *name) { int ret; print_offset(); printf("%s = %d\n", name, ret=tlb_read_int()); return ret; }
static int print_short_hex(const char *name) { int ret; print_offset(); printf("%s = %xh\n", name, ret=tlb_read_short()); return ret; }
static void dump_double(grib_dumper* d,grib_accessor* a,const char* comment) { grib_dumper_wmo *self = (grib_dumper_wmo*)d; double value; size_t size = 1; int err = grib_unpack_double(a,&value,&size); if( a->length == 0 && (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; set_begin_end(d,a); /*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/ print_offset(self->dumper.out,self->begin,self->theEnd); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) fprintf(self->dumper.out,"%s ",a->creator->op); if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a)) fprintf(self->dumper.out,"%s = MISSING",a->name); else fprintf(self->dumper.out,"%s = %g",a->name,value); /*if(comment) fprintf(self->dumper.out," [%s]",comment);*/ if (err==0) print_hexadecimal(self->dumper.out,d->option_flags,a); if(err) fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_double]",err,grib_get_error_message(err)); aliases(d,a); fprintf(self->dumper.out,"\n"); }
int main(int argc, char **argv){ if(argc == 1){ int i; array = malloc(sizeof(double)*X*Y); if(array == NULL){ printf("failed : malloc() -- exit.\n"); exit(0); } *array = malloc(sizeof(double *)*Y); if(*array == NULL){ printf("failed : malloc() -- exit.\n"); exit(0); } for(i=0;i<Y;i++){ array[i] = *array+i*X; } array[3][9] = 9; //printf("%d\n",array[3][9]); read_to_array_from_stdin(); }else if(argc == 2){ //for test print_def(); exit(0); }else if(argc == 3){ sscanf(argv[1],"%d",&wid); sscanf(argv[2],"%d",&hei); print_head(wid*init_x_scale, hei*init_y_scale); print_def(); print_offset(init_x_scale,init_y_scale,-1,0); print_next_from_stdin(); print_tail(); exit(0); } }
static void dump_name_only(grib_dumper* d,grib_accessor* a,const char* comment) { grib_dumper_keys *self = (grib_dumper_keys*)d; print_offset(self->dumper.out,d,a); if (a->flags & GRIB_ACCESSOR_FLAG_HIDDEN) { return; } if( a->length == 0 && (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; if( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0 && (d->option_flags & GRIB_DUMP_FLAG_DUMP_OK) != 0) return; fprintf(self->dumper.out,"%s",a->name); if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) { fprintf(self->dumper.out," (read only)"); } if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0){ fprintf(self->dumper.out," (type %s) ",a->creator->op); } aliases(d,a); fprintf(self->dumper.out,"\n"); }
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment) { grib_dumper_default *self = (grib_dumper_default*)d; char *value=NULL; char *p = NULL; size_t size = 0; grib_context* c=NULL; int err = grib_get_string_length(a->parent->h,a->name,&size); c=a->parent->h->context; if (size==0) return; value=(char*)grib_context_malloc_clear(c,size); if (!value) { grib_context_log(c,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size); return; } err = grib_unpack_string(a,value,&size); p=value; if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; while(*p) { if(!isprint(*p)) *p = '.'; p++; } print_offset(self->dumper.out,d,a); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# type %s \n",a->creator->op); } aliases(d,a); if(comment) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# %s \n",comment); } if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"#-READ ONLY- "); } else fprintf(self->dumper.out," "); if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a) ) fprintf(self->dumper.out,"%s = MISSING;",a->name); else fprintf(self->dumper.out,"%s = %s;",a->name,value); if(err) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_string]",err,grib_get_error_message(err)); } fprintf(self->dumper.out,"\n"); grib_context_free(c,value); }
int handle_ccn_content(unsigned char **buf, int *len, int offset, FILE *stream){ int num, typ; if(dehead(buf, len, &num, &typ)) return -1; print_offset(offset); printf("<CONTENT>\n"); while(typ != 2){ dehead(buf, len, &num, &typ); } while(1) { switch(num) { case CCN_DTAG_NAME: handle_ccn_name(buf, len, offset+4, stream); break; case CCN_DTAG_INTEREST: break; case CCNL_DTAG_DEBUGREQUEST: handle_ccn_debugrequest(buf, len, offset+4, stream); break; case CCNL_DTAG_DEBUGREPLY: handle_ccn_debugreply(buf, len, offset+4, stream); break; case CCN_DTAG_FACEINSTANCE: handle_ccn_debugreply_content(buf, len, offset+4, "FACEINSTANCE", stream); break; case CCNL_DTAG_DEVINSTANCE: handle_ccn_debugreply_content(buf, len, offset+4, "DEVINSTANCE", stream); break; case CCNL_DTAG_PREFIX: handle_ccn_debugreply_content(buf, len, offset+4, "PREFIX", stream); break; case CCN_DTAG_ACTION: print_offset(offset + 4); print_tag_content_with_tag(buf, len, "ACTION", stream); break; default: //printf("%i,%i\n", num, typ); goto Bail; break; } if(dehead(buf, len, &num, &typ)) break; } Bail: print_offset(offset); printf("</CONTENT>\n"); return 0; }
int handle_ccn_action(unsigned char **buf, int *len, int offset, FILE *stream) { int num, typ; if(dehead(buf, len, &num, &typ)) return -1; print_offset(offset); printf("<ACTION>"); print_tag_content(buf,len,stream); printf("</ACTION>\n"); return 0; }
static void print_guid(const char *name) { GUID guid = *(const GUID*)tlb_read(sizeof(guid)); print_offset(); printf("%s = {%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x}\n", name, guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7]); }
int handle_ccn_component_content(unsigned char **buf, int *len, int offset, FILE *stream) { int num, typ; print_offset(offset); printf("<COMPONENT>"); if(dehead(buf, len, &num, &typ)) return -1; print_tag_content(buf,len,stream); printf("</COMPONENT>\n"); return 0; }
static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment) { grib_dumper_default *self = (grib_dumper_default*)d; int i; long value; size_t size = 1; int err = grib_unpack_long(a,&value,&size); if ( (a->flags & GRIB_ACCESSOR_FLAG_DUMP) == 0) return; print_offset(self->dumper.out,d,a); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# type %s \n",a->creator->op); } aliases(d,a); if(comment) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# %s \n",comment); } fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# flags: "); for(i=0;i<(a->length*8);i++) { if(test_bit(value,a->length*8-i-1)) fprintf(self->dumper.out,"1"); else fprintf(self->dumper.out,"0"); } fprintf(self->dumper.out,"\n"); if (a->flags & GRIB_ACCESSOR_FLAG_READ_ONLY) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"#-READ ONLY- "); } else fprintf(self->dumper.out," "); if( ((a->flags & GRIB_ACCESSOR_FLAG_CAN_BE_MISSING) != 0) && grib_is_missing_internal(a) ) fprintf(self->dumper.out,"%s = MISSING;",a->name); else fprintf(self->dumper.out,"%s = %ld;",a->name,value); if(err) { fprintf(self->dumper.out," "); fprintf(self->dumper.out,"# *** ERR=%d (%s) [grib_dumper_default::dump_bits]",err,grib_get_error_message(err)); } fprintf(self->dumper.out,"\n"); }
int main(int argc, char **argv){ if(argc == 3){ sscanf(argv[1],"%d",&wid); sscanf(argv[2],"%d",&hei); print_head(wid*init_x_scale, hei*init_y_scale); print_def(); print_offset(init_x_scale,init_y_scale,-1,hei-1); print_next_from_stdin(); print_tail(); exit(0); } return(0); }
void print_offsets(struct agnx_priv *priv) { print_offset(priv, 0); print_offset(priv, 4); print_offset(priv, 1); print_offset(priv, 5); print_offset(priv, 2); print_offset(priv, 6); }
static void dump_msft_name(int base, int n) { int len; print_begin_block_id("Name", n); print_hex("hreftype"); print_hex("next_hash"); len = print_hex("namelen")&0xff; print_offset(); printf("name = "); dump_string(len, 0); printf("\n"); print_end_block(); }
void print_ast(ast* x, int offset) { if (offset) { print_offset(offset); rstack[offset] = rstack[offset]->next; } switch (x->tag) { case int_ast: fprintf(tree_file, "Integer(%d)\n", x->info.integer); break; case real_ast: fprintf(tree_file, "Real(%f)\n", x->info.real); break; case var_ast: fprintf(tree_file, "Var(%s)\n", x->info.variable); break; case str_ast: fprintf(tree_file, "String(%s)\n", x->info.string); break; case node_ast: { fprintf(tree_file, "%s [%d:%d-%d:%d]\n", ast_names[x->info.node.tag], x->first_line, x->first_column, x->last_line, x->last_column); rstack[offset + 1] = x->info.node.arguments; print_ast_list(x->info.node.arguments, offset + 1); break; }; }; };
static void dump_string(grib_dumper* d,grib_accessor* a,const char* comment) { grib_dumper_wmo *self = (grib_dumper_wmo*)d; size_t size=0; char *value=NULL; char *p=NULL; int err = grib_get_string_length(a->parent->h,a->name,&size); value=(char *)grib_context_malloc_clear(a->parent->h->context,size); if (!value) { grib_context_log(a->parent->h->context,GRIB_LOG_FATAL,"unable to allocate %d bytes",(int)size); return; } err=grib_unpack_string(a,value,&size); p=value; if( a->length == 0 && (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) { grib_context_free(a->parent->h->context,value); return; } set_begin_end(d,a); while(*p) { if(!isprint(*p)) *p = '.'; p++; } /*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/ print_offset(self->dumper.out,self->begin,self->theEnd); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) fprintf(self->dumper.out,"%s ",a->creator->op); fprintf(self->dumper.out,"%s = %s",a->name,value); if (err==0) print_hexadecimal(self->dumper.out,d->option_flags,a); /*if(comment) fprintf(self->dumper.out," [%s]",comment);*/ if(err) fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_string]",err,grib_get_error_message(err)); aliases(d,a); fprintf(self->dumper.out,"\n"); if (value) grib_context_free(a->parent->h->context,value); }
static void dump_msft_string(int n) { int len; print_begin_block_id("String", n); len = print_short_hex("stringlen"); print_offset(); printf("string = "); dump_string(len, 2); if(len < 3) { for(len = 0; len < 4; len++) printf("\\%2.2x", tlb_read_byte()); } printf("\n"); print_end_block(); }
static void dump_msft_name(int base, int n) { int len; print_begin_block_id("Name", n); print_hex("hreftype"); print_hex("next_hash"); len = print_hex("namelen")&0xff; print_offset(); printf("name = \""); fwrite(tlb_read(len), len, 1, stdout); printf("\" "); while(len++ & 3) printf("\\%2.2x", tlb_read_byte()); printf("\n"); print_end_block(); }
static void dump_binary(int n) { int i; for(i = 1; i <= n; i++) { switch(i & 0x0f) { case 0: printf("%02x\n", tlb_read_byte()); break; case 1: print_offset(); /* fall through */ default: printf("%02x ", tlb_read_byte()); } } if(n&0x0f) printf("\n"); }
static void print_ctl2(const char *name) { int len; const char *buf; print_offset(); len = tlb_read_short(); printf("%s = %d \"", name, len); len >>= 2; buf = tlb_read(len); fwrite(buf, len, 1, stdout); printf("\""); len += 2; while(len++ & 3) printf("\\%02x", tlb_read_byte()); printf("\n"); }
static void dump_bits(grib_dumper* d,grib_accessor* a,const char* comment) { grib_dumper_wmo *self = (grib_dumper_wmo*)d; int i; long value = 0; size_t size = 1; int err = grib_unpack_long(a,&value,&size); if( a->length == 0 && (d->option_flags & GRIB_DUMP_FLAG_CODED) != 0) return; set_begin_end(d,a); /*for(i = 0; i < d->depth ; i++) fprintf(self->dumper.out," ");*/ print_offset(self->dumper.out,self->begin,self->theEnd); if ((d->option_flags & GRIB_DUMP_FLAG_TYPE) != 0) fprintf(self->dumper.out,"%s ",a->creator->op); fprintf(self->dumper.out,"%s = %ld [",a->name,value); for(i=0;i<(a->length*8);i++) { if(test_bit(value,a->length*8-i-1)) fprintf(self->dumper.out,"1"); else fprintf(self->dumper.out,"0"); } /* if(comment) fprintf(self->dumper.out,":%s]",comment); else */ fprintf(self->dumper.out,"]"); if (err==0) print_hexadecimal(self->dumper.out,d->option_flags,a); if(err) fprintf(self->dumper.out," *** ERR=%d (%s) [grib_dumper_wmo::dump_bits]",err,grib_get_error_message(err)); aliases(d,a); fprintf(self->dumper.out,"\n"); }
int handle_ccn_signature(unsigned char **buf, int *buflen, int offset, FILE *stream) { int num, typ, i; if(dehead(buf, buflen, &num, &typ)) return -1; if (typ != CCN_TT_BLOB) return 0; print_offset(offset); printf("<SIGNATURE>"); for(i = 0; i < num; ++i){ printf("%c",(*buf)[i]); } printf("</SIGNATURE>\n"); *buflen -= (num+1); *buf += (num+1); return 0; }
void msft_dump(void) { int i; dump_msft_header(); for(i=0; i < typeinfo_cnt; i++) print_hex_id("typeinfo %d offset", i); if(header_flags & HELPDLLFLAG) print_hex("help dll offset"); print_offset(); printf("\n"); dump_msft_segdir(); while(!msft_eof) { if(!dump_offset()) print_hex("unknown"); } }