#include #include #include #include "common.h" #include "chain.h" #include "utility.h" #include "options.h" struct options opt; static int soi_s2n(char *ptr, unsigned int *seg, unsigned int *off, unsigned int *ip, unsigned int def) { unsigned int segval = 0, offval, ipval, val; char *p; offval = def; ipval = def; segval = strtoul(ptr, &p, 0); if (p[0] == ':' && p[1] && p[1] != ':') offval = strtoul(p+1, &p, 0); if (p[0] == ':' && p[1] && p[1] != ':') ipval = strtoul(p+1, NULL, 0); val = (segval << 4) + offval; if (val < ADDRMIN || val > ADDRMAX) { error("Invalid seg:off:* address specified..\n"); goto bail; } val = (segval << 4) + ipval; if (ipval > 0xFFFE || val < ADDRMIN || val > ADDRMAX) { error("Invalid seg:*:ip address specified.\n"); goto bail; } if (seg) *seg = segval; if (off) *off = offval; if (ip) *ip = ipval; return 0; bail: return -1; } static void usage(void) { unsigned int i; static const char key[] = "Press any key...\n"; static const char *const usage[] = { "\ Usage:\n\ chain.c32 [options]\n\ chain.c32 {fd|hd}{,| }[] [options]\n\ chain.c32 mbr{:|=}{,| }[] [options]\n\ chain.c32 guid{:|=}{,| }[] [options]\n\ chain.c32 label{:|=}