pike.git / src / modules / Gz / zlibmod.c

version» Context lines:

pike.git/src/modules/Gz/zlibmod.c:1:   ;/*\   ||| This file is part of Pike. For copyright information see COPYRIGHT.   ||| Pike is distributed under GPL, LGPL and MPL. See the file COPYING   ||| for more information.   \*/   /**/   #include "global.h" - RCSID("$Id: zlibmod.c,v 1.49 2002/08/26 09:08:33 grendel Exp $"); + RCSID("$Id: zlibmod.c,v 1.50 2002/09/10 14:31:26 grubba Exp $");      #include "zlib_machine.h"      #if !defined(HAVE_LIBZ) && !defined(HAVE_LIBGZ)   #undef HAVE_ZLIB_H   #endif      #ifdef HAVE_ZLIB_H      #include "interpret.h"
pike.git/src/modules/Gz/zlibmod.c:676:    }       res = gzwrite(THIS->gzfile,    sp[-args].u.string->str,    (unsigned INT32)sp[-args].u.string->len);       pop_n_elems(args);    push_int(res);   }    + #ifdef HAVE_GZSEEK   /*! @decl int seek(int pos, void|int type) -  *! Seeks within the file. +  *! Seeks within the file.    *! @param pos -  *! Position relative to the searchtype. +  *! Position relative to the searchtype.    *! @param type -  *! SEEK_SET = set current position in file to pos -  *! SEEK_CUR = new position is current+pos -  *! SEEK_END is not supported. +  *! SEEK_SET = set current position in file to pos +  *! SEEK_CUR = new position is current+pos +  *! SEEK_END is not supported.    *! @returns -  *! New position or negative number if seek failed. +  *! New position or negative number if seek failed. +  *! +  *! @note +  *! Not supported on all operating systems.    */   void gz_file_seek(INT32 args)   {    int res, newpos;    int type = SEEK_SET;       if (args>2) {    Pike_error("Bad number of arguments to file->seek()\n"    "Got %d, expected 1 or 2.\n", args);    }
pike.git/src/modules/Gz/zlibmod.c:720:    }       newpos = sp[-args].u.integer;       pop_n_elems(args);       res = gzseek(THIS->gzfile, newpos, type);       push_int(res);   } + #endif /* HAVE_GZSEEK */    - /*! @decl int seek() + #ifdef HAVE_GZTELL + /*! @decl int tell()    *! @returns    *! the current position within the file. -  +  *! +  *! @note +  *! Not supported on all operating systems.    */   void gz_file_tell(INT32 args)   {    if (args!=0) {    Pike_error("Bad number of arguments to file->tell()\n"    "Got %d, expected 0.\n", args);    }       if (THIS->gzfile == NULL) {    Pike_error("File not open!\n");    }       push_int(gztell(THIS->gzfile));      } -  + #endif /* HAVE_GZTELL */    -  + #ifdef HAVE_GZEOF   /*! @decl int(0..1) eof()    *! @returns    *! 1 if EOF has been reached. -  +  *! +  *! @note +  *! Not supported on all operating systems.    */   void gz_file_eof(INT32 args)   {    if (args!=0) {    Pike_error("Bad number of arguments to file->eof()\n"    "Got %d, expected 0.\n", args);    }       push_int(gzeof(THIS->gzfile));   } -  + #endif /* HAVE_GZEOF */    -  + #ifdef HAVE_GZSETPARAMS   /*! @decl int setparams(int level, int strategy) -  *! Sets the encoding level and strategy +  *! Sets the encoding level and strategy    *! @param level -  *! Level of the compression. -  *! 0 is the least compression, 9 is max. 8 is default. +  *! Level of the compression. +  *! 0 is the least compression, 9 is max. 8 is default.    *! @param strategy -  *! Set strategy for encoding to one of the following: -  *! Z_DEFAULT_STRATEGY -  *! Z_FILTERED -  *! Z_HUFFMAN_ONLY +  *! Set strategy for encoding to one of the following: +  *! Z_DEFAULT_STRATEGY +  *! Z_FILTERED +  *! Z_HUFFMAN_ONLY +  *! +  *! @note +  *! Not supported on all operating systems.    */   void gz_file_setparams(INT32 args)   {    int res;    if (args!=2) {    Pike_error("Bad number of arguments to file->setparams()\n"    "Got %d, expected 2.\n", args);    }       if (sp[-args].type != PIKE_T_INT ||
pike.git/src/modules/Gz/zlibmod.c:785:    Pike_error("Bad type in argument\n");    }       res = gzsetparams(THIS->gzfile,    sp[-args].u.integer,    sp[1-args].u.integer);       pop_n_elems(args);    push_int(res == Z_OK);   } + #endif /* HAVE_GZSETPARAMS */      static void init_gz_file(struct object *o)   {    mt_init(& THIS->lock);    THIS->gzfile = NULL;   }      static void exit_gz_file(struct object *o)   {    if (THIS->gzfile != NULL)
pike.git/src/modules/Gz/zlibmod.c:856: Inside #if defined(HAVE_ZLIB_H)
   end_class("inflate",0);       start_new_program();    ADD_STORAGE(struct zipper);       ADD_FUNCTION("create", gz_file_create, tFunc(tOr(tVoid, tString) tOr(tVoid, tString), tVoid), 0);    ADD_FUNCTION("open", gz_file_open, tFunc(tString tOr(tVoid, tString), tInt), 0);    ADD_FUNCTION("close", gz_file_close, tFunc(tVoid, tInt), 0);    ADD_FUNCTION("read", gz_file_read, tFunc(tInt,tOr(tString,tInt)), 0);    ADD_FUNCTION("write", gz_file_write, tFunc(tString,tInt), 0); + #ifdef HAVE_GZSEEK    ADD_FUNCTION("seek", gz_file_seek, tFunc(tInt tOr(tVoid,tInt), tInt), 0); -  + #endif /* HAVE_GZSEEK */ + #ifdef HAVE_GZTELL    ADD_FUNCTION("tell", gz_file_tell, tFunc(tVoid, tInt), 0); -  + #endif /* HAVE_GZTELL */ + #ifdef HAVE_GZEOF    ADD_FUNCTION("eof", gz_file_eof, tFunc(tVoid, tInt), 0); -  + #endif /* HAVE_GZEOF */ + #ifdef HAVE_GZSETPARAMS    ADD_FUNCTION("setparams", gz_file_setparams, tFunc(tInt tInt, tInt), 0); -  + #endif /* HAVE_GZSETPARAMS */       add_integer_constant("SEEK_SET", SEEK_SET, 0);    add_integer_constant("SEEK_CUR", SEEK_CUR, 0);    add_integer_constant("Z_DEFAULT_STRATEGY", Z_DEFAULT_STRATEGY,0);    add_integer_constant("Z_FILTERED", Z_FILTERED,0);    add_integer_constant("Z_HUFFMAN_ONLY", Z_HUFFMAN_ONLY,0);    set_init_callback(init_gz_file);    set_exit_callback(exit_gz_file);    end_class("_file", 0);