void cb_login_button(GtkButton *button, gpointer data) { LOGIN_WIDGET *login = &login_widget; const gchar *username = NULL; const gchar *password = NULL; username = gtk_entry_get_text(login->userentry); password = gtk_entry_get_text(login->passentry); if (!logincheck(username, password, &cur_user)) { gtk_widget_hide(GTK_WIDGET(login->loginwindow)); gtk_widget_show(GTK_WIDGET(login->mainwindow)); } }
int main(void) { char user[10], pass[10]; int logres, seats, bookres, bookch, loginch, usercheck; int maxseats = 20; //hardcoded max seats available system("cls"); printf("\nWelcome to Railway booking system!\n"); //Provide option to login or sign up printf("1. Press 1 to Login if you have already signed up.\n"); printf("2. Press 2 to Sign Up.\n\n"); printf("Your Choice?: "); scanf("%d", &loginch); usercheck = logincheck(loginch); //Check if user opted for login or sign-up if(usercheck == 1) //user opted for login in loginch, logincheck() returns 1 { A: //label to return to login after sign-up printf("\nUser Login:\nPlease enter your username and password:\n"); printf("Username: "******"%s", user); printf("Password: "******"%s", pass); logres = login(user, pass); //call to login, checks if user name and pass are correct if(logres == 1) //login success if login returns 1 above, ie. user name and pass are correct { printf("Login successful!\n\nPlease proceed for booking!\n20 Seats available!"); printf("\nPlease enter number of seats: "); scanf("%d", &seats); bookres = booking(seats, maxseats); //allow booking only if login success, //call booking() with no of seats user enters and max seats if(bookres == 1)//booking() above checks if enough seats are available, returns 1 if available { printf("\nEnough seats available! Proceed for booking.\n\n"); //Allow class selection if seats available printf("Please select your class:\n"); printf("1.Enter 1 for AC 1 Tier.\n"); printf("2.Enter 2 for AC 2 Tier.\n"); printf("3.Enter 3 for AC 3 Tier.\n"); printf("4.Enter 4 for Sleeper.\n"); printf("\nYour choice?: "); scanf("%d", &bookch); maxseats = bookmenu(bookch, seats, maxseats); //Actual Booking, call to bookmenu() } else //booking returns 0 if user entered seats exceeds available seats { printf("Not enough seats!"); } } else //login returns 0 if username OR pass is incorrect, comparison fails { printf("Invalid username or password!"); } } else if(usercheck == 2)//user opted for sign-up, logincheck() returns 2 { createuser();//Call user creation module system("cls"); goto A; //continue with login, after user creation } printf("\n\nThank You for using the Railway booking system. Press any key to exit!"); getche(); return 0; }
/* -------------------------------------------------------------------- */ void doLogin(char moreYet) { int foundIt; char InitPw[NAMESIZE+NAMESIZE+2]; char password[NAMESIZE+NAMESIZE+2]; char initials[NAMESIZE+NAMESIZE+2]; char *semicolon; Mflush(); if (!CARRIER) return; if (login_user || login_pw) /* handle command line log-ins */ { if (!modStat) if (cfg.offhook) offhook(); /* login using initials and pw */ if (login_pw) { normalizepw(cmd_login, initials, password); login_pw = FALSE; } else if (login_user) { normalizeString(cmd_login); if (findPerson(cmd_login, &logBuf) != ERROR) { strcpy(initials, logBuf.lbin); strcpy(password, logBuf.lbpw); } login_user = FALSE; } } else /* ask user for initials and password */ { if (moreYet == 2) moreYet = FALSE; else { /* dont print Login when hitting 'L' from console mode */ if (!(!moreYet && !loggedIn && !modStat)) { mPrintf("Login "); } } if (loggedIn) { mPrintf("\n Already logged in!\n "); return; } if (!modStat) if (cfg.offhook) offhook(); getNormStr((moreYet) ? "" : "your initials", InitPw, NAMESIZE+NAMESIZE+1, NO_ECHO); if (!CARRIER) return; dospCR(); semicolon = strchr(InitPw, ';'); if (!semicolon) { strcpy(initials, InitPw); getNormStr( "password", password, NAMESIZE, NO_ECHO); dospCR(); } else { normalizepw(InitPw, initials, password); } /* dont allow anything over 19 characters */ initials[NAMESIZE] = '\0'; } /* reset transmitted & received */ transmitted = 0l; received = 0l; /* reset read & entered */ mread = 0; entered = 0; foundIt = ((pwslot(initials, password)) != ERROR); if (foundIt && *password) { loggedIn = TRUE; update25(); /* trap it */ if (!logBuf.lbflags.NODE) { sprintf( msgBuf->mbtext, "Login %s", logBuf.lbname); if (onConsole) strcat(msgBuf->mbtext, " (Console)"); trap(msgBuf->mbtext, T_LOGIN); } else { sprintf( msgBuf->mbtext, "NetLogin %s", logBuf.lbname); trap(msgBuf->mbtext, T_NETWORK); } } else { loginNew(initials, password); } if (!loggedIn) return; heldMessage = FALSE; setsysconfig(); setgroupgen(); setroomgen(); setlbvisit(); slideLTab(thisSlot); /* cant log in now. */ if (cfg.accounting && !logBuf.lbflags.NOACCOUNT) { negotiate(); logincrement(); if (!logincheck()) { Hangup(); return; } } /* can't log in now. */ if (logBuf.VERIFIED && !onConsole) { tutorial("verified.blb"); Hangup(); return; } if (logBuf.lbflags.NODE) { #ifdef TRASH if (debug) { readnode(); cPrintf("Node: \"%s\" \"%s\"", node.ndname, node.ndregion); doccr(); cPrintf("Phone: \"%s\" %d", node.ndphone, node.nddialto); doccr(); cPrintf("Login: \"%s\" %d", node.ndlogin, node.ndwaitto); doccr(); cPrintf("Baud: %d Protocol: \"%s\"\n ", node.ndbaud, node.ndprotocol); cPrintf("Expire:%d Waitout: %d", node.ndexpire, node.ndwaitto); doccr(); cPrintf("Network: %d ZIP: %s UNZIP: %s", node.network, node.zip, node.unzip); doccr(); } #endif time(&logtimestamp); return; } if (logBuf.PSYCHO) { backout = TRUE; } /* reverse engineering Minibin?!?! */ if (logBuf.MINIBIN) { minibin(); } changedir(cfg.helppath); if ( filexists("bulletin.blb") ) { tutorial("bulletin.blb"); } gotodefaulthall(); roomtalley(); mf.mfLim = 0; /* just to make sure. */ mf.mfMai = 0; mf.mfPub = 0; mf.mfUser[0]=0; nochat(TRUE); /* reset chats */ /* verbose = FALSE; */ verbose = logBuf.VERBOSE; /* hmmm... where to put this */ if (roomBuf.rbflags.APLIC && roomBuf.rbflags.AUTOAPP ) ExeAplic(); showMessages(NEWoNLY, FALSE); verbose = FALSE; if (expert) listRooms(NEWRMS, FALSE); else listRooms(OLDNEW, FALSE); outFlag = OUTOK; setio(whichIO, echo, outFlag); /* record login time, date */ time(&logtimestamp); cfg.callno++; storeLog(); }