#include <sys/types.h>#include <sys/stat.h>Include dependency graph for portable.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.
Data Structures | |
| struct | fileInfo |
| struct | tempName |
Functions | |
| slName * | listDir (char *dir, char *pattern) |
| fileInfo * | newFileInfo (char *name, off_t size, bool isDir) |
| fileInfo * | listDirX (char *dir, char *pattern, boolean fullPath) |
| char * | getCurrentDir () |
| boolean | setCurrentDir (char *newDir) |
| boolean | makeDir (char *dirName) |
| long | clock1000 () |
| void | sleep1000 (int milli) |
| long | clock1 () |
| char * | rTempName (char *dir, char *base, char *suffix) |
| void | makeTempName (struct tempName *tn, char *base, char *suffix) |
| char * | semiUniqName (char *base) |
| char * | cgiDir () |
| char * | trashDir () |
| void | mkdirTrashDirectory (char *prefix) |
| double | machineSpeed () |
| char * | mysqlHost () |
| char * | getHost () |
| void | uglyfBreak () |
| char * | getUser () |
| void | envUpdate (char *name, char *value) |
| int | mustFork () |
| int | rawKeyIn () |
| unsigned long | fileModTime (char *pathName) |
| boolean | isPipe (int fd) |
| char* cgiDir | ( | ) |
Definition at line 56 of file portimpl.c.
References webServerSpecific::cgiDir, setupWss(), and wss.
Here is the call graph for this function:

| long clock1 | ( | ) |
| long clock1000 | ( | ) |
Definition at line 31 of file osunix.c.
Referenced by dnaQuery(), genoPcrDirect(), pcrQuery(), qaPageFromForm(), qaPageGet(), qaStatusOnPage(), transQuery(), transTransQuery(), and uglyTime().
00033 { 00034 struct timeval tv; 00035 static long origSec; 00036 gettimeofday(&tv, NULL); 00037 if (origSec == 0) 00038 origSec = tv.tv_sec; 00039 return (tv.tv_sec-origSec)*1000 + tv.tv_usec / 1000; 00040 }
Here is the caller graph for this function:

| void envUpdate | ( | char * | name, | |
| char * | value | |||
| ) |
Definition at line 76 of file portimpl.c.
References needMem(), and safef().
Referenced by initCgiInput().
00078 { 00079 int size = strlen(name) + strlen(value) + 2; 00080 char *s = needMem(size); 00081 safef(s, size, "%s=%s", name, value); 00082 putenv(s); 00083 }
Here is the call graph for this function:

Here is the caller graph for this function:

| unsigned long fileModTime | ( | char * | pathName | ) |
Definition at line 201 of file osunix.c.
References errAbort().
00205 { 00206 struct stat st; 00207 if (stat(pathName, &st) < 0) 00208 errAbort("stat failed in fileModTime: %s", pathName); 00209 return st.st_mtime; 00210 }
Here is the call graph for this function:

