void menu::run_menu() { if (!is_open) return; reset_vars(); static int a_int = 0; static float a_float = 0; static bool a_bool = false; switch (current_menu) { case Main_Menu: { sub_title = "Main Menu"; option_count = 9; add_option_i("Edit Int", &a_int, 0, 100); add_option_f("Edit Float", &a_float, 0, 5); add_option_b("Toggle Bool", &a_bool); add_option_bc("Toggle Godmode", true, toggle_godmode, !*toggle_godmode()); add_option_c("Explode Self", explode_player, PLAYER::PLAYER_ID()); add_option_bc_arg("Spawn Adder", false, spawn_vehicle, true, "adder"); add_option_bc_arg("Change Model to Alien", false, set_model, true, "S_M_M_MovAlien_01"); add_option_c("Open Sub", change_menu, Sub_1); add_option_c("Players Menu", change_menu, Players); break; } case Sub_1: { sub_title = "Sub menu 1"; option_count = 15 + 1; for (int i = 0; i < 15; i++) { add_option_n(string("Option ") + string(i + 1)); } add_option_c("Open Nested Sub", change_menu, Sub_2); break; } case Sub_2: { sub_title = "A Nested Sub"; option_count = 3; add_option_n("Option 1"); add_option_n("Option 2"); add_option_n("Option 3"); break; } case Players: { sub_title = "Players Menu"; option_count = get_players_count(); for_player { char* name = PLAYER::GET_PLAYER_NAME(player); if (!strcmp(name, "**Invalid**")) continue; add_option_c(name, open_players_options, player); } break; } case Players_Options: { sub_title = PLAYER::GET_PLAYER_NAME(selected_player); option_count = 3; add_option_c("Blow Up", explode_player, selected_player); add_option_c("Teleport To", teleport, ENTITY::GET_ENTITY_COORDS(PLAYER::GET_PLAYER_PED(selected_player))); add_option_bc_arg("Drop Cash", true, toggle_cash_drop, !*toggle_cash_drop(0, selected_player), selected_player); break; } } }
int main(int argc, char **argv) { int i, rank, nproc, mpi_type_size; int errors = 0, all_errors = 0; TYPE_C *val_ptr, *res_ptr; MPI_Win win; MPI_Init(&argc, &argv); MPI_Comm_rank(MPI_COMM_WORLD, &rank); MPI_Comm_size(MPI_COMM_WORLD, &nproc); MPI_Type_size(TYPE_MPI, &mpi_type_size); assert(mpi_type_size == sizeof(TYPE_C)); val_ptr = malloc(sizeof(TYPE_C)*nproc); res_ptr = malloc(sizeof(TYPE_C)*nproc); MPI_Win_create(val_ptr, sizeof(TYPE_C)*nproc, sizeof(TYPE_C), MPI_INFO_NULL, MPI_COMM_WORLD, &win); /* Test self communication */ reset_vars(val_ptr, res_ptr, win); for (i = 0; i < ITER; i++) { TYPE_C one = 1, result = -1; MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win); MPI_Fetch_and_op(&one, &result, TYPE_MPI, rank, 0, MPI_SUM, win); MPI_Win_unlock(rank, win); } MPI_Win_lock(MPI_LOCK_EXCLUSIVE, rank, 0, win); if ( CMP(val_ptr[0], ITER) ) { SQUELCH( printf("%d->%d -- SELF: expected "TYPE_FMT", got "TYPE_FMT"\n", rank, rank, (TYPE_C) ITER, val_ptr[0]); ); errors++; }
int clean_suite_crypt_mpi(void) { ops_finish(); reset_vars(); return 0; }
void TachyonDisplayDevice::write_trailer(void){ fprintf(outfile, "End_Scene \n"); if (inclipgroup) { msgErr << "TachyonDisplayDevice clipping group still active at end of scene\n" << sendmsg; } msgInfo << "Tachyon file generation finished" << sendmsg; reset_vars(); }
void detectar_objetos(int x1, int y1, int x2, int y2) { char url[80]; reset_vars(); sprintf(url,"http://%s:8080/?action=snapshot", robot_ip); /* comm_get_http_file("http://10.0.20.201:8080/?action=snapshot", "archivo.jpg"); */ comm_get_http_file(url, "archivo.jpg"); detectar_colores("archivo.jpg", objetos); }
mrb_value mrb_f_syslog_close(mrb_state *mrb, mrb_value self) { mrb_value opened; opened = mrb_cv_get(mrb, self, mrb_intern_lit(mrb, "@opened")); if (! mrb_bool(opened)) { mrb_raise(mrb, E_RUNTIME_ERROR, "syslog not opened"); } closelog(); reset_vars(mrb, self); return mrb_nil_value(); }
void POV3DisplayDevice::write_trailer(void){ fprintf(outfile, "// End of POV-Ray 3.x generation \n"); if (degenerate_cones != 0) { msgWarn << "Skipped " << degenerate_cones << " degenerate cones" << sendmsg; } if (degenerate_cylinders != 0) { msgWarn << "Skipped " << degenerate_cylinders << " degenerate cylinders" << sendmsg; } if (degenerate_triangles != 0) { msgWarn << "Skipped " << degenerate_triangles << " degenerate triangles" << sendmsg; } reset_vars(); // Reset variables before the next rendering. }
TEST(thread_local_storage, shared) { reset_vars(); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2000); // Update shared_var, local_var remains 1000. ASSERT_EQ(run_one_thread(inc_shared_var), 2001); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2001); ASSERT_EQ(run_one_thread(inc_shared_var), 2002); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2002); ASSERT_EQ(run_one_thread(inc_shared_var), 2003); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2003); }
TEST(thread_local_storage, local) { reset_vars(); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2000); // When a child thread updates its own TLS variable, // this thread's local_var and shared_var are not changed. // TLS local_var is initialized to 100 in a thread. ASSERT_EQ(run_one_thread(inc_local_var), 101); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2000); ASSERT_EQ(run_one_thread(inc_local_var), 101); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2000); ASSERT_EQ(run_one_thread(inc_local_var), 101); ASSERT_EQ(local_var, 1000); ASSERT_EQ(shared_var, 2000); }
TachyonDisplayDevice::TachyonDisplayDevice() : FileRenderer ("Tachyon", "Tachyon", "vmdscene.dat", get_tachyon_run_string()) { // Add supported file formats formats.add_name("BMP", 0); formats.add_name("PPM", 0); formats.add_name("PPM48", 0); formats.add_name("PSD48", 0); formats.add_name("RGB", 0); formats.add_name("TGA", 0); // Set default aa level has_aa = TRUE; aasamples = 12; aosamples = 12; reset_vars(); // Default image format depends on platform #if defined(_MSC_VER) || defined(WIN32) curformat = 0; // Windows BMP #else curformat = 5; // Targa #endif }
/// constructor ... initialize some variables RenderManDisplayDevice::RenderManDisplayDevice() : FileRenderer("RenderMan","plot.rib", "rendrib -d 8 %s") { reset_vars(); // initialize material cache }
void GelatoDisplayDevice::write_trailer(void){ fprintf(outfile, "Render (\"camera\")\n"); fprintf(outfile, "# End Input\n"); reset_vars(); // reinitialize material cache }
GelatoDisplayDevice::GelatoDisplayDevice() : FileRenderer("Gelato", "NVIDIA Gelato 2.1", "vmdscene.pyg", "gelato %s") { reset_vars(); // initialize material cache }
int main(int argc, char *argv[]) { int retval = 1; set_aumessage_mode(MSG_STDERR, DBG_NO); if (argc == 1) { usage(); return 1; } #ifndef DEBUG /* Make sure we are root */ if (geteuid() != 0) { fprintf(stderr, "You must be root to run this program.\n"); return 4; } #endif /* Check where the rules are coming from: commandline or file */ if ((argc == 3) && (strcmp(argv[1], "-R") == 0)) { fd = audit_open(); if (audit_is_enabled(fd) == 2) { fprintf(stderr, "The audit system is in immutable " "mode, no rule changes allowed\n"); return 0; } else if (errno == ECONNREFUSED) { fprintf(stderr, "The audit system is disabled\n"); return 0; } else if (fileopt(argv[2])) return 1; else { if (continue_error < 0) return 1; return 0; } } else { if (reset_vars()) { free(rule_new); return 1; } retval = setopt(argc, 0, argv); if (retval == -3) { free(rule_new); return 0; } } if (add != AUDIT_FILTER_UNSET || del != AUDIT_FILTER_UNSET) { fd = audit_open(); if (audit_is_enabled(fd) == 2) { fprintf(stderr, "The audit system is in immutable " "mode, no rule changes allowed\n"); free(rule_new); return 0; } else if (errno == ECONNREFUSED) { fprintf(stderr, "The audit system is disabled\n"); free(rule_new); return 0; } } retval = handle_request(retval); free(rule_new); return retval; }
/* * This function reads the given file line by line and executes the rule. * It returns 0 if everything went OK, 1 if there are problems before reading * the file and -1 on error conditions after executing some of the rules. * It will abort reading the file if it encounters any problems. */ static int fileopt(const char *file) { int i, tfd, rc, lineno = 1; struct stat st; FILE *f; char buf[LINE_SIZE]; /* Does the file exist? */ rc = open(file, O_RDONLY); if (rc < 0) { if (errno != ENOENT) { fprintf(stderr,"Error opening %s (%s)\n", file, strerror(errno)); return 1; } fprintf(stderr, "file %s doesn't exist, skipping\n", file); return 0; } tfd = rc; /* Is the file permissions sane? */ if (fstat(tfd, &st) < 0) { fprintf(stderr, "Error fstat'ing %s (%s)\n", file, strerror(errno)); close(tfd); return 1; } if (st.st_uid != 0) { fprintf(stderr, "Error - %s isn't owned by root\n", file); close(tfd); return 1; } if ((st.st_mode & S_IWOTH) == S_IWOTH) { fprintf(stderr, "Error - %s is world writable\n", file); close(tfd); return 1; } if (!S_ISREG(st.st_mode)) { fprintf(stderr, "Error - %s is not a regular file\n", file); close(tfd); return 1; } f = fdopen(tfd, "rm"); if (f == NULL) { fprintf(stderr, "Error - fdopen failed (%s)\n", strerror(errno)); close(tfd); return 1; } /* Read until eof, lineno starts as 1 */ while (get_line(f, buf)) { char *options[NUM_OPTIONS]; char *ptr; int idx=0; /* Weed out blank lines */ while (buf[idx] == ' ') idx++; if (buf[idx] == 0) { lineno++; continue; } preprocess(buf); ptr = strtok(buf, " "); if (ptr == NULL) break; /* allow comments */ if (ptr[0] == '#') { lineno++; continue; } i = 0; options[i++] = "auditctl"; options[i++] = ptr; while( (ptr=strtok(NULL, " ")) && i<NUM_OPTIONS-1 ) { postprocess(ptr); options[i++] = ptr; } options[i] = NULL; /* Parse it */ if (reset_vars()) { fclose(f); return -1; } rc = setopt(i, lineno, options); /* handle reply or send rule */ if (rc != -3) { if (handle_request(rc) == -1) { if (errno != ECONNREFUSED) fprintf(stderr, "There was an error in line %d of %s\n", lineno, file); else { fprintf(stderr, "The audit system is disabled\n"); fclose(f); return 0; } if (ignore == 0) { fclose(f); return -1; } if (continue_error) continue_error = -1; } } lineno++; } fclose(f); return 0; }
POV3DisplayDevice::POV3DisplayDevice() : FileRenderer("POV3", "POV-Ray 3.6", "vmdscene.pov", "povray +W%w +H%h -I%s -O%s.tga +D +X +A +FT") { reset_vars(); // initialize state variables }
int main() { time_t now = 0L; plan_tests(62); ok(test_start_time == 0L, "Start time is empty"); ok(test_comment == NULL, "And test_comment is blank"); ok(cmd_delete_downtime_by_start_time_comment(1, "1234567890;This is a comment") == OK, "cmd_delete_downtime_by_start_time_comment"); ok(test_start_time == 1234567890L, "Start time called correctly"); ok(strcmp(test_comment, "This is a comment") == 0, "comment set correctly"); ok(cmd_delete_downtime_by_start_time_comment(1, "") == ERROR, "cmd_delete_downtime_by_start_time_comment errors if no args sent"); ok(cmd_delete_downtime_by_start_time_comment(1, "1234;Comment;") == OK, "cmd_delete_downtime_by_start_time_comment"); ok(test_start_time == 1234, "Silly start time parsed but will get rejected lower down"); ok(strcmp(test_comment, "Comment;") == 0, "Comment with ; will get dropped: '%s' <--- not sure if this should be true or not", test_comment); ok(cmd_delete_downtime_by_start_time_comment(1, "1234;Comment with \n in it;") == OK, "cmd_delete_downtime_by_start_time_comment"); ok(strcmp(test_comment, "Comment with ") == 0, "Comment truncated at \\n") || diag("comment=%s", test_comment); ok(cmd_delete_downtime_by_start_time_comment(1, ";") == ERROR, "cmd_delete_downtime_by_start_time_comment error due to no args"); test_start_time = 0L; test_comment = "somethingelse"; ok(cmd_delete_downtime_by_start_time_comment(1, "badtime") == ERROR, "cmd_delete_downtime_by_start_time_comment error due to bad time value"); ok(cmd_delete_downtime_by_start_time_comment(1, "123badtime;comment") == OK, "cmd_delete_downtime_by_start_time_comment"); ok(test_start_time == 123L, "Partly bad start time is parsed, but that's an input problem"); ok(strcmp(test_comment, "comment") == 0, "Comment"); ok(cmd_delete_downtime_by_start_time_comment(1, ";commentonly") == OK, "cmd_delete_downtime_by_start_time_comment"); ok(test_start_time == 0L, "No start time, but comment is set"); ok(strcmp(test_comment, "commentonly") == 0, "Comment"); deleted = 0; ok(cmd_delete_downtime_by_start_time_comment(1, ";commentonly") == ERROR, "Got an error here because no items deleted"); /* Test deletion of downtimes by name */ ok(cmd_delete_downtime_by_host_name(1, "") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no args set"); ok(cmd_delete_downtime_by_host_name(1, ";svc;1234567890;Some comment") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 0, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(test_servicename == NULL, "servicename right"); ok(test_comment == NULL, "comment right"); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;svc1;;") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 0, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(strcmp(test_servicename, "svc1") == 0, "servicename right"); ok(test_comment == NULL, "comment right") || diag("comment=%s", test_comment); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;svc1") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 0, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(strcmp(test_servicename, "svc1") == 0, "servicename right"); ok(test_comment == NULL, "comment right") || diag("comment=%s", test_comment); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;svc1;1234567;") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 1234567L, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(strcmp(test_servicename, "svc1") == 0, "servicename right"); ok(test_comment == NULL, "comment right") || diag("comment=%s", test_comment); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;svc1;12345678") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 12345678L, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(strcmp(test_servicename, "svc1") == 0, "servicename right"); ok(test_comment == NULL, "comment right") || diag("comment=%s", test_comment); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;;12345678;comment too") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 12345678, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(test_servicename == NULL, "servicename right") || diag("servicename=%s", test_servicename); ok(strcmp(test_comment, "comment too") == 0, "comment right") || diag("comment=%s", test_comment); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;;12345678;") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 12345678, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(test_servicename == NULL, "servicename right") || diag("servicename=%s", test_servicename); ok(test_comment == NULL, "comment right") || diag("comment=%s", test_comment); reset_vars(); ok(cmd_delete_downtime_by_host_name(1, "host1;;;comment") == ERROR, "cmd_delete_downtime_by_start_time_comment - errors if no host name set"); ok(test_start_time == 0L, "start time right"); ok(strcmp(test_hostname, "host1") == 0, "hostname right"); ok(test_servicename == NULL, "servicename right") || diag("servicename=%s", test_servicename); ok(strcmp(test_comment, "comment") == 0, "comment right") || diag("comment=%s", test_comment); return exit_status(); }
void mrb_mruby_syslog_gem_init(mrb_state *mrb) { struct RClass *slog; slog = mrb_define_module(mrb, "Syslog"); mrb_define_module_function(mrb, slog, "open", mrb_f_syslog_open, MRB_ARGS_ANY()); mrb_define_module_function(mrb, slog, "_log0", mrb_f_syslog_log0, MRB_ARGS_REQ(1)); mrb_define_module_function(mrb, slog, "close", mrb_f_syslog_close, MRB_ARGS_NONE()); mrb_define_module_function(mrb, slog, "ident", mrb_f_syslog_ident, MRB_ARGS_NONE()); reset_vars(mrb, mrb_obj_value(slog)); /* Syslog options */ #define mrb_define_syslog_option(c) \ mrb_define_const(mrb, slog, #c, mrb_fixnum_value(c)) #ifdef LOG_PID mrb_define_syslog_option(LOG_PID); #endif #ifdef LOG_CONS mrb_define_syslog_option(LOG_CONS); #endif #ifdef LOG_ODELAY mrb_define_syslog_option(LOG_ODELAY); /* deprecated */ #endif #ifdef LOG_NDELAY mrb_define_syslog_option(LOG_NDELAY); #endif #ifdef LOG_NOWAIT mrb_define_syslog_option(LOG_NOWAIT); /* deprecated */ #endif #ifdef LOG_PERROR mrb_define_syslog_option(LOG_PERROR); #endif /* Syslog facilities */ #define mrb_define_syslog_facility(c) \ mrb_define_const(mrb, slog, #c, mrb_fixnum_value(c)) #ifdef LOG_AUTH mrb_define_syslog_facility(LOG_AUTH); #endif #ifdef LOG_AUTHPRIV mrb_define_syslog_facility(LOG_AUTHPRIV); #endif #ifdef LOG_CONSOLE mrb_define_syslog_facility(LOG_CONSOLE); #endif #ifdef LOG_CRON mrb_define_syslog_facility(LOG_CRON); #endif #ifdef LOG_DAEMON mrb_define_syslog_facility(LOG_DAEMON); #endif #ifdef LOG_FTP mrb_define_syslog_facility(LOG_FTP); #endif #ifdef LOG_KERN mrb_define_syslog_facility(LOG_KERN); #endif #ifdef LOG_LPR mrb_define_syslog_facility(LOG_LPR); #endif #ifdef LOG_MAIL mrb_define_syslog_facility(LOG_MAIL); #endif #ifdef LOG_NEWS mrb_define_syslog_facility(LOG_NEWS); #endif #ifdef LOG_NTP mrb_define_syslog_facility(LOG_NTP); #endif #ifdef LOG_SECURITY mrb_define_syslog_facility(LOG_SECURITY); #endif #ifdef LOG_SYSLOG mrb_define_syslog_facility(LOG_SYSLOG); #endif #ifdef LOG_USER mrb_define_syslog_facility(LOG_USER); #endif #ifdef LOG_UUCP mrb_define_syslog_facility(LOG_UUCP); #endif #ifdef LOG_LOCAL0 mrb_define_syslog_facility(LOG_LOCAL0); #endif #ifdef LOG_LOCAL1 mrb_define_syslog_facility(LOG_LOCAL1); #endif #ifdef LOG_LOCAL2 mrb_define_syslog_facility(LOG_LOCAL2); #endif #ifdef LOG_LOCAL3 mrb_define_syslog_facility(LOG_LOCAL3); #endif #ifdef LOG_LOCAL4 mrb_define_syslog_facility(LOG_LOCAL4); #endif #ifdef LOG_LOCAL5 mrb_define_syslog_facility(LOG_LOCAL5); #endif #ifdef LOG_LOCAL6 mrb_define_syslog_facility(LOG_LOCAL6); #endif #ifdef LOG_LOCAL7 mrb_define_syslog_facility(LOG_LOCAL7); #endif /* Syslog levels and the shortcut methods */ #define mrb_define_syslog_level(c, m) \ mrb_define_const(mrb, slog, #c, mrb_fixnum_value(c)); #ifdef LOG_EMERG mrb_define_syslog_level(LOG_EMERG, emerg); #endif #ifdef LOG_ALERT mrb_define_syslog_level(LOG_ALERT, alert); #endif #ifdef LOG_CRIT mrb_define_syslog_level(LOG_CRIT, crit); #endif #ifdef LOG_ERR mrb_define_syslog_level(LOG_ERR, err); #endif #ifdef LOG_WARNING mrb_define_syslog_level(LOG_WARNING, warning); #endif #ifdef LOG_NOTICE mrb_define_syslog_level(LOG_NOTICE, notice); #endif #ifdef LOG_INFO mrb_define_syslog_level(LOG_INFO, info); #endif #ifdef LOG_DEBUG mrb_define_syslog_level(LOG_DEBUG, debug); #endif }
void RenderManDisplayDevice::write_trailer(void){ fprintf(outfile, "WorldEnd\n"); reset_vars(); // reinitialize material cache }