Exemplo n.º 1
0
static int
output_string_key(char *string, int width, format_key_t *key)
{
	if (strlen(string) == 0)
		string = key_empty(key);
	return output_string(string, width, key_align(key));
}
Exemplo n.º 2
0
/**
 * dump switch table
 */
dumpsw(loop_t *loop) {
        int     i,j;

        data_segment_gdata ();
        generate_label (loop->body_label);
        if (loop->test_label != swstp) {
                j = loop->test_label;
                while (j < swstp) {
                        gen_def_word ();
                        i = 4;
                        while (i--) {
                                output_number (swstcase[j]);
                                output_byte (',');
                                print_label (swstlab[j++]);
                                if ((i == 0) | (j >= swstp)) {
                                        newline ();
                                        break;
                                }
                                output_byte (',');
                        }
                }
        }
        gen_def_word ();
        print_label (loop->cont_label);
        output_string (",0");
        newline ();
        code_segment_gtext ();
}
Exemplo n.º 3
0
/**
 * print all assembler info before any code is generated
 */
void header (void) {
    output_string ("; Small C Debug\n;\tCoder (ac0)\n;");
    frontend_version();
    newline ();
    output_line ("\t;program area SMALLC_GENERATED is RELOCATABLE");
    output_line ("\t.module SMALLC_GENERATED");
}
Exemplo n.º 4
0
static
void parse_timings_v1(confword_t* data)
{
    mgconf_core_freq = &data[0];

    if (!verbose_boot)
        return;

    output_string("timings\n"
                  "   core frequency: ", 2);
    output_uint(data[0], 2);
    output_string("MHz\n"
                  "   external memory bandwidth: ", 2);
    output_uint(data[1], 2);
    output_string(" x 1E6 bytes/s\n", 2);
}
Exemplo n.º 5
0
/**
 * call the specified subroutine name
 * @param sname subroutine name
 */
void gen_call(char *sname) {
    output_with_tab ("call ");
    output_string (sname);
    output_byte(',');
    output_number(args);
    newline ();
}
Exemplo n.º 6
0
// XIGNORE: *:D
int main(int argc, const char **argv) {
   output_int(argc, 1);
   output_char('\n', 1);
   output_string(argv[0], 1);
   output_char('\n',1);
   return 0;
}
Exemplo n.º 7
0
/**
 * dump switch table
 */
dumpsw(WHILE *ws) {
        int     i,j;

        data_segment_gdata ();
        generate_label (ws->body_tab);
        if (ws->case_test != swstp) {
                j = ws->case_test;
                while (j < swstp) {
                        gen_def_word ();
                        i = 4;
                        while (i--) {
                                output_number (swstcase[j]);
                                output_byte (',');
                                print_label (swstlab[j++]);
                                if ((i == 0) | (j >= swstp)) {
                                        newline ();
                                        break;
                                }
                                output_byte (',');
                        }
                }
        }
        gen_def_word ();
        print_label (ws->incr_def);
        output_string (",0");
        newline ();
        code_segment_gtext ();
}
Exemplo n.º 8
0
/**
 * dump all static variables
 */
void dumpglbs(void) {
    int dim, i, list_size, line_count, value;
    if (!glbflag)
        return;
    current_symbol_table_idx = rglobal_table_index;
    while (current_symbol_table_idx < global_table_index) {
        SYMBOL *symbol = &symbol_table[current_symbol_table_idx];
        if (symbol->identity != FUNCTION) {
            ppubext(symbol);
            if (symbol->storage != EXTERN) {
                output_string(symbol->name);
                output_label_terminator();
                dim = symbol->offset;
                list_size = 0;
                line_count = 0;
                if (find_symbol_initials(symbol->name)) { // has initials
                    list_size = get_size(symbol->name);
                    if (dim == -1) {
                        dim = list_size;
                    }
                }
                for (i=0; i<dim; i++) {
                    if (symbol->type == STRUCT) {
                        dump_struct(symbol, i);
                    } else {
                        if (line_count % 10 == 0) {
                            newline();
                            if ((symbol->type & CINT) || (symbol->identity == POINTER)) {
                                gen_def_word();
                            } else {
                                gen_def_byte();
                            }
                        }
                        if (i < list_size) {
                            // dump data
                            value = get_item_at(symbol->name, i, &tag_table[symbol->tagidx]);
                            output_number(value);
                        } else {
                            // dump zero, no more data available
                            output_number(0);
                        }
                        line_count++;
                        if (line_count % 10 == 0) {
                            line_count = 0;
                        } else {
                            if (i < dim-1) {
                                output_byte( ',' );
                            }
                        }
                    }
                }
                newline();
            }
        } else {
            fpubext(symbol);
        }
        current_symbol_table_idx++;
    }
}
Exemplo n.º 9
0
static int puts(FILE *fp, const char *s) {
  SkunkConsole *co = fp->data;
  if(co != NULL) {
    output_string(co, s);
    return 0;
  }
  return EOF;
}
Exemplo n.º 10
0
/**
 * enforces bracket
 * @param str
 * @return 
 */
