generated from BecoSystems/exn-adventuretxt
-
Notifications
You must be signed in to change notification settings - Fork 12
/
exN.c
287 lines (269 loc) · 11.1 KB
/
exN.c
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
/*****************************************************************************
* exN.c Version 20180714.101818 *
* *
* Brief description *
* Copyright (C) 2016-2018 by Ruben Carlo Benante *
*****************************************************************************
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License. *
* *
* This program is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with this program; if not, write to the *
* Free Software Foundation, Inc., *
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
*****************************************************************************
* To contact the author, please write to: *
* Ruben Carlo Benante *
* Email: [email protected] *
* Webpage: www.beco.cc *
* Phone: +55 (81) 3184-7555 *
*****************************************************************************/
/* ------------------------------------------------------------------------- */
/**
* @file exN.c
* @ingroup GroupUnique
* @brief Brief description
* @details This program really do a nice job as a template, and template only!
* @version 20160908.182830
* @date 2016-09-08
* @author Ruben Carlo Benante <<[email protected]>>
* @par Webpage
* <<a href="http://www.beco.cc">www.beco.cc</a>>
* @copyright (c) 2016 GNU GPL v2
* @note This program is free software: you can redistribute it
* and/or modify it under the terms of the
* GNU General Public License as published by
* the Free Software Foundation version 2 of the License.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program.
* If not, write to the Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA. 02111-1307, USA.
* Or read it online at <<http://www.gnu.org/licenses/>>.
*
*
* @todo Now that you have the template, hands on! Programme!
* @warning Be carefull not to lose your mind in small things.
* @bug This file right now does nothing usefull
*
*/
/*
* Instrucoes para compilar:
* $gcc exN.c -o exN.x -Wall
* -Wextra -ansi -pedantic-errors -g -O0 -DDEBUG=1 -DVERSION="0.1.160612.142044"
* ou preferencialmente inclua um makefile e use:
* $make
*
* Modelo de indentacao:
* Estilo: --style=allman ou -A1
*
* Opcoes: -A1 -s4 -k3 -xj -SCNeUpv
*
* * No vi use:
* :% !astyle -A1 -s4 -k3 -xj -SCNeUpv
* * No linux:
* $astlye -A1 -s4 -k3 -xj -SCNeUpv exN.c
*/
/* ------------------------------------------------------------------------- */
/* includes */
#include <stdio.h> /* Standard I/O functions */
#include <stdlib.h> /* Miscellaneous functions (rand, malloc, srand)*/
#include <getopt.h> /* get options from system argc/argv */
#include "exN.h" /* To be created for this template if needed */
/* #include <time.h> */ /* Time and date functions */
/* #include <math.h> */ /* Mathematics functions */
/* #include <string.h> */ /* Strings functions definitions */
/* #include <dlfcn.h> */ /* Dynamic library */
/* #include <malloc.h> */ /* Dynamic memory allocation */
/* #include <unistd.h> */ /* UNIX standard function */
/* #include <limits.h> */ /* Various C limits */
/* #include <ctype.h> */ /* Character functions */
/* #include <errno.h> */ /* Error number codes errno */
/* #include <signal.h> */ /* Signal processing */
/* #include <stdarg.h> */ /* Functions with variable arguments */
/* #include <pthread.h> */ /* Parallel programming with threads */
/* #include <fcntl.h> */ /* File control definitions */
/* #include <termios.h> */ /* Terminal I/O definitions POSIX */
/* #include <sys/stat.h> */ /* File status and information */
/* #include <float.h> */ /* Float constants to help portability */
/* #include <setjmp.h> */ /* Bypass standard function calls and return */
/* #include <stddef.h> */ /* Various types and MACROS */
/* #include <SWI-Prolog.h> */ /* Prolog integration with C */
/* #include <ncurses.h> */ /* Screen handling and optimisation functions */
/* #include <allegro.h> */ /* A game library for graphics, sounds, etc. */
/* #include <libintl.h> */ /* Internationalization / translation */
/* #include <locale.h> */ /* MACROS LC_ for location specific settings */
/* #include "libeco.h" */ /* I/O, Math, Sound, Color, Portable Linux/Windows */
/* ------------------------------------------------------------------------- */
/**
* @ingroup GroupUnique
* @brief This is the main event of the evening
* @details Ladies and Gentleman... It's tiiiime!
* Fightiiiiing at the blue corner,
* he, who has compiled more C code than any other adversary in the history,
* he, who has developed UNIX and Linux, and is an inspiration to maaany languages
* and compilers, the GNU C Compiler, GCC!
* Fightiiiiing at the red corner, the challenger, in his first fight, lacking of any
* valid experience but angrily, blindly, and no doubtfully, will try to
* compile this program without errors. He, the student, the apprentice,
* the developer, beco!!
*
* @param[in] argc Argument counter
* @param[in] argv Argument strings (argument values)
*
* @retval 0 If succeed (EXIT_SUCCESS).
* @retval 1 Or another error code if failed.
*
* @par Example
* @code
* $./exN -h
* @endcode
*
* @warning Be carefull with...
* @bug There is a bug with...
* @todo Need to do...
* @note You can read more about it at <<a href="http://www.beco.cc">www.beco.cc</a>>
* @author Ruben Carlo Benante
* @version 20160908.182830
* @date 2016-09-08
*
*/
int main(int argc, char *argv[])
{
int opt; /* return from getopt() */
IFDEBUG("Starting optarg loop...");
/* getopt() configured options:
* -h help
* -V version
* -v verbose
*/
opterr = 0;
while((opt = getopt(argc, argv, "vhV")) != EOF)
switch(opt)
{
case 'h':
help();
break;
case 'V':
copyr();
break;
case 'v':
verb++;
break;
case '?':
default:
printf("Type\n\t$man %s\nor\n\t$%s -h\nfor help.\n\n", argv[0], argv[0]);
return EXIT_FAILURE;
}
if(verb)
printf("Verbose level set at: %d\n", verb);
exN_init(); /* initialization function */
/* ...and we are done */
/* Write your code here... */
return EXIT_SUCCESS;
}
/* Write your functions here... */
/* ------------------------------------------------------------------------- */
/**
* @ingroup GroupUnique
* @brief Prints help information and exit
* @details Prints help information (usually called by opt -h)
* @return Void
* @author Ruben Carlo Benante
* @version 20160908.182830
* @date 2016-09-08
*
*/
void help(void)
{
IFDEBUG("help()");
printf("%s - %s\n", "exN", "Brief description");
printf("\nUsage: %s [-h|-v]\n", "exN");
printf("\nOptions:\n");
printf("\t-h, --help\n\t\tShow this help.\n");
printf("\t-V, --version\n\t\tShow version and copyright information.\n");
printf("\t-v, --verbose\n\t\tSet verbose level (cumulative).\n");
/* add more options here */
printf("\nExit status:\n\t0 if ok.\n\t1 some error occurred.\n");
printf("\nTodo:\n\tLong options not implemented yet.\n");
printf("\nAuthor:\n\tWritten by %s <%s>\n\n", "Ruben Carlo Benante", "[email protected]");
exit(EXIT_FAILURE);
}
/* ------------------------------------------------------------------------- */
/**
* @ingroup GroupUnique
* @brief Prints version and copyright information and exit
* @details Prints version and copyright information (usually called by opt -V)
* @return Void
* @author Ruben Carlo Benante
* @version 20160908.182830
* @date 2016-09-08
*
*/
void copyr(void)
{
IFDEBUG("copyr()");
printf("%s - Version %s\n", "exN", VERSION);
printf("\nCopyright (C) %d %s <%s>, GNU GPL version 2 <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. USE IT AS IT IS. The author takes no responsability to any damage this software may inflige in your data.\n\n", 2016, "Ruben Carlo Benante", "[email protected]");
if(verb > 3) printf("copyr(): Verbose: %d\n", verb); /* -vvvv */
exit(EXIT_FAILURE);
}
/* ------------------------------------------------------------------------- */
/**
* @ingroup GroupUnique
* @brief This function initializes some operations before start
* @details Details to be written in
* multiple lines
*
* @pre You need to call foo() before calling this function
*
* @param[in] i Input parameter that does bla
* @param[out] o Parameter that outputs ble
* @param[in,out] z The @a z variable is used as input and output
*
* @retval 0 Returned when bli
* @retval 1 Error code: function returned blo
*
* @par Example
* @code
* if(x == funcexample(i, o, z))
* printf("And that is it\n");
* @endcode
*
* @return Void
*
* @warning Be carefull with blu
* @todo Need to implement it. Its empty now. This doxygen tags are overwhelming.
* Mandatory tags are: ingroup, brief, details, param, return, author and date.
* The others are optional.
*
* @deprecated This function will be deactivated in version +11
* @see help()
* @see copyr()
* @bug There is a bug with x greater than y
* @note You can read more about it at <<a href="http://www.beco.cc">www.beco.cc</a>>
*
* @author Ruben Carlo Benante
* @version 20160908.182830
* @date 2016-09-08
* @copyright Use this tag only if not the same as the whole file
*
*/
void exN_init(void)
{
IFDEBUG("exN_init()");
/* initialization */
return;
}
/* ------------------------------------------------------------------------- */
/* vi: set ai et ts=4 sw=4 tw=0 wm=0 fo=croql : C config for Vim modeline */
/* Template by Dr. Beco <rcb at beco dot cc> Version 20180716.101436 */