]> andersk Git - zcommit.git/blob - src/zsend-0.0.1/lread.h
Added source for zsend
[zcommit.git] / src / zsend-0.0.1 / lread.h
1 /*
2    lread.h  Header file for elisp reader and destructurer
3    Copyright (C) 1992 Nick Thompson (nix@cs.cmu.edu)
4
5    This program is free software; you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation; either version 2 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program; if not, write to the Free Software
17    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19    This code is useful for communicating with emacs, particularly in
20    subprocesses which are started by emacs.  It allows you to do structured
21    ipc by passing printed s-expressions between emacs and the subprocess -
22    strings are parsed into a union "Value" by this code and there is also a
23    fairly convenient way to extract data.
24    
25   */
26
27 #include <stdlib.h>     /* for malloc() */
28
29 enum Vtag { any, nil, cons, string, symbol, integer, var };
30
31 typedef struct Value Value;
32 struct Value {
33    enum Vtag tag;
34    union {
35       /* tag nil has no data */
36       struct { Value *car, *cdr; } cons;
37       struct { int length; char *string; } s;   /* tag string or symbol */
38       struct { long i; } integer;
39       struct { enum Vtag tag; void **value; } var;
40    } value;
41 };
42
43 #define ALLOC_VALUE()   ((Value *) malloc(sizeof(Value)))
44
45 #define VTAG(v) (v?((v)->tag):nil)
46
47 extern Value *vmake_cons(Value *car, Value *cdr);
48 #define VCAR(v) ((v)->value.cons.car)
49 #define VCDR(v) ((v)->value.cons.cdr)
50
51 extern Value *vmake_symbol(int length, char *data);
52 extern Value *vmake_symbol_c(char *s);
53 extern Value *vmake_string(int length, char *data);
54 extern Value *vmake_string_c(char *s);
55 extern char *vextract_string_c(Value *v);
56 #define VSLENGTH(v) ((v)->value.s.length)
57 #define VSDATA(v) ((v)->value.s.string)
58
59 extern Value *vmake_integer(int n);
60 #define VINTEGER(v) ((v)->value.integer.i)
61
62 extern Value *vmake_var(enum Vtag tag, void **value);
63 #define VVTAG(v) ((v)->value.var.tag)
64 #define VVDATA(v) ((v)->value.var.value)
65
66 extern Value *assqv(Value *key, Value *assoc);
67 extern int vlength(Value *l);
68
69 extern int eqv();
70 extern int parse();
71 extern void free_value();
This page took 0.518854 seconds and 5 git commands to generate.