GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: src/bin/tend.c Lines: 0 40 0.0 %
Date: 2017-05-26 Branches: 0 14 0.0 %

Line Branch Exec Source
1
/*
2
  Teem: Tools to process and visualize scientific data and images             .
3
  Copyright (C) 2013, 2012, 2011, 2010, 2009  University of Chicago
4
  Copyright (C) 2008, 2007, 2006, 2005  Gordon Kindlmann
5
  Copyright (C) 2004, 2003, 2002, 2001, 2000, 1999, 1998  University of Utah
6
7
  This library is free software; you can redistribute it and/or
8
  modify it under the terms of the GNU Lesser General Public License
9
  (LGPL) as published by the Free Software Foundation; either
10
  version 2.1 of the License, or (at your option) any later version.
11
  The terms of redistributing and/or modifying this software also
12
  include exceptions to the LGPL that facilitate static linking.
13
14
  This library is distributed in the hope that it will be useful,
15
  but WITHOUT ANY WARRANTY; without even the implied warranty of
16
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17
  Lesser General Public License for more details.
18
19
  You should have received a copy of the GNU Lesser General Public License
20
  along with this library; if not, write to Free Software Foundation, Inc.,
21
  51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
22
*/
23
24
#include <teem/ten.h>
25
26
#define TEND "tend"
27
28
int
29
main(int argc, const char **argv) {
30
  int i, ret;
31
  const char *me;
32
  char *argv0 = NULL;
33
  hestParm *hparm;
34
  airArray *mop;
35
36
  me = argv[0];
37
38
  /* parse environment variables first, in case they break nrrdDefault*
39
     or nrrdState* variables in a way that nrrdSanity() should see */
40
  nrrdDefaultGetenv();
41
  nrrdStateGetenv();
42
43
  /* no harm done in making sure we're sane */
44
  nrrdSanityOrDie(me);
45
46
  mop = airMopNew();
47
  hparm = hestParmNew();
48
  airMopAdd(mop, hparm, (airMopper)hestParmFree, airMopAlways);
49
  hparm->elideSingleEnumType = AIR_TRUE;
50
  hparm->elideSingleOtherType = AIR_TRUE;
51
  hparm->elideSingleOtherDefault = AIR_FALSE;
52
  hparm->elideSingleNonExistFloatDefault = AIR_TRUE;
53
  hparm->elideMultipleNonExistFloatDefault = AIR_TRUE;
54
  hparm->elideSingleEmptyStringDefault = AIR_TRUE;
55
  hparm->elideMultipleEmptyStringDefault = AIR_TRUE;
56
  hparm->cleverPluralizeOtherY = AIR_TRUE;
57
  hparm->columns = 78;
58
59
  /* if there are no arguments, then we give general usage information */
60
  if (1 >= argc) {
61
    unrrduUsage(TEND, hparm, tendTitle, tendCmdList);
62
    airMopError(mop);
63
    exit(1);
64
  }
65
  /* else, we see if its --version */
66
  if (!strcmp("--version", argv[1])) {
67
    char vbuff[AIR_STRLEN_LARGE];
68
    airTeemVersionSprint(vbuff);
69
    printf("%s\n", vbuff);
70
    exit(0);
71
  }
72
  /* else, we should see if they're asking for a command we know about */
73
  for (i=0; tendCmdList[i]; i++) {
74
    if (!strcmp(argv[1], tendCmdList[i]->name))
75
      break;
76
    if (!strcmp("--help", argv[1])
77
        && !strcmp("about", tendCmdList[i]->name)) {
78
      break;
79
    }
80
  }
81
  if (tendCmdList[i]) {
82
    /* yes, we have that command */
83
    /* initialize variables used by the various commands */
84
    argv0 = (char *)calloc(strlen(TEND) + strlen(argv[1]) + 2, sizeof(char));
85
    airMopMem(mop, &argv0, airMopAlways);
86
    sprintf(argv0, "%s %s", TEND, argv[1]);
87
88
    /* run the individual tend program, saving its exit status */
89
    ret = tendCmdList[i]->main(argc-2, argv+2, argv0, hparm);
90
  } else {
91
    fprintf(stderr, "%s: unrecognized command: \"%s\"; type \"%s\" for "
92
            "complete list\n", me, argv[1], me);
93
    ret = 1;
94
  }
95
96
  airMopDone(mop, ret);
97
  return ret;
98
}