コード例 #1
0
static duk_ret_t test_1(duk_context *ctx) {
	const char *p;
	duk_size_t sz;

	duk_set_top(ctx, 0);
	duk_push_lstring(ctx, "foo\0bar", 7);
	duk_push_string(ctx, "");

	sz = (duk_size_t) 0xdeadbeef;
	p = duk_require_lstring(ctx, 0, &sz);
	dump_string_size(p, sz);

	sz = (duk_size_t) 0xdeadbeef;
	p = duk_require_lstring(ctx, 0, NULL);
	dump_string(p);

	sz = (duk_size_t) 0xdeadbeef;
	p = duk_require_lstring(ctx, 1, &sz);
	dump_string_size(p, sz);

	sz = (duk_size_t) 0xdeadbeef;
	p = duk_require_lstring(ctx, 1, NULL);
	dump_string(p);
	return 0;
}
コード例 #2
0
ファイル: dump_string.cpp プロジェクト: AntonioModer/xray-16
std::string dump_string( LPCSTR name, const Fmatrix &form )
{
	return 
	make_string( "%s, _14_=%f \n", dump_string( make_string( "%s.i, ", name ).c_str(), form.i ).c_str( ) , form._14_ )	+ 
	make_string( "%s, _24_=%f \n", dump_string( make_string( "%s.j, ", name ).c_str(), form.j ).c_str( ) , form._24_ )	+  
	make_string( "%s, _34_=%f \n", dump_string( make_string( "%s.k, ", name ).c_str(), form.k ).c_str( ) , form._34_  ) +  
	make_string( "%s, _44_=%f \n", dump_string( make_string( "%s.c, ", name ).c_str(), form.c ).c_str( ) , form._44_ );  
}
コード例 #3
0
static duk_ret_t test_1(duk_context *ctx) {
	duk_set_top(ctx, 0);
	duk_push_string(ctx, "foo");
	duk_push_string(ctx, "");
	dump_string(duk_require_string(ctx, 0));
	dump_string(duk_require_string(ctx, 1));
	return 0;
}
コード例 #4
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
void
dump_charinfo (int f , int c) {
  charinfo *co;
  int x;
  liginfo *lig;
  kerninfo *kern;

  dump_int(c);
  co = char_info(f,c);
  set_charinfo_used(co,0);
  dump_int(get_charinfo_width(co));
  dump_int(get_charinfo_height(co));
  dump_int(get_charinfo_depth(co));
  dump_int(get_charinfo_italic(co));
  dump_int(get_charinfo_tag(co));
  dump_int(get_charinfo_ef(co));
  dump_int(get_charinfo_rp(co));
  dump_int(get_charinfo_lp(co));
  dump_int(get_charinfo_remainder(co));
  dump_int(get_charinfo_used(co));
  dump_int(get_charinfo_index(co));
  dump_string(get_charinfo_name(co));
  dump_string(get_charinfo_tounicode(co));

  /* ligatures */
  x = 0;
  if ((lig = get_charinfo_ligatures(co)) != NULL) {
    while (!lig_end(lig[x])) { x++; }
    x++;
    dump_int(x);  dump_things(*lig, x);
  } else {
    dump_int(x);
  }
  /* kerns */
  x = 0;
  if ((kern = get_charinfo_kerns(co)) != NULL) {
    while (!kern_end(kern[x])) { x++; }
    x++;
    dump_int(x);  dump_things(*kern, x);
  } else {
    dump_int(x);	
  }
  /* packets */
  x= vf_packet_bytes(co);
  dump_int(x);  
  if (x>0) {
    dump_things(*get_charinfo_packets(co), x);
  }

  if (get_charinfo_tag(co)==ext_tag) {
    x = get_charinfo_extensible(co,EXT_TOP);       dump_int(x);
    x = get_charinfo_extensible(co,EXT_BOT);       dump_int(x);
    x = get_charinfo_extensible(co,EXT_MID);       dump_int(x);
    x = get_charinfo_extensible(co,EXT_REP);       dump_int(x);
  }
}
コード例 #5
0
ファイル: dump.c プロジェクト: DJHartley/iphone-dev
static void
dump_access (dump_info_p di, tree t)
{
  if (TREE_PROTECTED(t))
    dump_string (di, "protected");
  else if (TREE_PRIVATE(t))
    dump_string (di, "private");
  else
    dump_string (di, "public");
}
コード例 #6
0
ファイル: util.c プロジェクト: fatihky/gason-c
void dump_value(gason_value_t *o, int indent) {
    switch (gason_value_get_tag(o)) {
    case G_JSON_NUMBER:
        fprintf(stdout, "%f", gason_value_to_number(o));
        break;
    case G_JSON_STRING:
        dump_string(gason_value_to_string(o));
        break;
    case G_JSON_ARRAY:
        // It is not necessary to use o.toNode() to check if an array or object
        // is empty before iterating over its members, we do it here to allow
        // nicer pretty printing.
        if (!gason_value_to_node(o)) {
            fprintf(stdout, "[]");
            break;
        }
        fprintf(stdout, "[\n");
        for (gason_node_t *i = gason_value_to_node(o); i; i = i->next)
        {
            // gason_node_t *n = gason_iterator_node(gason_iterator_t *it);
            fprintf(stdout, "%*s", indent + SHIFT_WIDTH, "");
            dump_value(&i->value, indent + SHIFT_WIDTH);
            fprintf(stdout, i->next ? ",\n" : "\n");
        }
        fprintf(stdout, "%*s]", indent, "");
        break;
    case G_JSON_OBJECT:
        if (!gason_value_to_node(o)) {
            fprintf(stdout, "{}");
            break;
        }
        fprintf(stdout, "{\n");
        for(gason_node_t *i = gason_value_to_node(o); i; i = i->next) {
            fprintf(stdout, "%*s", indent + SHIFT_WIDTH, "");
            dump_string(i->key);
            fprintf(stdout, ": ");
            dump_value(&i->value, indent + SHIFT_WIDTH);
            fprintf(stdout, i->next ? ",\n" : "\n");
        }
        fprintf(stdout, "%*s}", indent, "");
        break;
    case G_JSON_TRUE:
        fprintf(stdout, "true");
        break;
    case G_JSON_FALSE:
        fprintf(stdout, "false");
        break;
    case G_JSON_NULL:
        fprintf(stdout, "null");
        break;
    }
}
コード例 #7
0
ファイル: misc.c プロジェクト: FMayzek/gnupg
/* Log the certificate's name in "#SN/ISSUERDN" format along with
   TEXT. */
