Cleanup
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@14 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
59155a06c2
commit
17f6c1597b
6 changed files with 296 additions and 174 deletions
|
|
@ -1,11 +1,7 @@
|
||||||
|
# Generated automatically from Makefile.in by configure.
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# $Header$
|
# $Header$
|
||||||
# Simplified Wrapper and Interface Generator (SWIG)
|
# DOH
|
||||||
#
|
|
||||||
# Makefile for version 1.0 Final
|
|
||||||
# Dave Beazley
|
|
||||||
# August 1, 1996
|
|
||||||
#
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
#.KEEP_STATE:
|
#.KEEP_STATE:
|
||||||
|
|
@ -13,8 +9,8 @@
|
||||||
# Set your C++ compiler here. g++ works on most machines,
|
# Set your C++ compiler here. g++ works on most machines,
|
||||||
# but you might have to change it depending on your installation.
|
# but you might have to change it depending on your installation.
|
||||||
#
|
#
|
||||||
CC = cc -g
|
CC = gcc -O2
|
||||||
prefix = /usr/local
|
prefix = /usr/sandbox
|
||||||
|
|
||||||
# Comment out the following line if you're on an SGI or don't have ranlib!
|
# Comment out the following line if you're on an SGI or don't have ranlib!
|
||||||
RANLIB = ranlib
|
RANLIB = ranlib
|
||||||
|
|
@ -34,8 +30,6 @@ INCLUDE = -I../Include
|
||||||
CFLAGS =
|
CFLAGS =
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# Rules for creation of a .o file from .cxx
|
# Rules for creation of a .o file from .cxx
|
||||||
.SUFFIXES: .c
|
.SUFFIXES: .c
|
||||||
|
|
|
||||||
|
|
@ -1,42 +1,16 @@
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# $Header$
|
# $Header$
|
||||||
# Simplified Wrapper and Interface Generator (SWIG)
|
# DOH
|
||||||
#
|
|
||||||
# Makefile for version 1.0 Final
|
|
||||||
# Dave Beazley
|
|
||||||
# August 1, 1996
|
|
||||||
#
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
|
|
||||||
#.KEEP_STATE:
|
#.KEEP_STATE:
|
||||||
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
|
||||||
VPATH = @srcdir@
|
|
||||||
|
|
||||||
# Set your C++ compiler here. g++ works on most machines,
|
# Set your C++ compiler here. g++ works on most machines,
|
||||||
# but you might have to change it depending on your installation.
|
# but you might have to change it depending on your installation.
|
||||||
#
|
#
|
||||||
CC = @CC@
|
CC = @CC@
|
||||||
|
|
||||||
#
|
|
||||||
# Set the prefix below to indicate where you want SWIG to install its
|
|
||||||
# files. Normally this is /usr/local
|
|
||||||
#
|
|
||||||
|
|
||||||
prefix = @prefix@
|
prefix = @prefix@
|
||||||
|
|
||||||
# Location of the SWIG library. Is normally put in /usr/local/lib/swig_lib
|
|
||||||
# The SWIG library contains configuration files and library modules
|
|
||||||
# so you should install it someplace where it can be easily accessed.
|
|
||||||
|
|
||||||
SWIG_LIB = $(prefix)/lib/@SWIGLIBDIR@
|
|
||||||
|
|
||||||
# YACC parser. Use bison by default. if this doesn't work, switch
|
|
||||||
# it over to yacc. If that still doesn't work, let me know...
|
|
||||||
|
|
||||||
YACC = @YACC@
|
|
||||||
|
|
||||||
# Comment out the following line if you're on an SGI or don't have ranlib!
|
# Comment out the following line if you're on an SGI or don't have ranlib!
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
AR = @AR@
|
AR = @AR@
|
||||||
|
|
@ -45,51 +19,31 @@ AR = @AR@
|
||||||
# Normally, you shouldn't have to change anything below this point #
|
# Normally, you shouldn't have to change anything below this point #
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
|
LIBOBJS = void.o fio.o memory.o base.o file.o list.o hash.o string.o
|
||||||
|
|
||||||
LIBOBJS = scanner.o parms.o types.o error.o module.o getopt.o file.o string.o list.o hash.o base.o main.o
|
LIBSRCS = void.c fio.c memory.c base.c file.c list.c hash.c string.c
|
||||||
|
|
||||||
LIBSRCS = scanner.c parms.c types.c error.c module.c getopt.c file.c string.c list.c hash.c base.c main.c
|
LIBHEADERS = ../Include/doh.h
|
||||||
|
LIB = ../libdoh.a
|
||||||
LIBHEADERS = ../Include/swig.h
|
|
||||||
LIB = ../libswig.a
|
|
||||||
PARSER = parser.y
|
|
||||||
INCLUDE = -I../Include
|
INCLUDE = -I../Include
|
||||||
CFLAGS = @CFLAGS@ -DSWIG_LIB='"$(SWIG_LIB)"' -DSWIG_CC='"$(CC)"' @DEFS@
|
CFLAGS =
|
||||||
SHELL = /bin/sh
|
SHELL = /bin/sh
|
||||||
|
|
||||||
#
|
|
||||||
#
|
|
||||||
#
|
#
|
||||||
# Rules for creation of a .o file from .cxx
|
# Rules for creation of a .o file from .cxx
|
||||||
.SUFFIXES: .c
|
.SUFFIXES: .c
|
||||||
.c.o:
|
.c.o:
|
||||||
$(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
|
$(CC) $(INCLUDE) $(CFLAGS) -c -o $*.o $<
|
||||||
|
|
||||||
all:
|
all: $(LIB)
|
||||||
@cd ..; $(MAKE)
|
|
||||||
|
|
||||||
|
|
||||||
build: $(LIB)
|
|
||||||
#$(CC) $(LIBOBJS) -o swig -ldl
|
|
||||||
|
|
||||||
py: $(LIB)
|
|
||||||
/usr/local/bin/swig -python -o swig_wrap.c ../Include/swig.h
|
|
||||||
$(CC) $(INCLUDE) -I/usr/local/include/python1.5 $(CFLAGS) -c swig_wrap.c
|
|
||||||
ld -G $(LIBOBJS) swig_wrap.o -o swigmodule.so
|
|
||||||
|
|
||||||
$(LIB): $(LIBOBJS)
|
$(LIB): $(LIBOBJS)
|
||||||
@echo "Building library"
|
@echo "Building library"
|
||||||
$(AR) cr $(LIB) $(LIBOBJS)
|
$(AR) cr $(LIB) $(LIBOBJS)
|
||||||
$(RANLIB) $(LIB)
|
$(RANLIB) $(LIB)
|
||||||
|
|
||||||
Makefile: $(srcdir)/Makefile.in ../config.status
|
|
||||||
(cd ..; CONFIG_FILES=SWIG/Makefile $(SHELL) config.status)
|
|
||||||
|
|
||||||
.PRECIOUS: Makefile
|
|
||||||
|
|
||||||
clean::
|
clean::
|
||||||
rm -f *.o libswig.a y.tab.c y.tab.h
|
rm -f *.o ../libdoh.a
|
||||||
|
|
||||||
nuke::
|
nuke::
|
||||||
rm -f Makefile *~ #* core a.out
|
rm -f Makefile *~ #* core a.out
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,22 @@
|
||||||
|
|
||||||
#include "doh.h"
|
#include "doh.h"
|
||||||
|
|
||||||
|
static int debug_level = 0;
|
||||||
|
|
||||||
|
void DohError(int level, char *fmt, ...) {
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap,fmt);
|
||||||
|
if (level <= debug_level) {
|
||||||
|
printf("DOH %d:",level);
|
||||||
|
vprintf(fmt,ap);
|
||||||
|
}
|
||||||
|
va_end(ap);
|
||||||
|
}
|
||||||
|
|
||||||
|
void DohDebug(int d) {
|
||||||
|
debug_level = d;
|
||||||
|
}
|
||||||
|
|
||||||
static DohObjInfo DohBaseType = {
|
static DohObjInfo DohBaseType = {
|
||||||
"Base", /* objname */
|
"Base", /* objname */
|
||||||
sizeof(DohBase), /* objsize */
|
sizeof(DohBase), /* objsize */
|
||||||
|
|
@ -70,6 +86,9 @@ static DOH *find_internal(DOH *co) {
|
||||||
char *c;
|
char *c;
|
||||||
if (DohCheck(co)) return co;
|
if (DohCheck(co)) return co;
|
||||||
c = (char *) co;
|
c = (char *) co;
|
||||||
|
if (debug_level) {
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x being treated as 'char *'.\n", c);
|
||||||
|
}
|
||||||
r = root;
|
r = root;
|
||||||
s = 0;
|
s = 0;
|
||||||
while (r) {
|
while (r) {
|
||||||
|
|
@ -98,6 +117,7 @@ static DOH *find_internal(DOH *co) {
|
||||||
/* Destroy an object */
|
/* Destroy an object */
|
||||||
void DohDestroy(DOH *obj) {
|
void DohDestroy(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohDestroy %x\n",obj);
|
||||||
if (!DohCheck(b)) return;
|
if (!DohCheck(b)) return;
|
||||||
b->refcount--;
|
b->refcount--;
|
||||||
if (b->refcount <= 0) {
|
if (b->refcount <= 0) {
|
||||||
|
|
@ -113,28 +133,37 @@ void DohDestroy(DOH *obj) {
|
||||||
DOH *DohCopy(DOH *obj) {
|
DOH *DohCopy(DOH *obj) {
|
||||||
DOH *result;
|
DOH *result;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
if (!DohCheck(b)) return 0;
|
DohError(DOH_CALLS,"DohCopy %x\n",obj);
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to Copy.\n", obj);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (b->objinfo->doh_copy) {
|
if (b->objinfo->doh_copy) {
|
||||||
return (b->objinfo->doh_copy)(obj);
|
return (b->objinfo->doh_copy)(obj);
|
||||||
}
|
}
|
||||||
printf("No copy method defined for type '%s'\n", b->objinfo->objname);
|
DohError(DOH_UNSUPPORTED,"No copy method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DohClear(DOH *obj) {
|
void DohClear(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
if (!DohCheck(b)) return;
|
DohError(DOH_CALLS,"DohClear %x\n",obj);
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to Clear.\n",obj);
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (b->objinfo->doh_clear) {
|
if (b->objinfo->doh_clear) {
|
||||||
(b->objinfo->doh_clear)(obj);
|
(b->objinfo->doh_clear)(obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("No clear method defined for type '%s'\n", b->objinfo->objname);
|
DohError(DOH_UNSUPPORTED, "No clear method defined for type '%s'\n", b->objinfo->objname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Turn an object into a string */
|
/* Turn an object into a string */
|
||||||
DOH *DohStr(DOH *obj) {
|
DOH *DohStr(DOH *obj) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohStr %x\n",obj);
|
||||||
if (DohCheck(b)) {
|
if (DohCheck(b)) {
|
||||||
if (b->objinfo->doh_str) {
|
if (b->objinfo->doh_str) {
|
||||||
return (b->objinfo->doh_str)(b);
|
return (b->objinfo->doh_str)(b);
|
||||||
|
|
@ -143,6 +172,7 @@ DOH *DohStr(DOH *obj) {
|
||||||
Printf(s,"'%s' at %x>", b->objinfo->objname, b);
|
Printf(s,"'%s' at %x>", b->objinfo->objname, b);
|
||||||
return s;
|
return s;
|
||||||
} else {
|
} else {
|
||||||
|
DohError(DOH_CONVERSION, "Creating new string from unknown object %x (assuming char *).\n", obj);
|
||||||
return NewString(obj);
|
return NewString(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -150,10 +180,14 @@ DOH *DohStr(DOH *obj) {
|
||||||
/* Serialize an object */
|
/* Serialize an object */
|
||||||
int DohDump(DOH *obj, DOH *out) {
|
int DohDump(DOH *obj, DOH *out) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohDump %x, %x\n",obj,out);
|
||||||
if (DohCheck(obj)) {
|
if (DohCheck(obj)) {
|
||||||
if (b->objinfo->doh_dump) {
|
if (b->objinfo->doh_dump) {
|
||||||
return (b->objinfo->doh_dump)(b,out);
|
return (b->objinfo->doh_dump)(b,out);
|
||||||
}
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No dump method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN, "Unknown object %x passed to Dump.\n",obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -162,12 +196,17 @@ int DohDump(DOH *obj, DOH *out) {
|
||||||
int DohLen(DOH *obj) {
|
int DohLen(DOH *obj) {
|
||||||
int s;
|
int s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohLen %x\n",obj);
|
||||||
|
if (!b) return 0;
|
||||||
if (DohCheck(b)) {
|
if (DohCheck(b)) {
|
||||||
if (b->objinfo->doh_len) {
|
if (b->objinfo->doh_len) {
|
||||||
return (b->objinfo->doh_len)(obj);
|
return (b->objinfo->doh_len)(obj);
|
||||||
}
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED, "No len method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_CONVERSION, "Using strlen() on unknown object %x.\n", obj);
|
||||||
|
return strlen((char *) obj);
|
||||||
}
|
}
|
||||||
printf("No len method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -175,11 +214,14 @@ int DohLen(DOH *obj) {
|
||||||
int DohHashval(DOH *obj) {
|
int DohHashval(DOH *obj) {
|
||||||
int s;
|
int s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohHashval %x\n",obj);
|
||||||
if (DohCheck(b)) {
|
if (DohCheck(b)) {
|
||||||
if (b->objinfo->doh_hash) {
|
if (b->objinfo->doh_hash) {
|
||||||
return (b->objinfo->doh_hash)(obj);
|
return (b->objinfo->doh_hash)(obj);
|
||||||
}
|
}
|
||||||
printf("No hash method defined for type '%s'\n", b->objinfo->objname);
|
DohError(DOH_UNSUPPORTED,"No hash method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to Hashval.\n", obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -189,16 +231,18 @@ void *DohData(DOH *obj) {
|
||||||
char *c;
|
char *c;
|
||||||
char *s;
|
char *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohData %x\n",obj);
|
||||||
c = (char *) obj;
|
c = (char *) obj;
|
||||||
if (!c) return 0;
|
|
||||||
if (DohCheck(c)) {
|
if (DohCheck(c)) {
|
||||||
if (b->objinfo) {
|
if (b->objinfo) {
|
||||||
if (b->objinfo->doh_data) {
|
if (b->objinfo->doh_data) {
|
||||||
return (b->objinfo->doh_data)(obj);
|
return (b->objinfo->doh_data)(obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf("No data method defined for type '%s'\n", b->objinfo->objname);
|
DohError(DOH_UNSUPPORTED,"No data method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return 0;
|
return 0;
|
||||||
|
} else {
|
||||||
|
DohError(DOH_CONVERSION, "Unknown object %x passed to Data being returned as-is.\n", obj);
|
||||||
}
|
}
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
@ -206,8 +250,11 @@ void *DohData(DOH *obj) {
|
||||||
/* Get the line number */
|
/* Get the line number */
|
||||||
int DohGetline(DOH *obj) {
|
int DohGetline(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohGetline %x\n",obj);
|
||||||
if (DohCheck(obj)) {
|
if (DohCheck(obj)) {
|
||||||
return b->line;
|
return b->line;
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN, "Unknown object %x passed to Getline.\n", obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -215,16 +262,22 @@ int DohGetline(DOH *obj) {
|
||||||
/* Set the line number */
|
/* Set the line number */
|
||||||
void DohSetline(DOH *obj, int line) {
|
void DohSetline(DOH *obj, int line) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohSetline %x, %d\n",obj, line);
|
||||||
if (DohCheck(obj)) {
|
if (DohCheck(obj)) {
|
||||||
b->line = line;
|
b->line = line;
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN, "Unknown object %x passed to Setline.\n", obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the file name */
|
/* Get the file name */
|
||||||
DOH *DohGetfile(DOH *obj) {
|
DOH *DohGetfile(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohGetfile %x\n",obj);
|
||||||
if (DohCheck(obj)) {
|
if (DohCheck(obj)) {
|
||||||
return b->file;
|
return b->file;
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN, "Unknown object %x passed to Getfile.\n", obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -233,6 +286,7 @@ DOH *DohGetfile(DOH *obj) {
|
||||||
void DohSetfile(DOH *obj, DOH *file) {
|
void DohSetfile(DOH *obj, DOH *file) {
|
||||||
DOH *nf;
|
DOH *nf;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohSetfile %x, %x\n",obj,file);
|
||||||
if (DohCheck(obj)) {
|
if (DohCheck(obj)) {
|
||||||
if (file) {
|
if (file) {
|
||||||
nf = find_internal(file);
|
nf = find_internal(file);
|
||||||
|
|
@ -243,6 +297,8 @@ void DohSetfile(DOH *obj, DOH *file) {
|
||||||
Delete(b->file);
|
Delete(b->file);
|
||||||
b->file = 0;
|
b->file = 0;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN, "Unknown object %x passed to Setfile.\n", obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,6 +306,7 @@ void DohSetfile(DOH *obj, DOH *file) {
|
||||||
int DohCmp(DOH *obj1, DOH *obj2) {
|
int DohCmp(DOH *obj1, DOH *obj2) {
|
||||||
int s;
|
int s;
|
||||||
DohBase *b1, *b2;
|
DohBase *b1, *b2;
|
||||||
|
DohError(DOH_CALLS,"DohCmp %x, %x\n",obj1,obj2);
|
||||||
b1 = (DohBase *) obj1;
|
b1 = (DohBase *) obj1;
|
||||||
b2 = (DohBase *) obj2;
|
b2 = (DohBase *) obj2;
|
||||||
if (!DohCheck(b1)) {
|
if (!DohCheck(b1)) {
|
||||||
|
|
@ -259,13 +316,14 @@ int DohCmp(DOH *obj1, DOH *obj2) {
|
||||||
b2 = find_internal(b2);
|
b2 = find_internal(b2);
|
||||||
}
|
}
|
||||||
if (b1->objinfo == b2->objinfo) {
|
if (b1->objinfo == b2->objinfo) {
|
||||||
if (b1->objinfo->doh_cmp) {
|
if (b1->objinfo->doh_cmp) {
|
||||||
return (b1->objinfo->doh_cmp)(b1,b2);
|
return (b1->objinfo->doh_cmp)(b1,b2);
|
||||||
}
|
}
|
||||||
printf("No cmp method defined for type '%s'\n", b1->objinfo->objname);
|
DohError(DOH_UNSUPPORTED,"No cmp method defined for type '%s'\n", b1->objinfo->objname);
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
printf("Can't compare type '%s' with type '%s'\n", b1->objinfo->objname, b2->objinfo->objname);
|
DohError(DOH_UNSUPPORTED,"Can't compare type '%s' with type '%s'\n", b1->objinfo->objname, b2->objinfo->objname);
|
||||||
return 0;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------------
|
/* ----------------------------------------------------------------------
|
||||||
|
|
@ -284,44 +342,31 @@ DOH *DohGetattr(DOH *obj, DOH *name) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DOH *name_obj;
|
DOH *name_obj;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohGetattr %x, %x\n",obj,name);
|
||||||
if (DohIsMapping(b)) {
|
if (DohIsMapping(b)) {
|
||||||
name_obj = find_internal(name);
|
name_obj = find_internal(name);
|
||||||
if (b->objinfo->doh_mapping->doh_getattr) {
|
if (b->objinfo->doh_mapping->doh_getattr) {
|
||||||
return (b->objinfo->doh_mapping->doh_getattr)(obj,name_obj);
|
return (b->objinfo->doh_mapping->doh_getattr)(obj,name_obj);
|
||||||
}
|
}
|
||||||
return 0;
|
}
|
||||||
|
if (DohCheck(b)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No getattr method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to Getattr.\n", obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef OLD
|
|
||||||
/* Getattrf */
|
|
||||||
int DohGetattrf(DOH *obj, DOH *name, char *format, ...) {
|
|
||||||
va_list ap;
|
|
||||||
int ret = 0;
|
|
||||||
DOH *item, *str;
|
|
||||||
item = DohGetattr(obj,name);
|
|
||||||
if (item) {
|
|
||||||
str = DohStr(item);
|
|
||||||
DohSeek(str,0,SEEK_SET);
|
|
||||||
va_start(ap,format);
|
|
||||||
ret = DohvScanf(str,format,ap);
|
|
||||||
va_end(ap);
|
|
||||||
Delete(str);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Set an attribute in an object */
|
/* Set an attribute in an object */
|
||||||
int DohSetattr(DOH *obj, DOH *name, DOH *value) {
|
int DohSetattr(DOH *obj, DOH *name, DOH *value) {
|
||||||
int s;
|
int s;
|
||||||
DOH *name_obj, *value_obj;
|
DOH *name_obj, *value_obj;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohSetattr %x, %x, %x\n",obj,name, value);
|
||||||
if (DohIsMapping(b)) {
|
if (DohIsMapping(b)) {
|
||||||
name_obj = find_internal(name);
|
name_obj = find_internal(name);
|
||||||
if (!DohCheck(value)) {
|
if (!DohCheck(value)) {
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to a string in Setattr.\n",value);
|
||||||
value_obj = NewString(value);
|
value_obj = NewString(value);
|
||||||
} else {
|
} else {
|
||||||
value_obj = value;
|
value_obj = value;
|
||||||
|
|
@ -329,38 +374,31 @@ int DohSetattr(DOH *obj, DOH *name, DOH *value) {
|
||||||
if (b->objinfo->doh_mapping->doh_setattr) {
|
if (b->objinfo->doh_mapping->doh_setattr) {
|
||||||
return (b->objinfo->doh_mapping->doh_setattr)(obj,name_obj,value_obj);
|
return (b->objinfo->doh_mapping->doh_setattr)(obj,name_obj,value_obj);
|
||||||
}
|
}
|
||||||
printf("No setattr method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
|
if (DohCheck(b)) {
|
||||||
|
DohError(DOH_UNSUPPORTED, "No setattr method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to Setattr\n", obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Setattrf */
|
|
||||||
int DohSetattrf(DOH *obj, DOH *name, char *format, ...) {
|
|
||||||
va_list ap;
|
|
||||||
int ret = 0;
|
|
||||||
DOH *str;
|
|
||||||
str = NewString("");
|
|
||||||
Incref(str);
|
|
||||||
va_start(ap,format);
|
|
||||||
ret = DohvPrintf(str,format,ap);
|
|
||||||
va_end(ap);
|
|
||||||
DohSetattr(obj,name,str);
|
|
||||||
Delete(str);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Delete an attribute from an object */
|
/* Delete an attribute from an object */
|
||||||
void DohDelattr(DOH *obj, DOH *name) {
|
void DohDelattr(DOH *obj, DOH *name) {
|
||||||
DOH *name_obj;
|
DOH *name_obj;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohDelattr %x, %x\n",obj,name);
|
||||||
if (DohIsMapping(obj)) {
|
if (DohIsMapping(obj)) {
|
||||||
name_obj = find_internal(name);
|
name_obj = find_internal(name);
|
||||||
if (b->objinfo->doh_mapping->doh_delattr) {
|
if (b->objinfo->doh_mapping->doh_delattr) {
|
||||||
(b->objinfo->doh_mapping->doh_delattr)(obj,name_obj);
|
(b->objinfo->doh_mapping->doh_delattr)(obj,name_obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("No delattr method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED, "No delattr method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to Delattr\n",obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -369,12 +407,16 @@ void DohDelattr(DOH *obj, DOH *name) {
|
||||||
DOH *DohFirst(DOH *obj) {
|
DOH *DohFirst(DOH *obj) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohFirst %x\n",obj);
|
||||||
if (DohIsMapping(obj)) {
|
if (DohIsMapping(obj)) {
|
||||||
if (b->objinfo->doh_mapping->doh_firstkey) {
|
if (b->objinfo->doh_mapping->doh_firstkey) {
|
||||||
return DohGetattr(obj,(b->objinfo->doh_mapping->doh_firstkey)(obj));
|
return DohGetattr(obj,(b->objinfo->doh_mapping->doh_firstkey)(obj));
|
||||||
}
|
}
|
||||||
printf("No firstkey method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
return 0;
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No firstkey method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohFirst\n",obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -383,12 +425,16 @@ DOH *DohFirst(DOH *obj) {
|
||||||
DOH *DohNext(DOH *obj) {
|
DOH *DohNext(DOH *obj) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohNext %x\n",obj);
|
||||||
if (DohIsMapping(obj)) {
|
if (DohIsMapping(obj)) {
|
||||||
if (b->objinfo->doh_mapping->doh_nextkey) {
|
if (b->objinfo->doh_mapping->doh_nextkey) {
|
||||||
return DohGetattr(obj,(b->objinfo->doh_mapping->doh_nextkey)(obj));
|
return DohGetattr(obj,(b->objinfo->doh_mapping->doh_nextkey)(obj));
|
||||||
}
|
}
|
||||||
printf("No nextkey method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
return 0;
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No nextkey method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohNext\n",obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -398,12 +444,16 @@ DOH *DohNext(DOH *obj) {
|
||||||
DOH *DohFirstkey(DOH *obj) {
|
DOH *DohFirstkey(DOH *obj) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohFirstkey %x\n",obj);
|
||||||
if (DohIsMapping(obj)) {
|
if (DohIsMapping(obj)) {
|
||||||
if (b->objinfo->doh_mapping->doh_firstkey) {
|
if (b->objinfo->doh_mapping->doh_firstkey) {
|
||||||
return (b->objinfo->doh_mapping->doh_firstkey)(obj);
|
return (b->objinfo->doh_mapping->doh_firstkey)(obj);
|
||||||
}
|
}
|
||||||
printf("No firstkey method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
return 0;
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No firstkey method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohFirstkey\n",obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -412,12 +462,16 @@ DOH *DohFirstkey(DOH *obj) {
|
||||||
DOH *DohNextkey(DOH *obj) {
|
DOH *DohNextkey(DOH *obj) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohNextkey %x\n",obj);
|
||||||
if (DohIsMapping(obj)) {
|
if (DohIsMapping(obj)) {
|
||||||
if (b->objinfo->doh_mapping->doh_nextkey) {
|
if (b->objinfo->doh_mapping->doh_nextkey) {
|
||||||
return (b->objinfo->doh_mapping->doh_nextkey)(obj);
|
return (b->objinfo->doh_mapping->doh_nextkey)(obj);
|
||||||
}
|
}
|
||||||
printf("No nextkey method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
return 0;
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No nextkey method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohNextkey\n",obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -425,6 +479,7 @@ DOH *DohNextkey(DOH *obj) {
|
||||||
int DohGetInt(DOH *obj, DOH *name) {
|
int DohGetInt(DOH *obj, DOH *name) {
|
||||||
int ival;
|
int ival;
|
||||||
DOH *val;
|
DOH *val;
|
||||||
|
DohError(DOH_CALLS,"DohGetInt %x, %x\n",obj,name);
|
||||||
val = Getattr(obj,name);
|
val = Getattr(obj,name);
|
||||||
if (!val) return 0;
|
if (!val) return 0;
|
||||||
if (String_check(val)) {
|
if (String_check(val)) {
|
||||||
|
|
@ -436,6 +491,7 @@ int DohGetInt(DOH *obj, DOH *name) {
|
||||||
double DohGetDouble(DOH *obj, DOH *name) {
|
double DohGetDouble(DOH *obj, DOH *name) {
|
||||||
double dval;
|
double dval;
|
||||||
DOH *val;
|
DOH *val;
|
||||||
|
DohError(DOH_CALLS,"DohGetDouble %x, %x\n",obj,name);
|
||||||
val = Getattr(obj,name);
|
val = Getattr(obj,name);
|
||||||
if (!val) return 0;
|
if (!val) return 0;
|
||||||
if (String_check(val)) {
|
if (String_check(val)) {
|
||||||
|
|
@ -459,11 +515,16 @@ int DohIsSequence(DOH *obj) {
|
||||||
DOH *DohGetitem(DOH *obj, int index) {
|
DOH *DohGetitem(DOH *obj, int index) {
|
||||||
DOH *s;
|
DOH *s;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohGetitem %x, %d\n",obj,index);
|
||||||
if (DohIsSequence(obj)) {
|
if (DohIsSequence(obj)) {
|
||||||
if (b->objinfo->doh_sequence->doh_getitem) {
|
if (b->objinfo->doh_sequence->doh_getitem) {
|
||||||
return (b->objinfo->doh_sequence->doh_getitem)(obj,index);
|
return (b->objinfo->doh_sequence->doh_getitem)(obj,index);
|
||||||
}
|
}
|
||||||
printf("No getitem method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No getitem method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohGetitem\n",obj);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -472,8 +533,10 @@ DOH *DohGetitem(DOH *obj, int index) {
|
||||||
void DohSetitem(DOH *obj, int index, DOH *value) {
|
void DohSetitem(DOH *obj, int index, DOH *value) {
|
||||||
DOH *value_obj;
|
DOH *value_obj;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohSetitem %x, %d, %x\n",obj,index, value);
|
||||||
if (DohIsSequence(obj)) {
|
if (DohIsSequence(obj)) {
|
||||||
if (!DohCheck(value)) {
|
if (!DohCheck(value)) {
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x being converted to a string in Setitem.\n", value);
|
||||||
value_obj = NewString(value);
|
value_obj = NewString(value);
|
||||||
} else {
|
} else {
|
||||||
value_obj = value;
|
value_obj = value;
|
||||||
|
|
@ -482,19 +545,28 @@ void DohSetitem(DOH *obj, int index, DOH *value) {
|
||||||
(b->objinfo->doh_sequence->doh_setitem)(obj,index,value_obj);
|
(b->objinfo->doh_sequence->doh_setitem)(obj,index,value_obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("No setitem method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No setitem method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohSetitem\n",obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Delete an item from an object */
|
/* Delete an item from an object */
|
||||||
void DohDelitem(DOH *obj, int index) {
|
void DohDelitem(DOH *obj, int index) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohDelitem %x, %d\n",obj,index);
|
||||||
if (DohIsSequence(obj)) {
|
if (DohIsSequence(obj)) {
|
||||||
if (b->objinfo->doh_sequence->doh_delitem) {
|
if (b->objinfo->doh_sequence->doh_delitem) {
|
||||||
(b->objinfo->doh_sequence->doh_delitem)(obj,index);
|
(b->objinfo->doh_sequence->doh_delitem)(obj,index);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("No delitem method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No delitem method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohDelitem\n",obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -502,8 +574,10 @@ void DohDelitem(DOH *obj, int index) {
|
||||||
void DohInsertitem(DOH *obj, int index, DOH *value) {
|
void DohInsertitem(DOH *obj, int index, DOH *value) {
|
||||||
DOH *value_obj;
|
DOH *value_obj;
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohInsertitem %x, %d, %x\n",obj,index, value);
|
||||||
if (DohIsSequence(obj)) {
|
if (DohIsSequence(obj)) {
|
||||||
if (!DohCheck(value)) {
|
if (!DohCheck(value)) {
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x being converted to a string in Insertitem.\n", value);
|
||||||
value_obj = NewString(value);
|
value_obj = NewString(value);
|
||||||
} else {
|
} else {
|
||||||
value_obj = value;
|
value_obj = value;
|
||||||
|
|
@ -512,7 +586,11 @@ void DohInsertitem(DOH *obj, int index, DOH *value) {
|
||||||
(b->objinfo->doh_sequence->doh_insitem)(obj,index,value_obj);
|
(b->objinfo->doh_sequence->doh_insitem)(obj,index,value_obj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
printf("No insitem method defined for type '%s'\n", b->objinfo->objname);
|
}
|
||||||
|
if (DohCheck(obj)) {
|
||||||
|
DohError(DOH_UNSUPPORTED,"No insitem method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
} else {
|
||||||
|
DohError(DOH_UNKNOWN,"Unknown object %x passed to DohInsertitem\n",obj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -530,127 +608,143 @@ int DohIsFile(DOH *obj) {
|
||||||
/* Read */
|
/* Read */
|
||||||
int DohRead(DOH *obj, void *buffer, int length) {
|
int DohRead(DOH *obj, void *buffer, int length) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohRead %x, %x, %d\n",obj,buffer,length);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_read) {
|
if (b->objinfo->doh_file->doh_read) {
|
||||||
return (b->objinfo->doh_file->doh_read)(obj,buffer,length);
|
return (b->objinfo->doh_file->doh_read)(obj,buffer,length);
|
||||||
}
|
}
|
||||||
printf("No read method defined for type '%s'\n", b->objinfo->objname);
|
} else if (!DohCheck(b)) {
|
||||||
} else {
|
|
||||||
/* Hmmm. Not a file. Maybe it's a real FILE */
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
if (!DohCheck(b)) {
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohRead\n",b);
|
||||||
return fread(buffer,1,length,(FILE *) b);
|
return fread(buffer,1,length,(FILE *) b);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No read method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write */
|
/* Write */
|
||||||
int DohWrite(DOH *obj, void *buffer, int length) {
|
int DohWrite(DOH *obj, void *buffer, int length) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohWrite %x, %x, %d\n",obj,buffer,length);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_write) {
|
if (b->objinfo->doh_file->doh_write) {
|
||||||
return (b->objinfo->doh_file->doh_write)(obj,buffer,length);
|
return (b->objinfo->doh_file->doh_write)(obj,buffer,length);
|
||||||
}
|
}
|
||||||
printf("No write method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
if (!DohCheck(b)) {
|
|
||||||
return fwrite(buffer,1,length,(FILE *) b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohWrite\n",b);
|
||||||
|
return fwrite(buffer,1,length,(FILE *) b);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No write method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Seek */
|
/* Seek */
|
||||||
int DohSeek(DOH *obj, long offset, int whence) {
|
int DohSeek(DOH *obj, long offset, int whence) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohSeek %x, %d, %d\n",obj,offset,whence);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_seek) {
|
if (b->objinfo->doh_file->doh_seek) {
|
||||||
return (b->objinfo->doh_file->doh_seek)(obj,offset,whence);
|
return (b->objinfo->doh_file->doh_seek)(obj,offset,whence);
|
||||||
}
|
}
|
||||||
printf("No seek method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
if (!DohCheck(b)) {
|
|
||||||
return fseek((FILE *) b, offset,whence);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohSeek\n",b);
|
||||||
|
return fseek((FILE *) b, offset, whence);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No seek method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell */
|
/* Tell */
|
||||||
long DohTell(DOH *obj) {
|
long DohTell(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohTell %x\n",obj);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_tell) {
|
if (b->objinfo->doh_file->doh_tell) {
|
||||||
return (b->objinfo->doh_file->doh_tell)(obj);
|
return (b->objinfo->doh_file->doh_tell)(obj);
|
||||||
}
|
}
|
||||||
printf("No tell method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
if (!DohCheck(b)) {
|
|
||||||
return ftell((FILE *) b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohTell\n",b);
|
||||||
|
return ftell((FILE *) b);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No tell method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Getc */
|
/* Getc */
|
||||||
int DohGetc(DOH *obj) {
|
int DohGetc(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohGetc %x\n",obj);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_getc) {
|
if (b->objinfo->doh_file->doh_getc) {
|
||||||
return (b->objinfo->doh_file->doh_getc)(obj);
|
return (b->objinfo->doh_file->doh_getc)(obj);
|
||||||
}
|
}
|
||||||
printf("No getc method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
if (!DohCheck(b)) {
|
|
||||||
return fgetc((FILE *) b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohGetc\n",b);
|
||||||
|
return fgetc((FILE *) b);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No getc method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Putc */
|
/* Putc */
|
||||||
int DohPutc(int ch, DOH *obj) {
|
int DohPutc(int ch, DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohPutc '%c',%x\n",ch,obj);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_putc) {
|
if (b->objinfo->doh_file->doh_putc) {
|
||||||
return (b->objinfo->doh_file->doh_putc)(obj,ch);
|
return (b->objinfo->doh_file->doh_putc)(obj,ch);
|
||||||
}
|
}
|
||||||
printf("No putc method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
if (!DohCheck(b)) {
|
|
||||||
return fputc(ch,(FILE *) b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohPutc\n",b);
|
||||||
|
return fputc(ch,(FILE *) b);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No putc method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ungetc */
|
/* ungetc */
|
||||||
int DohUngetc(int ch, DOH *obj) {
|
int DohUngetc(int ch, DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohUngetc '%c',%x\n",ch,obj);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_ungetc) {
|
if (b->objinfo->doh_file->doh_ungetc) {
|
||||||
return (b->objinfo->doh_file->doh_ungetc)(obj,ch);
|
return (b->objinfo->doh_file->doh_ungetc)(obj,ch);
|
||||||
}
|
}
|
||||||
printf("No ungetc method defined for type '%s'\n", b->objinfo->objname);
|
|
||||||
} else {
|
|
||||||
if (!DohCheck(b)) {
|
|
||||||
return ungetc(ch,(FILE *) b);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohUngetc\n",b);
|
||||||
|
return ungetc(ch,(FILE *) b);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No ungetc method defined for type '%s'\n", b->objinfo->objname);
|
||||||
return EOF;
|
return EOF;
|
||||||
}
|
}
|
||||||
|
|
||||||
int DohClose(DOH *obj) {
|
int DohClose(DOH *obj) {
|
||||||
DohBase *b = (DohBase *) obj;
|
DohBase *b = (DohBase *) obj;
|
||||||
|
DohError(DOH_CALLS,"DohClose %x\n",obj);
|
||||||
if (DohIsFile(obj)) {
|
if (DohIsFile(obj)) {
|
||||||
if (b->objinfo->doh_file->doh_close) {
|
if (b->objinfo->doh_file->doh_close) {
|
||||||
return (b->objinfo->doh_file->doh_close)(obj);
|
return (b->objinfo->doh_file->doh_close)(obj);
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
if (!DohCheck(obj)) {
|
|
||||||
fclose((FILE *) obj);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
if (!DohCheck(b)) {
|
||||||
|
/* Hmmm. Not a file. Maybe it's a real FILE */
|
||||||
|
DohError(DOH_CONVERSION,"Unknown object %x converted to FILE * in DohClose\n",b);
|
||||||
|
return fclose((FILE *) obj);
|
||||||
|
}
|
||||||
|
DohError(DOH_UNSUPPORTED,"No close method defined for type '%s'\n", b->objinfo->objname);
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DohInit(DOH *b) {
|
void DohInit(DOH *b) {
|
||||||
|
|
|
||||||
|
|
@ -115,7 +115,8 @@ extern int DohCheck(DOH *ptr);
|
||||||
extern int DohFreeCheck(DOH *ptr);
|
extern int DohFreeCheck(DOH *ptr);
|
||||||
|
|
||||||
/* Low-level doh methods. Do not call directly (well, unless you want to). */
|
/* Low-level doh methods. Do not call directly (well, unless you want to). */
|
||||||
|
extern void DohError(int level, char *fmt,...);
|
||||||
|
extern void DohDebug(int d);
|
||||||
extern void DohDestroy(DOH *obj);
|
extern void DohDestroy(DOH *obj);
|
||||||
extern DOH *DohCopy(DOH *obj);
|
extern DOH *DohCopy(DOH *obj);
|
||||||
extern void DohClear(DOH *obj);
|
extern void DohClear(DOH *obj);
|
||||||
|
|
@ -123,9 +124,7 @@ extern int DohCmp(DOH *obj1, DOH *obj2);
|
||||||
extern DOH *DohStr(DOH *obj);
|
extern DOH *DohStr(DOH *obj);
|
||||||
extern int DohDump(DOH *obj, DOH *out);
|
extern int DohDump(DOH *obj, DOH *out);
|
||||||
extern DOH *DohGetattr(DOH *obj, DOH *name);
|
extern DOH *DohGetattr(DOH *obj, DOH *name);
|
||||||
extern int DohGetattrf(DOH *obj, DOH *name, char *fmt, ...);
|
|
||||||
extern int DohSetattr(DOH *obj, DOH *name, DOH *value);
|
extern int DohSetattr(DOH *obj, DOH *name, DOH *value);
|
||||||
extern int DohSetattrf(DOH *obj, DOH *name, char *fmt, ...);
|
|
||||||
extern void DohDelattr(DOH *obj, DOH *name);
|
extern void DohDelattr(DOH *obj, DOH *name);
|
||||||
extern int DohHashval(DOH *obj);
|
extern int DohHashval(DOH *obj);
|
||||||
extern DOH *DohGetitem(DOH *obj, int index);
|
extern DOH *DohGetitem(DOH *obj, int index);
|
||||||
|
|
@ -172,9 +171,7 @@ extern int DohvPrintf(DOH *obj, char *format, va_list ap);
|
||||||
#define Dump DohDump
|
#define Dump DohDump
|
||||||
#define Signature DohSignature
|
#define Signature DohSignature
|
||||||
#define Getattr DohGetattr
|
#define Getattr DohGetattr
|
||||||
#define Getattrf DohGetattrf
|
|
||||||
#define Setattr DohSetattr
|
#define Setattr DohSetattr
|
||||||
#define Setattrf DohSetattrf
|
|
||||||
#define Delattr DohDelattr
|
#define Delattr DohDelattr
|
||||||
#define Hashval DohHashval
|
#define Hashval DohHashval
|
||||||
#define Getitem DohGetitem
|
#define Getitem DohGetitem
|
||||||
|
|
@ -283,4 +280,14 @@ extern DOH *NewVoid(void *ptr, void (*del)(void *));
|
||||||
extern DOH *DohSplit(DOH *input, char *chs, int nsplits);
|
extern DOH *DohSplit(DOH *input, char *chs, int nsplits);
|
||||||
#define Split DohSplit
|
#define Split DohSplit
|
||||||
|
|
||||||
|
/* -----------------------------------------------------------------------------
|
||||||
|
* Error handling levels.
|
||||||
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#define DOH_UNSUPPORTED 1
|
||||||
|
#define DOH_UNKNOWN 2
|
||||||
|
#define DOH_CONVERSION 3
|
||||||
|
#define DOH_CALLS 10
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
29
Source/DOH/Makefile.in
Normal file
29
Source/DOH/Makefile.in
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
##############################################################
|
||||||
|
# Makefile
|
||||||
|
#
|
||||||
|
# DOH
|
||||||
|
##############################################################
|
||||||
|
|
||||||
|
prefix = @prefix@
|
||||||
|
exec_prefix= @exec_prefix@
|
||||||
|
|
||||||
|
INCLUDE_DIR = $(prefix)/include
|
||||||
|
LIB_DIR = $(exec_prefix)/lib
|
||||||
|
|
||||||
|
# Installer
|
||||||
|
|
||||||
|
INSTALL = ./install-sh -c
|
||||||
|
INSTALL_DATA = ${INSTALL} -m 644
|
||||||
|
INSTALL_PROGRAM= ${INSTALL} -m 755
|
||||||
|
|
||||||
|
all:
|
||||||
|
cd Doh; $(MAKE)
|
||||||
|
|
||||||
|
install:
|
||||||
|
@echo "Installing $(LIB_DIR)/libdoh.a..."
|
||||||
|
@$(INSTALL_DATA) libdoh.a $(LIB_DIR)/libdoh.a
|
||||||
|
@echo "Installing $(INCLUDE_DIR)/doh.h..."
|
||||||
|
@$(INSTALL_DATA) Include/doh.h $(INCLUDE_DIR)/doh.h
|
||||||
|
|
||||||
|
clean:
|
||||||
|
cd Doh; $(MAKE) clean
|
||||||
44
Source/DOH/configure.in
Normal file
44
Source/DOH/configure.in
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
dnl Process this file with autoconf to produce a configure script.
|
||||||
|
AC_INIT(Include/doh.h)
|
||||||
|
AC_PREREQ(2.0)
|
||||||
|
|
||||||
|
# Set name for machine-dependent library files
|
||||||
|
AC_SUBST(MACHDEP)
|
||||||
|
AC_MSG_CHECKING(MACHDEP)
|
||||||
|
if test -z "$MACHDEP"
|
||||||
|
then
|
||||||
|
if test -f /usr/lib/NextStep/software_version; then
|
||||||
|
set X `hostinfo | grep 'NeXT Mach.*:' | \
|
||||||
|
sed -e 's/://' -e 's/\./_/'` && \
|
||||||
|
ac_sys_system=next && ac_sys_release=$4
|
||||||
|
MACHDEP="$ac_sys_system$ac_sys_release$ac_sys_cpu"
|
||||||
|
else
|
||||||
|
ac_sys_system=`uname -s`
|
||||||
|
if test "$ac_sys_system" = "AIX" ; then
|
||||||
|
ac_sys_release=`uname -v`
|
||||||
|
else
|
||||||
|
ac_sys_release=`uname -r`
|
||||||
|
fi
|
||||||
|
ac_md_system=`echo $ac_sys_system |
|
||||||
|
tr -d '[/ ]' | tr '[[A-Z]]' '[[a-z]]'`
|
||||||
|
ac_md_release=`echo $ac_sys_release |
|
||||||
|
tr -d '[/ ]' | sed 's/\..*//'`
|
||||||
|
MACHDEP="$ac_md_system$ac_md_release"
|
||||||
|
fi
|
||||||
|
case MACHDEP in
|
||||||
|
'') MACHDEP=unknown;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
|
AC_MSG_RESULT($MACHDEP)
|
||||||
|
|
||||||
|
AC_PROG_CC
|
||||||
|
AC_PROG_RANLIB
|
||||||
|
|
||||||
|
AC_SUBST(AR)
|
||||||
|
AC_CHECK_PROGS(AR, ar aal, ar)
|
||||||
|
|
||||||
|
dnl Checks for header files.
|
||||||
|
AC_HEADER_STDC
|
||||||
|
dnl Checks for library functions.
|
||||||
|
|
||||||
|
AC_OUTPUT(Makefile Doh/Makefile)
|
||||||
Loading…
Add table
Add a link
Reference in a new issue