static void command(struct skynet_context *ctx, struct package *P, int session, uint32_t source, const char *msg, size_t sz) { switch (msg[0]) { case 'R': // request a package if (P->closed) { skynet_send(ctx, 0, source, PTYPE_ERROR, session, NULL, 0); break; } if (!queue_empty(&P->response)) { assert(queue_empty(&P->request)); struct response resp; queue_pop(&P->response, &resp); skynet_send(ctx, 0, source, PTYPE_RESPONSE | PTYPE_TAG_DONTCOPY, session, resp.msg, resp.sz); } else { struct request req; req.source = source; req.session = session; queue_push(&P->request, &req); } break; case 'K': // shutdown the connection skynet_socket_shutdown(ctx, P->fd); break; case 'I': report_info(ctx, P, session, source); break; default: // invalid command skynet_error(ctx, "Invalid command %.*s", (int)sz, msg); skynet_send(ctx, 0, source, PTYPE_ERROR, session, NULL, 0); break; }; }
int main(int argc, char *argv[]) { parse_arg_list(argc, argv); open_logfile(NULL); report_info("main()", "About Server:\nName: %s\nPID: %d\nAddress: %s\nPort: %d", server_name, getpid(), inet_ntoa(*(struct in_addr *)&server_address), server_port); start_server(); return 0; }
void run_proc(std::string command_line) { report_info("Running: " + command_line); // execute the process STARTUPINFO startup_info = { 0 }; startup_info.cb = sizeof(startup_info); PROCESS_INFORMATION process_info = { 0 }; CreateProcessW(NULL, const_cast<char16 *>(utf8::cvt<std::wstring>(command_line).c_str()), NULL, NULL, FALSE, 0, NULL, NULL, &startup_info, &process_info); CloseHandle(process_info.hProcess); CloseHandle(process_info.hThread); }
static bool MinidumpCallback(const wchar_t *minidump_folder, const wchar_t *minidump_id, void *context, EXCEPTION_POINTERS*, MDRawAssertionInfo*, bool) { ExceptionManager* this_ptr = reinterpret_cast<ExceptionManager*>(context); report_info("Detected crash..."); std::string minidump_path = utf8::cvt<std::string>(minidump_folder) + "\\" + utf8::cvt<std::string>(minidump_id) + ".dmp"; if (minidump_path.length() >= MAX_PATH) { report_error("Path to long"); return false; } if (!boost::filesystem::is_regular(minidump_path)) { report_error("Failed to create mini dump please check that you have a proper version of dbghlp.dll"); return false; } std::string path = modulePath() + "\\reporter.exe"; if (path.length() >= MAX_PATH) { report_error("Path to long"); return false; } if (!boost::filesystem::is_regular(path)) { report_error("Failed to find reporter.exe"); return false; } if (this_ptr->is_archive()) { run_command(this_ptr, path, "archive", minidump_path, this_ptr->target()); } if (this_ptr->is_send()) { if (this_ptr->is_send_ui()) run_command(this_ptr, path, "send-gui", minidump_path, this_ptr->target()); else run_command(this_ptr, path, "send", minidump_path, this_ptr->target()); } #ifdef WIN32 if (this_ptr->is_restart()) { std::vector<std::string> commands; try { if (!serviceControll::isStarted(utf8::cvt<std::wstring>(this_ptr->service()))) { report_error("Service not started, not restarting..."); return true; } } catch (...) { report_error("Failed to check service state"); } commands.push_back(path); commands.push_back("restart"); commands.push_back(this_ptr->service()); run_proc(build_commandline(commands)); } #endif return true; }
static void init(void) { if (piglit_is_extension_supported("GL_ARB_vertex_shader")) { glGetIntegerv(GL_MAX_TEXTURE_COORDS, &MaxTextureCoordUnits); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &MaxTextureImageUnits); glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS, &MaxTextureVertexUnits); glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &MaxTextureCombinedUnits); } else if (piglit_is_extension_supported("GL_ARB_fragment_shader") || piglit_is_extension_supported("GL_ARB_fragment_program")) { glGetIntegerv(GL_MAX_TEXTURE_COORDS, &MaxTextureCoordUnits); glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS, &MaxTextureImageUnits); MaxTextureVertexUnits = 0; MaxTextureCombinedUnits = MaxTextureImageUnits; } else { glGetIntegerv(GL_MAX_TEXTURE_UNITS, &MaxTextureCoordUnits); MaxTextureImageUnits = MaxTextureCombinedUnits = MaxTextureCoordUnits; MaxTextureVertexUnits = 0; } report_info(); if (MaxTextureCombinedUnits > MAX_UNITS) { /* Need to increase the MAX_UNITS limit */ piglit_report_result(PIGLIT_WARN); } generate_random_numbers(); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); }
int bench_main(int argc, char *argv[]) { double tmin = 0.0; double tol; int repeat = 0; int rounds = 10; int iarounds = 0; int arounds = 1; /* this is too low for precise results */ int c; report = report_verbose; /* default */ verbose = 0; tol = SINGLE_PRECISION ? 1.0e-3 : (QUAD_PRECISION ? 1e-29 : 1.0e-10); main_init(&argc, &argv); bench_srand(1); while ((c = my_getopt (argc, argv, options)) != -1) { switch (c) { case 't' : tmin = strtod(my_optarg, 0); break; case 'r': repeat = atoi(my_optarg); break; case 's': timer_init(tmin, repeat); speed(my_optarg, 0); break; case 'S': timer_init(tmin, repeat); speed(my_optarg, 1); break; case 'd': report_can_do(my_optarg); break; case 'o': useropt(my_optarg); break; case 'v': if (verbose >= 0) { /* verbose < 0 disables output */ if (my_optarg) verbose = atoi(my_optarg); else ++verbose; } break; case 'y': verify(my_optarg, rounds, tol); break; case 'a': accuracy(my_optarg, arounds, iarounds); break; case 'i': report_info(my_optarg); break; case 'I': report_info_all(); break; case 'h': if (verbose >= 0) my_usage(argv[0], options); break; case 300: /* --report-mflops */ report = report_mflops; break; case 310: /* --report-time */ report = report_time; break; case 320: /* --report-benchmark */ report = report_benchmark; break; case 330: /* --report-verbose */ report = report_verbose; break; case 400: /* --print-time-min */ timer_init(tmin, repeat); ovtpvt("%g\n", time_min); break; case 401: /* --verify-rounds */ rounds = atoi(my_optarg); break; case 402: /* --print-precision */ if (SINGLE_PRECISION) ovtpvt("single\n"); else if (QUAD_PRECISION) ovtpvt("quad\n"); else if (LDOUBLE_PRECISION) ovtpvt("long-double\n"); else if (DOUBLE_PRECISION) ovtpvt("double\n"); else ovtpvt("unknown %d\n", sizeof(bench_real)); break; case 403: /* --verify-tolerance */ tol = strtod(my_optarg, 0); break; case 404: /* --random-seed */ bench_srand(atoi(my_optarg)); break; case 405: /* --accuracy-rounds */ arounds = atoi(my_optarg); break; case 406: /* --impulse-accuracy-rounds */ iarounds = atoi(my_optarg); break; case '?': /* my_getopt() already printed an error message. */ cleanup(); return 1; default: abort (); } } /* assume that any remaining arguments are problems to be benchmarked */ while (my_optind < argc) { timer_init(tmin, repeat); speed(argv[my_optind++], 0); } cleanup(); return 0; }
int bench_main(int argc, char *argv[]) { double tmin = 0.0; double tol; int repeat = 0; int rounds = 10; int iarounds = 0; int arounds = 1; /* this is too low for precise results */ int c; int index; char *short_options = make_short_options(long_options); check_alignment(&tol); report = report_verbose; /* default */ verbose = 0; tol = SINGLE_PRECISION ? 1.0e-3 : 1.0e-10; bench_srand(1); while ((c = getopt_long (argc, argv, short_options, long_options, &index)) != -1) { switch (c) { case 't' : tmin = strtod(optarg, 0); break; case 'r': repeat = atoi(optarg); break; case 's': timer_init(tmin, repeat); speed(optarg); break; case 'd': report_can_do(optarg); break; case 'o': useropt(optarg); break; case 'v': if (optarg) verbose = atoi(optarg); else ++verbose; break; case 'y': verify(optarg, rounds, tol); break; case 'a': accuracy(optarg, arounds, iarounds); break; case 'i': report_info(optarg); break; case 'I': report_info_all(); break; case 'h': usage(argv[0], long_options); break; case 300: /* --report-mflops */ report = report_mflops; break; case 310: /* --report-time */ report = report_time; break; case 320: /* --report-benchmark */ report = report_benchmark; break; case 330: /* --report-verbose */ report = report_verbose; break; case 400: /* --print-time-min */ timer_init(tmin, repeat); ovtpvt("%g\n", time_min); break; case 401: /* --verify-rounds */ rounds = atoi(optarg); break; case 402: /* --print-precision */ if (SINGLE_PRECISION) ovtpvt("single\n"); else if (LDOUBLE_PRECISION) ovtpvt("long-double\n"); else if (DOUBLE_PRECISION) ovtpvt("double\n"); else ovtpvt("unknown %d\n", sizeof(bench_real)); break; case 403: /* --verify-tolerance */ tol = strtod(optarg, 0); break; case 404: /* --random-seed */ bench_srand(atoi(optarg)); break; case 405: /* --accuracy-rounds */ arounds = atoi(optarg); break; case 406: /* --impulse-accuracy-rounds */ iarounds = atoi(optarg); break; case '?': /* `getopt_long' already printed an error message. */ break; default: abort (); } } /* assume that any remaining arguments are problems to be benchmarked */ while (optind < argc) { timer_init(tmin, repeat); speed(argv[optind++]); } cleanup(); bench_free(short_options); return 0; }
void do_menu_command( long menuResult) { short menuID; short menuItem; menuID= GET_MENU_ID(menuResult); menuItem= GET_MENU_ITEM(menuResult); switch (menuID) { case mApple: switch (menuItem) { case iAbout: break; default: #if defined(OP_PLATFORM_MAC_CFM) && !defined(OP_PLATFORM_MAC_CARBON_FLAG) { Str255 daName; GetMenuItemText(GetMenuHandle(mApple), menuItem, daName); OpenDeskAcc(daName); } #endif break; } break; case mFile: switch (menuItem) { case iOpen: case iOpenPassive: handle_open(menuItem==iOpen, false); break; case iOpenActiveUI: case iOpenPassiveUI: handle_open(menuItem==iOpenActiveUI, true); break; case iClose: close_front_window(); break; case iQuit: handle_quit(); break; } break; case mSpecial: switch(menuItem) { case iSendPacket: send_packet(); break; case iSendStream: send_stream(); break; case iProtocolAlive: is_alive(); break; case iAcceptingConnections: accepting_connections= !accepting_connections; check_menu_item(menuID, menuItem, accepting_connections); break; case iActiveEnumeration: active_enumeration= !active_enumeration; check_menu_item(menuID, menuItem, active_enumeration); break; case iSetTimeout: set_timeout(); break; case iGetInfo: report_info(); break; case iGetConfigString: // get_config_string(); break; } break; case mWindowMenu: switch(menuItem) { case iCascade: case iTile: cascade_or_tile_windows(menuItem==iCascade); break; } } #if OP_PLATFORM_MAC_CFM || OP_PLATFORM_MAC_MACHO HiliteMenu(0); #endif adjust_menus(); return; }