ndbm.c
Go to the documentation of this file.
00001 /* ndbm -- ndbm compatibility library in the GNU data base manager, gdbm
00002         January 2000
00003         (c) 2000, Toshihiro Matsui, Electrotechnical Laboratory
00004         cc -c -I/usr/local/eus/include -fpic  ndbm.c ; cc -o ndbm.so -shared ndbm.o
00005 */
00006 
00007 #include <ndbm.h>
00008 #include "eus.h"
00009 
00010 pointer DBM_OPEN(ctx,n,argv)
00011 register context *ctx;
00012 int n;
00013 register pointer argv[];
00014 { DBM *dbm;
00015   ckarg(3);
00016   dbm=dbm_open(Getstring(argv[0])->c.str.chars,
00017                ckintval(argv[1]),
00018                ckintval(argv[2]));
00019   return(makeint(dbm));}
00020 
00021 pointer DBM_CLOSE(ctx,n,argv)
00022 register context *ctx;
00023 int n;
00024 register pointer argv[];
00025 { ckarg(1);
00026   dbm_close(ckintval(argv[0]));
00027   return(T);}
00028 
00029 pointer DBM_FETCH(ctx,n,argv)
00030 register context *ctx;
00031 int n;
00032 register pointer argv[];
00033 { register pointer s;
00034   datum key,content;
00035   ckarg(2);
00036   s=Getstring(argv[1]);
00037   key.dptr=(char *)(s->c.str.chars);
00038   key.dsize=strlength(s);
00039   content=dbm_fetch(ckintval(argv[0]), key);
00040   if (content.dptr==NULL) return(NIL);
00041   return(makestring(content.dptr,content.dsize));}
00042 
00043 pointer DBM_STORE(ctx,n,argv)
00044 register context *ctx;
00045 int n;
00046 register pointer argv[];
00047 { register pointer s;
00048   datum key,content;
00049   ckarg(4);
00050   s=Getstring(argv[1]);
00051   key.dptr=(char *)s->c.str.chars;
00052   key.dsize=strlength(s);
00053   s=Getstring(argv[2]);
00054   content.dptr=(char *)s->c.str.chars;
00055   content.dsize=strlength(s);
00056   n=dbm_store(ckintval(argv[0]), key, content, ckintval(argv[3]));
00057   return((n==0)?T:NIL);}
00058 
00059 pointer DBM_DELETE(ctx,n,argv)
00060 register context *ctx;
00061 int n;
00062 register pointer argv[];
00063 { register pointer s;
00064   datum key;
00065   ckarg(2);
00066   s=Getstring(argv[1]);
00067   key.dptr=(char *)s->c.str.chars;
00068   key.dsize=strlength(s);
00069   n=dbm_delete(ckintval(argv[0]), key);
00070   return((n==0)?T:NIL);}
00071 
00072 pointer DBM_FIRSTKEY(ctx,n,argv)
00073 register context *ctx;
00074 int n;
00075 register pointer argv[];
00076 { datum key;
00077   ckarg(1);
00078   key=dbm_firstkey(ckintval(argv[0]));
00079   if (key.dptr==NULL) return(NIL);
00080   return(makestring(key.dptr,key.dsize));}
00081 
00082 pointer DBM_NEXTKEY(ctx,n,argv)
00083 context *ctx;
00084 int n;
00085 register pointer argv[];
00086 { datum key;
00087   ckarg(1);
00088   key=dbm_nextkey(ckintval(argv[0]));
00089   if (key.dptr==NULL) return(NIL);
00090   return(makestring(key.dptr,key.dsize));}
00091 
00092 pointer DBM_ERROR(ctx,n,argv)
00093 register context *ctx;
00094 int n;
00095 register pointer argv[];
00096 { ckarg(1);
00097   n=dbm_error((DBM *)ckintval(argv[0]));
00098   return((n==0)?T:NIL);}
00099 
00100 pointer DBM_CLEARERR(ctx,n,argv)
00101 register context *ctx;
00102 int n;
00103 register pointer argv[];
00104 { ckarg(1);
00105   dbm_clearerr((DBM *)ckintval(argv[0]));
00106   return(T);}
00107 
00108 
00109 ndbm(context *ctx, int n, pointer argv[])
00110 { pointer mod=argv[0];
00111   defun(ctx,"DBM-OPEN",mod,DBM_OPEN);
00112   defun(ctx,"DBM-CLOSE",mod,DBM_CLOSE);
00113   defun(ctx,"DBM-FETCH",mod,DBM_FETCH);
00114   defun(ctx,"DBM-STORE",mod,DBM_STORE);
00115   defun(ctx,"DBM-DELETE",mod,DBM_DELETE);
00116   defun(ctx,"DBM-FIRSTKEY",mod,DBM_FIRSTKEY);
00117   defun(ctx,"DBM-NEXTKEY",mod,DBM_NEXTKEY);
00118   defun(ctx,"DBM-ERROR",mod,DBM_ERROR);
00119   defun(ctx,"DBM-CLEARERR",mod,DBM_CLEARERR);
00120   }
00121 


euslisp
Author(s): Toshihiro Matsui
autogenerated on Thu Sep 3 2015 10:36:20