| char* getCurrentDir | ( | ) |
Definition at line 69 of file osunix.c.
References warn().
Referenced by listDir().
00071 { 00072 static char dir[1024]; 00073 00074 if (getcwd( dir, sizeof(dir) ) == NULL ) 00075 { 00076 warn("No current directory"); 00077 return NULL; 00078 } 00079 return dir; 00080 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* getHost | ( | ) |
Definition at line 213 of file osunix.c.
References chopSuffix().
Referenced by semiUniqName().
00215 { 00216 static char *hostName = NULL; 00217 static char buf[128]; 00218 if (hostName == NULL) 00219 { 00220 hostName = getenv("HTTP_HOST"); 00221 if (hostName == NULL) 00222 { 00223 hostName = getenv("HOST"); 00224 if (hostName == NULL) 00225 { 00226 if (hostName == NULL) 00227 { 00228 static struct utsname unamebuf; 00229 if (uname(&unamebuf) >= 0) 00230 hostName = unamebuf.nodename; 00231 else 00232 hostName = "unknown"; 00233 } 00234 } 00235 } 00236 strncpy(buf, hostName, sizeof(buf)); 00237 chopSuffix(buf); 00238 hostName = buf; 00239 } 00240 return hostName; 00241 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* getUser | ( | ) |
Definition at line 299 of file osunix.c.
References errnoAbort().
00301 { 00302 uid_t uid = geteuid(); 00303 struct passwd *pw = getpwuid(uid); 00304 if (pw == NULL) 00305 errnoAbort("can't get user name for uid %d", (int)uid); 00306 return pw->pw_name; 00307 }
Here is the call graph for this function:

| boolean isPipe | ( | int | fd | ) |
Definition at line 345 of file osunix.c.
References errnoAbort().
00347 { 00348 struct stat buf; 00349 if (fstat(fd, &buf) < 0) 00350 errnoAbort("fstat failed"); 00351 return S_ISFIFO(buf.st_mode); 00352 }
Here is the call graph for this function:

| struct slName* listDir | ( | char * | dir, | |
| char * | pattern | |||
| ) | [read] |
Definition at line 93 of file osunix.c.
References FALSE, getCurrentDir(), name, newSlName(), sameString, setCurrentDir(), slAddHead, slNameSort(), and TRUE.
00096 { 00097 struct slName *list = NULL, *name; 00098 struct dirent *de; 00099 DIR *d; 00100 00101 if ((d = opendir(dir)) == NULL) 00102 return NULL; 00103 while ((de = readdir(d)) != NULL) 00104 { 00105 char *fileName = de->d_name; 00106 if (differentString(fileName, ".") && differentString(fileName, "..")) 00107 { 00108 if (pattern == NULL || wildMatch(pattern, fileName)) 00109 { 00110 name = newSlName(fileName); 00111 slAddHead(&list, name); 00112 } 00113 } 00114 } 00115 closedir(d); 00116 slNameSort(&list); 00117 return list; 00118 }
Here is the call graph for this function:

| struct fileInfo* listDirX | ( | char * | dir, | |
| char * | pattern, | |||
| boolean | fullPath | |||
| ) | [read] |
Definition at line 158 of file osunix.c.
References cmpFileInfo(), differentString, errAbort(), FALSE, newFileInfo(), slAddHead, slSort(), TRUE, and wildMatch().
00162 { 00163 struct fileInfo *list = NULL, *el; 00164 struct dirent *de; 00165 DIR *d; 00166 int dirNameSize = strlen(dir); 00167 int fileNameOffset = dirNameSize+1; 00168 char pathName[512]; 00169 00170 if ((d = opendir(dir)) == NULL) 00171 return NULL; 00172 memcpy(pathName, dir, dirNameSize); 00173 pathName[dirNameSize] = '/'; 00174 00175 while ((de = readdir(d)) != NULL) 00176 { 00177 char *fileName = de->d_name; 00178 if (differentString(fileName, ".") && differentString(fileName, "..")) 00179 { 00180 if (pattern == NULL || wildMatch(pattern, fileName)) 00181 { 00182 struct stat st; 00183 bool isDir = FALSE; 00184 strcpy(pathName+fileNameOffset, fileName); 00185 if (stat(pathName, &st) < 0) 00186 errAbort("stat failed in listDirX"); 00187 if (S_ISDIR(st.st_mode)) 00188 isDir = TRUE; 00189 if (fullPath) 00190 fileName = pathName; 00191 el = newFileInfo(fileName, st.st_size, isDir); 00192 slAddHead(&list, el); 00193 } 00194 } 00195 } 00196 closedir(d); 00197 slSort(&list, cmpFileInfo); 00198 return list; 00199 }
Here is the call graph for this function:

| double machineSpeed | ( | ) |
Definition at line 69 of file portimpl.c.
References setupWss(), webServerSpecific::speed, and wss.
Here is the call graph for this function:

| boolean makeDir | ( | char * | dirName | ) |
Definition at line 139 of file osunix.c.
References errAbort(), errno, FALSE, and TRUE.
Referenced by makeDirs().
00143 { 00144 int err; 00145 if ((err = mkdir(dirName, 0777)) < 0) 00146 { 00147 if (errno != EEXIST) 00148 { 00149 perror(""); 00150 errAbort("Couldn't make directory %s", dirName); 00151 } 00152 return FALSE; 00153 } 00154 return TRUE; 00155 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void makeTempName | ( | struct tempName * | tn, | |
| char * | base, | |||
| char * | suffix | |||
| ) |
Definition at line 49 of file portimpl.c.
References webServerSpecific::makeTempName, setupWss(), and wss.
Referenced by parseMultiParts(), xenAlignBig(), and xenAlignWorm().
00051 { 00052 setupWss(); 00053 wss->makeTempName(tn,base,suffix); 00054 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void mkdirTrashDirectory | ( | char * | prefix | ) |
Definition at line 85 of file portimpl.c.
References errnoAbort(), safef(), and trashDir().
00087 { 00088 struct stat buf; 00089 char trashDirName[128]; 00090 safef(trashDirName, sizeof(trashDirName), "%s/%s", trashDir(), prefix); 00091 if (stat(trashDirName,&buf)) 00092 { 00093 int result = mkdir (trashDirName, S_IRWXU | S_IRWXG | S_IRWXO); 00094 if (0 != result) 00095 errnoAbort("failed to create directory %s", trashDirName); 00096 } 00097 }
Here is the call graph for this function:

| int mustFork | ( | ) |
Definition at line 309 of file osunix.c.
References errnoAbort().
Referenced by logDaemonize().
00311 { 00312 int childId = fork(); 00313 if (childId == -1) 00314 errnoAbort("Unable to fork"); 00315 return childId; 00316 }
Here is the call graph for this function:

Here is the caller graph for this function:

| char* mysqlHost | ( | ) |
Definition at line 243 of file osunix.c.
References FALSE, fileExists(), firstWordInFile(), and TRUE.
00245 { 00246 boolean gotIt = FALSE; 00247 static char *host = NULL; 00248 if (!gotIt) 00249 { 00250 static char hostBuf[128]; 00251 gotIt = TRUE; 00252 if (fileExists("mysqlHost")) 00253 { 00254 return (host = firstWordInFile("mysqlHost", hostBuf, sizeof(hostBuf))); 00255 } 00256 else 00257 return (host = getenv("MYSQLHOST")); 00258 } 00259 return host; 00260 }
Here is the call graph for this function:

| struct fileInfo* newFileInfo | ( | char * | name, | |
| off_t | size, | |||
| bool | isDir | |||
| ) | [read] |
Definition at line 120 of file osunix.c.
References needMem().
Referenced by listDirX().
00122 { 00123 int len = strlen(name); 00124 struct fileInfo *fi = needMem(sizeof(*fi) + len); 00125 fi->size = size; 00126 fi->isDir = isDir; 00127 strcpy(fi->name, name); 00128 return fi; 00129 }
Here is the call graph for this function:

Here is the caller graph for this function:

| int rawKeyIn | ( | ) |
Definition at line 318 of file osunix.c.
References errAbort(), and errnoAbort().
00320 { 00321 struct termios attr; 00322 tcflag_t old; 00323 char c; 00324 00325 /* Set terminal to non-echoing non-buffered state. */ 00326 if (tcgetattr(STDIN_FILENO, &attr) != 0) 00327 errAbort("Couldn't do tcgetattr"); 00328 old = attr.c_lflag; 00329 attr.c_lflag &= ~ICANON; 00330 attr.c_lflag &= ~ECHO; 00331 if (tcsetattr(STDIN_FILENO, TCSANOW, &attr) == -1) 00332 errAbort("Couldn't do tcsetattr"); 00333 00334 /* Read one byte */ 00335 if (read(STDIN_FILENO,&c,1) != 1) 00336 errnoAbort("I/O error"); 00337 00338 /* Put back terminal to how it was. */ 00339 attr.c_lflag = old; 00340 if (tcsetattr(STDIN_FILENO, TCSANOW, &attr) == -1) 00341 errAbort("Couldn't do tcsetattr2"); 00342 return c; 00343 }
Here is the call graph for this function:

| char* rTempName | ( | char * | dir, | |
| char * | base, | |||
| char * | suffix | |||
| ) |
Definition at line 282 of file osunix.c.
Referenced by _makeTempName(), dnaMotifToLogoPGM(), dnaMotifToLogoPng(), doBlat(), and doDetailLine().
00284 { 00285 char *x; 00286 static char fileName[PATH_LEN]; 00287 int i; 00288 for (i=0;;++i) 00289 { 00290 x = semiUniqName(base); 00291 safef(fileName, sizeof(fileName), "%s/%s%d%s", 00292 dir, x, i, suffix); 00293 if (!fileExists(fileName)) 00294 break; 00295 } 00296 return fileName; 00297 }
Here is the caller graph for this function:

| char* semiUniqName | ( | char * | base | ) |
Definition at line 262 of file osunix.c.
References getHost(), name, PATH_LEN, safef(), and subChar().
Referenced by rTempName().
00267 { 00268 int pid = getpid(); 00269 int num = time(NULL)&0xFFFFF; 00270 char host[512]; 00271 strcpy(host, getHost()); 00272 char *s = strchr(host, '.'); 00273 if (s != NULL) 00274 *s = 0; 00275 subChar(host, '-', '_'); 00276 static char name[PATH_LEN]; 00277 safef(name, sizeof(name), "%s_%s_%x_%x", 00278 base, host, pid, num); 00279 return name; 00280 }
Here is the call graph for this function:

Here is the caller graph for this function:

| boolean setCurrentDir | ( | char * | newDir | ) |
Definition at line 82 of file osunix.c.
References FALSE, TRUE, and warn().
Referenced by listDir().
00084 { 00085 if (chdir(newDir) != 0) 00086 { 00087 warn("Unable to set dir %s", newDir); 00088 return FALSE; 00089 } 00090 return TRUE; 00091 }
Here is the call graph for this function:

Here is the caller graph for this function:

| void sleep1000 | ( | int | milli | ) |
| char* trashDir | ( | ) |
Definition at line 62 of file portimpl.c.
References setupWss(), webServerSpecific::trashDir, and wss.
Referenced by mkdirTrashDirectory().
Here is the call graph for this function:

Here is the caller graph for this function:

| void uglyfBreak | ( | ) |
1.5.2