TPCCLIB
Loading...
Searching...
No Matches
bigend.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/*****************************************************************************/
15#include "libtpcmisc.h"
16/*****************************************************************************/
17
18/*****************************************************************************/
19static char *info[] = {
20 "Reports the byte order of the current platform.",
21 "Big endian computers include Sun Sparc, Motorola, and PowerPC,",
22 "while PC/Intel computers are little endian.",
23 "Programs return code is either 1 (big endian) or 0 (little endian),",
24 "and, by default, either one of the following is printed on screen:",
25 " byte_order := big",
26 " byte_order := little",
27 " ",
28 "Usage: @P [Options]",
29 " ",
30 "Options:",
31 " -stdoptions", // List standard options like --help, -v, etc
32 " ",
33 "See also: convend, img2flat, flat2img, anabyteo",
34 " ",
35 "Keywords: image, byte order, big endian, little endian",
36 0};
37/*****************************************************************************/
38
39/*****************************************************************************/
40/* Turn on the globbing of the command line, since it is disabled by default in
41 mingw-w64 (_dowildcard=0); in MinGW32 define _CRT_glob instead, if necessary;
42 In Unix&Linux wildcard command line processing is enabled by default. */
43/*
44#undef _CRT_glob
45#define _CRT_glob -1
46*/
47int _dowildcard = -1;
48/*****************************************************************************/
49
50/*****************************************************************************/
54int main(int argc, char **argv)
55{
56 int ai, help=0, version=0, verbose=1;
57 char *cptr;
58
59
60 /*
61 * Get arguments
62 */
63 //if(argc==1) {tpcPrintUsage(argv[0], info, stderr); return(1);}
64 /* Options */
65 for(ai=1; ai<argc; ai++) if(*argv[ai]=='-') { /* options */
66 cptr=argv[ai]+1; if(*cptr=='-') cptr++; if(cptr==NULL) continue;
67 if(tpcProcessStdOptions(argv[ai], &help, &version, &verbose)==0) continue;
68 fprintf(stderr, "Error: invalid option '%s'\n", argv[ai]);
69 return(1);
70 } else break;
71
72 /* Print help or version? */
73 if(help==2) {tpcHtmlUsage(argv[0], info, ""); return(0);}
74 if(help) {tpcPrintUsage(argv[0], info, stdout); return(0);}
75 if(version) {tpcPrintBuild(argv[0], stdout); return(0);}
76
77 /* Process other arguments, starting from the first non-option */
78 if(ai<argc) {
79 fprintf(stderr, "Error: invalid argument '%s'\n", argv[ai]);
80 return(1);
81 }
82
83 if(little_endian()) {
84 if(verbose>0) printf("byte_order := little\n");
85 return(0);
86 }
87 if(verbose>0) printf("byte_order := big\n");
88 return(1);
89}
90/*****************************************************************************/
91
92/*****************************************************************************/
Header file for libtpcmisc.
int tpcProcessStdOptions(const char *s, int *print_usage, int *print_version, int *verbose_level)
Definition proginfo.c:40
int little_endian()
Definition swap.c:14
int tpcHtmlUsage(const char *program, char *text[], const char *path)
Definition proginfo.c:213
void tpcPrintBuild(const char *program, FILE *fp)
Definition proginfo.c:383
void tpcPrintUsage(const char *program, char *text[], FILE *fp)
Definition proginfo.c:158