| 313 |
dpurdie |
1 |
/* -*- mode: c; tabs: 4; -*- ************************************************
|
|
|
2 |
* Module name : cmdfile.h
|
|
|
3 |
* Module type : CMDFILE source file
|
|
|
4 |
* Environment(s): n/a
|
|
|
5 |
*
|
|
|
6 |
* Version Who Date Description
|
|
|
7 |
APY 12/99 Created
|
|
|
8 |
*
|
|
|
9 |
* $Source: /cvsroot/device/DEVL/UTILS/CMDFILE/cmdfile.h,v $
|
|
|
10 |
* $Revision: 1.9 $ $Date: 2004/11/05 07:51:39 $ $State: Exp $
|
|
|
11 |
* $Author: ayoung $ $Locker: $
|
|
|
12 |
*.........................................................................*/
|
|
|
13 |
|
|
|
14 |
#include <stdio.h>
|
|
|
15 |
#include <stdlib.h>
|
|
|
16 |
#include <string.h>
|
|
|
17 |
#include <unistd.h>
|
|
|
18 |
#include <limits.h> /* PATH_MAX */
|
|
|
19 |
#include <errno.h>
|
|
|
20 |
|
|
|
21 |
#if defined(linux)
|
|
|
22 |
#include <sys/io.h>
|
|
|
23 |
#elif defined(MSDOS) || defined(WIN32)
|
|
|
24 |
#include <io.h>
|
|
|
25 |
#endif
|
|
|
26 |
|
|
|
27 |
#ifndef TRUE
|
|
|
28 |
#define FALSE 0
|
|
|
29 |
#define TRUE 1 /*!FALSE*/
|
|
|
30 |
#endif
|
|
|
31 |
|
|
|
32 |
#define MACRO_MAX 4096
|
|
|
33 |
#define TMPNAME "cmdfile.XXX" /*see mktemp*/
|
|
|
34 |
|
|
|
35 |
#if !defined(PATH_MAX)
|
|
|
36 |
#if defined(linux)
|
|
|
37 |
#define PATH_MAX 1024
|
|
|
38 |
#else
|
|
|
39 |
#error Unknown target OS ...
|
|
|
40 |
#endif
|
|
|
41 |
#endif
|
|
|
42 |
|
|
|
43 |
#define WS_UNKNOWN 0 /*embedded space handling*/
|
|
|
44 |
#define WS_IGNORE 1
|
|
|
45 |
#define WS_ESCAPE 2
|
|
|
46 |
#define WS_QUOTE 3
|
|
|
47 |
#define WS_JUNK 4
|
|
|
48 |
#define WS_URL 5
|
|
|
49 |
|
|
|
50 |
typedef struct {
|
|
|
51 |
char * s_data;
|
|
|
52 |
char * s_ptr;
|
|
|
53 |
unsigned s_left;
|
|
|
54 |
unsigned s_len;
|
|
|
55 |
} String_t;
|
|
|
56 |
|
|
|
57 |
extern const char * version_string;
|
|
|
58 |
extern char * program_name;
|
|
|
59 |
extern FILE * output;
|
|
|
60 |
|
|
|
61 |
extern int cflg;
|
|
|
62 |
|
|
|
63 |
extern char mflg;
|
|
|
64 |
extern char dflg[2];
|
|
|
65 |
|
|
|
66 |
#define MACROCHAR mflg
|
|
|
67 |
#define LDELIMITOR dflg[0]
|
|
|
68 |
#define RDELIMITOR dflg[1]
|
|
|
69 |
|
|
|
70 |
extern int eflg;
|
|
|
71 |
extern int kflg;
|
|
|
72 |
extern int k2flg;
|
|
|
73 |
extern int Mflg;
|
|
|
74 |
extern int nflg;
|
|
|
75 |
extern int nlflg;
|
|
|
76 |
extern const char * oflg;
|
|
|
77 |
extern int rflg;
|
|
|
78 |
extern char rtags[10];
|
|
|
79 |
extern int tflg;
|
|
|
80 |
extern int vflg;
|
|
|
81 |
extern int wflg;
|
|
|
82 |
extern int whitespace;
|
|
|
83 |
|
|
|
84 |
extern void fatalerr(const char *msg, ...);
|
|
|
85 |
extern void warning(const char *msg, ...);
|
|
|
86 |
extern void verbose(const char *msg, ...);
|
|
|
87 |
extern void message(const char *msg, ...);
|
|
|
88 |
|
|
|
89 |
extern int mkstemp(char *path);
|
|
|
90 |
|
|
|
91 |
extern int StringInit(String_t *, char *, unsigned);
|
|
|
92 |
extern int StringZero(String_t *);
|
|
|
93 |
extern int StringCat(String_t *, const char *);
|
|
|
94 |
extern int StringPath(String_t *, const char *);
|
|
|
95 |
extern int StringCatn(String_t *, const char *, unsigned);
|
|
|
96 |
extern int StringPut(String_t *, char);
|
|
|
97 |
extern char * StringData(String_t *pStr);
|
|
|
98 |
|
|
|
99 |
extern int expected(const char *s, char c);
|
|
|
100 |
extern int token(const char *s, char *buffer, int len);
|
|
|
101 |
extern int argument(const char *s, char *buffer, int len);
|
|
|
102 |
extern int pathargument(const char *s, char *buffer, int len);
|
|
|
103 |
|
|
|
104 |
#define VFLAG_PATH 0x00
|
|
|
105 |
#define VFLAG_LIBRARY 0x01
|
|
|
106 |
#define VFLAG_GLOB 0x02
|
|
|
107 |
#define VFLAG_LINT 0x04
|
|
|
108 |
|
|
|
109 |
#define VFLAG_MUSTRESOLVE 0x10
|
|
|
110 |
#define VFLAG_OPTIONAL 0x20
|
|
|
111 |
|
|
|
112 |
extern int vpath(String_t *str, const char *s, int flags);
|
|
|
113 |
extern int do_vhost(const char *s);
|
|
|
114 |
extern int do_vsep(const char *s);
|
|
|
115 |
extern int macro(String_t *str, const char *s);
|
|
|
116 |
extern int dosify(String_t *str, const char *s);
|
|
|
117 |
extern int do_realpath(String_t *str, const char *s);
|
|
|
118 |
extern int do_shortpath(String_t *str, const char *s);
|
|
|
119 |
extern int do_url2path(String_t *str, const char *s);
|
|
|
120 |
extern int do_path2url(String_t *str, const char *s);
|
|
|
121 |
extern const char * Realpath(const char *name, char *buf);
|
|
|
122 |
extern int do_vlibgcc( String_t *str, const char *s );
|
|
|
123 |
extern int from_env(String_t *str, const char *s);
|
|
|
124 |
extern int do_clean_sep ( String_t *str, const char *s );
|
|
|
125 |
|