示例#1
0
const char* get_symbol_str(const char* symname)
{
    char*       tmp;
    const char* ret;

    if (!symname) return "(nil)";
    if (globals.do_demangle)
    {
        parsed_symbol   symbol;

        symbol_init(&symbol, symname);
        if (!symbol_demangle(&symbol))
            ret = symname;
        else if (symbol.flags & SYM_DATA)
        {
            ret = tmp = dump_want_n(strlen(symbol.arg_text[0]) + 1);
            if (tmp) strcpy(tmp, symbol.arg_text[0]);
        }
        else
        {
            unsigned int i, len, start = symbol.flags & SYM_THISCALL ? 1 : 0;

            len = strlen(symbol.return_text) + 3 /* ' __' */ +
                strlen(symbol_get_call_convention(&symbol)) + 1 /* ' ' */+
                strlen(symbol.function_name) + 1 /* ')' */;
            if (!symbol.argc || (symbol.argc == 1 && symbol.flags & SYM_THISCALL))
                len += 4 /* "void" */;
            else for (i = start; i < symbol.argc; i++)
                len += (i > start ? 2 /* ", " */ : 0 /* "" */) + strlen(symbol.arg_text[i]);
            if (symbol.varargs) len += 5 /* ", ..." */;
            len += 2; /* ")\0" */

            ret = tmp = dump_want_n(len);
            if (tmp)
            {
                sprintf(tmp, "%s __%s %s(",
                        symbol.return_text,
                        symbol_get_call_convention(&symbol),
                        symbol.function_name);
                if (!symbol.argc || (symbol.argc == 1 && symbol.flags & SYM_THISCALL))
                    strcat(tmp, "void");
                else for (i = start; i < symbol.argc; i++)
                {
                    if (i > start) strcat(tmp, ", ");
                    strcat(tmp, symbol.arg_text[i]);
                }
                if (symbol.varargs) strcat(tmp, ", ...");
                strcat(tmp, ")");
            }
        }
        symbol_clear(&symbol);
    }
    else ret = symname;
    return ret;
}
示例#2
0
static void
time_line_clear(void)
{
    symbol_p    scan;
    symbol_p    prev;

    scan = time_line;
    while (scan != NULL) {
        prev = scan;
        scan = scan->next;
        symbol_clear(prev);
    }

    time_line = NULL;
}
示例#3
0
文件: main.c 项目: DeltaYang/wine
int   main (int argc, char *argv[])
#endif
{
    parsed_symbol symbol;
    int count = 0;

    globals.mode = NONE;
    globals.forward_dll = NULL;
    globals.input_name = NULL;
    globals.dumpsect = NULL;

    parse_options (argv);

    memset (&symbol, 0, sizeof (parsed_symbol));

    switch (globals.mode)
    {
    case DMGL:
        VERBOSE = TRUE;

        if (globals.input_name == NULL)
            fatal("No symbol name has been given\n");
        printf("%s\n", get_symbol_str(globals.input_name));
	break;

    case SPEC:
        if (globals.input_name == NULL)
            fatal("No file name has been given\n");
        set_module_name(TRUE);
	if (!dll_open (globals.input_name))
            break;

	output_spec_preamble ();
	output_header_preamble ();
	output_c_preamble ();

        while (dll_next_symbol (&symbol))
	{
	    count++;

	    if (NORMAL)
		printf ("Export %3d - '%s' ...%c", count, symbol.symbol,
			VERBOSE ? '\n' : ' ');

	    if (globals.do_code && symbol_searched(count, symbol.symbol))
	    {
		/* Attempt to get information about the symbol */
                BOOL result = symbol_demangle (&symbol) || symbol_search(&symbol);

                if (result && symbol.function_name)
		    /* Clean up the prototype */
		    symbol_clean_string (symbol.function_name);

		if (NORMAL)
                    puts (result ? "[OK]" : "[Not Found]");
	    }
	    else if (NORMAL)
		puts ("[Ignoring]");

	    output_spec_symbol (&symbol);
	    output_header_symbol (&symbol);
	    output_c_symbol (&symbol);

	    symbol_clear (&symbol);
	}

	output_makefile ();

	if (VERBOSE)
	    puts ("Finished, Cleaning up...");
        if (symbol_finish())
            return 1;
	break;
    case NONE:
	do_usage(0);
	break;
    case DUMP:
        if (globals.input_name == NULL)
            fatal("No file name has been given\n");
        set_module_name(FALSE);
	dump_file(globals.input_name);
	break;
    }

    return 0;
}
示例#4
0
static void
symbol_dealloc (zbarSymbol *self)
{
    symbol_clear(self);
    ((PyObject*)self)->ob_type->tp_free((PyObject*)self);
}