Release.
[safe/jmp/vzgot] / lib / subapl.h
1 /************************************************/
2 /*                                              */
3 /*      Copyright:                              */
4 /*       Jean-Marc Pigeon <jmp@safe.ca>  2009   */
5 /*                                              */
6 /************************************************/
7 /* This program is free software; you can       */
8 /* redistribute it and/or modify it under the   */
9 /* terms of the GNU General Public License as   */
10 /* published by the Free Software Foundation    */
11 /* version 2 of the License                     */
12 /*                                              */
13 /* This program is distributed in the hope that */
14 /* it will be useful, but WITHOUT ANY WARRANTY; */
15 /* without even the implied warranty of         */
16 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR  */
17 /* PURPOSE.  See the GNU General Public License */
18 /* for more details.                            */
19 /*                                              */
20 /* You should have received a copy of the GNU   */
21 /* General Public License along with this       */
22 /* program; if not, write to the Free Software  */
23 /* Foundation, Inc., 51 Franklin Street,        */
24 /* Fifth Floor, Boston, MA  02110-1301, USA.    */
25 /************************************************/
26 /*                                              */
27 /*      Define sub level procedure needed by    */
28 /*      the application.                        */
29 /*                                              */
30 /************************************************/
31 #ifndef SUBAPL
32 #define SUBAPL
33 #include        <unistd.h>
34 #include        <stdio.h>
35 #include        <sys/types.h>
36 #include        "lowtyp.h"
37
38
39 /*vzboot application name               */
40 #define VZGOT   "vzgot"
41 /*vzboot current application revision level     */
42 #define VZBVERS "$Revision: 0.84.0.0 $"
43
44
45 /*transit subdirectory name                     */
46 #define TSUFFIX "-S"
47
48 /*defining application directory                */
49 typedef enum    {
50         d_tmp,          /*directory /tmp        */
51         d_crash,        /*the crash directory   */
52         d_etc,          /*directory is /etc     */
53         d_ubin,         /*directory /usr/bin    */
54         d_usbin,        /*directory /usr/sbin   */
55         d_usrlib,       /*directory /usr/lib    */
56         d_varlib,       /*directory /var/lib    */
57         d_spool,        /*spool directory       */
58         d_log,          /*logs directory        */
59         d_lock,         /*locking directory     */
60         d_vzgot,        /*application main dir  */
61         d_null          /*no directoy specified */
62         }DIRENUM;
63
64 typedef struct  {       /*vocable table type    */
65         int code;       /*code value            */
66         const char *key;/*key code              */
67         const void *ptr;/*pay load              */
68         }VOCTYP;
69
70 /*Signal flag definition                        */
71 extern  int sigterm;
72 extern  int sigquit;
73 extern  int sigint;
74
75 /*application current version number            */
76 extern const char *curvers;
77 /*application working base directory            */
78 extern char *base;
79 /*application name                              */
80 extern char *appname;
81 /*application debug level                       */
82 extern int debug;
83 /*application verbosity level                   */
84 extern int verbose;
85 /*application working mode foreground/background*/
86 extern int apl_foreground;
87
88 extern int apl_isdir(char *dirpath);
89 extern char *apl_freestr(char *str);
90 extern char *apl_getvers();
91 extern u_long apl_getmillisec();
92 extern char *apl_uniquename(unsigned int seq);
93 extern u_long apl_date(time_t curtime);
94 extern char *apl_ascsystime(time_t curtime);
95 extern char *apl_ascsysdate(time_t curtime);
96 extern char *apl_ascsysdatetime(time_t curtime);
97 extern char *apl_ascsysstamp(time_t curtime);
98 extern time_t apl_datetimesysasc(char *strdate,char *strtime);
99 extern void apl_alert(const int dlevel,const char *fmt,...);
100 extern void apl_argvtrace(const int dlevel,const char *fmt,char *argv[]);
101 extern char *apl_mkbase(char *newbase);
102 extern char *apl_appdir(DIRENUM dir);
103 extern void apl_trapsegv(int onoff);
104 extern void apl_core_dump(char *frmt, ...);
105 extern void apl_settrap(int set);
106 extern char *apl_strtolower(char *str);
107 extern char *apl_getstr(FILE *fichier,char *str,u_int taille,char carcom);
108 extern int apl_createdirs(char *dirname);
109 extern char *apl_getapvers();
110 extern VOCTYP *apl_getvoca(const VOCTYP *table,char *str);
111 extern char *apl_cleanstring(char *str);
112 #endif