TPCCLIB
Toggle main menu visibility
Loading...
Searching...
No Matches
analyze
ana_lhdr.c
Go to the documentation of this file.
1
7
/*****************************************************************************/
8
#include "tpcclibConfig.h"
9
/*****************************************************************************/
10
#include <stdio.h>
11
#include <stdlib.h>
12
#include <math.h>
13
#include <string.h>
14
#include <time.h>
15
/*****************************************************************************/
16
#include "
libtpcmisc.h
"
17
#include "
libtpcimgio.h
"
18
/*****************************************************************************/
19
20
/*****************************************************************************/
21
static
char
*info[] = {
22
"List the information in Analyze 7.5 image header."
,
23
" "
,
24
"Usage: @P headerfile"
,
25
" "
,
26
"Options:"
,
27
" -stdoptions"
,
// List standard options like --help, -v, etc
28
" "
,
29
"Example:"
,
30
" @P a8765.hdr"
,
31
" "
,
32
"See also: ana2ecat, ecat2ana, ana_ehdr, anabyteo, nii_lhdr"
,
33
" "
,
34
"Keywords: image, Analyze, header, IFT"
,
35
0};
36
/*****************************************************************************/
37
38
/*****************************************************************************/
39
/* Turn on the globbing of the command line, since it is disabled by default in
40
mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
41
In Unix&Linux wildcard command line processing is enabled by default. */
42
/*
43
#undef _CRT_glob
44
#define _CRT_glob -1
45
*/
46
int
_dowildcard = -1;
47
/*****************************************************************************/
48
49
/*****************************************************************************/
53
int
main(
int
argc,
char
**argv)
54
{
55
int
ai, help=0, version=0, verbose=1;
56
int
ret;
57
char
hdrfile[FILENAME_MAX], *cptr;
58
ANALYZE_DSR
dsr;
59
60
61
/*
62
* Get arguments
63
*/
64
if
(argc==1) {
tpcPrintUsage
(argv[0], info, stderr);
return
(1);}
65
hdrfile[0]=(char)0;
66
/* Options */
67
for
(ai=1; ai<argc; ai++)
if
(*argv[ai]==
'-'
) {
/* options */
68
cptr=argv[ai]+1;
if
(*cptr==
'-'
) cptr++;
if
(cptr==NULL)
continue
;
69
if
(
tpcProcessStdOptions
(argv[ai], &help, &version, &verbose)==0)
continue
;
70
fprintf(stderr,
"Error: invalid option '%s'\n"
, argv[ai]);
71
return
(1);
72
}
else
break
;
73
74
/* Print help or version? */
75
if
(help==2) {
tpcHtmlUsage
(argv[0], info,
""
);
return
(0);}
76
if
(help) {
tpcPrintUsage
(argv[0], info, stdout);
return
(0);}
77
if
(version) {
tpcPrintBuild
(argv[0], stdout);
return
(0);}
78
79
/* Process other arguments, starting from the first non-option */
80
for
(; ai<argc; ai++) {
81
if
(!hdrfile[0]) {strcpy(hdrfile, argv[ai]);
continue
;}
82
fprintf(stderr,
"Error: invalid argument '%s'\n"
, argv[ai]);
83
return
(1);
84
}
85
86
/* Is something missing? */
87
if
(!hdrfile[0]) {
88
fprintf(stderr,
"Error: Analyze header was not given.\n"
);
89
return
(1);
90
}
91
92
/* In verbose mode print arguments and options */
93
if
(verbose>1) {
94
printf(
"hdrfile := %s\n"
, hdrfile);
95
}
96
if
(verbose>2)
ANALYZE_TEST
=verbose-2;
else
ANALYZE_TEST
=0;
97
98
99
100
/*
101
* Read Analyze header file
102
*/
103
/* Check that filename contains .hdr extension */
104
cptr=strrchr(hdrfile,
'.'
);
105
if
(cptr==NULL || strcasecmp(cptr,
".hdr"
)!=0) strcat(hdrfile,
".hdr"
);
106
/* Read header file */
107
if
(verbose>1) printf(
"reading %s\n"
, hdrfile);
108
ret=
anaReadHeader
(hdrfile, &dsr);
109
if
(ret) {
110
fprintf(stderr,
"Error: cannot read %s.\n"
, hdrfile);
111
if
(verbose>1) fprintf(stderr,
" ret := %d\n"
, ret);
112
return
(2);
113
}
114
115
/*
116
* Print Analyze header
117
*/
118
anaPrintHeader
(&dsr, stdout);
119
120
return
(0);
121
}
122
/*****************************************************************************/
123
124
/*****************************************************************************/
anaPrintHeader
int anaPrintHeader(ANALYZE_DSR *h, FILE *fp)
Definition
analyze.c:380
ANALYZE_TEST
int ANALYZE_TEST
Definition
analyze.c:8
anaReadHeader
int anaReadHeader(char *filename, ANALYZE_DSR *h)
Definition
analyze.c:131
libtpcimgio.h
Header file for libtpcimgio.
libtpcmisc.h
Header file for libtpcmisc.
tpcProcessStdOptions
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition
proginfo.c:40
tpcHtmlUsage
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition
proginfo.c:213
tpcPrintBuild
void tpcPrintBuild(const char *program, FILE *fp)
Definition
proginfo.c:383
tpcPrintUsage
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition
proginfo.c:158
ANALYZE_DSR
Definition
libtpcimgio.h:193
Generated on
for TPCCLIB by
1.17.0