void do_add(char *cmd) { int err = 0; char *i, *f; struct Employee e; i = &cmd[1]; while (*i && isspace(*i)) i++; if (*i) f = strchr(i, ','); else f = NULL; if (f) { strncpy(e.name, i, f - i); e.name[f - i] = '\0'; i = f + 1; while (*i && isspace(*i)) i++; f = strchr(i, ','); } else input_field("name: ", e.name); if (f) { strncpy(e.title, i, f - i); e.title[f - i] = '\0'; i = f + 1; while (*i && isspace(*i)) i++; f = i; while (*f) f++; } else input_field("title: ", e.title); if (f) { strncpy(e.number, i, f - i); e.number[f - i] = '\0'; } else input_field("number: ", e.number); if (cp_multimap_get(t, &e)) printf("replacing "); else printf("adding "); printf("entry: [%s, %s, %s]\n", e.name, e.title, e.number); cp_multimap_insert(t, &e, &err); if (err == CP_UNIQUE_INDEX_VIOLATION) { printf("unique index violation, insert rejected\n"); } }
void block_url_query(struct session *ses, unsigned char *u) { if (test_list_window_in_use(&blocks_ld, ses->term)) return; input_field(ses->term, NULL, TEXT_(T_BLOCK_URL) , TEXT_(T_BLOCK_ADD), ses, 0, MAX_INPUT_URL_LEN, u, 0, 0, NULL, TEXT_(T_OK), (void (*)(void *, unsigned char *)) block_url_add, TEXT_(T_CANCEL), NULL, NULL); }
void nspot_login() { unsigned char *username = NULL; unsigned char *password = NULL; const char *blob = NULL; int i; erase(); draw_box(2, 4, 12, 37); mvprintw(3, 6, "Enter Spotify account or Facebook"); mvprintw(4, 7, "details or leave blank to login"); mvprintw(5, 11, "with stored credentials"); draw_box(7, 6, 3, 33); draw_box(10, 6, 3, 33); mvprintw(11, 7, "Password"); curs_set(1); input_field(8, 7, 31, &username, 0); curs_set(0); if (*username) { for (i = 0; i < 8; ++i) mvaddch(11, 7 + i, ' '); curs_set(1); input_field(11, 7, 31, &password, 1); curs_set(0); if (!*password) { free(password); password = NULL; } } else { free(username); username = NULL; } /* Do login checks here and stuff */ if (username) free(username); if (password) free(password); }