inc/portable.h

Go to the documentation of this file.
00001 /* portable.h - wrappers around things that vary from server
00002  * to server and operating system to operating system. 
00003  *
00004  * This file is copyright 2002 Jim Kent, but license is hereby
00005  * granted for all use - public, private or commercial. */
00006 
00007 #ifndef PORTABLE_H
00008 #define PORTABLE_H
00009 
00010 #include <sys/types.h>
00011 #include <sys/stat.h>
00012 
00013 struct slName *listDir(char *dir, char *pattern);
00014 /* Return an alphabetized list of all files that match 
00015  * the wildcard pattern in directory. */
00016 
00017 struct fileInfo 
00018 /* Info about a file. */
00019     {
00020     struct fileInfo  *next;     /* Next in list. */
00021     off_t size;         /* Size in bytes. */
00022     bool isDir;         /* True if file is a directory. */
00023     char name[1];       /* Allocated at run time. */
00024     };
00025 
00026 struct fileInfo *newFileInfo(char *name, off_t size, bool isDir);
00027 /* Return a new fileInfo. */
00028 
00029 struct fileInfo *listDirX(char *dir, char *pattern, boolean fullPath);
00030 /* Return list of files matching wildcard pattern with
00031  * extra info. If full path is true then the path will be
00032  * included in the name of each file.  You can free the
00033  * resulting list with slFreeList. */
00034 
00035 char *getCurrentDir();
00036 /* Return current directory. */
00037 
00038 boolean setCurrentDir(char *newDir);
00039 /* Set current directory.  Return FALSE if it fails. */
00040 
00041 boolean makeDir(char *dirName);
00042 /* Make dir.  Returns TRUE on success.  Returns FALSE
00043  * if failed because directory exists.  Prints error
00044  * message and aborts on other error. */
00045 
00046 long clock1000();
00047 /* 1000 hz clock */
00048 
00049 void sleep1000(int milli);
00050 /* Sleep for given number of milliseconds. */
00051 
00052 long clock1();
00053 /* A 1 hz clock. */
00054 
00055 char *rTempName(char *dir, char *base, char *suffix);
00056 /* Make a temp name that's almost certainly unique. */
00057 
00058 /* This structure helps us generate temp names and use
00059  * them.  Since different servers locate where the cgi
00060  * runs from differently, and where the generated html
00061  * file runs from - this is necessary for portable code. */
00062 struct tempName
00063         {
00064         char forCgi[128];
00065         char forHtml[128];
00066         };
00067 
00068 void makeTempName(struct tempName *tn, char *base, char *suffix);
00069 /* Make a good name for a temp file. */
00070 
00071 char *semiUniqName(char *base);
00072 /* Figure out a name likely to be unique.
00073  * Name will have no periods.  Returns a static
00074  * buffer, so best to clone result unless using
00075  * immediately. */
00076 
00077 char *cgiDir();
00078 /* Return directory to look for cgi in. */
00079 
00080 char *trashDir();
00081 /* Return directory for relative path to trash from cgi binaries */
00082 
00083 void mkdirTrashDirectory(char *prefix);
00084 /*      create the specified trash directory if it doesn't exist */
00085 
00086 double machineSpeed();
00087 /* Return relative speed of machine.  UCSC CSE dept. 1999 web server is 1.0 */
00088 
00089 char *mysqlHost();
00090 /* Return host computer on network for mySQL database. */
00091 
00092 char *getHost();
00093 /* Get name of this machine. */
00094 
00095 void uglyfBreak();
00096 /* Invoke the debugger. */
00097 
00098 char *getUser();
00099 /* Get user name */
00100 
00101 void envUpdate(char *name, char *value);
00102 /* Update an environment string */
00103 
00104 int mustFork();
00105 /* Fork or abort. */
00106 
00107 int rawKeyIn();
00108 /* Read in an unbuffered, unechoed character from keyboard. */
00109 
00110 unsigned long fileModTime(char *pathName);
00111 /* Return file last modification time.  The units of
00112  * these may vary from OS to OS, but you can depend on
00113  * later files having a larger time. */
00114 
00115 
00116 boolean isPipe(int fd);
00117 /* determine in an open file is a pipe  */
00118 
00119 #endif /* PORTABLE_H */
00120 

Generated on Tue Dec 25 18:39:29 2007 for blat by  doxygen 1.5.2