unsigned int cmd_quit(callbackp *callbacki) { QUIT(callbacki->fdclient, callbacki->g_ape); deluser(callbacki->call_user, callbacki->g_ape); // After that callbacki->call_user is free'd return (FOR_NULL); }
int main() { int menu, connected; // Local Variable do { // Show the Menu printf (" ______________\n"); printf ("| |\n"); printf ("| 1 - Sign In |\n"); printf ("| 2 - Sign Up |\n"); printf ("| 3 - Delete |\n"); printf ("| 4 - Modify |\n"); printf ("| |\n"); printf ("| 0 - Exit |\n"); printf ("|______________|\n"); printf ("Choice:"); scanf ("%d", &menu); // Choose the Option of the Menu }while (menu<0 || menu>4); if (menu != 0) authenticate(); switch (menu) { case 0: exit (EXIT_SUCCESS); break; case 1: connected = login (username, password); // Check if the Username and Password are Correct. if (connected == TRUE) // Check if the User is connected { printf ("You have Logged in as %s\n", username); } break; case 2: newuser (username, password); // Create the new Username break; case 3: deluser (username, password); // Delete the typed Username break; case 4: printf ("New password:"******"%s", &newpassword[0]); edituser (username, password, newpassword); // Change User Password break; } #ifdef _WIN32 system ("PAUSE"); #endif return 0; }
int runCommand(){ int i = 0; int argc = splitString(textBuffer, ' '); for(i =0;i<argc;i++){argv[i]=stringArray[i];} if(k_strcmp(argv[0], "")==0){} else if(k_strcmp(argv[0], "clear")==0){ clearScreen(); typeOffset = 0;} else if(k_strcmp(argv[0], "history")==0){ printHistory();} else if(k_strcmp(argv[0], "pong")==0){ pong();} else if(k_strcmp(argv[0], "help")==0){ listCommands();} else if(k_strcmp(argv[0], "welcome")==0){ welcome();} else if(k_strcmp(argv[0], "splash")==0){ splash();} else if(k_strcmp(argv[0], "ls")==0){ ls(argc, argv); } else if(k_strcmp(argv[0], "cat")==0){ cat(argc, argv); } else if(k_strcmp(argv[0], "rm")==0){ rm(argc, argv); } else if(k_strcmp(argv[0], "chmod")==0){ chmod(argc, argv); } else if(k_strcmp(argv[0], "te")==0){ te(argc, argv); } else if(k_strcmp(argv[0], "cp")==0){ cp(argc, argv); } else if(k_strcmp(argv[0], "diff")==0){ diff(argc, argv); } else if(k_strcmp(argv[0], "wc")==0){ wc(argc, argv); } else if(k_strcmp(argv[0], "su")==0){ su(argc, argv); } else if(k_strcmp(argv[0], "chown")==0){ chown(argc, argv); } else if(k_strcmp(argv[0], "echo")==0){ echo(argc, argv); } else if(k_strcmp(argv[0], "adduser")==0){ adduser(argc, argv); } else if(k_strcmp(argv[0], "deluser")==0){ deluser(argc, argv); } else if(k_strcmp(argv[0], "listus")==0){ listus(); } else if(k_strcmp(argv[0], "passwd")==0){ passwd(argc, argv); } else if(k_strcmp(argv[0], "mkdir")==0){ mkdir(argc, argv); } else if(k_strcmp(argv[0], "rmdir")==0){ rmdir(argc, argv); } else if(k_strcmp(argv[0], "cd")==0){ cd(argc, argv); } else if(k_strcmp(argv[0], "pwd")==0){ pwd(argc, argv); } else if(k_strcmp(argv[0], "mv")==0){ mv(argc, argv); } // else check files else { printToConsole("Error: Unknown command '"); printToConsole(argv[0]); printToConsole("'\n"); } return 0; }
void check_timeout(acetables *g_ape) { USERS *list, *wait; long int ctime = time(NULL); list = g_ape->uHead; while (list != NULL) { wait = list->next; if ((ctime - list->idle) >= TIMEOUT_SEC && list->type == HUMAN) { deluser(list, g_ape); } else if (list->type == HUMAN) { subuser **n = &(list->subuser); while (*n != NULL) { if ((ctime - (*n)->idle) >= TIMEOUT_SEC) { delsubuser(n); continue; } if ((*n)->state == ALIVE && (*n)->nraw && !(*n)->need_update) { /* Data completetly sent => closed */ if (send_raws(*n, g_ape)) { do_died(*n); } else { (*n)->burn_after_writing = 1; } } else { FIRE_EVENT_NONSTOP(tickuser, *n, g_ape); } n = &(*n)->next; } } list = wait; } }
void deflag_user(struct userrec *u, int why, char *msg, struct chanset_t *chan) { char tmp[30] = "", tmp2[1024] = ""; struct flag_record fr = {FR_GLOBAL | FR_CHAN, 0, 0, 0 }; int which = 0; switch (why) { case DEFLAG_BADCOOKIE: strlcpy(tmp, "Bad op cookie", sizeof(tmp)); which = chan->bad_cookie; break; case DEFLAG_MANUALOP: strlcpy(tmp, STR("Manual op in -manop channel"), sizeof(tmp)); which = chan->manop; break; #ifdef G_MEAN case DEFLAG_MEAN_DEOP: strlcpy(tmp, STR("Deopped bot in +mean channel"), sizeof(tmp)); ent = &CFG_MEANDEOP; break; case DEFLAG_MEAN_KICK: strlcpy(tmp, STR("Kicked bot in +mean channel"), sizeof(tmp)); ent = &CFG_MEANDEOP; break; case DEFLAG_MEAN_BAN: strlcpy(tmp, STR("Banned bot in +mean channel"), sizeof(tmp)); ent = &CFG_MEANDEOP; break; #endif /* G_MEAN */ case DEFLAG_MDOP: strlcpy(tmp, "Mass deop", sizeof(tmp)); which = chan->mdop; break; case DEFLAG_MOP: strlcpy(tmp, "Mass op", sizeof(tmp)); which = chan->mop; break; default: simple_snprintf(tmp, sizeof(tmp), "Reason #%i", why); } if (which == P_DEOP) { putlog(LOG_WARN, "*", "Setting %s +d (%s): %s", u->handle, tmp, msg); simple_snprintf(tmp2, sizeof(tmp2), "+d: %s (%s)", tmp, msg); set_user(&USERENTRY_COMMENT, u, tmp2); get_user_flagrec(u, &fr, chan->dname); if (fr.global == USER_DEOP) fr.match &= ~FR_GLOBAL; else fr.global = USER_DEOP; if (fr.chan == USER_DEOP) fr.match &= ~FR_CHAN; else fr.chan = USER_DEOP; /* did anything change? */ if (fr.match) set_user_flagrec(u, &fr, chan->dname); } else if (which == P_KICK) { putlog(LOG_WARN, "*", "Setting %s +dk (%s): %s", u->handle, tmp, msg); simple_snprintf(tmp2, sizeof(tmp2), "+dk: %s (%s)", tmp, msg); set_user(&USERENTRY_COMMENT, u, tmp2); get_user_flagrec(u, &fr, chan->dname); if (fr.global == (USER_DEOP|USER_KICK)) fr.match &= ~FR_GLOBAL; else fr.global = USER_DEOP | USER_KICK; if (fr.chan == (USER_DEOP|USER_KICK)) fr.match &= ~FR_CHAN; else fr.chan = USER_DEOP | USER_KICK; /* did anything change */ if (fr.match) set_user_flagrec(u, &fr, chan->dname); } else if (which == P_DELETE) { putlog(LOG_WARN, "*", "Deleting %s (%s): %s", u->handle, tmp, msg); deluser(u->handle); } else { putlog(LOG_WARN, "*", "No user flag effects for %s (%s): %s", u->handle, tmp, msg); simple_snprintf(tmp2, sizeof(tmp2), "Warning: %s (%s)", tmp, msg); set_user(&USERENTRY_COMMENT, u, tmp2); } }