void needbrack(char *str) {
    if (!match (str)) {
        error ("missing bracket");
        gen_comment ();
        output_string (str);
        newline ();
    }
}
Exemplo n.º 11
0
/**
 * perform subroutine call to value on top of stack
 */
void callstk(void) {
    gen_immediate ();
    output_string ("#.+5");
    newline ();
    gen_swap_stack ();
    output_line ("pchl");
    stkp = stkp + INTSIZE;
}
Exemplo n.º 12
0
static void
added (guestfs_h *g, struct file *file)
{
    output_start_line ();
    output_string ("+");
    output_file (g, file);
    output_end_line ();
}
void erase_string(string& in_string,unsigned int erase_point,unsigned int erase_length) {
    if (in_string.empty()) return;
    if (!(in_string.length()>=erase_point+erase_length)) return;

    string output_string(in_string.substr(0,erase_point));
    output_string+=in_string.substr(erase_point+erase_length,in_string.length());
    in_string=output_string;
}
Exemplo n.º 14
0
Arquivo: net.c Projeto: aragaer/wine
static BOOL net_service(int operation, const WCHAR* service_name)
{
    SC_HANDLE SCManager, serviceHandle;
    BOOL result = 0;
    WCHAR service_display_name[4096];
    DWORD buffer_size;

    SCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    if(!SCManager)
    {
        output_string(STRING_NO_SCM);
        return FALSE;
    }
    serviceHandle = OpenServiceW(SCManager, service_name, SC_MANAGER_ALL_ACCESS);
    if(!serviceHandle)
    {
        output_string(STRING_NO_SVCHANDLE);
        CloseServiceHandle(SCManager);
        return FALSE;
    }

    buffer_size = sizeof(service_display_name)/sizeof(*service_display_name);
    GetServiceDisplayNameW(SCManager, service_name, service_display_name, &buffer_size);
    if (!service_display_name[0]) lstrcpyW(service_display_name, service_name);

    switch(operation)
    {
    case NET_START:
        output_string(STRING_START_SVC, service_display_name);
        result = StartServiceW(serviceHandle, 0, NULL);

        if(result) output_string(STRING_START_SVC_SUCCESS, service_display_name);
        else
        {
            if (!output_error_string(GetLastError()))
                output_string(STRING_START_SVC_FAIL, service_display_name);
        }
        break;
    case NET_STOP:
        output_string(STRING_STOP_SVC, service_display_name);
        result = StopService(SCManager, serviceHandle);

        if(result) output_string(STRING_STOP_SVC_SUCCESS, service_display_name);
        else
        {
            if (!output_error_string(GetLastError()))
                output_string(STRING_STOP_SVC_FAIL, service_display_name);
        }
        break;
    }

    CloseServiceHandle(serviceHandle);
    CloseServiceHandle(SCManager);
    return result;
}
Exemplo n.º 15
0
/**
 * fetch a static memory cell into the primary register
 * @param sym
 */
void gen_get_memory(SYMBOL *sym) {
    if ((sym->identity != POINTER) && (sym->type == CCHAR)) {
        output_with_tab ("lda\t");
        output_string (sym->name);
        newline ();
        gen_call ("ccsxt");
    } else if ((sym->identity != POINTER) && (sym->type == UCHAR)) {
        output_with_tab("lda\t");
        output_string(sym->name);
        newline();
        output_line("mov \tl,a");
        output_line("mvi \th,#0");
    } else {
        output_with_tab ("lhld\t");
        output_string (sym->name);
        newline ();
    }
}
Exemplo n.º 16
0
static
void parse_layout_v1(confword_t* data)
{
    mgconf_layout_data = &data[0];
    if (!verbose_boot)
        return;

    output_string("place layout\n", 2);
}
Exemplo n.º 17
0
/**
 * print all assembler info before any code is generated
 */
