/**------------------------------------------------------**/ void print_R(char* out, const char *format, ...) { LOG_FILETYPE stderr_f; char buffer[64]; va_list argptr; va_start(argptr, format); VSNPRINTF(buffer, format, argptr); va_end(argptr); if(out == NULL) { printf_terminal(buffer); }else { if(!monitor_openappend(out,&stderr_f)) { if(!monitor_openwrite(out,&stderr_f)) { return; } } /* print to file */ (void)monitor_seek_end(&stderr_f); (void)monitor_write(buffer,&stderr_f); (void)monitor_close(&stderr_f); } }
static void sh3_close (int quitting) { monitor_close (quitting); if (parallel_in_use) { serial_close (parallel); parallel_in_use = 0; } }
/* 意大利面条式代码,但是暂时还没什么好的错误处理方法 */ static int server_start(void) { int flag; #ifdef HAVE_DB flag = db_init(oracle_servername, oracle_username, oracle_password); if (flag == -1) { return -1; } INFO("Database initilize!"); #endif flag = spam_init(spam_thresold, spam_data); if (flag == -1) { return -1; } flag = match_init(); if (flag == -1) { return -1; } flag = kill_init(); if (flag == -1) { match_close(); return -1; } flag = log_init(); if (flag == -1) { match_close(); kill_close(); return -1; } flag = monitor_init(); if (flag == -1) { match_close(); kill_close(); log_close(); return -1; } flag = analy_init(netcard); if (flag == -1) { match_close(); kill_close(); log_close(); monitor_close(); } return 0; }
static void vm_deinit_vdevs(struct vmctx *ctx) { deinit_pci(ctx); monitor_close(); if (debugexit_enabled) deinit_debugexit(); vhpet_deinit(ctx); vpit_deinit(ctx); vrtc_deinit(ctx); ioc_deinit(ctx); atkbdc_deinit(ctx); pci_irq_deinit(ctx); ioapic_deinit(); deinit_vtpm2(ctx); }
/**------------------------------------------------------**/ void prints_R(char* out, const char *string) { LOG_FILETYPE stderr_f; if(out == NULL) { printf_terminal(string); }else { if(!monitor_openappend(out,&stderr_f)) { if(!monitor_openwrite(out,&stderr_f)) { return; } } /* print to file */ (void)monitor_seek_end(&stderr_f); (void)monitor_write(string,&stderr_f); (void)monitor_close(&stderr_f); } }
void prints_P(char* out, const char *string) { char buffer[32]; LOG_FILETYPE stderr_f; if(out == NULL) { printf_terminal_P(string); }else { STRCPY_P(buffer,string); if(!monitor_openappend(out,&stderr_f)) { if(!monitor_openwrite(out,&stderr_f)) { return; } } /* print to file */ (void)monitor_seek_end(&stderr_f); (void)monitor_write(buffer,&stderr_f); (void)monitor_close(&stderr_f); } }
static int vm_init_vdevs(struct vmctx *ctx) { int ret; init_mem(); init_inout(); pci_irq_init(ctx); atkbdc_init(ctx); ioapic_init(ctx); /* * We don't care ioc_init return value so far. * Will add return value check once ioc is full function. */ ret = ioc_init(ctx); ret = vrtc_init(ctx); if (ret < 0) goto vrtc_fail; ret = vpit_init(ctx); if (ret < 0) goto vpit_fail; ret = vhpet_init(ctx); if (ret < 0) goto vhpet_fail; sci_init(ctx); if (debugexit_enabled) init_debugexit(); ret = monitor_init(ctx); if (ret < 0) goto monitor_fail; ret = init_pci(ctx); if (ret < 0) goto pci_fail; init_vtpm2(ctx); return 0; pci_fail: monitor_close(); monitor_fail: if (debugexit_enabled) deinit_debugexit(); vhpet_deinit(ctx); vhpet_fail: vpit_deinit(ctx); vpit_fail: vrtc_deinit(ctx); vrtc_fail: ioc_deinit(ctx); atkbdc_deinit(ctx); pci_irq_deinit(ctx); ioapic_deinit(); return -1; }