ndbm.c
Go to the documentation of this file.
1 /* ndbm -- ndbm compatibility library in the GNU data base manager, gdbm
2  January 2000
3  (c) 2000, Toshihiro Matsui, Electrotechnical Laboratory
4  cc -c -I/usr/local/eus/include -fpic ndbm.c ; cc -o ndbm.so -shared ndbm.o
5 */
6 
7 #include <ndbm.h>
8 #include "eus.h"
9 
10 pointer DBM_OPEN(ctx,n,argv)
11 register context *ctx;
12 int n;
13 register pointer argv[];
14 { DBM *dbm;
15  ckarg(3);
16  dbm=dbm_open(Getstring(argv[0])->c.str.chars,
17  ckintval(argv[1]),
18  ckintval(argv[2]));
19  return(makeint(dbm));}
20 
21 pointer DBM_CLOSE(ctx,n,argv)
22 register context *ctx;
23 int n;
24 register pointer argv[];
25 { ckarg(1);
26  dbm_close(ckintval(argv[0]));
27  return(T);}
28 
29 pointer DBM_FETCH(ctx,n,argv)
30 register context *ctx;
31 int n;
32 register pointer argv[];
33 { register pointer s;
34  datum key,content;
35  ckarg(2);
36  s=Getstring(argv[1]);
37  key.dptr=(char *)(s->c.str.chars);
38  key.dsize=strlength(s);
39  content=dbm_fetch(ckintval(argv[0]), key);
40  if (content.dptr==NULL) return(NIL);
41  return(makestring(content.dptr,content.dsize));}
42 
43 pointer DBM_STORE(ctx,n,argv)
44 register context *ctx;
45 int n;
46 register pointer argv[];
47 { register pointer s;
48  datum key,content;
49  ckarg(4);
50  s=Getstring(argv[1]);
51  key.dptr=(char *)s->c.str.chars;
52  key.dsize=strlength(s);
53  s=Getstring(argv[2]);
54  content.dptr=(char *)s->c.str.chars;
55  content.dsize=strlength(s);
56  n=dbm_store(ckintval(argv[0]), key, content, ckintval(argv[3]));
57  return((n==0)?T:NIL);}
58 
59 pointer DBM_DELETE(ctx,n,argv)
60 register context *ctx;
61 int n;
62 register pointer argv[];
63 { register pointer s;
64  datum key;
65  ckarg(2);
66  s=Getstring(argv[1]);
67  key.dptr=(char *)s->c.str.chars;
68  key.dsize=strlength(s);
69  n=dbm_delete(ckintval(argv[0]), key);
70  return((n==0)?T:NIL);}
71 
73 register context *ctx;
74 int n;
75 register pointer argv[];
76 { datum key;
77  ckarg(1);
78  key=dbm_firstkey(ckintval(argv[0]));
79  if (key.dptr==NULL) return(NIL);
80  return(makestring(key.dptr,key.dsize));}
81 
83 context *ctx;
84 int n;
85 register pointer argv[];
86 { datum key;
87  ckarg(1);
88  key=dbm_nextkey(ckintval(argv[0]));
89  if (key.dptr==NULL) return(NIL);
90  return(makestring(key.dptr,key.dsize));}
91 
92 pointer DBM_ERROR(ctx,n,argv)
93 register context *ctx;
94 int n;
95 register pointer argv[];
96 { ckarg(1);
97  n=dbm_error((DBM *)ckintval(argv[0]));
98  return((n==0)?T:NIL);}
99 
101 register context *ctx;
102 int n;
103 register pointer argv[];
104 { ckarg(1);
105  dbm_clearerr((DBM *)ckintval(argv[0]));
106  return(T);}
107 
108 
109 ndbm(context *ctx, int n, pointer argv[])
110 { pointer mod=argv[0];
111  defun(ctx,"DBM-OPEN",mod,DBM_OPEN,NULL);
112  defun(ctx,"DBM-CLOSE",mod,DBM_CLOSE,NULL);
113  defun(ctx,"DBM-FETCH",mod,DBM_FETCH,NULL);
114  defun(ctx,"DBM-STORE",mod,DBM_STORE,NULL);
115  defun(ctx,"DBM-DELETE",mod,DBM_DELETE,NULL);
116  defun(ctx,"DBM-FIRSTKEY",mod,DBM_FIRSTKEY,NULL);
117  defun(ctx,"DBM-NEXTKEY",mod,DBM_NEXTKEY,NULL);
118  defun(ctx,"DBM-ERROR",mod,DBM_ERROR,NULL);
119  defun(ctx,"DBM-CLEARERR",mod,DBM_CLEARERR,NULL);
120  }
121 
#define makeint(v)
Definition: sfttest.c:2
pointer DBM_CLOSE(context *ctx, int n, argv)
Definition: ndbm.c:21
Definition: eus.h:522
struct string str
Definition: eus.h:400
byte chars[1]
Definition: eus.h:210
pointer DBM_STORE(context *ctx, int n, argv)
Definition: ndbm.c:43
pointer Getstring()
pointer T
Definition: eus.c:110
GLfloat n[6][3]
Definition: cube.c:15
defun("ADR_TO_STRING", mod, ADR_TO_STRING)
ckarg(2)
pointer DBM_OPEN(context *ctx, int n, argv)
Definition: ndbm.c:10
pointer DBM_NEXTKEY(context *ctx, int n, argv)
Definition: ndbm.c:82
static void key(unsigned char c, int x, int y)
Definition: dinoshade.c:753
union cell::cellunion c
Definition: eus.h:379
short s
Definition: structsize.c:2
ndbm(context *ctx, int n, pointer argv[])
Definition: ndbm.c:109
pointer DBM_FETCH(context *ctx, int n, argv)
Definition: ndbm.c:29
pointer DBM_FIRSTKEY(context *ctx, int n, argv)
Definition: ndbm.c:72
pointer makestring(char *, int)
Definition: makes.c:147
pointer DBM_ERROR(context *ctx, int n, argv)
Definition: ndbm.c:92
#define NULL
Definition: transargv.c:8
pointer NIL
Definition: eus.c:110
pointer DBM_DELETE(context *ctx, int n, argv)
Definition: ndbm.c:59
pointer DBM_CLEARERR(context *ctx, int n, argv)
Definition: ndbm.c:100


euslisp
Author(s): Toshihiro Matsui
autogenerated on Fri Feb 21 2020 03:20:54