void header (void) {
    output_string ("; Small C 8080\n;\tCoder (2.4,84/11/27)\n;");
    frontend_version();
    newline ();
    output_line ("\t;program area SMALLC_GENERATED is RELOCATABLE");
    output_line ("\t.module SMALLC_GENERATED");
    output_line ("\t.list   (err, loc, bin, eqt, cyc, lin, src, lst, md)");
    output_line ("\t.nlist  (pag)");
}
Exemplo n.º 18
0
static int reg_query(WCHAR *key_name, WCHAR *value_name, BOOL value_empty,
    BOOL subkey)
{
    static const WCHAR stubW[] = {'S','T','U','B',' ','Q','U','E','R','Y',' ',
        '-',' ','%','1',' ','%','2',' ','%','3','!','d','!',' ','%','4','!','d','!','\n',0};
    output_string(stubW, key_name, value_name, value_empty, subkey);

    return 1;
}
Exemplo n.º 19
0
/**
 * asm - store the primary register into the specified static memory cell
 * @param sym
 */
void gen_put_memory(SYMBOL *sym) {
    if ((sym->identity != POINTER) && (sym->type & CCHAR)) {
        output_line ("mov \ta,l");
        output_with_tab ("sta \t");
    } else {
        output_with_tab ("shld\t");
    }
    output_string (sym->name);
    newline ();
}
Exemplo n.º 20
0
Arquivo: net.c Projeto: aragaer/wine
static BOOL net_enum_services(void)
{
    static const WCHAR runningW[]={' ',' ',' ',' ','%','s','\n',0};
    SC_HANDLE SCManager;
    LPENUM_SERVICE_STATUS_PROCESSW services;
    DWORD size, i, count, resume;
    BOOL success = FALSE;

    SCManager = OpenSCManagerW(NULL, NULL, SC_MANAGER_ALL_ACCESS);
    if(!SCManager)
    {
        output_string(STRING_NO_SCM);
        return FALSE;
    }

    EnumServicesStatusExW(SCManager, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_ACTIVE, NULL, 0, &size, &count, NULL, NULL);
    if(GetLastError() != ERROR_MORE_DATA)
    {
        output_error_string(GetLastError());
        goto end;
    }
    services = HeapAlloc(GetProcessHeap(), 0, size);
    resume = 0;
    if(!EnumServicesStatusExW(SCManager, SC_ENUM_PROCESS_INFO, SERVICE_WIN32, SERVICE_ACTIVE, (LPBYTE)services, size, &size, &count, &resume, NULL))
    {
        output_error_string(GetLastError());
        goto end;
    }
    output_string(STRING_RUNNING_HEADER);
    for(i = 0; i < count; i++)
    {
        output_printf(runningW, services[i].lpDisplayName);
        WINE_TRACE("service=%s state=%d controls=%x\n",
                   wine_dbgstr_w(services[i].lpServiceName),
                   services[i].ServiceStatusProcess.dwCurrentState,
                   services[i].ServiceStatusProcess.dwControlsAccepted);
    }
    success = TRUE;

 end:
    CloseServiceHandle(SCManager);
    return success;
}
Exemplo n.º 21
0
/*
   Dump insertion points
*/
static void dump_member (member m)
	{ if (is_an_invisible_member (m)) return;
	  switch (m -> tag)
	     { case tag_call: wlog (m -> u.call.nonterminal); break;
	       case tag_terminal: output_string (stderr, m -> u.terminal);
				  break;
	       case tag_semiterminal: wlog ("{}");
	       default: break;
	     };
	};
Exemplo n.º 22
0
static void describe_access(SYMBOL *sym)
{
    if (sym->storage == REGISTER) {
        output_string("r");
        output_number(sym->offset);
        newline();
        return;
    }
    output_byte('(');
    if (sym->storage == LSTATIC) {
        print_label(sym->offset);
    } else if (sym->storage == AUTO || sym->storage == DEFAUTO) {
        output_number(sym->offset);
        output_string("+fp");
    } else
        output_label_name(sym->name);
    output_byte(')');
    newline();
}
Exemplo n.º 23
0
/** \brief prints 2 messages, returns 0.
 * \param argc nr of args, unused
 * \param argv arguments, unused
 * \param env Environment, unused
 * \param api API interface, used for print functions
 * */
