summaryrefslogtreecommitdiff
path: root/support/dktools/test-opt.c
blob: 339fec47828e2b42c527d687442e98f92e5c4170 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
	WARNING: This file was generated by dkct.
	Changes you make here will be lost if dkct is run again!
	You should modify the original source and run dkct on it.
	Original source: test-opt.ctr
*/

/**	@file test-opt.c The test-opt module.
*/


#line 1 "test-opt.ctr"

#include "dk4conf.h"
#include "dk4types.h"
#include "dk4mem.h"
#include "dk4opt.h"





#line 10 "test-opt.ctr"



/**	Command line options for program.
*/
static	dk4_option_t	options[] = {
  { { dkT('i'),	dkT("interactive"),	DK4_OPT_ARG_NONE },	{ NULL }, 0},
  { { dkT('s'),	dkT("socket"),		DK4_OPT_ARG_STRING },	{ NULL }, 0},
  { { dkT('h'),	dkT("host"),		DK4_OPT_ARG_STRING },	{ NULL }, 0},
  { { dkT('p'),	dkT("port"),		DK4_OPT_ARG_UNSIGNED },	{ NULL }, 0}
};



static const size_t szoptions = sizeof(options)/sizeof(dk4_option_t);


/**	Main function.
	@param	argc	Number of command line arguments.
	@param	argv	Command line arguments array.
	@return	0 on success, all other values indicate errors.
*/
#if DK4_CHAR_SIZE > 1
int
wmain(int argc, wchar_t *argv[])
#else
int
main(int argc, char *argv[])
#endif
{
  dkChar	*filenames[32];
  size_t	 szfn	= DK4_SIZEOF(filenames,DK4_PDKCHAR);
  int	res;

  

#line 45 "test-opt.ctr"
  

#line 46 "test-opt.ctr"
  res = dk4opt_process_argv(
    options, szoptions, argc, argv,
    filenames, &szfn, 1, 1, NULL
  );
  if (0 != res) {
    if (0 != options[0].found) {
      fputs("Option -i found.\n", stdout);
    }
    if (0 != options[1].found) {
      fputs("Option -s found.\nArgument: ", stdout);
      if (NULL != options[1].val.t) {
        fputs(options[1].val.t, stdout);
      }
      fputc('\n', stdout);
      fflush(stdout);
    }
    if (0 != options[2].found) {
      fputs("Option -h found.\n", stdout);
      if (NULL != options[2].val.t) {
        fputs(options[2].val.t, stdout);
      }
      fputc('\n', stdout);
      fflush(stdout);
    }
    if (0 != options[3].found) {
      fputs("Option -p found.\n", stdout);
      fprintf(stdout, "Argument: %ju\n", options[3].val.u);
      fflush(stdout);
    }
  }
  

#line 77 "test-opt.ctr"
  

#line 78 "test-opt.ctr"
  exit(0); return 0;
}