int save_gen_b(GtkButton *button, FILE *file_p) { GtkWidget /**bt2,*/ *bt3, *bt4, *bt5 /*,*bt7, *bt8*/; gchar *bt1_t, *bt2_t; long count = 0, del = 0; int timeflag = 0/*, index = 0*/; //bt2 = lookup_widget(GTK_WIDGET (button), "optionmenu9"); bt3 = lookup_widget(GTK_WIDGET (button), "entry109"); bt4 = lookup_widget(GTK_WIDGET (button), "entry110"); bt5 = lookup_widget(GTK_WIDGET(button), "checkbutton35"); bt1_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt3)); bt2_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt4)); //bt7 = GTK_OPTION_MENU(bt2)->menu; //bt8 = gtk_menu_get_active (GTK_MENU (bt7)); /* YYY we don't save this value, since we don't know how to load it. We don't know what packet this is */ //index = g_list_index (GTK_MENU_SHELL (bt7)->children, bt8); if (GTK_TOGGLE_BUTTON(bt5)->active) { count = -3; } else { /* there can be rubbish in this field */ if (check_digit(bt1_t, strlen(bt1_t), "Error: Number of packets to send field") == -1) return -1; count = strtol(bt1_t, (char **)NULL, 10); /* we allow to send 9999999 max */ if ( (count > 9999999) || (count < 1) ) { //printf("Error: Packets send number value\n"); error("Error: Packets send number value (1 - 9999999)"); return -1; } } /* there can be rubbish in this field */ if (check_digit(bt2_t, strlen(bt2_t), "Error: Delay between packets field") == -1) return -1; del = strtol(bt2_t, (char **)NULL, 10); /* max delay 999,999999 s */ if ( (del > 999999999) || (del < 1) ) { //printf("Error: Delay between packets value\n"); error("Error: Delay between packets value (1 - 999999999"); return -1; } fprintf(file_p, "#configuration parameters for send built generator\n"); fprintf(file_p, "#absolute/relative timing (1/0)\n%d\n" /*"#adjust parameters while sending\n%d\n"*/ "#number of packets to send (-3 for infinite)\n%ld\n" "#delay between packets (0 for max speed)\n%ld\n", timeflag /*,index*/, count, del); return 1; }
bool check_letterdigit(t_parser *parser, char *string, char end) { int i; if (DEBUG == true) printf("check_letterdigit : %s\n", &(string[parser->pos])); i = 0; if (check_letter(string[parser->pos]) == false && check_digit(string[parser->pos]) == false) return (false); while (string[++(parser->pos)] != end && string[parser->pos] != 0) { ++i; if (check_letter(string[parser->pos]) == false && check_digit(string[parser->pos]) == false) { parser->pos -= i; return (dspb("letter", false)); } } if (string[parser->pos] != end) { parser->pos -= i; return (dspb("letter", false)); } ++(parser->pos); return (dspb("letter", true)); }
int init(int argc, char **argv, struct config *status) { status->port = NULL; status->root_dir = NULL; status->backlog = 1024; static struct option long_options[] = { {"help", no_argument, 0, 'h'}, {"port", required_argument, 0, 'p'}, {"root-dir", required_argument, 0, 'r' }, {"backlog", required_argument, 0, 'b'}, {0, 0, 0, 0} }; int c, option_index; while ((c = getopt_long(argc, argv, "hp:r:b:", long_options, &option_index)) != -1) { switch (c) { case 'h': { printf("Usage: %s [OPTIONS]\n", argv[0]); printf("\t--help \tDisplay this message\n"); printf("\t--port \tSet the port of the server\n"); printf("\t--root-dir\tSet the root directory of the server\n"); printf("\t--backlog\tSet the max incoming connections to listen to\n"); exit(EXIT_SUCCESS); } case 'b': { check_digit(optarg); status->backlog = (int)strtol(optarg, NULL, 10); break; } case 'p': { check_digit(optarg); status->port = strdup(optarg); break; } case 'r': { if (is_folder(optarg) == -1) { fprintf(stderr, "\"%s\" is not a directory\n", optarg); exit(EXIT_FAILURE); } if (status->root_dir) { free(status->root_dir); } status->root_dir = strdup(optarg); break; } default: break; } } if (status->port == NULL) { uid_t uid = geteuid(); status->port = strdup(uid == 0 ? "80" : "8080"); } if (status->root_dir == NULL) { status->root_dir = get_current_dir_name(); } return 0; }
int main(int argc, char **argv) { t_shell *head; int i; i = argc == 2 ? 0 : 1; if (argc == 2 && string_is_valid(argv[1])) argv = ft_strsplit(argv[1], ' '); if (argc == 1 || !(head = (t_shell*)malloc(sizeof(t_shell)))) return (0); init_head(head); while (argv[i]) { if (check_digit(argv[i]) == -1) return (flush(head->sa, 0)); head->sa = push_back_stack2(head->sa, ft_atoi(argv[i])); head->max = ft_atoi(argv[i]) > head->max ? ft_atoi(argv[i]) : head->max; i++; } head->len = l_len(head->sa); which_swap(head); free_lst(head); if (argc == 2) free_array(argv); if (head) free(head); return (0); }
/** * Test command to launch led_blink_x2 pattern: * ui led_blink_x2 <led_number> <color_green> <color_blue> <color_red> <intensity> <duration_on_1> <duration_off_1> <duration_on_2> <duration_off_2> <repetition_count> * * @param[in] argc Number of arguments in the Test Command (including group and name), * @param[in] argv Table of null-terminated buffers containing the arguments * @param[in] ctx The Test command response context */ void ui_led_blink_x2(int argc, char *argv[], struct tcmd_handler_ctx *ctx) { led_s *pattern; int8_t ret; char *message = balloc(sizeof(char) * BUFFER_LENGTH, NULL); ui_srv_data_t *ui_srv_values = balloc(sizeof(ui_srv_data_t), NULL); ui_srv_values->context = ctx; if (argc != 12) { snprintf(message, BUFFER_LENGTH, "Not the correct number of parameters"); goto err; } if (!(check_digit(argc, argv))) { snprintf(message, BUFFER_LENGTH, "Parameters shall be only digit"); goto err; } if ((ui_srv_values->ui_service_conn = ui_svc_tcmd_init()) == NULL) { snprintf(message, BUFFER_LENGTH, "service not registered"); goto err; } pattern = balloc(sizeof *pattern, NULL); #ifdef CONFIG_LED_MULTICOLOR /* Be careful not to put values higher than NCP5623C_PWM_MAX * defined in ncp5623c.h.*/ pattern->rgb[0].g = (uint8_t) (strtoul(argv[3], NULL, 16)); pattern->rgb[0].b = (uint8_t) (strtoul(argv[4], NULL, 16)); pattern->rgb[0].r = (uint8_t) (strtoul(argv[5], NULL, 16)); #endif pattern->intensity = (uint8_t) (atoi(argv[6])); pattern->duration[0].duration_on = (uint16_t) (atoi(argv[7])); pattern->duration[0].duration_off = (uint16_t) (atoi(argv[8])); pattern->duration[1].duration_on = (uint16_t) (atoi(argv[9])); pattern->duration[1].duration_off = (uint16_t) (atoi(argv[10])); pattern->repetition_count = (uint8_t) (atoi(argv[11])); ret = ui_play_led_pattern(ui_srv_values->ui_service_conn, (uint8_t) (atoi(argv[2])), LED_BLINK_X2, pattern, ui_srv_values); bfree(pattern); if (ret) { snprintf(message, BUFFER_LENGTH, "ui_play_led_pattern error %d", ret); goto err; } bfree(message); return; err: bfree(ui_srv_values); TCMD_RSP_ERROR(ctx, message); bfree(message); }
static int32 skip_atoi (const char **s) { int32 i; i = 0; while (check_digit (**s)) i = i*10 + *((*s)++) - '0'; return i; }
/* Checks if an integer is composable pandigitally using the given set of digits. * Returns: * -1 on failure (unavailable digit, multiples of digit, or 0 used) * 0 on exact match * 1 on a match which does not use all digits */ int composable(dmask m, int c) { int n; for (n = c; n != 0; n = n / 10) { int d = n % 10; if (d == 0) { return -1; } if (check_digit(m, d) == true) { return -1; } m = set_digit(m, d); } return m == FULL_DMASK ? 0 : 1; }
/** * Test command to launch led_none pattern: * ui led_none <led_number> * * @param[in] argc Number of arguments in the Test Command (including group and name), * @param[in] argv Table of null-terminated buffers containing the arguments * @param[in] ctx The Test command response context */ void ui_led_none(int argc, char *argv[], struct tcmd_handler_ctx *ctx) { led_s *pattern; int8_t ret; char *message = balloc(sizeof(char) * BUFFER_LENGTH, NULL); ui_srv_data_t *ui_srv_values = balloc(sizeof(ui_srv_data_t), NULL); ui_srv_values->context = ctx; if (argc != 3) { snprintf(message, BUFFER_LENGTH, "Not the correct number of parameters"); goto err; } if (!(check_digit(argc, argv))) { snprintf(message, BUFFER_LENGTH, "led_number shall be only digit"); goto err; } if ((ui_srv_values->ui_service_conn = ui_svc_tcmd_init()) == NULL) { snprintf(message, BUFFER_LENGTH, "service not registered"); goto err; } pattern = balloc(sizeof *pattern, NULL); ret = ui_play_led_pattern(ui_srv_values->ui_service_conn, (uint8_t) (atoi(argv[2])), LED_NONE, pattern, ui_srv_values); bfree(pattern); if (ret) { snprintf(message, BUFFER_LENGTH, "ui_play_led_pattern error %d", ret); goto err; } bfree(message); return; err: bfree(ui_srv_values); TCMD_RSP_ERROR(ctx, message); bfree(message); }
int itf14(struct zint_symbol *symbol, uint8_t source[], int length) { int error_number, zeroes; unsigned int count; char localstr[16]; error_number = 0; count = 0; if(length > 13) { strcpy(symbol->errtxt, "Input too long"); return ZERROR_TOO_LONG; } error_number = is_sane(NEON, source, length); if(error_number == ZERROR_INVALID_DATA) { strcpy(symbol->errtxt, "Invalid character in data"); return error_number; } /* Add leading zeros as required */ zeroes = 13 - length; for(int i = 0; i < zeroes; i++) { localstr[i] = '0'; } strcpy(localstr + zeroes, (char *)source); /* Calculate the check digit - the same method used for EAN-13 */ for (int i = 12; i >= 0; i--) { count += ctoi(localstr[i]); if (!(i & 1)) { count += 2 * ctoi(localstr[i]); } } localstr[13] = check_digit(count); localstr[14] = '\0'; error_number = interleaved_two_of_five(symbol, (uint8_t *)localstr, strlen(localstr)); ustrcpy(symbol->text, (uint8_t*)localstr); return error_number; }
int dpleit(struct zint_symbol *symbol, uint8_t source[], int length) { /* Deutshe Post Leitcode */ int error_number; unsigned int count; char localstr[16]; int zeroes; error_number = 0; count = 0; if(length > 13) { strcpy(symbol->errtxt, "Input wrong length"); return ZERROR_TOO_LONG; } error_number = is_sane(NEON, source, length); if(error_number == ZERROR_INVALID_DATA) { strcpy(symbol->errtxt, "Invalid characters in data"); return error_number; } zeroes = 13 - length; for(int i = 0; i < zeroes; i++) localstr[i] = '0'; strcpy(localstr + zeroes, (char *)source); for (int i = 12; i >= 0; i--) { count += 4 * ctoi(localstr[i]); if (i & 1) { count += 5 * ctoi(localstr[i]); } } localstr[13] = check_digit(count); localstr[14] = '\0'; error_number = interleaved_two_of_five(symbol, (uint8_t *)localstr, strlen(localstr)); ustrcpy(symbol->text, (uint8_t*)localstr); return error_number; }
int dpident(struct zint_symbol *symbol, unsigned char source[], int length) { /* Deutsche Post Identcode */ int i, error_number, zeroes; unsigned int count; char localstr[16]; count = 0; if(length > 11) { strcpy(symbol->errtxt, "Input wrong length"); return ERROR_TOO_LONG; } error_number = is_sane(NEON, source, length); if(error_number == ERROR_INVALID_DATA1) { strcpy(symbol->errtxt, "Invalid characters in data"); return error_number; } zeroes = 11 - length; for(i = 0; i < zeroes; i++) localstr[i] = '0'; strcpy(localstr + zeroes, (char *)source); for (i = 10; i >= 0; i--) { count += 4 * ctoi(localstr[i]); if (i & 1) { count += 5 * ctoi(localstr[i]); } } localstr[11] = check_digit(count); localstr[12] = '\0'; error_number = interleaved_two_of_five(symbol, (unsigned char *)localstr, strlen(localstr)); ustrcpy(symbol->text, (unsigned char*)localstr); return error_number; }
static int check_alnum(int c) { return check_alpha(c) || check_digit(c); }
int save_gen_s(GtkButton *button, FILE *file_p) { GtkWidget *bt1, *bt2, *bt5, *bt6, *bt7; gchar *bt1_t, *bt2_t; long count = 0, del = 0; int i = 0, timeflag = 0; unsigned char pkttable[10][71]; long int partable[10][5]; char buff4[101]; bt1 = lookup_widget(GTK_WIDGET (button), "radiobutton36"); bt2 = lookup_widget(GTK_WIDGET (button), "radiobutton37"); bt5 = lookup_widget(GTK_WIDGET (button), "checkbutton36"); bt6 = lookup_widget(GTK_WIDGET (button), "entry151"); bt7 = lookup_widget(GTK_WIDGET (button), "entry152"); bt1_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt6)); bt2_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt7)); if (GTK_TOGGLE_BUTTON(bt1)->active) timeflag = 1; else timeflag = 0; if (GTK_TOGGLE_BUTTON(bt5)->active) { count = -3; } else { /* there can be rubbish in this field */ if (check_digit(bt1_t, strlen(bt1_t), "Error: Number of sequences to send field") == -1) return -1; count = strtol(bt1_t, (char **)NULL, 10); /* we allow to send 9999999 max */ if ( (count > 9999999) || (count < 1) ) { //printf("Error: Number of sequences to send field\n"); error("Error: Number of sequences to send field (1 - 9999999)"); return -1; } } if (count == 1) del = 0; else { /* there can be rubbish in this field */ if (check_digit(bt2_t, strlen(bt2_t), "Error: Delay between sequences field") == -1) return -1; del = strtol(bt2_t, (char **)NULL, 10); /* max delay 999,999999 s */ if ( (del > 999999999) || (del < 0) ) { //printf("Error: Delay between sequences field\n"); error("Error: Delay between sequences field (0 - 999999999)"); return -1; } } for (i=0; i<10; i++) { /* name of the packet and packet contents */ snprintf(buff4, 100, "entry%d", 111+i); bt1 = lookup_widget(GTK_WIDGET (button), buff4); bt1_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt1)); /* if there is no name, skip it */ if ( strlen(bt1_t) == 0 ) { partable[i][0] = 0; continue; } else partable[i][0] = 1; /* copy the name in the table */ strncpy(&pkttable[i][0], bt1_t, 70); /* number of packets to send */ snprintf(buff4, 100, "entry%d", 121+i); bt2 = lookup_widget(GTK_WIDGET (button), buff4); bt2_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt2)); snprintf(buff4, 100, "Error: Number of packets field in row %d", i+1); if (check_digit(bt2_t,strlen(bt2_t), buff4) == -1) return -1; partable[i][1] = strtol(bt2_t, (char **)NULL, 10); /* we allow to send 9999999 max */ if ( (partable[i][1] > 9999999) || (partable[i][1] < 0) ) { snprintf(buff4, 100, "Error: number of packets value in row %d", i+1); //printf("Error: number of packets value in row %d\n", i+1); error(buff4); return -1; } /* delay between packets */ snprintf(buff4, 100, "entry%d", 131+i); bt2 = lookup_widget(GTK_WIDGET (button), buff4); bt2_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt2)); snprintf(buff4, 100, "Error: Delay between packets field in row %d", i+1); if (check_digit(bt2_t,strlen(bt2_t), buff4) == -1) return -1; partable[i][2] = strtol(bt2_t, (char **)NULL, 10); /* max delay 999,999999 s */ if ( (partable[i][2] > 999999999) || (partable[i][2] < 0) ) { snprintf(buff4, 100, "Error: delay between value in row %d", i+1); //printf("Error: delay between value in row %d\n", i+1); error(buff4); return -1; } /* delay to next sequence */ snprintf(buff4, 100, "entry%d", 141+i); bt2 = lookup_widget(GTK_WIDGET (button), buff4); bt2_t = (char *) gtk_entry_get_text(GTK_ENTRY(bt2)); snprintf(buff4, 100, "Error: Delay to next value in row %d", i+1); if (check_digit(bt2_t,strlen(bt2_t), buff4) == -1) return -1; partable[i][3] = strtol(bt2_t, (char **)NULL, 10); /* max delay 999,999999 s */ if ( (partable[i][3] > 999999999) || (partable[i][3] < 0) ) { snprintf(buff4, 100, "Error: delay to next value in row %d", i+1); //printf("Error: delay to next value in row %d\n", i+1); error(buff4); return -1; } /* enable or disable */ snprintf(buff4, 100, "checkbutton%d", 25+i); bt1 = lookup_widget(GTK_WIDGET(button), buff4); if (GTK_TOGGLE_BUTTON(bt1)->active) partable[i][4] = 0; else partable[i][4] = 1; } fprintf(file_p, "#configuration parameters for send sequence generator\n"); fprintf(file_p, "#absolute/relative timing (1/0), number (-3=infinite), delay (1=max)\n"); fprintf(file_p, "%d,%ld,%ld\n", timeflag, count,del); fprintf(file_p, "#parameters for each sequence should have:\n#name, number of packets, delay between packets, delay to next sequence, enable/disable\n"); for (i=0; i<10; i++) { fprintf(file_p, "#parameters for sequence number %d\n", i); if (partable[i][0] == 0) { fprintf(file_p, "0\n"); } else fprintf(file_p, "%s,%ld,%ld,%ld,%ld\n", &pkttable[i][0], partable[i][1], partable[i][2], partable[i][3],partable[i][4]); } return 1; }
static char *process_option(int command, int mode) { static char digits[] = ".0123456789"; char *ptr, **tabptr; //, *ptb; int i; float f; #ifdef DEBUG_CONF printf("command %d detected.\n", command); #endif switch (command) { case 5: #ifdef DEBUG_CONF puts("Allow override"); #endif break; case 0: /* mouse */ case 2: /* m */ ptr = strtok(NULL, " "); if (ptr == NULL) goto inv_mouse; if (check_digit(ptr, digits + 1)) { /* It is a number.. */ i = atoi(ptr); if ((i < 0) || (i > 9)) goto inv_mouse; mouse_type = i; } else { /* parse for symbolic name.. */ for (i = 0, tabptr = conf_mousenames; *tabptr; tabptr++, i++) { if (!strcasecmp(ptr, *tabptr)) { mouse_type = i; goto leave; } } inv_mouse: printf("svgalib: Illegal mouse setting: {mouse|m} %s\n" "Correct usage: {mouse|m} mousetype\n" "where mousetype is one of 0, 1, 2, 3, 4, 5, 6, 7, 9,\n", (ptr != NULL) ? ptr : ""); for (tabptr = conf_mousenames, i = 0; *tabptr; tabptr++, i++) { if (i == MOUSE_NONE) continue; printf("%s, ", *tabptr); } puts("or none."); return ptr; /* Allow a second parse of str */ } break; case 1: /* monitor */ case 3: /* M */ ptr = strtok(NULL, " "); if (check_digit(ptr, digits + 1)) { /* It is an int.. */ i = atoi(ptr); if (i < 7) { command = i + 12; goto monnum; } else { f = i; goto monkhz; } } else if (check_digit(ptr, digits)) { /* It is a float.. */ f = atof(ptr); monkhz: if (!mode) goto mon_deny; // __svgalib_horizsync.max = f * 1000.0f; } else { printf("svgalib: Illegal monitor setting: {monitor|M} %s\n" "Correct usage: {monitor|M} monitortype\n" "where monitortype is one of 0, 1, 2, 3, 4, 5, 6, or\n" "maximal horz. scan frequency in khz.\n" "Example: monitor 36.5\n", (ptr != NULL) ? ptr : ""); return ptr; /* Allow a second parse of str */ } break; case 4: /* chipset */ ptr = strtok(NULL, " "); break; case 6: /* oldstyle config: m0-m4 */ case 7: case 8: case 9: case 10: mouse_type = command - 6; break; case 11: /* m9 */ mouse_type = MOUSE_NONE; break; case 12: /* oldstyle config: M0-M6 */ case 13: case 14: case 15: case 16: case 17: case 18: monnum: if (!mode) { mon_deny: puts("Monitor setting from environment denied."); break; } break; case 19: /*nolinear */ break; case 20: /*linear */ break; case 21: /* oldstyle chipset C0 - C9 */ case 22: case 23: case 24: case 25: case 26: case 27: case 28: case 29: case 30: break; case 31: /* c0-c1 color-text selection */ if (!mode) { coltexdeny: puts("Color/mono text selection from environment denied."); break; } color_text = 0; break; case 32: if (!mode) { puts("Color/mono text selection from environment denied."); break; } color_text = 1; break; case 33: case 34: if (!mode) goto coltexdeny; color_text = command - 32; break; case 35: /* Mouse type 5 - "PS2". */ mouse_type = 5; break; case 36: mouse_modem_ctl &= ~(MOUSE_CHG_DTR | MOUSE_DTR_HIGH); break; case 37: mouse_modem_ctl &= ~MOUSE_DTR_HIGH; mouse_modem_ctl |= MOUSE_CHG_DTR; break; case 38: mouse_modem_ctl |= (MOUSE_CHG_RTS | MOUSE_RTS_HIGH); break; case 39: mouse_modem_ctl &= ~(MOUSE_CHG_RTS | MOUSE_RTS_HIGH); break; case 40: mouse_modem_ctl &= ~MOUSE_RTS_HIGH; mouse_modem_ctl |= MOUSE_CHG_RTS; break; case 41: mouse_modem_ctl |= (MOUSE_CHG_RTS | MOUSE_RTS_HIGH); break; case 42: /* grayscale */ break; case 43: /* horizsync */ ptr = strtok(NULL, " "); if (check_digit(ptr, digits)) { /* It is a float.. */ f = atof(ptr); if (!mode) goto mon_deny; // __svgalib_horizsync.min = f * 1000; } else goto hs_bad; ptr = strtok(NULL, " "); if (check_digit(ptr, digits)) { /* It is a float.. */ f = atof(ptr); if (!mode) goto mon_deny; // __svgalib_horizsync.max = f * 1000; } else { hs_bad: printf("svgalib: Illegal HorizSync setting.\n" "Correct usage: HorizSync min_kHz max_kHz\n" "Example: HorizSync 31.5 36.5\n"); } break; case 44: /* vertrefresh */ ptr = strtok(NULL, " "); if (check_digit(ptr, digits)) { /* It is a float.. */ f = atof(ptr); if (!mode) goto mon_deny; // __svgalib_vertrefresh.min = f; } else goto vr_bad; ptr = strtok(NULL, " "); if (check_digit(ptr, digits)) { /* It is a float.. */ f = atof(ptr); if (!mode) goto mon_deny; // __svgalib_vertrefresh.max = f; } else { vr_bad: printf("svgalib: Illegal VertRefresh setting.\n" "Correct usage: VertRefresh min_Hz max_Hz\n" "Example: VertRefresh 50 70\n"); } break; case 45:{ /* modeline */ // MonitorModeTiming mmt; const struct { char *name; int val; } options[7]; /* = { */ /* { */ /* "-hsync", NHSYNC */ /* }, */ /* { */ /* "+hsync", PHSYNC */ /* }, */ /* { */ /* "-vsync", NVSYNC */ /* }, */ /* { */ /* "+vsync", PVSYNC */ /* }, */ /* { */ /* "interlace", INTERLACED */ /* }, */ /* { */ /* "interlaced", INTERLACED */ /* }, */ /* { */ /* "doublescan", DOUBLESCAN */ /* } */ /* }; */ #define ML_NR_OPTS (sizeof(options)/sizeof(*options)) /* Skip the name of the mode */ ptr = strtok(NULL, " "); if (!ptr) break; ptr = strtok(NULL, " "); if (!ptr) break; // mmt.pixelClock = atof(ptr) * 1000; #define ML_GETINT(x) \ ptr = strtok(NULL, " "); if(!ptr) break; // mmt.##x = atoi(ptr); ML_GETINT(HDisplay); ML_GETINT(HSyncStart); ML_GETINT(HSyncEnd); ML_GETINT(HTotal); ML_GETINT(VDisplay); ML_GETINT(VSyncStart); ML_GETINT(VSyncEnd); ML_GETINT(VTotal); // mmt.flags = 0; while ((ptr = strtok(NULL, " "))) { for (i = 0; i < ML_NR_OPTS; i++) /* if (!strcasecmp(ptr, options[i].name)) */ /* mmt.flags |= options[i].val; */ if (i == ML_NR_OPTS) break; } #undef ML_GETINT #undef ML_NR_OPTS return ptr; } case 46: if (!mode) { puts("Security setting from environment denied."); break; } if ( (ptr = strtok( NULL, " ")) ) { if (!strcasecmp("revoke-all-privs", ptr)) { // __svgalib_security_revokeallprivs = 1; break; } else if (!strcasecmp("compat", ptr)) { // __svgalib_security_revokeallprivs = 0; break; } } puts("svgalib: Unknown security options\n"); break; case 47: ptr = strtok(NULL," "); if (ptr) { mouse_device = strdup(ptr); if (mouse_device == NULL) { nomem: puts("svgalib: Fatal error: out of memory."); exit(1); } } else goto param_needed; break; case 48: /* default_mode */ if ( (ptr = strtok(NULL, " ")) != 0) { int mode = vga_getmodenumber(ptr); if (mode != -1) { __svgalib_default_mode = mode; } else { printf("svgalib: config: illegal mode \'%s\' for \'%s\'\n", ptr, vga_conf_commands[command]); } } else { param_needed: printf("svgalib: config: \'%s\' requires parameter(s)", vga_conf_commands[command]); break; } break; case 49: /* nosigint */ __svgalib_nosigint = 1; break; case 50: /* sigint */ __svgalib_nosigint = 0; break; case 51: /* joystick0 */ case 52: /* joystick1 */ case 53: /* joystick2 */ case 54: /* joystick3 */ if (! (ptr = strtok(NULL, " ")) ) goto param_needed; #ifndef SVGA_AOUT if (__joystick_devicenames[command - 51]) free(__joystick_devicenames[command - 51]); __joystick_devicenames[command - 51] = strdup(ptr); if (!__joystick_devicenames[command - 51]) goto nomem; #else printf("svgalib: No joystick support in a.out version.\n"); #endif break; case 55: /* TextProg */ ptr = strtok(NULL," "); if(ptr==NULL)break; /* __svgalib_textprog|=2; */ /* __svgalib_TextProg = strdup(ptr); */ /* if (!__svgalib_TextProg) */ /* goto nomem; */ i=1; while(((ptr=strtok(NULL," "))!=NULL) /* && */ /* (i< ((sizeof(__svgalib_TextProg_argv) / sizeof(char *)) + 1)) */ && strcmp(ptr,"END")){ /* __svgalib_TextProg_argv[i]=strdup(ptr); */ /* if (!__svgalib_TextProg_argv[i]) */ /* goto nomem; */ i++; }; /* __svgalib_TextProg_argv[i]=NULL; */ /* ptb=strrchr(__svgalib_TextProg,'/'); */ /* __svgalib_TextProg_argv[0]=ptb?ptb + 1:__svgalib_TextProg; */ /* printf("%s\n",__svgalib_TextProg); for(j=0;j<i;j++)printf("%i:%s\n",j,__svgalib_TextProg_argv[j]); */ break; } leave: return strtok(NULL, " "); }
int vsnprintf (char *buf, int size, const char *fmt, va_list args) { int len; unsigned long num; int i; int base; char *str; const char *s; int flags; /* NOTE: Flags to printf_number (). */ int field_width; /* NOTE: Width of output field. */ int precision; /* NOTE: min. # of digits for integers; max number of chars for from string. */ int qualifier; /* NOTE: 'h', 'l', or 'L' for integer fields. */ for (str = buf; *fmt && ((str - buf) < (size - 1)); ++fmt) { /* STAGE: If it's not specifying an option, just pass it on through. */ if (*fmt != '%') { *str++ = *fmt; continue; } /* STAGE: Process the flags. */ flags = 0; repeat: ++fmt; /* NOTE: This also skips first '%' */ switch (*fmt) { case '-' : flags |= N_LEFT; goto repeat; case '+' : flags |= N_PLUS; goto repeat; case ' ' : flags |= N_SPACE; goto repeat; case '#' : flags |= N_SPECIAL; goto repeat; case '0' : flags |= N_ZEROPAD; goto repeat; } /* STAGE: Get field width. */ field_width = -1; if (check_digit (*fmt)) { field_width = skip_atoi (&fmt); } else if (*fmt == '*') { ++fmt; /* STAGE: Specified on the next argument. */ field_width = va_arg (args, int); if (field_width < 0) { field_width = -field_width; flags |= N_LEFT; } } /* STAGE: Get the precision. */ precision = -1; if (*fmt == '.') { ++fmt; if (check_digit (*fmt)) { precision = skip_atoi (&fmt); } else if (*fmt == '*') { ++fmt; /* STAGE: Specified on the next argument */ precision = va_arg (args, int); }