FILES and DIRECTORIES FILE *fopen(char *name, char *access); typedef struct { int _cnt, _bufsiz, _flag, _file; char *ptr, *base; } FILE; void fclose(FILE *file); void fflush(FILE *file); int fseek(FILE *file, long int pos, int from); /* from= SEEK_SET, SEEK_CUR, or SEEK_END */ char *gets(char *string); char *fgets(char *string, int max, FILE *file); int getchar(void); int fgetc(FILE *file); int scanf(char *format, ...); int fscanf(FILE *file, char *format, ...); int sscanf(char *string, char *format, ...); int putchar(int c); int fputc(int c, FILE *f); int puts(char *string); int fputs(char *string, FILE *file); int printf(char *format, ...); int fprintf(FILE *file, char *format, ...); int sprintf(char *string, char *format, ...); int rename(char *oldname, char *newname); int unlink(char *filename); int open(char *name, int mode, [int permissions] ); /* mode= O_RDWR, O_RDONLY, O_WRONLY, O_CREAT, O_APPEND */ int dup(int oldfd); int dup2(int oldfd, int newfd); void pipe(int fdpair[]); int close(int fd); int read(int fd, char *buffer, int number); int write(int fd, char *buffer, int number); long int lseek(int fd, long int pos, int from); /* from= L_SET, L_CUR, C_END */ int stat(char *name, struct stat *info); struct stat { int st_ino, st_mode, st_nlink, st_uid, st_size; time_t st_atime, st_mtime, st_ctime; }; DIR *opendir(char *name); void closedir(DIR *dir); struct direct *readdir(DIR *dir); struct direct { char *d_name; int d_ino; }; TIME and DATE typedef long int time_t; struct tm { int tm_year, tm_mon, tm_mday, tm_wday; int tm_yday, tm_hour, tm_min, tm_sec, tm_isdst; char *tm_zone; }; time_t time(time_t *ptr); /* ptr should be NULL */ char *ctime(time_t *ptr); struct tm *localtime(time_t *ptr); char *asctime(struct tm *ptr); time_t mktime(struct tm *ptr); void gettimeofday(struct timeval *tv, struct timezone *tz); struct timeval { long int tv_sec, tv_usec; }; struct timezone { int tz_minuteswest; }; void ftime(struct timeb *ptr); struct timeb { time_t time; long int millitm; }; PROCESSES int fork(void); void exit(int exitstatus); char *getenv(char *var); void setenv(char *var, char *value, int overwr); void unsetenv(char *var); int execl(char *path, char *arg0, char *arg1, ...); int execlp(char *prog, char *arg0, char *arg1, ...); int execv(char *path, char *args[]); int execvp(char *prog, char *args[]); int wait(int *exitstatus); void sleep(int seconds); void pause(void); int alarm(int seconds); int getpid(void); int kill(int pid, int code); void (*signal(int code, void (*handler)(void)))(); /* codes: SIGHUP, SIGINT, SIGQUIT, SIGKILL, SIGALRM, SIGTERM, SIGSTOP, SIGTSTP, SIGCONT, SIGCHLD, SIGUSR1, SIGUSR2, SIGSEGV, SIGBUS, SIGSYS, SIGILL, SIGFPE, SIGPIPE */ /* special handlers: SIG_IGN, SIG_DFL */ SOCKETS int socket(int family, int type, int protocol); /* families: AF_INET, AF_UNIX */ /* types: SOCK_STREAM, SOCK_DGRAM, SOCK_RAW */ /* protocols: 0 */ int connect(int socket, struct sockaddr *ia, int ialen); int bind(int socket, struct sockaddr *ia, int ialen); int listen(int socket, int maxqueuelen); int accept(int newsock, struct sockaddr *ia, int *ialen); the NETWORK void gethostname(char *string); struct hostent *gethostbyname(char *hostname); struct hostent { long int h_name; /* IP address */ }; struct sockaddr_in { int sin_family; in_addr sin_addr; short int sin_port; }; short int htons(short int port); long int htonl(long int addr); char *inet_ntoa(long int ipaddr); PEOPLE int getuid(void); struct passwd *getpwuid(int uid); struct passwd *getpwnam(char *username); struct passwd { char *pw_name, *pw_passwd, *pw_dir, *pw_shell; int pw_uid; }; OTHER int rand(void); void srand(int seed); void perror(char *message);