Changeset 4979 for trunk/psLib/src/sys/psLogMsg.c
- Timestamp:
- Sep 8, 2005, 3:11:23 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/sys/psLogMsg.c (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psLogMsg.c
r4952 r4979 12 12 * @author GLG, MHPCC 13 13 * 14 * @version $Revision: 1.5 0$ $Name: not supported by cvs2svn $15 * @date $Date: 2005-09-0 7 00:36:12 $14 * @version $Revision: 1.51 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2005-09-09 01:11:22 $ 16 16 * 17 17 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 90 90 bool psLogSetDestination(int fd) 91 91 { 92 // char protocol[5];93 // char location[257];94 // char dest[257];95 92 FILE *fp; 96 93 // if logDest has not been initialized, do so before using it … … 98 95 logDest = stderr; 99 96 } 97 if (fd == -1) 98 return false; 100 99 101 100 if ( fd == 1 ) { … … 117 116 } 118 117 logDest = NULL; 119 return true;118 // return true; 120 119 } else if (fd > 2) { 121 120 if (logDest != NULL && logDest != stderr && logDest != stdout) { … … 125 124 logDest = fp; 126 125 // fclose(fp); 127 return true; 128 } 129 130 /* 131 if (dest == NULL || strcmp(dest, "none") == 0) { 132 if (logDest != NULL && logDest != stderr && logDest != stdout) { 133 fclose(logDest); 134 } 135 logDest = NULL; 136 return true; 137 } 138 if (sscanf(dest, "%4s:%256s", protocol, location) < 2) { 139 psError(PS_ERR_LOCATION_INVALID, true, 140 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED, 141 dest); 142 return false; 143 } 144 */ 145 /* 146 147 if (strcmp(protocol, "dest") == 0) { 148 if (strcmp(location, "stderr") == 0) { 149 if (logDest != NULL && logDest != stderr && logDest != stdout) { 150 fclose(logDest); 151 } 152 logDest = stderr; 153 return true; 154 } 155 if (strcmp(location, "stdout") == 0) { 156 if (logDest != NULL && logDest != stderr && logDest != stdout) { 157 fclose(logDest); 158 } 159 logDest = stdout; 160 return true; 161 } 162 psError(PS_ERR_LOCATION_INVALID, true, PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID, 163 location); 164 return 1; 165 } else if (strcmp(protocol, "file") == 0) { 166 FILE *file = fopen(location, "w"); 167 168 if (file == NULL) { 169 psError(PS_ERR_IO, true, PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED, 170 location); 171 return false; 172 } 173 if (logDest != NULL && logDest != stderr && logDest != stdout) { 174 fclose(logDest); 175 } 176 logDest = file; 177 return true; 178 } 179 */ 126 // return true; 127 } 128 180 129 return true; 181 130 … … 253 202 } 254 203 204 int psMessageDestination (const char *dest) 205 { 206 char protocol[5]; 207 char location[257]; 208 if (logDest == (FILE *) 1) { 209 logDest = stderr; 210 } 211 212 if (dest == NULL || strcmp(dest, "none") == 0) { 213 if (logDest != NULL && logDest != stderr && logDest != stdout) { 214 fclose(logDest); 215 } 216 logDest = NULL; 217 return 0; 218 } 219 if (sscanf(dest, "%4s:%256s", protocol, location) < 2) { 220 psError(PS_ERR_LOCATION_INVALID, true, 221 PS_ERRORTEXT_psLogMsg_DESTINATION_MALFORMED, 222 dest); 223 return -1; 224 } 225 if (strcmp(protocol, "dest") == 0) { 226 if (strcmp(location, "stderr") == 0) { 227 if (logDest != NULL && logDest != stderr && logDest != stdout) { 228 fclose(logDest); 229 } 230 logDest = stderr; 231 return 2; 232 } 233 if (strcmp(location, "stdout") == 0) { 234 if (logDest != NULL && logDest != stderr && logDest != stdout) { 235 fclose(logDest); 236 } 237 logDest = stdout; 238 return 1; 239 } 240 psError(PS_ERR_LOCATION_INVALID, true, PS_ERRORTEXT_psLogMsg_DEST_LOCATION_INVALID, 241 location); 242 return -1; 243 } else if (strcmp(protocol, "file") == 0) { 244 // FILE *file = fopen(location, "w"); 245 int fileD = creat(location, 0666); 246 247 if (fileD == 0) { 248 psError(PS_ERR_IO, true, PS_ERRORTEXT_psLogMsg_OPEN_FILE_FAILED, 249 location); 250 return -1; 251 } 252 if (logDest != NULL && logDest != stderr && logDest != stdout) { 253 fclose(logDest); 254 } 255 logDest = fdopen(fileD, "w"); 256 return fileD; 257 } 258 return -1; 259 } 260 255 261 #ifndef HOST_NAME_MAX // should be in limits.h 256 262 #define HOST_NAME_MAX 256
Note:
See TracChangeset
for help on using the changeset viewer.
