| 1 |
/* program to exercise spec_example.stp */ |
| 2 |
|
| 3 |
#include <sys/types.h> |
| 4 |
#include <sys/stat.h> |
| 5 |
#include <fcntl.h> |
| 6 |
|
| 7 |
#include <unistd.h> |
| 8 |
#include <stdlib.h> |
| 9 |
#include <stdio.h> |
| 10 |
|
| 11 |
#define BOGUS NULL |
| 12 |
#define MAXSIZE 512 |
| 13 |
static char buf1[MAXSIZE]; |
| 14 |
static char buf2[MAXSIZE]; |
| 15 |
|
| 16 |
int main (int argc, char ** argv) |
| 17 |
{ |
| 18 |
int fbad = open("/tmp/junky_bad", O_CREAT|O_RDWR, 0660); |
| 19 |
int fokay = open("/tmp/junky_good", O_CREAT|O_RDWR, 0660); |
| 20 |
|
| 21 |
if (fbad < 0) return(EXIT_FAILURE); |
| 22 |
if (fokay < 0) return(EXIT_FAILURE); |
| 23 |
|
| 24 |
write(fokay, buf1, MAXSIZE); |
| 25 |
write(fokay, buf1, MAXSIZE); |
| 26 |
write(fbad, buf2, MAXSIZE); |
| 27 |
write(fokay, buf2, MAXSIZE); |
| 28 |
write(fokay, buf1, MAXSIZE); |
| 29 |
write(fbad, buf1, MAXSIZE); |
| 30 |
write(fbad, BOGUS, MAXSIZE); |
| 31 |
write(fokay, buf1, MAXSIZE); |
| 32 |
|
| 33 |
return(EXIT_SUCCESS); |
| 34 |
} |