void
cert_log_name (const char *text, ksba_cert_t cert)
{
  log_info ("%s", text? text:"certificate" );
  if (cert)
    {
      ksba_sexp_t sn;
      char *p;

      p = ksba_cert_get_issuer (cert, 0);
      sn = ksba_cert_get_serial (cert);
      if (p && sn)
        {
          log_printf (" #");
          dump_serial (sn);
          log_printf ("/");
          dump_string (p);
        }
      else
        log_printf (" [invalid]");
      ksba_free (sn);
      xfree (p);
    }
  log_printf ("\n");
}
コード例 #8
0
ファイル: tlb.c プロジェクト: Dimillian/wine
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;
}
コード例 #9
0
ファイル: dump_string.cpp プロジェクト: AntonioModer/xray-16
void dump( LPCSTR name, const Fmatrix &form )
{
	Msg( "%s", dump_string( name, form ) );
	//Msg( "%s, _14_=%f ", dump_string( make_string( "%s.i, ", name ).c_str(), form.i ).c_str( ) , form._14_ );  
	//Msg( "%s, _24_=%f ", dump_string( make_string( "%s.j, ", name ).c_str(), form.j ).c_str( ) , form._24_ );  
	//Msg( "%s, _34_=%f ", dump_string( make_string( "%s.k, ", name ).c_str(), form.k ).c_str( ) , form._34_  );  
	//Msg( "%s, _44_=%f ", dump_string( make_string( "%s.c, ", name ).c_str(), form.c ).c_str( ) , form._44_ );  
}
コード例 #10
0
ファイル: main.c プロジェクト: archiecobbs/jcvm
static void
dump_const(_jc_cf_constant *cp)
{
	switch (cp->type) {
	case CONSTANT_Long:
		printf("0x%016llx", cp->u.Long);
		break;
	case CONSTANT_Float:
		printf("%g (0x%08x)", cp->u.Float, cp->u.Integer);
		break;
	case CONSTANT_Double:
		printf("%g (0x%016llx)", cp->u.Double, cp->u.Long);
		break;
	case CONSTANT_Integer:
		printf("0x%08x", cp->u.Integer);
		break;
	case CONSTANT_String:
		dump_string(cp->u.String);
		break;
	case CONSTANT_Class:
		printf("class \"%s\"", cp->u.Class);
		break;
	case CONSTANT_Fieldref:
		printf("class \"%s\" field \"%s\" descriptor \"%s\"",
		    cp->u.Ref.class, cp->u.Ref.name, cp->u.Ref.descriptor);
		break;
	case CONSTANT_Methodref:
		printf("class \"%s\" method \"%s\" descriptor \"%s\"",
		    cp->u.Ref.class, cp->u.Ref.name, cp->u.Ref.descriptor);
		break;
	case CONSTANT_InterfaceMethodref:
		printf("interface \"%s\" method \"%s\" descriptor \"%s\"",
		    cp->u.Ref.class, cp->u.Ref.name, cp->u.Ref.descriptor);
		break;
	case CONSTANT_NameAndType:
		printf("name \"%s\" descriptor \"%s\"",
		    cp->u.NameAndType.name, cp->u.NameAndType.descriptor);
		break;
	case CONSTANT_Utf8:
		dump_string(cp->u.Utf8);
		break;
	default:
		assert(0);
		break;
	}
}
コード例 #11
0
ファイル: texfont.c プロジェクト: luigiScarso/mflua
void
dump_font (int f) {
  int i,x;

  set_font_used(f,0);
  font_tables[f]->charinfo_cache = NULL;
  dump_things(*(font_tables[f]), 1);
  dump_string(font_name(f));
  dump_string(font_area(f));
  dump_string(font_filename(f));
  dump_string(font_fullname(f));
  dump_string(font_encodingname(f));
  dump_string(font_cidregistry(f));
  dump_string(font_cidordering(f));

  dump_things(*param_base(f),(font_params(f)+1));

  if (has_left_boundary(f)) {
    dump_int(1);  dump_charinfo(f,left_boundarychar);
  } else {
    dump_int(0);
  }
  if (has_right_boundary(f)) {
    dump_int(1);  dump_charinfo(f,right_boundarychar);
  } else {
    dump_int(0);
  }

  for(i=font_bc(f); i<=font_ec(f); i++) {
    if (char_exists(f,i)) {
      dump_charinfo(f,i);
    }
  }
}
コード例 #12
0
ファイル: misc.c プロジェクト: FMayzek/gnupg
/* Dump an KSBA cert object to the log stream. Prefix the output with
   TEXT.  This is used for debugging. */
void
dump_cert (const char *text, ksba_cert_t cert)
{
  ksba_sexp_t sexp;
  char *p;
  ksba_isotime_t t;

  log_debug ("BEGIN Certificate '%s':\n", text? text:"");
  if (cert)
    {
      sexp = ksba_cert_get_serial (cert);
      p = serial_hex (sexp);
      log_debug ("     serial: %s\n", p?p:"?");
      xfree (p);
      ksba_free (sexp);

      ksba_cert_get_validity (cert, 0, t);
      log_debug ("  notBefore: ");
      dump_isotime (t);
      log_printf ("\n");
      ksba_cert_get_validity (cert, 1, t);
      log_debug ("   notAfter: ");
      dump_isotime (t);
      log_printf ("\n");

      p = ksba_cert_get_issuer (cert, 0);
      log_debug ("     issuer: ");
      dump_string (p);
      ksba_free (p);
      log_printf ("\n");

      p = ksba_cert_get_subject (cert, 0);
      log_debug ("    subject: ");
      dump_string (p);
      ksba_free (p);
      log_printf ("\n");

      log_debug ("  hash algo: %s\n", ksba_cert_get_digest_algo (cert));

      p = get_fingerprint_hexstring (cert);
      log_debug ("  SHA1 fingerprint: %s\n", p);
      xfree (p);
    }
  log_debug ("END Certificate\n");
}
コード例 #13
0
static duk_ret_t test_1(duk_context *ctx) {
	/*
	 *  Test with a string containing non-ASCII to ensure indices are
	 *  treated correctly as char indices.
	 *
	 *  >>> u'foo\u1234ar'.encode('utf-8').encode('hex')
	 *  '666f6fe188b46172'
	 */
	const char *teststr = "666f6fe188b46172";

	duk_set_top(ctx, 0);

	duk_push_string(ctx, (const char *) teststr);
	duk_hex_decode(ctx, -1);
	duk_to_string(ctx, -1);

	/* basic case */
	duk_dup_top(ctx);
	duk_push_int(ctx, 123);  /* dummy */
	duk_substring(ctx, -2, 2, 5);  /* test index other than stack top */
	duk_pop(ctx);
	dump_string(ctx);

	/* end is clamped */
	duk_dup_top(ctx);
	duk_substring(ctx, -1, 2, 8);
	dump_string(ctx);

	/* start and end are clamped */
	duk_dup_top(ctx);
	duk_substring(ctx, -1, 10, 20);
	dump_string(ctx);

	/* start > end */
	duk_dup_top(ctx);
	duk_substring(ctx, -1, 4, 2);
	dump_string(ctx);

	printf("final top: %ld\n", (long) duk_get_top(ctx));
	return 0;
}
コード例 #14
0
ファイル: soap.c プロジェクト: Haxe/gtk-gnutella
/**
 * Callback invoked when the HTTP data of the request have been sent.
 */
