|
|
1.1 ! root 1: /* ! 2: * UAE - The Un*x Amiga Emulator ! 3: * ! 4: * Various stuff missing in some OSes. ! 5: * ! 6: * Copyright 1997 Bernd Schmidt ! 7: */ ! 8: ! 9: #include "sysconfig.h" ! 10: #include "sysdeps.h" ! 11: ! 12: #include "config.h" ! 13: #include "options.h" ! 14: #include "uae.h" ! 15: ! 16: #ifndef HAVE_STRDUP ! 17: ! 18: char *my_strdup (const char *s) ! 19: { ! 20: /* The casts to char * are there to shut up the compiler on HPUX */ ! 21: char *x = (char*)xmalloc(strlen((char *)s) + 1); ! 22: strcpy(x, (char *)s); ! 23: return x; ! 24: } ! 25: ! 26: #endif ! 27: ! 28: #ifndef HAVE_GETOPT ! 29: ! 30: /* This isn't a complete getopt, but it's good enough for UAE. */ ! 31: char *optarg; ! 32: int optind = 0; ! 33: ! 34: int getopt (int argc, char *const *argv, const char *str) ! 35: { ! 36: char *p, c; ! 37: ! 38: if (optind == 0) ! 39: optind = 1; ! 40: for (;;) { ! 41: while (optind < argc && (argv[optind][0] != '-' || argv[optind][1] == '\0')) ! 42: optind++; ! 43: if (optind >= argc) ! 44: return EOF; ! 45: p = strchr (str, c = argv[optind][1]); ! 46: if (p == 0) { ! 47: sprintf (warning_buffer, "Commandline parsing error - invalid option \"-%c\".\n", argv[optind][1]); ! 48: write_log (warning_buffer); ! 49: optind++; ! 50: continue; ! 51: } ! 52: break; ! 53: } ! 54: if (*(p+1) == ':') { ! 55: if (argv[optind][2] == '\0') { ! 56: optarg = argv[optind + 1]; ! 57: optind++; ! 58: } else { ! 59: optarg = argv[optind] + 2; ! 60: } ! 61: } ! 62: optind++; ! 63: return c; ! 64: } ! 65: ! 66: #endif ! 67: ! 68: void *xmalloc(size_t n) ! 69: { ! 70: void *a = malloc (n); ! 71: if (a == NULL) { ! 72: write_log ("virtual memory exhausted\n"); ! 73: abort(); ! 74: } ! 75: return a; ! 76: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.