void addOberkat(const std::string kat, std::vector<std::string>& vec, const size_t MAXSIZE) { clrScreen(); printVector(vec); std::cout << std::endl; std::cout << "\t" << kat << " eingeben (zurueck mit 0): "; std::string line; getline(std::cin, line); if((line=="0")) { clrScreen(); return; //continue; } if(line.size() > MAXSIZE) { std::cout << "\n\n\tEingabe String zu lang! Maximal " << MAXSIZE; std::cout << " Zeichen erlaubt.\n\n"; std::cout << "\tweiter mit beliebiger Taste "; std::string tmp; getline(std::cin, tmp); clrScreen(); return; } vec.push_back(line); clrScreen(); std::cout << "\n\n\n" << std::endl; std::cout << "\t" << kat << " " << line << " hinzugefuegt\n"; std::cout << "\n\n\n" << std::endl; printVector(vec); std::cout << "\n\n\n\tweiter mit beliebiger Taste "; std::string tmp; getline(std::cin, tmp); clrScreen(); }
void oberkatVerwalten(const std::string kat, std::vector<std::string>& vec, const size_t MAXSIZE) { clrScreen(); if(vec.empty()) std::cout << "\n\n\tBisher noch keine " << kat << " vorhanden\n\n"; else { std::cout << "\n\n\tErfasste " << kat << ":\n"; std::cout << "\t========="; for(size_t i = 0; i != kat.size()+1; ++i) std::cout << "="; std::cout << "\n\n"; } printVector(vec); std::cout << "\n\n"; std::cout << "\t" << kat << " verwalten" << std::endl; std::cout << "\t"; for(size_t i = 0; i != kat.size()+1; ++i) std::cout << "="; std::cout << "========="; showOberkatMenu(); std::string line; while( getline(std::cin, line) ) { if ( (line.empty()) || (line.size() > 1) || (!isdigit(line[0])) ){ wrongInput(); clrScreen(); printVector(vec); showOberkatMenu(); continue; } const char input = (char)line[0]; // is this a good cast (ok casts are never friends) switch(input) { case '1': clrScreen(); printVector(vec); addOberkat(kat, vec, MAXSIZE); printVector(vec); oberkatVerwalten(kat, vec, MAXSIZE); return; case '2': clrScreen(); printVector(vec); loeschenOberkat(kat, vec); printVector(vec); oberkatVerwalten(kat, vec, MAXSIZE); return; case '0': clrScreen(); return; default: assert("should never get here"); } } }
int main(void) { initializeI2C(); affTexte("Test LCD\n"); initCoders(); setupInterrupt(); unsigned int count = 0; char s[20]; while (1) { count++; if ((count % 60000) == 0) { clrScreen(); int i; for (i=0; i<2; i++) { long coder = getCoderValue(i); sprintf(s, "%x_", (int)(coder >> 16)); affTexte(s); sprintf(s, "%x", (int)(coder & 0xFFFF)); affTexte(s); carRetCur(); } count = 0; } }
void loeschenOberkat(const std::string kat, std::vector<std::string>& vec) { clrScreen(); if(vec.empty()) { std::cout << "\n\n\n\tNichts zu loeschen" << std::endl; return; } printVector(vec); std::cout << std::endl; std::cout << "\tWelche "; std::cout << kat << " loeschen (zurueck mit 0): "; std::string line; size_t i; getline(std::cin, line); if((line.empty()) || (line.size() > 1) || (!isdigit(line[0]))) { wrongInput(); clrScreen(); return; //continue; } char c =(char)line[0]; if(c=='0') { clrScreen(); return; } i = atoi(&c); if(i>vec.size()) { wrongInput(); clrScreen(); return; //continue; } std::vector<std::string>::iterator deleted = vec.begin() + i - 1; std::cout << "\n\n\n\n\n\t" << *deleted << " geloescht" << std::endl; vec.erase(vec.begin()+(i-1)); std::cout << std::endl; std::cout << "\n\n\n\t" << std::endl; printVector(vec); std::cout << "\n\n\tweiter mit beliebiger Taste "; std::string tmp; getline(std::cin, tmp); clrScreen(); }
void main(){ int hr; int min; int sec; getTime(&hr, &min, &sec); clrScreen(); drawBar(); makeInterrupt21(); loadProgram(); }
int main(int argc, char *argv[]) { int portno,map_id; pthread_t receive_connection_thread; int receive_t; portno=atoi(argv[1]); char usertext[10]; system("setterm -term linux -back green -fore white -bold on -clear"); //system("gnome-terminal "); //gotoxy(50,50); fflush(stdout); clrScreen(); printCenter("Max No. of Players : "); scanf("%d",&max_players); clrScreen(); printCenter("No. Of Automatic Commandos : "); scanf("%d",&auto_commando_count); clrScreen(); printCenter("No.Of Automatic ALiens : "); scanf("%d",&auto_alien_count); printCenter(" Choose Arena\n"); printCenter("******************\n"); printCenter("1 : Forest_War\n"); printCenter("2 : Nuke_Alien\n"); printCenter("3 : Mountain_Comm\n"); printCenter("4 : Mission_Earth\n"); printCenter("5 : Collapse_CA\n"); printCenter("Your Choice : "); scanf("%d",&map_id); clrScreen(); initializeGame(map_id); serverInit(portno); printCenter(" *********The Game Begins Now*******\n"); printCenter(" Server Established \n"); printCenter("Waiting For Incomming Connections...\n"); //timer(); //change pthread_create(&receive_connection_thread,NULL,receiveIncomingConnections,(void *)&receive_t); //receiveIncomingConnections(); while(1) { printCenter("Press x to Shutdown Server : "); scanf("%s",usertext); if(strcmp(usertext,"q")==0) { system("setterm -default"); system("clear"); printf("All Connections Terminated\n"); printf("Server ShutDown\n"); showAllData(-1); shutDownServer(); //exit(0); } else { printCenter("Please enter x to quit :\n"); } } }
int main(int argc, char *argv[], char *envp[]) { char *line; int returnValue; int i, fd; char *pathString = (char *)malloc(sizeof(char) * 256); char *cmd = (char *)malloc(sizeof(char) * 256); bzero(pathString, 256); bzero(cmd, 256); /* Manage Signals */ signal(SIGINT, SIG_IGN); signal(SIGQUIT,SIG_IGN); // signal(SIGCHLD,SIG_IGN); signal(SIGKILL,SIG_IGN); signal(SIGTERM,SIG_IGN); signal(SIGINT, handleSignal); /* Extract the PATH= var from envp */ getPathString(envp, pathString); /* Insert each path to be searched into searchPath[][] */ insertPathStringToSearch(searchPath, pathString); /* Print about Slash */ clrScreen(argv, envp); printf("%s", aboutSlash); printf("PID=%d\n", getpid()); #if SLASH_DEBUG for(i=0; envp[i] != NULL; i++) printf("%s\n", envp[i]); #endif /* Bind our completer + History Feature */ initialize_readline(); while(1) { line = readline ("\x1b[96m<$lash/>\x1b[00m "); /* Print in Red! */ #if SLASH_DEBUG printf("Input: %s\n", line); #endif if(*line) { add_history (line); returnValue = execute_line (line); if(returnValue == CMD_EXIT) break; if(returnValue == CMD_UNKNOWN) { #if SLASH_DEBUG printf("CMD_UNKNOWN: %s\n", line); #endif /* Extract args to command into slashArgv[][] */ nullifyArgv(slashArgv); fillArgv(line, slashArgv); bzero(cmd, 256); strncpy(cmd, slashArgv[0], strlen(slashArgv[0])); strncat(cmd, "\0", 1); #if SLASH_DEBUG printf("arg[0]: %s\n", slashArgv[0]); printf("cmd: %s\n", cmd); #endif if(index(cmd, '/') == NULL) { if(attachPath(cmd, searchPath) == 0) { callFork(cmd, slashArgv, envp); } else printf("%s: command not found\n", cmd); } else { if((fd = open(cmd, O_RDONLY)) > 0) { close(fd); callFork(cmd, slashArgv, envp); } else printf("%s: command not found\n", cmd); } freeArgv(slashArgv); } } if(line != NULL) free(line); fflush(stdout); } free(cmd); free(pathString); for(i=0;i<50;i++) free(searchPath[i]); return 0; }
void pressAnyKeyToContinue(){ std::cout << "\n\n\n\tweiter mit beliebiger Taste "; std::string tmp; getline(std::cin, tmp); clrScreen(); }