void dataeditfrm::acceptdata() { if(lblID->text()!="-") updateentry(); else newentry(); QSqlDatabase::database().commit(); this->accept(); }
// Main loop int mainloop(char *argv){ FILE *database = fopen(argv, "r"); char buffer[128]; Node list = NULL; while(!(feof(database))){ Node newNode = malloc(sizeof(struct node)); readline(buffer, 128, database); newNode->key = malloc(strlen(buffer) + 1); strcpy(newNode->key, buffer); readline(buffer, 128, database); newNode->value = malloc(strlen(buffer) + 1); strcpy(newNode->value, buffer); newNode->next = list; list = newNode; } int choice = -1; while(choice != 0){ puts("Please choose an operation"); puts("1. Query a key"); puts("2. Update an entry"); puts("3. New entry"); puts("4. Remove entry"); puts("5. Print database"); puts("0. Exit database"); printf("? "); scanf("%d", &choice); while(getchar() != '\n'); // Clear stdin /*int found; Node cursor;*/ switch(choice){ case 1: querykey(list); break; case 2: updateentry(list); break; case 3: newentry(list); break; /*case 4: removeentry(list); break; case 5: printdb(list); break;*/ case 0: // Exit puts("¡Adios señor!\n"); break; default: puts("Could not parse choice! Please try again!\n"); } } return 0; }
void main(void) { auto int wKey; char buffer[20]; auto int i,j; brdInit(); initLcdKeypad(); // Initialize the #web-registered variables strcpy(passwords[0].entrypw, "12340"); strcpy(passwords[0].entryname, "JGunchy"); strcpy(passwords[0].entrytime, "no activity"); strcpy(passwords[0].exittime, "no activity"); for (i=1; i<MAX_ENTRIES; i++) { strcpy(passwords[i].entrypw, "Unused"); strcpy(passwords[i].entryname, "Unused"); strcpy(passwords[i].entrytime, "no activity"); strcpy(passwords[i].exittime, "no activity"); } updateentry(); //initialize temporary variables j= 10; i = 0; // Initialize the TCP/IP stack, HTTP server sock_init(); http_init(); while (1) { // Drive the HTTP server http_handler(); costate { keyProcess(); wKey = keyGet(); } costate { switch (wKey) { case 0: break; case '+': //entry case '-': //exit buffer[i]='\0'; TextGotoXY(&wholewindow, 0, 1); if (confirmentry(buffer, wKey)) { TextPrintf(&wholewindow, "Accepted"); TextGotoXY(&wholewindow, 0, 3); TextPrintf(&wholewindow, "Thank you %s", buffer); } else { TextPrintf(&wholewindow, "Incorrect password"); } i=0; j=10; waitfor(DelaySec(3)); glBlankScreen(); TextGotoXY(&wholewindow, 0, 0); TextPrintf(&wholewindow, "Password"); break; default: if (i<7) { buffer[i] = wKey; TextGotoXY(&wholewindow, j, 0); //TextPrintf(&wholewindow, "%c", wKey); TextPrintf(&wholewindow, "%c", '*'); j++; i++; } break; }//end switch }//end costate switch } }