summaryrefslogtreecommitdiffstats
path: root/src/common.h
blob: b9ee5f3b39a056e6119b315220f016cd724f6092 (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
/*
 * $Id: common.h,v 1.5 2005/11/21 22:05:34 nangel Exp $
 */
#ifndef _COMMON_H
#define _COMMON_H	1


/* how many argv slots to allocate at once */
#define ALLOC_CHUNK	10


#define STDIN	0
#define STDOUT  1
#define STDERR	2


#define TRUE  -1
#define FALSE 0
#define NONE  1

/* linked list */
typedef struct
{
  char *buf;
  void *next;
} list_t;

/* name/value pairs */
typedef struct
{
  char *string;			/* the string */
  unsigned char quoted;		/* non-zero if the string was quoted */
} argv_t;

/* expandable buffer structure */
typedef struct
{
  unsigned char *data;		/* the data */
  unsigned char *ptr;		/* where to write to next */
  unsigned char *limit;		/* maximal allocated buffer pos */
} buffer_t;


/* common.c */

int argc_argv (char *instr, argv_t ** argv, char *commentstr);
void haserl_buffer_init (buffer_t * buf);
void buffer_reset (buffer_t * buf);
void buffer_destroy (buffer_t * buf);
void buffer_add (buffer_t * buf, const void *data, unsigned long size);

#ifndef JUST_LUACSHELL

void uppercase (char *instr);
void lowercase (char *instr);
char *skip_whitespace (char *instr);
char *find_whitespace (char *instr);
int count_lines (char *instr, size_t len, char *where);

#endif

#endif /* !_COMMON_H */