summaryrefslogtreecommitdiffstats
path: root/src/common.h
blob: 1bc8210e752204dc87a1450dde17b0d3f2085c17 (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
/* --------------------------------------------------------------------------
 * Copyright 2003-2011 (inclusive) Nathan Angelacos 
 *                   (nangel@users.sourceforge.net)
 * 
 *   This file is part of haserl.
 *
 *   Haserl is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License version 2,
 *   as published by the Free Software Foundation.
 *
 *   Haserl 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 haserl.  If not, see <http://www.gnu.org/licenses/>.
 *
 * ------------------------------------------------------------------------ */

#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 */