int lmain(int argc, char **argv, char *env, struct loader_api_s *api) {
    void (*output_string)(const char *, int) = api->print_string;
    void (*output_int)(int, int) = api->print_int;
    (void)api;
    (void)argc;
    (void)argv;
    (void)env;
    output_string("The answer is 42\n", 1);
    return 0;
}
Exemplo n.º 24
0
void parse_asmdirective(char *dir, char *str, int integer, float fnum)
{
    if (strcmp(dir, ".text") == 0) // deprecated
    {
        Warning("Deprecated assembler directive %s", dir);
    }
    else if (strcmp(dir, ".data") == 0) // deprecated
    {
        Warning("Deprecated assembler directive %s", dir);
    }
    else if (strcmp(dir, ".byte") == 0)
    {
        if (str)
        {
            Error("Unsupported data type for label");
        }

        emit8(integer);
    }
    else if (strcmp(dir, ".word") == 0)
    {
        if (str)
        {
            Error("Unsupported data type for label");
        }

        emit16(integer);
    }
    else if (strcmp(dir, ".dword") == 0)
    {
        if (str)
        {
            AddRelocEntry(str, codeptr);
            emit32(0);
        }
        else
        {
            emit32(integer);
        }
    }
    else if (strcmp(dir, ".float") == 0)
    {
        if (str)
        {
            Error("Unsupported data type for label");
        }

        emitfloat(fnum);
    }
    else if (strcmp(dir, ".string") == 0)
    {
        assert(str != 0);
        output_string(str);
    }
}
Exemplo n.º 25
0
void
grad_utent_print_header(format_data_t *form)
{
	int i, outbytes = 0;
	format_data_t *p;

	for (p = form; p; p = p->next) 
		if (p->type == FDATA_NEWLINE)
			return;
	
	for (; form; form = form->next) {
		switch (form->type) {
		case FDATA_FH:
			if (form->v.fh.header)
				outbytes += output_string(form->v.fh.header,
							  form->v.fh.width,
							  ALIGN_LEFT);
			else
				outbytes += form->v.fh.width;
			break;
				
		case FDATA_STRING:
			outbytes += output_string("",
						  strlen(form->v.string),
						  ALIGN_LEFT);
			break;
			
		case FDATA_TAB:
			outbytes += output_tab(outbytes, form->v.tabstop);
			break;

		case FDATA_NEWLINE:
			for (i = 0; i < form->v.nl; i++)
				putchar('\n');
			break;
			
		default:
			abort();
		}
	}
	putchar('\n');
}
Exemplo n.º 26
0
static void crash_handler(int signum, siginfo_t *info, void *data) {
  void *addrlist[MAX_FRAMES + 1];
  int addrlen;

  output_string("\n\n\n*******************************\nCaught signal ");
  output_num(signum);
  output_string("\n");

  addrlen = backtrace(addrlist, GPR_ARRAY_SIZE(addrlist));

  if (addrlen == 0) {
    output_string("  no backtrace\n");
  } else {
    backtrace_symbols_fd(addrlist, addrlen, STDERR_FILENO);
  }

  /* try to get a core dump for SIGTERM */
  if (signum == SIGTERM) signum = SIGQUIT;
  raise(signum);
}
Exemplo n.º 27
0
void gen_epilogue(void)
{
    int i;
    /* FIXME: usual case we can pop these in this order need to spot the
       sp position and optimize accordingly */
    for (i = nextreg - 1; i >= 3; i--) {
        if (stkp == regv[i]) {
            stkp += 2;
            output_with_tab("pop r");
            output_number(i);
        } else {
            output_with_tab("load r");
            output_number(i);
            output_string(" (");
            output_number(regv[i]);
            output_string("+fp)");
        }
        newline();
    }
}
Exemplo n.º 28
0
static void
output_string_link (const char *link)
{
  if (csv)
    output_string (link);
  else {
    next_field ();

    if (printf ("-> %s", link) < 0)
      error (EXIT_FAILURE, errno, "printf");
  }
}
Exemplo n.º 29
0
/* stop memory, and delete any buffer that wasn't deleted */
void memory_stop(void)
{
	if (NULL != heaps) {
		/* we should never get here! */
		output_string("Warning: a buffer was not freed from the heap!\n");

		/* we won't delete anything because we don't know how this situation is even possible, and we want to avoid a used-after-free */
	}

	memory_dyn_clean(&dyn_global_head);
	memory_dyn_clean(&dyn_inter_head);
}
Exemplo n.º 30
0
Arquivo: ne.c Projeto: hagenkaye/ne
void about()
{
    clear_entire_screen();
    displaying_info = true;
    int i;
    for (i = 0; NO_WARRANTY_msg[i]; i++)
    {
        if (i == ne_lines - 1)
        {
            break;
        }
        move_cursor(i, 0);
        output_string(NO_WARRANTY_msg[i], false);
    }
    if (++i < ne_lines - 1)
    {
        move_cursor(i, 0);
        if (exists_gprefs_dir())
        {
            output_string("Global Directory: ", false);
            output_string(exists_gprefs_dir(), false);
        }
        else
        {
            output_string("Global directory \"", false);
            output_string(get_global_dir(), false);
            output_string("\" not found!", false);
        }
    }
    reset_window();
    print_message(ABOUT_MSG);
}