//Entry point of the P2- microshell implementation int main(int argc, char *argv[]) { Pipe p; ctrlCFlag = 1; signalHandling(); ushrcProcessing(); char *hostName = (char *)malloc(1000); gethostname(hostName,1024); while(1){ fflush(stdin); if(isatty(fileno(stdin)) && ctrlCFlag == 1){ printf("%s%%", hostName); fflush(stdout); } ctrlCFlag = 1; p = parse(); if(p == NULL) { continue; } if(p!=NULL && strcmp(p->head->args[0], "end")) { prPipe(p); } else if(isatty(fileno(stdin)) && !strcmp(p->head->args[0], "end")) { exit(0); } else if(!isatty(fileno(stdin)) && !strcmp(p->head->args[0], "end")){ break; } freePipe(p); } }
// ========== The Main Function ============ int main (int argc, char *argv[]) { configure_server(config); signalHandling(); #if DEBUG printf("Checking if transmission directory exists...\n"); #endif // if DEBUG dirChkCreate(BISON_TRANSFER_DIR.c_str(), "transfer"); printf("Server Starting Up...\n"); // Insert PID file management stuff here // keep on preparing the connection until it is prepared. while (1) { if (!prepare_connection()) break; for (int i = 0; i > ERROR_WAIT; i++) usleep(1000); } #if DEBUG printf("Server ready, waiting for connection.\n"); #endif // if DEBUG // Loop to keep accepting connections while (1) { const char* ret = update_filetable(BISON_TRANSFER_DIR, filetable); if (ret) { std::cerr << "Error on filetable update: " << ret << std::endl; } handle_connection(); usleep(5000); // wait a bit so that we won't - // overload the system } return 0; }