Settings::Settings() { parse_settings( read_file( "settings.txt" ) ); generate_screen_params(); }
static ErlDrvData emonk_start(ErlDrvPort port, char *cmd) { uint rt_max, gc_max, gc_last, ctx; emonk_drv_t* drv = NULL; ErlDrvData ret = ERL_DRV_ERROR_GENERAL; emonk_settings_t settings; if(parse_settings(cmd, &settings) < 0) { ret = ERL_DRV_ERROR_BADARG; goto error; } drv = (emonk_drv_t*) driver_alloc(sizeof(emonk_drv_t)); if(drv == NULL) goto error; drv->port = port; drv->ok = driver_mk_atom("ok"); drv->error = driver_mk_atom("error"); drv->undefined = driver_mk_atom("undefined"); drv->bad_cmd = driver_mk_atom("bad_command"); drv->vm = init_vm(&settings); if(drv->vm == NULL) goto error; return (ErlDrvData) drv; error: if(drv != NULL) driver_free(drv); return ret; }
static bool read_settings (struct x_display_info *dpyinfo, struct xsettings *settings) { Atom act_type; int act_form; unsigned long nitems, bytes_after; unsigned char *prop = NULL; Display *dpy = dpyinfo->display; int rc; bool got_settings = false; x_catch_errors (dpy); rc = XGetWindowProperty (dpy, dpyinfo->xsettings_window, dpyinfo->Xatom_xsettings_prop, 0, LONG_MAX, False, AnyPropertyType, &act_type, &act_form, &nitems, &bytes_after, &prop); if (rc == Success && prop != NULL && act_form == 8 && nitems > 0 && act_type == dpyinfo->Xatom_xsettings_prop) got_settings = parse_settings (prop, nitems, settings) != 0; XFree (prop); x_uncatch_errors (); return got_settings; }
void update_cot_settings(void) { FILE * ini ; ini = fopen_path(COTSETTINGS, "w"); fprintf(ini, ";\n; COT Settings INI\n;\n\n[Settings]\nTheme = %s ;\nSDTheme = %i;\nORSReboot = %i ;\nORSWipePrompt = %i ;\nBackupPrompt = %i ;\nSignatureCheckEnabled = %i ;\nBackupFormat = %i ;\nmaxX = %i ;\nmaxY = %i ;\ntouchY = %i ;\nLanguage = %s ;\n\n", currenttheme, is_sd_theme, orsreboot, orswipeprompt, backupprompt, signature_check_enabled, backupfmt, maxX, maxY, touchY, language); fclose(ini); parse_settings(); }
int main(int argc, char *argv[]) { if(argc < 2 || argc > 4) { printf("\n Usage: %s port [a|b] [name] \n",argv[0]); return 1; } sockfd = server_connect(argv[1]); if (sockfd < 0) { // something happened while trying to connect-- abort mission return -1; } parse_settings(argv[2], argv[3]); printf("Request name %s and team %d\n", name, team); //construct proper sendBuff //(name, team) snprintf(sendBuff, sizeof sendBuff, "%s %d", name, team); // send it send_to_server(); // read reply read_from_server(); //printf("Bytes written: %d. Bytes read: %d.\n%s\n", writtenbytes, readbytes, recvBuff); sscanf(recvBuff, "%s", recvName); printf("%s\n", recvBuff); char *ghs = "Game has already started"; if(strcmp(ghs, recvBuff) == 0){ close(sockfd); return 0; } initscr(); loading_screen(); display_teams(); start_color(); initscr(); loadMap(mapNameFromServer); teamInfoMap(); initBoard();/* creates play board */ refresh();/* Print it on to the real screen */ load_players(); //place_players(); control_test(); final_standings(); getch(); endwin(); close(sockfd); return 0; }
void * parse_driver_settings_string(const char *settingsString) { // we simply copy the whole string to use it as our internal buffer char *text = strdup(settingsString); if (settingsString == NULL || text != NULL) { settings_handle *handle = malloc(sizeof(settings_handle)); if (handle != NULL) { handle->magic = SETTINGS_MAGIC; handle->text = text; if (parse_settings(handle) == B_OK) return handle; free(handle); } free(text); } return NULL; }
static settings_handle * load_driver_settings_from_file(int file) { struct stat stat; // Allocate a buffer and read the whole file into it. // We will keep this buffer in memory, until the settings // are unloaded. // The driver_parameter::name field will point directly // to this buffer. if (fstat(file, &stat) < B_OK) return NULL; if (stat.st_size > B_OK && stat.st_size < MAX_SETTINGS_SIZE) { char *text = (char *)malloc(stat.st_size + 1); if (text != NULL && read(file, text, stat.st_size) == stat.st_size) { settings_handle *handle = malloc(sizeof(settings_handle)); if (handle != NULL) { text[stat.st_size] = '\0'; handle->magic = SETTINGS_MAGIC; handle->text = text; if (parse_settings(handle) == B_OK) { return handle; } free(handle); } } // "text" might be NULL here, but that's allowed free(text); } return NULL; }
int main (int argc, char **argv) { char command [CMD_SIZE]; int initialize_tape = 1; int tape_status = 5; int status; unsigned char *beam_ptr; int first_time = TRUE; LL_beam_rec *enet_pak; extern process_exit(); extern print_target_elev (); /* trap signals */ (void) signal (SIGINT, ((void (*) ()) process_exit)); (void) signal (SIGHUP, ((void (*) ()) process_exit)); (void) signal (SIGTERM, ((void (*) ()) process_exit)); enet_pak = (LL_beam_rec *) malloc ((unsigned) sizeof (LL_beam_rec)); if (enet_pak == NULL) { (void) printf ("Malloc error \n"); return (-1); } if ((!get_params (&Glob))) exit (2); /* initialize streams (fmq and/or shmem) for sending beam data */ if (init_streams ()) { (void) fprintf (stderr, "streams initialization error"); return (1); } if (system ("clear") != 0) perror ("clear"); /* Determine the source of the data to be reformatted */ if (!Glob.real_time) { /* initialize the shared memory for receiving commands*/ if (recv_cmd (1, Glob.cmd_shmem_key, (unsigned char **) &command) == -1) { (void) printf ("recv_cmd fatal error\n"); exit (-1); } for (;;) { if ((status = get_shm_cmd (command)) > 0) break; else if (first_time) { first_time = FALSE; (void) printf ("waiting for menu process to send start command\n"); } sleep (2); } source = parse_settings (command, &Glob); if (source < 0) return (0); } else source = RADAR; switch (source) { case RADAR: if (recv_shm (1, Glob.input_shmem_key, &beam_ptr)) { (void) printf ("recv_shm fatal error\n"); exit (-1); } for (;go ;) { if (get_shmem_data (enet_pak, Glob.input_shmem_key) == 0) { if (first_time) { (void) printf ("waiting for data\n"); first_time = FALSE; } usleep (no_packet); } /* Check for a stop command */ if (!Glob.real_time) { if ((status = get_shm_cmd (command)) > 0) { source = parse_settings (command, &Glob); if (source < 0) go = 0; if (source == FLAG_CHANGE) { (void) printf ("\n Flag status: Dealias failure = %s\n", Glob.caf ? "TRUE":"FALSE"); (void) printf (" Point Target = %s\n", Glob.ctf ? "TRUE":"FALSE"); (void) printf (" SNR thresholding = %s\n", Glob.cvf ? "TRUE":"FALSE"); (void) printf (" Clutter = %s\n", Glob.ccv ? "TRUE":"FALSE"); (void) printf (" low PRF in valid gate = %s\n\n", Glob.cv ? "TRUE":"FALSE"); } } } } break; case TAPE: if (Glob.remote_tape) { if (tape_init (&fd_tape, Glob.tape_device)) { (void) printf("Error initializing the tape device %s", Glob.tape_device); source = -1; return (0); } } for (;go ;) { if (initialize_tape) { initialize_tape = FALSE; tape_command (); } tape_status = get_tape_data (fd_tape, data_rate, enet_pak); switch (tape_status) { case 0: /* automatically rewind the tape * when end of tape is detected */ /* tape_rewind = REWIND; initialize_tape = TRUE; */ /* or stop the system at the end of the tape */ (void) printf ("Received STOP command \n"); go = 0; exit (0); break; case INITIALIZE_RMT: (void) close (fd_tape); if (tape_init (&fd_tape, Glob.tape_device)) { (void) printf("Error initializing the tape device %s", Glob.tape_device); source = -1; return (0); } break; case INITIALIZE: initialize_tape = TRUE; break; case REWIND: /*go = 0; exit (0); break;*/ tape_rewind = REWIND; initialize_tape = TRUE; break; case TAPE_ERR: (void) printf ("Tape read error / received STOP command \n"); go = 0; break; case RATE_CHANGE: initialize_tape = FALSE; break; case PAUSE: for (;;) { if (Glob.remote_tape) { (void) rmt_close (); } if ((status = get_shm_cmd (command)) > 0) { if (Glob.remote_tape) { if (tape_init (&fd_tape, Glob.tape_device)) { (void) printf("Error initializing the tape device %s", Glob.tape_device); go = 0; } } break; } else usleep (3000); } break; case FLAG_CHANGE: (void) printf ("\n Flag status: Dealias failure = %s\n", Glob.caf ? "TRUE":"FALSE"); (void) printf (" Point Target = %s\n", Glob.ctf ? "TRUE":"FALSE"); (void) printf (" SNR thresholding = %s\n", Glob.cvf ? "TRUE":"FALSE"); (void) printf (" Clutter = %s\n", Glob.ccv ? "TRUE":"FALSE"); (void) printf (" low PRF in valid gate = %s\n\n", Glob.cv ? "TRUE":"FALSE"); } } break; default: (void) printf ("source unrecognized \n"); break; } return (0); }
static void read_settings (GdkX11Screen *x11_screen, gboolean do_notify) { GdkScreen *screen = GDK_SCREEN (x11_screen); Atom type; int format; unsigned long n_items; unsigned long bytes_after; unsigned char *data; int result; GHashTable *old_list = x11_screen->xsettings; GValue value = G_VALUE_INIT; GValue *setting, *copy; x11_screen->xsettings = NULL; if (x11_screen->xsettings_manager_window) { GdkDisplay *display = x11_screen->display; Atom xsettings_atom = gdk_x11_get_xatom_by_name_for_display (display, "_XSETTINGS_SETTINGS"); gdk_x11_display_error_trap_push (display); result = XGetWindowProperty (gdk_x11_display_get_xdisplay (display), gdk_x11_window_get_xid (x11_screen->xsettings_manager_window), xsettings_atom, 0, LONG_MAX, False, xsettings_atom, &type, &format, &n_items, &bytes_after, &data); gdk_x11_display_error_trap_pop_ignored (display); if (result == Success && type != None) { if (type != xsettings_atom) { g_warning ("Invalid type for XSETTINGS property: %s", gdk_x11_get_xatom_name_for_display (display, type)); } else if (format != 8) { g_warning ("Invalid format for XSETTINGS property: %d", format); } else x11_screen->xsettings = parse_settings (data, n_items); XFree (data); } } /* Since we support scaling we look at the specific Gdk/UnscaledDPI setting if it exists and use that instead of Xft/DPI if it is set */ if (x11_screen->xsettings && !x11_screen->fixed_window_scale) { setting = g_hash_table_lookup (x11_screen->xsettings, "gdk-unscaled-dpi"); if (setting) { copy = g_new0 (GValue, 1); g_value_init (copy, G_VALUE_TYPE (setting)); g_value_copy (setting, copy); g_hash_table_insert (x11_screen->xsettings, "gtk-xft-dpi", copy); } } if (do_notify) notify_changes (x11_screen, old_list); if (old_list) g_hash_table_unref (old_list); g_value_init (&value, G_TYPE_INT); if (!screen->resolution_set) { /* This code is duplicated with gtksettings.c:settings_update_resolution(). * The update of the screen resolution needs to happen immediately when * gdk_x11_display_set_window_scale() is called, and not wait for events * to be processed, so we can't always handling it in gtksettings.c. * But we can't always handle it here because the DPI can be set through * GtkSettings, which we don't have access to. */ int dpi_int = 0; double dpi; const char *scale_env; double scale; if (gdk_screen_get_setting (GDK_SCREEN (x11_screen), "gtk-xft-dpi", &value)) dpi_int = g_value_get_int (&value); if (dpi_int > 0) dpi = dpi_int / 1024.; else dpi = -1.; scale_env = g_getenv ("GDK_DPI_SCALE"); if (scale_env) { scale = g_ascii_strtod (scale_env, NULL); if (scale != 0 && dpi > 0) dpi *= scale; } _gdk_screen_set_resolution (screen, dpi); } if (!x11_screen->fixed_window_scale && gdk_screen_get_setting (GDK_SCREEN (x11_screen), "gdk-window-scaling-factor", &value)) _gdk_x11_screen_set_window_scale (x11_screen, g_value_get_int (&value)); }
void init_from_stream(std::basic_istream< CharT >& strm) { init_from_settings(parse_settings(strm)); }