📄 book.txt
字号:
00710 #endif
00711
00712 /* Here are types that are closely associated with signal handling. */
00713 typedef int sig_atomic_t;
00714
00715 #ifdef _POSIX_SOURCE
00716 #ifndef _SIGSET_T
00717 #define _SIGSET_T
00718 typedef unsigned long sigset_t;
00719 #endif
00720 #endif
00721
00722 #define _NSIG 16 /* number of signals used */
00723
00724 #define SIGHUP 1 /* hangup */
00725 #define SIGINT 2 /* interrupt (DEL) */
00726 #define SIGQUIT 3 /* quit (ASCII FS) */
00727 #define SIGILL 4 /* illegal instruction */
00728 #define SIGTRAP 5 /* trace trap (not reset when caught) */
00729 #define SIGABRT 6 /* IOT instruction */
00730 #define SIGIOT 6 /* SIGABRT for people who speak PDP-11 */
00731 #define SIGUNUSED 7 /* spare code */
00732 #define SIGFPE 8 /* floating point exception */
00733 #define SIGKILL 9 /* kill (cannot be caught or ignored) */
00734 #define SIGUSR1 10 /* user defined signal # 1 */
00735 #define SIGSEGV 11 /* segmentation violation */
00736 #define SIGUSR2 12 /* user defined signal # 2 */
00737 #define SIGPIPE 13 /* write on a pipe with no one to read it */
00738 #define SIGALRM 14 /* alarm clock */
00739 #define SIGTERM 15 /* software termination signal from kill */
00740
00741 #define SIGEMT 7 /* obsolete */
00742 #define SIGBUS 10 /* obsolete */
00743
00744 /* POSIX requires the following signals to be defined, even if they are
00745 * not supported. Here are the definitions, but they are not supported.
00746 */
00747 #define SIGCHLD 17 /* child process terminated or stopped */
00748 #define SIGCONT 18 /* continue if stopped */
00749 #define SIGSTOP 19 /* stop signal */
00750 #define SIGTSTP 20 /* interactive stop signal */
00751 #define SIGTTIN 21 /* background process wants to read */
00752 #define SIGTTOU 22 /* background process wants to write */
00753
00754 /* The sighandler_t type is not allowed unless _POSIX_SOURCE is defined. */
00755 #ifdef _POSIX_SOURCE
00756 #define __sighandler_t sighandler_t
00757 #else
00758 typedef void (*__sighandler_t) (int);
00759 #endif
00760
00761 /* Macros used as function pointers. */
00762 #define SIG_ERR ((__sighandler_t) -1) /* error return */
00763 #define SIG_DFL ((__sighandler_t) 0) /* default signal handling */
00764 #define SIG_IGN ((__sighandler_t) 1) /* ignore signal */
00765 #define SIG_HOLD ((__sighandler_t) 2) /* block signal */
00766 #define SIG_CATCH ((__sighandler_t) 3) /* catch signal */
00767
00768 #ifdef _POSIX_SOURCE
00769 struct sigaction {
00770 __sighandler_t sa_handler; /* SIG_DFL, SIG_IGN, or pointer to function */
00771 sigset_t sa_mask; /* signals to be blocked during handler */
00772 int sa_flags; /* special flags */
00773 };
00774
00775 /* Fields for sa_flags. */
00776 #define SA_ONSTACK 0x0001 /* deliver signal on alternate stack */
00777 #define SA_RESETHAND 0x0002 /* reset signal handler when signal caught */
00778 #define SA_NODEFER 0x0004 /* don't block signal while catching it */
00779 #define SA_RESTART 0x0008 /* automatic system call restart */
00780 #define SA_SIGINFO 0x0010 /* extended signal handling */
00781 #define SA_NOCLDWAIT 0x0020 /* don't create zombies */
00782 #define SA_NOCLDSTOP 0x0040 /* don't receive SIGCHLD when child stops */
00783
00784 /* POSIX requires these values for use with sigprocmask(2). */
00785 #define SIG_BLOCK 0 /* for blocking signals */
00786 #define SIG_UNBLOCK 1 /* for unblocking signals */
00787 #define SIG_SETMASK 2 /* for setting the signal mask */
00788 #define SIG_INQUIRE 4 /* for internal use only */
00789 #endif /* _POSIX_SOURCE */
00790
00791 /* POSIX and ANSI function prototypes. */
00792 _PROTOTYPE( int raise, (int _sig) );
00793 _PROTOTYPE( __sighandler_t signal, (int _sig, __sighandler_t _func) );
00794
00795 #ifdef _POSIX_SOURCE
00796 _PROTOTYPE( int kill, (pid_t _pid, int _sig) );
00797 _PROTOTYPE( int sigaction,
00798 (int _sig, const struct sigaction *_act, struct sigaction *_oact) );
00799 _PROTOTYPE( int sigaddset, (sigset_t *_set, int _sig) );
00800 _PROTOTYPE( int sigdelset, (sigset_t *_set, int _sig) );
00801 _PROTOTYPE( int sigemptyset, (sigset_t *_set) );
00802 _PROTOTYPE( int sigfillset, (sigset_t *_set) );
00803 _PROTOTYPE( int sigismember, (sigset_t *_set, int _sig) );
00804 _PROTOTYPE( int sigpending, (sigset_t *_set) );
00805 _PROTOTYPE( int sigprocmask,
00806 (int _how, const sigset_t *_set, sigset_t *_oset) );
00807 _PROTOTYPE( int sigsuspend, (const sigset_t *_sigmask) );
00808 #endif
00809
00810 #endif /* _SIGNAL_H */
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/fcntl.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
00900 /* The <fcntl.h> header is needed by the open() and fcntl() system calls,
00901 * which have a variety of parameters and flags. They are described here.
00902 * The formats of the calls to each of these are:
00903 *
00904 * open(path, oflag [,mode]) open a file
00905 * fcntl(fd, cmd [,arg]) get or set file attributes
00906 *
00907 */
00908
00909 #ifndef _FCNTL_H
00910 #define _FCNTL_H
00911
00912 /* These values are used for cmd in fcntl(). POSIX Table 6-1. */
00913 #define F_DUPFD 0 /* duplicate file descriptor */
00914 #define F_GETFD 1 /* get file descriptor flags */
00915 #define F_SETFD 2 /* set file descriptor flags */
00916 #define F_GETFL 3 /* get file status flags */
00917 #define F_SETFL 4 /* set file status flags */
00918 #define F_GETLK 5 /* get record locking information */
00919 #define F_SETLK 6 /* set record locking information */
00920 #define F_SETLKW 7 /* set record locking info; wait if blocked */
00921
00922 /* File descriptor flags used for fcntl(). POSIX Table 6-2. */
00923 #define FD_CLOEXEC 1 /* close on exec flag for third arg of fcntl */
00924
00925 /* L_type values for record locking with fcntl(). POSIX Table 6-3. */
00926 #define F_RDLCK 1 /* shared or read lock */
00927 #define F_WRLCK 2 /* exclusive or write lock */
00928 #define F_UNLCK 3 /* unlock */
00929
00930 /* Oflag values for open(). POSIX Table 6-4. */
00931 #define O_CREAT 00100 /* creat file if it doesn't exist */
00932 #define O_EXCL 00200 /* exclusive use flag */
00933 #define O_NOCTTY 00400 /* do not assign a controlling terminal */
00934 #define O_TRUNC 01000 /* truncate flag */
00935
00936 /* File status flags for open() and fcntl(). POSIX Table 6-5. */
00937 #define O_APPEND 02000 /* set append mode */
00938 #define O_NONBLOCK 04000 /* no delay */
00939
00940 /* File access modes for open() and fcntl(). POSIX Table 6-6. */
00941 #define O_RDONLY 0 /* open(name, O_RDONLY) opens read only */
00942 #define O_WRONLY 1 /* open(name, O_WRONLY) opens write only */
00943 #define O_RDWR 2 /* open(name, O_RDWR) opens read/write */
00944
00945 /* Mask for use with file access modes. POSIX Table 6-7. */
00946 #define O_ACCMODE 03 /* mask for file access modes */
00947
00948 /* Struct used for locking. POSIX Table 6-8. */
00949 struct flock {
00950 short l_type; /* type: F_RDLCK, F_WRLCK, or F_UNLCK */
00951 short l_whence; /* flag for starting offset */
00952 off_t l_start; /* relative offset in bytes */
00953 off_t l_len; /* size; if 0, then until EOF */
00954 pid_t l_pid; /* process id of the locks' owner */
00955 };
00956
00957
00958 /* Function Prototypes. */
00959 #ifndef _ANSI_H
00960 #include <ansi.h>
00961 #endif
00962
00963 _PROTOTYPE( int creat, (const char *_path, Mode_t _mode) );
00964 _PROTOTYPE( int fcntl, (int _filedes, int _cmd, ...) );
00965 _PROTOTYPE( int open, (const char *_path, int _oflag, ...) );
00966
00967 #endif /* _FCNTL_H */
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/stdlib.h
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
01000 /* The <stdlib.h> header defines certain common macros, types, and functions.*/
01001
01002 #ifndef _STDLIB_H
01003 #define _STDLIB_H
01004
01005 /* The macros are NULL, EXIT_FAILURE, EXIT_SUCCESS, RAND_MAX, and MB_CUR_MAX.*/
01006 #define NULL ((void *)0)
01007
01008 #define EXIT_FAILURE 1 /* standard error return using exit() */
01009 #define EXIT_SUCCESS 0 /* successful return using exit() */
01010 #define RAND_MAX 32767 /* largest value generated by rand() */
01011 #define MB_CUR_MAX 1 /* max value of multibyte character in MINIX */
01012
01013 typedef struct { int quot, rem; } div_t;
01014 typedef struct { long quot, rem; } ldiv_t;
01015
01016 /* The types are size_t, wchar_t, div_t, and ldiv_t. */
01017 #ifndef _SIZE_T
01018 #define _SIZE_T
01019 typedef unsigned int size_t; /* type returned by sizeof */
01020 #endif
01021
01022 #ifndef _WCHAR_T
01023 #define _WCHAR_T
01024 typedef char wchar_t; /* type expanded character set */
01025 #endif
01026
01027 /* Function Prototypes. */
01028 #ifndef _ANSI_H
01029 #include <ansi.h>
01030 #endif
01031
01032 _PROTOTYPE( void abort, (void) );
01033 _PROTOTYPE( int abs, (int _j) );
01034 _PROTOTYPE( int atexit, (void (*_func)(void)) );
01035 _PROTOTYPE( double atof, (const char *_nptr) );
01036 _PROTOTYPE( int atoi, (const char *_nptr) );
01037 _PROTOTYPE( long atol, (const char *_nptr) );
01038 _PROTOTYPE( void *calloc, (size_t _nmemb, size_t _size) );
01039 _PROTOTYPE( div_t div, (int _numer, int _denom) );
01040 _PROTOTYPE( void exit, (int _status) );
01041 _PROTOTYPE( void free, (void *_ptr) );
01042 _PROTOTYPE( char *getenv, (const char *_name) );
01043 _PROTOTYPE( long labs, (long _j) );
01044 _PROTOTYPE( ldiv_t ldiv, (long _numer, long _denom) );
01045 _PROTOTYPE( void *malloc, (size_t _size) );
01046 _PROTOTYPE( int mblen, (const char *_s, size_t _n) );
01047 _PROTOTYPE( size_t mbstowcs, (wchar_t *_pwcs, const char *_s, size_t _n));
01048 _PROTOTYPE( int mbtowc, (wchar_t *_pwc, const char *_s, size_t _n) );
01049 _PROTOTYPE( int rand, (void) );
01050 _PROTOTYPE( void *realloc, (void *_ptr, size_t _size) );
01051 _PROTOTYPE( void srand, (unsigned int _seed) );
01052 _PROTOTYPE( double strtod, (const char *_nptr, char **_endptr) );
01053 _PROTOTYPE( long strtol, (const char *_nptr, char **_endptr, int _base) );
01054 _PROTOTYPE( int system, (const char *_string) );
01055 _PROTOTYPE( size_t wcstombs, (char *_s, const wchar_t *_pwcs, size_t _n));
01056 _PROTOTYPE( int wctomb, (char *_s, wchar_t _wchar) );
01057 _PROTOTYPE( void *bsearch, (const void *_key, const void *_base,
01058 size_t _nmemb, size_t _size,
01059 int (*compar) (const void *, const void *)) );
01060 _PROTOTYPE( void qsort, (void *_base, size_t _nmemb, size_t _size,
01061 int (*compar) (const void *, const void *)) );
01062 _PROTOTYPE( unsigned long int strtoul,
01063 (const char *_nptr, char **_endptr, int _base) );
01064
01065 #ifdef _MINIX
01066 _PROTOTYPE( int putenv, (const char *_name) );
01067 _PROTOTYPE(int getopt, (int _argc, char **_argv, char *_opts));
01068 extern char *optarg;
01069 extern int optind, opterr, optopt;
01070 #endif /* _MINIX */
01071
01072 #endif /* STDLIB_H */
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -