CSCE 510 Function Prototypes
- int open(const char *path, int oflag, /* mode_t mode */...);
- int close (int filedes );
- int creat(const char *path, mode_t mode);
- off_t lseek(int fildes, off_t offset, int whence);
- ssize_t read(int filedes, void *buffer, size_t nbytes);
- ssize_t write(int filedes, void *buffer, size_t nbytes);
- void (*signal(int sig, void (*function) (int))) (int);
- pid_t getpid( void );
- char *strcat(char *s1, const char *s2);
- int strcmp(const char *s1, const char *s2);
- char *strcpy(char *s1, const char *s2);
- int strncmp(const char *s1, const char *s2, size_t n);
- char *strncpy(char *s1, const char *s2, size_t n);
- char *strdup(const char *s1);
- size_t strlen(const char *s);
- char *strchr(const char *s, int c);
- char *strrchr(const char *s, int c);
- char *strstr(const char *s1, const char *s2);
- char *strtok(char *s1, const char *s2);
- char *strtok_r(char *s1, const char *s2, char **savept);
- char *strerror(int errnum);
- int dup(int filedes );
- int dup2(int old, int new );
- int stat(const char *path, struct stat *buf);
- int lstat(const char *path, struct stat *buf);
- int fstat(int fildes, struct stat *buf);
- DIR *opendir(const char *dirname);
- struct dirent *readdir(DIR *dirp);
- void rewinddir(DIR *dp);
- int closedir(DIR *dp);
- int mkdir(const char *path, mode_t mode);
- int rmdir(const char *path);
- int statvfs(const char *path, struct statvfs *buf);
- int fstatvfs(int fildes, struct statvfs *buf);
- int rename(const char *old, const char *new);
- char * getenv(char *p);
- pid_t fork(void); int execl(const char *path, const char *arg0, ..., const char *argn, char * /*NULL*/);
- int execv(const char *path, char *const argv[]);
- int execle(const char *path, const char *arg0, ..., const char *argn, char * /*NULL*/, char *const envp[]);
- int execve(const char *path, char *const argv[], char *const envp[]);
- int execlp(const char *file, const char *arg0, ..., const char *argn, char * /*NULL*/);
- int execvp(const char *file, char *const argv[]);
- void *mmap(void *addr, size_t len, int prot, int flags, int fd, off_t off);
- int munmap(void *addr, size_t len);
- void (*signal (int sig, void (*disp)(int)))(int);
- int kill(pid_t pid, int sig);
- int sigaction(int sig, const struct sigaction *act, struct
sigaction *oact);
- int sigprocmask(int how, const sigset_t *set, sigset_t *oset);
- int sigpending(sigset_t *set);
- int sigsetjmp(sigjmp_buf env, int savemask);
- void siglongjmp(sigjmp_buf env, int val);
- int sigemptyset(sigset_t *set);
- int sigfillset(sigset_t *set);
- int sigaddset(sigset_t *set, int signo);
- int sigdelset(sigset_t *set, int signo);
- int sigismember(sigset_t *set, int signo);
- int mknod(const char *path, mode_t mode, dev_t dev);
- int lockf(int fildes, int function, off_t size);
- int fcntl(int fildes, int cmd, /* arg */ ...);
- CMDS for fcntl : F_GETFD, F_SETFD, F_SETLK, F_GETLK, F_SETLKW
struct flock {
...
short l_type; /* Type of lock: F_RDLCK,
F_WRLCK, F_UNLCK */
short l_whence; /* How to interpret l_start:
SEEK_SET, SEEK_CUR, SEEK_END */
off_t l_start; /* Starting offset for lock */
off_t l_len; /* Number of bytes to lock */
pid_t l_pid; /* PID of process blocking our lock
(F_GETLK only) */
...
};
- int pipe(int fildes[2]);
- int pthread_create(pthread_t *thread, const pthread_attr_t *attr, void *(*start_routine, void*),void *arg);
- int pthread_join(pthread_t thread, void **value_ptr);
- int pthread_mutex_init(pthread_mutex_t *mutex, const
pthread_mutexattr_t *attr);
- int pthread_mutex_lock(pthread_mutex_t *mutex);
- int pthread_mutex_trylock(pthread_mutex_t *mutex);
- int pthread_mutex_unlock(pthread_mutex_t *mutex);
- key_t ftok(const char *pathname, int proj_id);
- int msgget(key_t key, int msgflg);
- int msgctl(int msqid, int cmd, struct msqid_ds *buf);
- int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
- int msgsnd(int msqid, struct msgbuf *msgp, size_t msgsz, int msgflg);
- int semget(key_t key, int nsems, int semflg);
- int semctl(int semid, int semnum, int cmd, ...);
- union semun {
int val; /* value for SETVAL */
struct semid_ds *buf; /* buffer for IPC_STAT, IPC_SET */
unsigned short *array; /* array for GETALL, SETALL */
/* Linux specific part: */
struct seminfo *__buf; /* buffer for IPC_INFO */
};
- int socket(int domain, int type, int protocol);
- int bind(int sockfd, struct sockaddr *my_addr, socklen_t addrlen);
- int accept(int s, struct sockaddr *addr, socklen_t *addrlen);
- int listen(int s, int backlog);
- int semop(int semid, struct sembuf *sops, unsigned nsops);
- struct hostent *gethostbyname(const char *name);
- int gethostname(char *name, size_t len);
-
-
struct stat {
dev_t st_dev;
ino_t st_ino;
mode_t st_mode;
nlink_t st_nlink;
uid_t st_uid;
gid_t st_gid;
dev_t st_rdev;
off_t st_size;
timestruc_t st_atim;
timestruc_t st_mtim;
timestruc_t st_ctim;
blksize_t st_blksize;
blkcnt_t st_blocks;
char st_fstype[_ST_FSTYPSZ];
};
#define S_IRWXU 00700 /* read, write, execute: owner */
#define S_IRUSR 00400 /* read permission: owner */
#define S_IWUSR 00200 /* write permission: owner */
#define S_IXUSR 00100 /* execute permission: owner */
#define S_IRWXG 00070 /* read, write, execute: group */
#define S_IRGRP 00040 /* read permission: group */
#define S_IWGRP 00020 /* write permission: group */
#define S_IXGRP 00010 /* execute permission: group */
#define S_IRWXO 00007 /* read, write, execute: other */
#define S_IROTH 00004 /* read permission: other */
#define S_IWOTH 00002 /* write permission: other */
#define S_IXOTH 00001 /* execute permission: other */
#define S_ISFIFO(mode) (((mode)&0xF000) == 0x1000)
#define S_ISCHR(mode) (((mode)&0xF000) == 0x2000)
#define S_ISDIR(mode) (((mode)&0xF000) == 0x4000)
#define S_ISBLK(mode) (((mode)&0xF000) == 0x6000)
#define S_ISREG(mode) (((mode)&0xF000) == 0x8000)
#define S_ISLNK(mode) (((mode)&0xF000) == 0xa000)
#define S_ISSOCK(mode) (((mode)&0xF000) == 0xc000)
#define S_ISDOOR(mode) (((mode)&0xF000) == 0xd000)
stdio.h macros
ar header
URL = http://www.cs.sc.edu/~matthews/Courses/510/FunctionPrototypes.html