static void
soap_sent_data(const struct http_async *ha,
	const struct gnutella_socket *s, const char *data, size_t len,
	gboolean deferred)
{
	soap_rpc_t *sr = http_async_get_opaque(ha);

	soap_rpc_check(sr);

	if (GNET_PROPERTY(soap_trace) & SOCK_TRACE_OUT) {
		g_debug("----Sent SOAP HTTP data%s to %s (%u bytes):",
			deferred ? " completely" : "",
			host_addr_port_to_string(s->addr, s->port), (unsigned) len);
		dump_string(stderr, data, len, "----");
	}
}
コード例 #15
0
ファイル: tlb.c プロジェクト: Dimillian/wine
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();
}
コード例 #16
0
ファイル: sexp.c プロジェクト: Greenchik/libgcrypt
void
gcry_sexp_dump (const gcry_sexp_t a)
{
  const byte *p;
  int indent = 0;
  int type;

  if (!a)
    {
      log_printf ( "[nil]\n");
      return;
    }

  p = a->d;
  while ( (type = *p) != ST_STOP )
    {
      p++;
      switch ( type )
        {
        case ST_OPEN:
          log_printf ("%*s[open]\n", 2*indent, "");
          indent++;
          break;
        case ST_CLOSE:
          if( indent )
            indent--;
          log_printf ("%*s[close]\n", 2*indent, "");
          break;
        case ST_DATA: {
          DATALEN n;
          memcpy ( &n, p, sizeof n );
          p += sizeof n;
          log_printf ("%*s[data=\"", 2*indent, "" );
          dump_string (p, n, '\"' );
          log_printf ("\"]\n");
          p += n;
        }
        break;
        default:
          log_printf ("%*s[unknown tag %d]\n", 2*indent, "", type);
          break;
	}
    }
}
コード例 #17
0
ファイル: chinnu.c プロジェクト: kwiskia/chinnu
void dump_chunk(Chunk *chunk, FILE *fp) {
    // TODO - may be wasteful, check size limits
    dump_int(fp, chunk->numtemps);
    dump_int(fp, chunk->numconstants);
    dump_int(fp, chunk->numinstructions);
    dump_int(fp, chunk->numchildren);
    dump_int(fp, chunk->numlocals);
    dump_int(fp, chunk->numupvars);
    dump_int(fp, chunk->numparams);

    int i;
    for (i = 0; i < chunk->numinstructions; i++) {
        dump_int(fp, chunk->instructions[i]);
    }

    for (i = 0; i < chunk->numconstants; i++) {
        // TODO - wasteful, doesn't need nearly 32 bits
        dump_int(fp, chunk->constants[i]->type);

        switch (chunk->constants[i]->type) {
            case CONST_INT:
            case CONST_BOOL:
                dump_int(fp, chunk->constants[i]->value.i);
                break;

            case CONST_REAL:
                dump_real(fp, chunk->constants[i]->value.d);
                break;

            case CONST_NULL:
                break;

            case CONST_STRING:
            {
                dump_string(fp, chunk->constants[i]->value.s);
            } break;
        }
    }

    for (i = 0; i < chunk->numchildren; i++) {
        dump_chunk(chunk->children[i], fp);
    }
}
コード例 #18
0
ファイル: tlb.c プロジェクト: Dimillian/wine
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();
}
コード例 #19
0
ファイル: misc.c プロジェクト: FMayzek/gnupg
/* Log the certificate's subject DN along with TEXT. */
void
cert_log_subject (const char *text, ksba_cert_t cert)
{
  log_info ("%s", text? text:"subject" );
  if (cert)
    {
      char *p;

      p = ksba_cert_get_subject (cert, 0);
      if (p)
        {
          log_printf (" /");
          dump_string (p);
          xfree (p);
        }
      else
        log_printf (" [invalid]");
    }
  log_printf ("\n");
}
コード例 #20
0
ファイル: cg.c プロジェクト: LeeThompson/replaypc
void dump_fixed_program_record(struct fixed_program_record * p) 
{
    dump_group_start    ("Program");
    dump_bitmapping     ("Flags",        p->flags, program_flags_mapping);
    dump_time           ("Event Time",   p->event_time);
    dump_u32            ("TMS ID",       p->tmsid);
    dump_u16            ("Minutes",      p->minutes);
    if (p->genre1)
        dump_mapping    ("Genre 1",      p->genre1, genre_mapping);
    if (p->genre2)
        dump_mapping    ("Genre 2",      p->genre2, genre_mapping);
    if (p->genre3)
        dump_mapping    ("Genre 3",      p->genre3, genre_mapping);
    if (p->genre4)
        dump_mapping    ("Genre 4",      p->genre4, genre_mapping);
    dump_u16            ("Record Length",p->record_len);
    if (p->flags & 0x0040)
        dump_parts      (               &p->parts);
    if (p->flags & 0x0020)
        dump_movie      (               &p->movie);
    if (p->title_len > 1)
        dump_string     ("Title",        p->datablock + p->title_offset);
    if (p->episode_len > 1)
        dump_string     ("Episode",      p->datablock + p->episode_offset);
    if (p->description_len > 1)
        dump_string     ("Description",  p->datablock + p->description_offset);
    if (p->actor_len > 1)
        dump_string     ("Actor",        p->datablock + p->actor_offset);
    if (p->guest_len > 1)
        dump_string     ("Guest",        p->datablock + p->guest_offset);
    if (p->suzuki_len > 1)
        dump_string     ("Suzuki",       p->datablock + p->suzuki_offset);
    if (p->producer_len > 1)
        dump_string     ("Producer",     p->datablock + p->producer_offset);
    if (p->director_len > 1)
        dump_string     ("Director",     p->datablock + p->director_offset);
    dump_group_end      ();
}
コード例 #21
0
ファイル: findhash.c プロジェクト: Azarien/open-watcom-v2
void dump_hash( void )
/********************/
{
    keyword_t i;
    unsigned j;
    unsigned ord;
    unsigned k;

    init_ordered();
    outfile = fopen( get_gh_filename( "keywords" ), "w" );
    extra = 0;
    for( i = 1; i <= hashsize; ++i ) {
        ord = ordered[i];
        fputs( "pick( T_", outfile );
        if( ord == 0 || ord > num_keywords ) {
            dump_token_name( 0 );
            fprintf( outfile, ",\"???%02u\",TC_UNKNOWN", extra );
            ++extra;
        } else {
            j = dump_token_name( ord );
            ++extra;
            fputc( ',', outfile );
            dump_n_blanks( 15 - j );
            if( ord != 0 ) {
                k = dump_string( tokens[ord] ) - 2;
                fputc( ',', outfile );
            } else {
                fprintf( outfile, "NULL," );
                k = 2;
            }
            dump_n_blanks( 15 - k );
            fprintf( outfile, "%s", token_class[ord] );
        }
        if( pick_extension != NULL ) {
            fprintf( outfile, " %s", pick_extension );
        }
        fprintf( outfile, " )\n" );
    }
    fclose( outfile );
}
コード例 #22
0
ファイル: c-dump.c プロジェクト: 0mp/freebsd
bool
c_dump_tree (void *dump_info, tree t)
{
  enum tree_code code;
  dump_info_p di = (dump_info_p) dump_info;

  /* Figure out what kind of node this is.  */
  code = TREE_CODE (t);

  switch (code)
    {
    case FIELD_DECL:
      if (DECL_C_BIT_FIELD (t))
	dump_string (di, "bitfield");
      break;

    default:
      break;
    }

  return false;
}
コード例 #23
0
ファイル: lnk.c プロジェクト: Sunmonds/wine
void lnk_dump(void)
{
    const LINK_HEADER*        hdr;
    const DATABLOCK_HEADER*   bhdr;
    DWORD dwFlags;

    offset = 0;
    hdr = fetch_block();
    if (!hdr)
        return;

    printf("Header\n");
    printf("------\n\n");
    printf("Size:    %04x\n", hdr->dwSize);
    printf("GUID:    %s\n", get_guid_str(&hdr->MagicGuid));

    printf("FileAttr: %08x\n", hdr->dwFileAttr);
    printf("FileLength: %08x\n", hdr->dwFileLength);
    printf("nIcon: %d\n", hdr->nIcon);
    printf("Startup: %d\n", hdr->fStartup);
    printf("HotKey: %08x\n", hdr->wHotKey);
    printf("Unknown5: %08x\n", hdr->Unknown5);
    printf("Unknown6: %08x\n", hdr->Unknown6);

    /* dump out all the flags */
    printf("Flags:   %04x ( ", hdr->dwFlags);
    dwFlags=hdr->dwFlags;
#define FLAG(x) do \
                { \
                    if (dwFlags & SLDF_##x) \
                    { \
                        printf("%s ", #x); \
                        dwFlags&=~SLDF_##x; \
                    } \
                } while (0)
    FLAG(HAS_ID_LIST);
    FLAG(HAS_LINK_INFO);
    FLAG(HAS_NAME);
    FLAG(HAS_RELPATH);
    FLAG(HAS_WORKINGDIR);
    FLAG(HAS_ARGS);
    FLAG(HAS_ICONLOCATION);
    FLAG(UNICODE);
    FLAG(FORCE_NO_LINKINFO);
    FLAG(HAS_EXP_SZ);
    FLAG(RUN_IN_SEPARATE);
    FLAG(HAS_LOGO3ID);
    FLAG(HAS_DARWINID);
    FLAG(RUNAS_USER);
    FLAG(HAS_EXP_ICON_SZ);
    FLAG(NO_PIDL_ALIAS);
    FLAG(FORCE_UNCNAME);
    FLAG(RUN_WITH_SHIMLAYER);
    FLAG(FORCE_NO_LINKTRACK);
    FLAG(ENABLE_TARGET_METADATA);
    FLAG(DISABLE_KNOWNFOLDER_RELATIVE_TRACKING);
    FLAG(RESERVED);
#undef FLAG
    if (dwFlags)
        printf("+%04x", dwFlags);
    printf(")\n");

    printf("Length:  %04x\n", hdr->dwFileLength);
    printf("\n");

    if (hdr->dwFlags & SLDF_HAS_ID_LIST)
        dump_pidl();
    if (hdr->dwFlags & SLDF_HAS_LINK_INFO)
        dump_location();
    if (hdr->dwFlags & SLDF_HAS_NAME)
        dump_string("Description", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_RELPATH)
        dump_string("Relative path", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_WORKINGDIR)
        dump_string("Working directory", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_ARGS)
        dump_string("Arguments", hdr->dwFlags & SLDF_UNICODE);
    if (hdr->dwFlags & SLDF_HAS_ICONLOCATION)
        dump_string("Icon path", hdr->dwFlags & SLDF_UNICODE);

    bhdr=fetch_block();
    while (bhdr)
    {
        if (!bhdr->cbSize)
            break;
        switch (bhdr->dwSignature)
        {
        case EXP_SZ_LINK_SIG:
            dump_sz_block(bhdr, "exp.link");
            break;
        case EXP_SPECIAL_FOLDER_SIG:
            dump_special_folder_block(bhdr);
            break;
        case EXP_SZ_ICON_SIG:
            dump_sz_block(bhdr, "icon");
            break;
        case EXP_DARWIN_ID_SIG:
            dump_darwin_id(bhdr);
            break;
        default:
            dump_raw_block(bhdr);
        }
        bhdr=fetch_block();
    }
}
コード例 #24
0
static duk_ret_t test_4(duk_context *ctx) {
	duk_set_top(ctx, 0);
	dump_string(duk_require_string(ctx, DUK_INVALID_INDEX));
	return 0;
}
コード例 #25
0
static duk_ret_t test_3(duk_context *ctx) {
	duk_set_top(ctx, 0);
	dump_string(duk_require_string(ctx, 0));
	return 0;
}
コード例 #26
0
ファイル: validate.c プロジェクト: 0ndorio/gnupg
/* Validate the certificate CHAIN up to the trust anchor. Optionally
   return the closest expiration time in R_EXPTIME (this is useful for
   caching issues).  MODE is one of the VALIDATE_MODE_* constants.

   If R_TRUST_ANCHOR is not NULL and the validation would fail only
   because the root certificate is not trusted, the hexified
   fingerprint of that root certificate is stored at R_TRUST_ANCHOR
   and success is returned.  The caller needs to free the value at
   R_TRUST_ANCHOR; in all other cases NULL is stored there.  */
gpg_error_t
validate_cert_chain (ctrl_t ctrl, ksba_cert_t cert, ksba_isotime_t r_exptime,
                     int mode, char **r_trust_anchor)
{
  gpg_error_t err = 0;
  int depth, maxdepth;
  char *issuer = NULL;
  char *subject = NULL;
  ksba_cert_t subject_cert = NULL, issuer_cert = NULL;
  ksba_isotime_t current_time;
  ksba_isotime_t exptime;
  int any_expired = 0;
  int any_no_policy_match = 0;
  chain_item_t chain;


  if (r_exptime)
    *r_exptime = 0;
  *exptime = 0;

  if (r_trust_anchor)
    *r_trust_anchor = NULL;

  if (!opt.system_daemon)
    {
      /* For backward compatibility we only do this in daemon mode.  */
      log_info (_("running in compatibility mode - "
                  "certificate chain not checked!\n"));
      return 0; /* Okay. */
    }

  if (DBG_X509)
    dump_cert ("subject", cert);

  /* May the target certificate be used for this purpose?  */
  switch (mode)
    {
    case VALIDATE_MODE_OCSP:
      err = cert_use_ocsp_p (cert);
      break;
    case VALIDATE_MODE_CRL:
    case VALIDATE_MODE_CRL_RECURSIVE:
      err = cert_use_crl_p (cert);
      break;
    default:
      err = 0;
      break;
    }
  if (err)
    return err;

  /* If we already validated the certificate not too long ago, we can
     avoid the excessive computations and lookups unless the caller
     asked for the expiration time.  */
  if (!r_exptime)
    {
      size_t buflen;
      time_t validated_at;

      err = ksba_cert_get_user_data (cert, "validated_at",
                                     &validated_at, sizeof (validated_at),
                                     &buflen);
      if (err || buflen != sizeof (validated_at) || !validated_at)
        err = 0; /* Not available or other error. */
      else
        {
          /* If the validation is not older than 30 minutes we are ready. */
          if (validated_at < gnupg_get_time () + (30*60))
            {
              if (opt.verbose)
                log_info ("certificate is good (cached)\n");
              /* Note, that we can't jump to leave here as this would
                 falsely updated the validation timestamp.  */
              return 0;
            }
        }
    }

  /* Get the current time. */
  gnupg_get_isotime (current_time);

  /* We walk up the chain until we find a trust anchor. */
  subject_cert = cert;
  maxdepth = 10;
  chain = NULL;
  depth = 0;
  for (;;)
    {
      /* Get the subject and issuer name from the current
         certificate.  */
      ksba_free (issuer);
      ksba_free (subject);
      issuer = ksba_cert_get_issuer (subject_cert, 0);
      subject = ksba_cert_get_subject (subject_cert, 0);

      if (!issuer)
        {
          log_error (_("no issuer found in certificate\n"));
          err = gpg_error (GPG_ERR_BAD_CERT);
          goto leave;
        }

      /* Handle the notBefore and notAfter timestamps.  */
      {
        ksba_isotime_t not_before, not_after;

        err = ksba_cert_get_validity (subject_cert, 0, not_before);
        if (!err)
          err = ksba_cert_get_validity (subject_cert, 1, not_after);
        if (err)
          {
            log_error (_("certificate with invalid validity: %s"),
                       gpg_strerror (err));
            err = gpg_error (GPG_ERR_BAD_CERT);
            goto leave;
          }

        /* Keep track of the nearest expiration time in EXPTIME.  */
        if (*not_after)
          {
            if (!*exptime)
              gnupg_copy_time (exptime, not_after);
            else if (strcmp (not_after, exptime) < 0 )
              gnupg_copy_time (exptime, not_after);
          }

        /* Check whether the certificate is already valid.  */
        if (*not_before && strcmp (current_time, not_before) < 0 )
          {
            log_error (_("certificate not yet valid"));
            log_info ("(valid from ");
            dump_isotime (not_before);
            log_printf (")\n");
            err = gpg_error (GPG_ERR_CERT_TOO_YOUNG);
            goto leave;
          }

        /* Now check whether the certificate has expired.  */
        if (*not_after && strcmp (current_time, not_after) > 0 )
          {
            log_error (_("certificate has expired"));
            log_info ("(expired at ");
            dump_isotime (not_after);
            log_printf (")\n");
            any_expired = 1;
          }
      }

      /* Do we have any critical extensions in the certificate we
         can't handle? */
      err = unknown_criticals (subject_cert);
      if (err)
        goto leave; /* yes. */

      /* Check that given policies are allowed.  */
      err = check_cert_policy (subject_cert);
      if (gpg_err_code (err) == GPG_ERR_NO_POLICY_MATCH)
        {
          any_no_policy_match = 1;
          err = 0;
        }
      else if (err)
        goto leave;

      /* Is this a self-signed certificate? */
      if (is_root_cert ( subject_cert, issuer, subject))
        {
          /* Yes, this is our trust anchor.  */
          if (check_cert_sig (subject_cert, subject_cert) )
            {
              log_error (_("selfsigned certificate has a BAD signature"));
              err = gpg_error (depth? GPG_ERR_BAD_CERT_CHAIN
                                    : GPG_ERR_BAD_CERT);
              goto leave;
            }

          /* Is this certificate allowed to act as a CA.  */
          err = allowed_ca (subject_cert, NULL);
          if (err)
            goto leave;  /* No. */

          err = is_trusted_cert (subject_cert);
          if (!err)
            ; /* Yes we trust this cert.  */
          else if (gpg_err_code (err) == GPG_ERR_NOT_TRUSTED)
            {
              char *fpr;

              log_error (_("root certificate is not marked trusted"));
              fpr = get_fingerprint_hexstring (subject_cert);
              log_info (_("fingerprint=%s\n"), fpr? fpr : "?");
              dump_cert ("issuer", subject_cert);
              if (r_trust_anchor)
                {
                  /* Caller wants to do another trustiness check.  */
                  *r_trust_anchor = fpr;
                  err = 0;
                }
              else
                xfree (fpr);
            }
          else
            {
              log_error (_("checking trustworthiness of "
                           "root certificate failed: %s\n"),
                         gpg_strerror (err));
            }
          if (err)
            goto leave;

          /* Prepend the certificate to our list.  */
          {
            chain_item_t ci;

            ci = xtrycalloc (1, sizeof *ci);
            if (!ci)
              {
                err = gpg_error_from_errno (errno);
                goto leave;
              }
            ksba_cert_ref (subject_cert);
            ci->cert = subject_cert;
            cert_compute_fpr (subject_cert, ci->fpr);
            ci->next = chain;
            chain = ci;
          }

          if (opt.verbose)
            {
              if (r_trust_anchor && *r_trust_anchor)
                log_info ("root certificate is good but not trusted\n");
              else
                log_info ("root certificate is good and trusted\n");
            }

          break;  /* Okay: a self-signed certicate is an end-point. */
        }

      /* To avoid loops, we use an arbitrary limit on the length of
         the chain. */
      depth++;
      if (depth > maxdepth)
        {
          log_error (_("certificate chain too long\n"));
          err = gpg_error (GPG_ERR_BAD_CERT_CHAIN);
          goto leave;
        }

      /* Find the next cert up the tree. */
      ksba_cert_release (issuer_cert); issuer_cert = NULL;
      err = find_issuing_cert (ctrl, subject_cert, &issuer_cert);
      if (err)
        {
          if (gpg_err_code (err) == GPG_ERR_NOT_FOUND)
            {
              log_error (_("issuer certificate not found"));
              log_info ("issuer certificate: #/");
              dump_string (issuer);
              log_printf ("\n");
            }
          else
            log_error (_("issuer certificate not found: %s\n"),
                         gpg_strerror (err));
          /* Use a better understandable error code.  */
          err = gpg_error (GPG_ERR_MISSING_ISSUER_CERT);
          goto leave;
        }

/*     try_another_cert: */
      if (DBG_X509)
        {
          log_debug ("got issuer's certificate:\n");
          dump_cert ("issuer", issuer_cert);
        }

      /* Now check the signature of the certificate.  Well, we
         should delay this until later so that faked certificates
         can't be turned into a DoS easily.  */
      err = check_cert_sig (issuer_cert, subject_cert);
      if (err)
        {
          log_error (_("certificate has a BAD signature"));
#if 0
          if (gpg_err_code (err) == GPG_ERR_BAD_SIGNATURE)
            {
              /* We now try to find other issuer certificates which
                 might have been used.  This is required because some
                 CAs are reusing the issuer and subject DN for new
                 root certificates without using a  authorityKeyIdentifier. */
              rc = find_up (kh, subject_cert, issuer, 1);
              if (!rc)
                {
                  ksba_cert_t tmp_cert;

                  rc = keydb_get_cert (kh, &tmp_cert);
                  if (rc || !compare_certs (issuer_cert, tmp_cert))
                    {
                      /* The find next did not work or returned an
                         identical certificate.  We better stop here
                         to avoid infinite checks. */
                      rc = gpg_error (GPG_ERR_BAD_SIGNATURE);
                      ksba_cert_release (tmp_cert);
                    }
                  else
                    {
                      do_list (0, lm, fp, _("found another possible matching "
                                            "CA certificate - trying again"));
                      ksba_cert_release (issuer_cert);
                      issuer_cert = tmp_cert;
                      goto try_another_cert;
                    }
                }
            }
#endif
          /* We give a more descriptive error code than the one
             returned from the signature checking. */
          err = gpg_error (GPG_ERR_BAD_CERT_CHAIN);
          goto leave;
        }

      /* Check that the length of the chain is not longer than allowed
         by the CA.  */
      {
        int chainlen;

        err = allowed_ca (issuer_cert, &chainlen);
        if (err)
          goto leave;
        if (chainlen >= 0 && (depth - 1) > chainlen)
          {
            log_error (_("certificate chain longer than allowed by CA (%d)"),
                       chainlen);
            err = gpg_error (GPG_ERR_BAD_CERT_CHAIN);
            goto leave;
          }
      }

      /* May that certificate be used for certification? */
      err = cert_use_cert_p (issuer_cert);
      if (err)
        goto leave;  /* No.  */

      /* Prepend the certificate to our list.  */
      {
        chain_item_t ci;

        ci = xtrycalloc (1, sizeof *ci);
        if (!ci)
          {
            err = gpg_error_from_errno (errno);
            goto leave;
          }
        ksba_cert_ref (subject_cert);
        ci->cert = subject_cert;
        cert_compute_fpr (subject_cert, ci->fpr);
        ci->next = chain;
        chain = ci;
      }

      if (opt.verbose)
        log_info (_("certificate is good\n"));

      /* Now to the next level up.  */
      subject_cert = issuer_cert;
      issuer_cert = NULL;
    }

  if (!err)
    { /* If we encountered an error somewhere during the checks, set
         the error code to the most critical one */
      if (any_expired)
        err = gpg_error (GPG_ERR_CERT_EXPIRED);
      else if (any_no_policy_match)
        err = gpg_error (GPG_ERR_NO_POLICY_MATCH);
    }

  if (!err && opt.verbose)
    {
      chain_item_t citem;

      log_info (_("certificate chain is good\n"));
      for (citem = chain; citem; citem = citem->next)
        cert_log_name ("  certificate", citem->cert);
    }

  if (!err && mode != VALIDATE_MODE_CRL)
    { /* Now that everything is fine, walk the chain and check each
         certificate for revocations.

         1. item in the chain  - The root certificate.
         2. item               - the CA below the root
         last item             - the target certificate.

         Now for each certificate in the chain check whether it has
         been included in a CRL and thus be revoked.  We don't do OCSP
         here because this does not seem to make much sense.  This
         might become a recursive process and we should better cache
         our validity results to avoid double work.  Far worse a
         catch-22 may happen for an improper setup hierarchy and we
         need a way to break up such a deadlock. */
      err = check_revocations (ctrl, chain);
    }

  if (!err && opt.verbose)
    {
      if (r_trust_anchor && *r_trust_anchor)
        log_info ("target certificate may be valid\n");
      else
        log_info ("target certificate is valid\n");
    }
  else if (err && opt.verbose)
    log_info ("target certificate is NOT valid\n");


 leave:
  if (!err && !(r_trust_anchor && *r_trust_anchor))
    {
      /* With no error we can update the validation cache.  We do this
         for all certificates in the chain.  Note that we can't use
         the cache if the caller requested to check the trustiness of
         the root certificate himself.  Adding such a feature would
         require us to also store the fingerprint of root
         certificate.  */
      chain_item_t citem;
      time_t validated_at = gnupg_get_time ();

      for (citem = chain; citem; citem = citem->next)
        {
          err = ksba_cert_set_user_data (citem->cert, "validated_at",
                                         &validated_at, sizeof (validated_at));
          if (err)
            {
              log_error ("set_user_data(validated_at) failed: %s\n",
                         gpg_strerror (err));
              err = 0;
            }
        }
    }

  if (r_exptime)
    gnupg_copy_time (r_exptime, exptime);
  ksba_free (issuer);
  ksba_free (subject);
  ksba_cert_release (issuer_cert);
  if (subject_cert != cert)
    ksba_cert_release (subject_cert);
  while (chain)
    {
      chain_item_t ci_next = chain->next;
      if (chain->cert)
        ksba_cert_release (chain->cert);
      xfree (chain);
      chain = ci_next;
    }
  if (err && r_trust_anchor && *r_trust_anchor)
    {
      xfree (*r_trust_anchor);
      *r_trust_anchor = NULL;
    }
  return err;
}
コード例 #27
0
ファイル: tree-dump.c プロジェクト: aosm/gcc_40
static void
dequeue_and_dump (dump_info_p di)
{
  dump_queue_p dq;
  splay_tree_node stn;
  dump_node_info_p dni;
  tree t;
  unsigned int index;
  enum tree_code code;
  enum tree_code_class code_class;
  const char* code_name;

  /* Get the next node from the queue.  */
  dq = di->queue;
  stn = dq->node;
  t = (tree) stn->key;
  dni = (dump_node_info_p) stn->value;
  index = dni->index;

  /* Remove the node from the queue, and put it on the free list.  */
  di->queue = dq->next;
  if (!di->queue)
    di->queue_end = 0;
  dq->next = di->free_list;
  di->free_list = dq;

  /* Print the node index.  */
  dump_index (di, index);
  /* And the type of node this is.  */
  if (dni->binfo_p)
    code_name = "binfo";
  else
    code_name = tree_code_name[(int) TREE_CODE (t)];
  fprintf (di->stream, "%-16s ", code_name);
  di->column = 25;

  /* Figure out what kind of node this is.  */
  code = TREE_CODE (t);
  code_class = TREE_CODE_CLASS (code);

  /* Although BINFOs are TREE_VECs, we dump them specially so as to be
     more informative.  */
  if (dni->binfo_p)
    {
      unsigned ix;
      tree base;
      VEC (tree) *accesses = BINFO_BASE_ACCESSES (t);

      dump_child ("type", BINFO_TYPE (t));

      if (BINFO_VIRTUAL_P (t))
	dump_string (di, "virt");

      dump_int (di, "bases", BINFO_N_BASE_BINFOS (t));
      for (ix = 0; BINFO_BASE_ITERATE (t, ix, base); ix++)
	{
	  tree access = (accesses ? VEC_index (tree, accesses, ix)
			 : access_public_node);
	  const char *string = NULL;

	  if (access == access_public_node)
	    string = "pub";
	  else if (access == access_protected_node)
	    string = "prot";
	  else if (access == access_private_node)
	    string = "priv";
	  else
	    gcc_unreachable ();

	  dump_string (di, string);
	  queue_and_dump_index (di, "binf", base, DUMP_BINFO);
	}

      goto done;
    }

  /* We can knock off a bunch of expression nodes in exactly the same
     way.  */
  if (IS_EXPR_CODE_CLASS (code_class))
    {
      /* If we're dumping children, dump them now.  */
      queue_and_dump_type (di, t);

      switch (code_class)
	{
	case tcc_unary:
	  dump_child ("op 0", TREE_OPERAND (t, 0));
	  break;

	case tcc_binary:
	case tcc_comparison:
	  dump_child ("op 0", TREE_OPERAND (t, 0));
	  dump_child ("op 1", TREE_OPERAND (t, 1));
	  break;

	case tcc_expression:
	case tcc_reference:
	case tcc_statement:
	  /* These nodes are handled explicitly below.  */
	  break;

	default:
	  gcc_unreachable ();
	}
    }
  else if (DECL_P (t))
    {
      expanded_location xloc;
      /* All declarations have names.  */
      if (DECL_NAME (t))
	dump_child ("name", DECL_NAME (t));
      if (DECL_ASSEMBLER_NAME_SET_P (t)
	  && DECL_ASSEMBLER_NAME (t) != DECL_NAME (t))
	dump_child ("mngl", DECL_ASSEMBLER_NAME (t));
      /* And types.  */
      queue_and_dump_type (di, t);
      dump_child ("scpe", DECL_CONTEXT (t));
      /* And a source position.  */
      xloc = expand_location (DECL_SOURCE_LOCATION (t));
      if (xloc.file)
	{
	  const char *filename = strrchr (xloc.file, '/');
	  if (!filename)
	    filename = xloc.file;
	  else
	    /* Skip the slash.  */
	    ++filename;

	  dump_maybe_newline (di);
	  fprintf (di->stream, "srcp: %s:%-6d ", filename,
		   xloc.line);
	  di->column += 6 + strlen (filename) + 8;
	}
      /* And any declaration can be compiler-generated.  */
      if (DECL_ARTIFICIAL (t))
	dump_string (di, "artificial");
      if (TREE_CHAIN (t) && !dump_flag (di, TDF_SLIM, NULL))
	dump_child ("chan", TREE_CHAIN (t));
    }
  else if (code_class == tcc_type)
    {
      /* All types have qualifiers.  */
      int quals = lang_hooks.tree_dump.type_quals (t);

      if (quals != TYPE_UNQUALIFIED)
	{
	  fprintf (di->stream, "qual: %c%c%c     ",
		   (quals & TYPE_QUAL_CONST) ? 'c' : ' ',
		   (quals & TYPE_QUAL_VOLATILE) ? 'v' : ' ',
		   (quals & TYPE_QUAL_RESTRICT) ? 'r' : ' ');
	  di->column += 14;
	}

      /* All types have associated declarations.  */
      dump_child ("name", TYPE_NAME (t));

      /* All types have a main variant.  */
      if (TYPE_MAIN_VARIANT (t) != t)
	dump_child ("unql", TYPE_MAIN_VARIANT (t));

      /* And sizes.  */
      dump_child ("size", TYPE_SIZE (t));

      /* All types have alignments.  */
      dump_int (di, "algn", TYPE_ALIGN (t));
    }
  else if (code_class == tcc_constant)
    /* All constants can have types.  */
    queue_and_dump_type (di, t);

  /* Give the language-specific code a chance to print something.  If
     it's completely taken care of things, don't bother printing
     anything more ourselves.  */
  if (lang_hooks.tree_dump.dump_tree (di, t))
    goto done;

  /* Now handle the various kinds of nodes.  */
  switch (code)
    {
      int i;

    case IDENTIFIER_NODE:
      dump_string_field (di, "strg", IDENTIFIER_POINTER (t));
      dump_int (di, "lngt", IDENTIFIER_LENGTH (t));
      break;

    case TREE_LIST:
      dump_child ("purp", TREE_PURPOSE (t));
      dump_child ("valu", TREE_VALUE (t));
      dump_child ("chan", TREE_CHAIN (t));
      break;

    case STATEMENT_LIST:
      {
	tree_stmt_iterator it;
	for (i = 0, it = tsi_start (t); !tsi_end_p (it); tsi_next (&it), i++)
	  {
	    char buffer[32];
	    sprintf (buffer, "%u", i);
	    dump_child (buffer, tsi_stmt (it));
	  }
      }
      break;

    case TREE_VEC:
      dump_int (di, "lngt", TREE_VEC_LENGTH (t));
      for (i = 0; i < TREE_VEC_LENGTH (t); ++i)
	{
	  char buffer[32];
	  sprintf (buffer, "%u", i);
	  dump_child (buffer, TREE_VEC_ELT (t, i));
	}
      break;

    case INTEGER_TYPE:
    case ENUMERAL_TYPE:
      dump_int (di, "prec", TYPE_PRECISION (t));
      if (TYPE_UNSIGNED (t))
	dump_string (di, "unsigned");
      dump_child ("min", TYPE_MIN_VALUE (t));
      dump_child ("max", TYPE_MAX_VALUE (t));

      if (code == ENUMERAL_TYPE)
	dump_child ("csts", TYPE_VALUES (t));
      break;

    case REAL_TYPE:
      dump_int (di, "prec", TYPE_PRECISION (t));
      break;

    case POINTER_TYPE:
      dump_child ("ptd", TREE_TYPE (t));
      break;

    case REFERENCE_TYPE:
      dump_child ("refd", TREE_TYPE (t));
      break;

    case METHOD_TYPE:
      dump_child ("clas", TYPE_METHOD_BASETYPE (t));
      /* Fall through.  */

    case FUNCTION_TYPE:
      dump_child ("retn", TREE_TYPE (t));
      dump_child ("prms", TYPE_ARG_TYPES (t));
      break;

    case ARRAY_TYPE:
      dump_child ("elts", TREE_TYPE (t));
      dump_child ("domn", TYPE_DOMAIN (t));
      break;

    case RECORD_TYPE:
    case UNION_TYPE:
      if (TREE_CODE (t) == RECORD_TYPE)
	dump_string (di, "struct");
      else
	dump_string (di, "union");

      dump_child ("flds", TYPE_FIELDS (t));
      dump_child ("fncs", TYPE_METHODS (t));
      queue_and_dump_index (di, "binf", TYPE_BINFO (t),
			    DUMP_BINFO);
      break;

    case CONST_DECL:
      dump_child ("cnst", DECL_INITIAL (t));
      break;

    case VAR_DECL:
    case PARM_DECL:
    case FIELD_DECL:
    case RESULT_DECL:
      if (TREE_CODE (t) == PARM_DECL)
	dump_child ("argt", DECL_ARG_TYPE (t));
      else
	dump_child ("init", DECL_INITIAL (t));
      dump_child ("size", DECL_SIZE (t));
      dump_int (di, "algn", DECL_ALIGN (t));

      if (TREE_CODE (t) == FIELD_DECL)
	{
	  if (DECL_FIELD_OFFSET (t))
	    dump_child ("bpos", bit_position (t));
	}
      else if (TREE_CODE (t) == VAR_DECL
	       || TREE_CODE (t) == PARM_DECL)
	{
	  dump_int (di, "used", TREE_USED (t));
	  if (DECL_REGISTER (t))
	    dump_string (di, "register");
	}
      break;

    case FUNCTION_DECL:
      dump_child ("args", DECL_ARGUMENTS (t));
      if (DECL_EXTERNAL (t))
	dump_string (di, "undefined");
      if (TREE_PUBLIC (t))
	dump_string (di, "extern");
      else
	dump_string (di, "static");
      if (DECL_LANG_SPECIFIC (t) && !dump_flag (di, TDF_SLIM, t))
	dump_child ("body", DECL_SAVED_TREE (t));
      break;

    case INTEGER_CST:
      if (TREE_INT_CST_HIGH (t))
	dump_int (di, "high", TREE_INT_CST_HIGH (t));
      dump_int (di, "low", TREE_INT_CST_LOW (t));
      break;

    case STRING_CST:
      fprintf (di->stream, "strg: %-7s ", TREE_STRING_POINTER (t));
      dump_int (di, "lngt", TREE_STRING_LENGTH (t));
      break;

    case TRUTH_NOT_EXPR:
    case ADDR_EXPR:
    case INDIRECT_REF:
    case ALIGN_INDIRECT_REF:
    case MISALIGNED_INDIRECT_REF:
    case CLEANUP_POINT_EXPR:
    case SAVE_EXPR:
    case REALPART_EXPR:
    case IMAGPART_EXPR:
      /* These nodes are unary, but do not have code class `1'.  */
      dump_child ("op 0", TREE_OPERAND (t, 0));
      break;

    case TRUTH_ANDIF_EXPR:
    case TRUTH_ORIF_EXPR:
    case INIT_EXPR:
    case MODIFY_EXPR:
    case COMPOUND_EXPR:
    case PREDECREMENT_EXPR:
    case PREINCREMENT_EXPR:
    case POSTDECREMENT_EXPR:
    case POSTINCREMENT_EXPR:
      /* These nodes are binary, but do not have code class `2'.  */
      dump_child ("op 0", TREE_OPERAND (t, 0));
      dump_child ("op 1", TREE_OPERAND (t, 1));
      break;

    case COMPONENT_REF:
      dump_child ("op 0", TREE_OPERAND (t, 0));
      dump_child ("op 1", TREE_OPERAND (t, 1));
      dump_child ("op 2", TREE_OPERAND (t, 2));
      break;

    case ARRAY_REF:
    case ARRAY_RANGE_REF:
      dump_child ("op 0", TREE_OPERAND (t, 0));
      dump_child ("op 1", TREE_OPERAND (t, 1));
      dump_child ("op 2", TREE_OPERAND (t, 2));
      dump_child ("op 3", TREE_OPERAND (t, 3));
      break;

    case COND_EXPR:
      dump_child ("op 0", TREE_OPERAND (t, 0));
      dump_child ("op 1", TREE_OPERAND (t, 1));
      dump_child ("op 2", TREE_OPERAND (t, 2));
      break;

    case CALL_EXPR:
      dump_child ("fn", TREE_OPERAND (t, 0));
      dump_child ("args", TREE_OPERAND (t, 1));
      break;

    case CONSTRUCTOR:
      dump_child ("elts", CONSTRUCTOR_ELTS (t));
      break;

    case BIND_EXPR:
      dump_child ("vars", TREE_OPERAND (t, 0));
      dump_child ("body", TREE_OPERAND (t, 1));
      break;

    case LOOP_EXPR:
      dump_child ("body", TREE_OPERAND (t, 0));
      break;

    case EXIT_EXPR:
      dump_child ("cond", TREE_OPERAND (t, 0));
      break;

    case TARGET_EXPR:
      dump_child ("decl", TREE_OPERAND (t, 0));
      dump_child ("init", TREE_OPERAND (t, 1));
      dump_child ("clnp", TREE_OPERAND (t, 2));
      /* There really are two possible places the initializer can be.
	 After RTL expansion, the second operand is moved to the
	 position of the fourth operand, and the second operand
	 becomes NULL.  */
      dump_child ("init", TREE_OPERAND (t, 3));
      break;

    default:
      /* There are no additional fields to print.  */
      break;
    }

 done:
  if (dump_flag (di, TDF_ADDRESS, NULL))
    dump_pointer (di, "addr", (void *)t);

  /* Terminate the line.  */
  fprintf (di->stream, "\n");
}
コード例 #28
0
void dump_string_array ( char **strings, int num_strings, FILE *fp )
{
  int i;
  for ( i=0; i<num_strings; i++ ) dump_string(strings[i], fp);
  return;
}
コード例 #29
0
ファイル: findhash.c プロジェクト: Azarien/open-watcom-v2
void dump_tiny( unsigned first_index, unsigned last_index )
/*********************************************************/
{
    unsigned i;
    int c;
    letter_t letter;
    int min_char;
    int max_char;
    unsigned ord;

    min_char = INT_MAX;
    max_char = 0;
    for( letter = LETTER_MIN; letter <= LETTER_MAX; ++letter ) {
        if( weights[letter] != 0 ) {
            c = make_char( letter );
            if( c < min_char ) {
                min_char = c;
            }
            if( c > max_char ) {
                max_char = c;
            }
        }
    }
    assert( min_char != INT_MAX );
    outfile = fopen( get_gh_filename( "tiny" ), "w" );
    dump_common_defs( first_index, last_index );
    fprintf( outfile, "#define TINY_MIN_CHAR '%c'\n", min_char );
    fprintf( outfile, "static unsigned char TINY_WEIGHTS[%u] = {\n",
                (( max_char - min_char ) + 4 ) & ~3 );
    for( c = min_char; c <= max_char; ++c ) {
        letter = make_letter( (char)c );
        fprintf( outfile, "%6u, /* '%c' */\n", weights[letter], c );
    }
    fputs( "};\n", outfile );
    init_ordered();
    fputs( "static char const * const TINY_IDS[] = {\n", outfile );
    for( i = 1; i <= hashsize; ++i ) {
        ord = ordered[i];
        if( ord == 0 || ord > num_keywords ) {
            dump_string( "" );
        } else {
            dump_string( tokens[ord] );
        }
        fputs( ",\n", outfile );
    }
    fputs( "};\n", outfile );
    fputs( "#define TINY_DEFS \\\n", outfile );
    extra = 0;
    for( i = 1; i <= hashsize; ++i ) {
        ord = ordered[i];
        fputs( "TINY_DEF( ", outfile );
        if( ord == 0 || ord > num_keywords ) {
            dump_token_name( 0 );
        } else {
            dump_token_name( ord );
        }
        ++extra;
        fputs( " ) \\\n", outfile );
    }
    fputs( "/* TINY_DEFS */\n", outfile );
    fclose( outfile );
}
コード例 #30
0
ファイル: dump.c プロジェクト: DJHartley/iphone-dev
static void
dump_op (dump_info_p di, tree t)
{
  switch (DECL_OVERLOADED_OPERATOR_P (t)) {
    case NEW_EXPR:
      dump_string (di, "new");
      break;
    case VEC_NEW_EXPR:
      dump_string (di, "vecnew");
      break;
    case DELETE_EXPR:
      dump_string (di, "delete");
      break;
    case VEC_DELETE_EXPR:
      dump_string (di, "vecdelete");
      break;
    case CONVERT_EXPR:
      dump_string (di, "pos");
      break;
    case NEGATE_EXPR:
      dump_string (di, "neg");
      break;
    case ADDR_EXPR:
      dump_string (di, "addr");
      break;
    case INDIRECT_REF:
      dump_string(di, "deref");
      break;
    case BIT_NOT_EXPR:
      dump_string(di, "not");
      break;
    case TRUTH_NOT_EXPR:
      dump_string(di, "lnot");
      break;
    case PREINCREMENT_EXPR:
      dump_string(di, "preinc");
      break;
    case PREDECREMENT_EXPR:
      dump_string(di, "predec");
      break;
    case PLUS_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "plusassign");
      else
        dump_string(di, "plus");
      break;
    case MINUS_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "minusassign");
      else
        dump_string(di, "minus");
      break;
    case MULT_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "multassign");
      else
        dump_string (di, "mult");
      break;
    case TRUNC_DIV_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "divassign");
      else
        dump_string (di, "div");
      break;
    case TRUNC_MOD_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
         dump_string (di, "modassign");
      else
        dump_string (di, "mod");
      break;
    case BIT_AND_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "andassign");
      else
        dump_string (di, "and");
      break;
    case BIT_IOR_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "orassign");
      else
        dump_string (di, "or");
      break;
    case BIT_XOR_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "xorassign");
      else
        dump_string (di, "xor");
      break;
    case LSHIFT_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "lshiftassign");
      else
        dump_string (di, "lshift");
      break;
    case RSHIFT_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "rshiftassign");
      else
        dump_string (di, "rshift");
      break;
    case EQ_EXPR:
      dump_string (di, "eq");
      break;
    case NE_EXPR:
      dump_string (di, "ne");
      break;
    case LT_EXPR:
      dump_string (di, "lt");
      break;
    case GT_EXPR:
      dump_string (di, "gt");
      break;
    case LE_EXPR:
      dump_string (di, "le");
      break;
    case GE_EXPR:
      dump_string (di, "ge");
      break;
    case TRUTH_ANDIF_EXPR:
      dump_string (di, "land");
      break;
    case TRUTH_ORIF_EXPR:
      dump_string (di, "lor");
      break;
    case COMPOUND_EXPR:
      dump_string (di, "compound");
      break;
    case MEMBER_REF:
      dump_string (di, "memref");
      break;
    case COMPONENT_REF:
      dump_string (di, "ref");
      break;
    case ARRAY_REF:
      dump_string (di, "subs");
      break;
    case POSTINCREMENT_EXPR:
      dump_string (di, "postinc");     
      break;
    case POSTDECREMENT_EXPR:
      dump_string (di, "postdec");
      break;
    case CALL_EXPR:
      dump_string (di, "call");
      break;
    case NOP_EXPR:
      if (DECL_ASSIGNMENT_OPERATOR_P (t))
        dump_string (di, "assign");
      break;
    default:
      break;
  }
}