/* parse arguments of out command */ static int runout(int argc, char **argv) { char *path = NULL; char *key = NULL; TCCMP cmp = NULL; int omode = 0; bool sx = false; for (int i = 2; i < argc; i++) { if (!path && argv[i][0] == '-') { if (!strcmp(argv[i], "-cd")) { cmp = tccmpdecimal; } else if (!strcmp(argv[i], "-ci")) { cmp = tccmpint32; } else if (!strcmp(argv[i], "-cj")) { cmp = tccmpint64; } else if (!strcmp(argv[i], "-nl")) { omode |= BDBONOLCK; } else if (!strcmp(argv[i], "-nb")) { omode |= BDBOLCKNB; } else if (!strcmp(argv[i], "-sx")) { sx = true; } else { usage(); } } else if (!path) { path = argv[i]; } else if (!key) { key = argv[i]; } else { usage(); } } if (!path || !key) usage(); int ksiz; char *kbuf; if (sx) { kbuf = tchexdecode(key, &ksiz); } else { ksiz = strlen(key); kbuf = tcmemdup(key, ksiz); } int rv = procout(path, kbuf, ksiz, cmp, omode); tcfree(kbuf); return rv; }
/* parse arguments of out command */ static int runout(int argc, char **argv){ char *name = NULL; char *key = NULL; bool sx = false; int sep = -1; for(int i = 2; i < argc; i++){ if(!name && argv[i][0] == '-'){ if(!strcmp(argv[i], "-sx")){ sx = true; } else if(!strcmp(argv[i], "-sep")){ if(++i >= argc) usage(); sep = sepstrtochr(argv[i]); } else { usage(); } } else if(!name){ name = argv[i]; } else if(!key){ key = argv[i]; } else { usage(); } } if(!name || !key) usage(); int ksiz; char *kbuf; if(sx){ kbuf = tchexdecode(key, &ksiz); } else if(sep > 0){ kbuf = strtozsv(key, sep, &ksiz); } else { ksiz = strlen(key); kbuf = tcmemdup(key, ksiz); } int rv = procout(name, kbuf, ksiz); tcfree(kbuf); return rv; }
/* parse arguments of out command */ static int runout(int argc, char **argv){ char *path = NULL; char *key = NULL; int omode = 0; bool sx = false; for(int i = 2; i < argc; i++){ if(argv[i][0] == '-'){ if(!strcmp(argv[i], "-nl")){ omode |= HDBONOLCK; } else if(!strcmp(argv[i], "-nb")){ omode |= HDBOLCKNB; } else if(!strcmp(argv[i], "-sx")){ sx = true; } else { usage(); } } else if(!path){ path = argv[i]; } else if(!key){ key = argv[i]; } else { usage(); } } if(!path || !key) usage(); int ksiz; char *kbuf; if(sx){ kbuf = hextoobj(key, &ksiz); } else { ksiz = strlen(key); kbuf = tcmemdup(key, ksiz); } int rv = procout(path, kbuf, ksiz, omode); free(kbuf); return rv; }
/* parse arguments of out command */ static int runout(int argc, char **argv){ char *path = NULL; char *pkey = NULL; int omode = 0; bool sx = false; for(int i = 2; i < argc; i++){ if(!path && argv[i][0] == '-'){ if(!strcmp(argv[i], "-nl")){ omode |= TDBONOLCK; } else if(!strcmp(argv[i], "-nb")){ omode |= TDBOLCKNB; } else if(!strcmp(argv[i], "-sx")){ sx = true; } else { usage(); } } else if(!path){ path = argv[i]; } else if(!pkey){ pkey = argv[i]; } else { usage(); } } if(!path || !pkey) usage(); int pksiz; char *pkbuf; if(sx){ pkbuf = tchexdecode(pkey, &pksiz); } else { pksiz = strlen(pkey); pkbuf = tcmemdup(pkey, pksiz); } int rv = procout(path, pkbuf, pksiz, omode); tcfree(pkbuf); return rv; }