BuildUnit::BuildUnit( Task* task ) { m_task = task; m_unit = NULL; initializeInformation(); BuildUnitManager::getInstance()->addUnit(this); }
BuildUnit::BuildUnit( BWAPI::Unit unit ) { m_unit = unit; m_task = NULL; initializeInformation(); BuildUnitManager::getInstance()->addUnit(this); }
int main(int argc, char* argv[]) { char* fname = NULL; struct information info; initializeInformation(&info); unsigned fileSize = 0; char* s; //char c = 0; int error = getArgs(argc, argv, &fname, &info); if(error) { return error; } FILE* file = NULL; if(fname == NULL) file = stdin; else file = fopen(fname,"rb"); if(!file) { fprintf(stderr,"The file %s doesn't exist!", argv[argc-1]); return 3; } if(fname == NULL) { freopen(NULL, "rb", stdin); s = malloc(500*sizeof(char)); while(read(STDIN_FILENO, s+fileSize, 1) > 0) { fileSize++; if(fileSize % 500 == 0) { s = realloc(s, (fileSize +500)*sizeof(char)); if(s == NULL) return 4; } } fileSize++; s[fileSize] = EOF; } else { rewind(file); fseek(file, 0L, SEEK_END); fileSize = ftell(file)+1; rewind(file); s = malloc(fileSize); fread(s, fileSize, 1, file); s[fileSize-1] = EOF; } printChosen(s, fileSize, info); free(s); fclose(file); return 0; }
int main(int argc, char* argv[]) { char* fname = NULL; struct information info; initializeInformation(&info); int error = getArgs(argc, argv, &fname, &info); unsigned fileSize = 0; char* s; if(error) { return error; } FILE* file = NULL; if(fname == NULL) file = stdin; else file = fopen(fname,"r"); if(!file) { fprintf(stderr,"The file %s doesn't exist!", argv[argc-1]); return 3; } if(file == stdin) { s = malloc(50); s[0] = fgetc(stdin); while(s[fileSize]!=EOF) { fileSize++; if(fileSize % 50 == 0) { s = realloc(s, fileSize +50); if(s == NULL) return 4; } s[fileSize] = fgetc(stdin); } } else { rewind(file); fseek(file, 0L, SEEK_END); fileSize = ftell(file); rewind(file); s = malloc(fileSize); fread(s, fileSize, 1, file); } printChosen(s, fileSize, info); free(s); fclose(file); return 0; }