9 ** This package defines functions for working with operating system facilities.
13 #include <sys/types.h> /* mode_t size_t */
20 ** Returns a best-guess estimate of the number of CPUs on the system.
27 ** Returns the current time in number of seconds since midnight 1/1/1970, GMT.
34 ** Returns the environment value for the variable #name#. This value is
35 ** determined in one of three ways: if an environment variable of that name is
36 ** set, its value is used; otherwise, if a file named #rcName# in one of the
37 ** colon-delimited set of directories #rcDirs# contains a line of the form
38 ** #name#=value, then that value is used; otherwise #defaultValue# is used.
39 ** For convenience, a directory of "~" in #rcDirs# is expanded to the contents
40 ** of the HOME environment variable.
43 GetEnvironmentValue(const char *name,
46 const char *defaultValue);
50 ** Attempts to determine the login id of the user running the binary. Returns
51 ** 1 and copies the name into the #length#-long array name if successful, else
55 GetUserName(char *name,
60 * Wrapper around the system signal() for the SIGALRM signal.
61 * new_hanlder is the handler to be installed and old_handler (if not
62 * NULL) will contain the handler to be substituted.
63 * Return 1 upon * success and 0 otherwise.
66 typedef void(* handler)(int sig);
68 SignalAlarm( handler new_handler,
69 handler *old_handler);
72 ** Prevents the O/S from raising the signal #sig# until a subsequent call to
73 ** ReleaseSignal() is made.
80 ** Creates the directory specified by #path# with mode #mode#. If
81 ** #makeEntirePath# is non-zero, any missing subpaths in #path# will also be
82 ** created. Returns 1 if successful, else 0.
85 MakeDirectory(const char *path,
91 ** Returns the number of microseconds that have elapsed since midnight, local
99 ** Allows the O/S to raise the signal #sig#.
102 ReleaseSignal(int sig);
106 ** Starts a timer that will raise a SIGALRM in #numberOfSecs# seconds.
109 SetRealTimer(unsigned int numberOfSecs);
110 #define RESETREALTIMER SetRealTimer(0)
113 * Locks are handled in a peculiar way: #lock# is a void * passed in by
114 * the module. If #lock# is NULL, GetNWSLock() will assign to it a mutex
115 * and then it will lock it. It's up to the module to keep track of the
117 * Returns 1 if succesfull 0 otherwise.
120 GetNWSLock(void **lock);
123 * release the NWS general lock. Returns 1 if succesful, 0 otherwise.
126 ReleaseNWSLock(void **lock);