#define TEST_DATA "Hello World!"
#define USER_ID "user_id_"
char InitialFile[BUFFER_SIZE];
char InitialDirectory[BUFFER_SIZE] = ".";
char Buffer[32];
int FilDes = -1;
int BytesRead;
int BytesWritten;
uid_t UserID;
void CleanUpOnError(int level)
{
printf("Error encountered, cleaning up.\n");
switch ( level )
{
case 1:
printf("Could not get current working directory.\n");
break;
case 2:
printf("Could not create file %s.\n",TEST_FILE);
break;
case 3:
printf("Could not write to file %s.\n",TEST_FILE);
close(FilDes);
unlink(TEST_FILE);
break;
case 4:
printf("Could not close file %s.\n",TEST_FILE);
close(FilDes);
unlink(TEST_FILE);
break;
case 5:
printf("Could not open file %s.\n",TEST_FILE);
unlink(TEST_FILE);
break;
case 6:
printf("Could not read file %s.\n",TEST_FILE);
close(FilDes);
unlink(TEST_FILE);
break;
case 7:
printf("Could not close file %s.\n",TEST_FILE);
close(FilDes);
unlink(TEST_FILE);
break;
case 8:
printf("Could not unlink file %s.\n",TEST_FILE);
unlink(TEST_FILE);
break;
default:
break;
}
printf("Program ended with Error.\n"\
"All test files and directories may not have been removed.\n");
}
B-176 System API Programming V4R1