void normalExitWithEncryption(char * logfilepath, char* token) { execution_argv[0] = logfilepath; execution_argv[1] = token; if (executeCommand("encrypt.sh", 2, execution_argv) != 0) normalExit(); normalExit(); }
void KompareProcess::slotProcessExited( KProcess* /* proc */ ) { // exit status of 0: no differences // 1: some differences // 2: error but there may be differences ! kdDebug(8101) << "Exited with exit status : " << exitStatus() << endl; emit diffHasFinished( normalExit() && exitStatus() != 0 ); }
int BatchMode(int argc, char** argv) { int i; for (i = 0; i < argc; i++) { if (strlen(argv[i]) < 2) continue; if (argv[i][0] == '-' && argv[i][1] == 'B' && argc == 3) { return true; } else if (argv[i][0] == '-' && argv[i][1] == 'B') { normalExit(); } } return false; }
int main(int argc, char** argv) { //checking //int argc = 5; //char* argv[] = {"logread", "-K", "secret", "-R", "/root/Desktop/.hidden/bibifi/log1"}; //char* argv[] = {"logread", "-B", "/root/Documents/NetBeansProjects/bibifi-final/dist/Debug/GNU-Linux-x86/hello"}; if (argc < 5) normalExit(); // parameter number if too low //normal mode int sflag = 0, rflag = 0, tflag = 0, iflag = 0; char* token = NULL, * employeename = NULL, *guestname = NULL, *logfilename = NULL; int switchflag = -1; //reading options while ((switchflag = getopt(argc, argv, "K:SRTIE:G:")) != -1) { switch (switchflag) { case 'K': if (!checkToken(optarg)) normalExit(); token = optarg; break; case 'S': sflag = true; break; case 'R': rflag = true; break; case 'T': tflag = true; break; case 'I': iflag = true; break; case 'E': if (!checkName(optarg)) normalExit(); employeename = optarg; break; case 'G': if (!checkName(optarg)) normalExit(); guestname = optarg; break; default: normalExit(); } } if (argc - optind != 1) normalExit(); else { if (!checkLogName(argv[optind])) normalExit(); logfilename = argv[optind]; } //here to check program syntax sanity int count_true = 0; if (sflag) count_true++; if (iflag) count_true++; if (rflag) count_true++; if (tflag) count_true++; if (token == NULL) normalExit(); if (count_true != 1) normalExit(); if (employeename != NULL && guestname != NULL && rflag) normalExit(); if (employeename == NULL && guestname == NULL && rflag) normalExit(); if (sflag && (employeename != NULL || guestname != NULL)) normalExit(); if (tflag || iflag) { printf("unimplemented"); exit(0); } //checking if file exists //getting the resolved path execution_argv[0] = logfilename; if (executeCommand("file_exists.sh", 1, execution_argv) == 0) // file found { //decrypt file execution_argv[0] = logfilename; execution_argv[1] = token; if (executeCommand("decrypt.sh", 2, execution_argv) != 0) securityExit(); //reading from the file time, type, where, name FILE* input = fopen(logfilename, "r"); if (input == NULL) normalExitWithEncryption(logfilename, token); int log_count = fill_log_array(input); fclose(input); if (sflag) { char ** emplist = (char **) malloc(sizeof (char*) * 1000); char ** guestlist = (char **) malloc(sizeof (char*) * 1000); int i, emp_count = 0, guest_count = 0; for (i = 0; i < 1000; i++) { emplist[i] = (char*) malloc(sizeof (char) * 100); guestlist[i] = (char*) malloc(sizeof (char) * 100); } emp_count = get_employee_names_list(emplist, log_count); guest_count = get_guest_names_list(guestlist, log_count); if (emp_count == 0) printf("\n"); else { for (i = 0; i < emp_count; i++) { if (i == emp_count - 1) printf("%s\n", emplist[i]); else printf("%s,", emplist[i]); } } if (guest_count == 0) printf("\n"); else { for (i = 0; i < guest_count; i++) { if (i == guest_count - 1) printf("%s\n", guestlist[i]); else printf("%s,", guestlist[i]); } } int* room_ids = (int*) malloc(sizeof (int) * 100); int room_count = get_room_list(room_ids, log_count); int j; for (i = 0; i < room_count; i++) { int who_count = who_is_in_room(guestlist, room_ids[i], log_count); if (who_count != 0) printf("%d: ", room_ids[i]); for (j = 0; j < who_count; j++) { if (j == who_count - 1) printf("%s\n", guestlist[j]); else printf("%s,", guestlist[j]); } } } if (rflag) { char *some_name; int some_type; some_type = EMPLOYEETYPE, some_name = employeename; if (employeename == NULL) some_type = GUESTTYPE, some_name = guestname; int* room_ids = (int*) malloc(sizeof (int) * 100); int room_count = get_r_request(room_ids, some_name, some_type, log_count); int index; for (index = 0; index < room_count; index++) { if (index == room_count - 1) printf("%d", room_ids[index]); else printf("%d,", room_ids[index]); } printf("\n"); } //encrypt file execution_argv[0] = logfilename; execution_argv[1] = token; if (executeCommand("encrypt.sh", 2, execution_argv) != 0) normalExitWithEncryption(logfilename, token); } else normalExit(); return (EXIT_SUCCESS); }