static void request_pin(const char *prompt_msg, char *pin) { int i, rc; if (opt_pin) { rc = securid_pin_format_ok(opt_pin); if (rc == ERR_BAD_LEN) warn("warning: bad --pin argument length, ignoring\n"); else if (rc == ERR_GENERAL) warn("warning: --pin argument is not numeric, ignoring\n"); else { strncpy(pin, opt_pin, BUFLEN); return; } } for (i = 0; ; i++) { prompt(prompt_msg); read_user_input(pin, BUFLEN, 1); rc = securid_pin_format_ok(pin); if (rc == ERR_NONE) break; if (i == 2) die("error: invalid PIN\n"); if (rc == ERR_BAD_LEN) warn("PIN must be %d-%d digits. Use '0000' for no PIN.\n", MIN_PIN, MAX_PIN); else warn("PIN can only contain digits.\n"); } }
/* This functions gets a user input from terminal and display the memory data for the correspendign SA */ void display_brt_sa ( void) { uint8_t subaddr; while (1) { dp_display_text("Sub Address #(1 to 31 ): "); rx_char_ptr = rx_char; read_user_input(rx_char_ptr); xatoi ( &rx_char_ptr, &subaddr); dp_display_text("\r\nInput recived : "); dp_display_value(subaddr,HEX); if ((subaddr > 0 ) && (subaddr < 32)) { display_brt_data(CORE1553BRT_0 ,subaddr); break; } else { dp_display_text("\r\n\Invaid input !!!!! Enter the Sub Address # ( 1 to 31)to display Data: "); } } }
static void request_pass(const char *prompt_msg, struct securid_token *t, char *pass, char *devid) { int i, rc; if (opt_password) { rc = securid_decrypt_seed(t, opt_password, devid); if (rc != ERR_DECRYPT_FAILED && rc != ERR_BAD_PASSWORD) { strncpy(pass, opt_password, BUFLEN); return; } warn("warning: --password parameter is incorrect\n"); } for (i = 0; ; i++) { prompt(prompt_msg); read_user_input(pass, BUFLEN, 1); rc = securid_decrypt_seed(t, pass, devid); if (rc == ERR_DECRYPT_FAILED) { if (i == 2) die("error: invalid password\n"); warn("Bad password.\n"); } else break; } }
static void request_devid(struct securid_token *t, char *devid) { int i, rc; if (opt_devid) { rc = securid_decrypt_seed(t, "", opt_devid); if (rc != ERR_BAD_DEVID) { strncpy(devid, opt_devid, BUFLEN); return; } warn("warning: --devid parameter is incorrect\n"); } prompt("This token is bound to a specific device.\n"); for (i = 0; ; i++) { prompt("Enter device ID from the RSA 'About' screen: "); read_user_input(devid, BUFLEN, 0); rc = securid_decrypt_seed(t, "", devid); if (rc != ERR_BAD_DEVID) return; if (i == 2) die("error: invalid device ID\n"); prompt("Device ID does not match the token.\n"); } }
int main(void) { char word[20];//create a string clear_screen(); read_user_input(word);// pass created string into function which can read input and display result. other function inside can wait for user return 0; }
uint8_t get_data_input ( void) { uint8_t data_in; rx_char_ptr = rx_char; read_user_input(rx_char_ptr); xatoi ( &rx_char_ptr, &data_in); dp_display_value(data_in,HEX); return data_in; //display_brt_data(CORE1553BRT_0 ,subaddr); }
static void request_new_pass(char *pass) { char confirm_pass[BUFLEN]; int len; if (opt_new_password) { len = strlen(opt_new_password); if (len > MAX_PASS) die("error: new password is too long\n"); strncpy(pass, opt_new_password, BUFLEN); } else { prompt("Enter new password: "******"Confirm new password: "******"error: new password is too long\n"); if (strcmp(pass, confirm_pass) != 0) die("error: passwords do not match\n"); } }
int main () { while (1) { /* Read in user input string */ printf("%%> "); char* user_input = read_user_input(); if (!user_input) { fprintf(stderr, "Oh bollocks, something went wrong\n"); return 1; } printf("Thanks, you entered: %s\n", user_input); int result = expr(user_input); printf("Your result is: %d\n", result); free(user_input); } return 0; }
uint8_t getRoombaNrFromRemote() { while (1) { uint8_t result = read_user_input(); //TODO for testing //uint16_t result = 1; // Error, when not 1 or 2 if (result != 1 && result != 2) { char result[4] = {'1', 'O', 'R', '2'}; set_Display(result); my_msleep(2000); } else { return result; } } }
/* This function will get teh Input from Terminal and check for valid input for the SA */ uint8_t validate_brt_sa_input ( void) { uint8_t subaddr; dp_display_text("Sub Address #(1 to 31 ): "); rx_char_ptr = rx_char; read_user_input(rx_char_ptr); xatoi ( &rx_char_ptr, &subaddr); dp_display_value(subaddr,HEX); if ((subaddr > 0 ) && (subaddr < 32)) { return subaddr; //display_brt_data(CORE1553BRT_0 ,subaddr); } else { dp_display_text("\r\n\Invaid input !!!!! Enter the Sub Address # ( 1 to 31)to display Data: "); return 0; } }
int main(int argc, char **argv) { char *last_slash; char emulator_system_file[32]; int num_files; int sdk_version = SYSTEM_DUMP_SDK_VERSION; long length = 0; FILE *fp; char filename_buf[256]; char *filename = filename_buf; #ifndef VARIABLES_PROVIDED printf("System dump SDK version?\n"); printf("See: https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels\n"); scanf("%d%*c", &sdk_version); #endif sprintf(emulator_system_file, "emulator_systems/sdk_%d.txt", sdk_version); fp = fopen(emulator_system_file, "r"); if (!fp) { printf("SDK text file %s not found, exiting!\n", emulator_system_file); return 1; } fseek(fp, 0, SEEK_END); length = ftell(fp); rewind(fp); sdk_buffer = (char*)malloc(sizeof(char) * length); fread(sdk_buffer, 1, length, fp); fclose(fp); #ifndef VARIABLES_PROVIDED read_user_input(system_dump_root, sizeof(system_dump_root_buf), "System dump root?\n"); if (build_prop_checker()) return 1; read_user_input(system_vendor, sizeof(system_vendor_buf), "Target vendor name?\n"); read_user_input(system_device, sizeof(system_device_buf), "Target device name?\n"); #endif printf("How many files?\n"); scanf("%d%*c", &num_files); while (num_files--) { printf("Files to go: %d\n", num_files + 1); read_user_input(filename, sizeof(filename_buf), "File name?\n"); dot_so_finder(filename); last_slash = strrchr(filename, '/'); if (last_slash) check_emulator_for_lib(++last_slash); } printf("Completed successfully.\n"); free(sdk_buffer); argc = argc; argv = argv; return 0; }
int main(int argc, char **argv) { char *cmd = parse_cmdline(argc, argv, NOT_GUI); int rc; char buf[BUFLEN]; struct securid_token *t; rc = common_init(cmd); if (rc != ERR_NONE) die("can't initialize: %s\n", stoken_errstr[rc]); t = current_token; if (!t) die("error: no token present. Use 'stoken import' to add one.\n"); terminal_init(); if (!strcmp(cmd, "tokencode")) { int days_left = securid_check_exp(t, adjusted_time()); if (days_left < 0 && !opt_force) die("error: token has expired; use --force to override\n"); unlock_token(t, 1, NULL); securid_compute_tokencode(t, adjusted_time(), buf); puts(buf); if (days_left < 14 && !opt_force) warn("warning: token expires in %d day%s\n", days_left, days_left == 1 ? "" : "s"); } else if (!strcmp(cmd, "import")) { char *pass; unlock_token(t, 0, &pass); if (!opt_keep_password) { pass = xmalloc(BUFLEN); request_new_pass(pass); } t->is_smartphone = 0; securid_encode_token(t, pass, opt_new_devid, buf); rc = write_token_and_pin(buf, NULL, pass); if (rc != ERR_NONE) die("rcfile: error writing new token: %s\n", stoken_errstr[rc]); } else if (!strcmp(cmd, "export")) { char *pass; unlock_token(t, 0, &pass); if (opt_new_password) pass = opt_new_password; else if (!opt_keep_password) pass = NULL; t->is_smartphone = opt_iphone || opt_android; securid_encode_token(t, pass, opt_new_devid, buf); print_formatted(buf); } else if (!strcmp(cmd, "show")) { unlock_token(t, 0, NULL); securid_token_info(t, &print_token_info_line); } else if (!strcmp(cmd, "setpin")) { char *pass = NULL, pin[BUFLEN], confirm_pin[BUFLEN]; int len; if (opt_file || opt_token) die("error: setpin only operates on the rcfile token\n"); unlock_token(t, 0, &pass); if (opt_new_pin) { if (securid_pin_format_ok(opt_new_pin) != ERR_NONE) die("error: invalid --new-pin format\n"); strncpy(pin, opt_new_pin, BUFLEN); len = strlen(pin); } else { prompt("Enter new PIN: "); len = read_user_input(pin, BUFLEN, 1); if (len > 0 && securid_pin_format_ok(pin) != ERR_NONE) die("error: PIN must be 4-8 digits\n"); prompt("Confirm new PIN: "); read_user_input(confirm_pin, BUFLEN, 1); if (strcmp(pin, confirm_pin) != 0) die("error: PINs do not match\n"); } securid_encode_token(t, pass, NULL, buf); rc = write_token_and_pin(buf, len ? pin : NULL, pass); free(pass); if (rc != ERR_NONE) die("error: can't set PIN: %s\n", stoken_errstr[rc]); } else if (!strcmp(cmd, "setpass")) { char pass[BUFLEN]; unlock_token(t, 0, NULL); request_new_pass(pass); securid_encode_token(t, pass, NULL, buf); /* just print to stdout if it didn't come from the rcfile */ if (opt_file || opt_token) print_formatted(buf); else { rc = write_token_and_pin(buf, strlen(t->pin) ? t->pin : NULL, strlen(pass) ? pass : NULL); if (rc != ERR_NONE) die("error: can't set password: %s\n", stoken_errstr[rc]); } } else die("error: invalid command '%s'\n", cmd); return 0; }