Changeset 33646
- Timestamp:
- Apr 1, 2012, 2:15:36 PM (14 years ago)
- Location:
- trunk/Ohana/src/libohana
- Files:
-
- 5 edited
- 3 copied
-
Makefile (modified) (1 diff)
-
include/ohana.h (modified) (5 diffs)
-
include/ohana_allocate.h (modified) (1 diff)
-
src/findexec.c (modified) (1 diff)
-
src/memstr.c (copied) (copied from branches/eam_branches/ipp-20111122/Ohana/src/libohana/src/memstr.c )
-
src/rconnect.c (copied) (copied from branches/eam_branches/ipp-20111122/Ohana/src/libohana/src/rconnect.c )
-
src/string.c (modified) (2 diffs)
-
test/memspeed.c (copied) (copied from branches/eam_branches/ipp-20111122/Ohana/src/libohana/test/memspeed.c )
Legend:
- Unmodified
- Added
- Removed
-
trunk/Ohana/src/libohana/Makefile
r31663 r33646 38 38 $(SRC)/Fread.$(ARCH).o \ 39 39 $(SRC)/IOBufferOps.$(ARCH).o \ 40 $(SRC)/memstr.$(ARCH).o \ 41 $(SRC)/rconnect.$(ARCH).o \ 40 42 $(SRC)/CommOps.$(ARCH).o \ 41 43 $(SRC)/isolate_elements.$(ARCH).o \ -
trunk/Ohana/src/libohana/include/ohana.h
r32632 r33646 215 215 */ 216 216 # define OHANA_WHITESPACE(c)(((c) == 0x09) || ((c) == 0x0a) || ((c) == 0x0b) || ((c) == 0x0b) || ((c) == 0x0c) || ((c) == 0x0d) || ((c) == 0x20)) 217 # define OHANA_ASSERT(LOGIC,...) { if (!(LOGIC)) { fprintf (stderr, __VA_ARGS__); abort(); } } 218 # define myAssert(LOGIC,...) { if (!(LOGIC)) { fprintf (stderr, __VA_ARGS__); abort(); } } 219 # define myAbort(MSG) { fprintf (stderr, "%s\n", MSG); abort(); } 217 220 218 221 // sorting is now defined as a macro call … … 236 239 char *strncreate PROTO((char *string, int n)); 237 240 int scan_line PROTO((FILE *f, char *line)); 241 int scan_line_maxlen PROTO((FILE *f, char *line, int maxlen)); 238 242 int dparse PROTO((double *X, int NX, char *line)); 239 243 int dparse_csv PROTO((double *X, int NX, char *line)); 244 int iparse PROTO((int *X, int NX, char *line)); 245 int iparse_csv PROTO((int *X, int NX, char *line)); 246 int tparse PROTO((time_t *X, int NX, char *line)); 247 int tparse_csv PROTO((time_t *X, int NX, char *line)); 240 248 int fparse PROTO((float *X, int NX, char *line)); 241 249 int get_argument PROTO((int argc, char **argv, char *arg)); … … 256 264 int check_dir_access PROTO((char *path, int verbose)); 257 265 int check_file_exec PROTO((char *filename)); 266 char *abspath PROTO((char *oldpath, int maxlength)); 258 267 259 268 /* in glockfile.c */ … … 323 332 off_t Fwrite PROTO((void *ptr, off_t size, off_t nitems, FILE *f, char *type)); 324 333 334 char *memstr PROTO((char *m1, char *m2, int n)); 335 int write_fmt PROTO((int fd, char *format, ...)); 336 325 337 char **isolate_elements PROTO((int argc, char **argv, int *nstack)); 326 338 … … 332 344 // gprint gets a stub implementation in libohana. opihi implements the real one. 333 345 int gprint (gpDest dest, char *format, ...); 346 347 // rconnect is used to run remote programs with a pipe for communication 348 typedef enum { 349 RCONNECT_ERR_NONE = 0, 350 RCONNECT_ERR_EXEC = 1, 351 RCONNECT_ERR_PIPE = 2, 352 RCONNECT_ERR_CONNECT = 3, 353 } RconnectErrors; 354 355 void rconnect_set_timeout (int timeout); 356 int rconnect (char *command, char *hostname, char *shell, int *stdio, int *errorInfo, int doHandshake); 334 357 335 358 /* -
trunk/Ohana/src/libohana/include/ohana_allocate.h
r31663 r33646 12 12 OhanaMemstats ohana_memstats (int mode); 13 13 14 /* EAM 2012.01.18 : comparative tests on my desktop 'pikake' (Intel Core 2 Quad) show a 15 * modest speed loss when using the Ohana memory managment stuff. the tests runs a ~1.2M 16 * allocations followed by the same number of frees. with the Ohana memory code, these 17 * ran at ~0.69 sec per block; without the time was ~0.56 sec per block 18 */ 19 14 20 /* default is to use basic system memory functions */ 21 15 22 # ifdef OHANA_MEMORY 16 23 -
trunk/Ohana/src/libohana/src/findexec.c
r27435 r33646 404 404 return TRUE; 405 405 } 406 407 // ohana-based equivalent to 'realpath'. realpath does not guarantee an absolute path (eg on Solaris), 408 // just a 'cannonical path'. I don't care about resolving out links, just ensuring an absolute path 409 // also, realpath is a bit ambiguous on the maxlength argument 410 char *abspath (char *oldpath, int maxlength) { 411 412 if (!oldpath) return NULL; 413 414 if (oldpath[0] == '/') { 415 char *newpath = strcreate (oldpath); 416 return newpath; 417 } 418 419 char *cwd = getcwd(NULL, maxlength); 420 if (cwd == NULL) { 421 // XXX need an error reporting function... 422 fprintf (stderr, "error getting cwd (longer than %d chars?)\n", maxlength); 423 return NULL; 424 } 425 426 char *newpath = NULL; 427 428 int Nbytes = strlen(cwd) + strlen(oldpath) + 2; 429 ALLOCATE (newpath, char, Nbytes); 430 snprintf (newpath, Nbytes, "%s/%s", cwd, oldpath); 431 return newpath; 432 } -
trunk/Ohana/src/libohana/src/string.c
r31663 r33646 143 143 } 144 144 145 int scan_line_maxlen (FILE *f, char *line, int maxlen) { 146 147 int i, status; 148 char c; 149 150 status = EOF + 1; 151 152 for (i = 0, c = 0; (c != '\n') && (status != EOF) && (i < maxlen); i++) { 153 status = fscanf (f, "%c", &c); 154 line[i] = c; 155 } 156 line[i - 1] = 0; /* this could make things crash! */ 157 158 if (i > 1) { 159 status = EOF + 1; 160 } 161 162 return (status); 163 } 164 145 165 char *_parse_nextword (char *string) { 146 166 … … 203 223 if (word[0] == '-') return (-1); 204 224 return (1); 225 } 226 227 int iparse (int *X, int NX, char *line) { 228 229 int i; 230 char *word; 231 char *ptr; 232 233 word = line; 234 for (i = 0; i < NX - 1; i++) 235 word = _parse_nextword (word); 236 237 *X = strtol (word, &ptr, 0); 238 if (ptr == word) return (FALSE); 239 if (word[0] == '-') return (-1); 240 return (1); 241 } 242 243 int iparse_csv (int *X, int NX, char *line) { 244 245 int i; 246 char *word; 247 char *ptr; 248 249 word = line; 250 for (i = 0; i < NX - 1; i++) 251 word = _parse_nextword_csv (word); 252 253 if (word[0] == '"') word[0] = ' '; 254 if (word[0] == ',') { 255 *X = 0; 256 return 1; 257 } 258 259 *X = strtol (word, &ptr, 0); 260 if (ptr == word) return (FALSE); 261 if (word[0] == '-') return (-1); 262 return (1); 263 } 264 265 int tparse (time_t *X, int NX, char *line) { 266 267 int i, status; 268 char *word; 269 270 word = line; 271 for (i = 0; i < NX - 1; i++) 272 word = _parse_nextword (word); 273 274 status = ohana_str_to_time (word, X); 275 if (!status) return (FALSE); 276 return (TRUE); 277 } 278 279 int tparse_csv (time_t *X, int NX, char *line) { 280 281 int i, status; 282 char *word; 283 284 word = line; 285 for (i = 0; i < NX - 1; i++) 286 word = _parse_nextword_csv (word); 287 288 if (word[0] == '"') word[0] = ' '; 289 if (word[0] == ',') { 290 *X = 0; 291 return 1; 292 } 293 294 status = ohana_str_to_time (word, X); 295 if (!status) return (FALSE); 296 return (TRUE); 205 297 } 206 298
Note:
See TracChangeset
for help on using the changeset viewer.
