int main(int argc, char** argv) { if(argc == 3) { removeBlanks(argv[1],argv[2]); } else { removeBlanks(SRCFILENAME,DSTFILENAME); } return EXIT_SUCCESS; }
void TSHPath::RemoveBlanks(LPTSTR pszPath) { static TModuleProcV1<LPTSTR> removeBlanks(GetModule(), RemoveBlanksStr); removeBlanks(pszPath); }
//The function to loop through dataStorage to determine the records that match //the input parameters for T, B, and C in Search. void searchResults(int range){ free(catStorage); int trow, tcol; char TempBodyA[71]; char TempBodyB[71]; int r; int i; removeBlanks(); for(i = 6; i <= 25; i++){ xt_par2(XT_SET_ROW_COL_POS,trow=i,tcol=20); printf(" "); } tempCounter = 0; //struct ArrayRecords *catStorage; catStorage = (struct ArrayRecords*)malloc((maxRecord) * sizeof(struct ArrayRecords)); for(i = 0; i < maxRecord; i++){ if(strstr(dataStorage[i].subject, Title) != NULL && strstr(dataStorage[i].body, Body) != NULL && strstr(dataStorage[i].category, Category) != NULL) { catStorage[tempCounter] = dataStorage[i]; tempCounter++; } } i = 0; //printf("Is there anything in catStorage? %s\n", catStorage[1].body); for(r = range; r < 4+range; r++){ if(r < tempCounter){ int k = 0; while(k != 70) { TempBodyA[k] = ' '; TempBodyB[k] = ' '; k++; } TempBodyA[70] = '\0'; TempBodyB[70] = '\0'; k = 0; xt_par2(XT_SET_ROW_COL_POS, trow = 7+5*i, tcol = 20); xt_par0(XT_CH_GREEN); printf("Record %d (%s)", r+1, catStorage[r].timedate); //get the time using myui1 xt_par0(XT_CH_WHITE); xt_par2(XT_SET_ROW_COL_POS, trow = 8+5*i, tcol = 20); int j = 0; while(catStorage[r].body[j] != '\0'){ if(j < 70) TempBodyA[j] = catStorage[r].body[j]; else if(j < 140) TempBodyB[j%70] = catStorage[r].body[j]; j++; } xt_par0(XT_CH_GREEN); printf("%s", catStorage[r].subject); xt_par0(XT_CH_WHITE); xt_par2(XT_SET_ROW_COL_POS, trow = 9+5*i, tcol = 20); printf("%s", TempBodyA); xt_par2(XT_SET_ROW_COL_POS, trow = 10+5*i, tcol = 20); printf("%s", TempBodyB); i++; } } xt_par2(XT_SET_ROW_COL_POS,row,col); }
int main(void) { char line[MAXLINE]; /* current input line */ while (getline(line, MAXLINE) > 0) { removeBlanks(line); printf("%s\n", line); } return 0; }
int main() { int len,newLen; char line[MAXLINE]; len=newLen=0; while( (len = getLine(line,MAXLINE)) > 0 ) if((newLen = removeBlanks(line , len)) >1) printf("%s",line); return 0; }
//Huge main function. int main(int argc, char *argv[]) { if (argc < 3){ //if you don't type enough arguments printf("Sockets client, usage:\n"); printf("sockets_client {IP-address} {port} \n"); return 0; } else { free(server); server = malloc((strlen(argv[1] + 1) * sizeof(char))); strcpy(server, argv[1]); portno = atoi(argv[2]); } int c; while(1){ if(screen == 0){ CATEGORY = 8; currentRecord = 0; recordView = 0; xt_par0(XT_CLEAR_SCREEN); lifeTracker(); xt_par2(XT_SET_ROW_COL_POS,row = 8, col = 2); } while(screen == 0) { while((c = getkey()) == KEY_NOTHING); if(c == KEY_F9) screen = 3; else if(c == KEY_F3 && maxRecord > 0 && col == 20) screen = 4; else if(c == KEY_DOWN) { if(col == 2 && row >= 8 && row < catCounter + 7){ xt_par2(XT_SET_ROW_COL_POS,CATEGORY = ++row,col); updateRecords(recordView); } if(col == 20 && row >= 7 && row <= tempCounter * 5 + 1){ if(row < 22){ xt_par2(XT_SET_ROW_COL_POS,row+=5,col); ++currentRecord; } else if(recordView < tempCounter-4){ ++recordView; if(search == 1) searchResults(recordView); else updateRecords(recordView); xt_par2(XT_SET_ROW_COL_POS,row=22,col); ++currentRecord; } } if(col > 94 && col < 120){ if(row == 9) xt_par2(XT_SET_ROW_COL_POS,row = 12,col = 95); else if(row == 12) xt_par2(XT_SET_ROW_COL_POS,row = 13,col = 95); else if(row == 13) xt_par2(XT_SET_ROW_COL_POS,row = 16,col); else if(row < 20) xt_par2(XT_SET_ROW_COL_POS,++row,col); else if(row == 20 && col < 110) xt_par2(XT_SET_ROW_COL_POS,++row,col); else if(row == 20 && col > 110) xt_par2(XT_SET_ROW_COL_POS,++row,col = 109); } } else if(c == KEY_UP){ if(col == 2 && row > 8 && row <= 18){ xt_par2(XT_SET_ROW_COL_POS,CATEGORY = --row,col); updateRecords(recordView); } if(col == 20 && row >= 7 && row < 24){ if(row <= 24 && row > 7){ xt_par2(XT_SET_ROW_COL_POS,row-=5,col); --currentRecord; } else if(recordView > 0){ --recordView; if(search == 1) searchResults(recordView); else updateRecords(recordView); xt_par2(XT_SET_ROW_COL_POS,row=7,col); --currentRecord; } } if(row > 9 && col > 94 && col < 120){ if(row == 12) xt_par2(XT_SET_ROW_COL_POS,row = 9,col = 95); else if(row == 13) xt_par2(XT_SET_ROW_COL_POS,row = 12,col = 95); else if(row == 16) xt_par2(XT_SET_ROW_COL_POS, row = 13, col = 95); else if(row < 22) xt_par2(XT_SET_ROW_COL_POS, --row, col); } } else if(c == KEY_ENTER && col > 94 && col < 120 && row > 12 && row < 18) xt_par2(XT_SET_ROW_COL_POS,++row,col=95); else if((c == KEY_LEFT || c == KEY_RIGHT) && col == 2) { CATEGORY = row; updateRecords(recordView); xt_par2(XT_SET_ROW_COL_POS,row=7,col=20); } else if((c == KEY_LEFT || c == KEY_RIGHT) && col == 20) { xt_par2(XT_SET_ROW_COL_POS,row=CATEGORY,col=2); if (search == 1) clearSearch(); currentRecord = recordView = search = 0; updateRecords(recordView); } else if(c == KEY_LEFT && col >= 95) { if(col > 95) xt_par2(XT_SET_ROW_COL_POS,row,--col); else if(row == 13 && col == 95) xt_par2(XT_SET_ROW_COL_POS,--row,col = 101); else if(row >= 17 && row <= 21 && col == 95) xt_par2(XT_SET_ROW_COL_POS,--row, col = 119); } else if(c == KEY_RIGHT && col > 94) { if(row == 9 && col < 112) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(row == 12 && col < 101) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(row == 12 && col == 101) xt_par2(XT_SET_ROW_COL_POS,++row,col = 95); else if(row == 13 && col < 112) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(row >= 16 && row < 21 && col < 119) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(row == 21 && col < 109) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(row >= 16 && row <= 21 && col == 119) xt_par2(XT_SET_ROW_COL_POS,++row,col = 95); } else if(c == KEY_DELETE) { putchar(' '); if(row == 9) Category[col - 95] = ' '; else if(row == 12) Title[col - 95] = ' '; else if(row == 13) Title[col - 88] = ' '; else if(row >= 16 && row < 22) Body[(row - 16) * 25 + col - 95] = ' '; } else if(c == KEY_BACKSPACE && col >= 95) { if((row == 9 || row == 12) && col > 95) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Category[col - 95] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if((row == 9 || row == 12) && col == 95) { putchar(' '); Title[col - 95] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row == 13 && col > 95) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Title[col - 88] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row == 13 && col == 95) { xt_par2(XT_SET_ROW_COL_POS,--row,col = 101); putchar(' '); Title[col - 88] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row >= 16 && row < 22 && col > 95) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Body[(row - 16) * 25 + col - 95] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row == 16 && col == 95) { putchar(' '); Body[(row - 16) * 25 + col - 95] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row > 16 && row < 22 && col == 95) { xt_par2(XT_SET_ROW_COL_POS,--row,col = 119); putchar(' '); Body[(row - 16) * 25 + col - 95] = ' '; xt_par2(XT_SET_ROW_COL_POS,row,col); } } else if((c >= ' ' && c <= '~') && col >= 95 && col < 120){ if(row == 9 && col < 112) { putchar(c); Category[col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,row,++col); } else if(row == 9 && col == 112) { putchar(c); Category[col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row == 12 && col < 101) { putchar(c); Title[col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,row,++col); } else if(row == 12 && col == 101) { putchar(c); Title[col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,++row,col=95); } else if(row == 13 && col < 112) { putchar(c); Title[col - 88] = c; xt_par2(XT_SET_ROW_COL_POS,row,++col); } else if(row == 13 && col == 112) { putchar(c); Title[col - 88] = c; xt_par2(XT_SET_ROW_COL_POS,row,col); } else if(row >= 16 && row < 21 && col < 119) { putchar(c); Body[(row - 16) * 25 + col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,row,++col); } else if(row >= 16 && row < 21 && col == 119) { putchar(c); Body[(row - 16) * 25 + col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,++row,col = 95); } else if(row == 21 && col < 109) { putchar(c); Body[(row - 16) * 25 + col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,row,++col); } else if(row == 21 && col == 109) { putchar(c); Body[(row - 16) * 25 + col - 95] = c; xt_par2(XT_SET_ROW_COL_POS,row,col); } } else if(c == KEY_F2) screen = 1; else if(c == KEY_F4 && col == 20 && maxRecord != 0) screen = 2; else if(c == KEY_F6) { if(sort == 0){ bubbleSort(); sort = 1; } else if (sort == 1){ bubbleSortTime(); sort = 0; } } else if (c == KEY_F7){ if(col < 95) { xt_par2(XT_SET_ROW_COL_POS,row = 9,col = 95); for(reset = 0; reset < 29; reset++) Title[reset] = ' '; for(reset = 0; reset < 140; reset++) Body[reset] = ' '; for(reset = 0; reset < 16; reset++) Category[reset] = ' '; } else if(Title[0] == ' ' && Body[0] == ' ' && Category[0] == ' ') { xt_par2(XT_SET_ROW_COL_POS,row = CATEGORY,col = 2); clearSearch(); updateRecords(0); } else if(Title[0] != ' ' || Body[0] != ' ' || Category[0] != ' ') { clearSearch(); search = 1; searchResults(0); xt_par2(XT_SET_ROW_COL_POS,row = 7, col = 20); } } } if (screen == 1 || screen == 2){ for(reset = 0; reset < 29; reset++) Title[reset] = ' '; for(reset = 0; reset < 140; reset++) Body[reset] = ' '; for(reset = 0; reset < 16; reset++) Category[reset] = ' '; addScreen(); if (screen == 2){ char TempBodyA[71]; char TempBodyB[71]; int k = 0; while(k != 70) { TempBodyA[k] = ' '; TempBodyB[k] = ' '; k++; } k = 0; xt_par2(XT_SET_ROW_COL_POS, row = 12, col = 25); xt_par0(XT_CH_GREEN); printf("Record %d (%s)", currentRecord+1, catStorage[currentRecord].timedate); //get the time using myui1 xt_par0(XT_CH_WHITE); xt_par2(XT_SET_ROW_COL_POS, row = 14, col = 25); printf("%s", catStorage[currentRecord].category); int j = 0; while(catStorage[currentRecord].body[j] != '\0'){ if (j < 70) TempBodyA[j] = catStorage[currentRecord].body[j]; else if (j < 140) TempBodyB[j%70] = catStorage[currentRecord].body[j]; j++; } TempBodyA[70] = '\0'; TempBodyB[70] = '\0'; xt_par2(XT_SET_ROW_COL_POS, row = 16, col = 25); printf("%s", catStorage[currentRecord].subject); xt_par0(XT_CH_WHITE); xt_par2(XT_SET_ROW_COL_POS, row = 19, col = 25); printf("%s", TempBodyA); xt_par2(XT_SET_ROW_COL_POS, row = 20, col = 25); printf("%s", TempBodyB); xt_par2(XT_SET_ROW_COL_POS, row = 14, col = 25); strncpy(Title, catStorage[currentRecord].subject, sizeof(Title)); strncpy(Body, catStorage[currentRecord].body, sizeof(Body)); strncpy(Category, catStorage[currentRecord].category, sizeof(Category)); } } while(screen == 1 || screen == 2) { while((c = getkey()) == KEY_NOTHING); if (c == KEY_F9){ screen = 0; xt_par0(XT_CLEAR_SCREEN); } else if (c == KEY_DOWN){ if(row == 14) xt_par2(XT_SET_ROW_COL_POS, row = 16, col = 25); else if(row == 16) xt_par2(XT_SET_ROW_COL_POS,row = 19,col = 25); else if(row < 20) xt_par2(XT_SET_ROW_COL_POS,++row,col); } else if (c == KEY_UP){ if(row == 16) xt_par2(XT_SET_ROW_COL_POS, row = 14, col = 25); if(row == 19) xt_par2(XT_SET_ROW_COL_POS,row = 16,col = 25); else if(row == 20) xt_par2(XT_SET_ROW_COL_POS,--row,col); } else if(c == KEY_LEFT && col > 25 && col < 95) xt_par2(XT_SET_ROW_COL_POS,row,--col); else if(c == KEY_LEFT && col == 25 && row == 20) xt_par2(XT_SET_ROW_COL_POS,--row,col=94); else if(c == KEY_RIGHT && col > 24 && col < 37 && row == 14) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(c == KEY_RIGHT && col > 24 && col < 53 && row == 16) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(c == KEY_RIGHT && col > 24 && col < 94 && row > 18) xt_par2(XT_SET_ROW_COL_POS,row,++col); else if(c == KEY_RIGHT && col == 94 && row == 19) xt_par2(XT_SET_ROW_COL_POS,++row,col=25); else if (c == KEY_ENTER && row > 18 && row < 20) xt_par2(XT_SET_ROW_COL_POS,++row,col=25); else if (c == KEY_BACKSPACE && col >= 25 && col < 95 && ((row > 18 && row < 21) || row == 16 || row == 14)){ if(row == 14 && col > 25 && col < 39) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Category[col - 25] = ' '; } else if(row == 16 && col > 25 && col <= 54) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Title[col - 25] = ' '; } else if(row == 19 && col > 25 && col <= 95) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Body[col - 25] = ' '; } else if(row == 20 && col > 25 && col <= 95) { xt_par2(XT_SET_ROW_COL_POS,row,--col); putchar(' '); Body[col + 45] = ' '; } else if(row == 20){ xt_par2(XT_SET_ROW_COL_POS,--row,col=94); putchar(' '); Body[69] = ' '; } xt_par2(XT_SET_ROW_COL_POS,row,col); } else if (c == KEY_DELETE) { if(row == 14 && col >= 25 && col < 38) { putchar(' '); Category[col - 25] = ' '; } else if(row == 16 && col >= 25 && col < 54) { putchar(' '); Title[col - 25] = ' '; } else if(row == 19 && col >= 25 && col <= 95) { putchar(' '); Body[col - 25] = ' '; } else if(row == 20 && col >= 25 && col <= 95) { putchar(' '); Body[col + 45] = ' '; } xt_par2(XT_SET_ROW_COL_POS,row,col); } else if((c >= ' ' && c <= '~') && col >= 25 && col < 95) { if(row == 14 && col >= 25 && col < 40) { putchar(c); Category[col - 25] = c; } else if(row == 16 && col >= 25 && col < 54) { putchar(c); Title[col - 25] = c; } else if(row == 19 && col >= 25 && col <= 95) { putchar(c); Body[col - 25] = c; } else if(row == 20 && col >= 25 && col <= 95) { putchar(c); Body[col + 45] = c; } if (col < 94 && !(row == 16 && col > 52) && !(row == 14 && col > 36)){ ++col; } else{ if (row == 19) xt_par2(XT_SET_ROW_COL_POS,++row,col=25); else xt_par2(XT_SET_ROW_COL_POS,row,col); } } else if(c == KEY_F2 && screen == 1 /* && there is a valid title and description */){ //save record to corresponding subject if(Title[0] != ' ' || Body[0] != ' ' || Category[0] != ' ') { removeBlanks(); readmyStoreFromChildSOCKETS("add", Title, Body, Category, NULL); } int k = 0; while(k != 29) Title[k++] = ' '; k = 0; while(k != 140) Body[k++] = ' '; k = 0; while(k != 15) Category[k++] = ' '; maxRecord++; screen = 0; } else if(c == KEY_F2 && screen == 2 /* && there has been a valid change in the record */){ //update record removeBlanks(); char str[80]; for(i = 0; i < maxRecord; i++){ if(strcmp(catStorage[currentRecord].subject, dataStorage[i].subject) == 0 && strcmp(catStorage[currentRecord].body, dataStorage[i].body) == 0 && strcmp(catStorage[currentRecord].category, dataStorage[i].category) == 0 && strcmp(catStorage[currentRecord].timedate, dataStorage[i].timedate) == 0){//looks for corresponding record in the actual record list sprintf(str, "%d", i+1); break; } } readmyStoreFromChildSOCKETS("edit", str, Title, Body, Category); int k = 0; while(k != 29) Title[k++] = ' '; k = 0; while(k != 140) Body[k++] = ' '; k = 0; while(k != 15) Category[k++] = ' '; screen = 0; } } if (screen == 4){ for(reset = 0; reset < 29; reset++) Title[reset] = ' '; for(reset = 0; reset < 140; reset++) Body[reset] = ' '; for(reset = 0; reset < 16; reset++) Category[reset] = ' '; deleteScreen(); if (screen == 4){ char TempBodyA[71]; char TempBodyB[71]; int k = 0; while(k != 70) { TempBodyA[k] = ' '; TempBodyB[k] = ' '; k++; } k = 0; xt_par2(XT_SET_ROW_COL_POS, row = 12, col = 25); xt_par0(XT_CH_GREEN); printf("Record %d (%s)", currentRecord+1, catStorage[currentRecord].timedate); //get the time using myui1 xt_par0(XT_CH_WHITE); xt_par2(XT_SET_ROW_COL_POS, row = 14, col = 25); printf("%s", catStorage[currentRecord].category); int j = 0; while(catStorage[currentRecord].body[j] != '\0'){ if (j < 70) TempBodyA[j] = catStorage[currentRecord].body[j]; else if (j < 140) TempBodyB[j%70] = catStorage[currentRecord].body[j]; j++; } TempBodyA[70] = '\0'; TempBodyB[70] = '\0'; xt_par2(XT_SET_ROW_COL_POS, row = 16, col = 25); printf("%s", catStorage[currentRecord].subject); xt_par0(XT_CH_WHITE); xt_par2(XT_SET_ROW_COL_POS, row = 19, col = 25); printf("%s", TempBodyA); xt_par2(XT_SET_ROW_COL_POS, row = 20, col = 25); printf("%s", TempBodyB); xt_par2(XT_SET_ROW_COL_POS, row = 14, col = 25); strncpy(Title, catStorage[currentRecord].subject, sizeof(Title)); strncpy(Body, catStorage[currentRecord].body, sizeof(Body)); strncpy(Category, catStorage[currentRecord].category, sizeof(Category)); //print corresponding record in correct locations using myui1 } } while(screen == 4) { while((c = getkey()) == KEY_NOTHING); if (c == KEY_F9){ screen = 0; xt_par0(XT_CLEAR_SCREEN); } else if (c == KEY_F3){ char str[80]; for(i = 0; i < maxRecord; i++){ if(strcmp(catStorage[currentRecord].subject, dataStorage[i].subject) == 0 && strcmp(catStorage[currentRecord].body, dataStorage[i].body) == 0 && strcmp(catStorage[currentRecord].category, dataStorage[i].category) == 0 && strcmp(catStorage[currentRecord].timedate, dataStorage[i].timedate) == 0){ //looks for corresponding record in the actual record list sprintf(str, "%d", i+1); break; } } readmyStoreFromChildSOCKETS("delete", str, NULL, NULL, NULL); maxRecord--; screen = 0; } } if (screen == 3) break; } getkey_terminate(); xt_par0(XT_CLEAR_SCREEN); xt_par0(XT_BG_DEFAULT); xt_par2(XT_SET_ROW_COL_POS,row=1,col=1); getkey_terminate(); return 0; }