Still another set of File I/O routines
Posted in 1995
With the flood of file I/O routine libraries hitting the Net lately, thought I'd join the party. Here is my take on the file I/O problem with regards to 4GL. Routines included: * openfile(charstr filename, int file_flags) RETURNING int file_descriptor * closefile(int file_descriptor) RETURNING int error_num * * readchar(int file_descriptor) RETURNING int error_num, char character_read * readline(int file_descriptor) RETURNING int error_num, charstr line_read * * writechar(int file_descriptor, char char_to_write) RETURNING int error_num * writeline(int file_descriptor, charstr line_to_write, int str_length, int add_newline) * RETURNING int error_num * * tmpfilename(charstr temp_dir_name, charstr tempfile_name_prefix) * RETURNING int error_num, charstr temporary_filename * * getprocid() RETURNING int pid * * getpprocid() RETURNING int ppid * * deletefile(charstr filename_to_delete) RETURNING int error_num * * statfile(charstr filename_to_stat) * RETURNING int error_num, * charstr owner_name, * charstr group_name, * charstr mode_string, Ex: 664 * long file_size, * int file_type, Ex: FT_PLAINFILE, FT_DIRECTORY, etc. * charstr last_access_time, Ex: "1994-12-31 23:59:59" * charstr last_modification_time, Ex: "1994-12-31 23:59:59" * charstr last_status_change_time Ex: "1994-12-31 23:59:59" * * createfile(charstr filename_to_create) RETURNING int error_num * * purgefile(charstr filename_to_purge) RETURNING int error_num * (Has a problem....) * * fileseek(int file_descriptor, long offset, int origin) RETURNING int error_num * * renamefile(charstr orig_file_name, charstr new_file_name) RETURNING int error_num * * filetell(int file_descriptor) RETURNING long offset And here's the shar... : "@(#)shar.sh 1.8" #! /bin/sh # # This is a shell archive. # Remove everything above this line and run sh on the resulting file. # If this archive is complete, you will see this message at the end: # "All files extracted" # # Created: Fri Apr 21 09:32:57 MDT 1995 by miker at UCAR # Files archived in this archive: # Makefile # README # fgiusr.c # file_io.1 # file_io.c # file_io_setup.4gl # global_defs.4gl # global_defs.h # #-------------------- if [ -f Makefile -a "$1" != "-c" ] then echo shar: Makefile already exists else echo 'x - Makefile (238 characters)' sed -e 's/^X//' >Makefile <<'SHAR-EOF' X X Xall: customfglgo customfgldb X Xcustomfglgo: fgiusr.c file_io.o X cfglgo fgiusr.c $(LDFLAGS) $(LIBS) -o customfglgo X Xcustomfgldb: fgiusr.c file_io.o X cfgldb fgiusr.c $(LDFLAGS) $(LIBS) -o customfgldb X Xfile_io.o:file_io.c X cc -c file_io.c X SHAR-EOF if [ `wc -c <Makefile` -ne 238 ] then echo shar: Makefile unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f README -a "$1" != "-c" ] then echo shar: README already exists else echo 'x - README (64 characters)' sed -e 's/^X//' >README <<'SHAR-EOF' XThis is a set of File I/O Routines for Informix 4GL Xprograms. X X SHAR-EOF if [ `wc -c <README` -ne 64 ] then echo shar: README unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f fgiusr.c -a "$1" != "-c" ] then echo shar: fgiusr.c already exists else echo 'x - fgiusr.c (2519 characters)' sed -e 's/^X//' >fgiusr.c <<'SHAR-EOF' X/*************************************************************************** X * X * INFORMIX SOFTWARE, INC. X * X * PROPRIETARY DATA X * X * THIS DOCUMENT CONTAINS TRADE SECRET DATA WHICH IS THE PROPERTY OF X * INFORMIX SOFTWARE, INC. THIS DOCUMENT IS SUBMITTED TO RECIPIENT IN X * CONFIDENCE. INFORMATION CONTAINED HEREIN MAY NOT BE USED, COPIED OR X * DISCLOSED IN WHOLE OR IN PART EXCEPT AS PERMITTED BY WRITTEN AGREEMENT X * SIGNED BY AN OFFICER OF INFORMIX SOFTWARE, INC. X * X * THIS MATERIAL IS ALSO COPYRIGHTED AS AN UNPUBLISHED WORK UNDER X * SECTIONS 104 AND 408 OF TITLE 17 OF THE UNITED STATES CODE. X * UNAUTHORIZED USE, COPYING OR OTHER REPRODUCTION IS PROHIBITED BY LAW. X * X * X * Title: fgiusr.c X * Sccsid: @(#)fgiusr.c 7.2 7/8/90 13:50:19 X * Description: X * definition of user C functions X * X *************************************************************************** X */ X X/*************************************************************************** X * X * This table is for user-defined C functions. X * X * Each initializer has the form: X * X * "name", name, nargs, X * X * Variable # of arguments: X * X * set nargs to -(maximum # args) X * X * Be sure to declare name before the table and to leave the X * line of 0's at the end of the table. X * X * Example: X * X * You want to call your C function named "mycfunc" and it expects X * 2 arguments. You must declare it: X * X * int mycfunc(); X * X * and then insert an initializer for it in the table: X * X * "mycfunc", mycfunc, 2, X * X *************************************************************************** X */ X X#include "fgicfunc.h" X Xint openfile(); Xint readchar(); Xint readline(); Xint writechar(); Xint writeline(); Xint closefile(); Xint tmpfilename(); Xint getprocid(); Xint getpprocid(); Xint statfile(); Xint deletefile(); Xint createfile(); Xint purgefile(); Xint fileseek(); Xint renamefile(); Xint filetell(); Xint upshift(); Xint downshift(); X X Xcfunc_t usrcfuncs[] = X { X "openfile", openfile, 2, X "readchar", readchar, 1, X "readline", readline, 1, X "writechar", writechar, 2, X "writeline", writeline, 4, X "closefile", closefile, 1, X "tmpfilename", tmpfilename, 2, X "getprocid", getprocid, 0, X "getpprocid", getpprocid, 0, X "statfile", statfile, 1, X "deletefile", deletefile, 1, X "createfile", createfile, 1, X "purgefile", purgefile, 1, X "fileseek", fileseek, 3, X "renamefile", renamefile, 2, X "filetell", filetell, 1, X "redraw", redraw, 0, X "redraw_screen", redraw_screen, 0, X 0, 0, 0 X }; SHAR-EOF if [ `wc -c <fgiusr.c` -ne 2519 ] then echo shar: fgiusr.c unpacked with wrong size fi # end of overwriting check fi #-------------------- if [ -f file_io.1 -a "$1" != "-c" ] then echo shar: file_io.1 already exists else echo 'x - file_io.1 (22978 characters)' sed -e 's/^X//' >file_io.1 <<'SHAR-EOF' X.\\" @(#)file