diff --git a/.gitattributes b/.gitattributes index 5b10394de6fe236ca5648cd6a5b64cff3d42779a..4e4bd74de8fa220b537b0067f8df2e5f21ea1deb 100644 --- a/.gitattributes +++ b/.gitattributes @@ -47,6 +47,7 @@ testfont binary /src/modules/image/togif.c foreign_ident /src/modules/pipe/pipe.c foreign_ident /src/modules/sprintf/sprintf.c foreign_ident +/src/modules/zlibmod/zlibmod.c foreign_ident /src/object.c foreign_ident /src/operators.c foreign_ident /src/pike_types.c foreign_ident diff --git a/src/ChangeLog b/src/ChangeLog index 499b87c9f62fd8797086cc425275ae436ad0c638..d90036bc4d058cdbdd4e628febfc828fb0982331 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +Fri Nov 15 21:09:10 1996 Fredrik Hubinette <hubbe@cytocin.hubbe.net> + + * support for zlib added + Thu Nov 7 20:49:42 1996 Fredrik Hubinette <hubbe@tymin.signum.se> * 'constant foo=<value>;' implemented on top level diff --git a/src/configure.in b/src/configure.in index 4c063c1e2a0b735082a04b9ce7328c98e0e6ba7d..22de0f1a68d332283325910067a464dabd56a830 100644 --- a/src/configure.in +++ b/src/configure.in @@ -1,4 +1,4 @@ -# $Id: configure.in,v 1.13 1996/11/14 01:24:08 hubbe Exp $ +# $Id: configure.in,v 1.14 1996/11/16 05:17:08 hubbe Exp $ AC_INIT(interpret.c) @@ -16,6 +16,7 @@ AC_ARG_WITH(gmp, [ --without-gmp no Support bignums]) AC_ARG_WITH(readline,[ --without-readline no support for command line editing]) AC_ARG_WITH(debug, [ --without-debug disable run time self tests],[],[with_debug=yes]) AC_ARG_WITH(threads, [ --without-threads no threads support],[],[with_threads=yes]) +AC_ARG_WITH(zlib, [ --without-zlib no gz compression suppoort],[],[with_zlib=yes]) if test x$with_debug = xyes ; then AC_DEFINE(DEBUG) diff --git a/src/dynamic_buffer.c b/src/dynamic_buffer.c index 9dd46079b34fefb4fc9fee9a423c188d6170b4f5..a606120e2bbea8cc46d28f5c82fe6c46abd13a82 100644 --- a/src/dynamic_buffer.c +++ b/src/dynamic_buffer.c @@ -54,16 +54,24 @@ void low_my_binary_strcat(const char *b,INT32 l,dynamic_buffer *buf) MEMCPY(low_make_buf_space(l,buf),b,l); } -void low_init_buf(dynamic_buffer *buf) +void initialize_buf(dynamic_buffer *buf) { - if(!buf->s.str) - buf->s.str=(char *)xalloc((buf->bufsize=BUFFER_BEGIN_SIZE)); - if(!buf->s.str) - error("Out of memory.\n"); + buf->s.str=(char *)xalloc((buf->bufsize=BUFFER_BEGIN_SIZE)); *(buf->s.str)=0; buf->s.len=0; } +void low_reinit_buf(dynamic_buffer *buf) +{ + if(!buf->s.str) + { + initialize_buf(buf); + }else{ + *(buf->s.str)=0; + buf->s.len=0; + } +} + void low_init_buf_with_string(string s,dynamic_buffer *buf) { if(buf->s.str) { free(buf->s.str); buf->s.str=NULL; } @@ -114,7 +122,7 @@ char *make_buf_space(INT32 space) { return low_make_buf_space(space,&buff); } void my_putchar(char b) { low_my_putchar(b,&buff); } void my_binary_strcat(const char *b,INT32 l) { low_my_binary_strcat(b,l,&buff); } void my_strcat(const char *b) { my_binary_strcat(b,strlen(b)); } -void init_buf(void) { low_init_buf(&buff); } +void init_buf(void) { low_reinit_buf(&buff); } void init_buf_with_string(string s) { low_init_buf_with_string(s,&buff); } char *return_buf(void) { diff --git a/src/dynamic_buffer.h b/src/dynamic_buffer.h index c021f9bf9341db8cb56b70602c389e3566eccab9..50d6fce474e2549a490487fb47988dad10128159 100644 --- a/src/dynamic_buffer.h +++ b/src/dynamic_buffer.h @@ -30,7 +30,8 @@ typedef struct dynamic_buffer_s dynamic_buffer; char *low_make_buf_space(INT32 space,dynamic_buffer *buf); void low_my_putchar(char b,dynamic_buffer *buf); void low_my_binary_strcat(const char *b,INT32 l,dynamic_buffer *buf); -void low_init_buf(dynamic_buffer *buf); +void initialize_buf(dynamic_buffer *buf); +void low_reinit_buf(dynamic_buffer *buf); void low_init_buf_with_string(string s,dynamic_buffer *buf); string complex_free_buf(void); void toss_buffer(dynamic_buffer *buf); diff --git a/src/modules/files/file.c b/src/modules/files/file.c index 020b97ca43fc506a76cd1e0e8ae66564ba64953d..233680c2f5709408075a60693731204e6adddf1a 100644 --- a/src/modules/files/file.c +++ b/src/modules/files/file.c @@ -6,7 +6,7 @@ #define READ_BUFFER 16384 #include "global.h" -RCSID("$Id: file.c,v 1.11 1996/11/14 01:36:33 hubbe Exp $"); +RCSID("$Id: file.c,v 1.12 1996/11/16 05:17:11 hubbe Exp $"); #include "types.h" #include "interpret.h" #include "svalue.h" @@ -302,7 +302,7 @@ static void file_read(INT32 args) dynamic_buffer b; b.s.str=0; - low_init_buf(&b); + initialize_buf(&b); SET_ONERROR(ebuf, free_dynamic_buffer, &b); do{ int fd=FD; diff --git a/src/modules/image/togif.c b/src/modules/image/togif.c index 64dbfe3f3c20e49f8f4e9945aa9215420872e785..8646a7569d0b31dd91a1309b44c455bfd88c053e 100644 --- a/src/modules/image/togif.c +++ b/src/modules/image/togif.c @@ -1,4 +1,4 @@ -/* $Id: togif.c,v 1.11 1996/11/14 12:35:05 law Exp $ */ +/* $Id: togif.c,v 1.12 1996/11/16 05:17:12 hubbe Exp $ */ /* togif @@ -160,7 +160,7 @@ struct pike_string * struct lzw lzw; buf.s.str=NULL; - low_init_buf(&buf); + initialize_buf(&buf); low_my_binary_strcat(transparent?"GIF89a":"GIF87a",6,&buf); buf_word((unsigned short)img->xsize,&buf); @@ -473,7 +473,7 @@ void image_gif_begin(INT32 args) pop_n_elems(args); buf.s.str=NULL; - low_init_buf(&buf); + initialize_buf(&buf); low_my_binary_strcat("GIF89a",6,&buf); buf_word((unsigned short)THIS->xsize,&buf); @@ -521,7 +521,7 @@ static void img_gif_add(INT32 args,int fs) dynamic_buffer buf; buf.s.str=NULL; - low_init_buf(&buf); + initialize_buf(&buf); if (args==0) x=y=0; else if (sp[-args].type!=T_INT diff --git a/src/modules/spider/encode_decode.c b/src/modules/spider/encode_decode.c index 725e232b13b3526ef3270c6a77b205eadd607a82..e375c1836f31afad8e5ada8a80f89bc1279cdec6 100644 --- a/src/modules/spider/encode_decode.c +++ b/src/modules/spider/encode_decode.c @@ -190,11 +190,7 @@ void f_encode_value(INT32 args) { dynamic_buffer buff; - buff.s.str = NULL; - buff.s.len = 0; - buff.bufsize = 0; - - low_init_buf(&buff); + initialize_buf(&buff); rec_save_value(sp-args, &buff, NULL); diff --git a/src/modules/zlibmod/.cvsignore b/src/modules/zlibmod/.cvsignore new file mode 100644 index 0000000000000000000000000000000000000000..64200ddc24cb90d8f410a6a9e2b0b79c4cd30d58 --- /dev/null +++ b/src/modules/zlibmod/.cvsignore @@ -0,0 +1,2 @@ +Makefile.in +configure diff --git a/src/modules/zlibmod/.gitignore b/src/modules/zlibmod/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..addfc0376f648196d317f7f7299705f23cb23c21 --- /dev/null +++ b/src/modules/zlibmod/.gitignore @@ -0,0 +1,2 @@ +/Makefile.in +/configure diff --git a/src/modules/zlibmod/Makefile.src b/src/modules/zlibmod/Makefile.src new file mode 100644 index 0000000000000000000000000000000000000000..e7ea5fea70fa238e767416f6389a057ee7f72f8e --- /dev/null +++ b/src/modules/zlibmod/Makefile.src @@ -0,0 +1,35 @@ +SRCDIR=@srcdir@ +VPATH=@srcdir@:@srcdir@/../..:../.. +PREFLAGS=$(DEFINES) -I. -I$(SRCDIR) -I$(SRCDIR)/../.. -I../.. +CFLAGS=$(PREFLAGS) $(OTHERFLAGS) + +FILES=zlibmod.o +LIB=zlibmod.a + +$(LIB): $(FILES) + -rm -f $(LIB) + ar cq $(LIB) $(FILES) + -@RANLIB@ $(LIB) + echo >linker_options @LIBS@ + +clean: + -rm -f *.o *.a + +depend: + gcc -MM $(PREFLAGS) $(SRCDIR)/*.c | $(TMP_BINDIR)/fixdepends.sh $(SRCDIR) + +#verify / debug +module_testsuite: $(SRCDIR)/testsuite.in + $(TMP_BINDIR)/mktestsuite $(SRCDIR)/testsuite.in >module_testsuite + +verify: module_testsuite + $(RUNPIKE) $(TMP_BINDIR)/test_pike.pike module_testsuite + +verbose_verify: module_testsuite + $(RUNPIKE) $(TMP_BINDIR)/test_pike.pike module_testsuite --verbose + +gdb_verify: module_testsuite + @echo >.gdbinit handle SIGUSR1 nostop noprint pass + @echo >>.gdbinit run -m @srcdir@/../../../lib/master.pike $(PIKEOPTS) @srcdir@/../../../bin/test_pike.pike module_testsuite -v -v -f + gdb ../../pike + @rm .gdbinit diff --git a/src/modules/zlibmod/configure.in b/src/modules/zlibmod/configure.in new file mode 100644 index 0000000000000000000000000000000000000000..04c676995366b13a67d5c080cbd2ba37d3c1dea5 --- /dev/null +++ b/src/modules/zlibmod/configure.in @@ -0,0 +1,19 @@ +AC_INIT(zlibmod.c) +AC_CONFIG_HEADER(zlib_machine.h) +AC_ARG_WITH(zlib, [ --with(out)-zlib Support gzip compression],[],[with_zlib=yes]) + +AC_PROG_CC +AC_PROG_RANLIB +AC_SUBST(RANLIB) + +if test x$with_zlib = xyes ; then + AC_CHECK_HEADERS(zlib.h) + if test $ac_cv_header_zlib_h = yes ; then + AC_CHECK_LIB(z, compress, [[LIBS="${LIBS-} -lz"]], + AC_CHECK_LIB(gz, compress)) + fi +fi + +AC_OUTPUT(Makefile,echo FOO >stamp-h ) + + diff --git a/src/modules/zlibmod/testsuite.in b/src/modules/zlibmod/testsuite.in new file mode 100644 index 0000000000000000000000000000000000000000..80f70561ca84b209c8b6d18bf8b0b3e040933209 --- /dev/null +++ b/src/modules/zlibmod/testsuite.in @@ -0,0 +1,2 @@ +test_true(Gz_deflate()) +test_true(Gz_inflate()) diff --git a/src/modules/zlibmod/zlib_machine.h.in b/src/modules/zlibmod/zlib_machine.h.in new file mode 100644 index 0000000000000000000000000000000000000000..7751a13fcd8c43413bf8bea820c72dfc7e0659ea --- /dev/null +++ b/src/modules/zlibmod/zlib_machine.h.in @@ -0,0 +1,13 @@ +#ifndef GMP_MACHINE_H +#define GMP_MACHINE_H + +/* Define this if you have <libz.h> */ +#undef HAVE_ZLIB_H + +/* Define this if you have -lz */ +#undef HAVE_LIBZ + +/* Define this if you have -lgz */ +#undef HAVE_LIBGZ + +#endif diff --git a/src/modules/zlibmod/zlibmod.c b/src/modules/zlibmod/zlibmod.c new file mode 100644 index 0000000000000000000000000000000000000000..1fb6207c42af96ff72150d2cc82e49f273fd198a --- /dev/null +++ b/src/modules/zlibmod/zlibmod.c @@ -0,0 +1,374 @@ +/*\ +||| This file a part of Pike, and is copyright by Fredrik Hubinette +||| Pike is distributed as GPL (General Public License) +||| See the files COPYING and DISCLAIMER for more information. +\*/ +#include "global.h" +RCSID("$Id: zlibmod.c,v 1.1 1996/11/16 05:17:15 hubbe Exp $"); + +#include "zlib_machine.h" +#include "types.h" + +#if !defined(HAVE_LIBZ) && !defined(HAVE_LIBGZ) +#undef HAVE_ZLIB_H +#endif + +#ifdef HAVE_ZLIB_H + +#include "interpret.h" +#include "svalue.h" +#include "stralloc.h" +#include "array.h" +#include "macros.h" +#include "program.h" +#include "stralloc.h" +#include "object.h" +#include "pike_types.h" +#include "threads.h" +#include "dynamic_buffer.h" + +#include <zlib.h> + +struct zipper +{ + struct z_stream_s gz; + DEFINE_MUTEX(lock); +}; + +#define BUF 16384 + +#define THIS ((struct zipper *)(fp->current_storage)) + +static void gz_deflate_create(INT32 args) +{ + int level=Z_DEFAULT_COMPRESSION; + + if(THIS->gz.state) + { + mt_lock(& this->lock); + deflateEnd(&THIS->gz); + mt_unlock(& this->lock); + } + + if(args) + { + if(sp[-args].type != T_INT) + error("Bad argument 1 to gz->create()\n"); + if(sp[-args].u.integer < Z_NO_COMPRESSION || + sp[-args].u.integer > Z_BEST_COMPRESSION) + { + error("Compression level out of range for gz_deflate->create()\n"); + } + } + + THIS->gz.zalloc=Z_NULL; + THIS->gz.zfree=Z_NULL; + THIS->gz.opaque=THIS; + + pop_n_elems(args); + mt_lock(& THIS->lock); + level=deflateInit(&THIS->gz, level); + mt_unlock(& THIS->lock); + switch(level) + { + case Z_OK: + return; + + case Z_VERSION_ERROR: + error("libz not compatible with zlib.h!!!\n"); + break; + + default: + if(THIS->gz.msg) + error("Failed to initialize gz_deflate: %s\n",THIS->gz.msg); + else + error("Failed to initialize gz_deflate\n"); + } +} + +static int do_deflate(dynamic_buffer *buf, + struct zipper *this, + int flush) +{ + int fail=0; + + THREADS_ALLOW(); + mt_lock(& this->lock); + if(!this->gz.state) + { + fail=Z_STREAM_ERROR; + }else{ + do + { + char *loc; + int ret; + loc=low_make_buf_space(BUF,buf); + this->gz.next_out=(Bytef *)loc; + this->gz.avail_out=BUF; + ret=deflate(& this->gz, flush); + low_make_buf_space(-this->gz.avail_out,buf); + if(ret != Z_OK) + { + fail=ret; + break; + } + } while(!this->gz.avail_out || flush==Z_FINISH || this->gz.avail_in); + } + + mt_unlock(& this->lock); + THREADS_DISALLOW(); + return fail; +} + +static void gz_deflate(INT32 args) +{ + struct pike_string *data; + int flush, fail; + struct zipper *this=THIS; + dynamic_buffer buf; + + if(!THIS->gz.state) + error("gz_deflate not initialized or destructed\n"); + + initialize_buf(&buf); + + if(args<1) + error("Too few arguments to gz_deflate->deflate()\n"); + + if(sp[-args].type != T_STRING) + error("Bad argument 1 to gz_deflate->deflate()\n"); + + data=sp[-args].u.string; + + if(args>1) + { + if(sp[1-args].type != T_INT) + error("Bad argument 2 to gz_deflate->deflate()\n"); + + flush=sp[1-args].u.integer; + + switch(flush) + { + case Z_PARTIAL_FLUSH: + case Z_FINISH: + case Z_SYNC_FLUSH: + case Z_NO_FLUSH: + break; + + defualt: + error("Argument 2 to gz_deflate->deflate() out of range.\n"); + } + }else{ + flush=Z_NO_FLUSH; + } + + this->gz.next_in=(Bytef *)data->str; + this->gz.avail_in=data->len; + + fail=do_deflate(&buf,this,flush); + pop_n_elems(args); + + if(fail != Z_OK && fail != Z_STREAM_END) + { + free(buf.s.str); + if(THIS->gz.msg) + error("Error in gz_deflate->deflate(): %s\n",THIS->gz.msg); + else + error("Error in gz_deflate->deflate(): %d\n",fail); + } + + push_string(low_free_buf(&buf)); +} + + +static void init_gz_deflate(struct object *o) +{ + mt_init(& THIS->locked); + MEMSET(& THIS->gz, 0, sizeof(THIS->gz)); + THIS->gz.zalloc=Z_NULL; + THIS->gz.zfree=Z_NULL; + THIS->gz.opaque=THIS; + deflateInit(& THIS->gz, Z_DEFAULT_COMPRESSION); +} + +static void exit_gz_deflate(struct object *o) +{ + mt_lock(& THIS->lock); + deflateEnd(&THIS->gz); + mt_unlock(& THIS->lock); +} + +/*******************************************************************/ + + +static void gz_inflate_create(INT32 args) +{ + int level; + if(THIS->gz.state) + { + mt_lock(this->lock); + inflateEnd(&THIS->gz); + mt_unlock(this->lock); + } + + + THIS->gz.zalloc=Z_NULL; + THIS->gz.zfree=Z_NULL; + THIS->gz.opaque=THIS; + + pop_n_elems(args); + mt_lock(THIS->lock); + level=inflateInit(& THIS->gz); + mt_unlock(THIS->lock); + switch(level) + { + case Z_OK: + return; + + case Z_VERSION_ERROR: + error("libz not compatible with zlib.h!!!\n"); + break; + + default: + if(THIS->gz.msg) + error("Failed to initialize gz_inflate: %s\n",THIS->gz.msg); + else + error("Failed to initialize gz_inflate\n"); + } +} + +static int do_inflate(dynamic_buffer *buf, + struct zipper *this, + int flush) +{ + int fail=0; + + THREADS_ALLOW(); + mt_lock(this->lock); + if(!this->gz.state) + { + fail=Z_STREAM_ERROR; + }else{ + do + { + char *loc; + int ret; + loc=low_make_buf_space(BUF,buf); + this->gz.next_out=(Bytef *)loc; + this->gz.avail_out=BUF; + ret=inflate(& this->gz, flush); + low_make_buf_space(-this->gz.avail_out,buf); + if(ret != Z_OK) + { + fail=ret; + break; + } + } while(!this->gz.avail_out || flush==Z_FINISH || this->gz.avail_in); + } + mt_unlock(this->lock); + THREADS_DISALLOW(); + return fail; +} + +static void gz_inflate(INT32 args) +{ + struct pike_string *data; + int fail; + struct zipper *this=THIS; + dynamic_buffer buf; + + if(!THIS->gz.state) + error("gz_inflate not initialized or destructed\n"); + + initialize_buf(&buf); + + if(args<1) + error("Too few arguments to gz_inflate->inflate()\n"); + + if(sp[-args].type != T_STRING) + error("Bad argument 1 to gz_inflate->inflate()\n"); + + data=sp[-args].u.string; + + this->gz.next_in=(Bytef *)data->str; + this->gz.avail_in=data->len; + + fail=do_inflate(&buf,this,Z_PARTIAL_FLUSH); + pop_n_elems(args); + + if(fail != Z_OK && fail != Z_STREAM_END) + { + free(buf.s.str); + if(THIS->gz.msg) + error("Error in gz_inflate->inflate(): %s\n",THIS->gz.msg); + else + error("Error in gz_inflate->inflate(): %d\n",fail); + } + push_string(low_free_buf(&buf)); + if(fail == Z_STREAM_END && !sp[-1].u.string->len) + { + pop_stack(); + push_int(0); + } +} + +static void init_gz_inflate(struct object *o) +{ + mt_init(THIS->locked); + MEMSET(& THIS->gz, 0, sizeof(THIS->gz)); + THIS->gz.zalloc=Z_NULL; + THIS->gz.zfree=Z_NULL; + THIS->gz.opaque=0; + inflateInit(&THIS->gz); + inflateEnd(&THIS->gz); +} + +static void exit_gz_inflate(struct object *o) +{ + mt_lock(& THIS->lock); + inflateEnd(& THIS->gz); + mt_unlock(& THIS->lock); +} + +#endif + +void init_zlibmod_efuns(void) {} +void exit_zlibmod(void) { } + +void init_zlibmod_programs(void) +{ +#ifdef HAVE_ZLIB_H + start_new_program(); + add_storage(sizeof(struct zipper)); + + add_function("create",gz_deflate_create,"function(int|void:void)",0); + add_function("deflate",gz_deflate,"function(string,int|void:string)",0); + + add_integer_constant("NO_FLUSH",Z_NO_FLUSH,0); + add_integer_constant("PARTIAL_FLUSH",Z_PARTIAL_FLUSH,0); + add_integer_constant("SYNC_FLUSH",Z_SYNC_FLUSH,0); + add_integer_constant("FINISH",Z_FINISH,0); + + set_init_callback(init_gz_deflate); + set_exit_callback(exit_gz_deflate); + + end_c_program("/precompiled/gz_deflate"); + + start_new_program(); + add_storage(sizeof(struct zipper)); + + add_function("create",gz_inflate_create,"function(int|void:void)",0); + add_function("inflate",gz_inflate,"function(string:string)",0); + + add_integer_constant("NO_FLUSH",Z_NO_FLUSH,0); + add_integer_constant("PARTIAL_FLUSH",Z_PARTIAL_FLUSH,0); + add_integer_constant("SYNC_FLUSH",Z_SYNC_FLUSH,0); + add_integer_constant("FINISH",Z_FINISH,0); + + set_init_callback(init_gz_inflate); + set_exit_callback(exit_gz_inflate); + + end_c_program("/precompiled/gz_inflate"); +#endif +} + diff --git a/src/peep.c b/src/peep.c index 354089388976f537c4cabda389a3e27694a6ce58..d68d59cda0434168e7b7200374ce76d44404b535 100644 --- a/src/peep.c +++ b/src/peep.c @@ -95,7 +95,7 @@ static int hasarg(int opcode) void init_bytecode() { - low_init_buf(&instrbuf); + low_reinit_buf(&instrbuf); } void exit_bytecode() diff --git a/src/program.c b/src/program.c index 25bcbc3088f3535dafd641f6e00ba52cb4d48e44..20b88befcf20246b9148448e714a29b63a91ec6f 100644 --- a/src/program.c +++ b/src/program.c @@ -4,7 +4,7 @@ ||| See the files COPYING and DISCLAIMER for more information. \*/ #include "global.h" -RCSID("$Id: program.c,v 1.6 1996/11/14 01:36:31 hubbe Exp $"); +RCSID("$Id: program.c,v 1.7 1996/11/16 05:17:10 hubbe Exp $"); #include "program.h" #include "object.h" #include "dynamic_buffer.h" @@ -133,8 +133,8 @@ void start_new_program() #undef PUSH #undef PROGRAM_STATE - for(e=0; e<NUM_AREAS; e++) low_init_buf(areas + e); - low_init_buf(& inherit_names); + for(e=0; e<NUM_AREAS; e++) low_reinit_buf(areas + e); + low_reinit_buf(& inherit_names); fake_program.id = ++current_program_id; inherit.prog=&fake_program; @@ -842,7 +842,7 @@ int add_constant(struct pike_string *name, #ifdef DEBUG if(name!=debug_findstring(name)) - fatal("define_variable on nonshared string.\n"); + fatal("define_constant on nonshared string.\n"); #endif setup_fake_program(); @@ -885,6 +885,23 @@ int add_constant(struct pike_string *name, return n; } +int add_integer_constant(char *name, + INT32 i, + INT32 flags) +{ + struct svalue tmp; + struct pike_string *id; + int ret; + tmp.u.integer=i; + tmp.type=T_INT; + tmp.subtype=NUMBER_NUMBER; + id=make_shared_string(name); + ret=add_constant(id,&tmp, flags); + free_string(id); + return ret; +} + + /* * define a new function * if func isn't given, it is supposed to be a prototype. diff --git a/src/program.h b/src/program.h index 268cad7a2920d02f10f4b5849b7b4c515185ac30..e327cb1906a06a97b7b5411add80bd9a1eeecba5 100644 --- a/src/program.h +++ b/src/program.h @@ -193,6 +193,9 @@ int define_variable(struct pike_string *name, int add_constant(struct pike_string *name, struct svalue *c, INT32 flags); +int add_integer_constant(char *name, + INT32 i, + INT32 flags); INT32 define_function(struct pike_string *name, struct pike_string *type, INT16 flags,