getdata-commits Mailing List for GetData (Page 14)
Scientific Database Format
Brought to you by:
ketiltrout
This list is closed, nobody may subscribe to it.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(5) |
Oct
(20) |
Nov
(21) |
Dec
(16) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2011 |
Jan
(1) |
Feb
(1) |
Mar
(56) |
Apr
(20) |
May
(4) |
Jun
(2) |
Jul
(3) |
Aug
(11) |
Sep
(2) |
Oct
(4) |
Nov
(18) |
Dec
(16) |
2012 |
Jan
(8) |
Feb
(12) |
Mar
(30) |
Apr
(13) |
May
(10) |
Jun
(17) |
Jul
(18) |
Aug
(19) |
Sep
|
Oct
(1) |
Nov
(1) |
Dec
(9) |
2013 |
Jan
(1) |
Feb
(4) |
Mar
(27) |
Apr
(6) |
May
(3) |
Jun
(1) |
Jul
(10) |
Aug
|
Sep
(3) |
Oct
(15) |
Nov
(4) |
Dec
(9) |
2014 |
Jan
|
Feb
(3) |
Mar
(4) |
Apr
(10) |
May
(15) |
Jun
|
Jul
(14) |
Aug
|
Sep
(2) |
Oct
(6) |
Nov
|
Dec
(9) |
2015 |
Jan
(2) |
Feb
(3) |
Mar
(1) |
Apr
(2) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <ket...@us...> - 2011-11-05 00:43:49
|
Revision: 610 http://getdata.svn.sourceforge.net/getdata/?rev=610&view=rev Author: ketiltrout Date: 2011-11-05 00:43:40 +0000 (Sat, 05 Nov 2011) Log Message: ----------- A major overhaul to the encoding framework to permit out-of-place writing of encoded raw data. T{Open,Move,Unlink} and Touch have been removed. In their place is a bookkeeping layer which takes care of calling various encoding functions when necessary and cleaning up after them. As a result: write support is now available for gzip compressed raw fields. Also added gd_sync which does half of what gd_flush does (sync but not close). Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/TODO trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/make_parameters.c trunk/getdata/configure.ac trunk/getdata/m4/encoding.m4 trunk/getdata/src/add.c trunk/getdata/src/ascii.c trunk/getdata/src/bzip.c trunk/getdata/src/close.c trunk/getdata/src/del.c trunk/getdata/src/encoding.c trunk/getdata/src/endian.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/gzip.c trunk/getdata/src/include.c trunk/getdata/src/internal.h trunk/getdata/src/lzma.c trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/name.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/raw.c trunk/getdata/src/sie.c trunk/getdata/src/slim.c trunk/getdata/test/Makefile.am trunk/getdata/test/alter_entry_recode.c trunk/getdata/test/gzip_put.c trunk/getdata/test/put_here.c trunk/getdata/test/put_heres.c trunk/getdata/test/put_rofs.c trunk/getdata/test/test.h Added Paths: ----------- trunk/getdata/test/ascii_add.c trunk/getdata/test/endian_alter_sie.c trunk/getdata/test/get_rofs.c trunk/getdata/test/gzip_add.c trunk/getdata/test/gzip_get_put.c trunk/getdata/test/gzip_move_to.c trunk/getdata/test/gzip_put_get.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/ChangeLog 2011-11-05 00:43:40 UTC (rev 610) @@ -1,3 +1,48 @@ +2011-11-05 D. V. Wiebe <ge...@ke...> svn:610 + * test/gzip_put_get.c test/ascii_add.c test/get_rofs.c test/gzip_move_to.c + test/gzip_add.c test/endian_alter_sie.c test/gzip_get_put.c: Added. + * test/gzip_put.c: Update. + + * m4/encoding.m4: Add a AC_CHECK_FUNCS call. + + * src/slim.c (_GD_SlimOpen): Update for the (non-existant) slimdopen(). + + * src/getdata.h.in: Renamed GD_SEEK_PAD to GD_SEEK_WRITE to better reflect + its purpose. + * bindings/idl/getdata.c (gdidl_seek): Update keywords for same. + + * src/flush.c (_GD_Flush): Add a third parameter, clo, to distinguish + sync from sync-and-close. + * src/flush.c (_GD_SyncOrClose): Renamed from gd_flush. + * src/flush.c (gd_sync gd_flush): Added. + + * src/internal.h: Added _gd_raw_file.mode. Replaced encoding_t.ecor with + encoding_t.flags; + * src/encoding.c: Deleted touch, topen, tmove, tunlink from the encoding + framework. Changed signature of open and seek. + * src/encoding.c (_GD_MoveOver): Renamed from _GD_GenericTMove. + * src/encoding.c (_GD_FiniRawIO) src/fpos.c (_GD_WriteSeek): Added. + * src/gzip.c (_GD_GzipOpen _GD_GzipSeek _GD_GzipClose) src/encoding.c + (_GD_InitRawIO): Update for out-of-place writes. + * src/endian.c (_GD_ByteSwapFragment) src/name.c (gd_rename) src/flush.c + (_GD_Flush) src/encoding.c (_GD_RecodeFragment) src/del.c (gd_delete) + src/flimits.c (_GD_ShiftFragment): Use _GD_FiniRawIO to clean up. + * src/encoding.c (_GD_GenericTouch) src/ascii.c (_GD_AsciiTOpen + _GD_AsciiTUnlink) src/sie.c (_GD_SampIndTOpen _GD_SampIndTUnlink) src/raw.c + (_GD_RawTOpen _GD_RawTUnlink): Deleted. + * src/move.c (_GD_MogrifyFile) src/mod.c (_GD_Change): Use _GD_FiniRawIO and + _GD_InitRawIO. + * src/parse.c (_GD_ParseFieldSpec) add.c (_GD_Add): Use _GD_InitRawIO for + touch. + * src/gzip.c (_GD_GzipOpen) src/ascii.c (_GD_AsciiOpen) src/sie.c + (_GD_SampIndDoOpen _GD_SampIndOpen) src/raw.c (_GD_RawOpen): Handle temp file + opens. + * src/putdata.c (_GD_DoRawOut) src/fpos.c (_GD_Seek): Use _GD_WriteSeek. + + * src/fpos.c (_GD_GetFilePos): Only try to open the file if necessary. + + * src/gzip.c (_GD_GzipWrite _GD_GzipSync): Added. + 2011-10-20 D. V. Wiebe <ge...@ke...> svn:609 * test/get_here_foffs.c test/seek_foffs.c: Added. Modified: trunk/getdata/TODO =================================================================== --- trunk/getdata/TODO 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/TODO 2011-11-05 00:43:40 UTC (rev 610) @@ -1,11 +1,8 @@ * Locking * Hashed compressed files -* Streaming/Appending * linterp table path munging [MH] * Make webpage suck less -* Handle RW dirfile on RO data better [JPF] + +* Fix VERSION leakage / Fragment encapsulation [MT/CBN] * INCLUDE name munging [RW/MT] -* Fix VERSION leakage [MT] * aliasing [MT] -* Fix REFERENCE spam [MT] -* Fragment encapsulation [MT/CBN] Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/bindings/idl/getdata.c 2011-11-05 00:43:40 UTC (rev 610) @@ -4711,13 +4711,13 @@ off64_t frame_num; off64_t sample_num; int whence; - int pad; + int write; } KW_RESULT; KW_RESULT kw; kw.whence = GD_SEEK_SET; kw.frame_num = kw.sample_num = 0; - kw.pad = 0; + kw.write = 0; GDIDL_KW_INIT_ERROR; static IDL_KW_PAR kw_pars[] = { @@ -4725,8 +4725,8 @@ GDIDL_KW_PAR_ESTRING, { "FRAME_NUM", IDL_TYP_LONG64, 1, 0, 0, IDL_KW_OFFSETOF(frame_num) }, { "SAMPLE_NUM", IDL_TYP_LONG64, 1, 0, 0, IDL_KW_OFFSETOF(sample_num) }, - { "PAD", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(pad) }, { "WHENCE", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(whence) }, + { "WRITE", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(write) }, { NULL } }; @@ -4737,7 +4737,7 @@ off64_t pos = gd_seek64(D, field_code, kw.frame_num, kw.sample_num, (kw.whence & (GD_SEEK_SET | GD_SEEK_CUR | GD_SEEK_END)) | - (kw.pad ? GD_SEEK_PAD : 0)); + (kw.write ? GD_SEEK_WRITE : 0)); GDIDL_SET_ERROR(D); Modified: trunk/getdata/bindings/make_parameters.c =================================================================== --- trunk/getdata/bindings/make_parameters.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/bindings/make_parameters.c 2011-11-05 00:43:40 UTC (rev 610) @@ -189,7 +189,7 @@ CONSTANT(SEEK_SET, "GDSK_S", 10), CONSTANT(SEEK_CUR, "GDSK_C", 10), CONSTANT(SEEK_END, "GDSK_E", 10), - CONSTANT(SEEK_PAD, "GDSK_P", 11), + CONSTANT(SEEK_WRITE, "GDSK_W", 11), CONSTANT(MAX_LINE_LENGTH, "GD_MLL", 99), CONSTANT(ALL_FRAGMENTS, "GD_ALL", 99), Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/configure.ac 2011-11-05 00:43:40 UTC (rev 610) @@ -414,7 +414,7 @@ LIBS=$saved_libs if test "x$have_ltdl" == "xno"; then - AC_MSG_ERROR([libltdl is required to build modules. Please either specify the location of the libltdl library using --with-ldtl-prefix=PREFIX or else disable the building of modules by using --disable-modules.]) + AC_MSG_ERROR([libltdl is required to build modules. Please either specify the location of the libltdl library using --with-ldtl=PREFIX or else disable the building of modules by using --disable-modules.]) fi if test "x$ltdl_prefix" != "x"; then @@ -660,7 +660,7 @@ echo AC_CHECK_FUNCS([_chsize _chsize_s _commit fchmod _fdopen fdopendir fseeko \ fseeko64 _fstat fstat64 _fstat64 fstatat fstatat64 fsync \ - ftello ftello64 ftruncate ftruncate64 _getcwd getdelim \ + ftello ftello64 ftruncate ftruncate64 getcwd _getcwd getdelim \ gmtime_r _lseeki64 lstat _mkdir nan _open openat _read \ renameat _rmdir _snprintf stat64 _stat64 _strtoi64 strtoll \ _strtoui64 strtoull _unlink unlinkat _write]) @@ -784,8 +784,9 @@ fi dnl external encodings -GD_CHECK_ENCODING([bzip2],[bz2],[BZ2_bzReadOpen],[bzlib.h],[bzip2],[bunzip2]) -GD_CHECK_ENCODING([slim],[slim],[slimopen],[slimlib.h],[slim slimdata],[unslim],[]) +GD_CHECK_ENCODING([bzip2],[bz2],[BZ2_bzReadOpen],[bzlib.h],[bzip2],[bunzip2],[]) +GD_CHECK_ENCODING([slim],[slim],[slimopen],[slimlib.h], [slim slimdata], + [unslim],[slimdopen]) GD_CHECK_ENCODING([gzip],[z],[gzopen],[zlib.h],[gzip],[gunzip],[]) GD_CHECK_ENCODING([lzma],[lzma],[lzma_auto_decoder],[lzma.h],[xz],[],[]) Modified: trunk/getdata/m4/encoding.m4 =================================================================== --- trunk/getdata/m4/encoding.m4 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/m4/encoding.m4 2011-11-05 00:43:40 UTC (rev 610) @@ -54,9 +54,14 @@ if test "x$gd_encoding[]_prefix" != "x"; then LDFLAGS="$LDFLAGS -L$gd_encoding[]_prefix/lib" fi - AC_CHECK_LIB([$2],[$3],[have_this_lib=yes] + AC_CHECK_LIB([$2],[$3],[have_this_lib=yes + LIBS="$LIBS -l$2"] AC_DEFINE(AS_TR_CPP([HAVE_LIB$2]), 1, [Define to 1 if you have the `$2' library (-l$2).])) + +ifelse(`x$7', `x',,[ + AC_CHECK_FUNCS([$7]) +]) LDFLAGS=$saved_ldflags LIBS=$saved_libs @@ -106,7 +111,6 @@ AC_DEFINE_UNQUOTED(AS_TR_CPP(gd_unprogname), ["$path_]gd_unprogname["], [ Define to the full path to the `]gd_unprogname[' binary ]) fi -$7 ]) AM_CONDITIONAL(AS_TR_CPP([USE_]gd_encoding), [test "x$use_]gd_encoding[" = "xyes"]) Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/add.c 2011-11-05 00:43:40 UTC (rev 610) @@ -210,16 +210,11 @@ else if (E->EN(raw,data_type) & 0x40 || (E->e->u.raw.size = GD_SIZE(E->EN(raw,data_type))) == 0) _GD_SetError(D, GD_E_BAD_TYPE, entry->EN(raw,data_type), NULL, 0, NULL); - else if (!_GD_Supports(D, E, GD_EF_TOUCH)) - ; /* error already set */ - else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) - ; /* error already set */ - else if ((*_gd_ef[E->e->u.raw.file[0].subenc].touch)( - D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - _GD_FileSwapBytes(D, E->fragment_index))) - _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, - NULL); - else if (D->fragment[E->fragment_index].ref_name == NULL) { + else if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, + GD_FILE_WRITE | GD_FILE_TOUCH, 0)) + { + ; + } else if (D->fragment[E->fragment_index].ref_name == NULL) { /* This is the first raw field in this fragment */ new_ref = strdup(E->field); if (new_ref == NULL) @@ -307,13 +302,13 @@ if ((E->in_fields[0] = strdup(entry->in_fields[0])) == NULL) _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); else if (E->EN(bit,numbits) < 1) - _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_NUMBITS, NULL, + _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_NUMBITS, NULL, entry->EN(bit,numbits), NULL); else if (E->EN(bit,bitnum) < 0) - _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_BITNUM, NULL, + _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_BITNUM, NULL, entry->EN(bit,bitnum), NULL); else if (E->EN(bit,bitnum) + E->EN(bit,numbits) - 1 > 63) - _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_BITSIZE, NULL, + _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_BITSIZE, NULL, E->EN(bit,bitnum) + E->EN(bit,numbits) - 1, NULL); copy_scalar[0] = copy_scalar[1] = 1; break; @@ -565,7 +560,7 @@ "dirfile_madd_spec()", 0, D->standards, D->flags & GD_PERMISSIVE); /* Directive parsing is skipped -- The Field Spec parser will add the field */ - if (!D->error) + if (!D->error) _GD_ParseFieldSpec(D, n_cols, in_cols, E, "dirfile_madd_spec()", 0, me, D->standards, 1, GD_PEDANTIC, 1, &outstring, tok_pos); @@ -628,7 +623,7 @@ /* Directive parsing is skipped -- The Field Spec parser will add the field */ if (!D->error) - _GD_ParseFieldSpec(D, n_cols, in_cols, NULL, "dirfile_add_spec()", 0, + _GD_ParseFieldSpec(D, n_cols, in_cols, NULL, "dirfile_add_spec()", 0, fragment_index, D->standards, 1, GD_PEDANTIC, 1, &outstring, tok_pos); free(outstring); @@ -669,7 +664,7 @@ gd_entry_t R; int error; - dtrace("%p, \"%s\", %x, %i, %i", D, field_code, data_type, spf, + dtrace("%p, \"%s\", 0x%X, %i, %i", D, field_code, data_type, spf, fragment_index); if (D->flags & GD_INVALID) {/* don't crash */ @@ -1155,7 +1150,7 @@ gd_entry_t C; int error; - dtrace("%p, \"%s\", 0x%x, 0x%x, %p, %i", D, field_code, const_type, data_type, + dtrace("%p, \"%s\", 0x%X, 0x%X, %p, %i", D, field_code, const_type, data_type, value, fragment_index); if (D->flags & GD_INVALID) {/* don't crash */ @@ -1197,7 +1192,7 @@ gd_entry_t C; int error; - dtrace("%p, \"%s\", 0x%x, %zi, 0x%x, %p, %i", D, field_code, const_type, + dtrace("%p, \"%s\", 0x%X, %zi, 0x%X, %p, %i", D, field_code, const_type, array_len, data_type, values, fragment_index); if (D->flags & GD_INVALID) { @@ -1723,7 +1718,7 @@ gd_entry_t *entry; gd_entry_t C; - dtrace("%p, \"%s\", \"%s\", 0x%x, 0x%x, %p", D, parent, field_code, + dtrace("%p, \"%s\", \"%s\", 0x%X, 0x%X, %p", D, parent, field_code, const_type, data_type, value); if (D->flags & GD_INVALID) {/* don't crash */ @@ -1774,7 +1769,7 @@ gd_entry_t *entry; gd_entry_t C; - dtrace("%p, \"%s\", \"%s\", 0x%x, %zi 0x%x, %p", D, parent, field_code, + dtrace("%p, \"%s\", \"%s\", 0x%X, %zi 0x%X, %p", D, parent, field_code, const_type, array_len, data_type, values); if (D->flags & GD_INVALID) {/* don't crash */ Modified: trunk/getdata/src/ascii.c =================================================================== --- trunk/getdata/src/ascii.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/ascii.c 2011-11-05 00:43:40 UTC (rev 610) @@ -33,41 +33,49 @@ /* The ASCII encoding uses file->edata for the stream pointer */ -int _GD_AsciiOpen(int dirfd, struct _gd_raw_file* file, int swap __gd_unused, - int mode, int creat) +int _GD_AsciiOpen(int fd, int fd2 __gd_unused, struct _gd_raw_file* file, + int swap __gd_unused, unsigned int mode) { - int fd; + dtrace("%i, <unused>, %p, <unused>, %u", fd, file, mode); - dtrace("%i, %p, <unused>, %i, %i", dirfd, file, mode, creat); + if (!(mode & GD_FILE_TEMP)) { + if (file->mode & mode) { + dreturn("%i", 0); + return 0; + } else if (file->edata != NULL) + fclose(file->edata); - fd = gd_OpenAt(file->D, dirfd, file->name, ((mode == GD_RDWR) ? O_RDWR : - O_RDONLY) | (creat ? O_CREAT : 0) | O_BINARY, 0666); + file->idata = gd_OpenAt(file->D, fd, file->name, ((mode & GD_FILE_WRITE) + ? (O_RDWR | O_CREAT) : O_RDONLY) | O_BINARY, 0666); - if (fd < 0) { - dreturn("%i", -1); - return -1; - } + if (file->idata < 0) { + dreturn("%i", -1); + return -1; + } + } else + file->idata = fd; - file->edata = fdopen(fd, (mode == GD_RDWR) ? "r+" : "r"); + file->edata = fdopen(file->idata, (mode & GD_FILE_WRITE) ? "r+" : "r"); if (file->edata == NULL) { - close(fd); + close(file->idata); + file->idata = -1; dreturn("%i", -1); return -1; } + file->mode = mode | GD_FILE_READ; file->pos = 0; - file->idata = 0; dreturn("%i", 0); return 0; } off64_t _GD_AsciiSeek(struct _gd_raw_file* file, off64_t count, - gd_type_t data_type __gd_unused, int pad) + gd_type_t data_type __gd_unused, unsigned int mode) { char line[64]; - dtrace("%p, %lli, <unused>, %i", file, count, pad); + dtrace("%p, %lli, <unused>, 0x%X", file, count, mode); if (count < file->pos) { rewind((FILE *)file->edata); @@ -78,7 +86,7 @@ if (fgets(line, 64, (FILE *)file->edata) == NULL) break; - if (pad && count > file->pos) { + if (mode & GD_FILE_WRITE && count > file->pos) { strcpy(line, "0\n"); for (; count > file->pos; ++file->pos) fputs(line, (FILE *)file->edata); @@ -90,7 +98,7 @@ static void _GD_ScanFormat(char* fmt, gd_type_t data_type) { - dtrace("%p, %x", fmt, data_type); + dtrace("%p, 0x%X", fmt, data_type); switch(data_type) { case GD_UINT8: @@ -151,7 +159,7 @@ short int i16; #endif - dtrace("%p, %p, 0x%x, %zu", file, ptr, data_type, nmemb); + dtrace("%p, %p, 0x%X, %zu", file, ptr, data_type, nmemb); _GD_ScanFormat(fmt, data_type); if (data_type & GD_COMPLEX) { @@ -210,7 +218,7 @@ ssize_t ret = 0; size_t n = 0; - dtrace("%p, %p, 0x%x, %zu", file, ptr, data_type, nmemb); + dtrace("%p, %p, 0x%X, %zu", file, ptr, data_type, nmemb); switch(data_type) { case GD_UINT8: @@ -348,14 +356,15 @@ dtrace("%p", file); ret = fclose((FILE *)file->edata); - if (ret != EOF) { - file->idata = -1; - dreturn("%i", 0); - return 0; + if (ret == EOF) { + dreturn("%i", 1); + return 1; } - dreturn("%i", 1); - return 1; + file->idata = -1; + file->mode = 0; + dreturn("%i", 0); + return 0; } off64_t _GD_AsciiSize(int dirfd, struct _gd_raw_file* file, @@ -391,44 +400,3 @@ dreturn("%lli", n); return n; } - -int _GD_AsciiTOpen(int fd, struct _gd_raw_file *file, int swap __gd_unused) -{ - dtrace("%i, %p, <unused>", fd, file); - - file->edata = fdopen(fd, "r+"); - - if (file->edata == NULL) { - dreturn("%i", -1); - return -1; - } - - file->pos = 0; - - dreturn("%i", 0); - return 0; -} - -int _GD_AsciiTUnlink(int dirfd, struct _gd_raw_file *file) -{ - dtrace("%i, %p", dirfd, file); - - if (file->name != NULL) { - if (file->pos >= 0) - if (_GD_AsciiClose(file)) { - dreturn("%i", -1); - return -1; - } - - if (gd_UnlinkAt(file->D, dirfd, file->name, 0)) { - dreturn("%i", -1); - return -1; - } - - free(file[1].name); - file[1].name = NULL; - } - - dreturn("%i", 0); - return 0; -} Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/bzip.c 2011-11-05 00:43:40 UTC (rev 610) @@ -101,10 +101,10 @@ return ptr; } -int _GD_Bzip2Open(int dirfd, struct _gd_raw_file* file, int swap __gd_unused, - int mode __gd_unused, int creat __gd_unused) +int _GD_Bzip2Open(int dirfd, int fd2 __gd_unused, struct _gd_raw_file* file, + int swap __gd_unused, unsigned int mode __gd_unused) { - dtrace("%i, %p, <unused>, <unused>, <unused>", dirfd, file); + dtrace("%i, <unused>, %p, <unused>, <unused>", dirfd, file); file->edata = _GD_Bzip2DoOpen(dirfd, file); @@ -113,17 +113,18 @@ return 1; } + file->mode = GD_FILE_READ; file->idata = 0; dreturn("%i", 0); return 0; } off64_t _GD_Bzip2Seek(struct _gd_raw_file* file, off64_t count, - gd_type_t data_type, int pad __gd_unused) + gd_type_t data_type, unsigned int mode __gd_unused) { struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; - dtrace("%p, %lli, %x, <unused>", file, (long long)count, data_type); + dtrace("%p, %lli, 0x%X, <unused>", file, (long long)count, data_type); count *= GD_SIZE(data_type); @@ -179,7 +180,7 @@ struct gd_bzdata *ptr = (struct gd_bzdata *)file->edata; unsigned long long nbytes = nmemb * GD_SIZE(data_type); - dtrace("%p, %p, %x, %zu", file, data, data_type, nmemb); + dtrace("%p, %p, 0x%X, %zu", file, data, data_type, nmemb); while (nbytes > (unsigned long long)(ptr->end - ptr->pos)) { int n; @@ -235,15 +236,16 @@ ptr->bzerror = 0; BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); - if (!fclose(ptr->stream)) { - file->idata = -1; - free(file->edata); - dreturn("%i", 0); - return 0; + if (fclose(ptr->stream)) { + dreturn("%i", 1); + return 1; } - dreturn("%i", 1); - return 1; + file->idata = -1; + file->mode = 0; + free(file->edata); + dreturn("%i", 0); + return 0; } off64_t _GD_Bzip2Size(int dirfd, struct _gd_raw_file *file, gd_type_t data_type, @@ -252,7 +254,7 @@ struct gd_bzdata *ptr; off_t n; - dtrace("%i, %p, %x, <unused>", dirfd, file, data_type); + dtrace("%i, %p, 0x%X, <unused>", dirfd, file, data_type); ptr = _GD_Bzip2DoOpen(dirfd, file); Modified: trunk/getdata/src/close.c =================================================================== --- trunk/getdata/src/close.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/close.c 2011-11-05 00:43:40 UTC (rev 610) @@ -33,7 +33,7 @@ dtrace("%p", D); - for (i = 0; i < D->n_entries; ++i) + for (i = 0; i < D->n_entries; ++i) _GD_FreeE(D, D->entry[i], 1); for (j = 0; j < D->n_fragment; ++j) { @@ -86,7 +86,7 @@ for(i = 0; i < D->n_entries; ++i) if (D->entry[i]->field_type == GD_RAW_ENTRY) - _GD_Flush(D, D->entry[i]); + _GD_Flush(D, D->entry[i], 1); if (D->error) { dreturn("%i", 1); Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/del.c 2011-11-05 00:43:40 UTC (rev 610) @@ -201,7 +201,7 @@ gd_entry_t *reference = NULL, *E; gd_entry_t **del_list; - dtrace("%p, \"%s\", %x", D, field_code_in, flags); + dtrace("%p, \"%s\", 0x%X", D, field_code_in, flags); if (D->flags & GD_INVALID) {/* don't crash */ _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -340,9 +340,8 @@ dreturn("%i", -1); return -1; } - } else if (E->field_type == GD_RAW_ENTRY && E->e->u.raw.file->idata != -1) { - if ((*_gd_ef[E->e->u.raw.file[0].subenc].close)(E->e->u.raw.file)) { - _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); + } else if (E->field_type == GD_RAW_ENTRY && E->e->u.raw.file->idata >= 0) { + if (_GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_DISCARD)) { free(del_list); dreturn("%i", -1); return -1; @@ -450,7 +449,7 @@ struct _gd_private_entry *Pe = E->e->p.parent->e; /* search and destroy */ - for (i = 0; i < Pe->n_meta; ++i) + for (i = 0; i < Pe->n_meta; ++i) if (Pe->p.meta_entry[i] == E) { Pe->p.meta_entry[i] = Pe->p.meta_entry[Pe->n_meta - 1]; break; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/encoding.c 2011-11-05 00:43:40 UTC (rev 610) @@ -44,7 +44,7 @@ /* encoding schemas */ #define GD_EF_NULL_SET NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \ - &_GD_GenericMove, &_GD_GenericUnlink, NULL, &_GD_GenericTMove, NULL + &_GD_GenericMove, &_GD_GenericUnlink #ifdef USE_MODULES #define GD_EXT_ENCODING(sc,ex,ec,af,ff) \ { sc,ex,ec,af,ff,GD_EF_PROVIDES,GD_EF_NULL_SET } @@ -52,25 +52,24 @@ #define GD_EXT_ENCODING(sc,ex,ec,af,ff) { sc,ex,ec,af,ff,0,GD_INT_FUNCS } #endif struct encoding_t _gd_ef[GD_N_SUBENCODINGS] = { - { GD_UNENCODED, "", 1, NULL, "none", 0, - &_GD_RawOpen, &_GD_RawClose, &_GD_GenericTouch, &_GD_RawSeek, &_GD_RawRead, - &_GD_RawSize, &_GD_RawWrite, &_GD_RawSync, &_GD_GenericMove, - &_GD_GenericUnlink, &_GD_RawTOpen, &_GD_GenericTMove, &_GD_RawTUnlink + { GD_UNENCODED, "", GD_EF_ECOR, NULL, "none", 0, + &_GD_RawOpen, &_GD_RawClose, &_GD_RawSeek, &_GD_RawRead, &_GD_RawSize, + &_GD_RawWrite, &_GD_RawSync, &_GD_GenericMove, &_GD_GenericUnlink }, #ifdef USE_GZIP #define GD_EF_PROVIDES \ - GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE + GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE | \ + GD_EF_WRITE | GD_EF_SYNC #define GD_INT_FUNCS \ - &_GD_GzipOpen, &_GD_GzipClose, NULL /* TOUCH */, &_GD_GzipSeek, \ - &_GD_GzipRead, &_GD_GzipSize, NULL /* WRITE */, NULL /* SYNC */, \ - &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ - NULL /* TUNLINK */ + &_GD_GzipOpen, &_GD_GzipClose, &_GD_GzipSeek, &_GD_GzipRead, &_GD_GzipSize, \ + &_GD_GzipWrite, &_GD_GzipSync, &_GD_GenericMove, &_GD_GenericUnlink #else #define GD_EF_PROVIDES 0 #define GD_INT_FUNCS GD_EF_NULL_SET #endif - GD_EXT_ENCODING(GD_GZIP_ENCODED, ".gz", 1, "Gzip", "gzip"), + GD_EXT_ENCODING(GD_GZIP_ENCODED, ".gz", GD_EF_ECOR | GD_EF_OOP, "Gzip", + "gzip"), #undef GD_INT_FUNCS #undef GD_EF_PROVIDES @@ -79,15 +78,14 @@ #define GD_EF_PROVIDES \ GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, #define GD_INT_FUNCS \ - &_GD_Bzip2Open, &_GD_Bzip2Close, NULL /* TOUCH */, &_GD_Bzip2Seek, \ - &_GD_Bzip2Read, &_GD_Bzip2Size, NULL /* WRITE */, NULL /* SYNC */, \ - &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ - NULL /* TUNLINK */ + &_GD_Bzip2Open, &_GD_Bzip2Close, &_GD_Bzip2Seek, &_GD_Bzip2Read, \ + &_GD_Bzip2Size, NULL /* WRITE */, NULL /* SYNC */, &_GD_GenericMove, \ + &_GD_GenericUnlink #else #define GD_INT_FUNCS GD_EF_NULL_SET #define GD_EF_PROVIDES 0 #endif - GD_EXT_ENCODING(GD_BZIP2_ENCODED, ".bz2", 1, "Bzip2", "bzip2"), + GD_EXT_ENCODING(GD_BZIP2_ENCODED, ".bz2", GD_EF_ECOR, "Bzip2", "bzip2"), #undef GD_INT_FUNCS #undef GD_EF_PROVIDES @@ -96,15 +94,13 @@ #define GD_EF_PROVIDES \ GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, #define GD_INT_FUNCS \ - &_GD_SlimOpen, &_GD_SlimClose, NULL /* TOUCH */, &_GD_SlimSeek, \ - &_GD_SlimRead, &_GD_SlimSize, NULL /* WRITE */, NULL /* SYNC */, \ - &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ - NULL /* TUNLINK */ + &_GD_SlimOpen, &_GD_SlimClose, &_GD_SlimSeek, &_GD_SlimRead, &_GD_SlimSize, \ + NULL /* WRITE */, NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink #else #define GD_INT_FUNCS GD_EF_NULL_SET #define GD_EF_PROVIDES 0 #endif - GD_EXT_ENCODING(GD_SLIM_ENCODED, ".slm", 1, "Slim", "slim"), + GD_EXT_ENCODING(GD_SLIM_ENCODED, ".slm", GD_EF_ECOR, "Slim", "slim"), #undef GD_INT_FUNCS #undef GD_EF_PROVIDES @@ -113,34 +109,32 @@ #define GD_EF_PROVIDES \ GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, #define GD_INT_FUNCS \ - &_GD_LzmaOpen, &_GD_LzmaClose, NULL /* TOUCH */, &_GD_LzmaSeek, \ - &_GD_LzmaRead, &_GD_LzmaSize, NULL /* WRITE */, NULL /* SYNC */, \ - &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ - NULL /* TUNLINK */ + &_GD_LzmaOpen, &_GD_LzmaClose, &_GD_LzmaSeek, &_GD_LzmaRead, &_GD_LzmaSize, \ + NULL /* WRITE */, NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink #else #define GD_INT_FUNCS GD_EF_NULL_SET #define GD_EF_PROVIDES 0 #endif - GD_EXT_ENCODING(GD_LZMA_ENCODED, ".xz", 1, "Lzma", "lzma"), - GD_EXT_ENCODING(GD_LZMA_ENCODED, ".lzma", 1, "Lzma", "lzma"), + GD_EXT_ENCODING(GD_LZMA_ENCODED, ".xz", GD_EF_ECOR, "Lzma", "lzma"), + GD_EXT_ENCODING(GD_LZMA_ENCODED, ".lzma", GD_EF_ECOR, "Lzma", "lzma"), #undef GD_INT_FUNCS #undef GD_EF_PROVIDES { GD_TEXT_ENCODED, ".txt", 0, NULL, "text", 0, - &_GD_AsciiOpen, &_GD_AsciiClose, &_GD_GenericTouch, &_GD_AsciiSeek, - &_GD_AsciiRead, &_GD_AsciiSize, &_GD_AsciiWrite, &_GD_AsciiSync, - &_GD_GenericMove, &_GD_GenericUnlink, &_GD_AsciiTOpen, &_GD_GenericTMove, - &_GD_AsciiTUnlink }, + &_GD_AsciiOpen, &_GD_AsciiClose, &_GD_AsciiSeek, &_GD_AsciiRead, + &_GD_AsciiSize, &_GD_AsciiWrite, &_GD_AsciiSync, &_GD_GenericMove, + &_GD_GenericUnlink + }, - { GD_SIE_ENCODED, ".sie", 0, NULL, "sie", 0, - &_GD_SampIndOpen, &_GD_SampIndClose, &_GD_GenericTouch, &_GD_SampIndSeek, - &_GD_SampIndRead, &_GD_SampIndSize, &_GD_SampIndWrite, &_GD_SampIndSync, - &_GD_GenericMove, &_GD_GenericUnlink, &_GD_SampIndTOpen, &_GD_GenericTMove, - &_GD_SampIndTUnlink }, + { GD_SIE_ENCODED, ".sie", GD_EF_ECOR | GD_EF_SWAP, NULL, "sie", 0, + &_GD_SampIndOpen, &_GD_SampIndClose, &_GD_SampIndSeek, &_GD_SampIndRead, + &_GD_SampIndSize, &_GD_SampIndWrite, &_GD_SampIndSync, &_GD_GenericMove, + &_GD_GenericUnlink + }, { GD_ENC_UNSUPPORTED, "", 0, "", "", 0, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, }; @@ -190,7 +184,7 @@ { int ret; - dtrace("%i, %x", encoding, funcs); + dtrace("%i, 0x%X", encoding, funcs); #ifdef USE_MODULES #ifdef USE_PTHREAD @@ -242,9 +236,6 @@ _gd_ef[encoding].close = (int (*)(struct _gd_raw_file*))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Close"); - if (_gd_ef[encoding].provides & GD_EF_TOUCH) - _gd_ef[encoding].touch = (int (*)(int, struct _gd_raw_file*)) - _GD_ResolveSymbol(lib, _gd_ef + encoding, "Touch"); if (_gd_ef[encoding].provides & GD_EF_SEEK) _gd_ef[encoding].seek = (off64_t (*)(struct _gd_raw_file*, off64_t, gd_type_t, int))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Seek"); @@ -270,9 +261,6 @@ if (_gd_ef[encoding].provides & GD_EF_TEMP) _gd_ef[encoding].temp = (int (*)(int, int, struct _gd_raw_file*, int, int))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Temp"); - if (_gd_ef[encoding].provides & GD_EF_TOPEN) - _gd_ef[encoding].topen = (gd_ef_topen_t)_GD_ResolveSymbol(lib, - _gd_ef + encoding, "TOpen"); /* we tried our best, don't bother trying again */ _gd_ef[encoding].provides = 0; @@ -285,49 +273,208 @@ ret = (funcs & GD_EF_OPEN && _gd_ef[encoding].open == NULL) || (funcs & GD_EF_CLOSE && _gd_ef[encoding].close == NULL) || - (funcs & GD_EF_TOUCH && _gd_ef[encoding].touch == NULL) || (funcs & GD_EF_SEEK && _gd_ef[encoding].seek == NULL) || (funcs & GD_EF_READ && _gd_ef[encoding].read == NULL) || (funcs & GD_EF_SIZE && _gd_ef[encoding].size == NULL) || (funcs & GD_EF_WRITE && _gd_ef[encoding].write == NULL) || (funcs & GD_EF_SYNC && _gd_ef[encoding].sync == NULL) || - (funcs & GD_EF_UNLINK && _gd_ef[encoding].unlink == NULL) || - (funcs & GD_EF_TOPEN && _gd_ef[encoding].topen == NULL) || - (funcs & GD_EF_TMOVE && _gd_ef[encoding].tmove == NULL) || - (funcs & GD_EF_TUNLINK && _gd_ef[encoding].tunlink == NULL); + (funcs & GD_EF_UNLINK && _gd_ef[encoding].unlink == NULL); dreturn("%i", ret); return ret; } -/* Open a raw file, if necessary, also check for required functions */ -int _GD_InitRawIO(DIRFILE *D, gd_entry_t *E, unsigned int funcs, int creat) +static int _GD_MoveOver(DIRFILE *D, int fragment, struct _gd_raw_file *file) { - dtrace("%p, %p, %x, %i", D, E, funcs, creat); + const int dirfd = D->fragment[fragment].dirfd; +#ifdef HAVE_FCHMOD + struct stat stat_buf; + mode_t mode; +#endif + dtrace("%p, %i, %p", D, fragment, file); - if (E->e->u.raw.file[0].idata < 0) { +#ifdef HAVE_FCHMOD + if (gd_StatAt(D, dirfd, file[0].name, &stat_buf, 0)) + mode = 0644; + else + mode = stat_buf.st_mode; +#endif + + if (gd_RenameAt(D, dirfd, file[1].name, dirfd, file[0].name)) { + int move_errno = errno; + if (gd_UnlinkAt(D, dirfd, file[1].name, 0) == 0) { + free(file[1].name); + file[1].name = NULL; + } + errno = move_errno; + _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[fragment].cname, 0, NULL); + D->flags |= GD_INVALID; + dreturn("%i", -1); + return -1; + } + +#ifdef HAVE_FCHMOD + int fd = gd_OpenAt(file->D, dirfd, file[0].name, O_RDONLY, 0666); + fchmod(fd, mode); + close(fd); +#endif + + dreturn("%i", 0); + return 0; +} + +/* Close a raw file, taking care of cleaning-up out-of-place writes, and + * discarding temporary files */ +int _GD_FiniRawIO(DIRFILE *D, gd_entry_t *E, int fragment, int flags) +{ + const int clotemp = (flags & GD_FINIRAW_CLOTEMP) ? 1 : 0; + const int old_mode = E->e->u.raw.file[0].mode; + dtrace("%p, %p, %i, 0x%X", D, E, fragment, flags); + + if ((E->e->u.raw.file[clotemp].idata >= 0) || + (clotemp == 0 && (_gd_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && + (E->e->u.raw.file[1].idata >= 0))) + { + /* close the file */ + if ((*_gd_ef[E->e->u.raw.file[clotemp].subenc].close)(E->e->u.raw.file + + clotemp)) + { + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[clotemp].name, errno, + NULL); + dreturn("%i", 1); + return 1; + } + } + + if (flags & GD_FINIRAW_DEFER) { + dreturn("%i", 0); + return 0; + } + + /* take care of moving things into place */ + if ((old_mode == GD_FILE_WRITE && (_gd_ef[E->e->u.raw.file[0].subenc].flags + & GD_EF_OOP)) || flags & GD_FINIRAW_CLOTEMP) + { + if (flags & GD_FINIRAW_DISCARD) { + /* Throw away the temporary file */ + if (gd_UnlinkAt(D, D->fragment[fragment].dirfd, E->e->u.raw.file[1].name, + 0)) + { + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[1].name, errno, NULL); + dreturn("%i", -1); + return -1; + } + } else { + /* Move the old file over the new file */ + if (_GD_MoveOver(D, fragment, E->e->u.raw.file)) { + dreturn("%i", -1); + return -1; + } + } + + free(E->e->u.raw.file[1].name); + E->e->u.raw.file[1].name = NULL; + } + + dreturn("%i", 0); + return 0; +} + +/* Open a raw file, if necessary; also check for required functions */ +int _GD_InitRawIO(DIRFILE *D, gd_entry_t *E, const char *filebase, + int fragment, const struct encoding_t *new_enc, unsigned int funcs, + unsigned int mode, int swap) +{ + int temp_fd = -1; + const int touch = mode & GD_FILE_TOUCH; + dtrace("%p, %p, \"%s\", %i, %p, 0x%X, 0x%X, %i", D, E, filebase, fragment, + new_enc, funcs, mode, swap); + + if (mode & (GD_FILE_WRITE | GD_FILE_TOUCH)) + funcs |= GD_EF_WRITE; + + mode &= ~GD_FILE_TOUCH; + + if (!(mode & GD_FILE_TEMP)) { if (!_GD_Supports(D, E, GD_EF_OPEN | funcs)) { dreturn("%i", 1); return 1; - } else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) + } + } + + /* close the file, if necessary */ + if ((E->e->u.raw.file[0].idata >= 0 || + ((_gd_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && + (E->e->u.raw.file[1].idata >= 0))) && !(mode & GD_FILE_TEMP) && + (E->e->u.raw.file[0].mode & GD_FILE_RDWR) != (mode & GD_FILE_RDWR)) + { + if (_GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP)) { + dreturn("%i", 1); + return 1; + } + } + + if (filebase == NULL) + filebase = E->e->u.raw.filebase; + + if (fragment == -1) + fragment = E->fragment_index; + + if (mode & GD_FILE_TEMP) { + /* create temporary file in file[1] */ + if (_GD_SetEncodedName(D, E->e->u.raw.file + 1, filebase, 1)) { + ; /* error already set */ + } else if ((temp_fd = _GD_MakeTempFile(D, D->fragment[fragment].dirfd, + E->e->u.raw.file[1].name)) < 0) + { + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[1].name, errno, NULL); + } else if ((*new_enc->open)(temp_fd, -1, E->e->u.raw.file + 1, swap, + GD_FILE_WRITE | GD_FILE_TEMP)) + { + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[1].name, errno, NULL); + } + + if (D->error) { dreturn("%i", 1); return 1; + } + } else if (E->e->u.raw.file[0].idata < 0) { + /* open a regular file, if necessary */ + if ((_gd_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && + mode == GD_FILE_WRITE) + { + /* an out-of-place write requires us to open a temporary file and pass + * in its fd */ + if (_GD_SetEncodedName(D, E->e->u.raw.file + 1, filebase, 1)) + { + dreturn("%i", 1); + return 1; + } else if ((temp_fd = _GD_MakeTempFile(D, + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file[1].name)) + < 0) + { + dreturn("%i", 1); + return 1; + } + } + + if (_GD_SetEncodedName(D, E->e->u.raw.file, filebase, 0)) { + dreturn("%i", 1); + return 1; } else if ((*_gd_ef[E->e->u.raw.file[0].subenc].open)( - D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - _GD_FileSwapBytes(D, E->fragment_index), D->flags & GD_ACCMODE, - creat)) + D->fragment[E->fragment_index].dirfd, temp_fd, E->e->u.raw.file, + _GD_FileSwapBytes(D, E->fragment_index), mode)) { - _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, - NULL); + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); dreturn("%i", 1); return 1; } - } else if (!_GD_Supports(D, E, funcs)) { - dreturn("%i", 1); - return 1; } + if (touch) + _GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP); + dreturn("%i", 0); return 0; } @@ -350,7 +497,7 @@ if (candidate) { strcat(strcpy(candidate, name), _gd_ef[i].ext); - if (gd_StatAt(D, dirfd, candidate, &statbuf, 0) == 0) + if (gd_StatAt(D, dirfd, candidate, &statbuf, 0) == 0) if (S_ISREG(statbuf.st_mode)) { if (file != NULL) file->subenc = i; @@ -378,7 +525,7 @@ int _GD_Supports(DIRFILE* D, gd_entry_t* E, unsigned int funcs) { - dtrace("%p, %p, %x", D, E, funcs); + dtrace("%p, %p, 0x%X", D, E, funcs); /* Figure out the dirfile encoding type, if required */ if (D->fragment[E->fragment_index].encoding == GD_AUTO_ENCODED) { @@ -482,15 +629,9 @@ * remove the temporary files */ if (D->error) { for (i = 0; i < n_raw; ++i) - if (!_GD_MissingFramework(raw_entry[i]->e->u.raw.file[1].subenc, - GD_EF_TUNLINK) && - (*_gd_ef[raw_entry[i]->e->u.raw.file[1].subenc].tunlink)( - D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file + 1)) - { - _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, - errno, NULL); - } - } else + _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_DISCARD | + GD_FINIRAW_CLOTEMP); + } else for (i = 0; i < n_raw; ++i) { struct _gd_raw_file temp; memcpy(&temp, raw_entry[i]->e->u.raw.file, sizeof(temp)); @@ -499,19 +640,17 @@ raw_entry[i]->e->u.raw.file[0].subenc = raw_entry[i]->e->u.raw.file[1].subenc; + /* discard the old file */ + _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_DISCARD); + if (_GD_SetEncodedName(D, raw_entry[i]->e->u.raw.file, raw_entry[i]->e->u.raw.filebase, 0)) { raw_entry[i]->e->u.raw.file[0].name = temp.name; raw_entry[i]->e->u.raw.file[0].subenc = temp.subenc; - } else if ((*_gd_ef[raw_entry[i]->e->u.raw.file[1].subenc].tmove)( - D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, - _gd_ef[raw_entry[i]->e->u.raw.file[1].subenc].tunlink)) + } else if (_GD_FiniRawIO(D, raw_entry[i], fragment, + GD_FINIRAW_KEEP | GD_FINIRAW_CLOTEMP)) { - _GD_SetError(D, GD_E_UNCLEAN_DB, 0, - D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); - D->flags |= GD_INVALID; raw_entry[i]->e->u.raw.file[0].name = temp.name; raw_entry[i]->e->u.raw.file[0].subenc = temp.subenc; } else if ((*_gd_ef[temp.subenc].unlink)(D->fragment[fragment].dirfd, @@ -687,22 +826,6 @@ return fd; } -int _GD_GenericTouch(int dirfd, struct _gd_raw_file* file, int swap __gd_unused) -{ - int fd; - - dtrace("%i, %p, <unused>", dirfd, file); - - fd = gd_OpenAt(file->D, dirfd, file->name, O_RDWR | O_CREAT | O_TRUNC - | O_BINARY, 0666); - - if (fd != -1) - fd = close(fd); - - dreturn("%i", fd); - return fd; -} - int _GD_GenericUnlink(int dirfd, struct _gd_raw_file* file) { int r; @@ -737,44 +860,5 @@ dreturn("%i", r); return r; } - -int _GD_GenericTMove(int dirfd0, int dirfd1, struct _gd_raw_file *file, - gd_ef_tunlink_t tunlink) -{ -#ifdef HAVE_FCHMOD - struct stat stat_buf; - mode_t mode; -#endif - dtrace("%i, %i, %p, %p", dirfd0, dirfd1, file, tunlink); - - if (file[1].name == NULL) { - dreturn("%i", 0); - return 0; - } - -#ifdef HAVE_FCHMOD - if (gd_StatAt(file[0].D, dirfd0, file[0].name, &stat_buf, 0)) - mode = 0644; - else - mode = stat_buf.st_mode; -#endif - - if (gd_RenameAt(file->D, dirfd1, file[1].name, dirfd0, file[0].name)) { - int move_errno = errno; - (*tunlink)(dirfd1, file + 1); - errno = move_errno; - dreturn("%i", -1); - return -1; - } - -#ifdef HAVE_FCHMOD - int fd = gd_OpenAt(file->D, dirfd0, file[0].name, O_RDONLY, 0666); - fchmod(fd, mode); - close(fd); -#endif - - dreturn("%i", 0); - return 0; -} /* vim: ts=2 sw=2 et tw=80 */ Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/endian.c 2011-11-05 00:43:40 UTC (rev 610) @@ -65,14 +65,16 @@ if (D->entry[i]->fragment_index == fragment && D->entry[i]->field_type == GD_RAW_ENTRY) { - /* if the field's data type is one byte long, do nothing */ - if (D->entry[i]->e->u.raw.size == 1) - continue; - - /* check subencoding support */ - if (!_GD_Supports(D, D->entry[i], GD_EF_TMOVE | GD_EF_TUNLINK)) + /* determine encoding scheme */ + if (!_GD_Supports(D, D->entry[i], 0)) break; + /* if the field's data type is one byte long, and no in-framework + * byte-swapping is required, do nothing */ + if (D->entry[i]->e->u.raw.size == 1 && + !(_gd_ef[D->entry[i]->e->u.raw.file[0].subenc].flags & GD_EF_SWAP)) + continue; + /* add this raw field to the list */ raw_entry[n_raw++] = D->entry[i]; @@ -87,23 +89,12 @@ * remove the temporary files */ if (D->error) { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)( - D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file + 1)) - { - _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, - errno, NULL); - } + _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_DISCARD | + GD_FINIRAW_CLOTEMP); } else { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tmove)( - D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, - _gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)) - { - _GD_SetError(D, GD_E_UNCLEAN_DB, 0, - D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); - D->flags |= GD_INVALID; - } + _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_KEEP | + GD_FINIRAW_CLOTEMP); } free(raw_entry); Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/flimits.c 2011-11-05 00:43:40 UTC (rev 610) @@ -57,7 +57,8 @@ if (D->entry[i]->fragment_index == fragment && D->entry[i]->field_type == GD_RAW_ENTRY) { - if (!_GD_Supports(D, D->entry[i], GD_EF_TMOVE | GD_EF_TUNLINK)) + /* determine encoding scheme */ + if (!_GD_Supports(D, D->entry[i], 0)) break; /* add this raw field to the list */ @@ -74,23 +75,12 @@ * remove the temporary files */ if (D->error) { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)( - D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file + 1)) - { - _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, - errno, NULL); - } + _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_DISCARD | + GD_FINIRAW_CLOTEMP); } else { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tmove)( - D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, - _gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)) - { - _GD_SetError(D, GD_E_UNCLEAN_DB, 0, - D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); - D->flags |= GD_INVALID; - } + _GD_FiniRawIO(D, raw_entry[i], fragment, GD_FINIRAW_KEEP | + GD_FINIRAW_CLOTEMP); } free(raw_entry); Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/flush.c 2011-11-05 00:43:40 UTC (rev 610) @@ -36,11 +36,11 @@ #define GD_MAX_PRETTY_FIELD_WIDTH 80 -void _GD_Flush(DIRFILE* D, gd_entry_t *E) +void _GD_Flush(DIRFILE* D, gd_entry_t *E, int clo) { int i; - dtrace("%p, %p", D, E); + dtrace("%p, %p, %i", D, E, clo); if (++D->recurse_level >= GD_MAX_RECURSE_LEVEL) { _GD_SetError(D, GD_E_RECURSE_LEVEL, 0, NULL, 0, E->field); @@ -51,14 +51,16 @@ switch(E->field_type) { case GD_RAW_ENTRY: - if (E->e->u.raw.file[0].idata >= 0) { + if (E->e->u.raw.file[0].idata >= 0 || + ((_gd_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP) && + (E->e->u.raw.file[1].idata >= 0))) + { if ((D->flags & GD_ACCMODE) == GD_RDWR && _gd_ef[E->e->u.raw.file[0].subenc].sync != NULL && (*_gd_ef[E->e->u.raw.file[0].subenc].sync)(E->e->u.raw.file)) _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); - else if ((*_gd_ef[E->e->u.raw.file[0].subenc].close)( - E->e->u.raw.file)) + else if (clo && _GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP)) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -67,11 +69,11 @@ break; case GD_LINCOM_ENTRY: for (i = 2; i < E->EN(lincom,n_fields); ++i) - _GD_Flush(D, E->e->entry[i]); + _GD_Flush(D, E->e->entry[i], clo); /* fallthrough */ case GD_MULTIPLY_ENTRY: case GD_DIVIDE_ENTRY: - _GD_Flush(D, E->e->entry[1]); + _GD_Flush(D, E->e->entry[1], clo); /* fallthrough */ case GD_LINTERP_ENTRY: case GD_BIT_ENTRY: @@ -79,7 +81,7 @@ case GD_POLYNOM_ENTRY: case GD_SBIT_ENTRY: case GD_RECIP_ENTRY: - _GD_Flush(D, E->e->entry[0]); + _GD_Flush(D, E->e->entry[0], clo); case GD_CONST_ENTRY: case GD_CARRAY_ENTRY: case GD_STRING_ENTRY: @@ -96,7 +98,7 @@ { const char* ptr; - dtrace("%p, 0x%x", D, data_type); + dtrace("%p, 0x%X", D, data_type); switch(data_type) { case GD_UINT8: @@ -149,7 +151,7 @@ { const char* ptr; - dtrace("%p, 0x%x", D, data_type); + dtrace("%p, 0x%X", D, data_type); switch(data_type) { case GD_UINT8: @@ -589,7 +591,7 @@ /* That's all; flush, sync, and close */ fflush(stream); fsync(fd); -#ifdef HAVE_FCHMOD +#ifdef HAVE_FCHMOD fchmod(fd, mode); #endif fclose(stream); @@ -687,7 +689,7 @@ return (D->error == GD_E_OK) ? 0 : -1; } -int gd_flush(DIRFILE* D, const char* field_code) +static int _GD_SyncOrClose(DIRFILE* D, const char* field_code, int clo) { unsigned int i; int repr; @@ -705,13 +707,13 @@ if (!D->error) for (i = 0; i < D->n_entries; ++i) if (D->entry[i]->field_type == GD_RAW_ENTRY) - _GD_Flush(D, D->entry[i]); + _GD_Flush(D, D->entry[i], clo); } else { /* discard representation */ E = _GD_FindFieldAndRepr(D, field_code, &simple_field_code, &repr, NULL, 1); if (!D->error) - _GD_Flush(D, E); + _GD_Flush(D, E, clo); if (field_code != simple_field_code) free(simple_field_code); @@ -721,6 +723,30 @@ return (D->error == GD_E_OK) ? 0 : -1; } +int gd_sync(DIRFILE *D, const char *field_code) +{ + int ret; + + dtrace("%p, \"%s\"", D, field_code); + + ret = _GD_SyncOrClose(D, field_code, 0); + + dreturn("%i", ret); + return ret; +} + +int gd_flush(DIRFILE *D, const char *field_code) +{ + int ret; + + dtrace("%p, \"%s\"", D, field_code); + + ret = _GD_SyncOrClose(D, field_code, 1); + + dreturn("%i", ret); + return ret; +} + #define GD_VERS_GE_1 0xFFFFFFFFFFFFFFFELU #define GD_VERS_GE_2 0xFFFFFFFFFFFFFFFCLU #define GD_VERS_GE_3 0xFFFFFFFFFFFFFFF8LU Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/fpos.c 2011-11-05 00:43:40 UTC (rev 610) @@ -42,7 +42,8 @@ switch (E->field_type) { case GD_RAW_ENTRY: /* We must open the file to know its starting offset */ - if (_GD_InitRawIO(D, E, 0, 0)) + if (E->e->u.raw.file[0].idata < 0) + if (_GD_InitRawIO(D, E, NULL, 0, NULL, 0, GD_FILE_READ, 0)) break; pos = E->e->u.raw.file[0].pos + E->EN(raw,spf) * D->fragment[E->fragment_index].frame_offset; @@ -139,7 +140,7 @@ if (entry->field_type & GD_SCALAR_ENTRY) _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); - else + else pos = _GD_GetFilePos(D, entry, -1); if (field_code != field_code_in) @@ -154,11 +155,40 @@ return (off_t)gd_tell64(D, field_code); } -static int _GD_Seek(DIRFILE *D, gd_entry_t *E, off64_t offset, int pad) +off64_t _GD_WriteSeek(DIRFILE *D, gd_entry_t *E, off64_t offset, + unsigned int mode) { + off64_t pos; + + dtrace("%p, %p, %lli, 0x%X", D, E, (long long)offset, mode); + + /* in this case we need to close and then re-open the file */ + if ((offset < E->e->u.raw.file[0].pos) && mode == GD_FILE_WRITE && + (_gd_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_OOP)) + { + if (_GD_FiniRawIO(D, E, E->fragment_index, GD_FINIRAW_KEEP)) { + dreturn("%i", -1); + return -1; + } else if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK, GD_FILE_WRITE, 0)) + { + dreturn("%i", -1); + return -1; + } + } + + pos = (*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, offset, + E->EN(raw,data_type), mode); + + dreturn("%lli", (long long)pos); + return pos; +} + +static int _GD_Seek(DIRFILE *D, gd_entry_t *E, off64_t offset, + unsigned int mode) +{ int i; - dtrace("%p, %p, %lli, %i", D, E, (long long)offset, pad); + dtrace("%p, %p, %lli, 0x%X", D, E, (long long)offset, mode); if (++D->recurse_level >= GD_MAX_RECURSE_LEVEL) { _GD_SetError(D, GD_E_RECURSE_LEVEL, 0, NULL, 0, E->field); @@ -170,7 +200,7 @@ switch (E->field_type) { case GD_RAW_ENTRY: /* open/create the file, if necessary */ - if (_GD_InitRawIO(D, E, GD_EF_SEEK, pad)) + if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK, mode, 0)) break; /* The requested offset is before the start of the file, so I guess @@ -183,9 +213,8 @@ break; } - if ((*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, offset - - E->EN(raw,spf) * D->fragment[E->fragment_index].frame_offset, - E->EN(raw,data_type), pad) == -1) + if (_GD_WriteSeek(D, E, offset - E->EN(raw,spf) * + D->fragment[E->fragment_index].frame_offset, mode) == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); } @@ -193,7 +222,7 @@ case GD_LINCOM_ENTRY: for (i = 0; i < E->EN(lincom,n_fields); ++i) if (!_GD_BadInput(D, E, i)) - _GD_Seek(D, E->e->entry[i], offset, pad); + _GD_Seek(D, E->e->entry[i], offset, mode); else break; break; @@ -201,7 +230,7 @@ case GD_DIVIDE_ENTRY: if (_GD_BadInput(D, E, 1)) break; - if (_GD_Seek(D, E->e->entry[1], offset, pad)) + if (_GD_Seek(D, E->e->entry[1], offset, mode)) break; /* fallthrough */ case GD_LINTERP_ENTRY: @@ -210,11 +239,11 @@ case GD_SBIT_ENTRY: case GD_RECIP_ENTRY: if (!_GD_BadInput(D, E, 0)) - _GD_Seek(D, E->e->entry[0], offset, pad); + _GD_Seek(D, E->e->entry[0], offset, mode); break; case GD_PHASE_ENTRY: if (!_GD_BadInput(D, E, 0)) - _GD_Seek(D, E->e->entry[0], offset + E->EN(phase,shift), pad); + _GD_Seek(D, E->e->entry[0], offset + E->EN(phase,shift), mode); break; case GD_INDEX_ENTRY: E->e->u.index_pos = offset; @@ -240,10 +269,11 @@ off64_t pos = 0; gd_entry_t* entry; char* field_code; - int repr, is_index = 0, pad = (whence & GD_SEEK_PAD) ? 1 : 0; + int repr, is_index = 0; + unsigned int mode = (whence & GD_SEEK_WRITE) ? GD_FILE_WRITE : GD_FILE_READ; - dtrace("%p, \"%s\", %lli, %lli, %x", D, field_code_in, frame_num, sample_num, - whence); + dtrace("%p, \"%s\", %lli, %lli, 0x%X", D, field_code_in, frame_num, + sample_num, whence); if (D->flags & GD_INVALID) {/* don't crash */ _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); @@ -294,7 +324,7 @@ _GD_SetError(D, GD_E_ARGUMENT, GD_E_ARG_WHENCE, NULL, 0, NULL); if (!D->error) - _GD_Seek(D, entry, sample_num + pos, pad); + _GD_Seek(D, entry, sample_num + pos, mode); if (field_code != field_code_in) free(field_code); Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2011-10-20 22:53:01 UTC (rev 609) +++ trunk/getdata/src/getdata.c 2011-11-05 00:43:40 UTC (rev 610) @@ -114,7 +114,7 @@ { size_t i; - dtrace("%p, %p, %x, %p, %x, %zu, %i", D, cdata, in_type, rdata, type, n, + dtrace("%p, %p, 0x%X, %p, 0x%X, %zu, %i", D, cdata, in_type, rdata, type, n, repr); switch (type) { @@ -169,7 +169,7 @@ { size_t i; - dtrace("%p, 0x%x, %lli, %zu", dataout, rtype, s0, n); + dtrace("%p, 0x%X, %lli, %zu", dataout, rtype, s0, n); switch (rtype) { case GD_INT8: @@ -234,7 +234,7 @@ size_t i; const double NaN = NAN; - dtrace("%p, 0x%x, %zu", databuffer, type, nz); + dtrace("%p, 0x%X, %zu", databuffer, type, nz); if (type & GD_IEEE754) { if (type == GD_FLOAT32) @@ -250,7 +250,7 @@ else for (i = 0; i < 2 * nz; ++i) *((double *)databuffer + i) = (double) NaN; - } else + } else memset(databuffer, 0, nz * GD_SIZE(type)); dreturn("%zu", nz); @@ -268,7 +268,7 @@ char *databuffer; size_t zero_pad = 0; - dtrace("%p, %p, %lli, %zu, 0x%x, %p)", D, E, s0, ns, return_type, data_out); + dtrace("%p, %p, %lli, %zu, 0x%X, %p)", D, E, s0, ns, return_type, data_out); if (s0 < E->EN(raw,spf) * D->fragment[E->fragment_index].frame_offset) zero_pad = E->EN(raw,spf) * D->fragment[E->fragment_index].frame_offset - @@ -295,14 +295,16 @@ if (ns > 0) { /** open the file (and cache the fp) if it hasn't been opened yet. */ - if (_GD_InitRawIO(D, E, GD_EF_SEEK | GD_EF_READ, 0)) { + if (_GD_InitRawIO(D, E, NULL, 0, NULL, GD_EF_SEEK | GD_EF_READ, + GD_FILE_READ, 0)) + { free(databuffer); dreturn("%i", 0); return 0; } if ((*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, s0, - E->EN(raw,data_type), 0) == -1) + E->EN(raw,data_type), GD_FILE_READ) == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); free(databuffer); @@ -321,7 +323,7 @@ return 0; } - if (_gd_ef[E->e->u.raw.file[0].subenc].ecor) { + if (_gd_ef[E->e->u.raw.file[0].subenc].flags & GD_EF_ECOR) { /* convert to/from middle-ended doubles */ if ((E->EN(raw,data_type) == GD_FLOAT64 || E->EN(raw,data_type) == GD_COMPLEX128) && @@ -421,7 +423,7 @@ { size_t i; - dtrace("%p, %p, 0x%x, %zu, %i, %p", D, data, type, npts, n, a); + dtrace("%p, %p, 0x%X, %zu, %i, %p", D, data, type, npts, n, a); if (n == 1) { /* no need to duplicate this case */ @@ -608,7 +610,7 @@ { size_t i; - dtrace("%p, %p, 0x%x, %zu, %i, %p", D, data, type, npts, n, a); + dtrace("%p, %p, 0x%X, %zu, %i, %p", D, data, type, npts, n, a); if (n == 1) { /* no need to duplicate this case */ @@ -658,7 +660,7 @@ { size_t i; - dtrace("%p, %p, %u, %p, %u, 0x%x, %zu", D, A, spfA, B, spfB, type, n); + dtrace("%p, %p, %u, %p, %u, 0x%X, %zu", D, A, spfA, B, spfB, type, n); switch (type) { case GD_NULL: break; @@ -709,7 +711,7 @@ { size_t i; - dtrace("%p, %p, %u, %p, %u, 0x%x, %zu", D, A, spfA, B, spfB, type, n); + dtrace("%p, %p, %u, %p, %u, 0x%X, %zu", D, A, spfA, B, spfB, type, n); switch (type) { case GD_NULL: break; @@ -754,7 +756,7 @@ { size_t i; - dtrace("%p, %p, %u, %p, %u, 0x%x, %zu", D, A, spfA, B, spfB, type, n); + dtrace("%p, %p, %u, %p, %u, 0x%X, %zu", D, A, spfA, B, spfB, type, n); switch (type) { case GD_NULL: break; @@ -806,7 +808,7 @@ { size_t i; - dtrace("%p, %p, %u, %p, %u, 0x%x, %zu", D, A, spfA, B, spfB, type, n); + dtrace("%p, %p, %u, %p, %u, 0x%X, %zu", D, A, spfA, B, spfB, type, n); switch (type) { case GD_NULL: break; @@ -842,7 +844,7 @@ const gd_type_t ntype = (return_type & GD_COMPLEX) ? GD_COMPLEX128 : GD_FLOAT64; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); /* input field checks */ @@ -975,7 +977,7 @@ off64_t first_samp2; gd_type_t type2; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); /* Check input fields */ @@ -1069,7 +1071,7 @@ { size_t n_read; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); /* Check input fields */ @@ -1114,7 +1116,7 @@ off64_t first_samp2; gd_type_t type2; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); /* Check input fields */ @@ -1209,7 +1211,7 @@ const uint64_t mask = (E->EN(bit,numbits) == 64) ? 0xffffffffffffffffULL : ((uint64_t)1 << E->EN(bit,numbits)) - 1; - dtrace("%p, %p, %i, %lli, %zu, 0x%x, %p", D, E, is_signed, first_samp, + dtrace("%p, %p, %i, %lli, %zu, 0x%X, %p", D, E, is_signed, first_samp, num_samp, return_type, data_out); if (_GD_BadInput(D, E, 0)) { @@ -1262,7 +1264,7 @@ { size_t n_read; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); if (_GD_BadInput(D, E, 0)) { @@ -1285,7 +1287,7 @@ size_t n_read = 0; double* data_in; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); if (E->e->u.linterp.table_len < 0) { @@ -1334,7 +1336,7 @@ { size_t n_read; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first_samp, num_samp, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first_samp, num_samp, return_type, data_out); if (_GD_BadInput(D, E, 0)) { @@ -1375,7 +1377,7 @@ { gd_type_t type; - dtrace("%p, %p, %lli, %zu, 0x%x, %p", D, E, first, len, return_type, + dtrace("%p, %p, %lli, %zu, 0x%X, %p", D, E, first, len, r... [truncated message content] |
From: <ket...@us...> - 2011-10-20 22:53:10
|
Revision: 609 http://getdata.svn.sourceforge.net/getdata/?rev=609&view=rev Author: ketiltrout Date: 2011-10-20 22:53:01 +0000 (Thu, 20 Oct 2011) Log Message: ----------- Fix interoperability between seek/tell/HERE and FRAMEOFFSET. Add the missing gd_[m]constants/gd_[m]strings Fortran bindings. All bindings tests for these plus seek/tell. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/bindings/cxx/test/big_test.cpp trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/f77/fgetdata.h trunk/getdata/bindings/f77/getdata.f.in trunk/getdata/bindings/f77/getdata.f90.in trunk/getdata/bindings/f77/test/big_test.f trunk/getdata/bindings/f77/test/big_test95.f90 trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/idl/test/big_test.pro trunk/getdata/bindings/make_parameters.c trunk/getdata/bindings/perl/Makefile.am trunk/getdata/bindings/perl/t/big_test.t trunk/getdata/bindings/perl/typemap trunk/getdata/bindings/python/pydirfile.c trunk/getdata/bindings/python/test/big_test.py trunk/getdata/doc/README.f77 trunk/getdata/doc/README.f95 trunk/getdata/doc/list.tests trunk/getdata/man/gd_mstrings.3 trunk/getdata/man/gd_strings.3 trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/test/get_here_foffs.c trunk/getdata/test/seek_foffs.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/ChangeLog 2011-10-20 22:53:01 UTC (rev 609) @@ -1,3 +1,31 @@ +2011-10-20 D. V. Wiebe <ge...@ke...> svn:609 + * test/get_here_foffs.c test/seek_foffs.c: Added. + + * src/getdata.c (_GD_DoRaw): Update file->pos after calling FillZero. + * src/fpos.c (_GD_GetFilePos): Adjust for SPF. + * src/fpos.c (_GD_Seek): If seeking before FRAMEOFFSET, set file->pos < 0. + + * bindings/python/pydirfile.c (gdpy_dirfile_seek): Fix type of frame_num, + sample_num. + + * bindings/perl/typemap: off64_t is signed. + + * bindings/f77/fgetdata.c (GDCONS GDMCOS GDSTRS GDMSTS GDSTRX GDMSTX): + Added. + * bindings/f77/getdata.f90.in (fgd_constants_i1 fgd_constants_i2 + fgd_constants_i4 fgd_constants_i8 fgd_constants_r4 fgd_constants_r8 + fgd_constants_c8 fgd_constants_c16 fgd_mconstants_i1 fgd_mconstants_i2 + fgd_mconstants_i4 fgd_mconstants_i8 fgd_mconstants_r4 fgd_mconstants_r8 + fgd_mconstants_c8 fgd_mconstants_c16 fgd_string_value_max fgd_strings + fgd_mstring_value_max fgd_mstrings): Added. + + * bindings/idl/getdata.c (gdidl_getdata gdidl_putdata): Add /HERE. + + * bindings/python/test/big_test.py bindings/cxx/test/big_test.cpp + bindings/perl/t/big_test.t bindings/f77/test/big_test.f + bindings/f77/test/big_test95.f90 bindings/idl/test/big_test.pro: Added tests + 183-204. + 2011-10-18 D. V. Wiebe <ge...@ke...> svn:607 * man/gd_seek.3 man/gd_tell.3: Added. Modified: trunk/getdata/bindings/cxx/test/big_test.cpp =================================================================== --- trunk/getdata/bindings/cxx/test/big_test.cpp 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/bindings/cxx/test/big_test.cpp 2011-10-20 22:53:01 UTC (rev 609) @@ -80,13 +80,14 @@ ne++; cerr << "d(" << i << ")[" << t << ", " << m << "] = " << (v) << endl; } #define CHECK_STRING(t,v,g) \ - if (strcmp((v), (g))) { ne++; cerr << "s[" << t << "] = " << (v) << endl; } + if (strcmp((v), (g))) { ne++; cerr << "s[" << t << "] = \"" << (v) << "\"" \ + << endl; } #define CHECK_STRING2(t,m,v,g) \ if (strcmp((v), (g))) { \ - ne++; cerr << "s[" << t << ", " << m << "] = " << (v) << endl; } + ne++; cerr << "s[" << t << ", " << m << "] = \"" << (v) << "\"" << endl; } #define CHECK_STRING_ARRAY(t,m,v,g) \ for (i = 0; i < m; ++i) if (strcmp((v), (g))) { \ - ne++; cerr << "s(" << i << ")[" << t << "] = " << (v) << endl; } + ne++; cerr << "s(" << i << ")[" << t << "] = \"" << (v) << "\"" << endl; } #define CHECK_COMPLEX2(t,m,v,g) \ if (abs((v) - (g)) > 1e-10) { \ @@ -127,9 +128,10 @@ unsigned char c[8]; unsigned char data_data[80]; signed char sc; - int n, i, e, ne = 0; + int m, n, i, e, ne = 0; float fl; double dp, p[6], q[6]; + const double *qp; complex<double> cq[6]; const char **list; const char* str; @@ -156,6 +158,7 @@ (char*)"linterp", (char*)"mult", (char*)"phase", (char*)"polynom", (char*)"recip", (char*)"sbit", (char*)"string", NULL, NULL, NULL, NULL, NULL, NULL, NULL}; + char *strings[3]; // Write the test dirfile mkdir(filedir, 0777); @@ -1311,8 +1314,55 @@ CHECK_INT2(181,4,ent->ArrayLen(),12); delete ent; + // 183: gd_constants + p[0] = 61.; + p[1] = 0.; + n = d->NFieldsByType(ConstEntryType); + qp = reinterpret_cast<const double *>(d->Constants()); + CHECK_OK(183); + CHECK_DOUBLE_ARRAY(183,0,n,qp[i],p[i]); + // 184: gd_mconstants + p[0] = 3.3; + p[1] = 0.; + n = d->NMFieldsByType("data", ConstEntryType); + qp = reinterpret_cast<const double *>(d->MConstants("data")); + CHECK_OK(184); + CHECK_DOUBLE_ARRAY(184,0,n,qp[i],p[i]); + // 199: gd_strings + strings[0] = (char *)"Lorem ipsum"; + strings[1] = (char *)""; + strings[2] = (char *)"Arthur Dent"; + n = d->NFieldsByType(StringEntryType); + list = d->Strings(); + CHECK_OK(199); + CHECK_STRING_ARRAY(199,n,list[i],strings[i]); + + // 200: gd_strings + strings[0] = (char *)"This is a string constant."; + n = d->NMFieldsByType("data", StringEntryType); + list = d->MStrings("data"); + CHECK_OK(200); + CHECK_STRING_ARRAY(200,n,list[i],strings[i]); + + // 203: gd_seek + n = d->Seek("data", 35, 0, GD_SEEK_SET); + CHECK_OK2(203,0); + m = d->GetData("data", GD_HERE, 0, 1, 0, UInt8, c); + CHECK_OK2(203,1); + CHECK_INT2(203,0,n,280); + CHECK_INT2(203,1,m,8); + CHECK_INT_ARRAY(203,8,c[i],17 + i); + + // 204: gd_tell + n = d->Tell("data"); + CHECK_OK(204); + CHECK_INT(204,n,288); + + + + // =================================================================== d->Discard(); delete d; Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/bindings/f77/fgetdata.c 2011-10-20 22:53:01 UTC (rev 609) @@ -219,12 +219,18 @@ const int* num_frames, const int* num_samples, const int* return_type, void* data_out) { + dtrace("%p, %i, %p, %i, %i, %i, %i, %i, 0x%x, %p", n_read, *dirfile, + field_code, *field_code_l, *first_frame, *first_sample, *num_frames, + *num_samples, *return_type, data_out); + char* out = (char *)malloc(*field_code_l + 1); *n_read = gd_getdata(_GDF_GetDirfile(*dirfile), _GDF_CString(out, field_code, *field_code_l), *first_frame, *first_sample, *num_frames, *num_samples, (gd_type_t)*return_type, data_out); free(out); + + dreturn("%i", *n_read); } /* Return the maximum field name length */ @@ -1312,7 +1318,11 @@ void F77_FUNC(gdnfdt, GDNFDT) (int* nfields, const int* dirfile, const int* type) { + dtrace("%p, %i, 0x%x", nfields, *dirfile, *type); + *nfields = gd_nfields_by_type(_GDF_GetDirfile(*dirfile), (gd_entype_t)*type); + + dreturn("%i", *nfields); } /* gd_nvectors wrapper */ @@ -1331,7 +1341,7 @@ if (D->error) return; - if (*field_num <= (int)nfields) { + if (*field_num > 0 && *field_num <= (int)nfields) { fl = gd_field_list_by_type(D, (gd_entype_t)*type); _GDF_FString(name, name_l, fl[*field_num - 1]); } else @@ -1354,7 +1364,7 @@ if (D->error) return; - if (*field_num <= (int)nfields) { + if (*field_num > 0 && *field_num <= (int)nfields) { fl = gd_vector_list(D); _GDF_FString(name, name_l, fl[*field_num - 1]); } else @@ -1381,7 +1391,7 @@ return; } - if (*field_num <= (int)nfields) { + if (*field_num > 0 && *field_num <= (int)nfields) { fl = gd_mfield_list_by_type(D, pa, (gd_entype_t)*type); _GDF_FString(name, name_l, fl[*field_num - 1]); } else @@ -1407,7 +1417,7 @@ return; } - if (*field_num <= (int)nfields) { + if (*field_num > 0 && *field_num <= (int)nfields) { fl = gd_mvector_list(D, pa); _GDF_FString(name, name_l, fl[*field_num - 1]); } else @@ -2080,10 +2090,14 @@ void F77_FUNC(gdnmft, GDNMFT) (int* nfields, const int* dirfile, const char* parent, const int* parent_l, const int* type) { + dtrace("%p, %i, %p, %i, 0x%x", nfields, *dirfile, parent, *parent_l, *type); + char* pa = (char *)malloc(*parent_l + 1); *nfields = gd_nmfields_by_type(_GDF_GetDirfile(*dirfile), _GDF_CString(pa, parent, *parent_l), (gd_entype_t)*type); free(pa); + + dreturn("%i", *nfields); } /* gd_nmvectors wrapper */ @@ -2956,3 +2970,148 @@ free(fc); dreturn("%i", *pos); } + +/* gd_constants wrapper -- this only returns one value */ +void F77_FUNC(gdcons, GDCONS) (void *value, const int *dirfile, + const int *return_type, const int *field_num) +{ + const void *v; + + dtrace("%p, %i, 0x%x, %i", value, *dirfile, *return_type, *field_num); + + DIRFILE *D = _GDF_GetDirfile(*dirfile); + unsigned int nfields = gd_nfields_by_type(D, GD_CONST_ENTRY); + + if (!D->error && (*field_num > 0) && (*field_num <= (int)nfields)) { + v = gd_constants(D, (gd_type_t)*return_type); + if (!D->error) + memcpy(value, (char*)v + (*field_num - 1) * GD_SIZE(*return_type), + GD_SIZE(*return_type)); + } + dreturnvoid(); +} + +/* gd_mconstants wrapper -- this only returns one value */ +void F77_FUNC(gdmcos, GDMCOS) (void *value, const int *dirfile, + const char *parent, const int *parent_l, const int *return_type, + const int *field_num) +{ + const void *v; + + dtrace("%p, %i, %p, %i, 0x%x, %i", value, *dirfile, parent, *parent_l, + *return_type, *field_num); + + DIRFILE *D = _GDF_GetDirfile(*dirfile); + + char *pa = (char *)malloc(*parent_l + 1); + _GDF_CString(pa, parent, *parent_l); + + unsigned int nfields = gd_nmfields_by_type(D, pa, GD_CONST_ENTRY); + + if (!D->error && (*field_num > 0) && (*field_num <= (int)nfields)) { + v = gd_mconstants(D, pa, (gd_type_t)*return_type); + if (!D->error) + memcpy(value, (char*)v + (*field_num - 1) * GD_SIZE(*return_type), + GD_SIZE(*return_type)); + } + + free(pa); + dreturnvoid(); +} + +/* gd_strings wrapper -- this only returns one value */ +void F77_FUNC(gdstrs, GDSTRS) (char *value, int *value_l, const int *dirfile, + const int *field_num) +{ + const char **v; + + dtrace("%p, %i, %i, %i", value, *value_l, *dirfile, *field_num); + + DIRFILE *D = _GDF_GetDirfile(*dirfile); + unsigned int nfields = gd_nfields_by_type(D, GD_STRING_ENTRY); + + if (!D->error && (*field_num > 0) && (*field_num <= (int)nfields)) { + v = gd_strings(D); + _GDF_FString(value, value_l, D->error ? "" : v[*field_num - 1]); + } else + *value_l = 0; + + dreturn("%i", *value_l); +} + +/* gd_mstrings wrapper -- this only returns one value */ +void F77_FUNC(gdmsts, GDMSTS) (void *value, int *value_l, const int *dirfile, + const char *parent, const int *parent_l, const int *field_num) +{ + const char **v; + + dtrace("%p, %i, %i, %p, %i, %i", value, *value_l, *dirfile, parent, + *parent_l, *field_num); + + DIRFILE *D = _GDF_GetDirfile(*dirfile); + + char *pa = (char *)malloc(*parent_l + 1); + _GDF_CString(pa, parent, *parent_l); + + unsigned int nfields = gd_nmfields_by_type(D, pa, GD_STRING_ENTRY); + + if (!D->error && (*field_num > 0) && (*field_num <= (int)nfields)) { + v = gd_mstrings(D, pa); + _GDF_FString(value, value_l, D->error ? "" : v[*field_num - 1]); + } else + *value_l = 0; + + free(pa); + dreturnvoid(); +} + +/* Return the maximum string value length */ +void F77_FUNC(gdstrx, GDSTRX) (int *max, const int *dirfile) +{ + dtrace("%p, %i", max, *dirfile); + + const char **v; + size_t len = 0; + DIRFILE *D = _GDF_GetDirfile(*dirfile); + unsigned int i, nfields = gd_nfields_by_type(D, GD_STRING_ENTRY); + + if (!D->error) { + v = gd_strings(D); + + for (i = 0; i < nfields; ++i) + if (strlen(v[i]) > len) + len = strlen(v[i]); + } + + *max = (int)len; + + dreturn("%i", *max); +} + +/* Return the maximum meta string value length */ +void F77_FUNC(gdmstx, GDMSTX) (int *max, const int *dirfile, const char *parent, + const int *parent_l) +{ + dtrace("%p, %i, %p, %i", max, *dirfile, parent, *parent_l); + + const char **v; + size_t len = 0; + DIRFILE *D = _GDF_GetDirfile(*dirfile); + + char *pa = (char *)malloc(*parent_l + 1); + _GDF_CString(pa, parent, *parent_l); + + unsigned int i, nfields = gd_nmfields_by_type(D, pa, GD_STRING_ENTRY); + + if (!D->error) { + v = gd_mstrings(D, pa); + + for (i = 0; i < nfields; ++i) + if (strlen(v[i]) > len) + len = strlen(v[i]); + } + + *max = (int)len; + + dreturn("%i", *max); +} Modified: trunk/getdata/bindings/f77/fgetdata.h =================================================================== --- trunk/getdata/bindings/f77/fgetdata.h 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/bindings/f77/fgetdata.h 2011-10-20 22:53:01 UTC (rev 609) @@ -564,6 +564,24 @@ void F77_FUNC(gdtell, GDTELL) (int* pos, const int* dirfile, const char* field_code, const int* field_code_l); + +void F77_FUNC(gdcons, GDCONS) (void *value, const int *dirfile, + const int *return_type, const int *field_num); + +void F77_FUNC(gdmcos, GDMCOS) (void *value, const int *dirfile, + const char *parent, const int *parent_l, const int *return_type, + const int *field_num); + +void F77_FUNC(gdstrs, GDSTRS) (char *value, int *value_l, const int *dirfile, + const int *field_num); + +void F77_FUNC(gdmsts, GDMSTS) (void *value, int *value_l, const int *dirfile, + const char *parent, const int *parent_l, const int *field_num); + +void F77_FUNC(gdstrx, GDSTRX) (int *max, const int *dirfile); + +void F77_FUNC(gdmstx, GDMSTX) (int *max, const int *dirfile, const char *parent, + const int *parent_l); #ifdef __cplusplus } #endif Modified: trunk/getdata/bindings/f77/getdata.f.in =================================================================== --- trunk/getdata/bindings/f77/getdata.f.in 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/bindings/f77/getdata.f.in 2011-10-20 22:53:01 UTC (rev 609) @@ -107,6 +107,8 @@ EXTERNAL GDCLBK C Corresponding to gd_close(3) EXTERNAL GDCLOS +C Corresponding to gd_constants(3) (sort of) + EXTERNAL GDCONS C Corresponding to gd_copen(3) EXTERNAL GDCOPN C Check whether an entry contains complex scalars @@ -197,6 +199,8 @@ EXTERNAL GDINCL C Corresponding to gd_invalid_dirfile(3) EXTERNAL GDINVD +C Corresponding to gd_mconstants(3) (sort of) + EXTERNAL GDMCOS C Corresponding to gd_madd_bit(3) EXTERNAL GDMDBT C Corresponding to gd_madd_carray(3) @@ -241,6 +245,11 @@ EXTERNAL GDMLSP C Correpsonding to gd_move(3) EXTERNAL GDMOVE +C Corresponding to gd_mstrings(3) (sort of) + EXTERNAL GDMSTS +C Returns the maximum length of the longest string metafield for a +C field + EXTERNAL GDMSTX C Corresponding to gd_mvector_list(3) (sort of) EXTERNAL GDMVEN C Corresponding to gd_dirfilename(3) @@ -285,8 +294,16 @@ EXTERNAL GDRFRG C Corresponding to gd_raw_filename(3) EXTERNAL GDRWFN +C Corresponding to gd_seek(3) + EXTERNAL GDSEEK C Corresponding to gd_dirfile_standards(3) EXTERNAL GDSTDV +C Corresponding to gd_strings(3) (sort of) + EXTERNAL GDSTRS +C Returns the length of the longest string field + EXTERNAL GDSTRX +C Corresponding to gd_tell(3) + EXTERNAL GDTELL C Corresponding to gd_uninclude(3) EXTERNAL GDUINC C Corresponding to gd_vector_list(3) (sort of) Modified: trunk/getdata/bindings/f77/getdata.f90.in =================================================================== --- trunk/getdata/bindings/f77/getdata.f90.in 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/bindings/f77/getdata.f90.in 2011-10-20 22:53:01 UTC (rev 609) @@ -2143,4 +2143,287 @@ call gdtell(fgd_tell, dirfile, TRIM(field_name), LEN_TRIM(field_name)) end function +! gd_constants with return_type=GD_INT8 +subroutine fgd_constants_i1 (constants, dirfile) + integer*1, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_INT8, i) + end do +end subroutine + +! gd_constants with return_type=GD_INT16 +subroutine fgd_constants_i2 (constants, dirfile) + integer*2, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_INT16, i) + end do +end subroutine + +! gd_constants with return_type=GD_INT32 +subroutine fgd_constants_i4 (constants, dirfile) + integer*4, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_INT32, i) + end do +end subroutine + +! gd_constants with return_type=GD_INT64 +subroutine fgd_constants_i8 (constants, dirfile) + integer*8, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_INT64, i) + end do +end subroutine + +! gd_constants with return_type=GD_FLOAT32 +subroutine fgd_constants_r4 (constants, dirfile) + real*4, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_FLOAT32, i) + end do +end subroutine + +! gd_constants with return_type=GD_FLOAT64 +subroutine fgd_constants_r8 (constants, dirfile) + real*8, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_STRING_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_FLOAT64, i) + end do +end subroutine + +! gd_constants with return_type=GD_COMPLEX64 +subroutine fgd_constants_c8 (constants, dirfile) + complex, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_STRING_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_COMPLEX64, i) + end do +end subroutine + +! gd_constants with return_type=GD_COMPLEX128 +subroutine fgd_constants_c16 (constants, dirfile) + double complex, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + + nfields = fgd_nfields_by_type(dirfile, GD_STRING_ENTRY) + do i=1,nfields + ! call f77 library + call gdcons(constants(i), dirfile, GD_COMPLEX128, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_INT8 +subroutine fgd_mconstants_i1 (constants, dirfile, parent) + integer*1, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_INT8, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_INT16 +subroutine fgd_mconstants_i2 (constants, dirfile, parent) + integer*2, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_INT16, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_INT32 +subroutine fgd_mconstants_i4 (constants, dirfile, parent) + integer*4, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_INT32, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_INT64 +subroutine fgd_mconstants_i8 (constants, dirfile, parent) + integer*8, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_INT64, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_FLOAT32 +subroutine fgd_mconstants_r4 (constants, dirfile, parent) + real*4, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_FLOAT32, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_FLOAT64 +subroutine fgd_mconstants_r8 (constants, dirfile, parent) + real*8, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_FLOAT64, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_COMPLEX64 +subroutine fgd_mconstants_c8 (constants, dirfile, parent) + complex, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_COMPLEX64, i) + end do +end subroutine + +! gd_mconstants with return_type=GD_COMPLEX128 +subroutine fgd_mconstants_c16 (constants, dirfile, parent) + double complex, dimension(:), intent(out) :: constants + integer, intent(in) :: dirfile + integer :: nfields, i + character (len=*), intent(in) :: parent + + nfields = fgd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY) + do i=1,nfields + ! call f77 library + call gdmcos(constants(i), dirfile, TRIM(parent), LEN_TRIM(parent), & + GD_COMPLEX128, i) + end do +end subroutine + +function fgd_string_value_max (dirfile) + integer :: fgd_string_value_max + integer, intent(in) :: dirfile + + ! call f77 library + call gdstrx(fgd_string_value_max, dirfile) +end function + +subroutine fgd_strings (strings, dirfile, string_len) + character(len=*), dimension(:), intent(out) :: strings + integer, intent(in) :: dirfile + integer, intent(inout) :: string_len + integer :: max_len, nfields, i + + ! make sure the string list is large enough + max_len = fgd_string_value_max(dirfile) + + if (string_len .lt. max_len) then + string_len = max_len + else + nfields = fgd_nfields_by_type(dirfile, GD_STRING_ENTRY) + do i=1,nfields + ! call f77 library + call gdstrs(strings(i), string_len, dirfile, i) + end do + end if +end subroutine + +function fgd_mstring_value_max (dirfile, parent) + integer :: fgd_mstring_value_max + integer, intent(in) :: dirfile + character (len=*), intent(in) :: parent + + ! call f77 library + call gdmstx(fgd_mstring_value_max, dirfile, TRIM(parent), LEN_TRIM(parent)) +end function + +subroutine fgd_mstrings (strings, dirfile, parent, string_len) + character(len=*), dimension(:), intent(out) :: strings + integer, intent(in) :: dirfile + integer, intent(inout) :: string_len + integer :: max_len, nfields, i + character (len=*), intent(in) :: parent + + ! make sure the field list is large enough + max_len = fgd_mstring_value_max(dirfile, parent) + + if (string_len .lt. max_len) then + string_len = max_len + else + nfields = fgd_nmfields_by_type(dirfile, parent, GD_STRING_ENTRY) + do i=1,nfields + ! call f77 library + call gdmsts(strings(i), string_len, dirfile, TRIM(parent), & + LEN_TRIM(parent), i) + end do + end if +end subroutine + end module Modified: trunk/getdata/bindings/f77/test/big_test.f =================================================================== --- trunk/getdata/bindings/f77/test/big_test.f 2011-10-19 10:15:31 UTC (rev 608) +++ trunk/getdata/bindings/f77/test/big_test.f 2011-10-20 22:53:01 UTC (rev 609) @@ -40,10 +40,13 @@ PARAMETER (flen = 7) INTEGER nfields PARAMETER (nfields = 14) + INTEGER slen + PARAMETER (slen = 26) + CHARACTER*26 strings(3) CHARACTER*7 fields(nfields + 7) CHARACTER*7 fn - CHARACTER*20 str + CHARACTER*26 str INTEGER*1 c(8) INTEGER*1 datdat(80) INTEGER*1 k @@ -121,7 +124,7 @@ ne = 0 IF (e .NE. GD_EOP) THEN ne = ne + 1 - WRITE(*, 2001) 0, e + WRITE(*, 9001) 0, e ENDIF C 1: GDOPEN check @@ -130,7 +133,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 1, e + WRITE(*, 9001) 1, e ENDIF C 2: GDGETD check @@ -139,18 +142,18 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 2, e + WRITE(*, 9001) 2, e ENDIF IF (n .NE. 8) THEN ne = ne + 1 - WRITE(*, 2002) 2, n + WRITE(*, 9002) 2, n ENDIF DO 20 i = 1, 8 IF (c(i) .NE. 40 + i) THEN ne = ne + 1 - WRITE(*, 2004) i, 2, c(i) + WRITE(*, 9004) i, 2, c(i) ENDIF 20 CONTINUE @@ -160,12 +163,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 3, e + WRITE(*, 9001) 3, e ENDIF IF (abs(fl - 5.5) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2005) 3, fl + WRITE(*, 9005) 3, fl ENDIF C 4: GDFDNX check @@ -174,12 +177,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 4, e + WRITE(*, 9001) 4, e ENDIF IF (i .NE. flen) THEN ne = ne + 1 - WRITE(*, 2002) 4, i + WRITE(*, 9002) 4, i ENDIF C 5: GDMFNX check @@ -188,12 +191,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 5, e + WRITE(*, 9001) 5, e ENDIF IF (i .NE. 6) THEN ne = ne + 1 - WRITE(*, 2002) 5, i + WRITE(*, 9002) 5, i ENDIF C 6: GDNFLD check @@ -202,12 +205,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 6, e + WRITE(*, 9001) 6, e ENDIF IF (n .NE. nfields) THEN ne = ne + 1 - WRITE(*, 2002) 6, n + WRITE(*, 9002) 6, n ENDIF C 7: This is a check of (one of many instances of) _GDF_FString @@ -217,12 +220,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 7, e + WRITE(*, 9001) 7, e ENDIF IF (l .NE. 5) THEN ne = ne + 1 - WRITE(*, 2002) 7, l + WRITE(*, 9002) 7, l ENDIF C 8: GDFLDN check @@ -233,17 +236,17 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 8, i, e + WRITE(*, 9006) 8, i, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 8, i, l + WRITE(*, 9007) 8, i, l ENDIF IF (fn .NE. fields(i)) THEN ne = ne + 1 - WRITE(*, 2008) i, 8, fn + WRITE(*, 9008) i, 8, fn ENDIF 80 CONTINUE @@ -253,12 +256,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 9, e + WRITE(*, 9001) 9, e ENDIF IF (n .NE. 3) THEN ne = ne + 1 - WRITE(*, 2002) 9, n + WRITE(*, 9002) 9, n ENDIF C 10: GDMFDN check @@ -272,17 +275,17 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 10, i, e + WRITE(*, 9006) 10, i, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 10, i, l + WRITE(*, 9007) 10, i, l ENDIF IF (fn .NE. fields(i)) THEN ne = ne + 1 - WRITE(*, 2008) i, 10, fn + WRITE(*, 9008) i, 10, fn ENDIF 100 CONTINUE @@ -292,12 +295,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 11, e + WRITE(*, 9001) 11, e ENDIF IF (n .NE. 10) THEN ne = ne + 1 - WRITE(*, 2002) 11, n + WRITE(*, 9002) 11, n ENDIF C 12: GDGSPF check @@ -306,12 +309,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 12, e + WRITE(*, 9001) 12, e ENDIF IF (n .NE. 8) THEN ne = ne + 1 - WRITE(*, 2002) 12, n + WRITE(*, 9002) 12, n ENDIF C 13: GDPUTD check @@ -328,12 +331,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 13, e + WRITE(*, 9001) 13, e ENDIF IF (n .NE. 4) THEN ne = ne + 1 - WRITE(*, 2002) 13, n + WRITE(*, 9002) 13, n ENDIF CALL GDGETD(n, d, 'data', 4, 5, 0, 1, 0, GD_I8, c) @@ -342,17 +345,17 @@ IF (((i .EQ. 1 .OR. i .GT. 5) .AND. c(i) .NE. 40 + i) .OR. +(i .GT. 1 .AND. i .LT. 6) .AND. c(i) .NE. 11 + i) THEN ne = ne + 1 - WRITE(*, 2004) i, 13, c(i) + WRITE(*, 9004) i, 13, c(i) ENDIF 130 CONTINUE C 14: GDESTR check CALL GDGETD(n, d, 'x', 1, 5, 0, 1, 0, GD_I8, c) - CALL GDESTR(d, str, 20) + CALL GDESTR(d, str, slen) IF (str .NE. 'Field not found: x ') THEN ne = ne + 1 - WRITE(*, 2009) 14, str + WRITE(*, 9009) 14, str ENDIF C 15: GDENTY check @@ -361,12 +364,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 15, e + WRITE(*, 9001) 15, e ENDIF IF (n .NE. GD_RWE) THEN ne = ne + 1 - WRITE(*, 2002) 15, n + WRITE(*, 9002) 15, n ENDIF C 16: GDGERW check @@ -375,22 +378,22 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 16, e + WRITE(*, 9001) 16, e ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 16, 1, n + WRITE(*, 9007) 16, 1, n ENDIF IF (l .NE. 8) THEN ne = ne + 1 - WRITE(*, 2007) 16, 2, l + WRITE(*, 9007) 16, 2, l ENDIF IF (i .NE. GD_I8) THEN ne = ne + 1 - WRITE(*, 2007) 16, 3, i + WRITE(*, 9007) 16, 3, i ENDIF C 17: GDGELC check @@ -401,37 +404,37 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 17, e + WRITE(*, 9001) 17, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 17, 1, l + WRITE(*, 9007) 17, 1, l ENDIF IF (i .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 17, 2, i + WRITE(*, 9007) 17, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 17, 3, n + WRITE(*, 9007) 17, 3, n ENDIF IF (fields(1) .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 17, 4, fields(1) + WRITE(*, 9008) 17, 4, fields(1) ENDIF IF (fields(2) .NE. 'INDEX') THEN ne = ne + 1 - WRITE(*, 2008) 17, 5, fields(2) + WRITE(*, 9008) 17, 5, fields(2) ENDIF IF (fields(3) .NE. 'linterp') THEN ne = ne + 1 - WRITE(*, 2008) 17, 6, fields(3) + WRITE(*, 9008) 17, 6, fields(3) ENDIF q(1) = 1.1 @@ -443,7 +446,7 @@ DO 170 i=1,6 IF (abs(p(i) - q(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2010) i, 17, p(i) + WRITE(*, 9010) i, 17, p(i) ENDIF 170 CONTINUE @@ -455,37 +458,37 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 18, e + WRITE(*, 9001) 18, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 18, 1, l + WRITE(*, 9007) 18, 1, l ENDIF IF (i .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 18, 2, i + WRITE(*, 9007) 18, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 18, 3, n + WRITE(*, 9007) 18, 3, n ENDIF IF (fields(1) .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 18, 4, fields(1) + WRITE(*, 9008) 18, 4, fields(1) ENDIF IF (fields(2) .NE. 'INDEX') THEN ne = ne + 1 - WRITE(*, 2008) 18, 5, fields(2) + WRITE(*, 9008) 18, 5, fields(2) ENDIF IF (fields(3) .NE. 'linterp') THEN ne = ne + 1 - WRITE(*, 2008) 18, 6, fields(3) + WRITE(*, 9008) 18, 6, fields(3) ENDIF cq(1) = cmplx(1.1, 0.0) @@ -497,7 +500,7 @@ DO 180 i=1,6 IF (abs(cp(i) - cq(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2011) i, 18, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) + WRITE(*, 9011) i, 18, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) ENDIF 180 CONTINUE @@ -509,27 +512,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 19, e + WRITE(*, 9001) 19, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 19, 1, l + WRITE(*, 9007) 19, 1, l ENDIF IF (i .NE. 5) THEN ne = ne + 1 - WRITE(*, 2007) 19, 2, i + WRITE(*, 9007) 19, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 19, 3, n + WRITE(*, 9007) 19, 3, n ENDIF IF (fn .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 19, 4, fn + WRITE(*, 9008) 19, 4, fn ENDIF q(1) = 1.1 @@ -541,7 +544,7 @@ DO 190 i=1,6 IF (abs(p(i) - q(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2010) i, 19, p(i) + WRITE(*, 9010) i, 19, p(i) ENDIF 190 CONTINUE @@ -553,27 +556,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 20, e + WRITE(*, 9001) 20, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 20, 1, l + WRITE(*, 9007) 20, 1, l ENDIF IF (i .NE. 5) THEN ne = ne + 1 - WRITE(*, 2007) 20, 2, i + WRITE(*, 9007) 20, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 20, 3, n + WRITE(*, 9007) 20, 3, n ENDIF IF (fn .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 20, 4, fn + WRITE(*, 9008) 20, 4, fn ENDIF cq(1) = cmplx(1.1, 0.0) @@ -585,38 +588,38 @@ DO 200 i=1,6 IF (abs(cp(i) - cq(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2011) i, 30, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) + WRITE(*, 9011) i, 30, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) ENDIF 200 CONTINUE C 21: GDGELT check l = flen - CALL GDGELT(fn, l, str, 20, n, d, 'linterp', 7) + CALL GDGELT(fn, l, str, slen, n, d, 'linterp', 7) CALL GDEROR(e, d) IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 21, e + WRITE(*, 9001) 21, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 21, 1, l + WRITE(*, 9007) 21, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 21, 2, n + WRITE(*, 9007) 21, 2, n ENDIF IF (fn .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 21, 3, fn + WRITE(*, 9008) 21, 3, fn ENDIF IF (str .NE. '/look/up/file') THEN ne = ne + 1 - WRITE(*, 2008) 21, 4, str + WRITE(*, 9008) 21, 4, str ENDIF C 22: GDGEBT check @@ -626,32 +629,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 22, e + WRITE(*, 9001) 22, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 22, 1, l + WRITE(*, 9007) 22, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 22, 2, n + WRITE(*, 9007) 22, 2, n ENDIF IF (i .NE. 4) THEN ne = ne + 1 - WRITE(*, 2007) 22, 3, i + WRITE(*, 9007) 22, 3, i ENDIF IF (m .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 22, 4, m + WRITE(*, 9007) 22, 4, m ENDIF IF (fn .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 22, 5, fn + WRITE(*, 9008) 22, 5, fn ENDIF C 23: GDGESB check @@ -661,32 +664,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 23, e + WRITE(*, 9001) 23, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 23, 1, l + WRITE(*, 9007) 23, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 23, 2, n + WRITE(*, 9007) 23, 2, n ENDIF IF (i .NE. 6) THEN ne = ne + 1 - WRITE(*, 2007) 23, 3, i + WRITE(*, 9007) 23, 3, i ENDIF IF (m .NE. 5) THEN ne = ne + 1 - WRITE(*, 2007) 23, 4, m + WRITE(*, 9007) 23, 4, m ENDIF IF (fn .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 23, 5, fn + WRITE(*, 9008) 23, 5, fn ENDIF C 24: GDGEMT check @@ -696,27 +699,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 24, e + WRITE(*, 9001) 24, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 24, 1, l + WRITE(*, 9007) 24, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 24, 2, n + WRITE(*, 9007) 24, 2, n ENDIF IF (fields(1) .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 24, 3, fields(1) + WRITE(*, 9008) 24, 3, fields(1) ENDIF IF (fields(2) .NE. 'sbit') THEN ne = ne + 1 - WRITE(*, 2008) 24, 4, fields(2) + WRITE(*, 9008) 24, 4, fields(2) ENDIF C 25: GDGEPH check @@ -726,27 +729,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 25, e + WRITE(*, 9001) 25, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 25, 1, l + WRITE(*, 9007) 25, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 25, 2, n + WRITE(*, 9007) 25, 2, n ENDIF IF (i .NE. 11) THEN ne = ne + 1 - WRITE(*, 2007) 25, 3, i + WRITE(*, 9007) 25, 3, i ENDIF IF (fn .NE. 'data') THEN ne = ne + 1 - WRITE(*, 2008) 25, 4, fn + WRITE(*, 9008) 25, 4, fn ENDIF C 26: GDGECO check @@ -755,17 +758,17 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 26, e + WRITE(*, 9001) 26, e ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 26, 1, n + WRITE(*, 9007) 26, 1, n ENDIF IF (i .NE. GD_F64) THEN ne = ne + 1 - WRITE(*, 2007) 26, 2, i + WRITE(*, 9007) 26, 2, i ENDIF C 27: GDFRGI check @@ -774,12 +777,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 27, e + WRITE(*, 9001) 27, e ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2002) 27, n + WRITE(*, 9002) 27, n ENDIF C 28: GDADRW check @@ -788,7 +791,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 28, 1, e + WRITE(*, 9006) 28, 1, e ENDIF CALL GDGERW(l, i, n, d, 'new1', 4) @@ -796,22 +799,22 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 28, 2, e + WRITE(*, 9006) 28, 2, e ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 28, 3, n + WRITE(*, 9007) 28, 3, n ENDIF IF (l .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 28, 4, l + WRITE(*, 9007) 28, 4, l ENDIF IF (i .NE. GD_F64) THEN ne = ne + 1 - WRITE(*, 2007) 28, 5, i + WRITE(*, 9007) 28, 5, i ENDIF C 29: GDADLC check @@ -821,7 +824,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 29, 1, e + WRITE(*, 9006) 29, 1, e ENDIF l = flen @@ -831,32 +834,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 29, 2, e + WRITE(*, 9006) 29, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 29, 3, l + WRITE(*, 9007) 29, 3, l ENDIF IF (i .NE. 2) THEN ne = ne + 1 - WRITE(*, 2007) 29, 4, i + WRITE(*, 9007) 29, 4, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 29, 5, n + WRITE(*, 9007) 29, 5, n ENDIF IF (fields(1) .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 29, 6, fields(1) + WRITE(*, 9008) 29, 6, fields(1) ENDIF IF (fields(2) .NE. 'in2') THEN ne = ne + 1 - WRITE(*, 2008) 29, 7, fields(2) + WRITE(*, 9008) 29, 7, fields(2) ENDIF q(1) = 9.9 @@ -868,7 +871,7 @@ DO 290 i=1,4 IF (abs(p(i) - q(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2010) i, 29, p(i) + WRITE(*, 9010) i, 29, p(i) ENDIF 290 CONTINUE @@ -883,7 +886,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 30, 1, e + WRITE(*, 9006) 30, 1, e ENDIF l = flen @@ -893,32 +896,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 30, e + WRITE(*, 9001) 30, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 30, 1, l + WRITE(*, 9007) 30, 1, l ENDIF IF (i .NE. 2) THEN ne = ne + 1 - WRITE(*, 2007) 30, 2, i + WRITE(*, 9007) 30, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 30, 3, n + WRITE(*, 9007) 30, 3, n ENDIF IF (fields(1) .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 30, 4, fields(1) + WRITE(*, 9008) 30, 4, fields(1) ENDIF IF (fields(2) .NE. 'in2') THEN ne = ne + 1 - WRITE(*, 2008) 30, 5, fields(2) + WRITE(*, 9008) 30, 5, fields(2) ENDIF cq(1) = cmplx(1.1, 1.2) @@ -928,7 +931,7 @@ DO 300 i=1,4 IF (abs(cp(i) - cq(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2011) i, 30, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) + WRITE(*, 9011) i, 30, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) ENDIF 300 CONTINUE @@ -939,7 +942,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 31, 1, e + WRITE(*, 9006) 31, 1, e ENDIF l = flen @@ -949,27 +952,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 31, 2, e + WRITE(*, 9006) 31, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 31, 1, l + WRITE(*, 9007) 31, 1, l ENDIF IF (i .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 31, 2, i + WRITE(*, 9007) 31, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 31, 3, n + WRITE(*, 9007) 31, 3, n ENDIF IF (fn .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 31, 4, fn + WRITE(*, 9008) 31, 4, fn ENDIF q(1) = 3d3 @@ -982,7 +985,7 @@ DO 310 i=1,4 IF (abs(p(i) - q(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2010) i, 31, p(i) + WRITE(*, 9010) i, 31, p(i) ENDIF 310 CONTINUE @@ -997,7 +1000,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 32, 1, e + WRITE(*, 9006) 32, 1, e ENDIF l = flen @@ -1007,27 +1010,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 32, 2, e + WRITE(*, 9006) 32, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 32, 1, l + WRITE(*, 9007) 32, 1, l ENDIF IF (i .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 32, 2, i + WRITE(*, 9007) 32, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 32, 3, n + WRITE(*, 9007) 32, 3, n ENDIF IF (fn .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 32, 4, fn + WRITE(*, 9008) 32, 4, fn ENDIF cq(1) = cmplx(3.1, 7.0) @@ -1037,7 +1040,7 @@ DO 320 i=1,4 IF (abs(cp(i) - cq(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2011) i, 32, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) + WRITE(*, 9011) i, 32, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) ENDIF 320 CONTINUE @@ -1047,36 +1050,36 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 33, 1, e + WRITE(*, 9006) 33, 1, e ENDIF l = flen - CALL GDGELT(fn, l, str, 20, n, d, 'new6', 4) + CALL GDGELT(fn, l, str, slen, n, d, 'new6', 4) CALL GDEROR(e, d) IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 33, 2, e + WRITE(*, 9006) 33, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 33, 1, l + WRITE(*, 9007) 33, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 33, 2, n + WRITE(*, 9007) 33, 2, n ENDIF IF (fn .NE. 'in') THEN ne = ne + 1 - WRITE(*, 2008) 33, 3, fn + WRITE(*, 9008) 33, 3, fn ENDIF IF (str .NE. './some/table') THEN ne = ne + 1 - WRITE(*, 2008) 33, 4, str + WRITE(*, 9008) 33, 4, str ENDIF C 34: GDADBT check @@ -1085,7 +1088,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 34, 1, e + WRITE(*, 9006) 34, 1, e ENDIF l = flen @@ -1094,32 +1097,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 34, 2, e + WRITE(*, 9006) 34, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 34, 1, l + WRITE(*, 9007) 34, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 34, 2, n + WRITE(*, 9007) 34, 2, n ENDIF IF (i .NE. 12) THEN ne = ne + 1 - WRITE(*, 2007) 34, 3, i + WRITE(*, 9007) 34, 3, i ENDIF IF (m .NE. 13) THEN ne = ne + 1 - WRITE(*, 2007) 34, 4, m + WRITE(*, 9007) 34, 4, m ENDIF IF (fn .NE. 'in') THEN ne = ne + 1 - WRITE(*, 2008) 34, 5, fn + WRITE(*, 9008) 34, 5, fn ENDIF C 35: GDADSB check @@ -1128,7 +1131,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 35, 1, e + WRITE(*, 9006) 35, 1, e ENDIF l = flen @@ -1137,32 +1140,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 35, 2, e + WRITE(*, 9006) 35, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 35, 1, l + WRITE(*, 9007) 35, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 35, 2, n + WRITE(*, 9007) 35, 2, n ENDIF IF (i .NE. 12) THEN ne = ne + 1 - WRITE(*, 2007) 35, 3, i + WRITE(*, 9007) 35, 3, i ENDIF IF (m .NE. 13) THEN ne = ne + 1 - WRITE(*, 2007) 35, 4, m + WRITE(*, 9007) 35, 4, m ENDIF IF (fn .NE. 'in') THEN ne = ne + 1 - WRITE(*, 2008) 35, 5, fn + WRITE(*, 9008) 35, 5, fn ENDIF C 36: GDADMT check @@ -1171,7 +1174,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 36, 1, e + WRITE(*, 9006) 36, 1, e ENDIF l = flen @@ -1180,27 +1183,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 36, 2, e + WRITE(*, 9006) 36, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 36, 1, l + WRITE(*, 9007) 36, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 36, 2, n + WRITE(*, 9007) 36, 2, n ENDIF IF (fields(1) .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 36, 3, fields(1) + WRITE(*, 9008) 36, 3, fields(1) ENDIF IF (fields(2) .NE. 'in2') THEN ne = ne + 1 - WRITE(*, 2008) 36, 4, fields(2) + WRITE(*, 9008) 36, 4, fields(2) ENDIF C 37: GDADPH check @@ -1209,7 +1212,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 37, 1, e + WRITE(*, 9006) 37, 1, e ENDIF l = flen @@ -1218,27 +1221,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 37, 2, e + WRITE(*, 9006) 37, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 37, 1, l + WRITE(*, 9007) 37, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 37, 2, n + WRITE(*, 9007) 37, 2, n ENDIF IF (i .NE. 22) THEN ne = ne + 1 - WRITE(*, 2007) 37, 3, i + WRITE(*, 9007) 37, 3, i ENDIF IF (fn .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 37, 4, fn + WRITE(*, 9008) 37, 4, fn ENDIF C 38: GDADCO check @@ -1247,7 +1250,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 38, 1, e + WRITE(*, 9006) 38, 1, e ENDIF CALL GDGECO(i, n, d, 'new11', 5) @@ -1255,17 +1258,17 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 38, 2, e + WRITE(*, 9006) 38, 2, e ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 38, 1, n + WRITE(*, 9007) 38, 1, n ENDIF IF (i .NE. GD_F64) THEN ne = ne + 1 - WRITE(*, 2007) 38, 2, i + WRITE(*, 9007) 38, 2, i ENDIF CALL GDGTCO(d, 'new11', 5, GD_F32, fl) @@ -1273,26 +1276,26 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 38, 3, e + WRITE(*, 9006) 38, 3, e ENDIF IF (abs(fl + 8.1) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2005) 38, fl + WRITE(*, 9005) 38, fl ENDIF C 39: GDFRGN check - CALL GDFRGN(str, 20, d, 0) + CALL GDFRGN(str, slen, d, 0) CALL GDEROR(e, d) IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 39, e + WRITE(*, 9001) 39, e ENDIF IF (str .NE. 'test_dirfile/format') THEN ne = ne + 1 - WRITE(*, 2009), 39, str + WRITE(*, 9009), 39, str ENDIF C 40: GDNFRG check @@ -1301,12 +1304,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 40, e + WRITE(*, 9001) 40, e ENDIF IF (n .NE. 1) THEN ne = ne + 1 - WRITE(*, 2002), 40, n + WRITE(*, 9002), 40, n ENDIF C 41: GDINCL check @@ -1315,7 +1318,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 41, 3, e + WRITE(*, 9006) 41, 3, e ENDIF CALL GDGTCO(d, 'const2', 6, GD_I8, c(1)) @@ -1323,12 +1326,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 41, 3, e + WRITE(*, 9006) 41, 3, e ENDIF IF (c(1) .NE. -19) THEN ne = ne + 1 - WRITE(*, 2004) 1, 41, c(1) + WRITE(*, 9004) 1, 41, c(1) ENDIF C 42: GDNFDT check @@ -1337,12 +1340,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 42, e + WRITE(*, 9001) 42, e ENDIF IF (n .NE. 3) THEN ne = ne + 1 - WRITE(*, 2002), 42, n + WRITE(*, 9002), 42, n ENDIF C 43: GDFDNT check @@ -1356,17 +1359,17 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 43, i, e + WRITE(*, 9006) 43, i, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 43, i, l + WRITE(*, 9007) 43, i, l ENDIF IF (fn .NE. fields(i)) THEN ne = ne + 1 - WRITE(*, 2008) i, 43, fn + WRITE(*, 9008) i, 43, fn ENDIF 430 CONTINUE @@ -1376,12 +1379,12 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 44, e + WRITE(*, 9001) 44, e ENDIF IF (n .NE. 21) THEN ne = ne + 1 - WRITE(*, 2002), 44, n + WRITE(*, 9002), 44, n ENDIF C 45: GDVECN check @@ -1413,17 +1416,17 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 45, i, e + WRITE(*, 9006) 45, i, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 45, i, l + WRITE(*, 9007) 45, i, l ENDIF IF (fn .NE. fields(i)) THEN ne = ne + 1 - WRITE(*, 2008) i, 45, fn + WRITE(*, 9008) i, 45, fn ENDIF 450 CONTINUE @@ -1434,7 +1437,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 46, 1, e + WRITE(*, 9006) 46, 1, e ENDIF l = flen @@ -1444,32 +1447,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 46, 2, e + WRITE(*, 9006) 46, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 46, 3, l + WRITE(*, 9007) 46, 3, l ENDIF IF (i .NE. 2) THEN ne = ne + 1 - WRITE(*, 2007) 46, 4, i + WRITE(*, 9007) 46, 4, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 46, 5, n + WRITE(*, 9007) 46, 5, n ENDIF IF (fields(1) .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 46, 6, fields(1) + WRITE(*, 9008) 46, 6, fields(1) ENDIF IF (fields(2) .NE. 'in2') THEN ne = ne + 1 - WRITE(*, 2008) 46, 7, fields(2) + WRITE(*, 9008) 46, 7, fields(2) ENDIF q(1) = 9.9 @@ -1481,7 +1484,7 @@ DO 460 i=1,4 IF (abs(p(i) - q(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2010) i, 46, p(i) + WRITE(*, 9010) i, 46, p(i) ENDIF 460 CONTINUE @@ -1496,7 +1499,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 47, 1, e + WRITE(*, 9006) 47, 1, e ENDIF l = flen @@ -1506,32 +1509,32 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2001) 47, e + WRITE(*, 9001) 47, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 47, 1, l + WRITE(*, 9007) 47, 1, l ENDIF IF (i .NE. 2) THEN ne = ne + 1 - WRITE(*, 2007) 47, 2, i + WRITE(*, 9007) 47, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 47, 3, n + WRITE(*, 9007) 47, 3, n ENDIF IF (fields(1) .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 47, 4, fields(1) + WRITE(*, 9008) 47, 4, fields(1) ENDIF IF (fields(2) .NE. 'in2') THEN ne = ne + 1 - WRITE(*, 2008) 47, 5, fields(2) + WRITE(*, 9008) 47, 5, fields(2) ENDIF cq(1) = cmplx(1.1, 1.2) @@ -1541,7 +1544,7 @@ DO 470 i=1,4 IF (abs(cp(i) - cq(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2011) i, 47, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) + WRITE(*, 9011) i, 47, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) ENDIF 470 CONTINUE @@ -1552,7 +1555,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 48, 1, e + WRITE(*, 9006) 48, 1, e ENDIF l = flen @@ -1562,27 +1565,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 48, 2, e + WRITE(*, 9006) 48, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 48, 1, l + WRITE(*, 9007) 48, 1, l ENDIF IF (i .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 48, 2, i + WRITE(*, 9007) 48, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 48, 3, n + WRITE(*, 9007) 48, 3, n ENDIF IF (fn .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 48, 4, fn + WRITE(*, 9008) 48, 4, fn ENDIF q(1) = 3d3 @@ -1594,7 +1597,7 @@ DO 480 i=1,4 IF (abs(p(i) - q(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2010) i, 48, p(i) + WRITE(*, 9010) i, 48, p(i) ENDIF 480 CONTINUE @@ -1609,7 +1612,7 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 49, 1, e + WRITE(*, 9006) 49, 1, e ENDIF l = flen @@ -1619,27 +1622,27 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 49, 2, e + WRITE(*, 9006) 49, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 49, 1, l + WRITE(*, 9007) 49, 1, l ENDIF IF (i .NE. 3) THEN ne = ne + 1 - WRITE(*, 2007) 49, 2, i + WRITE(*, 9007) 49, 2, i ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 49, 3, n + WRITE(*, 9007) 49, 3, n ENDIF IF (fn .NE. 'in1') THEN ne = ne + 1 - WRITE(*, 2008) 49, 4, fn + WRITE(*, 9008) 49, 4, fn ENDIF cq(1) = cmplx(1.1, 0.0) @@ -1649,7 +1652,7 @@ DO 490 i=1,4 IF (abs(cp(i) - cq(i)) .gt. 0.001) THEN ne = ne + 1 - WRITE(*, 2011) i, 49, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) + WRITE(*, 9011) i, 49, REAL(REAL(cp(i))), REAL(AIMAG(cp(i))) ENDIF 490 CONTINUE @@ -1659,36 +1662,36 @@ IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 50, 1, e + WRITE(*, 9006) 50, 1, e ENDIF l = flen - CALL GDGELT(fn, l, str, 20, n, d, 'data/mnew6', 10) + CALL GDGELT(fn, l, str, slen, n, d, 'data/mnew6', 10) CALL GDEROR(e, d) IF (e .NE. GD_EOK) THEN ne = ne + 1 - WRITE(*, 2006) 50, 2, e + WRITE(*, 9006) 50, 2, e ENDIF IF (l .NE. flen) THEN ne = ne + 1 - WRITE(*, 2007) 50, 1, l + WRITE(*, 9007) 50, 1, l ENDIF IF (n .NE. 0) THEN ne = ne + 1 - WRITE(*, 2007) 50, 2, n + WRITE(*, 9007) 50, 2, n ENDIF IF (fn .NE. 'in') THEN ne = ne + 1 - ... [truncated message content] |
From: <ket...@us...> - 2011-10-19 10:15:40
|
Revision: 608 http://getdata.svn.sourceforge.net/getdata/?rev=608&view=rev Author: ketiltrout Date: 2011-10-19 10:15:31 +0000 (Wed, 19 Oct 2011) Log Message: ----------- off64_t -> gd_off64_t in public header. Modified Paths: -------------- trunk/getdata/src/getdata.h.in Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2011-10-18 01:48:16 UTC (rev 607) +++ trunk/getdata/src/getdata.h.in 2011-10-19 10:15:31 UTC (rev 608) @@ -945,10 +945,10 @@ extern gd_off64_t gd_eof64(DIRFILE *dirfile, const char *field_code) gd_nonnull ((1,2)); -extern off64_t gd_seek64(DIRFILE *dirfile, const char *field_code, - off64_t frame_num, off64_t sample_num, int whence) gd_nonnull ((1,2)); +extern gd_off64_t gd_seek64(DIRFILE *dirfile, const char *field_code, + gd_off64_t frame_num, gd_off64_t sample_num, int whence) gd_nonnull ((1,2)); -extern off64_t gd_tell64(DIRFILE *dirfile, const char *field_code) gd_nothrow +extern gd_off64_t gd_tell64(DIRFILE *dirfile, const char *field_code) gd_nothrow gd_nonnull ((1,2)); #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-10-18 01:48:24
|
Revision: 607 http://getdata.svn.sourceforge.net/getdata/?rev=607&view=rev Author: ketiltrout Date: 2011-10-18 01:48:16 +0000 (Tue, 18 Oct 2011) Log Message: ----------- Bindings and docs for gd_seek/gd_tell. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/bindings/cxx/dirfile.cpp trunk/getdata/bindings/cxx/getdata/dirfile.h trunk/getdata/bindings/f77/fgetdata.c trunk/getdata/bindings/f77/fgetdata.h trunk/getdata/bindings/f77/getdata.f90.in trunk/getdata/bindings/idl/getdata.c trunk/getdata/bindings/make_parameters.c trunk/getdata/bindings/perl/simple_funcs.xsin trunk/getdata/bindings/python/pydirfile.c trunk/getdata/doc/README.cxx trunk/getdata/doc/README.f77 trunk/getdata/doc/README.f95 trunk/getdata/man/Makefile.am trunk/getdata/man/gd_getdata.3 trunk/getdata/man/gd_putdata.3 trunk/getdata/src/fpos.c trunk/getdata/src/getdata.c trunk/getdata/src/putdata.c trunk/getdata/src/spf.c Added Paths: ----------- trunk/getdata/man/gd_seek.3 trunk/getdata/man/gd_tell.3 Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/ChangeLog 2011-10-18 01:48:16 UTC (rev 607) @@ -1,3 +1,20 @@ +2011-10-18 D. V. Wiebe <ge...@ke...> svn:607 + * man/gd_seek.3 man/gd_tell.3: Added. + + * src/spf.c (gd_spf): Throw GD_E_DIMENSION on scalar field specified per + documentation. + * src/fpos.c (gd_tell64 gd_seek64): Ditto. + + * src/putdata.c (_GD_DoFieldOut): Don't return on error from _GD_GetFilePos; + a better error will be generated later. + + * bindings/make_parameters.c: Add GD_E_ARGUMENT, GD_SEEK_*, GD_HERE. + * bindings/python/pydirfile.c (gdpy_dirfile_seek gdpy_dirfile_tell) + bindings/cxx/dirfile.cpp (Dirfile::Seek Dirfile::Tell) + bindings/perl/simple_funcs.xsin (seek tell) bindings/f77/fgetdata.c (GDSEEK + GDTELL) bindings/f77/getdata.f90.in (fgd_seek fgd_tell) + bindings/idl/getdata.c (gdidl_seek gdidl_tell): Added. + 2011-10-13 D. V. Wiebe <ge...@ke...> svn:606 * test/entry_divide.c test/entry_recip.c test/get_here.c test/get_heres.c test/put_here.c test/put_heres.c test/seek64.c test/seek_cur.c test/seek_end.c Modified: trunk/getdata/bindings/cxx/dirfile.cpp =================================================================== --- trunk/getdata/bindings/cxx/dirfile.cpp 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/cxx/dirfile.cpp 2011-10-18 01:48:16 UTC (rev 607) @@ -1,4 +1,4 @@ -// Copyright (C) 2008-2010 D. V. Wiebe +// Copyright (C) 2008-2011 D. V. Wiebe // /////////////////////////////////////////////////////////////////////////// // @@ -139,7 +139,7 @@ return gd_error(D); } -int Dirfile::ErrorCount() +int Dirfile::ErrorCount() const { return gd_error_count(D); } @@ -445,3 +445,14 @@ { return gd_dirfile_standards(D, version); } + +off_t Dirfile::Seek(const char* field_code, off_t frame_num, + off_t sample_num, int flags) const +{ + return gd_seek(D, field_code, frame_num, sample_num, flags); +} + +off_t Dirfile::Tell(const char* field_code) const +{ + return gd_tell(D, field_code); +} Modified: trunk/getdata/bindings/cxx/getdata/dirfile.h =================================================================== --- trunk/getdata/bindings/cxx/getdata/dirfile.h 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/cxx/getdata/dirfile.h 2011-10-18 01:48:16 UTC (rev 607) @@ -111,7 +111,7 @@ int Error() const; - int ErrorCount(); + int ErrorCount() const; const char *ErrorString(); const char *ErrorString(size_t n) gd_deprecated; @@ -205,6 +205,9 @@ unsigned int SamplesPerFrame(const char *field_code) const; + off_t Seek(const char* field_code, off_t frame_num, off_t sample_num, + int flags) const; + void SetCallback(gd_parser_callback_t sehandler, void* extra = NULL) const; @@ -212,6 +215,8 @@ const char **Strings() const; + off_t Tell(const char* field_code) const; + int UnInclude(int fragment_index, int del = 0) const; int Validate(const char* field_code) const; Modified: trunk/getdata/bindings/f77/fgetdata.c =================================================================== --- trunk/getdata/bindings/f77/fgetdata.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/f77/fgetdata.c 2011-10-18 01:48:16 UTC (rev 607) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * ************************************************************************* * @@ -2926,3 +2926,33 @@ dreturn("%i", *vers); } + +/* gd_seek wrapper */ +void F77_FUNC(gdseek, GDSEEK) (int* pos, const int* dirfile, + const char* field_code, const int* field_code_l, const int* frame_num, + const int* sample_num, const int* flags) +{ + char *fc = (char *)malloc(*field_code_l + 1); + dtrace("%p, %i, %p, %i, %i, %i, 0x%x", pos, *dirfile, field_code, + *field_code_l, *frame_num, *sample_num, *flags); + + *pos = (int)gd_seek(_GDF_GetDirfile(*dirfile), _GDF_CString(fc, field_code, + *field_code_l), *frame_num, *sample_num, *flags); + + free(fc); + dreturn("%i", *pos); +} + +/* gd_tell wrapper */ +void F77_FUNC(gdtell, GDTELL) (int* pos, const int* dirfile, + const char* field_code, const int* field_code_l) +{ + char *fc = (char *)malloc(*field_code_l + 1); + dtrace("%p, %i, %p, %i", pos, *dirfile, field_code, *field_code_l); + + *pos = (int)gd_tell(_GDF_GetDirfile(*dirfile), _GDF_CString(fc, field_code, + *field_code_l)); + + free(fc); + dreturn("%i", *pos); +} Modified: trunk/getdata/bindings/f77/fgetdata.h =================================================================== --- trunk/getdata/bindings/f77/fgetdata.h 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/f77/fgetdata.h 2011-10-18 01:48:16 UTC (rev 607) @@ -557,6 +557,13 @@ void F77_FUNC(gdpcas, GDPCAS) (const int *dirfile, const char *field_code, const int *field_code_l, const int *start, const int *n, const int *data_type, const void *data_in); + +void F77_FUNC(gdseek, GDSEEK) (int* pos, const int* dirfile, + const char* field_code, const int* field_code_l, const int* frame_num, + const int* sample_num, const int* flags); + +void F77_FUNC(gdtell, GDTELL) (int* pos, const int* dirfile, + const char* field_code, const int* field_code_l); #ifdef __cplusplus } #endif Modified: trunk/getdata/bindings/f77/getdata.f90.in =================================================================== --- trunk/getdata/bindings/f77/getdata.f90.in 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/f77/getdata.f90.in 2011-10-18 01:48:16 UTC (rev 607) @@ -1,4 +1,4 @@ -! Copyright (C) 2008-2010 D. V. Wiebe +! Copyright (C) 2008-2011 D. V. Wiebe ! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! @@ -2126,4 +2126,21 @@ array_len) end subroutine +function fgd_seek (dirfile, field_name, frame_num, sample_num, flags) + integer :: fgd_seek + integer, intent(in) :: dirfile, frame_num, sample_num, flags + character (len=*), intent(in) :: field_name + + call gdseek(fgd_seek, dirfile, TRIM(field_name), LEN_TRIM(field_name), & + frame_num, sample_num, flags) +end function + +function fgd_tell (dirfile, field_name) + integer :: fgd_tell + integer, intent(in) :: dirfile + character (len=*), intent(in) :: field_name + + call gdtell(fgd_tell, dirfile, TRIM(field_name), LEN_TRIM(field_name)) +end function + end module Modified: trunk/getdata/bindings/idl/getdata.c =================================================================== --- trunk/getdata/bindings/idl/getdata.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/idl/getdata.c 2011-10-18 01:48:16 UTC (rev 607) @@ -3476,7 +3476,7 @@ DIRFILE* D = gdidl_get_dirfile(IDL_LongScalar(argv[0])); const char *field_code = IDL_VarGetString(argv[1]); - off64_t bof = gd_bof(D, field_code); + off64_t bof = gd_bof64(D, field_code); GDIDL_SET_ERROR(D); @@ -3839,7 +3839,7 @@ DIRFILE* D = gdidl_get_dirfile(IDL_LongScalar(argv[0])); const char *field_code = IDL_VarGetString(argv[1]); - off64_t eof = gd_eof(D, field_code); + off64_t eof = gd_eof64(D, field_code); GDIDL_SET_ERROR(D); @@ -4688,8 +4688,81 @@ return r; } +/* @@DLM: F gdidl_seek GD_SEEK 2 2 KEYWORDS */ +IDL_VPTR gdidl_seek(int argc, IDL_VPTR argv[], char *argk) +{ + dtraceidl(); + typedef struct { + IDL_KW_RESULT_FIRST_FIELD; + GDIDL_KW_RESULT_ERROR; + off64_t frame_num; + off64_t sample_num; + int whence; + int pad; + } KW_RESULT; + KW_RESULT kw; + kw.whence = GD_SEEK_SET; + kw.frame_num = kw.sample_num = 0; + kw.pad = 0; + GDIDL_KW_INIT_ERROR; + + static IDL_KW_PAR kw_pars[] = { + GDIDL_KW_PAR_ERROR, + GDIDL_KW_PAR_ESTRING, + { "FRAME_NUM", IDL_TYP_LONG64, 1, 0, 0, IDL_KW_OFFSETOF(frame_num) }, + { "SAMPLE_NUM", IDL_TYP_LONG64, 1, 0, 0, IDL_KW_OFFSETOF(sample_num) }, + { "PAD", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(pad) }, + { "WHENCE", IDL_TYP_INT, 1, 0, 0, IDL_KW_OFFSETOF(whence) }, + { NULL } + }; + + argc = IDL_KWProcessByOffset(argc, argv, argk, kw_pars, NULL, 1, &kw); + + DIRFILE *D = gdidl_get_dirfile(IDL_LongScalar(argv[0])); + const char* field_code = IDL_VarGetString(argv[1]); + + off64_t pos = gd_seek64(D, field_code, kw.frame_num, kw.sample_num, + (kw.whence & (GD_SEEK_SET | GD_SEEK_CUR | GD_SEEK_END)) | + (kw.pad ? GD_SEEK_PAD : 0)); + + GDIDL_SET_ERROR(D); + + IDL_KW_FREE; + + IDL_VPTR r = IDL_Gettmp(); + r->type = IDL_TYP_LONG64; + r->value.l64 = (IDL_LONG64)pos; + dreturn("%p", r); + return r; +} + +/* @@DLM: F gdidl_tell GD_TELL 2 2 KEYWORDS */ +IDL_VPTR gdidl_tell(int argc, IDL_VPTR argv[], char *argk) +{ + dtraceidl(); + + GDIDL_KW_ONLY_ERROR; + + DIRFILE* D = gdidl_get_dirfile(IDL_LongScalar(argv[0])); + const char* field_code = IDL_VarGetString(argv[1]); + + off64_t pos = gd_tell64(D, field_code); + + GDIDL_SET_ERROR(D); + + IDL_KW_FREE; + + IDL_VPTR r = IDL_Gettmp(); + r->type = IDL_TYP_LONG64; + r->value.l64 = (IDL_LONG64)pos; + dreturn("%p", r); + return r; +} + + + /**** Module initialisation ****/ /* These are defined in the automatically generated sublist.c */ Modified: trunk/getdata/bindings/make_parameters.c =================================================================== --- trunk/getdata/bindings/make_parameters.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/make_parameters.c 2011-10-18 01:48:16 UTC (rev 607) @@ -29,6 +29,22 @@ #define NO_GETDATA_LEGACY_API #include "getdata.h" +/* The type parameter: + * 0: error codes + * 1: open flags represented as INT in IDL + * 2: open flags represented as LONG in IDL + * 3: entry types + * 4: data types + * 5: delete flags (not in IDL) + * 6: protection levels + * 7: callback actions (not in IDL) + * 8: GD_E_FORMAT suberrors (not in IDL) + * 9: special version codes not used by pygetdata + * 10: special version codes used by pygetdata + * 11: gd_seek whence values + * 12: gd_seek flags (not in IDL) + * 99: miscellaneous constants + */ #define CONSTANT(s,f,t) { "GD_" #s, #s, f, GD_ ## s, t } static struct { const char* lname; /* Long name */ @@ -46,7 +62,7 @@ CONSTANT(E_BAD_TYPE, "GD_EBT", 0), CONSTANT(E_RAW_IO, "GD_ERW", 0), CONSTANT(E_OPEN_FRAGMENT, "GD_EOF", 0), - CONSTANT(E_OPEN_INCLUDE, "GD_EOI", 0), + CONSTANT(E_OPEN_INCLUDE, "GD_EOI", 0), /* deprecated */ CONSTANT(E_INTERNAL_ERROR, "GD_EIE", 0), CONSTANT(E_ALLOC, "GD_EAL", 0), CONSTANT(E_RANGE, "GD_ERA", 0), @@ -64,9 +80,10 @@ CONSTANT(E_BAD_REFERENCE, "GD_EBR", 0), CONSTANT(E_PROTECTED, "GD_EPT", 0), CONSTANT(E_DELETE, "GD_EDL", 0), - CONSTANT(E_BAD_ENDIANNESS, "GD_EEN", 0), + CONSTANT(E_ARGUMENT, "GD_EAR", 0), + CONSTANT(E_BAD_ENDIANNESS, "GD_EEN", 0), /* deprecated */ CONSTANT(E_CALLBACK, "GD_ECB", 0), - CONSTANT(E_BAD_PROTECTION, "GD_EBP", 0), + CONSTANT(E_BAD_PROTECTION, "GD_EBP", 0), /* deprecated */ CONSTANT(E_UNCLEAN_DB, "GD_UCL", 0), CONSTANT(E_DOMAIN, "GD_EDO", 0), CONSTANT(E_BAD_REPR, "GD_ERP", 0), @@ -170,9 +187,15 @@ CONSTANT(VERSION_LATEST, "GDSV_L", 10), CONSTANT(VERSION_EARLIEST, "GDSV_E", 10), - CONSTANT(MAX_LINE_LENGTH, "GD_MLL", 11), - CONSTANT(ALL_FRAGMENTS, "GD_ALL", 11), - CONSTANT(DIRFILE_STANDARDS_VERSION, "GD_DSV", 11), + CONSTANT(SEEK_SET, "GDSK_S", 11), + CONSTANT(SEEK_CUR, "GDSK_C", 11), + CONSTANT(SEEK_END, "GDSK_E", 11), + CONSTANT(SEEK_PAD, "GDSK_P", 12), + + CONSTANT(MAX_LINE_LENGTH, "GD_MLL", 99), + CONSTANT(ALL_FRAGMENTS, "GD_ALL", 99), + CONSTANT(HERE, "GD_HER", 99), + CONSTANT(DIRFILE_STANDARDS_VERSION, "GD_DSV", 99), { NULL } }; @@ -265,10 +288,17 @@ parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); + printf("\\\n%c Seek flags\\\n", c); + + for (j = 0; constant_list[j].lname != NULL; ++j) + if (constant_list[j].type == 11 || constant_list[j].type == 12) + parameter(constant_list[j].lname, constant_list[j].fname, + constant_list[j].value, i); + printf("\\\n%c Miscellaneous parameters\\\n", c); for (j = 0; constant_list[j].lname != NULL; ++j) - if (constant_list[j].type == 11) + if (constant_list[j].type == 99) parameter(constant_list[j].lname, constant_list[j].fname, constant_list[j].value, i); @@ -316,7 +346,8 @@ for (i = 0; constant_list[i].lname != NULL; ++i) if ((constant_list[i].type != 1) && (constant_list[i].type != 5) && - (constant_list[i].type != 7) && (constant_list[i].type != 8)) + (constant_list[i].type != 7) && (constant_list[i].type != 8) && + (constant_list[i].type != 12)) { printf("{ \"%s\", 0, (void*)IDL_TYP_%s }, ", constant_list[i].sname, (constant_list[i].type == 2) ? "LONG" : "INT"); @@ -336,7 +367,8 @@ for (n = i = 0; constant_list[i].lname != NULL; ++i) if ((constant_list[i].type != 1) && (constant_list[i].type != 5) && - (constant_list[i].type != 7) && (constant_list[i].type != 8)) + (constant_list[i].type != 7) && (constant_list[i].type != 8) && + (constant_list[i].type != 12)) { printf("*(IDL_%s*)(data + IDL_StructTagInfoByIndex(gdidl_const_def, %i, " "IDL_MSG_LONGJMP, NULL)) = %li;\n", (constant_list[i].type == 2) ? Modified: trunk/getdata/bindings/perl/simple_funcs.xsin =================================================================== --- trunk/getdata/bindings/perl/simple_funcs.xsin 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/perl/simple_funcs.xsin 2011-10-18 01:48:16 UTC (rev 607) @@ -118,3 +118,6 @@ off64_t bof64(DIRFILE *dirfile, const char* field_code) off64_t eof64(DIRFILE *dirfile, const char* field_code) int error_count(DIRFILE *dirfile) +off64_t seek(DIRFILE *dirfile, const char* field_code, off64_t frame_num, + off64_t sample_num, int flags=GD_SEEK_SET) +off64_t tell(DIRFILE *dirfile, const char* field_code) Modified: trunk/getdata/bindings/python/pydirfile.c =================================================================== --- trunk/getdata/bindings/python/pydirfile.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/bindings/python/pydirfile.c 2011-10-18 01:48:16 UTC (rev 607) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009, 2010 D. V. Wiebe +/* Copyright (C) 2009-2011 D. V. Wiebe * *************************************************************************** * @@ -2070,6 +2070,61 @@ return 0; } +static PyObject *gdpy_dirfile_seek(struct gdpy_dirfile_t *self, PyObject *args, + PyObject *keys) +{ + dtrace("%p, %p, %p", self, args, keys); + + char *keywords[] = { "field_code", "flags", "frame_num", "sample_num", NULL }; + const char *field_code; + long int frame_num = 0, sample_num = 0; + int flags; + off_t pos; + + if (!PyArg_ParseTupleAndKeywords(args, keys, "si|LL:pygetdata.dirfile.seek", + keywords, &field_code, &flags, &frame_num, &sample_num)) + { + dreturn("%p", NULL); + return NULL; + } + + pos = gd_seek(self->D, field_code, (off_t)frame_num, (off_t)sample_num, + flags); + + PYGD_CHECK_ERROR(self->D, NULL); + + PyObject* pyobj = PyLong_FromLongLong((long long)pos); + + dreturn("%p", pyobj); + return pyobj; +} + +static PyObject *gdpy_dirfile_tell(struct gdpy_dirfile_t *self, PyObject *args, + PyObject *keys) +{ + dtrace("%p, %p, %p", self, args, keys); + + char *keywords[] = { "field_code", NULL }; + const char *field_code; + off_t pos; + + if (!PyArg_ParseTupleAndKeywords(args, keys, "s:pygetdata.dirfile.tell", + keywords, &field_code)) + { + dreturn("%p", NULL); + return NULL; + } + + pos = gd_tell(self->D, field_code); + + PYGD_CHECK_ERROR(self->D, NULL); + + PyObject* pyobj = PyLong_FromLongLong((long long)pos); + + dreturn("%p", pyobj); + return pyobj; +} + static PyGetSetDef gdpy_dirfile_getset[] = { { "error", (getter)gdpy_dirfile_geterror, NULL, "The numerical error code encountered by the last call to the GetData\n" @@ -2080,7 +2135,6 @@ NULL }, { "error_count", (getter)gdpy_dirfile_geterrorcount, NULL, "The number of errors encountered by the GetData library for this\n" - /* -----------------------------------------------------------------| */ "dirfile since the last time this member was accessed. Note:\n" "accessing this member, resets it to zero. See gd_error_count(3).", NULL }, @@ -2239,7 +2293,7 @@ "and values, unlike the C API counterpart." }, {"getdata", (PyCFunction)gdpy_dirfile_getdata, METH_VARARGS | METH_KEYWORDS, - "gd_getdata(field_code, return_type [, first_frame, first_sample,\n" + "getdata(field_code, return_type [, first_frame, first_sample,\n" "num_frames, num_samples, as_list])\n\n" "Retrieve a data vector from the dirfile. If NumPy support is\n" "present in pygetdata, and 'as_list' is not given or zero, a NumPy\n" @@ -2252,7 +2306,7 @@ "indicated. For list data it should be (typically) one of:\n" "pygetdata.INT, pygetdata.LONG, pygetdata.ULONG, pygetdata.FLOAT, or\n" "pygetdata.COMPLEX, although any GetData data type code is permitted.\n" - "The 'first_frame' and 'first_samples' parameters indicate first\n" + "The 'first_frame' and 'first_sample' parameters indicate first\n" "datum to read. If they are both omitted, data is read from the\n" "first sample. Similarly, 'num_frames' and 'num_samples' indicate\n" "the amount of data. Omitting both of these results in an error.\n" @@ -2533,6 +2587,15 @@ "a RAW field, the file on disk will also be renamed accordingly.\n" "See gd_rename(3)." }, + {"seek", (PyCFunction)gdpy_dirfile_seek, METH_VARARGS | METH_KEYWORDS, + "seek(field_code, flags [, frame_num, sample_num])\n\n" + "Set the field pointer of the field specified by 'field_code'. The\n" + "'frame_num' and 'sample_num' parameters indicate desired position.\n" + "If they are both omitted, the field pointer is set to sample zero.\n" + "The 'flags' parameter must contain one of pygetdata.SEEK_SET,\n" + "pygetdata.SEEK_CUR and pygetdata.SEEK_END, which may be bitwise or'd\n" + "with pygetdata.SEEK_PAD. See gd_seek(3)." + }, {"set_callback", (PyCFunction)gdpy_dirfile_callback, METH_VARARGS | METH_KEYWORDS, "set_callback(sehandler, extra)\n\n" @@ -2544,6 +2607,12 @@ "handler, or None, if no such object is needed. See\n" "gd_parser_callback(3)." }, + {"tell", (PyCFunction)gdpy_dirfile_tell, METH_VARARGS | METH_KEYWORDS, + "tell(field_code)\n\n" + /* -----------------------------------------------------------------| */ + "Report the current position of the field pointer of 'field_code'.\n" + "See gd_tell(3)." + }, {"uninclude", (PyCFunction)gdpy_dirfile_uninclude, METH_VARARGS | METH_KEYWORDS, "uninclude(fragment_index [, del])\n\n" Modified: trunk/getdata/doc/README.cxx =================================================================== --- trunk/getdata/doc/README.cxx 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/doc/README.cxx 2011-10-18 01:48:16 UTC (rev 607) @@ -182,7 +182,10 @@ GetData::DataType type, const void *data_in) * size_t Dirfile::PutString(const char *field_code, const char *data_in) * unsigned int Dirfile::SamplesPerFrame(const char *field_code) +* off_t Dirfile::Seek(const char *field_code, off_t frame_num, off_t sample_num, + int whence) * const char **Dirfile::Strings() +* off_t Dirfile::Tell(const char *field_code) * int Dirfile::Validate(const char *field_code) * const char **Dirfile::VectorList() Modified: trunk/getdata/doc/README.f77 =================================================================== --- trunk/getdata/doc/README.f77 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/doc/README.f77 2011-10-18 01:48:16 UTC (rev 607) @@ -308,7 +308,32 @@ This subroutine wraps gd_framenum_subset(3), and performs a reverse look-up on a field. +* GDSEEK(pos, dirfile_unit, field_code, field_code_len, frame_num, sample_num, + flags) + Output: + INTEGER pos + Input: + INTEGER dirfile_unit, field_code_len, frame_num, sample_num, flags + CHARACTER*<field_code_len> field_code + + This subroutine wraps gd_seek(3), and repositions the field pointer of the + specified field. It returns the new value of the field pointer. The + 'flags' argument should be one of GDSK_S, GDSK_C, or GDSK_E, optionally + bitwise or'd with GDSK_E. + +* GDTELL(pos, dirfile_unit, field_code) + + Output: + INTEGER pos + Input: + INTEGER dirfile_unit, field_code_len + CHARACTER*<field_code_len> field_code + + This subroutine wraps gd_tell(3), and returns the current value of the field + pointer for the specified field. + + Subroutines interacting with global metadata -------------------------------------------- @@ -1789,10 +1814,20 @@ GDSV_L GD_VERSION_LATEST GDSV_E GD_VERSION_EARLIEST +Seek flags: + + F77 symbol C symbol + ---------- --------------------- + GDSK_C GD_SEEK_CUR + GDSK_E GD_SEEK_END + GDSK_P GD_SEEK_PAD + GDSK_S GD_SEEK_SET + Miscellaneous parameters: F77 symbol C symbol ---------- ------------------------- GD_ALL GD_ALL_FRAGMENTS GD_DSV DIRFILE_STANDARDS_VERSION + GD_HER GD_HERE GD_MLL GD_MAX_LINE_LENGTH Modified: trunk/getdata/doc/README.f95 =================================================================== --- trunk/getdata/doc/README.f95 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/doc/README.f95 2011-10-18 01:48:16 UTC (rev 607) @@ -514,7 +514,15 @@ * integer function fgd_invalid_dirfile () +* integer function fgd_seek (dirfile, field_code, frame_num, sample_num, flags) + integer, intent(in) :: dirfile, frame_num, sample_num, flags + character (len=*), intent(in): field_code +* integer function fgd_tell (dirfile, field_code) + integer, intent(in) :: dirfile + character (len=*), intent(in): field_code + + In order to respect type safety, the gd_getdata and gd_putdata analogues encode the data type of their array in their function name, rather than as a parameter. Otherwise, they behave the same as their C counterparts. Modified: trunk/getdata/man/Makefile.am =================================================================== --- trunk/getdata/man/Makefile.am 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/man/Makefile.am 2011-10-18 01:48:16 UTC (rev 607) @@ -35,22 +35,23 @@ gd_put_carray_slice.3 gd_get_constant.3 gd_put_constant.3 \ gd_constants.3 gd_dirfile_standards.3 gd_getdata.3 \ gd_putdata.3 gd_delete.3 gd_encoding.3 gd_endianness.3 \ - gd_entry.3 gd_entry_type.3 gd_eof.3 gd_error.3 gd_error_count.3 \ - gd_error_string.3 gd_field_list.3 gd_field_list_by_type.3 \ - gd_flush.3 gd_fragment_index.3 gd_fragmentname.3 \ - gd_framenum_subset.3 gd_frameoffset.3 gd_free_entry_strings.3 \ - gd_include.3 gd_invalid_dirfile.3 gd_madd_bit.3 gd_mcarrays.3 \ - gd_mconstants.3 gd_metaflush.3 gd_mfield_list.3 \ - gd_mfield_list_by_type.3 gd_move.3 gd_mstrings.3 \ - gd_mvector_list.3 gd_dirfilename.3 gd_native_type.3 \ - gd_nfields.3 gd_nfields_by_type.3 gd_nfragments.3 gd_nframes.3 \ - gd_nmfields.3 gd_nmfields_by_type.3 gd_nmvectors.3 \ - gd_nvectors.3 gd_parent_fragment.3 gd_parser_callback.3 \ - gd_protection.3 gd_raw_filename.3 gd_reference.3 gd_rename.3 \ - gd_rewrite_fragment.3 gd_spf.3 gd_get_string.3 gd_put_string.3 \ - gd_strings.3 gd_uninclude.3 gd_validate.3 gd_vector_list.3 \ - dirfile.5 dirfile-encoding.5 dirfile-format.5 \ - $(LFS_transitional_mans) + gd_entry.3 gd_entry_type.3 gd_eof.3 gd_error.3 \ + gd_error_count.3 gd_error_string.3 gd_field_list.3 \ + gd_field_list_by_type.3 gd_flush.3 gd_fragment_index.3 \ + gd_fragmentname.3 gd_framenum_subset.3 gd_frameoffset.3 \ + gd_free_entry_strings.3 gd_include.3 gd_invalid_dirfile.3 \ + gd_madd_bit.3 gd_mcarrays.3 gd_mconstants.3 gd_metaflush.3 \ + gd_mfield_list.3 gd_mfield_list_by_type.3 gd_move.3 \ + gd_mstrings.3 gd_mvector_list.3 gd_dirfilename.3 \ + gd_native_type.3 gd_nfields.3 gd_nfields_by_type.3 \ + gd_nfragments.3 gd_nframes.3 gd_nmfields.3 \ + gd_nmfields_by_type.3 gd_nmvectors.3 gd_nvectors.3 \ + gd_parent_fragment.3 gd_parser_callback.3 gd_protection.3 \ + gd_raw_filename.3 gd_reference.3 gd_rename.3 \ + gd_rewrite_fragment.3 gd_seek.3 gd_spf.3 gd_get_string.3 \ + gd_put_string.3 gd_strings.3 gd_tell.3 gd_uninclude.3 \ + gd_validate.3 gd_vector_list.3 dirfile.5 dirfile-encoding.5 \ + dirfile-format.5 $(LFS_transitional_mans) MAN3ALIASES=gd_add_bit.3:gd_add_carray.3 gd_add_bit.3:gd_add_clincom.3 \ gd_add_bit.3:gd_add_const.3 gd_add_bit.3:gd_add_cpolynom.3 \ Modified: trunk/getdata/man/gd_getdata.3 =================================================================== --- trunk/getdata/man/gd_getdata.3 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/man/gd_getdata.3 2011-10-18 01:48:16 UTC (rev 607) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_getdata 3 "19 August 2011" "Version 0.8.0" "GETDATA" +.TH gd_getdata 3 "14 October 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_getdata \(em retrieve data from a dirfile database .SH SYNOPSIS @@ -62,7 +62,9 @@ must point to a valid memory location of sufficient size to hold all data requested. -The first sample returned will be +Unless using +.B GD_HERE +(see below), the first sample returned will be .RS .IR first_frame " * " samples_per_frame " + " first_sample .RE @@ -83,6 +85,18 @@ .IR num_frames " and " first_frames , equal to zero. +Instead of explicitly specifying the origin of the read, the caller may pass the +special symbol +.B GD_HERE +as +.IR first_frame . +This will result in the read occurring at the current position of the I/O +pointer for the field (see +.BR gd_seek (3) +for a discussion of I/O pointers). In this case, the value of +.I first_sample +is ignored. + The .I return_type argument should be one of the following symbols, which indicates the desired @@ -140,6 +154,10 @@ purely real one is required, only the real portion of the requested vector will be returned. +Upon successful completion, the I/O pointer of the field will be on the sample +immediately following the last sample returned. On error, the position of the +I/O pointer is not specified. + .SH RETURN VALUE In all cases, .BR gd_getdata () @@ -198,6 +216,12 @@ .I field_code or one of its inputs. .TP +.B GD_E_DOMAIN +An immediate read was attempted using +.BR GD_HERE , +but the I/O pointer of the field was not well defined because two or more of +the field's inputs did not agree as to the location of the I/O pointer. +.TP .B GD_E_INTERNAL_ERROR An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the @@ -225,7 +249,6 @@ supported by the library. See .BR dirfile-encoding (5) for details on dirfile encoding schemes. -.RE .PP The dirfile error may be retrieved by calling .BR gd_error (3). @@ -284,6 +307,7 @@ .BR gd_error (3), .BR gd_error_string (3), .BR gd_nframes (3), +.BR gd_seek (3), .BR gd_spf (3), .BR gd_get_string (3), .BR gd_putdata (3) Modified: trunk/getdata/man/gd_putdata.3 =================================================================== --- trunk/getdata/man/gd_putdata.3 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/man/gd_putdata.3 2011-10-18 01:48:16 UTC (rev 607) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_putdata 3 "19 August 2011" "Version 0.8.0" "GETDATA" +.TH gd_putdata 3 "14 October 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_putdata \(em write data to a dirfile database .SH SYNOPSIS @@ -52,7 +52,9 @@ argument must point to a valid DIRFILE object previously created by a call to .BR gd_open (3). -The first sample written will be +Unless using +.B GD_HERE +(see below), the first sample written will be .RS .IR first_frame " * " samples_per_frame " + " first_sample .RE @@ -75,6 +77,18 @@ .IR num_frames " and " first_frames , equal to zero. +Instead of explicitly specifying the origin of the write, the caller may pass +the special symbol +.B GD_HERE +as +.IR first_frame . +This will result in the write occurring at the current position of the I/O +pointer for the field (see +.BR gd_seek (3) +for a discussion of I/O pointers). In this case, the value of +.I first_sample +is ignored. + The .I data_type argument should be one of the following symbols, which indicates the type of @@ -117,6 +131,11 @@ appropriate type. The argument .I data_in must point to a valid memory location of containing all the data to be written. + +Upon successful completion, the I/O pointer of the field will be on the sample +immediately following the last sample written. On error, the position of the +I/O pointer is not specified. + .SH RETURN VALUE In all cases, .BR gd_putdata () @@ -180,13 +199,20 @@ the definition of .IR field_code . .TP +.B GD_E_DOMAIN +An attempt was made to write to a +.B LINTERP +field with a look-up table which was not monotonic or not purely real. +.TP .B GD_E_INTERNAL_ERROR An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the maintainer. .TP .B GD_E_OPEN_LINFILE -An error occurred while trying to read a LINTERP table from disk. +An error occurred while trying to read a +.B LINTERP +table from disk. .TP .B GD_E_PROTECTED The data of the @@ -231,4 +257,5 @@ .BR gd_getdata (3), .BR gd_put_carray (3), .BR gd_put_constant (3), +.BR gd_seek (3), .BR gd_spf (3) Added: trunk/getdata/man/gd_seek.3 =================================================================== --- trunk/getdata/man/gd_seek.3 (rev 0) +++ trunk/getdata/man/gd_seek.3 2011-10-18 01:48:16 UTC (rev 607) @@ -0,0 +1,208 @@ +.\" gd_getdata.3. The gd_getdata man page. +.\" +.\" Copyright (C) 2011 D. V. Wiebe +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.\" This file is part of the GetData project. +.\" +.\" Permission is granted to copy, distribute and/or modify this document +.\" under the terms of the GNU Free Documentation License, Version 1.2 or +.\" any later version published by the Free Software Foundation; with no +.\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +.\" Texts. A copy of the license is included in the `COPYING.DOC' file +.\" as part of this distribution. +.\" +.TH gd_seek 3 "14 October 2011" "Version 0.8.0" "GETDATA" +.SH NAME +gd_seek \(em reposition a dirfile field pointer +.SH SYNOPSIS +.B #include <getdata.h> +.HP +.nh +.ad l +.BI "off_t gd_seek(DIRFILE *" dirfile ", const char *" field_code ", off_t" +.IB frame_num ", off_t " sample_num ", int " flags ); +.hy +.ad n +.SH DESCRIPTION +The +.BR gd_seek () +function changes the field position of the field +.I field_code +in the dirfile(5) database specified by +.IR dirfile . +In normal operation, +.BR gd_seek () +advances the field pointer +.I frame_num +frames plus +.I sample_num +samples from the origin point specified in +.IR flags , +which should contain one of +.BR GD_SEEK_SET ", " GD_SEEK_CUR , +or +.BR GD_SEEK_END , +indicating, repsectively, origins of sample zero, the current position of the +field pointer, and the location of the end-of-field marker (see +.BR gd_eof (3)). + +In addition to one of the symbols above, the +.I flags +parameter may also, optionally, be bitwise or'd with +.BR GD_SEEK_PAD , +which will result in the field being padded (with zero for integer types or a +IEEE-754 conforming not-a-number otherwise) in the event of seeking past the +end-of-field marker. Note: for some data encodings, the padding may be deferred +until a write occurs. The result of calling +.BR gd_seek () +with +.BR GD_SEEK_PAD , +but without a subsequent call to +.BR gd_putdata (3), +is encoding specific, and may not actually advance the end of field. Attempting +to seek past the end-of-field marker without specifying +.B GD_SEEK_PAD +is also encoding specific: in some encodings the field pointer will be moved +past the end-of-field marker, while in others, it will result in an error. + +In general, +.B GD_SEEK_PAD +should be used on +.BR gd_seek () +calls before a write via +.BR gd_putdata (3), +while calls before a read via +.BR gd_getdata (3) +should omit the +.B GD_SEEK_PAD +flag. So the following: +.IP +.nh +.ad l +.BI "gd_seek(" dirfile ", " field_code ", " a ", " b , +.B GD_SEEK_SET | GD_SEEK_PAD); +.br +.BI "gd_putdata(" dirfile ", "field_code ", GD_HERE, 0, " c ", " d ", " type , +.IB data ); +.ad n +.hy +.P +is equivalent to: +.IP +.nh +.ad l +.BI "gd_putdata(" dirfile ", "field_code ", " a ", " b ", " c ", " d ", " type , +.IB data ); +.P +and, similarly, +.IP +.nh +.ad l +.BI "gd_seek(" dirfile ", " field_code ", " a ", " b ", GD_SEEK_SET);" +.br +.BI "gd_getdata(" dirfile ", "field_code ", GD_HERE, 0, " c ", " d ", " type , +.IB data ); +.ad n +.hy +.P +is equivalent to: +.IP +.nh +.ad l +.BI "gd_getdata(" dirfile ", "field_code ", " a ", " b ", " c ", " d ", " type , +.IB data ); +.P +Only +.B RAW +fields (and the implicit +.I INDEX +field) have field pointers associated with them. Calling +.BR gd_seek () +on a derived field will move the field pointers of all of the field's inputs. +It is possible to create derived fields which simultaneously read from different +places of the same field. Calling +.BR gd_seek () +on such a field will result in an error. + +.SH RETURN VALUE +Upon successful completion, +.BR gd_seek () +returns the field position of the specified field in samples. On error, it +returns -1 and set the dirfile error to a non-zero value. Possible error values +are: +.TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP +.B GD_E_ARGUMENT +The +.I flags +parameter didn't contain exaclty one of +.BR GD_SEEK_SET ", " GD_SEEK_CUR , +or +.BR GD_SEEK_END . +.TP +.B GD_E_BAD_CODE +The field specified by +.IR field_code , +or one of the fields it uses for input, was not found in the database. +.TP +.B GD_E_BAD_DIRFILE +The supplied dirfile was invalid. +.TP +.B GD_E_BAD_FIELD_TYPE +An attempt was made to seek relative to +.B GD_SEEK_END +on the +.I INDEX +field, which has no end-of-field marker. +.TP +.B GD_E_BAD_REPR +The representation suffix specified in +.IR field_code , +or in one of the field codes it uses for input, was invalid. +.TP +.B GD_E_DIMENSION +The specified field or one of its inputs wasn't of vector type. +.TP +.B GD_E_DOMAIN +The field posision couldn't be set due to a derived field reading simultaneously +from more than one place in an input field. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +maintainer. +.TP +.B GD_E_RAW_IO +An error occurred while trying to open or read from a file on disk containing +a raw field. +.TP +.B GD_E_RECURSE_LEVEL +Too many levels of recursion were encountered while trying to resolve +.IR field_code . +This usually indicates a circular dependency in field specification in the +dirfile. +.TP +.B GD_E_UNKNOWN_ENCODING +The encoding scheme of a RAW field could not be determined. This may also +indicate that the binary file associated with the RAW field could not be found. +.TP +.B GD_E_UNSUPPORTED +Reading from dirfiles with the encoding scheme of the specified dirfile is not +supported by the library. See +.BR dirfile-encoding (5) +for details on dirfile encoding schemes. +.PP +The dirfile error may be retrieved by calling +.BR gd_error (3). +A descriptive error string for the last error encountered can be obtained from +a call to +.BR gd_error_string (3). +.SH SEE ALSO +.BR gd_open (3), +.BR gd_getdata (3), +.BR gd_putdata (3), +.BR gd_tell (3). Added: trunk/getdata/man/gd_tell.3 =================================================================== --- trunk/getdata/man/gd_tell.3 (rev 0) +++ trunk/getdata/man/gd_tell.3 2011-10-18 01:48:16 UTC (rev 607) @@ -0,0 +1,110 @@ +.\" gd_getdata.3. The gd_getdata man page. +.\" +.\" Copyright (C) 2011 D. V. Wiebe +.\" +.\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +.\" +.\" This file is part of the GetData project. +.\" +.\" Permission is granted to copy, distribute and/or modify this document +.\" under the terms of the GNU Free Documentation License, Version 1.2 or +.\" any later version published by the Free Software Foundation; with no +.\" Invariant Sections, with no Front-Cover Texts, and with no Back-Cover +.\" Texts. A copy of the license is included in the `COPYING.DOC' file +.\" as part of this distribution. +.\" +.TH gd_tell 3 "14 October 2011" "Version 0.8.0" "GETDATA" +.SH NAME +gd_tell \(em reposition a dirfile field pointer +.SH SYNOPSIS +.B #include <getdata.h> +.HP +.nh +.ad l +.BI "off_t gd_tell(DIRFILE *" dirfile ", const char *" field_code ); +.hy +.ad n +.SH DESCRIPTION +The +.BR gd_tell () +function reports the current position of the I/O pointer of the field +.I field_code +in the dirfile(5) database specified by +.IR dirfile . +.P +Only +.B RAW +fields (and the implicit +.I INDEX +field) have field pointers associated with them. Calling +.BR gd_tell () +on a derived field will report the position of the I/O pointer of the derived +field only if all of it's inputs are positioned the same. Otherwise, an error +results. + +.SH RETURN VALUE +Upon successful completion, +.BR gd_tell () +returns the I/O position of the specified field in samples. On error, it +returns -1 and set the dirfile error to a non-zero value. Possible error values +are: +.TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP +.B GD_E_BAD_CODE +The field specified by +.IR field_code , +or one of the fields it uses for input, was not found in the database. +.TP +.B GD_E_BAD_DIRFILE +The supplied dirfile was invalid. +.TP +.B GD_E_BAD_REPR +The representation suffix specified in +.IR field_code , +or in one of the field codes it uses for input, was invalid. +.TP +.B GD_E_DIMENSION +The specified field or one of its inputs wasn't of vector type. +.TP +.B GD_E_DOMAIN +The field posision couldn't be determined due to a mismatch in the I/O pointer +of field reading simultaneously +from more than one place in an input field. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +maintainer. +.TP +.B GD_E_RAW_IO +An error occurred while trying to open or read from a file on disk containing +a raw field. +.TP +.B GD_E_RECURSE_LEVEL +Too many levels of recursion were encountered while trying to resolve +.IR field_code . +This usually indicates a circular dependency in field specification in the +dirfile. +.TP +.B GD_E_UNKNOWN_ENCODING +The encoding scheme of a RAW field could not be determined. This may also +indicate that the binary file associated with the RAW field could not be found. +.TP +.B GD_E_UNSUPPORTED +Reading from dirfiles with the encoding scheme of the specified dirfile is not +supported by the library. See +.BR dirfile-encoding (5) +for details on dirfile encoding schemes. +.PP +The dirfile error may be retrieved by calling +.BR gd_error (3). +A descriptive error string for the last error encountered can be obtained from +a call to +.BR gd_error_string (3). +.SH SEE ALSO +.BR gd_open (3), +.BR gd_getdata (3), +.BR gd_putdata (3), +.BR gd_seek (3). Modified: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/src/fpos.c 2011-10-18 01:48:16 UTC (rev 607) @@ -138,7 +138,7 @@ } if (entry->field_type & GD_SCALAR_ENTRY) - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); else pos = _GD_GetFilePos(D, entry, -1); @@ -250,7 +250,7 @@ } if (entry->field_type & GD_SCALAR_ENTRY) { - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); if (field_code != field_code_in) free(field_code); dreturn("%u", -1); Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/src/getdata.c 2011-10-18 01:48:16 UTC (rev 607) @@ -1236,7 +1236,7 @@ /* extract bits */ if (is_signed) { - uint64_t sign = -1 << (E->EN(bit,numbits) + - 1); + uint64_t sign = -1 << (E->EN(bit,numbits) - 1); for (i = 0; i < n_read; i++) ((int64_t *)tmpbuf)[i] = (((((uint64_t *)tmpbuf)[i] >> E->EN(bit,bitnum)) & mask) + sign) ^ sign; Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/src/putdata.c 2011-10-18 01:48:16 UTC (rev 607) @@ -591,13 +591,12 @@ return 0; } - if (first_samp == GD_HERE) { + /* this call will throw GD_E_DOMAIN if a problem arises; however, that only + * happens in cases where the field has multiple inputs, which putdata will + * reject anyways; so we ignore this error for a more relevant one later + */ + if (first_samp == GD_HERE) first_samp = _GD_GetFilePos(D, E, -1); - if (D->error) { - dreturn("%i", 0); - return 0; - } - } switch (E->field_type) { case GD_RAW_ENTRY: Modified: trunk/getdata/src/spf.c =================================================================== --- trunk/getdata/src/spf.c 2011-10-13 02:08:13 UTC (rev 606) +++ trunk/getdata/src/spf.c 2011-10-18 01:48:16 UTC (rev 607) @@ -106,7 +106,7 @@ } if (entry->field_type & GD_SCALAR_ENTRY) - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); else spf = _GD_GetSPF(D, entry); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-10-13 02:08:23
|
Revision: 606 http://getdata.svn.sourceforge.net/getdata/?rev=606&view=rev Author: ketiltrout Date: 2011-10-13 02:08:13 +0000 (Thu, 13 Oct 2011) Log Message: ----------- Facilities to read/write at the "current position" (using GD_HERE). And facilities to change and report this position (gd_seek, gd_tell). Also added GD_ARGUMENT error; plus an attempt to curtail the excessive unnecessary linkings discovered by Steve. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/NEWS trunk/getdata/bindings/cxx/Makefile.am trunk/getdata/bindings/f77/Makefile.am trunk/getdata/bindings/idl/package/Makefile.am trunk/getdata/bindings/python/Makefile.am trunk/getdata/src/Makefile.am trunk/getdata/src/ascii.c trunk/getdata/src/encoding.c trunk/getdata/src/endian.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/gzip.c trunk/getdata/src/index.c trunk/getdata/src/internal.h trunk/getdata/src/legacy.c trunk/getdata/src/lzma.c trunk/getdata/src/protect.c trunk/getdata/src/putdata.c trunk/getdata/src/raw.c trunk/getdata/src/sie.c trunk/getdata/test/Makefile.am trunk/getdata/test/legacy_put.c trunk/getdata/test/put_complex128.c trunk/getdata/test/put_complex64.c trunk/getdata/test/put_ff.c trunk/getdata/test/put_float32.c trunk/getdata/test/put_float64.c trunk/getdata/test/put_foffs.c trunk/getdata/test/put_fs.c trunk/getdata/test/put_int16.c trunk/getdata/test/put_int32.c trunk/getdata/test/put_int64.c trunk/getdata/test/put_int8.c trunk/getdata/test/put_lincom1.c trunk/getdata/test/put_linterp.c trunk/getdata/test/put_linterp_reverse.c trunk/getdata/test/put_off64.c trunk/getdata/test/put_phase.c trunk/getdata/test/put_polynom1.c trunk/getdata/test/put_recip.c trunk/getdata/test/put_sf.c trunk/getdata/test/put_ss.c trunk/getdata/test/put_uint16.c trunk/getdata/test/put_uint32.c trunk/getdata/test/put_uint64.c Added Paths: ----------- trunk/getdata/src/fpos.c trunk/getdata/test/entry_divide.c trunk/getdata/test/entry_recip.c trunk/getdata/test/get_here.c trunk/getdata/test/get_heres.c trunk/getdata/test/put_here.c trunk/getdata/test/put_heres.c trunk/getdata/test/seek64.c trunk/getdata/test/seek_cur.c trunk/getdata/test/seek_end.c trunk/getdata/test/seek_set.c trunk/getdata/test/tell.c trunk/getdata/test/tell64.c Property Changed: ---------------- trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/ChangeLog 2011-10-13 02:08:13 UTC (rev 606) @@ -1,3 +1,47 @@ +2011-10-13 D. V. Wiebe <ge...@ke...> svn:606 + * test/entry_divide.c test/entry_recip.c test/get_here.c test/get_heres.c + test/put_here.c test/put_heres.c test/seek64.c test/seek_cur.c test/seek_end.c + test/seek_set.c test/tell.c test/tell64.c: Added. + + * test/legacy_put.c test/put_complex128.c test/put_complex64.c + test/put_float32.c test/put_float64.c test/put_ff.c test/put_foffs.c + test/put_fs.c test/put_int16.c test/put_int32.c test/put_int64.c + test/put_int8.c test/put_lincom1.c test/put_linterp.c + test/put_linterp_reverse.c test/put_off64.c test/put_phase.c + test/put_polynom1.c test/put_recip.c test/put_sf.c test/put_ss.c + test/put_uint16.c test/put_uint32.c test/put_uint64.c: Don't perform + unnecessary tests in the event the data file wasn't created. + + * src/getdata.h.in: Combine GD_E_BAD_ENDIANNESS and GD_E_BAD_PROTECTION into + GD_ARGUMENT. The former are kept as aliases of the new symbol. + * src/endian.c (gd_alter_endianness) src/errors.c src/protect.c + (gd_alter_protection): Update for GD_E_ARGUMENT. + + * src/internal.h: Add .pos to _gd_raw_file. Add .u.index_pos to + _gd_private_entry. + * src/ascii.c (_GD_AsciiOpen _GD_AsciiSeek _GD_AsciiRead _GD_AsciiTOpen + _GD_AsciiTUnlink) src/gzip.c (_GD_GzipOpen _GD_GzipSeek _GD_GzipRead) + src/lzma.c (_GD_LzmaOpen _GD_LzmaSeek _GD_LzmaRead) src/sie.c + (_GD_SampIndOpen _GD_SampIndSeek _GD_SampIndRead _GD_SampIndWrite + _GD_SampIndTOpen) src/raw.c (_GD_RawOpen _GD_RawSeek _GD_RawRead + _GD_RawWrite _GD_RawTOpen): Track file position. + + * src/encoding.c (_GD_InitRawIO): Added. + * src/getdata.c (_GD_DoRaw) src/putdata.c (_GD_DoRawOut): Call _GD_InitRawIO. + + * src/fpos.c: Added. + * src/flimits.c (_GD_GetEOF): Publicise. + * src/getdata.c (gd_getdata64) src/putdata.c (gd_putdata64): Regularise use of + GD_HERE. Also, only call _GD_GetSPF when necessary. + * src/getdata.c (_GD_DoField) src/putdata.c (_GD_DoFieldOut): Resolve + instances of GD_HERE. + + * bindings/python/Makefile.am bindings/cxx/Makefile.am + bindings/f77/Makefile.am: Remove some unnecessary linking. + + * bindings/idl/package/Makefile.am: Add $(DEFS) to the make_parameters rule + to ensure it builds properly. + 2011-08-23 D. V. Wiebe <ge...@ke...> svn:600 * test/error_error.c: Simplify test. * test/test.h (CHECKSp): Added. Modified: trunk/getdata/NEWS =================================================================== --- trunk/getdata/NEWS 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/NEWS 2011-10-13 02:08:13 UTC (rev 606) @@ -1,3 +1,9 @@ +New in version 0.8.0a: + + * Some stuff. + +|==============================================================================| + New in version 0.7.3: Library Changes Modified: trunk/getdata/bindings/cxx/Makefile.am =================================================================== --- trunk/getdata/bindings/cxx/Makefile.am 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/bindings/cxx/Makefile.am 2011-10-13 02:08:13 UTC (rev 606) @@ -30,6 +30,7 @@ endif INCLUDES = ${WALL} $(WEXTRA) -I$(top_srcdir)/src +LIBS= SUBDIRS=test Modified: trunk/getdata/bindings/f77/Makefile.am =================================================================== --- trunk/getdata/bindings/f77/Makefile.am 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/bindings/f77/Makefile.am 2011-10-13 02:08:13 UTC (rev 606) @@ -55,6 +55,7 @@ SUBDIRS = test BUILT_SOURCES=getdata.f $(F95_INC) +LIBS= nodist_include_HEADERS=getdata.f $(F95_INC) @@ -65,7 +66,7 @@ libfgetdata_la_LDFLAGS = -version-info @FGETDATA_VERSION@ nodist_libf95getdata_la_SOURCES=getdata.f90 -libf95getdata_la_LIBADD=libfgetdata.la ../../src/libgetdata.la +libf95getdata_la_LIBADD=libfgetdata.la libf95getdata_la_LDFLAGS = -version-info @F95GETDATA_VERSION@ getdata.mod: getdata.o Modified: trunk/getdata/bindings/idl/package/Makefile.am =================================================================== --- trunk/getdata/bindings/idl/package/Makefile.am 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/bindings/idl/package/Makefile.am 2011-10-13 02:08:13 UTC (rev 606) @@ -35,7 +35,7 @@ EXTRA_DIST = ChangeLog README.idl make_parameters$(EXEEXT): $(make_parameters_SOURCES) - ${BUILDCC} -I../src -o make_parameters$(EXEEXT) $(srcdir)/$(make_parameters_SOURCES) + ${BUILDCC} $(DEFS) -Isrc -o make_parameters$(EXEEXT) $(srcdir)/$(make_parameters_SOURCES) clean-local: rm -rf *~ Modified: trunk/getdata/bindings/python/Makefile.am =================================================================== --- trunk/getdata/bindings/python/Makefile.am 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/bindings/python/Makefile.am 2011-10-13 02:08:13 UTC (rev 606) @@ -31,6 +31,7 @@ SUBDIRS=test python_LTLIBRARIES = pygetdata.la +LIBS= BUILT_SOURCES = pyconstants.c AM_CFLAGS = ${WALL} -fno-strict-aliasing Modified: trunk/getdata/src/Makefile.am =================================================================== --- trunk/getdata/src/Makefile.am 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/Makefile.am 2011-10-13 02:08:13 UTC (rev 606) @@ -105,7 +105,7 @@ ${LIBGETDATABZIP2_LA} ${LIBGETDATALZMA_LA} libgetdata_la_SOURCES = add.c ascii.c ${BZIP2_C} close.c common.c compat.c \ constant.c ${DEBUG_C} del.c encoding.c endian.c \ - entry.c errors.c field_list.c flimits.c flush.c \ + entry.c errors.c field_list.c flimits.c flush.c fpos.c \ fragment.c getdata.c globals.c ${GZIP_C} index.c \ include.c ${LEGACY_C} ${LZMA_C} meta_list.c mod.c \ move.c name.c native.c nfields.c nframes.c nmeta.c \ Modified: trunk/getdata/src/ascii.c =================================================================== --- trunk/getdata/src/ascii.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/ascii.c 2011-10-13 02:08:13 UTC (rev 606) @@ -31,8 +31,7 @@ #include <errno.h> #endif -/* The ASCII encoding uses file->idata to indicate the current line and - * file->edata for the stream pointer */ +/* The ASCII encoding uses file->edata for the stream pointer */ int _GD_AsciiOpen(int dirfd, struct _gd_raw_file* file, int swap __gd_unused, int mode, int creat) @@ -57,6 +56,7 @@ return -1; } + file->pos = 0; file->idata = 0; dreturn("%i", 0); return 0; @@ -69,23 +69,23 @@ dtrace("%p, %lli, <unused>, %i", file, count, pad); - if (count < file->idata) { + if (count < file->pos) { rewind((FILE *)file->edata); - file->idata = 0; + file->pos = 0; } - for (; count > file->idata; ++file->idata) + for (; count > file->pos; ++file->pos) if (fgets(line, 64, (FILE *)file->edata) == NULL) break; - if (pad && count > file->idata) { + if (pad && count > file->pos) { strcpy(line, "0\n"); - for (; count > file->idata; ++file->idata) + for (; count > file->pos; ++file->pos) fputs(line, (FILE *)file->edata); } - dreturn("%i", file->idata); - return file->idata; + dreturn("%lli", (long long)file->pos); + return file->pos; } static void _GD_ScanFormat(char* fmt, gd_type_t data_type) @@ -166,7 +166,7 @@ ret = -1; break; } - file->idata++; + file->pos++; } } else { for (n = 0; n < nmemb; ++n) { @@ -196,7 +196,7 @@ break; } } - file->idata++; + file->pos++; } } @@ -403,7 +403,7 @@ return -1; } - file->idata = 0; + file->pos = 0; dreturn("%i", 0); return 0; @@ -414,7 +414,7 @@ dtrace("%i, %p", dirfd, file); if (file->name != NULL) { - if (file->idata >= 0) + if (file->pos >= 0) if (_GD_AsciiClose(file)) { dreturn("%i", -1); return -1; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/encoding.c 2011-10-13 02:08:13 UTC (rev 606) @@ -300,6 +300,38 @@ return ret; } +/* Open a raw file, if necessary, also check for required functions */ +int _GD_InitRawIO(DIRFILE *D, gd_entry_t *E, unsigned int funcs, int creat) +{ + dtrace("%p, %p, %x, %i", D, E, funcs, creat); + + if (E->e->u.raw.file[0].idata < 0) { + if (!_GD_Supports(D, E, GD_EF_OPEN | funcs)) { + dreturn("%i", 1); + return 1; + } else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) + { + dreturn("%i", 1); + return 1; + } else if ((*_gd_ef[E->e->u.raw.file[0].subenc].open)( + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, + _GD_FileSwapBytes(D, E->fragment_index), D->flags & GD_ACCMODE, + creat)) + { + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, + NULL); + dreturn("%i", 1); + return 1; + } + } else if (!_GD_Supports(D, E, funcs)) { + dreturn("%i", 1); + return 1; + } + + dreturn("%i", 0); + return 0; +} + /* Figure out the encoding scheme */ static unsigned long _GD_ResolveEncoding(const DIRFILE *D gd_unused_d, const char* name, unsigned long scheme, int dirfd, Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/endian.c 2011-10-13 02:08:13 UTC (rev 606) @@ -147,7 +147,7 @@ } if (byte_sex != GD_BIG_ENDIAN && byte_sex != GD_LITTLE_ENDIAN) { - _GD_SetError(D, GD_E_BAD_ENDIANNESS, 0, NULL, 0, NULL); + _GD_SetError(D, GD_E_ARGUMENT, GD_E_ARG_ENDIANNESS, NULL, 0, NULL); dreturn("%i", -1); return -1; } Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/errors.c 2011-10-13 02:08:13 UTC (rev 606) @@ -165,12 +165,14 @@ "Cannot delete field {4} used in definiton of field {2}", 0 }, { GD_E_DELETE, GD_E_DEL_DERIVED, "Cannot delete field {4} used as input to field {2}", 0 }, - /* GD_E_BAD_ENDIANNESS: (nothing) */ - { GD_E_BAD_ENDIANNESS, 0, "Invalid endianness specified", 0 }, + /* GD_E_ARGUMENT: (nothing) */ + { GD_E_ARGUMENT, GD_E_ARG_WHENCE, "Invalid origin specified", 0 }, + { GD_E_ARGUMENT, GD_E_ARG_ENDIANNESS, "Invalid endianness specified", 0 }, + { GD_E_ARGUMENT, GD_E_ARG_PROTECTION, "Invalid protection level specified", + 0 }, + { GD_E_ARGUMENT, 0, "Bad argument", 0 }, /* GD_E_CALLBACK: 3 = response */ { GD_E_CALLBACK, 0, "Unrecognised response from callback function: {3}", 0 }, - /* GD_E_BAD_PROTECTION: (nothing) */ - { GD_E_BAD_PROTECTION, 0, "Invalid protection level specified", 0 }, /* GD_E_UNCLEAN_DB: 3 = fragment */ { GD_E_UNCLEAN_DB, 0, "Unexpected system error processing {3}; database unclean", 0 }, @@ -178,6 +180,7 @@ { GD_E_DOMAIN, GD_E_DOMAIN_COMPLEX, "Improper domain: complex valued", 0 }, { GD_E_DOMAIN, GD_E_DOMAIN_EMPTY, "Improper domain: empty set", 0 }, { GD_E_DOMAIN, GD_E_DOMAIN_ANTITONIC, "Improper domain: not monotonic", 0 }, + { GD_E_DOMAIN, GD_E_DOMAIN_MULTIPOS, "I/O position mismatch in inputs", 0 }, /* GD_E_UNCLEAN_DB: 4 = repr */ { GD_E_BAD_REPR, GD_E_REPR_UNKNOWN, "Unknown field representation: .{4}", 0 }, { GD_E_BAD_REPR, GD_E_REPR_PUT, "Unable to write to field reprentation: .{4}", Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/flimits.c 2011-10-13 02:08:13 UTC (rev 606) @@ -187,8 +187,7 @@ return gd_frameoffset64(D, fragment); } -static off64_t _GD_GetEOF(DIRFILE *D, gd_entry_t* E, const char *parent, - int *is_index) +off64_t _GD_GetEOF(DIRFILE *D, gd_entry_t* E, const char *parent, int *is_index) { off64_t ns = -1, ns1; gd_spf_t spf0, spf1; Added: trunk/getdata/src/fpos.c =================================================================== --- trunk/getdata/src/fpos.c (rev 0) +++ trunk/getdata/src/fpos.c 2011-10-13 02:08:13 UTC (rev 606) @@ -0,0 +1,306 @@ +/* Copyright (C) 2011 D. V. Wiebe + * + *************************************************************************** + * + * This file is part of the GetData project. + * + * GetData is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the + * Free Software Foundation; either version 2.1 of the License, or (at your + * option) any later version. + * + * GetData is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public + * License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with GetData; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ +#include "internal.h" + +#ifdef STDC_HEADERS +#include <string.h> +#include <stdlib.h> +#endif + +off64_t _GD_GetFilePos(DIRFILE *D, gd_entry_t *E, off64_t index_pos) +{ + int i; + off64_t pos = -1, pos2; + + dtrace("%p, %p, %lli", D, E, (long long)index_pos); + + if (++D->recurse_level >= GD_MAX_RECURSE_LEVEL) { + _GD_SetError(D, GD_E_RECURSE_LEVEL, 0, NULL, 0, E->field); + dreturn("%u", 0); + D->recurse_level--; + return 0; + } + + switch (E->field_type) { + case GD_RAW_ENTRY: + /* We must open the file to know its starting offset */ + if (_GD_InitRawIO(D, E, 0, 0)) + break; + pos = E->e->u.raw.file[0].pos + + D->fragment[E->fragment_index].frame_offset; + break; + case GD_LINCOM_ENTRY: + if (_GD_BadInput(D, E, 0)) + break; + + pos = _GD_GetFilePos(D, E->e->entry[0], -1); + if (!D->error) + for (i = 1; i < E->EN(lincom,n_fields); ++i) { + if (_GD_BadInput(D, E, i)) { + pos = -1; + break; + } + pos2 = _GD_GetFilePos(D, E->e->entry[i], pos); + if (pos2 != pos) { + _GD_SetError(D, GD_E_DOMAIN, GD_E_DOMAIN_MULTIPOS, NULL, 0, NULL); + pos = -1; + break; + } + } + break; + case GD_LINTERP_ENTRY: + case GD_BIT_ENTRY: + case GD_POLYNOM_ENTRY: + case GD_SBIT_ENTRY: + case GD_RECIP_ENTRY: + if (_GD_BadInput(D, E, 0)) + break; + pos = _GD_GetFilePos(D, E->e->entry[0], -1); + break; + case GD_MULTIPLY_ENTRY: + case GD_DIVIDE_ENTRY: + if (_GD_BadInput(D, E, 0) || _GD_BadInput(D, E, 1)) + break; + pos = _GD_GetFilePos(D, E->e->entry[0], 0); + pos2 = _GD_GetFilePos(D, E->e->entry[0], pos); + if (!D->error && pos != pos2) { + _GD_SetError(D, GD_E_DOMAIN, GD_E_DOMAIN_MULTIPOS, NULL, 0, NULL); + pos = -1; + } + break; + case GD_PHASE_ENTRY: + if (_GD_BadInput(D, E, 0)) + break; + pos = _GD_GetFilePos(D, E->e->entry[0], -1); + if (pos >= 0) + pos += E->EN(phase,shift); + break; + case GD_INDEX_ENTRY: + if (index_pos == -1) + pos = E->e->u.index_pos; + else + pos = index_pos; + break; + case GD_NO_ENTRY: + case GD_CONST_ENTRY: + case GD_STRING_ENTRY: + case GD_CARRAY_ENTRY: + _GD_InternalError(D); + } + + D->recurse_level--; + dreturn("%lli", (long long)pos); + return pos; +} + +/* Get the current I/O position of the given field +*/ +off64_t gd_tell64(DIRFILE *D, const char *field_code_in) +{ + off64_t pos = -1; + gd_entry_t* entry; + char* field_code; + int repr; + + dtrace("%p, \"%s\"", D, field_code_in); + + if (D->flags & GD_INVALID) {/* don't crash */ + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%u", 0); + return 0; + } + + _GD_ClearError(D); + + entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1); + + if (D->error) { + dreturn("%u", 0); + return 0; + } + + if (entry->field_type & GD_SCALAR_ENTRY) + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + else + pos = _GD_GetFilePos(D, entry, -1); + + if (field_code != field_code_in) + free(field_code); + + dreturn("%lli", (long long)pos); + return pos; +} + +off_t gd_tell(DIRFILE *D, const char *field_code) +{ + return (off_t)gd_tell64(D, field_code); +} + +static int _GD_Seek(DIRFILE *D, gd_entry_t *E, off64_t offset, int pad) +{ + int i; + + dtrace("%p, %p, %lli, %i", D, E, (long long)offset, pad); + + if (++D->recurse_level >= GD_MAX_RECURSE_LEVEL) { + _GD_SetError(D, GD_E_RECURSE_LEVEL, 0, NULL, 0, E->field); + D->recurse_level--; + dreturn("%i", 1); + return 1; + } + + switch (E->field_type) { + case GD_RAW_ENTRY: + /* open/create the file, if necessary */ + if (_GD_InitRawIO(D, E, GD_EF_SEEK, pad)) + break; + + if ((*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, offset, + E->EN(raw,data_type), pad) == -1) + { + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); + } + break; + case GD_LINCOM_ENTRY: + for (i = 0; i < E->EN(lincom,n_fields); ++i) + if (!_GD_BadInput(D, E, i)) + _GD_Seek(D, E->e->entry[i], offset, pad); + else + break; + break; + case GD_MULTIPLY_ENTRY: + case GD_DIVIDE_ENTRY: + if (_GD_BadInput(D, E, 1)) + break; + if (_GD_Seek(D, E->e->entry[1], offset, pad)) + break; + /* fallthrough */ + case GD_LINTERP_ENTRY: + case GD_BIT_ENTRY: + case GD_POLYNOM_ENTRY: + case GD_SBIT_ENTRY: + case GD_RECIP_ENTRY: + if (!_GD_BadInput(D, E, 0)) + _GD_Seek(D, E->e->entry[0], offset, pad); + break; + case GD_PHASE_ENTRY: + if (!_GD_BadInput(D, E, 0)) + _GD_Seek(D, E->e->entry[0], offset + E->EN(phase,shift), pad); + break; + case GD_INDEX_ENTRY: + E->e->u.index_pos = offset; + break; + case GD_NO_ENTRY: + case GD_CONST_ENTRY: + case GD_STRING_ENTRY: + case GD_CARRAY_ENTRY: + _GD_InternalError(D); + } + + D->recurse_level--; + dreturn("%i", (D->error == 0) ? 0 : 1); + return (D->error == 0) ? 0 : 1; +} + +/* Set the I/O position of the given field + */ +off64_t gd_seek64(DIRFILE *D, const char *field_code_in, off64_t frame_num, + off64_t sample_num, int whence) +{ + gd_spf_t spf = 0; + off64_t pos = 0; + gd_entry_t* entry; + char* field_code; + int repr, is_index = 0, pad = (whence & GD_SEEK_PAD) ? 1 : 0; + + dtrace("%p, \"%s\", %lli, %lli, %x", D, field_code_in, frame_num, sample_num, + whence); + + if (D->flags & GD_INVALID) {/* don't crash */ + _GD_SetError(D, GD_E_BAD_DIRFILE, 0, NULL, 0, NULL); + dreturn("%u", 0); + return 0; + } + + _GD_ClearError(D); + + entry = _GD_FindFieldAndRepr(D, field_code_in, &field_code, &repr, NULL, 1); + + if (D->error) { + dreturn("%u", -1); + return -1; + } + + if (entry->field_type & GD_SCALAR_ENTRY) { + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + if (field_code != field_code_in) + free(field_code); + dreturn("%u", -1); + return -1; + } + + if (frame_num) { + spf = _GD_GetSPF(D, entry); + + if (D->error) { + if (field_code != field_code_in) + free(field_code); + dreturn("%u", -1); + return -1; + } + } + + sample_num += frame_num * spf; + + whence &= (GD_SEEK_SET | GD_SEEK_CUR | GD_SEEK_END); + if (whence == GD_SEEK_SET) + pos = 0; + else if (whence == GD_SEEK_CUR) + pos = _GD_GetFilePos(D, entry, 1); + else if (whence == GD_SEEK_END) { + pos = _GD_GetEOF(D, entry, NULL, &is_index); + if (is_index) + _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, field_code); + } else + _GD_SetError(D, GD_E_ARGUMENT, GD_E_ARG_WHENCE, NULL, 0, NULL); + + if (!D->error) + _GD_Seek(D, entry, sample_num + pos, pad); + + if (field_code != field_code_in) + free(field_code); + + if (D->error) + pos = -1; + else + pos = _GD_GetFilePos(D, entry, 1); + + dreturn("%lli", (long long)pos); + return pos; +} + +off_t gd_seek(DIRFILE *D, const char *field_code, off_t frame_num, + off_t sample_num, int whence) +{ + return (off_t)gd_seek64(D, field_code, frame_num, sample_num, whence); +} +/* vim: ts=2 sw=2 et tw=80 +*/ Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/getdata.c 2011-10-13 02:08:13 UTC (rev 606) @@ -293,27 +293,10 @@ if (ns > 0) { /** open the file (and cache the fp) if it hasn't been opened yet. */ - if (E->e->u.raw.file[0].idata < 0) { - if (!_GD_Supports(D, E, GD_EF_OPEN | GD_EF_SEEK | GD_EF_READ)) { - free(databuffer); - dreturn("%i", 0); - return 0; - } else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, - 0)) - { - free(databuffer); - dreturn("%i", 0); - return 0; - } else if ((*_gd_ef[E->e->u.raw.file[0].subenc].open)( - D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - _GD_FileSwapBytes(D, E->fragment_index), D->flags & GD_ACCMODE, 0)) - { - _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, - NULL); - free(databuffer); - dreturn("%i", 0); - return 0; - } + if (_GD_InitRawIO(D, E, GD_EF_SEEK | GD_EF_READ, 0)) { + free(databuffer); + dreturn("%i", 0); + return 0; } if ((*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, s0, @@ -327,7 +310,7 @@ samples_read = (*_gd_ef[E->e->u.raw.file[0].subenc].read)(E->e->u.raw.file, - databuffer + n_read * E->e->u.raw.size, E->EN(raw,data_type), ns); + databuffer + n_read * E->e->u.raw.size, E->EN(raw,data_type), ns); if (samples_read == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -348,11 +331,11 @@ if (D->fragment[E->fragment_index].byte_sex & #ifdef WORDS_BIGENDIAN - GD_LITTLE_ENDIAN + GD_LITTLE_ENDIAN #else - GD_BIG_ENDIAN + GD_BIG_ENDIAN #endif - ) + ) { if (E->EN(raw,data_type) & GD_COMPLEX) _GD_FixEndianness(databuffer + n_read * E->e->u.raw.size, @@ -1457,6 +1440,14 @@ return 0; } + if (first_samp == GD_HERE) { + first_samp = _GD_GetFilePos(D, E, -1); + if (D->error) { + dreturn("%i", 0); + return 0; + } + } + /* short circuit for purely real native types */ if (~ntype & GD_COMPLEX) { if (repr == GD_REPR_IMAG) { @@ -1581,17 +1572,30 @@ return 0; } - /* get the samples per frame */ - spf = _GD_GetSPF(D, entry); + if (first_frame == GD_HERE || first_samp == GD_HERE) { + first_samp = GD_HERE; + first_frame = 0; + } - if (D->error) { + if (first_frame > 0 || num_frames > 0) { + /* get the samples per frame */ + spf = _GD_GetSPF(D, entry); + + if (D->error) { + dreturn("%i", 0); + return 0; + } + + first_samp += spf * first_frame; + num_samp += spf * num_frames; + } + + if (first_samp < 0 && (first_samp != GD_HERE || first_frame != 0)) { + _GD_SetError(D, GD_E_RANGE, GD_E_OUT_OF_RANGE, NULL, 0, NULL); dreturn("%i", 0); return 0; } - first_samp += spf * first_frame; - num_samp += spf * num_frames; - n_read = _GD_DoField(D, entry, repr, first_samp, num_samp, return_type, data_out); Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/getdata.h.in 2011-10-13 02:08:13 UTC (rev 606) @@ -142,9 +142,8 @@ #define GD_E_BAD_REFERENCE 24 #define GD_E_PROTECTED 25 #define GD_E_DELETE 26 -#define GD_E_BAD_ENDIANNESS 27 +#define GD_E_ARGUMENT 27 #define GD_E_CALLBACK 28 -#define GD_E_BAD_PROTECTION 29 #define GD_E_UNCLEAN_DB 30 #define GD_E_DOMAIN 31 #define GD_E_BAD_REPR 32 @@ -156,7 +155,9 @@ #define GD_N_ERROR_CODES 37 /* Deprecated error codes */ -#define GD_E_OPEN_INCLUDE GD_E_OPEN_FRAGMENT +#define GD_E_OPEN_INCLUDE GD_E_OPEN_FRAGMENT +#define GD_E_BAD_ENDIANNESS GD_E_ARGUMENT +#define GD_E_BAD_PROTECTION GD_E_ARGUMENT #define GD_MAX_LINCOM 3 @@ -197,12 +198,12 @@ #define GD_PROTECT_ALL ( GD_PROTECT_DATA | GD_PROTECT_FORMAT ) /* Standards specifiers */ -#define GD_VERSION_CURRENT -1 -#define GD_VERSION_LATEST -2 -#define GD_VERSION_EARLIEST -3 +#define GD_VERSION_CURRENT (-1) +#define GD_VERSION_LATEST (-2) +#define GD_VERSION_EARLIEST (-3) /* this MUST be one less than the lowest allowed fragment index */ -#define GD_ALL_FRAGMENTS -1 +#define GD_ALL_FRAGMENTS (-1) #define GD_SCALAR_ENTRY 0x10 /* field types */ @@ -231,6 +232,8 @@ @DEFINE_gd_uint16_t@ @DEFINE_gd_int64_t@ +#define GD_HERE (-1) + #if ! defined GD_C89_API # include <inttypes.h> # define GD_DCOMPLEXM(v) double _Complex v @@ -408,6 +411,12 @@ #define GD_DEL_DEREF 0x4 #define GD_DEL_FORCE 0x8 +/* seek flags */ +#define GD_SEEK_SET 0x0 +#define GD_SEEK_CUR 0x1 +#define GD_SEEK_END 0x2 +#define GD_SEEK_PAD 0x4 + extern int gd_add_bit(DIRFILE *dirfile, const char *field_code, const char *in_field, gd_bit_t bitnum, gd_bit_t numbits, int fragment_index) gd_nothrow gd_nonnull ((1,2,3)); @@ -840,6 +849,12 @@ extern off_t gd_eof(DIRFILE *dirfile, const char *field_code) gd_nonnull ((1,2)); + +extern off_t gd_seek(DIRFILE *dirfile, const char *field_code, off_t frame_num, + off_t sample_num, int whence) gd_nonnull ((1,2)); + +extern off_t gd_tell(DIRFILE *dirfile, const char *field_code) gd_nothrow +gd_nonnull ((1,2)); #else # ifdef __REDIRECT_NTH extern off_t __REDIRECT_NTH (gd_bof, (DIRFILE *dirfile, const char *field_code), @@ -847,9 +862,13 @@ extern off_t __REDIRECT_NTH (gd_frameoffset, (DIRFILE *dirfile, int fragment), gd_frameoffset64) gd_nonnull ((1)); + +extern off_t __REDIRECT_NTH (gd_tell, (DIRFILE *dirfile, + const char *field_code), gd_tell64) gd_nonnull ((1,2)); # else # define gd_bof gd_bof64 # define gd_frameoffset gd_frameoffset64 +# define gd_tell gd_tell64 # endif # ifdef __REDIRECT @@ -874,6 +893,10 @@ extern double __REDIRECT (gd_framenum_subset, (DIRFILE *dirfile, const char *field_code, double value, off_t field_start, off_t field_end), gd_framenum_subset64) gd_nonnull ((1,2)); + +extern off_t __REDIRECT (gd_seek, (DIRFILE *dirfile, const char *field_code, + off_t frame_num, off_t sample_num, int whence), gd_seek64) +gd_nonnull ((1,2)); # else # define gd_alter_frameoffset gd_alter_frameoffset64 # define gd_getdata gd_getdata64 @@ -881,6 +904,7 @@ # define gd_nframes gd_nframes64 # define gd_eof gd_eof64 # define gd_framenum_subset gd_framenum_subset64 +# define gd_seek gd_seek64 # endif #endif @@ -920,6 +944,12 @@ extern gd_off64_t gd_eof64(DIRFILE *dirfile, const char *field_code) gd_nonnull ((1,2)); + +extern off64_t gd_seek64(DIRFILE *dirfile, const char *field_code, + off64_t frame_num, off64_t sample_num, int whence) gd_nonnull ((1,2)); + +extern off64_t gd_tell64(DIRFILE *dirfile, const char *field_code) gd_nothrow +gd_nonnull ((1,2)); #endif Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/gzip.c 2011-10-13 02:08:13 UTC (rev 606) @@ -61,6 +61,7 @@ file->edata = gzdopen(fd, "r"); if (file->edata != NULL) { + file->pos = 0; file->idata = 0; dreturn("%i", 0); return 0; @@ -78,15 +79,23 @@ dtrace("%p, %lli, %x, <unused>", file, (long long)count, data_type); + if (file->pos == count) { + dreturn("%lli", (long long)count); + return count; + } + n = (off64_t)gzseek(file->edata, (off_t)count * GD_SIZE(data_type), SEEK_SET); if (n == -1) { dreturn("%i", -1); return -1; } + + n /= GD_SIZE(data_type); + file->pos = n; - dreturn("%lli", (long long)(n / GD_SIZE(data_type))); - return n / GD_SIZE(data_type); + dreturn("%lli", (long long)n); + return n; } ssize_t _GD_GzipRead(struct _gd_raw_file *file, void *ptr, gd_type_t data_type, @@ -98,8 +107,10 @@ n = gzread(file->edata, ptr, GD_SIZE(data_type) * nmemb); - if (n >= 0) + if (n >= 0) { n /= GD_SIZE(data_type); + file->pos += n; + } dreturn("%zu", n); return n; Modified: trunk/getdata/src/index.c =================================================================== --- trunk/getdata/src/index.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/index.c 2011-10-13 02:08:13 UTC (rev 606) @@ -1,4 +1,4 @@ -/* Copyright (C) 2009-2010 D. V. Wiebe +/* Copyright (C) 2009-2011 D. V. Wiebe * *************************************************************************** * Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/internal.h 2011-10-13 02:08:13 UTC (rev 606) @@ -497,6 +497,7 @@ #define GD_E_DOMAIN_COMPLEX 1 #define GD_E_DOMAIN_EMPTY 2 #define GD_E_DOMAIN_ANTITONIC 3 +#define GD_E_DOMAIN_MULTIPOS 4 #define GD_E_OUT_OF_RANGE 1 #define GD_E_SINGULAR_RANGE 2 @@ -514,12 +515,17 @@ #define GD_E_VERS_NONE 1 #define GD_E_VERS_MISSING 2 +#define GD_E_ARG_WHENCE 1 +#define GD_E_ARG_ENDIANNESS 2 +#define GD_E_ARG_PROTECTION 3 + struct _gd_raw_file { char* name; int idata; void* edata; int subenc; const DIRFILE *D; + off64_t pos; }; struct _gd_lut { @@ -574,6 +580,7 @@ gd_entry_t** client; } scalar; char* string; + off64_t index_pos; } u; }; @@ -797,6 +804,9 @@ void _GD_Flush(DIRFILE* D, gd_entry_t *E); void _GD_FlushMeta(DIRFILE* D, int fragment, int force); void _GD_FreeE(DIRFILE *D, gd_entry_t* E, int priv); +off64_t _GD_GetEOF(DIRFILE *D, gd_entry_t* E, const char *parent, + int *is_index); +off64_t _GD_GetFilePos(DIRFILE *D, gd_entry_t *E, off64_t index_pos); char *_GD_GetLine(FILE *fp, size_t *n, int* linenum); int _GD_GetRepr(DIRFILE*, const char*, char**); gd_spf_t _GD_GetSPF(DIRFILE* D, gd_entry_t* E); @@ -804,6 +814,7 @@ int _GD_Include(DIRFILE* D, const char* ename, const char* format_file, int linenum, char** ref_name, int me, int* standards, unsigned long *flags); void _GD_InitialiseFramework(void); +int _GD_InitRawIO(DIRFILE *D, gd_entry_t *E, unsigned int funcs, int creat); void _GD_InvertData(DIRFILE* D, void* data, gd_type_t return_type, double dividend, size_t n_read); void _GD_InsertSort(DIRFILE* D, gd_entry_t* E, int u) gd_nothrow; Modified: trunk/getdata/src/legacy.c =================================================================== --- trunk/getdata/src/legacy.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/legacy.c 2011-10-13 02:08:13 UTC (rev 606) @@ -75,9 +75,9 @@ "Bad REFERENCE field", /* GD_E_BAD_REFERENCE */ "Operation prohibited by protection level", /* GD_E_PROTECTED */ NULL, /* GD_E_DELETE */ - NULL, /* GD_E_BAD_ENDIANNESS */ + "Bad argument", /* GD_E_ARGUMENT */ NULL, /* GD_E_CALLBACK */ - NULL, /* GD_E_BAD_PROTECTION */ + NULL, /* unused */ NULL, /* GD_E_UNCLEAN_DB */ "Improper domain", /* GD_E_DOMAIN */ "Bad representation", /* GD_E_BAD_REPR */ Modified: trunk/getdata/src/lzma.c =================================================================== --- trunk/getdata/src/lzma.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/lzma.c 2011-10-13 02:08:13 UTC (rev 606) @@ -130,6 +130,7 @@ return 1; } + file->pos = 0; file->idata = 0; dreturn("%i", 0); return 0; @@ -206,6 +207,12 @@ count *= GD_SIZE(data_type); + /* the easy case */ + if (file->pos == count) { + dreturn("%lli", (long long)count); + return count; + } + if (ptr->base > count) { /* a backwards seek -- rewind to the beginning */ lzma_end(&ptr->xzfile); @@ -239,8 +246,10 @@ ptr->out_pos = (ptr->stream_end && count >= ptr->base + ptr->end) ? ptr->end : count - ptr->base; - dreturn("%lli", (long long)((ptr->base + ptr->out_pos) / GD_SIZE(data_type))); - return (ptr->base + ptr->out_pos) / GD_SIZE(data_type); + file->pos = (ptr->base + ptr->out_pos) / GD_SIZE(data_type); + + dreturn("%lli", (long long)(file->pos)); + return file->pos; } ssize_t _GD_LzmaRead(struct _gd_raw_file *file, void *data, gd_type_t data_type, @@ -287,6 +296,8 @@ nbytes = 0; } + file->pos += nmemb - nbytes / GD_SIZE(data_type); + dreturn("%li", (long)(nmemb - nbytes / GD_SIZE(data_type))); return nmemb - nbytes / GD_SIZE(data_type); } Modified: trunk/getdata/src/protect.c =================================================================== --- trunk/getdata/src/protect.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/protect.c 2011-10-13 02:08:13 UTC (rev 606) @@ -78,7 +78,7 @@ protection_level != GD_PROTECT_DATA && protection_level != GD_PROTECT_ALL) { - _GD_SetError(D, GD_E_BAD_PROTECTION, 0, NULL, 0, NULL); + _GD_SetError(D, GD_E_ARGUMENT, GD_E_ARG_PROTECTION, NULL, 0, NULL); dreturn("%i", -1); return -1; } Modified: trunk/getdata/src/putdata.c =================================================================== --- trunk/getdata/src/putdata.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/putdata.c 2011-10-13 02:08:13 UTC (rev 606) @@ -100,31 +100,19 @@ } /* write data to file. */ - if (E->e->u.raw.file[0].idata < 0) { - /* open file for reading / writing if not already opened */ - - if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) { - free(databuffer); - dreturn("%i", 0); - return 0; - } else if ((*_gd_ef[E->e->u.raw.file[0].subenc].open)( - D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - _GD_FileSwapBytes(D, E->fragment_index), D->flags & GD_ACCMODE, 1)) - { - _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); - free(databuffer); - dreturn("%i", 0); - return 0; - } + if (_GD_InitRawIO(D, E, 0, 1)) { + free(databuffer); + dreturn("%i", 0); + return 0; } if ((*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, s0, E->EN(raw,data_type), 1) == -1) { - _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); - free(databuffer); - dreturn("%i", 0); - return 0; + _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); + free(databuffer); + dreturn("%i", 0); + return 0; } n_wrote = (*_gd_ef[E->e->u.raw.file[0].subenc].write)(E->e->u.raw.file, @@ -603,6 +591,14 @@ return 0; } + if (first_samp == GD_HERE) { + first_samp = _GD_GetFilePos(D, E, -1); + if (D->error) { + dreturn("%i", 0); + return 0; + } + } + switch (E->field_type) { case GD_RAW_ENTRY: n_wrote = _GD_DoRawOut(D, E, first_samp, num_samp, data_type, data_in); @@ -659,7 +655,7 @@ gd_entry_t *entry; char* field_code; int repr; - gd_spf_t spf; + gd_spf_t spf = 0; dtrace("%p, \"%s\", %lli, %lli, %zu, %zu, 0x%x, %p", D, field_code_in, first_frame, first_samp, num_frames, num_samp, data_type, data_in); @@ -696,17 +692,30 @@ return 0; } - /* get the samples per frame */ - spf = _GD_GetSPF(D, entry); + if (first_frame == GD_HERE || first_samp == GD_HERE) { + first_samp = GD_HERE; + first_frame = 0; + } - if (D->error) { + if (num_frames > 0 || first_frame > 0) { + /* get the samples per frame */ + spf = _GD_GetSPF(D, entry); + + if (D->error) { + dreturn("%i", 0); + return 0; + } + + first_samp += spf * first_frame; + num_samp += spf * num_frames; + } + + if (first_samp < 0 && (first_samp != GD_HERE || first_frame != 0)) { + _GD_SetError(D, GD_E_RANGE, GD_E_OUT_OF_RANGE, NULL, 0, NULL); dreturn("%i", 0); return 0; } - first_samp += spf * first_frame; - num_samp += spf * num_frames; - n_wrote = _GD_DoFieldOut(D, entry, repr, first_samp, num_samp, data_type, data_in); Modified: trunk/getdata/src/raw.c =================================================================== --- trunk/getdata/src/raw.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/raw.c 2011-10-13 02:08:13 UTC (rev 606) @@ -36,6 +36,8 @@ file->idata = gd_OpenAt(file->D, dirfd, file->name, ((mode == GD_RDWR) ? O_RDWR : O_RDONLY) | (creat ? O_CREAT : 0) | O_BINARY, 0666); + file->pos = 0; + dreturn("%i", file->idata < 0); return (file->idata < 0); } @@ -47,6 +49,12 @@ dtrace("%p, %lli, %x, <unused>", file, (long long)count, data_type); + /* short circuit */ + if (file->pos == count) { + dreturn("%lli", (long long)count); + return count; + } + pos = lseek64(file->idata, count * GD_SIZE(data_type), SEEK_SET); if (pos == -1) { @@ -54,6 +62,8 @@ return -1; } + file->pos = count; + dreturn("%lli", (long long)count); return count; } @@ -67,8 +77,10 @@ nread = read(file->idata, ptr, nmemb * GD_SIZE(data_type)); - if (nread >= 0) + if (nread >= 0) { nread /= GD_SIZE(data_type); + file->pos += nread; + } dreturn("%zi", nread); return nread; @@ -83,8 +95,10 @@ nwrote = write(file->idata, ptr, nmemb * GD_SIZE(data_type)); - if (nwrote >= 0) + if (nwrote >= 0) { nwrote /= GD_SIZE(data_type); + file->pos += nwrote; + } dreturn("%zu", nwrote); return nwrote; @@ -130,6 +144,7 @@ dtrace("%i, %p, <unused>", fd, file); file->idata = fd; + file->pos = 0; dreturn("%i", 0); return 0; Modified: trunk/getdata/src/sie.c =================================================================== --- trunk/getdata/src/sie.c 2011-09-30 00:55:47 UTC (rev 605) +++ trunk/getdata/src/sie.c 2011-10-13 02:08:13 UTC (rev 606) @@ -90,6 +90,7 @@ return -1; } + file->pos = -1; file->idata = 0; dreturn("%i", 0); return 0; @@ -147,6 +148,11 @@ dtrace("%p, %llx, 0x%03x, %i", file, (long long)sample, data_type, pad); + if (file->pos == sample) { + dreturn("%lli", sample); + return sample; + } + if (sample < f->p) { /* seek backwards -- reading a file backwards doesn't necessarily work * that well. So, let's just rewind to the beginning and try again. */ @@ -181,7 +187,7 @@ } f->s = sample; } - f->p = sample; + file->pos = f->p = sample; dreturn("%llx", f->p); return (off64_t)(f->p); @@ -262,6 +268,8 @@ f->p = f->d[0] + 1; } + file->pos = f->p; + dreturn("%llx", (long long)count); return count; } @@ -409,6 +417,7 @@ free(p); + file->pos = f->p; dreturn("%llu", (unsigned long long)nelem); return nelem; } @@ -512,6 +521,7 @@ f = (struct gd_siedata*)(file->edata); memset(f, 0, sizeof(struct gd_siedata)); f->r = f->s = f->p = f->d[0] = -1; + file->pos = -1; f->fp = stream; f->swap = swap; file->idata = 0; Property changes on: trunk/getdata/test ___________________________________________________________________ Modified: svn:ignore - Makefile Makefile.in *.o *.odirfile *.swp *.exe .deps .libs convert_uint8_int8 convert_uint8_uint16 convert_uint8_int16 convert_uint8_uint32 convert_uint8_int32 convert_uint8_float32 convert_uint8_uint64 convert_uint8_int64 convert_uint8_float64 convert_int8_uint8 convert_int8_uint16 convert_int8_int16 convert_int8_uint32 convert_int8_int32 convert_int8_float32 convert_int8_uint64 convert_int8_int64 convert_int8_float64 convert_uint16_uint8 convert_uint16_int8 convert_uint16_int16 convert_uint16_uint32 convert_uint16_int32 convert_uint16_float32 convert_uint16_uint64 convert_uint16_int64 convert_uint16_float64 convert_int16_uint8 convert_int16_int8 convert_int16_uint16 convert_int16_uint32 convert_int16_int32 convert_int16_float32 convert_int16_uint64 convert_int16_int64 convert_int16_float64 convert_uint32_uint8 convert_uint32_int8 convert_uint32_uint16 convert_uint32_int16 convert_uint32_int32 convert_uint32_float32 convert_uint32_uint64 convert_uint32_int64 convert_uint32_float64 convert_int32_uint8 convert_int32_int8 convert_int32_uint16 convert_int32_int16 convert_int32_uint32 convert_int32_float32 convert_int32_uint64 convert_int32_int64 convert_int32_float64 convert_uint64_uint8 convert_uint64_int8 convert_uint64_uint16 convert_uint64_int16 convert_uint64_uint32 convert_uint64_int32 convert_uint64_float32 convert_uint64_int64 convert_uint64_float64 convert_int64_uint8 convert_int64_int8 convert_int64_uint16 convert_int64_int16 convert_int64_uint32 convert_int64_int32 convert_int64_float32 convert_int64_uint64 convert_int64_float64 convert_float32_uint8 convert_float32_int8 convert_float32_uint16 convert_float32_int16 convert_float32_uint32 convert_float32_int32 convert_float32_uint64 convert_float32_int64 convert_float32_float64 convert_float64_uint8 convert_float64_int8 convert_float64_uint16 convert_float64_int16 convert_float64_uint32 convert_float64_int32 convert_float64_float32 convert_float64_uint64 convert_float64_int64 creat creat_excl creat_rdonly flist flist_invalid get64 get_bad_code get_bit get_char get_endian8 get_endian16 get_endian32 get_endian64 get_endian_float32_big get_endian_float32_arm get_endian_float32_little get_endian_float64_big get_endian_float64_arm get_endian_float64_little get_ff get_float32 get_float64 get_foffs get_fs get_int8 get_int16 get_int32 get_int64 get_invalid get_lincom1 get_lincom2 get_lincom3 get_lincom_noin get_linterp get_linterp_noin get_linterp_notab get_multiply get_multiply_noin get_nonexistent get_null get_off64 get_phase get_recurse get_sf get_ss get_type get_uint16 get_uint32 get_uint64 legacy_get legacy_nframes legacy_nonexistent legacy_put legacy_spf nfields nfields_invalid nframes nframes64 nframes_empty nframes_invalid nframes_off64 nframes_spf open open_eaccess open_nonexistent open_notdirfile parse_badline parse_bit parse_bit4 parse_bit_bitnum parse_bit_bitsize parse_bit_ncols parse_bit_numbits parse_endian_bad parse_endian_big parse_endian_force parse_endian_little parse_foffs parse_include parse_include_nonexistent parse_index parse_lincom parse_lincom_ncols1 parse_lincom_ncols2 parse_lincom_nfields parse_lincom_nofields parse_linterp parse_linterp_ncols parse_multiply parse_multiply_ncols parse_ncols parse_phase parse_phase_ncols parse_raw parse_raw_char parse_raw_ncols parse_raw_spf parse_raw_type parse_version parse_version_include put64 put_bad_code put_bit put_bof put_char put_endian8 put_endian16 put_endian32 put_endian64 put_endian_float32_arm put_endian_float32_big put_endian_float32_little put_endian_float64_arm put_endian_float64_big put_endian_float64_little put_ff put_float32 put_float64 put_foffs put_fs put_int8 put_int16 put_int32 put_int64 put_invalid put_lincom1 put_lincom2 put_lincom_noin put_linterp put_linterp_notab put_multiply put_null put_off64 put_phase put_phase_noin put_rdonly put_recurse put_rofs put_sf put_ss put_type put_uint16 put_uint32 put_uint64 spf spf_lincom spf_multiply spf_recurse trunc trunc_rdonly trunc_rofs flush_invalid parse_version_slash flush_all flush close_null close parse_endian_slash error_error parse_name parse_include_slash close_bad parse_foffs_slash flush_bad_code dfes_bit dfes_lincom dfes_linterp dfes_multiply dfes_null dfes_phase dfes_raw dfes_zero entry_bad_code entry_bit entry_invalid entry_lincom entry_linterp entry_multiply entry_phase entry_raw legacy_get_put legacy_get_rofs add_phase add_lincom_nfields add_raw add_multiply add_bit_bitsize flush_meta add_type add_raw_type add_bit_bitnum add_bit add_format add_raw_spf put_linterp_noin error_short error add add_linterp nfragments add_duplicate add_code add_bit_numbits add_lincom add_rdonly ascii_get ascii_put ascii_nframes slim_get slim_nframes slim_put add_many add_sort nfields_type nfields_type_invalid nmeta nmeta_invalid nmeta_parent nmeta_type nmeta_type_invalid nmeta_type_parent nmeta_vectors nmeta_vectors_invalid nmeta_vectors_parent nvectors nvectors_invalid parse_const parse_const_ncols parse_duplicate parse_meta parse_meta_parent parse_meta_raw parse_quote parse_sort parse_string parse_string_ncols parse_whitespace madd_linterp_invalid madd_lincom_invalid vlist_invalid vlist_meta add_raw_invalid cvlist_invalid svlist_invalid cvlist svlist madd_phase_invalid add_invalid madd_phase add_phase_invalid add_spec_directive add_string add_linterp_invalid madd_multiply flist_type_invalid clist cvlist_meta_invalid flist_meta_invalid flist_type svlist_meta_invalid cvlist_meta vlist_meta_invalid svlist_meta parse_string_null madd_linterp madd_lincom vlist add_bit_invalid add_lincom_invalid madd_bit_invalid madd_bit add_multiply_invalid add_const madd_multiply_invalid madd add_spec_invalid flist_type_meta_invalid add_spec flist_type_meta flist_meta parse_meta_index entry_raw_scalar_code parse_bit_scalar entry_raw_scalar_type entry_lincom_scalar entry_phase_scalar entry_raw_scalar parse_lincom_scalar entry_bit_scalar parse_raw_scalar parse_phase_scalar include include_nonexistent include_creat include_invalid include_accmode include_index madd_spec_directive madd_spec_invalid madd_spec parse_quote_mismatch parse_eol parse_foffs_include put_string parse_protect_data put_const put_string_protect ref put_const_protect parse_protect_all ref_none parse_ref add_protect parse_protect_format parse_protect_bad ref_two put_protect include_rdonly parse_ref_nonexistent parse_protect_none parse_name_pedantic parse_name_dot parse_name_ext parse_duplicate_ignore gzip_get gzip_nframes gzip_put gzip_get_get bzip_get bzip_nframes bzip_put bzip_get_get global_name open_cb_abort open_cb_cont open_cb_ignore open_cb_rescan open_cb_invalid del_const_force del_const del_derived_force del_const_deref del_meta_force del_data del_meta del del_derived close_discard global_ref_set global_ref_empty include_ignore global_ref include_ref include_auto move move_index move_protect move_data_enc_ar bzip_move_from gzip_move_from move_data_foffs move_data_enc_ra move_data_endian move_data_nop alter_multiply alter_bit_bitnum alter_entry_recode alter_linterp_move alter_raw_spf alter_entry alter_bit_numbits alter_lincom_slope alter_raw_type alter_lincom_input alter_const alter_phase alter_lincom_offset alter_linterp foffs_get foffs_move foffs_alter endian_alter endian_move endian_get encode_alter encode_get encode_move protect_alter move_subdir unclude_del name_move unclude file name file_type unclude_move file_code parent protect_get global_ref_get alter_mspec alter_spec include_cb include_pc include_syntax fragment_index fragment_name fragment_name_oor entry_type alter_polynom_coeff get_polynom_noin get_polynom put_polynom_noin madd_polynom parse_polynom_scalar alter_polynom_ord parse_polynom spf_polynom entry_polynom_scalar put_polynom1 put_polynom2 parse_polynom_ncols1 parse_polynom_ncols2 alter_polynom_input add_polynom entry_polynom parse_lincom_non_ncols parse_lincom_non get_lincom_non xz_get xz_nframes lzma_get lzma_nframes add_sbit parse_sbit put_sbit get_sbit madd_sbit flush_spec index_domain madd_clincom index madd_const index_range add_clincom add_cpolynom get_clincom convert_float32_complex64 convert_int32_complex128 get_endian_complex128_big get_endian_complex128_arm get_endian_complex128_little convert_complex64_float64 parse_meta_index2 convert_uint16_complex128 put_endian_complex64_arm put_endian_complex64_big put_endian_complex64_little convert_uint16_complex64 convert_float64_complex128 repr_int8 convert_complex64_int64 convert_uint64_complex64 convert_complex64_complex128 get_const convert_uint8_complex128 parse_meta_implicit2 convert_float32_complex128 get_complex64 add_spec_meta convert_float64_complex64 convert_int16_complex128 alter_cpolynom madd_cpolynom convert_int32_complex64 alter_lincom_23 convert_complex64_uint64 repr_uint8 put_complex128 get_endian_complex64_big get_endian_complex64_arm get_endian_complex64_little alter_spec_meta repr_real_a repr_real_i repr_real_m repr_real_r repr_int16 convert_uint8_complex64 repr_int32 madd_string convert_complex128_float64 repr_uint16 repr_int64 put_endian_complex128_arm put_endian_complex128_big put_endian_complex128_little get_complex128 repr_uint32 convert_complex128_uint64 get_const_repr convert_complex128_int64 repr_float32 repr_uint64 convert_int16_complex64 repr_float64 put_complex64 convert_uint64_complex128 convert_int64_complex64 repr_a repr_i repr_m repr_r get_const_complex convert_int8_complex128 convert_uint32_complex128 parse_meta_implicit get_cpolynom put_repr convert_complex128_complex64 convert_int8_complex64 convert_uint32_complex64 convert_int64_complex128 move_meta add_scalar alter_entry_scalar2a alter_entry_scalar2n alter_entry_scalar3 alter_entry_scalar4 get_zero entry_scalar_repr header_complex version_5_strict parse_version_permissive version_7_strict version_0 version_1 version_2 version_3 version_4 version_5 version_6 version_7 version_6_strict eof eof_index eof_lincom eof_phase bof bof_lincom bof_phase put_linterp_nomono get_linterp_sort put_linterp_reverse alter_lincom_32 parse_recip parse_divide alter_recip dfes_recip add_crecip89 add_divide put_divide madd_recip add_crecip get_recip_const spf_divide add_divide_invalid version_8 alter_crecip89 put_recip spf_recip madd_crecip89 alter_divide get_recip alter_crecip madd_divide dfes_divide madd_crecip add_recip get_divide version_8_strict version_5_write version_0_write version_7_write version_2_write version_4_write version_6_write version_1_write version_8_write version_3_write put_carray_slice cvlist_array_meta del_carray get_carray_slice cvlist_array del_carray_deref nmeta_vectors_del get_carray parse_carray madd_carray add_carray put_carray get_carray_len parse_carray_long alter_carray_len alter_carray_type ascii_get_get parse_include_relabs parse_include_absrel parse_include_relrel parse_include_absolute add_raw_include alter_crecip_zero alter_recip_zero error_num sie_put_little sie_get_big sie_move_to sie_nframes_big sie_get_little sie_nframes_little sie_move_from sie_put_big + Makefile Makefile.in *.o *.odirfile *.swp *.exe .deps .libs convert_uint8_int8 convert_uint8_uint16 convert_uint8_int16 convert_uint8_uint32 convert_uint8_int32 convert_uint8_float32 convert_uint8_uint64 convert_uint8_int64 convert_uint8_float64 convert_int8_uint8 convert_int8_uint16 convert_int8_int16 convert_int8_uint32 convert_int8_int32 convert_int8_float32 convert_int8_uint64 convert_int8_int64 convert_int8_float64 convert_uint16_uint8 convert_uint16_int8 convert_uint16_int16 convert_uint16_uint32 convert_uint16_int32 convert_uint16_float32 convert_uint16_uint64 convert_uint16_int64 convert_uint16_float64 convert_int16_uint8 convert_int16_int8 convert_int16_uint16 convert_int16_uint32 convert_int16_int32 convert_int16_float32 convert_int16_uint64 convert_int16_int64 convert_int16_float64 convert_uint32_uint8 convert_uint32_int8 convert_uint32_uint16 convert_uint32_int16 convert_uint32_int32 convert_uint32_float32 convert_uint32_uint64 convert_uint32_int64 convert_uint32_float64 convert_int32_uint8 convert_int32_int8 convert_int32_uint16 convert_int32_int16 convert_int32_uint32 convert_int32_float32 convert_int32_uint64 convert_int32_int64 convert_int32_float64 convert_uint64_uint8 convert_uint64_int8 convert_uint64_uint16 convert_uint64_int16 convert_uint64_uint32 convert_uint64_int32 convert_uint64_float32 convert_uint64_int64 convert_uint64_float64 convert_int64_uint8 convert_int64_int8 convert_int64_uint16 convert_int64_int16 convert_int64_uint32 convert_int64_int32 convert_int64_float32 convert_int64_uint64 convert_int64_float64 convert_float32_uint8 convert_float32_int8 convert_float32_uint16 convert_float32_int16 convert_float32_uint32 convert_float32_int32 convert_float32_uint64 convert_float32_int64 convert_float32_float64 convert_float64_uint8 convert_float64_int8 convert_float64_uint16 convert_float64_int16 convert_float64_uint32 convert_float64_int32 convert_float64_float32 convert_float64_uint64 convert_float64_int64 creat creat_excl creat_rdonly flist flist_invalid get64 get_bad_code get_bit get_char get_endian8 get_endian16 get_endian32 get_endian64 get_endian_float32_big get_endian_float32_arm get_endian_float32_little get_endian_float64_big get_endian_float64_arm get_endian_float64_little get_ff get_float32 get_float64 get_foffs get_fs get_int8 get_int16 get_int32 get_int64 get_invalid get_lincom1 get_lincom2 get_lincom3 get_lincom_noin get_linterp get_linterp_noin get_linterp_notab get_multiply get_multiply_noin get_nonexistent get_null get_off64 get_phase get_recurse get_sf get_ss get_type get_uint16 get_uint32 get_uint64 legacy_get legacy_nframes legacy_nonexistent legacy_put legacy_spf nfields nfields_invalid nframes nframes64 nframes_empty nframes_invalid nframes_off64 nframes_spf open open_eaccess open_nonexistent open_notdirfile parse_badline parse_bit parse_bit4 parse_bit_bitnum parse_bit_bitsize parse_bit_ncols parse_bit_numbits parse_endian_bad parse_endian_big parse_endian_force parse_endian_little parse_foffs parse_include parse_include_nonexistent parse_index parse_lincom parse_lincom_ncols1 parse_lincom_ncols2 parse_lincom_nfields parse_lincom_nofields parse_linterp parse_linterp_ncols parse_multiply parse_multiply_ncols parse_ncols parse_phase parse_phase_ncols parse_raw parse_raw_char parse_raw_ncols parse_raw_spf parse_raw_type parse_version parse_version_include put64 put_bad_code put_bit put_bof put_char put_endian8 put_endian16 put_endian32 put_endian64 put_endian_float32_arm put_endian_float32_big put_endian_float32_little put_endian_float64_arm put_endian_float64_big put_endian_float64_little put_ff put_float32 put_float64 put_foffs put_fs put_int8 put_int16 put_int32 put_int64 put_invalid put_lincom1 put_lincom2 put_lincom_noin put_linterp put_linterp_notab put_multiply put_null put_off64 put_phase put_phase_noin put_rdonly put_recurse put_rofs put_sf put_ss put_type put_uint16 put_uint32 put_uint64 spf spf_lincom spf_multiply spf_recurse trunc trunc_rdonly trunc_rofs flush_invalid parse_version_slash flush_all flush close_null close parse_endian_slash error_error parse_name parse_include_slash close_bad parse_foffs_slash flush_bad_code dfes_bit dfes_lincom dfes_linterp dfes_multiply dfes_null dfes_phase dfes_raw dfes_zero entry_bad_code entry_bit entry_invalid entry_lincom entry_linterp entry_multiply entry_phase entry_raw legacy_get_put legacy_get_rofs add_phase add_lincom_nfields add_raw add_multiply add_bit_bitsize flush_meta add_type add_raw_type add_bit_bitnum add_bit add_format add_raw_spf put_linterp_noin error_short error add add_linterp nfragments add_duplicate add_code add_bit_numbits add_lincom add_rdonly ascii_get ascii_put ascii_nframes slim_get slim_nframes slim_put add_many add_sort nfields_type nfields_type_invalid nmeta nmeta_invalid nmeta_parent nmeta_type nmeta_type_invalid nmeta_type_parent nmeta_vectors nmeta_vectors_invalid nmeta_vectors_parent nvectors nvectors_invalid parse_const parse_const_ncols parse_duplicate parse_meta parse_meta_parent parse_meta_raw parse_quote parse_sort parse_string parse_string_ncols parse_whitespace madd_linterp_invalid madd_lincom_invalid vlist_invalid vlist_meta add_raw_invalid cvlist_invalid svlist_invalid cvlist svlist madd_phase_invalid add_invalid madd_phase add_phase_invalid add_spec_directive add_string add_linterp_invalid madd_multiply flist_type_invalid clist cvlist_meta_invalid flist_meta_invalid flist_type svlist_meta_invalid cvlist_meta vlist_meta_invalid svlist_meta parse_string_null madd_linterp madd_lincom vlist add_bit_invalid add_lincom_invalid madd_bit_invalid madd_bit add_multiply_invalid add_const madd_multiply_invalid madd add_spec_invalid flist_type_meta_invalid add_spec flist_type_meta flist_meta parse_meta_index entry_raw_scalar_code parse_bit_scalar entry_raw_scalar_type entry_lincom_scalar entry_phase_scalar entry_raw_scalar parse_lincom_scalar entry_bit_scalar parse_raw_scalar parse_phase_scalar include include_nonexistent include_creat include_invalid include_accmode include_index madd_spec_directive madd_spec_invalid madd_spec parse_quote_mismatch parse_eol parse_foffs_include put_string parse_protect_data put_const put_string_protect ref put_const_protect parse_protect_all ref_none parse_ref add_protect parse_protect_format parse_protect_bad ref_two put_protect include_rdonly parse_ref_nonexistent parse_protect_none parse_name_pedantic parse_name_dot parse_name_ext parse_duplicate_ignore gzip_get gzip_nframes gzip_put gzip_get_get bzip_get bzip_nframes bzip_put bzip_get_get global_name open_cb_abort open_cb_cont open_cb_ignore open_cb_rescan open_cb_invalid del_const_force del_const del_derived_force del_const_deref del_meta_force del_data del_meta del del_derived close_discard global_ref_set global_ref_empty include_ignore global_ref include_ref include_auto move move_index move_protect move_data_enc_ar bzip_move_from gzip_move_from move_data_foffs move_data_enc_ra move_data_endian move_data_nop alter_multiply alter_bit_bitnum alter_entry_recode alter_linterp_move alter_raw_spf alter_entry alter_bit_numbits alter_lincom_slope alter_raw_type alter_lincom_input alter_const alter_phase alter_l... [truncated message content] |
From: <ket...@us...> - 2011-09-30 00:55:53
|
Revision: 605 http://getdata.svn.sourceforge.net/getdata/?rev=605&view=rev Author: ketiltrout Date: 2011-09-30 00:55:47 +0000 (Fri, 30 Sep 2011) Log Message: ----------- Lintian fixes from the Debian build courtesy Michael Milligan. Modified Paths: -------------- trunk/getdata/man/gd_error_string.3 trunk/getdata/man/gd_get_carray_slice.3 trunk/getdata/man/gd_put_carray_slice.3 Modified: trunk/getdata/man/gd_error_string.3 =================================================================== --- trunk/getdata/man/gd_error_string.3 2011-09-07 21:36:47 UTC (rev 604) +++ trunk/getdata/man/gd_error_string.3 2011-09-30 00:55:47 UTC (rev 605) @@ -14,6 +14,7 @@ .\" as part of this distribution. .\" .TH gd_error_string 3 "20 April 2011" "Version 0.8.0" "GETDATA" +.SH NAME gd_error_string \(em report a GetData library error .SH SYNOPSIS .B #include <getdata.h> Modified: trunk/getdata/man/gd_get_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_get_carray_slice.3 2011-09-07 21:36:47 UTC (rev 604) +++ trunk/getdata/man/gd_get_carray_slice.3 2011-09-30 00:55:47 UTC (rev 605) @@ -15,7 +15,7 @@ .\" .TH gd_get_carray_slice 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME -gd_get_carray gd_get_carray_slice \(em retrieve CARRAY data from a dirfile +gd_get_carray, gd_get_carray_slice \(em retrieve CARRAY data from a dirfile database .SH SYNOPSIS .B #include <getdata.h> Modified: trunk/getdata/man/gd_put_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_put_carray_slice.3 2011-09-07 21:36:47 UTC (rev 604) +++ trunk/getdata/man/gd_put_carray_slice.3 2011-09-30 00:55:47 UTC (rev 605) @@ -15,7 +15,7 @@ .\" .TH gd_put_carray_slice 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME -gd_put_carray gd_put_carray_slice \(em write CARRAY data to a dirfile database +gd_put_carray, gd_put_carray_slice \(em write CARRAY data to a dirfile database .SH SYNOPSIS .B #include <getdata.h> .HP This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-09-07 21:36:56
|
Revision: 604 http://getdata.svn.sourceforge.net/getdata/?rev=604&view=rev Author: ketiltrout Date: 2011-09-07 21:36:47 +0000 (Wed, 07 Sep 2011) Log Message: ----------- Module::Build seems to handle VPATH builds better than ExtUtils::MakeMaker, so let's just go with that. Module::Build has been part of the core modules since perl5.9.4. Modified Paths: -------------- trunk/getdata/bindings/perl/Makefile.am trunk/getdata/bindings/perl/simple_funcs.pl trunk/getdata/configure.ac trunk/getdata/m4/perl.m4 Added Paths: ----------- trunk/getdata/bindings/perl/Build.PL.in trunk/getdata/bindings/perl/MANIFEST Removed Paths: ------------- trunk/getdata/bindings/perl/Makefile.PL.in Property Changed: ---------------- trunk/getdata/bindings/perl/ Property changes on: trunk/getdata/bindings/perl ___________________________________________________________________ Modified: svn:ignore - simple_funcs.xs Makefile.in GetData.pm GetData.c .deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib debug.c MYMETA.yml GetData.bs GetData.bs + simple_funcs.xs Makefile.in GetData.pm GetData.c .deps make_parameters.sed Makefile MYMETA.yml MYMETA.json _build Build lib debug.c blib Build.PL Added: trunk/getdata/bindings/perl/Build.PL.in =================================================================== --- trunk/getdata/bindings/perl/Build.PL.in (rev 0) +++ trunk/getdata/bindings/perl/Build.PL.in 2011-09-07 21:36:47 UTC (rev 604) @@ -0,0 +1,25 @@ +# @configure_input@ + +use Module::Build; +my $build = Module::Build->new( + c_source => '@srcdir@', + dist_abstract => "Perl bindings to the GetData library", + dist_author => 'The GetData Project <@PACKAGE_BUGREPORT@>', + dist_version_from => "GetData.pm", + extra_compiler_flags => '@DEFS@', + extra_linker_flags => ['-L@top_builddir@/src/.libs/', '-lgetdata'], + include_dirs => '@top_srcdir@/src', + license => 'lgpl', + module_name => "GetData", + pm_files => { + 'GetData.pm' => 'lib/GetData.pm', + }, + requires => { + perl => '5.6.0', + 'Math::Complex' => '1.34' + }, + xs_files => { + '@srcdir@/GetData.xs' => 'lib/GetData.xs' + } +); +$build->create_build_script; Added: trunk/getdata/bindings/perl/MANIFEST =================================================================== --- trunk/getdata/bindings/perl/MANIFEST (rev 0) +++ trunk/getdata/bindings/perl/MANIFEST 2011-09-07 21:36:47 UTC (rev 604) @@ -0,0 +1,2 @@ +MANIFEST This list of files +GetData.pm Deleted: trunk/getdata/bindings/perl/Makefile.PL.in =================================================================== --- trunk/getdata/bindings/perl/Makefile.PL.in 2011-08-24 21:06:52 UTC (rev 603) +++ trunk/getdata/bindings/perl/Makefile.PL.in 2011-09-07 21:36:47 UTC (rev 604) @@ -1,23 +0,0 @@ -use 5.00800; -use ExtUtils::MakeMaker; - -my @gd_cfiles = ("GetData.c"); -push @gd_cfiles, "debug.c" if (@GETDATA_DEBUG@); -my $gd_objects = "GetData\${OBJ_EXT}" . ((@GETDATA_DEBUG@) ? " debug\${OBJ_EXT}" : ""); - -WriteMakefile( - ABSTRACT_FROM => "GetData.pm", - AUTHOR => "The GetData Progject <@PACKAGE_BUGREPORT@>", - C => \@gd_cfiles, - DEFINE => "@DEFS@", - FIRST_MAKEFILE => "perl.mk", - INC => '-I. -I@top_builddir@/src', - LIBS => ['-L@top_builddir@/src/.libs/ -lgetdata'], - NAME => "GetData", - OBJECT => $gd_objects, - PM => { "GetData.pm" => "\$(INST_LIBDIR)/GetData.pm" }, - PREREQ_FATAL => 1, - PREREQ_PM => { "Math::Complex" => 1.34 }, - VERSION_FROM => "GetData.pm", - depend => { "perl.mk" => "\${VERSION_FROM}" } -); Modified: trunk/getdata/bindings/perl/Makefile.am =================================================================== --- trunk/getdata/bindings/perl/Makefile.am 2011-08-24 21:06:52 UTC (rev 603) +++ trunk/getdata/bindings/perl/Makefile.am 2011-09-07 21:36:47 UTC (rev 604) @@ -20,6 +20,9 @@ # AUTOMAKE_OPTIONS = foreign +EXTRA_DIST=funclist.pl GetData.xs simple_funcs.pl simple_funcs.xsin typemap \ + GetData.pm.in MANIFEST + if GETDATA_DEBUG DEBUG_C = debug.c TEST_VERBOSE="TEST_VERBOSE=1" @@ -28,40 +31,51 @@ cat $< >> $@ endif -simple_funcs.xs: $(srcdir)/simple_funcs.xsin $(srcdir)/simple_funcs.pl - $(PERL) simple_funcs.pl $< > $@ +lib: + mkdir lib +lib/typemap: $(srcdir)/typemap lib + cat $< > $@ + +lib/simple_funcs.xs: $(srcdir)/simple_funcs.xsin $(srcdir)/simple_funcs.pl lib + $(PERL) $(srcdir)/simple_funcs.pl $< > $@ + make_parameters.sed: ../make_parameters ../../src/getdata.h ../make_parameters P > $@ ../make_parameters: $(srcdir)/../make_parameters.c cd .. && ${MAKE} make_parameters -GetData.pm: $(srcdir)/GetData.pm.in make_parameters.sed funclist.pl \ - GetData.xs simple_funcs.xs +GetData.pm: $(srcdir)/GetData.pm.in make_parameters.sed $(srcdir)/funclist.pl \ + $(srcdir)/GetData.xs lib/simple_funcs.xs rm -f $@ $(SED) -f make_parameters.sed $< | \ - $(PERL) funclist.pl GetData.xs simple_funcs.xs > $@ + $(PERL) $(srcdir)/funclist.pl $(srcdir)/GetData.xs lib/simple_funcs.xs > $@ chmod a-w $@ -all-local: blib/man3/GetData.3pm +all-local: blib/arch/auto/GetData/GetData.so -blib/man3/GetData.3pm: perl.mk $(DEBUG_C) - $(MAKE) -f perl.mk +blib/arch/auto/GetData/GetData.so: Build + $(PERL) $< build -perl.mk: Makefile.PL GetData.pm GetData.xs simple_funcs.xs typemap +.PRECIOUS: Build +Build: Build.PL GetData.pm GetData.xs lib/simple_funcs.xs lib/typemap $(DEBUG_C) perl $< clean-local: - $(MAKE) -f perl.mk clean - rm -f $(BUILT_SOURCES) make_parameters.sed perl.mk.old debug.c + rm -rf lib + if test -e Build; then \ + $(PERL) Build clean; \ + fi + rm -f $(BUILT_SOURCES) make_parameters.sed debug.c MYMETA.yml MYMETA.json GetData.pm + rm -rf Build _build if TEST_PERL check: $(MAKE) test -test testdb: - ${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../src/.libs $(MAKE) -f perl.mk $@ ${TEST_VERBOSE} +test testdb testcover: + ${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../src/.libs $(PERL) ./Build $@ -.PHONY: test +.PHONY: test testdb testcover endif Modified: trunk/getdata/bindings/perl/simple_funcs.pl =================================================================== --- trunk/getdata/bindings/perl/simple_funcs.pl 2011-08-24 21:06:52 UTC (rev 603) +++ trunk/getdata/bindings/perl/simple_funcs.pl 2011-09-07 21:36:47 UTC (rev 604) @@ -64,8 +64,6 @@ } } -print "# This code is automatically generated. Changes made here will be lost.\n\n"; - while (<>) { chomp; until (/\)/) { Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-08-24 21:06:52 UTC (rev 603) +++ trunk/getdata/configure.ac 2011-09-07 21:36:47 UTC (rev 604) @@ -821,7 +821,7 @@ AC_CONFIG_FILES([bindings/idl/makedlm.sh]) AC_CONFIG_FILES([bindings/idl/test/Makefile]) AC_CONFIG_FILES([bindings/perl/Makefile]) -AC_CONFIG_FILES([bindings/perl/Makefile.PL]) +AC_CONFIG_FILES([bindings/perl/Build.PL]) AC_CONFIG_FILES([bindings/python/Makefile]) AC_CONFIG_FILES([bindings/python/test/Makefile]) AC_CONFIG_FILES([doc/Makefile]) Modified: trunk/getdata/m4/perl.m4 =================================================================== --- trunk/getdata/m4/perl.m4 2011-08-24 21:06:52 UTC (rev 603) +++ trunk/getdata/m4/perl.m4 2011-09-07 21:36:47 UTC (rev 604) @@ -141,11 +141,11 @@ if test "x${have_perl}" != "xno"; then GD_PERL_CHECK_MODULE([Math::Complex]) - GD_PERL_CHECK_MODULE([ExtUtils::MakeMaker]) + GD_PERL_CHECK_MODULE([Module::Build]) GD_PERL_CHECK_MODULE([Test::Harness]) fi -if test "$HAVE_Math__Complex$HAVE_ExtUtils__MakeMaker" != "yesyes"; then +if test "$HAVE_Math__Complex$HAVE_Module__Build" != "yesyes"; then have_perl=no fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-24 21:06:58
|
Revision: 603 http://getdata.svn.sourceforge.net/getdata/?rev=603&view=rev Author: ketiltrout Date: 2011-08-24 21:06:52 +0000 (Wed, 24 Aug 2011) Log Message: ----------- Fix tests for Math::Complex. Modified Paths: -------------- trunk/getdata/bindings/perl/t/big_test.t Modified: trunk/getdata/bindings/perl/t/big_test.t =================================================================== --- trunk/getdata/bindings/perl/t/big_test.t 2011-08-23 23:11:47 UTC (rev 602) +++ trunk/getdata/bindings/perl/t/big_test.t 2011-08-24 21:06:52 UTC (rev 603) @@ -27,6 +27,15 @@ my $ne = 0; my ($s, @a, %h); +sub isn { + cmp_ok ( + (defined $_[0]) ? $_[0] : "undef", + (defined $_[0] and defined $_[1]) ? '==' : 'eq', + (defined $_[1]) ? $_[1] : "undef", $_[2] . " = " . + ((defined $_[0]) ? $_[0] : "undef") . ", expected " . + ((defined $_[1]) ? $_[1] : "undef")); +} + sub CheckError { my $e = $_->error; print "\n"; @@ -47,8 +56,7 @@ is ($#{$_[1]}, $#_ - 2, "a[$_[0]]: " . (1 + $#{$_[1]}) . " elements, expected " . ($#_ - 1)); for $i (0 .. $#_ - 2) { - is (${$_[1]}[$i], $_[$i + 2], - "a($i)[$_[0]] = ${$_[1]}[$i], expected " . $_[$i + 2]); + isn (${$_[1]}[$i], $_[$i + 2], "a($i)[$_[0]]"); } print "\n"; } @@ -59,9 +67,7 @@ is ($#{$_[2]}, $#_ - 3, "a[$_[0],$_[1]]: " . (1 + $#{$_[2]}) . " elements, expected " . ($#_ - 2)); for $i (0 .. $#_ - 3) { - is (${$_[2]}[$i], $_[$i + 3], "a($i)[$_[0],$_[1]] = " . - ((defined ${$_[2]}[$i]) ? ${$_[2]}[$i] : "undef") . ", expected " . - ((defined $_[$i + 3]) ? $_[$i + 3] : "undef") . "\n"); + isn (${$_[2]}[$i], $_[$i + 3], "a($i)[$_[0],$_[1]]" ); } print "\n"; } @@ -88,18 +94,9 @@ } } -sub CheckNum { - is ($_[1], $_[2], "n[$_[0]] = " . - ((defined $_[1]) ? $_[1] : "undef") . ", expected " . - ((defined $_[2]) ? $_[2] : "undef")); -} +sub CheckNum { isn ($_[1], $_[2], "n[$_[0]]"); } +sub CheckNum2 { isn ($_[2], $_[3], "n[$_[0],$_[1]]"); } -sub CheckNum2 { - is ($_[2], $_[3], "n[$_[0],$_[1]] = " . - ((defined $_[2]) ? $_[2] : "undef") . ", expected " . - ((defined $_[3]) ? $_[3] : "undef")); -} - sub CheckString { is ($_[1], $_[2], "s[$_[0]] = \"$_[1]\", expected \"$_[2]\""); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-23 23:11:52
|
Revision: 602 http://getdata.svn.sourceforge.net/getdata/?rev=602&view=rev Author: ketiltrout Date: 2011-08-23 23:11:47 +0000 (Tue, 23 Aug 2011) Log Message: ----------- ablaut Modified Paths: -------------- trunk/getdata/m4/perl.m4 Modified: trunk/getdata/m4/perl.m4 =================================================================== --- trunk/getdata/m4/perl.m4 2011-08-23 22:14:53 UTC (rev 601) +++ trunk/getdata/m4/perl.m4 2011-08-23 23:11:47 UTC (rev 602) @@ -142,7 +142,7 @@ if test "x${have_perl}" != "xno"; then GD_PERL_CHECK_MODULE([Math::Complex]) GD_PERL_CHECK_MODULE([ExtUtils::MakeMaker]) - GD_PERL_CHECK_MODULE([Tost::Harness]) + GD_PERL_CHECK_MODULE([Test::Harness]) fi if test "$HAVE_Math__Complex$HAVE_ExtUtils__MakeMaker" != "yesyes"; then This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-23 22:15:01
|
Revision: 601 http://getdata.svn.sourceforge.net/getdata/?rev=601&view=rev Author: ketiltrout Date: 2011-08-23 22:14:53 +0000 (Tue, 23 Aug 2011) Log Message: ----------- More perl config fixes. Modified Paths: -------------- trunk/getdata/bindings/perl/Makefile.am trunk/getdata/configure.ac trunk/getdata/m4/perl.m4 Modified: trunk/getdata/bindings/perl/Makefile.am =================================================================== --- trunk/getdata/bindings/perl/Makefile.am 2011-08-23 17:08:28 UTC (rev 600) +++ trunk/getdata/bindings/perl/Makefile.am 2011-08-23 22:14:53 UTC (rev 601) @@ -56,6 +56,7 @@ $(MAKE) -f perl.mk clean rm -f $(BUILT_SOURCES) make_parameters.sed perl.mk.old debug.c +if TEST_PERL check: $(MAKE) test @@ -63,3 +64,4 @@ ${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../src/.libs $(MAKE) -f perl.mk $@ ${TEST_VERBOSE} .PHONY: test +endif Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-08-23 17:08:28 UTC (rev 600) +++ trunk/getdata/configure.ac 2011-08-23 22:14:53 UTC (rev 601) @@ -778,7 +778,7 @@ echo "*** Configuring Perl bindings" echo GD_PERL - if test "x$have_perl" != "xyes"; then + if test "x$have_perl" = "xno"; then make_perlbindings=no fi fi @@ -862,6 +862,7 @@ AM_CONDITIONAL(USE_MODULES, [test "x$use_modules" != "xno"]) AM_CONDITIONAL(TEST_PYTHON, [test "x$NO_DLOPEN_TESTS" = "x0"]) AM_CONDITIONAL(TEST_IDL, [test "x$NO_DLOPEN_TESTS" = "x0"]) +AM_CONDITIONAL(TEST_PERL, [test "x$HAVE_Test__Harness" = "xyes"]) AM_CONDITIONAL(HAVE_DIFF, [test "x$DIFF" != "x"]) AM_CONDITIONAL(GDIDL_EXTERNAL, [false]) Modified: trunk/getdata/m4/perl.m4 =================================================================== --- trunk/getdata/m4/perl.m4 2011-08-23 17:08:28 UTC (rev 600) +++ trunk/getdata/m4/perl.m4 2011-08-23 22:14:53 UTC (rev 601) @@ -142,10 +142,10 @@ if test "x${have_perl}" != "xno"; then GD_PERL_CHECK_MODULE([Math::Complex]) GD_PERL_CHECK_MODULE([ExtUtils::MakeMaker]) - GD_PERL_CHECK_MODULE([Test::Harness]) + GD_PERL_CHECK_MODULE([Tost::Harness]) fi -if test "$HAVE_MATH__COMPLEX$HAVE_EXTUTILS__MAKEMAKER" != "yesyes"; then +if test "$HAVE_Math__Complex$HAVE_ExtUtils__MakeMaker" != "yesyes"; then have_perl=no fi This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-23 17:08:35
|
Revision: 600 http://getdata.svn.sourceforge.net/getdata/?rev=600&view=rev Author: ketiltrout Date: 2011-08-23 17:08:28 +0000 (Tue, 23 Aug 2011) Log Message: ----------- Make the new path rigmarole work with the MSVCRT. Third parties moving stuff around will still confuse us here more than it would on a POSIX system, but we're at least protected from the caller confusing us with chdir(). A few other minor things. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/configure.ac trunk/getdata/src/bzip.c trunk/getdata/src/close.c trunk/getdata/src/common.c trunk/getdata/src/compat.c trunk/getdata/src/errors.c trunk/getdata/src/internal.h trunk/getdata/src/open.c trunk/getdata/test/error_error.c trunk/getdata/test/test.h Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/ChangeLog 2011-08-23 17:08:28 UTC (rev 600) @@ -1,3 +1,41 @@ +2011-08-23 D. V. Wiebe <ge...@ke...> svn:600 + * test/error_error.c: Simplify test. + * test/test.h (CHECKSp): Added. + + * src/errors.c src/internal.h: Added GD_E_CREAT_OPEN. + * src/open.c (_GD_CreateDirfile): Distinguish GD_E_CREAT_DIR from + GD_E_CREAT_OPEN. + + * src/internal.h: When linking to the MSVCRT, define GD_NO_DIR_OPEN to + indicate that the MSVCRT's open() prohibits openind directories. (This is + referred to as "the non-POSIX case". + * src/open.c (_GD_CreateDirfile): Take dirfile, a malloc'd copy instead of + filedir itself. In the non-POSIX case, this has the full pathname. Also, + handle non-POSIX computation of dirfd. + * src/open.c (gd_cbopen): In the non-POSIX case, prepend the CWD to filedir + if it's not absolute, and pass that string to _GD_CreateDirfile. Also need + to stat the directory in this case, in lieu of trying to open it. + * src/close.c (_GD_ShutdownDirfile): Don't try to close the dirfds in the + non-POSIX case. + * src/common.c (_GD_DirName): In the non-POSIX case, the dirfd parameter + simply contains the index into the dir array, so no need to search. + * src/common.c (_GD_GrabDir _GD_ReleaseDir): In the non-POSIX case, don't + try to open or close the directory: it just contains the index into dir, so + no need to search for it either. + + * src/compat.c (gd_OpenAt): Or flags with O_BINARY for operation on Win32. + + * src/open.c (gd_cbopen): Close dirfd on error. + + * src/bzip.c (_GD_Bzip2Seek): Return -1 on error. + + * src/internal.h (_GD_AbsPath): Added. + + * src/internal.h (gd_swap64): Fix doubled backslashes. + + * configure.ac: Fix perl check to properly exclude the bindings when + necessary. + 2011-08-20 D. V. Wiebe <ge...@ke...> svn:599 * src/open.c (gd_cbopen): Properly initialise bname; also check for malloc errors. Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/configure.ac 2011-08-23 17:08:28 UTC (rev 600) @@ -660,7 +660,7 @@ echo AC_CHECK_FUNCS([_chsize _chsize_s _commit fchmod _fdopen fdopendir fseeko \ fseeko64 _fstat fstat64 _fstat64 fstatat fstatat64 fsync \ - ftello ftello64 ftruncate ftruncate64 getcwd _getcwd getdelim \ + ftello ftello64 ftruncate ftruncate64 _getcwd getdelim \ gmtime_r _lseeki64 lstat _mkdir nan _open openat _read \ renameat _rmdir _snprintf stat64 _stat64 _strtoi64 strtoll \ _strtoui64 strtoull _unlink unlinkat _write]) @@ -778,6 +778,9 @@ echo "*** Configuring Perl bindings" echo GD_PERL + if test "x$have_perl" != "xyes"; then + make_perlbindings=no + fi fi dnl external encodings Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/bzip.c 2011-08-23 17:08:28 UTC (rev 600) @@ -135,8 +135,8 @@ if (ptr->bzfile == NULL || ptr->bzerror != BZ_OK) { fclose(ptr->stream); - dreturn("%i", 1); - return 1; + dreturn("%i", -1); + return -1; } ptr->pos = ptr->end = 0; ptr->base = ptr->stream_end = 0; Modified: trunk/getdata/src/close.c =================================================================== --- trunk/getdata/src/close.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/close.c 2011-08-23 17:08:28 UTC (rev 600) @@ -93,9 +93,11 @@ return -1; } +#ifndef GD_NO_DIR_OPEN /* close the directory */ for (i = 0; i < (unsigned int)D->ndir; ++i) close(D->dir[i].fd); +#endif _GD_FreeD(D); Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/common.c 2011-08-23 17:08:28 UTC (rev 600) @@ -893,15 +893,25 @@ const char *_GD_DirName(const DIRFILE *D, int dirfd) { +#ifndef GD_NO_DIR_OPEN unsigned int i; +#endif dtrace("%p, %i", D, dirfd); +#ifdef GD_NO_DIR_OPEN + /* in the non-POSIX case, dirfd is just the index in the dir list */ + if (D->ndir > 0) { + dreturn("\"%s\"", D->dir[dirfd].path); + return D->dir[dirfd].path; + } +#else for (i = 0; i < D->ndir; ++i) if (dirfd == D->dir[i].fd) { dreturn("\"%s\"", D->dir[i].path); return D->dir[i].path; } +#endif /* we only get here in the early stages of opening a dirfile */ dreturn("%p", D->name); @@ -937,13 +947,7 @@ unsigned int i; char *path, *dir = NULL; void *ptr; - int abs = ( -#if defined _WIN32 || defined _WIN64 - name[0] != '\0' && name[1] == ':' -#else - name[0] == '/' -#endif - ); + int abs = _GD_AbsPath(name); dtrace("%p, %i, \"%s\"", D, dirfd, name); @@ -989,6 +993,10 @@ return -1; } +#ifdef GD_NO_DIR_OPEN + D->dir[D->ndir].fd = D->ndir; + free(path); +#else if (abs) { D->dir[D->ndir].fd = open(dir, O_RDONLY); } else { @@ -1009,6 +1017,7 @@ dreturn("%i", -1); return -1; } +#endif D->ndir++; dreturn("%i", D->dir[D->ndir - 1].fd); @@ -1017,10 +1026,18 @@ void _GD_ReleaseDir(DIRFILE *D, int dirfd) { +#ifndef GD_NO_DIR_OPEN unsigned int i; +#endif dtrace("%p, %i", D, dirfd); +#ifdef GD_NO_DIR_OPEN + if (--D->dir[dirfd].rc == 0) { + free(D->dir[dirfd].path); + D->dir[dirfd] = D->dir[--D->ndir]; + } +#else for (i = 0; i < D->ndir; ++i) if (D->dir[i].fd == dirfd) { if (--D->dir[i].rc == 0) { @@ -1030,6 +1047,7 @@ } break; } +#endif dreturnvoid(); } Modified: trunk/getdata/src/compat.c =================================================================== --- trunk/getdata/src/compat.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/compat.c 2011-08-23 17:08:28 UTC (rev 600) @@ -63,7 +63,7 @@ dtrace("%p, %i, \"%s\", %x, 0%o", D, dirfd, name, flags, mode); path = _GD_MakeFullPath(D, dirfd, name); - ret = open(path, flags, mode); + ret = open(path, flags | O_BINARY, mode); free(path); dreturn("%i", ret); @@ -169,6 +169,7 @@ ptr = strerror(errnum); strncpy(buf, ptr, buflen); + dreturn("%i", 0); return 0; } #endif Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/errors.c 2011-08-23 17:08:28 UTC (rev 600) @@ -80,6 +80,7 @@ { GD_E_TRUNC, 0, "Error truncating {2}: ", 1 }, /* GD_E_CREAT: 1 = suberror, 2 = filename, 3 = errno */ { GD_E_CREAT, GD_E_CREAT_DIR, "Unable to create directory {2}: ", 1 }, + { GD_E_CREAT, GD_E_CREAT_OPEN, "Unable to open directory {2}: ", 1 }, { GD_E_CREAT, GD_E_CREAT_FORMAT, "Unable to create format file {2}: ", 1 }, { GD_E_CREAT, GD_E_CREAT_EXCL, "Unable to create dirfile {2}: already exists", 0 }, Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/internal.h 2011-08-23 17:08:28 UTC (rev 600) @@ -47,12 +47,16 @@ #ifdef _MSC_VER -// missing in sys/stat.h +/* missing in sys/stat.h */ #define S_ISREG(m) (((m) & _S_IFMT) == _S_IFREG) #define S_ISDIR(m) (((m) & _S_IFMT) == _S_IFDIR) -#define snprintf _snprintf #endif +/* the open() in the MSVCRT doesn't permit open()ing directories */ +#ifdef __MSVCRT__ +#define GD_NO_DIR_OPEN +#endif + #ifdef __APPLE__ typedef off_t off64_t; #endif @@ -211,6 +215,16 @@ # endif #endif +#ifdef HAVE__GETCWD +# define gd_getcwd _getcwd +#else +# define gd_getcwd getcwd +#endif + +#ifdef HAVE__SNPRINTF +# define snprintf _snprintf +#endif + #ifndef HAVE_FTELLO64 # ifndef HAVE_FTELLO # define ftello64 (off64_t)ftell @@ -410,16 +424,22 @@ (((uint32_t)(x) >> 8) & 0xff00UL) | \ ((uint32_t)(x) >> 24)) #define gd_swap64(x) ( \ - (((uint64_t)(x) << 56) | \\ - (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \\ - (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \\ - (((uint64_t)(x) << 8) & 0xff00000000ULL) | \\ - (((uint64_t)(x) >> 8) & 0xff000000ULL) | \\ - (((uint64_t)(x) >> 24) & 0xff0000ULL) | \\ - (((uint64_t)(x) >> 40) & 0xff00ULL) | \\ - ((uint64_t)(x) >> 56)) + (((uint64_t)(x) << 56) | \ + (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \ + (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \ + (((uint64_t)(x) << 8) & 0xff00000000ULL) | \ + (((uint64_t)(x) >> 8) & 0xff000000ULL) | \ + (((uint64_t)(x) >> 24) & 0xff0000ULL) | \ + (((uint64_t)(x) >> 40) & 0xff00ULL) | \ + ((uint64_t)(x) >> 56))) #endif +/* returns true if s is an absolute path */ +#if defined _WIN32 || defined _WIN64 +# define _GD_AbsPath(s) ((s)[0] != '\0' && (s)[1] == ':') +#else +# define _GD_AbsPath(s) ((s)[0] == '/') +#endif /* maximum number of recursions */ #define GD_MAX_RECURSE_LEVEL 32 @@ -438,6 +458,7 @@ #define GD_E_CREAT_FORMAT 1 #define GD_E_CREAT_EXCL 2 #define GD_E_CREAT_DIR 3 +#define GD_E_CREAT_OPEN 4 /* GD_E_FORMAT suberrors are in getdata.h */ Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/src/open.c 2011-08-23 17:08:28 UTC (rev 600) @@ -41,7 +41,7 @@ /* attempt to open or create a new dirfile - set error appropriately */ static FILE* _GD_CreateDirfile(DIRFILE* D, int dirfd, int dir_error, - const char* filedir) + char* dirfile) { struct stat statbuf; DIR* dir; @@ -50,7 +50,7 @@ int format_error = 0; FILE* fp = NULL; - dtrace("%p, %i, %i, \"%s\"", D, dirfd, dir_error, filedir); + dtrace("%p, %i, %i, \"%s\"", D, dirfd, dir_error, dirfile); /* naively try to open the format file */ if (dirfd < 0) @@ -59,11 +59,14 @@ { format_error = errno; + /* in the non-POSIX case, this has already been done. */ +#ifndef GD_NO_DIR_OPEN /* open failed, try to stat the directory itself */ if (fstat(dirfd, &statbuf)) dir_error = errno; else if (!S_ISDIR(statbuf.st_mode)) dir_error = ENOTDIR; +#endif } else dir_error = 0; @@ -71,9 +74,10 @@ /* unable to read the format file */ if (format_error == EACCES || dir_error == EACCES) { - char *format_file = (char *)malloc(strlen(filedir) + 8); - strcat(strcpy(format_file, filedir), "/format"); + char *format_file = (char *)malloc(strlen(dirfile) + 8); + strcat(strcpy(format_file, dirfile), "/format"); _GD_SetError(D, GD_E_OPEN, GD_E_OPEN_NO_ACCESS, format_file, 0, NULL); + free(dirfile); free(format_file); dreturn("%p", NULL); return NULL; @@ -82,22 +86,25 @@ /* the directory exists, but it's not a dirfile, do nothing else -- even if we * were asked to truncate it */ if (!dir_error && format_error) { - _GD_SetError(D, GD_E_OPEN, GD_E_OPEN_NOT_DIRFILE, filedir, 0, NULL); + _GD_SetError(D, GD_E_OPEN, GD_E_OPEN_NOT_DIRFILE, dirfile, 0, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } /* Couldn't open the file, and we weren't asked to create it */ if (format_error && !(D->flags & GD_CREAT)) { - _GD_SetError(D, GD_E_OPEN, GD_E_OPEN_NOT_EXIST, filedir, format_error, + _GD_SetError(D, GD_E_OPEN, GD_E_OPEN_NOT_EXIST, dirfile, format_error, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } /* It does exist, but we were asked to exclusively create it */ if (!format_error && (D->flags & GD_CREAT) && (D->flags & GD_EXCL)) { - _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_EXCL, filedir, 0, NULL); + _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_EXCL, dirfile, 0, NULL); + free(dirfile); close(fd); dreturn("%p", NULL); return NULL; @@ -105,7 +112,7 @@ /* If we made it here we either: * 1) have no such directory, but plan to create it, or - * 2) have a dirfile, which means the directory supplied contains a readable + * 2) have a "dirfile", i.e. the directory supplied contains a readable * file called format */ /* Truncate, if needed -- dangerous! Truncating a dirfile deletes every @@ -120,6 +127,7 @@ /* can't truncate a read-only dirfile */ if ((D->flags & GD_ACCMODE) == GD_RDONLY) { _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } @@ -127,27 +135,30 @@ #ifdef HAVE_FDOPENDIR /* crawl the directory, and delete everything */ if ((fd = dup(dirfd)) == -1) { - _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_DIR, filedir, errno, NULL); + _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_DIR, dirfile, errno, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } dir = fdopendir(fd); #else - dir = opendir(filedir); + dir = opendir(dirfile); #endif if (dir == NULL) { - _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_DIR, filedir, errno, NULL); + _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_DIR, dirfile, errno, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } while ((lamb = readdir(dir)) != NULL) { if (gd_StatAt(D, dirfd, lamb->d_name, &statbuf, AT_SYMLINK_NOFOLLOW)) { - char *name = (char *)malloc(strlen(filedir) + strlen(lamb->d_name) + 2); - strcat(strcat(strcpy(name, filedir), "/"), lamb->d_name); + char *name = (char *)malloc(strlen(dirfile) + strlen(lamb->d_name) + 2); + strcat(strcat(strcpy(name, dirfile), "/"), lamb->d_name); _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_STAT, name, errno, NULL); + free(dirfile); free(name); closedir(dir); dreturn("%p", NULL); @@ -162,10 +173,11 @@ ) { if (gd_UnlinkAt(D, dirfd, lamb->d_name, 0)) { - char *name = (char *)malloc(strlen(filedir) + strlen(lamb->d_name) + char *name = (char *)malloc(strlen(dirfile) + strlen(lamb->d_name) + 2); - strcat(strcat(strcpy(name, filedir), "/"), lamb->d_name); + strcat(strcat(strcpy(name, dirfile), "/"), lamb->d_name); _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_UNLINK, name, errno, NULL); + free(dirfile); free(name); closedir(dir); dreturn("%p", NULL); @@ -183,32 +195,42 @@ /* can't create a read-only dirfile */ if ((D->flags & GD_ACCMODE) == GD_RDONLY) { _GD_SetError(D, GD_E_ACCMODE, 0, NULL, 0, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } /* attempt to create the dirfile directory, if not present */ if (dir_error) { - if (mkdir(filedir, 00777) < 0) { - _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_DIR, filedir, errno, NULL); + if (mkdir(dirfile, 0777) < 0) { + _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_DIR, dirfile, errno, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } - if ((dirfd = open(filedir, O_RDONLY)) < 0) { - _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_DIR, filedir, errno, NULL); +#ifdef GD_NO_DIR_OPEN + /* in the non-POSIX situation, dirfd just holds the index in the + * directory entry */ + dirfd = 0; +#else + if ((dirfd = open(dirfile, O_RDONLY)) < 0) { + _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_OPEN, dirfile, errno, NULL); + free(dirfile); dreturn("%p", NULL); return NULL; } +#endif } /* create a new, empty format file */ if ((fd = gd_OpenAt(D, dirfd, "format", O_CREAT | O_EXCL | O_BINARY, 0666)) < 0) { - char *format_file = (char *)malloc(strlen(filedir) + 8); - strcat(strcpy(format_file, filedir), "/format"); + char *format_file = (char *)malloc(strlen(dirfile) + 8); + strcat(strcpy(format_file, dirfile), "/format"); _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_FORMAT, format_file, errno, NULL); + free(dirfile); free(format_file); dreturn("%p", NULL); return NULL; @@ -221,9 +243,10 @@ /* associate a stream with the format file */ if ((fp = fdopen(fd, "r")) == NULL) { - char *format_file = (char *)malloc(strlen(filedir) + 8); - strcat(strcpy(format_file, filedir), "/format"); + char *format_file = (char *)malloc(strlen(dirfile) + 8); + strcat(strcpy(format_file, dirfile), "/format"); _GD_SetError(D, GD_E_CREAT, GD_E_CREAT_FORMAT, format_file, errno, NULL); + free(dirfile); free(format_file); close(fd); dreturn("%p", NULL); @@ -234,13 +257,7 @@ D->dir = (struct gd_dir_t *)malloc(sizeof(struct gd_dir_t)); D->dir[0].fd = dirfd; D->dir[0].rc = 1; - D->dir[0].path = strdup(filedir); - if (D->dir[0].path == NULL) { - _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); - fclose(fp); - dreturn("%p", NULL); - return NULL; - } + D->dir[0].path = dirfile; D->ndir = 1; dreturn("%p", fp); @@ -280,23 +297,64 @@ gd_parser_callback_t sehandler, void* extra) { FILE *fp; - char* ref_name; + char *ref_name; + char *dirfile; DIRFILE* D; gd_entry_t* E; - int dirfd, dirfd_error; + int dirfd = -1, dirfd_error = 0; +#ifdef GD_NO_DIR_OPEN + gd_stat64_t statbuf; +#endif + dtrace("\"%s\", 0x%lx, %p, %p", filedir, (unsigned long)flags, sehandler, extra); +#ifdef GD_NO_DIR_OPEN + /* if we can't cache directory descriptors, we just have to remember paths, + * so get the current directory, so that we're protected against the caller + * using chdir. + */ + + /* get a full path, if necessary */ + if (_GD_AbsPath(filedir)) + dirfile = strdup(filedir); + else { + dirfile = gd_getcwd(NULL, 0); + if (dirfile) { + char *ptr = realloc(dirfile, strlen(dirfile) + strlen(filedir) + 2); + if (ptr == NULL) { + free(dirfile); + dirfile = NULL; + } else + dirfile = strcat(strcat(ptr, "/"), filedir); + } + } + + /* that done, now stat the path to see if it exists (and is a directory) */ + if (dirfile) { + if (gd_stat64(dirfile, &statbuf)) + dirfd_error = errno; + else if (!S_ISDIR(statbuf.st_mode)) + dirfd_error = ENOTDIR; + else + dirfd = 0; + } +#else /* quickly, before it goes away, grab the directory (if it exists) */ dirfd = open(filedir, O_RDONLY); dirfd_error = errno; + dirfile = strdup(filedir); +#endif _GD_InitialiseFramework(); D = (DIRFILE *)malloc(sizeof(DIRFILE)); if (D == NULL) { + free(dirfile); +#ifndef GD_NO_DIR_OPEN close(dirfd); +#endif dreturn("%p", NULL); return NULL; } @@ -312,7 +370,7 @@ D->sehandler_extra = extra; D->standards = GD_DIRFILE_STANDARDS_VERSION; - if (D->name == NULL) { + if (D->name == NULL || dirfile == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); dreturn("%p", D); return D; @@ -322,26 +380,30 @@ D->n_entries = 1; D->entry = (gd_entry_t **)malloc(sizeof(gd_entry_t*)); - if (D->entry == NULL) { + if (D->entry) + D->entry[0] = (gd_entry_t *)malloc(sizeof(gd_entry_t)); + + if (D->entry == NULL || D->entry[0] == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + free(dirfile); +#ifndef GD_NO_DIR_OPEN + close(dirfd); +#endif dreturn("%p", D); return D; } - D->entry[0] = (gd_entry_t *)malloc(sizeof(gd_entry_t)); - if (D->entry == NULL) { - _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); - dreturn("%p", D); - return D; - } memset(D->entry[0], 0, sizeof(gd_entry_t)); - D->entry[0]->field_type = GD_INDEX_ENTRY; D->entry[0]->e = (struct _gd_private_entry *)malloc(sizeof(struct _gd_private_entry)); D->entry[0]->field = strdup("INDEX"); if (D->entry[0]->field == NULL || D->entry[0]->e == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + free(dirfile); +#ifndef GD_NO_DIR_OPEN + close(dirfd); +#endif dreturn("%p", D); return D; } @@ -349,7 +411,10 @@ D->entry[0]->e->calculated = 1; /* open the format file (or create it) */ - if ((fp = _GD_CreateDirfile(D, dirfd, dirfd_error, filedir)) == NULL) { + if ((fp = _GD_CreateDirfile(D, dirfd, dirfd_error, dirfile)) == NULL) { +#ifndef GD_NO_DIR_OPEN + close(dirfd); +#endif dreturn("%p", D); return D; /* errors have already been set */ } Modified: trunk/getdata/test/error_error.c =================================================================== --- trunk/getdata/test/error_error.c 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/test/error_error.c 2011-08-23 17:08:28 UTC (rev 600) @@ -34,7 +34,7 @@ gd_close(D); CHECKI(error, GD_E_OPEN); - CHECKS(string, "Dirfile does not exist: a non_existant dirfile"); + CHECKSp(string, "Dirfile does not exist"); return r; } Modified: trunk/getdata/test/test.h =================================================================== --- trunk/getdata/test/test.h 2011-08-20 21:38:14 UTC (rev 599) +++ trunk/getdata/test/test.h 2011-08-23 17:08:28 UTC (rev 600) @@ -87,6 +87,8 @@ #define CHECKPNi(i,n) CHECKi(i,(n) == NULL,n,"%p","%s",n,"non-NULL") #define CHECKS(n,v) CHECK(strcmp((n),(v)),n,"\"%s\"","\"%s\"",(n),(v)); #define CHECKSi(n,v) CHECKi(i,strcmp((n),(v)),n,"\"%s\"","\"%s\"",(n),(v)); +#define CHECKSp(n,v) CHECK(strncmp((n),(v), sizeof(v) - 1),n,"\"%s\"",\ + "\"%s\"",(n),(v)); #define CHECKU(n,v) CHECK((n) != (v),n,"%llu","%llu",\ (unsigned long long)(n),(unsigned long long)(v)) #define CHECKUi(i,n,v) CHECKi(i,(n) != (v),n,"%llu","%llu",\ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-20 21:38:20
|
Revision: 599 http://getdata.svn.sourceforge.net/getdata/?rev=599&view=rev Author: ketiltrout Date: 2011-08-20 21:38:14 +0000 (Sat, 20 Aug 2011) Log Message: ----------- Update the current SIE record at the end of a write. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/src/open.c trunk/getdata/src/sie.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-08-20 21:35:02 UTC (rev 598) +++ trunk/getdata/ChangeLog 2011-08-20 21:38:14 UTC (rev 599) @@ -1,3 +1,9 @@ +2011-08-20 D. V. Wiebe <ge...@ke...> svn:599 + * src/open.c (gd_cbopen): Properly initialise bname; also check for malloc + errors. + * sie/sie.c (_GD_SampIndWrite): Update the current record to reflect the + updated position of the file pointer. + 2011-08-20 D. V. Wiebe <ge...@ke...> svn:597 * src/internal.h: Added bname to fragment struct holding the basename of the file. Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-08-20 21:35:02 UTC (rev 598) +++ trunk/getdata/src/open.c 2011-08-20 21:38:14 UTC (rev 599) @@ -364,8 +364,13 @@ return D; } D->fragment[0].cname = malloc(strlen(filedir) + 8); + D->fragment[0].bname = strdup("format"); + if (D->fragment[0].cname == NULL || D->fragment[0].bname == NULL) { + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%p", D); + return D; + } strcat(strcpy(D->fragment[0].cname, filedir), "/format"); - D->fragment[0].bname = "format"; D->fragment[0].sname = NULL; /* The root format file needs no external name */ D->fragment[0].ename = NULL; Modified: trunk/getdata/src/sie.c =================================================================== --- trunk/getdata/src/sie.c 2011-08-20 21:35:02 UTC (rev 598) +++ trunk/getdata/src/sie.c 2011-08-20 21:38:14 UTC (rev 599) @@ -322,7 +322,7 @@ dreturn("%i", -1); return -1; } - p2 = p; + p = p2; } *cur_end = f->p + i - 1; cur_end = (int64_t*)((char*)p + size * rin); @@ -396,12 +396,19 @@ dreturn("%i", -1); return -1; } - free(p); /* truncate the file if necessary */ if (rin < rout) gd_truncate(fileno(f->fp), nrec - rout + rin); + /* update the current record */ + memcpy(f->d, (char *)p + (rin - 1) * size, size); + f->s = f->d[0]; + f->p = f->d[0] + 1; + f->r = fr + rin - 1; + + free(p); + dreturn("%llu", (unsigned long long)nelem); return nelem; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-20 21:35:08
|
Revision: 598 http://getdata.svn.sourceforge.net/getdata/?rev=598&view=rev Author: ketiltrout Date: 2011-08-20 21:35:02 +0000 (Sat, 20 Aug 2011) Log Message: ----------- Changelog Modified Paths: -------------- trunk/getdata/ChangeLog Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-08-20 08:43:25 UTC (rev 597) +++ trunk/getdata/ChangeLog 2011-08-20 21:35:02 UTC (rev 598) @@ -1,3 +1,11 @@ +2011-08-20 D. V. Wiebe <ge...@ke...> svn:597 + * src/internal.h: Added bname to fragment struct holding the basename of the + file. + * src/open.c (gd_cbopen) src/include.c (_GD_Include): Initialise + fragment->bname. + * src/close.c (_GD_FreeD) src/include.c (gd_uninclude): Deallocate + fragment->bname. + 2011-08-19 D. V. Wiebe <ge...@ke...> svn:596 * src/open.c (gd_invalid_dirfile gd_cbopen): If allocating the DIRFILE itself fails, return NULL instead of segfaulting. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-20 08:43:31
|
Revision: 597 http://getdata.svn.sourceforge.net/getdata/?rev=597&view=rev Author: ketiltrout Date: 2011-08-20 08:43:25 +0000 (Sat, 20 Aug 2011) Log Message: ----------- Get gd_uninclude to work with unlinkat. Modified Paths: -------------- trunk/getdata/src/close.c trunk/getdata/src/include.c trunk/getdata/src/internal.h trunk/getdata/src/open.c Modified: trunk/getdata/src/close.c =================================================================== --- trunk/getdata/src/close.c 2011-08-19 01:27:46 UTC (rev 596) +++ trunk/getdata/src/close.c 2011-08-20 08:43:25 UTC (rev 597) @@ -37,6 +37,7 @@ _GD_FreeE(D, D->entry[i], 1); for (j = 0; j < D->n_fragment; ++j) { + free(D->fragment[j].bname); free(D->fragment[j].cname); free(D->fragment[j].ename); free(D->fragment[j].ref_name); Modified: trunk/getdata/src/include.c =================================================================== --- trunk/getdata/src/include.c 2011-08-19 01:27:46 UTC (rev 596) +++ trunk/getdata/src/include.c 2011-08-20 08:43:25 UTC (rev 597) @@ -42,7 +42,7 @@ int found = 0; int dirfd = -1; char *temp_buf1, *temp_buf2; - const char *base; + char *base; void *ptr = NULL; FILE* new_fp = NULL; @@ -55,7 +55,13 @@ dreturn("%i", -1); return -1; } - base = basename(temp_buf2); + base = strdup(basename(temp_buf2)); + if (base == NULL) { + free(temp_buf2); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } /* Open the containing directory */ dirfd = _GD_GrabDir(D, D->fragment[me].dirfd, ename); @@ -86,23 +92,22 @@ /* If we found the file, we won't reopen it. Continue parsing. */ if (found) { _GD_ReleaseDir(D, dirfd); + free(base); free(temp_buf1); dreturn("%i", i); return i; } /* Try to open the file */ - temp_buf2 = strdup(temp_buf1); - i = gd_OpenAt(D, dirfd, basename(temp_buf2), - (((D->flags & GD_ACCMODE) == GD_RDWR) ? O_RDWR : O_RDONLY) | - ((*flags & GD_CREAT) ? O_CREAT : 0) | + i = gd_OpenAt(D, dirfd, base, (((D->flags & GD_ACCMODE) == GD_RDWR) ? O_RDWR : + O_RDONLY) | ((*flags & GD_CREAT) ? O_CREAT : 0) | ((*flags & GD_TRUNC) ? O_TRUNC : 0) | ((*flags & GD_EXCL) ? O_EXCL : 0) | O_BINARY, 0666); - free(temp_buf2); if (i < 0) { _GD_SetError(D, GD_E_OPEN_FRAGMENT, errno, format_file, linenum, temp_buf1); + free(base); free(temp_buf1); dreturn("%i", -1); return -1; @@ -113,6 +118,7 @@ /* If opening the file failed, set the error code and abort parsing. */ if (new_fp == NULL) { _GD_SetError(D, GD_E_OPEN_FRAGMENT, errno, format_file, linenum, temp_buf1); + free(base); free(temp_buf1); dreturn("%i", -1); return -1; @@ -123,12 +129,14 @@ if (ptr == NULL) { D->n_fragment--; _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + free(base); free(temp_buf1); dreturn("%i", -1); return -1; } D->fragment = (struct gd_fragment_t *)ptr; + D->fragment[D->n_fragment - 1].bname = base; D->fragment[D->n_fragment - 1].cname = temp_buf1; D->fragment[D->n_fragment - 1].ename = strdup(ename); D->fragment[D->n_fragment - 1].modified = 0; @@ -150,13 +158,13 @@ if (D->fragment[D->n_fragment - 1].ename == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + D->n_fragment--; + free(base); dreturn("%i", -1); return -1; } - /* extract the subdirectory name - dirname both returns a volatile string - * and modifies its argument, ergo strcpy */ - + /* extract the subdirectory name */ D->fragment[D->n_fragment - 1].sname = _GD_DirName(D, dirfd); *ref_name = _GD_ParseFragment(new_fp, D, D->n_fragment - 1, standards, flags); @@ -377,7 +385,7 @@ /* delete the fragments, if requested */ if (del) for (j = 0; j < nf; ++j) - gd_UnlinkAt(D, D->fragment[f[j]].dirfd, D->fragment[f[j]].cname, 0); + gd_UnlinkAt(D, D->fragment[f[j]].dirfd, D->fragment[f[j]].bname, 0); /* delete fields from the fragment -- memory use is not sufficient to warrant * resizing D->entry */ @@ -408,6 +416,7 @@ _GD_ReleaseDir(D, D->fragment[f[j]].dirfd); free(D->fragment[f[j]].cname); free(D->fragment[f[j]].ename); + free(D->fragment[f[j]].bname); free(D->fragment[f[j]].ref_name); memcpy(D->fragment + f[j], D->fragment + D->n_fragment - 1, Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-08-19 01:27:46 UTC (rev 596) +++ trunk/getdata/src/internal.h 2011-08-20 08:43:25 UTC (rev 597) @@ -642,7 +642,9 @@ char* cname; /* Subdirectory name */ const char* sname; - /* External name (relative to the parent format file fragment) */ + /* basename */ + char *bname; + /* External name (the one that appears in the format file) */ char* ename; int modified; int parent; Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-08-19 01:27:46 UTC (rev 596) +++ trunk/getdata/src/open.c 2011-08-20 08:43:25 UTC (rev 597) @@ -365,6 +365,7 @@ } D->fragment[0].cname = malloc(strlen(filedir) + 8); strcat(strcpy(D->fragment[0].cname, filedir), "/format"); + D->fragment[0].bname = "format"; D->fragment[0].sname = NULL; /* The root format file needs no external name */ D->fragment[0].ename = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-19 01:27:54
|
Revision: 596 http://getdata.svn.sourceforge.net/getdata/?rev=596&view=rev Author: ketiltrout Date: 2011-08-19 01:27:46 +0000 (Fri, 19 Aug 2011) Log Message: ----------- Error housekeeping including doc updates. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/man/gd_alter_spec.3 trunk/getdata/man/gd_bof.3 trunk/getdata/man/gd_carray_len.3 trunk/getdata/man/gd_carrays.3 trunk/getdata/man/gd_cbopen.3 trunk/getdata/man/gd_close.3 trunk/getdata/man/gd_constants.3 trunk/getdata/man/gd_entry.3 trunk/getdata/man/gd_entry_type.3 trunk/getdata/man/gd_eof.3 trunk/getdata/man/gd_error_count.3 trunk/getdata/man/gd_error_string.3 trunk/getdata/man/gd_field_list_by_type.3 trunk/getdata/man/gd_flush.3 trunk/getdata/man/gd_fragment_index.3 trunk/getdata/man/gd_framenum_subset.3 trunk/getdata/man/gd_get_carray_slice.3 trunk/getdata/man/gd_get_constant.3 trunk/getdata/man/gd_getdata.3 trunk/getdata/man/gd_include.3 trunk/getdata/man/gd_invalid_dirfile.3 trunk/getdata/man/gd_mcarrays.3 trunk/getdata/man/gd_mconstants.3 trunk/getdata/man/gd_metaflush.3 trunk/getdata/man/gd_mfield_list_by_type.3 trunk/getdata/man/gd_native_type.3 trunk/getdata/man/gd_nfields_by_type.3 trunk/getdata/man/gd_nframes.3 trunk/getdata/man/gd_nmfields_by_type.3 trunk/getdata/man/gd_put_carray_slice.3 trunk/getdata/man/gd_put_constant.3 trunk/getdata/man/gd_put_string.3 trunk/getdata/man/gd_putdata.3 trunk/getdata/man/gd_rename.3 trunk/getdata/man/gd_rewrite_fragment.3 trunk/getdata/man/gd_spf.3 trunk/getdata/man/gd_validate.3 trunk/getdata/man/make_html.pl trunk/getdata/src/encoding.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/include.c trunk/getdata/src/index.c trunk/getdata/src/nmeta.c trunk/getdata/src/open.c trunk/getdata/src/parse.c trunk/getdata/src/sie.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/ChangeLog 2011-08-19 01:27:46 UTC (rev 596) @@ -1,3 +1,27 @@ +2011-08-19 D. V. Wiebe <ge...@ke...> svn:596 + * src/open.c (gd_invalid_dirfile gd_cbopen): If allocating the DIRFILE + itself fails, return NULL instead of segfaulting. + + * src/nmeta.c (gd_nmfields_by_type): Throw GD_E_BAD_ENTRY on encountering + GD_NO_ENTRY. + + * src/index.c (gd_framenum_subset64): Throw GD_E_DIMENSION if the caller + supplies the field code for a scalar. + + * src/errors.c: Added GD_E_BOUNDS and GD_E_LINE_TOO_LONG. + + * src/encoding.c (_GD_ResolveEncoding): Don't segfault on malloc error. + + * src/flimits.c (_GD_GetBOF): Throw GD_INTERNAL_ERROR instead of + GD_E_BAD_FIELD_TYPE when encountering GD_NO_ENTRY. + + * src/parse.c (_GD_UTF8Encode): Renamed from utf8encode for consistency. + + * src/sie.c (_GD_SampIndTUnlink) src/include.c (gd_uninclude): Use + gd_UnlinkAt instead of bare unlink(). + + * man/make_html.pl: Handle multiparagraph .TPs. + 2011-08-11 D. V. Wiebe <ge...@ke...> svn:595 * src/internal.h: In cases where no explicitly 64-bit stat struct can be found, don't bother trying to use explicitly 64-bit stat functions. Modified: trunk/getdata/man/gd_alter_spec.3 =================================================================== --- trunk/getdata/man/gd_alter_spec.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_alter_spec.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_alter_spec.3. The gd_alter_spec man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_alter_spec 3 "21 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_alter_spec 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_alter_spec, gd_malter_spec \(em modify a field in a dirfile .SH SYNOPSIS @@ -64,7 +64,7 @@ and the .I recode argument is non-zero, the look-up table file will be moved if -.IR entry -> table +.I line specifies a different path, overwriting an existing file with the new pathname, if present. If the field specified by .I field_code @@ -152,6 +152,12 @@ A descriptive error string for the last error encountered can be obtained from a call to .BR gd_error_string (3). +.SH BUGS +If a +.B CARRAY +field with more than GD_MAX_CARRAY_LENGTH elements is provided, subsequent +elements will be silently truncated. GD_MAX_CARRAY_LENGTH is 2**24 on 32-bit +systems. It is larger on 64-bit systems. .SH SEE ALSO .BR gd_alter_bit (3), .BR gd_alter_const (3), Modified: trunk/getdata/man/gd_bof.3 =================================================================== --- trunk/getdata/man/gd_bof.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_bof.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_bof.3. The gd_bof man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_bof 3 "15 October 2010" "Version 0.7.0" "GETDATA" +.TH gd_bof 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_bof \(em report the start of data in a field .SH SYNOPSIS @@ -67,6 +67,9 @@ On error, it returns -1 and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -88,6 +91,11 @@ .I field_code itself specified a scalar field. .TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. +.TP .B GD_E_RECURSE_LEVEL Too many levels of recursion were encountered while trying to resolve .IR field_code . Modified: trunk/getdata/man/gd_carray_len.3 =================================================================== --- trunk/getdata/man/gd_carray_len.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_carray_len.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_carray_len.3. The gd_carray_len man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_carray_len 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_carray_len 3 "15 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_carray_len \(em returns the length of a CARRAY field in a dirfile .SH SYNOPSIS @@ -48,6 +48,9 @@ returns the length of the field specified. On error, it returns zero and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code Modified: trunk/getdata/man/gd_carrays.3 =================================================================== --- trunk/getdata/man/gd_carrays.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_carrays.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_carrays.3. The gd_carrays man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_carrays 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_carrays 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_carrays \(em retrieve a list of CARRAY values from a dirfile .SH SYNOPSIS @@ -123,6 +123,11 @@ The .I return_type specified was invalid. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_cbopen.3 =================================================================== --- trunk/getdata/man/gd_cbopen.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_cbopen.3 2011-08-19 01:27:46 UTC (rev 596) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_cbopen 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_cbopen 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_cbopen, gd_open \(em open or create a dirfile .SH SYNOPSIS @@ -74,7 +74,7 @@ .TP .PD .B GD_NOT_ARM_ENDIAN -Specifies that double precision floating point raw data on disk is, or is not, +Specifies that double precision floating point raw data on disk are, or are not, stored in the middle-endian format used by older ARM processors. These flag only set the default endianness, and will be overridden when an @@ -197,7 +197,7 @@ section below for full details. .TP .B GD_PRETTY_PRINT -When dirfile metadata is flushed to disk (either explicitly via +When dirfile metadata are flushed to disk (either explicitly via .BR gd_metaflush (),\~ gd_rewrite_fragment (), or .BR gd_flush () @@ -302,9 +302,10 @@ The GetData parser can operate in two modes: a .I permissive mode, in which much -non-Standards compliant syntax is allowed, and a +non-Standards-compliant syntax is allowed, and a .I pedantic -mode, in which the parser adheres strictly to the Standards. If +mode, in which the parser adheres strictly to the Standards. The mode made +change during the parsing of a dirfile. If .B GD_PEDANTIC is passed to .BR gd_cbopen (), @@ -569,11 +570,12 @@ .BR gd_cbopen () or .BR gd_open () -always returns a pointer to a newly allocated DIRFILE object. The DIRFILE -object is an opaque structure containing the parsed dirfile metadata. -If an error occurred, the dirfile error will be set to a non-zero error value. -The DIRFILE object will also be internally flagged as invalid. Possible error -values are: +always returns a pointer to a newly allocated DIRFILE object, except in +instances when it is unable to allocate memory for the DIRFILE object itself, +in which case it will return NULL. The DIRFILE object is an opaque structure +containing the parsed dirfile metadata. If an error occurred, the dirfile +error will be set to a non-zero error value. The DIRFILE object will also +be internally flagged as invalid. Possible error values are: .TP 8 .B GD_E_ACCMODE The library was asked to create or truncate a dirfile opened read-only (i.e. @@ -612,11 +614,6 @@ .B The Callback Function section above. .TP -.B GD_E_INTERNAL_ERROR -An internal error occurred in the library while trying to perform the task. -This indicates a bug in the library. Please report the incident to the -GetData developers. -.TP .B GD_E_LINE_TOO_LONG The parser encountered a line in the format specification longer than it was able to deal with. Lines are limited by the storage size of Modified: trunk/getdata/man/gd_close.3 =================================================================== --- trunk/getdata/man/gd_close.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_close.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_close.3. The gd_close man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_close 3 "20 October 2010" "Version 0.7.0" "GETDATA" +.TH gd_close 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_close, gd_discard \(em close a dirfile and free associated memory. .SH SYNOPSIS @@ -51,9 +51,9 @@ data files are still flushed to disk by this function. If .I dirfile was opened in read-only mode, -.BR gd_discard() +.BR gd_discard () and -.BR gd_close() +.BR gd_close () behave identically. One of these functions should be called on all pointers returned by @@ -64,7 +64,7 @@ even if the call to those function failed. After .BR gd_close () or -.BR gd_discard() +.BR gd_discard () returns successfully, the pointer .I dirfile should be considered invalid. @@ -85,6 +85,9 @@ and set the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_FLUSH A temporary file could not be opened into which to write the modified metadata, or renaming the temporary file over the original fragment failed. Modified: trunk/getdata/man/gd_constants.3 =================================================================== --- trunk/getdata/man/gd_constants.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_constants.3 2011-08-19 01:27:46 UTC (rev 596) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_constants 3 "15 October 2010" "Version 0.7.0" "GETDATA" +.TH gd_constants 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_constants \(em retrieve a list of constant values from a dirfile .SH SYNOPSIS @@ -89,6 +89,11 @@ The .I return_type specified was invalid. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_entry.3 =================================================================== --- trunk/getdata/man/gd_entry.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_entry.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_entry.3. The gd_entry man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_entry 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_entry 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_entry \(em retrieve a dirfile field's metadata .SH SYNOPSIS @@ -75,6 +75,9 @@ returns -1 and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -410,8 +413,9 @@ .I n_fields member indicates the number of input fields. It will be between one and .B GD_MAX_LINCOM -inclusive, which is defined in getdata.h to the maximum number of input fields -permitted by a +inclusive. +.B GD_MAX_LINCOM +is defined in getdata.h as the maximum number of input fields permitted by a .BR LINCOM . .PP The @@ -588,8 +592,9 @@ .I poly_ord member indicates the order of the polynomial. It will be between one and .B GD_MAX_POLY_ORD -inclusive, which is defined in getdata.h to the maximum order of polynomial -permitted by a +inclusive. +.B GD_MAX_POLY_ORD +is defined in getdata.h as the maximum order of polynomial permitted by a .BR POLYNOM . .PP The Modified: trunk/getdata/man/gd_entry_type.3 =================================================================== --- trunk/getdata/man/gd_entry_type.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_entry_type.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_entry_type.3. The gd_entry_type man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_entry_type 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_entry_type 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_entry_type \(em retrieve the type of a dirfile field .SH SYNOPSIS @@ -58,6 +58,9 @@ and sets the dirfile error a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP Modified: trunk/getdata/man/gd_eof.3 =================================================================== --- trunk/getdata/man/gd_eof.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_eof.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_eof.3. The gd_eof man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_eof 3 "15 October 2010" "Version 0.7.0" "GETDATA" +.TH gd_eof 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_eof \(em report the number of samples in a dirfile field .SH SYNOPSIS @@ -69,6 +69,9 @@ On error, it returns -1 and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -99,6 +102,11 @@ .I field_code itself specified a scalar field. .TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. +.TP .B GD_E_RAW_IO An attempt to .BR stat (2) Modified: trunk/getdata/man/gd_error_count.3 =================================================================== --- trunk/getdata/man/gd_error_count.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_error_count.3 2011-08-19 01:27:46 UTC (rev 596) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_error_count 3 "20 April 2011" "Version 0.8.0" "GETDATA" +.TH gd_error_count 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_error_count \(em report the number of errors encountered by the GetData library @@ -37,11 +37,14 @@ return the number of errors encountered only since the previous call to this function, for the specified DIRFILE. -The errors themselves are not cached by the library. The +The errors themselves are not cached by the library. The error status of +the .I last -error encountered by the library for +library call on .I dirfile -can be obtained by calling +(which might be +.BR GD_E_OK , +indicating no error) can be obtained by calling .BR gd_error (3). .SH RETURN VALUE Modified: trunk/getdata/man/gd_error_string.3 =================================================================== --- trunk/getdata/man/gd_error_string.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_error_string.3 2011-08-19 01:27:46 UTC (rev 596) @@ -67,4 +67,4 @@ is unchanged. .SH SEE ALSO .BR gd_error (3), -.BR gd_error_string (3) +.BR gd_error_count (3) Modified: trunk/getdata/man/gd_field_list_by_type.3 =================================================================== --- trunk/getdata/man/gd_field_list_by_type.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_field_list_by_type.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_field_list_by_type.3. The gd_field_list_by_type man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_field_list_by_type 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_field_list_by_type 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_field_list_by_type \(em retrieve a list of fields in a dirfile .SH SYNOPSIS @@ -90,6 +90,16 @@ .TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. +.TP +.B GD_E_BAD_ENTRY +The +.I type +parameter supplied was not one of the symbols listed above. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. .PP The dirfile error may be retrieved by calling .BR gd_error (3). @@ -99,6 +109,7 @@ .SH SEE ALSO .BR dirfile (5), .BR gd_open (3), +.BR gd_carrays (3), .BR gd_constants (3), .BR gd_error (3), .BR gd_error_string (3), Modified: trunk/getdata/man/gd_flush.3 =================================================================== --- trunk/getdata/man/gd_flush.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_flush.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_flush.3. The gd_flush man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_flush 3 "24 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_flush 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_flush \(em write all pending dirfile changes to disk. .SH SYNOPSIS @@ -54,6 +54,9 @@ On success, zero is returned. On error, -1 is returned and the dirfile error is set to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -76,6 +79,12 @@ .TP .B GD_E_RAW_IO An error occurred while trying to flush or close the field(s). +.TP +.B GD_E_RECURSE_LEVEL +Too many levels of recursion were encountered while trying to resolve +.IR field_code . +This usually indicates a circular dependency in field specification in the +dirfile. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_fragment_index.3 =================================================================== --- trunk/getdata/man/gd_fragment_index.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_fragment_index.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_fragment_index.3. The gd_fragment_index man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_fragment_index 3 "15 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_fragment_index 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_fragment_index \(em retrieve the fragment containing a dirfile field .SH SYNOPSIS @@ -43,14 +43,17 @@ returns -1 and sets the dirfile error a non-zero error value. Possible error values are: .TP 8 -.B GD_E_BAD_DIRFILE -The supplied dirfile was invalid. +.B GD_E_ALLOC +The library was unable to allocate memory. .TP .B GD_E_BAD_CODE The field specified by .I field_code was not found in the database. .TP +.B GD_E_BAD_DIRFILE +The supplied dirfile was invalid. +.TP .B GD_E_BAD_REPR The representation suffix specified in .I field_code Modified: trunk/getdata/man/gd_framenum_subset.3 =================================================================== --- trunk/getdata/man/gd_framenum_subset.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_framenum_subset.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_framenum_subset.3. The gd_framenum man page. .\" -.\" Copyright (C) 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_framenum_subset 3 "23 October 2010" "Version 0.7.0" "GETDATA" +.TH gd_framenum_subset 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_framenum_subset, gd_framenum \(em perform a reverse look-up on a monotonic dirfile field @@ -110,11 +110,6 @@ .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP -.B GD_E_BAD_FIELD_TYPE -The field specified by -.I field_code -was not a vector field. -.TP .B GD_E_BAD_REPR The representation suffix specified in .IR field_code , @@ -125,7 +120,10 @@ scalar type. .TP .B GD_E_DIMENSION -A scalar field was found where a vector field was expected. +The field specified by +.I field_code +was not a vector field. Or, a scalar field was found where a vector field was +expected in the definition of the field or one of its inputs. .TP .B GD_E_DOMAIN The specified field was complex valued, or the supplied frame range was too Modified: trunk/getdata/man/gd_get_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_get_carray_slice.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_get_carray_slice.3 2011-08-19 01:27:46 UTC (rev 596) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_get_carray_slice 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_get_carray_slice 3 "18 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_get_carray gd_get_carray_slice \(em retrieve CARRAY data from a dirfile database @@ -136,6 +136,9 @@ return zero. On error, they return -1 and set the dirfile error to a non-zero value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code Modified: trunk/getdata/man/gd_get_constant.3 =================================================================== --- trunk/getdata/man/gd_get_constant.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_get_constant.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_get_constant.3. The gd_get_constant man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_get_constant 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_get_constant 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_get_constant \(em retrieve a scalar constant from a dirfile database .SH SYNOPSIS @@ -111,6 +111,9 @@ returns zero. On error, it returns -1 and sets the dirfile error to a non-zero value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -134,8 +137,8 @@ .TP .B GD_E_BAD_REPR The representation suffix specified in -.IR field code , -or in one of the field codes it uses for input, was invalid. +.I field_code +was invalid. .TP .B GD_E_BAD_TYPE An invalid Modified: trunk/getdata/man/gd_getdata.3 =================================================================== --- trunk/getdata/man/gd_getdata.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_getdata.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_getdata.3. The gd_getdata man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_getdata 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_getdata 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_getdata \(em retrieve data from a dirfile database .SH SYNOPSIS @@ -168,19 +168,6 @@ .I dirfile was supplied. .TP -.B GD_E_BAD_FIELD_TYPE -The supplied -.I field_code -referred to a -.BR CONST ,\~ CARRAY , -or -.B STRING -field. The caller should use -.BR gd_get_constant (3),\~ gd_get_carray (3) , -or -.BR gd_get_string (3) -instead. -.TP .B GD_E_BAD_REPR The representation suffix specified in .IR field_code , @@ -196,7 +183,20 @@ was specified. .TP .B GD_E_DIMENSION -A scalar field was found where a vector field was expected. +The supplied +.I field_code +referred to a +.BR CONST ,\~ CARRAY , +or +.B STRING +field. The caller should use +.BR gd_get_constant (3),\~ gd_get_carray (3) , +or +.BR gd_get_string (3) +instead. Or, a scalar field was found where a vector field was expected in +the definition of +.I field_code +or one of its inputs. .TP .B GD_E_INTERNAL_ERROR An internal error occurred in the library while trying to perform the task. Modified: trunk/getdata/man/gd_include.3 =================================================================== --- trunk/getdata/man/gd_include.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_include.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_include.3. The gd_include man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_include 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_include 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_include \(em add a format specification fragment to a dirfile .SH SYNOPSIS @@ -239,7 +239,12 @@ .BR dirfile-format (5)) was not found, or was not a .B RAW -field. +field. In this case, the included fragment will still be added to the dirfile, +but the +.B /REFERENCE +directive will be ignored. See also the +.B BUGS +section below. .TP .B GD_E_CALLBACK The registered callback function returned an unrecognised response. @@ -247,11 +252,6 @@ .B GD_E_FORMAT A syntax error occurred in the fragment. .TP -.B GD_E_INTERNAL_ERROR -An internal error occurred in the library while trying to perform the task. -This indicates a bug in the library. Please report the incident to the -maintainer. -.TP .B GD_E_LINE_TOO_LONG The parser encountered a line in the format specification longer than it was able to deal with. Lines are limited by the storage size of @@ -264,19 +264,6 @@ .TP .B GD_E_PROTECTED The metadata of the parent fragment was protected from change. -.TP -.B GD_E_REFERENCE -The included fragment contained a -.B /REFERENCE -directive which referred to a non-existent field, or a field that was not of -type -.BR RAW . -In this case, the included fragment will still be added to the dirfile, but -the -.B /REFERENCE -directive will be ignored. See also the -.B BUGS -section below. .PP The dirfile error may be retrieved by calling .BR gd_error (3). @@ -288,7 +275,7 @@ even if the open failed. .SH BUGS If this function fails with the error -.BR GD_E_REFERENCE , +.BR GD_E_BAD_REFERENCE , it typically results in no reference field being defined for the dirfile, even if the dirfile contains .B RAW Modified: trunk/getdata/man/gd_invalid_dirfile.3 =================================================================== --- trunk/getdata/man/gd_invalid_dirfile.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_invalid_dirfile.3 2011-08-19 01:27:46 UTC (rev 596) @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_invalid_dirfile 3 "20 October 2010" "Version 0.7.0" "GETDATA" +.TH gd_invalid_dirfile 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_invalid_dirfile \(em obtain an pointer to an invalid DIRFILE object .SH SYNOPSIS @@ -63,7 +63,8 @@ .SH RETURN VALUE This function always returns a pointer to a newly allocated, invalid DIRFILE -object. +object, except when it is unable to allocate memory for the DIRFILE, in which +case it returns NULL. .SH SEE ALSO .BR gd_close (3), Modified: trunk/getdata/man/gd_mcarrays.3 =================================================================== --- trunk/getdata/man/gd_mcarrays.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_mcarrays.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_constants.3. The gd_constants man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_mcarrays 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_mcarrays 3 "19 August 2011" "Version 0.7.0" "GETDATA" .SH NAME gd_constants \(em retrieve a list of CARRAY values from a dirfile .SH SYNOPSIS @@ -125,6 +125,11 @@ The .I return_type specified was invalid. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_mconstants.3 =================================================================== --- trunk/getdata/man/gd_mconstants.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_mconstants.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_mconstants.3. The gd_mconstants man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_mconstants 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_mconstants 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_mconstants \(em retrieve a list of constant values from a dirfile .SH SYNOPSIS @@ -86,6 +86,11 @@ The .I return_type specified was invalid. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_metaflush.3 =================================================================== --- trunk/getdata/man/gd_metaflush.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_metaflush.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_metaflush.3. The gd_metaflush man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_metaflush 3 "24 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_metaflush 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_metaflush \(em write modified dirfile metadata to disk .SH SYNOPSIS @@ -51,17 +51,15 @@ .B GD_E_ACCMODE The supplied dirfile was opened in read-only mode. .TP +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP .B GD_E_FLUSH A temporary file could not be opened into which to write the modified metadata, or renaming the temporary file over the original fragment failed. -.TP -.B GD_E_INTERNAL_ERROR -An internal error occurred in the library while trying to perform the task. -This indicates a bug in the library. Please report the incident to the -maintainer. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_mfield_list_by_type.3 =================================================================== --- trunk/getdata/man/gd_mfield_list_by_type.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_mfield_list_by_type.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_mfield_list_by_type.3. The gd_mfield_list_by_type man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_mfield_list_by_type 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_mfield_list_by_type 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_mfield_list_by_type \(em retrieve a list of fields in a dirfile .SH SYNOPSIS @@ -91,6 +91,16 @@ .TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. +.TP +.B GD_E_BAD_ENTRY +The +.I type +parameter supplied was not one of the symbols listed above. +.TP +.B GD_E_INTERNAL_ERROR +An internal error occurred in the library while trying to perform the task. +This indicates a bug in the library. Please report the incident to the +GetData developers. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_native_type.3 =================================================================== --- trunk/getdata/man/gd_native_type.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_native_type.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_native_type.3. The gd_native_type man page. .\" -.\" Copyright (C) 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_native_type 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_native_type 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_native_type \(em returns the native data type of a field in a dirfile .SH SYNOPSIS @@ -110,6 +110,9 @@ and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -123,14 +126,6 @@ .IR field_code , or in one of its input fields, was not recognised. .TP -.B GD_E_BAD_SCALAR -A non-literal scalar used in the definition of the field or one of its inputs -was not found, or was not a -.B CONST -or -.B CARRAY -field. -.TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected. .TP Modified: trunk/getdata/man/gd_nfields_by_type.3 =================================================================== --- trunk/getdata/man/gd_nfields_by_type.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_nfields_by_type.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_nfields_by_type.3. The gd_nfields_by_type man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_nfields_by_type 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_nfields_by_type 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_nfields_by_type \(em report the number of fields of a given type in a dirfile .SH SYNOPSIS @@ -61,6 +61,11 @@ .TP 8 .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. +.TP +.B GD_E_BAD_ENTRY +The +.I type +parameter supplied was not one of the symbols listed above. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_nframes.3 =================================================================== --- trunk/getdata/man/gd_nframes.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_nframes.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_nframes.3. The gd_nframes man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_nframes 3 "22 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_nframes 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_nframes \(em report the size of a dirfile .SH SYNOPSIS @@ -55,13 +55,15 @@ returns the number of frames in the dirfile. On error, it returns zero and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP .B GD_E_RAW_IO -An attempt to -.BR stat (2) -the file associated with the reference field failed. +An attempt to determine the (unencoded) size of the data file associated with +the reference field failed. .TP .B GD_E_UNKNOWN_ENCODING The size of the decoded data file associated with the reference field could not Modified: trunk/getdata/man/gd_nmfields_by_type.3 =================================================================== --- trunk/getdata/man/gd_nmfields_by_type.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_nmfields_by_type.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_nmfields_by_type.3. The gd_nmfields_by_type man page. .\" -.\" Copyright (C) 2008, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_nmfields_by_type 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_nmfields_by_type 3 "17 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_nmfields_by_type \(em report the number of fields of a given type in a dirfile .SH SYNOPSIS @@ -63,6 +63,11 @@ .TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. +.TP +.B GD_E_BAD_ENTRY +The +.I type +parameter supplied was not one of the symbols listed above. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_put_carray_slice.3 =================================================================== --- trunk/getdata/man/gd_put_carray_slice.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_put_carray_slice.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_put_carray_slice.3. The gd_put_carray_slice man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_put_carray_slice 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_put_carray_slice 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_put_carray gd_put_carray_slice \(em write CARRAY data to a dirfile database .SH SYNOPSIS @@ -131,6 +131,9 @@ .I dirfile was opened read-only. .TP +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -169,6 +172,9 @@ An internal error occurred in the library while trying to perform the task. This indicates a bug in the library. Please report the incident to the maintainer. +.TP +.B GD_E_PROTECTED +The fragment containing the constant was protected from change. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_put_constant.3 =================================================================== --- trunk/getdata/man/gd_put_constant.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_put_constant.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_put_constant.3. The gd_put_constant man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_put_constant 3 "4 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_put_constant 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_put_constant \(em retrieve a scalar constant from a dirfile database .SH SYNOPSIS @@ -103,6 +103,9 @@ .I dirfile was opened read-only. .TP +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code Modified: trunk/getdata/man/gd_put_string.3 =================================================================== --- trunk/getdata/man/gd_put_string.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_put_string.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_put_string.3. The gd_put_string man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_put_string 3 "25 May 2010" "Version 0.7.0" "GETDATA" +.TH gd_put_string 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_put_string \(em retrieve a string from a dirfile database .SH SYNOPSIS @@ -53,6 +53,11 @@ On error, it returns 0 and sets the dirfile error to a non-zero value. Possible error values are: .TP 8 +.B GD_E_ACCMODE +The specified +.I dirfile +was opened read-only. +.TP .B GD_E_BAD_CODE The field specified by .I field_code @@ -70,6 +75,7 @@ .BR STRING . The caller should use .BR gd_putdata (3), +.BR gd_put_carray (3), or .BR gd_put_constant (3) instead. Modified: trunk/getdata/man/gd_putdata.3 =================================================================== --- trunk/getdata/man/gd_putdata.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_putdata.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_putdata.3. The gd_putdata man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_putdata 3 "4 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_putdata 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_putdata \(em write data to a dirfile database .SH SYNOPSIS @@ -153,10 +153,9 @@ .B DIVIDE type, or .B LINCOM -type with more than one input fields. In this case, -.BR gd_putdata () -has no knowledge on how to partition the input data. Alternately, the caller -may have attempted to write to the implicit INDEX field, which is not possible. +type with more than one input fields. In this case, GetData has no knowledge on +how to partition the input data. Alternately, the caller may have attempted to +write to the implicit INDEX field, which is not possible. .TP .B GD_E_BAD_REPR The representation suffix specified in @@ -170,7 +169,16 @@ was specified. .TP .B GD_E_DIMENSION -A scalar field was found where a vector field was expected. +The field specified by +.I field_code +was not a vector field. The caller should use +.BR gd_put_carray (3), +.BR gd_put_constant (3), +or +.BR gd_put_string (3) +instead. Or, a scalar field was found where a vector field was expected in +the definition of +.IR field_code . .TP .B GD_E_INTERNAL_ERROR An internal error occurred in the library while trying to perform the task. Modified: trunk/getdata/man/gd_rename.3 =================================================================== --- trunk/getdata/man/gd_rename.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_rename.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_rename.3. The gd_rename man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_rename 3 "20 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_rename 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_rename \(em change the name of a dirfile field .SH SYNOPSIS @@ -85,11 +85,6 @@ .I INDEX field. .TP -.B GD_E_BAD_REPR -The representation suffix specified in -.I field_code -was not recognised. -.TP .B GD_E_DUPLICATE The new name specified is already in use by another field. .TP Modified: trunk/getdata/man/gd_rewrite_fragment.3 =================================================================== --- trunk/getdata/man/gd_rewrite_fragment.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_rewrite_fragment.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_rewrite_fragment.3. The gd_rewrite_fragment man page. .\" -.\" Copyright (C) 2010 D. V. Wiebe +.\" Copyright (C) 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_rewrite_fragment 3 "22 March 2011" "Version 0.7.2" "GETDATA" +.TH gd_rewrite_fragment 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_rewrite_fragment \(em re-write a dirfile format specification fragment .SH SYNOPSIS @@ -52,6 +52,9 @@ .B GD_E_ACCMODE The supplied dirfile was opened in read-only mode. .TP +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_DIRFILE The supplied dirfile was invalid. .TP @@ -61,11 +64,6 @@ .B GD_E_FLUSH A temporary file could not be opened into which to write the modified metadata, or renaming the temporary file over the original fragment failed. -.TP -.B GD_E_INTERNAL_ERROR -An internal error occurred in the library while trying to perform the task. -This indicates a bug in the library. Please report the incident to the -maintainer. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/gd_spf.3 =================================================================== --- trunk/getdata/man/gd_spf.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_spf.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_spf.3. The gd_spf man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_spf 3 "24 July 2010" "Version 0.7.0" "GETDATA" +.TH gd_spf 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_spf \(em returns the samples per frame for a field in a dirfile @@ -50,6 +50,9 @@ returns zero and sets the dirfile error to a non-zero error value. Possible error values are: .TP 8 +.B GD_E_ALLOC +The library was unable to allocate memory. +.TP .B GD_E_BAD_CODE The field specified by .I field_code Modified: trunk/getdata/man/gd_validate.3 =================================================================== --- trunk/getdata/man/gd_validate.3 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/gd_validate.3 2011-08-19 01:27:46 UTC (rev 596) @@ -1,6 +1,6 @@ .\" gd_validate.3. The gd_validate man page. .\" -.\" Copyright (C) 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -13,7 +13,7 @@ .\" Texts. A copy of the license is included in the `COPYING.DOC' file .\" as part of this distribution. .\" -.TH gd_validate 3 "3 November 2010" "Version 0.7.0" "GETDATA" +.TH gd_validate 3 "19 August 2011" "Version 0.8.0" "GETDATA" .SH NAME gd_validate \(em check a dirfile field code for validity .SH SYNOPSIS @@ -71,12 +71,6 @@ .TP .B GD_E_DIMENSION A scalar field was found where a vector field was expected. -.TP -.B GD_E_RECURSE_LEVEL -Too many levels of recursion were encountered while trying to resolve -.IR field_code . -This usually indicates a circular dependency in field specification in the -dirfile. .PP The dirfile error may be retrieved by calling .BR gd_error (3). Modified: trunk/getdata/man/make_html.pl =================================================================== --- trunk/getdata/man/make_html.pl 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/man/make_html.pl 2011-08-19 01:27:46 UTC (rev 596) @@ -57,7 +57,9 @@ while(<F>) { next if (/^\.\\"/); chomp; - $_ = ".PP" if ($_ eq "" and not $nf); + if ($_ eq "" and not $nf) { + $_ = ($dl == 1) ? ".DP" : ".PP"; + } $_ = ".IP" if ($_ =~ /\.in /); $_ = ".PP" if ($_ eq ".in"); s/&/&/g; @@ -128,6 +130,8 @@ } else { $html .= Alternate("<B>", "</B>", "", "", $1) . " "; } + } elsif (/^\.DP$/) { + $html .= "<P>"; } elsif (/^\.HP$/) { if ($dl == 1) { $html .= "</DD></DL>"; $dl = 0; }; if ($ul == 1) { $html .= "</UL>"; $ul = 0; }; Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/encoding.c 2011-08-19 01:27:46 UTC (rev 596) @@ -315,17 +315,19 @@ for (i = 0; _gd_ef[i].scheme != GD_ENC_UNSUPPORTED; i++) { if (scheme == GD_AUTO_ENCODED || scheme == _gd_ef[i].scheme) { candidate = (char *)malloc(len + strlen(_gd_ef[i].ext) + 1); - strcat(strcpy(candidate, name), _gd_ef[i].ext); + if (candidate) { + strcat(strcpy(candidate, name), _gd_ef[i].ext); - if (gd_StatAt(D, dirfd, candidate, &statbuf, 0) == 0) - if (S_ISREG(statbuf.st_mode)) { - if (file != NULL) - file->subenc = i; - free(candidate); - dreturn("%08lx", _gd_ef[i].scheme); - return _gd_ef[i].scheme; - } - free(candidate); + if (gd_StatAt(D, dirfd, candidate, &statbuf, 0) == 0) + if (S_ISREG(statbuf.st_mode)) { + if (file != NULL) + file->subenc = i; + free(candidate); + dreturn("%08lx", _gd_ef[i].scheme); + return _gd_ef[i].scheme; + } + free(candidate); + } } } @@ -712,7 +714,7 @@ mode_t mode; #endif dtrace("%i, %i, %p, %p", dirfd0, dirfd1, file, tunlink); - + if (file[1].name == NULL) { dreturn("%i", 0); return 0; Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/errors.c 2011-08-19 01:27:46 UTC (rev 596) @@ -190,6 +190,10 @@ { GD_E_FLUSH, GD_E_FLUSH_MKTMP, "I/O error creating temporary file: ", 1 }, { GD_E_FLUSH, GD_E_FLUSH_OPEN, "I/O error opening temporary file: ", 1 }, { GD_E_FLUSH, GD_E_FLUSH_RENAME, "I/O error replacing format metadata: ", 1 }, + /* GD_E_BOUNDS: (nothing) */ + { GD_E_BOUNDS, 0, "CARRAY length out of bounds", 0 }, + /* GD_E_LINE_TOO_LONG: 2 = fragment, 3 = line number */ + { GD_E_LINE_TOO_LONG, 0, "Line {3} of {2} too long", 0 }, /* GD_E_OK: (nothing) */ { 0, 0, "Success", 0} /* this must be the last error string defined */ }; Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/flimits.c 2011-08-19 01:27:46 UTC (rev 596) @@ -540,7 +540,7 @@ _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, E->field); break; case GD_NO_ENTRY: - _GD_SetError(D, GD_E_BAD_FIELD_TYPE, GD_E_FIELD_BAD, NULL, 0, E->field); + _GD_InternalError(D); break; } @@ -595,4 +595,3 @@ } /* vim: ts=2 sw=2 et tw=80 */ - Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/flush.c 2011-08-19 01:27:46 UTC (rev 596) @@ -432,18 +432,22 @@ int pretty = 0; size_t max_len = 0; unsigned int u; +#ifdef HAVE_FCHMOD mode_t mode; struct stat stat_buf; +#endif time_t t; int dirfd = D->fragment[i].dirfd; dtrace("%p, %i, %i", D, i, permissive); +#ifdef HAVE_FCHMOD /* get the permissions of the old file */ if (stat(D->fragment[i].cname, &stat_buf)) mode = 0644; else mode = stat_buf.st_mode; +#endif /* open a temporary file */ fd = _GD_MakeTempFile(D, dirfd, temp_file); Modified: trunk/getdata/src/include.c =================================================================== --- trunk/getdata/src/include.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/include.c 2011-08-19 01:27:46 UTC (rev 596) @@ -377,7 +377,7 @@ /* delete the fragments, if requested */ if (del) for (j = 0; j < nf; ++j) - unlink(D->fragment[f[j]].cname); + gd_UnlinkAt(D, D->fragment[f[j]].dirfd, D->fragment[f[j]].cname, 0); /* delete fields from the fragment -- memory use is not sufficient to warrant * resizing D->entry */ Modified: trunk/getdata/src/index.c =================================================================== --- trunk/getdata/src/index.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/index.c 2011-08-19 01:27:46 UTC (rev 596) @@ -239,6 +239,8 @@ if (_GD_NativeType(D, entry, repr) & GD_COMPLEX) _GD_SetError(D, GD_E_DOMAIN, GD_E_DOMAIN_COMPLEX, NULL, 0, NULL); + else if (entry->field_type & GD_SCALAR_ENTRY) + _GD_SetError(D, GD_E_DIMENSION, GD_E_DIM_CALLER, NULL, 0, field_code); if (field_code != field_code_in) free(field_code); Modified: trunk/getdata/src/nmeta.c =================================================================== --- trunk/getdata/src/nmeta.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/nmeta.c 2011-08-19 01:27:46 UTC (rev 596) @@ -110,6 +110,8 @@ r = P->e->n_meta_const; else if (type == GD_CARRAY_ENTRY) r = P->e->n_meta_carray; + else if (type == GD_NO_ENTRY) + _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_TYPE, NULL, type, NULL); else for (i = 0; i < P->e->n_meta; ++i) if (P->e->p.meta_entry[i]->field_type == type) Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-08-17 15:20:30 UTC (rev 595) +++ trunk/getdata/src/open.c 2011-08-19 01:27:46 UTC (rev 596) @@ -265,8 +265,10 @@ dtracevoid(); D = (DIRFILE *)malloc(sizeof(DIRFILE)); - memset(D, 0, sizeof(DIRFILE)); - D->flags = GD_INVALID; + if (D) { + memset(D, 0, sizeof(DIRFILE)); + D->flags = GD_INVALID; + } dreturn("%p", D); return D; @@ -293,6 +... [truncated message content] |
From: <ket...@us...> - 2011-08-17 15:20:38
|
Revision: 595 http://getdata.svn.sourceforge.net/getdata/?rev=595&view=rev Author: ketiltrout Date: 2011-08-17 15:20:30 +0000 (Wed, 17 Aug 2011) Log Message: ----------- Fix stat64 stuff for OSX. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/src/internal.h trunk/getdata/src/sie.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-08-11 19:36:53 UTC (rev 594) +++ trunk/getdata/ChangeLog 2011-08-17 15:20:30 UTC (rev 595) @@ -1,3 +1,7 @@ +2011-08-11 D. V. Wiebe <ge...@ke...> svn:595 + * src/internal.h: In cases where no explicitly 64-bit stat struct can be + found, don't bother trying to use explicitly 64-bit stat functions. + 2011-08-11 D. V. Wiebe <ge...@ke...> svn:594 * test/sie_nframes_big.c test/sie_get_big.c test/sie_get_little.c test/sie_nframes_little.c test/sie_move_to.c test/sie_put_little.c Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-08-11 19:36:53 UTC (rev 594) +++ trunk/getdata/src/internal.h 2011-08-17 15:20:30 UTC (rev 595) @@ -280,34 +280,40 @@ #define rmdir _rmdir #endif -#if HAVE_STAT64 +#if HAVE_STRUCT_STAT64 +typedef struct stat64 gd_stat64_t; +#elif HAVE_STRUCT__STAT64 +typedef struct _stat64 gd_stat64_t; +#elif HAVE_STRUCT___STAT64 +typedef struct __stat64 gd_stat64_t; +#else +typedef struct stat gd_stat64_t; +#define GD_NO_64BIT_STAT +#endif + +#ifdef GD_NO_64BIT_STAT +# define gd_stat64 stat +# define gd_fstat64 fstat +#else +# if HAVE_STAT64 # define gd_stat64 stat64 -#elif HAVE__STAT64 +# elif HAVE__STAT64 # define gd_stat64 _stat64 -#else +# else # define gd_stat64 stat -#endif +# endif -#if HAVE_FSTAT64 +# if HAVE_FSTAT64 # define gd_fstat64 fstat64 -#elif HAVE__FSTAT64 +# elif HAVE__FSTAT64 # define gd_fstat64 _fstat64 -#elif HAVE__FSTAT +# elif HAVE__FSTAT # define gd_fstat64 _fstat -#else +# else # define gd_fstat64 fstat +# endif #endif -#if HAVE_STRUCT_STAT64 -typedef struct stat64 gd_stat64_t; -#elif HAVE_STRUCT__STAT64 -typedef struct _stat64 gd_stat64_t; -#elif HAVE_STRUCT___STAT64 -typedef struct __stat64 gd_stat64_t; -#else -typedef struct stat gd_stat64_t; -#endif - #ifndef AT_SYMLINK_NOFOLLOW #define AT_SYMLINK_NOFOLLOW 0x100 #endif Modified: trunk/getdata/src/sie.c =================================================================== --- trunk/getdata/src/sie.c 2011-08-11 19:36:53 UTC (rev 594) +++ trunk/getdata/src/sie.c 2011-08-17 15:20:30 UTC (rev 595) @@ -237,7 +237,7 @@ dtrace("%p, %p, 0x%03x, %zu", file, ptr, data_type, nelem); /* not enough data in the current run */ - while (f->d[0] - f->p <= nelem - count) { + while (f->d[0] - f->p <= (int64_t)(nelem - count)) { /* copy what we've got */ cur = _GD_Duplicate(cur, f->d + 1, GD_SIZE(data_type), f->d[0] - f->p + 1); count += f->d[0] - f->p + 1; @@ -252,7 +252,7 @@ } /* copy the remnant */ - if (f->d[0] - f->p >= nelem - count) { + if (f->d[0] - f->p >= (int64_t)(nelem - count)) { _GD_Duplicate(cur, f->d + 1, GD_SIZE(data_type), nelem - count); f->p += nelem - count; count = nelem; @@ -369,7 +369,7 @@ } if (fseek(f->fp, (fr + rout) * size, SEEK_SET) || (fread(buffer, size, nrec - (fr + rout), f->fp) - < nrec - (fr + rout))) + < (size_t)(nrec - (fr + rout)))) { free(buffer); free(p); @@ -377,7 +377,8 @@ return -1; } if (fseek(f->fp, (fr + rin) * size, SEEK_SET) || - (fwrite(buffer, size, nrec - (fr + rout), f->fp) < nrec - (fr + rout))) + (fwrite(buffer, size, nrec - (fr + rout), f->fp) + < (size_t)(nrec - (fr + rout)))) { free(buffer); free(p); @@ -447,7 +448,7 @@ int64_t n; const size_t size = sizeof(int64_t) + GD_SIZE(data_type); - dtrace("%i, %p, 0x%03x, %i", dirfd, file, data_type, size); + dtrace("%i, %p, 0x%03x, %i", dirfd, file, data_type, swap); /* open */ if (_GD_SampIndDoOpen(dirfd, file, &f, swap, GD_RDONLY, 0)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-08-11 19:37:04
|
Revision: 594 http://getdata.svn.sourceforge.net/getdata/?rev=594&view=rev Author: ketiltrout Date: 2011-08-11 19:36:53 +0000 (Thu, 11 Aug 2011) Log Message: ----------- Sample Index Encoding along with a few changes to the encoding framework. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/configure.ac trunk/getdata/src/Makefile.am trunk/getdata/src/add.c trunk/getdata/src/ascii.c trunk/getdata/src/bzip.c trunk/getdata/src/del.c trunk/getdata/src/encoding.c trunk/getdata/src/endian.c trunk/getdata/src/entry.c trunk/getdata/src/errors.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/gzip.c trunk/getdata/src/internal.h trunk/getdata/src/lzma.c trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/name.c trunk/getdata/src/nframes.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/raw.c trunk/getdata/test/Makefile.am Added Paths: ----------- trunk/getdata/src/sie.c trunk/getdata/test/sie_get_big.c trunk/getdata/test/sie_get_little.c trunk/getdata/test/sie_move_from.c trunk/getdata/test/sie_move_to.c trunk/getdata/test/sie_nframes_big.c trunk/getdata/test/sie_nframes_little.c trunk/getdata/test/sie_put_big.c trunk/getdata/test/sie_put_little.c Property Changed: ---------------- trunk/getdata/bindings/perl/ trunk/getdata/test/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/ChangeLog 2011-08-11 19:36:53 UTC (rev 594) @@ -1,3 +1,46 @@ +2011-08-11 D. V. Wiebe <ge...@ke...> svn:594 + * test/sie_nframes_big.c test/sie_get_big.c test/sie_get_little.c + test/sie_nframes_little.c test/sie_move_to.c test/sie_put_little.c + test/sie_move_from.c test/sie_put_big.c: Added. + + * configure.ac src/internal.h: Handle missing fstat64, ftruncate64, and byte + swapping routines. + + * src/internal.h src/errors.c: Differentiate GD_E_UNKNOWN_ENCODING errors + arising from existing, unknown encodings on disk from errors arising from + attempts to convert to an unknown encoding. + + * src/endian.c (_GD_FixEndianness): Use standard system byte-swapping + routines, where possible, with the assumption that they're not slower than + our old implementation. + + * src/encoding.c: Redo the way _gd_ef is initialised to try and make it + a little easier to maintain. + + * src/internal.h: In struct _gd_raw_file, rename .fp to .idata and .encoding + to .subenc to reduce code obfuscation. + + * src/encoding.c: Added SIE encoding hooks. + * src/sie.c: Added. + + * src/internal.h (_GD_FileSwapBytes): Added. + * src/internal.h: _gd_ef->open(), ->size(), ->touch(), and ->topen() now take + a "swap" parameter, indicating whether bytes are opposite-endian. + + * src/internal.h: Split _gd_ef->temp() into ->topen, ->tmove, and ->tunlink. + Also typedef all the framework method prototypes. + * src/ascii.c (_GD_AsciiTOpen _GD_AsciiTUnlink) src/raw.c (_GD_RawTOpen + _GD_RawTUnlink): Added. + * src/ascii.c (_GD_AsciiTemp) src/raw.c (_GD_RawTemp): Deleted. + * src/encoding.c (_GD_GenericTMove): Added. + * src/endian.c (_GD_ByteSwapFragment) src/encoding.c (_GD_MissingFramework + _GD_RecodeFragment) src/move.c (_GD_MogrifyFile) src/flimits.c + (_GD_ShiftFragment) src/mod.c (_GD_Change): Replace _gd_ef->temp() calls with + t{open|move|unlink} calls. + + * src/move.c (_GD_MogrifyFile) src/mod.c (_GD_Change): Call _GD_MakeTempFile + before calling _gd_ef->topen. + 2011-08-10 D. V. Wiebe <ge...@ke...> svn:593 * bindings/perl/t/big_test.t: Convert to TAP. Property changes on: trunk/getdata/bindings/perl ___________________________________________________________________ Modified: svn:ignore - simple_funcs.xs Makefile.in GetData.pm GetData.c .deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib debug.c GetData.bs + simple_funcs.xs Makefile.in GetData.pm GetData.c .deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib debug.c MYMETA.yml GetData.bs GetData.bs Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/configure.ac 2011-08-11 19:36:53 UTC (rev 594) @@ -51,7 +51,7 @@ dnl Features BUINDINGS_BUILT= BINDINGS_LEFT= -ENCODINGS_BUILT=" raw ascii" +ENCODINGS_BUILT=" raw ascii sie" ENCODINGS_LEFT= PRIVATE_LIBS= @@ -504,7 +504,7 @@ dnl libraries echo -echo "*** Looking for library functions" +echo "*** Looking for additional libraries" echo AC_SEARCH_LIBS([ceil],[m]) @@ -519,56 +519,17 @@ AC_CHECK_HEADERS(pthread.h) fi -dnl functions -AC_CHECK_FUNCS([_commit fchmod _fdopen fdopendir fseeko fseeko64 _fstat \ - fstatat fstatat64 fsync ftello ftello64 getcwd _getcwd \ - getdelim gmtime_r _lseeki64 lstat _mkdir nan _open openat \ - _read renameat _rmdir _snprintf stat64 _stat64 _strtoi64 \ - strtoll _strtoui64 strtoull _unlink unlinkat _write]) -if test "x$disable_c99" = "xno"; then - AC_CHECK_FUNCS([cabs]) -fi -AC_FUNC_STRERROR_R - dnl headers echo echo "*** Looking for additional header files" echo -AC_CHECK_HEADERS([direct.h fcntl.h libgen.h stdint.h unistd.h]) +AC_CHECK_HEADERS([byteswap.h direct.h fcntl.h io.h libgen.h \ + libkern/OSByteOrder.h stdint.h sys/endian.h unistd.h]) if test "x$disable_c99" = "xno"; then AC_CHECK_HEADERS([complex.h]) fi AC_HEADER_DIRENT -AC_CHECK_HEADERS([io.h]) - -AC_MSG_CHECKING([whether mkdir accepts two arguments]) -AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ -#if HAVE_SYS_STAT_H -#include <sys/stat.h> -#endif -#if HAVE_SYS_TYPES_H -#include <sys/types.h> -#endif -#if HAVE_IO_H -#include <io.h> -#endif -], [[ -#ifdef HAVE__MKDIR -_mkdir("x", 00777); -#else -mkdir("x", 00777); -#endif -]])], -[gd_2arg_mkdir=yes], -[gd_2arg_mkdir=no]) -AC_MSG_RESULT([$gd_2arg_mkdir]) - -if test $gd_2arg_mkdir = "no"; then - AC_DEFINE([MKDIR_NO_MODE], [1], - [ Define to 1 if the `mkdir' function takes only one argument.]) -fi dnl` - dnl types echo echo "*** Checking data types" @@ -693,6 +654,61 @@ AC_SUBST([DEFINE_gd_uint16_t]) AC_SUBST([DEFINE_gd_int64_t]) +dnl library functions +echo +echo "*** Looking for additional library functions" +echo +AC_CHECK_FUNCS([_chsize _chsize_s _commit fchmod _fdopen fdopendir fseeko \ + fseeko64 _fstat fstat64 _fstat64 fstatat fstatat64 fsync \ + ftello ftello64 ftruncate ftruncate64 getcwd _getcwd getdelim \ + gmtime_r _lseeki64 lstat _mkdir nan _open openat _read \ + renameat _rmdir _snprintf stat64 _stat64 _strtoi64 strtoll \ + _strtoui64 strtoull _unlink unlinkat _write]) +if test "x$disable_c99" = "xno"; then + AC_CHECK_FUNCS([cabs]) +fi +AC_FUNC_STRERROR_R + +AC_MSG_CHECKING([whether mkdir accepts two arguments]) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ +#if HAVE_SYS_STAT_H +#include <sys/stat.h> +#endif +#if HAVE_SYS_TYPES_H +#include <sys/types.h> +#endif +#if HAVE_IO_H +#include <io.h> +#endif +], [[ +#ifdef HAVE__MKDIR +_mkdir("x", 00777); +#else +mkdir("x", 00777); +#endif +]])], +[gd_2arg_mkdir=yes], +[gd_2arg_mkdir=no]) +AC_MSG_RESULT([$gd_2arg_mkdir]) + +if test $gd_2arg_mkdir = "no"; then + AC_DEFINE([MKDIR_NO_MODE], [1], + [ Define to 1 if the `mkdir' function takes only one argument.]) +fi dnl` + +AC_CHECK_DECLS([bswap16, bswap_16, OSSwapInt16],,, + [ +#ifdef HAVE_BYTESWAP_H +#include <byteswap.h> +#endif +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif +#ifdef HAVE_LIBKERN_OSBYTEORDER_H +#include <libkern/OSByteOrder.h> +#endif +]) + dnl python if test "x$make_pybindings" = "xyes"; then echo Modified: trunk/getdata/src/Makefile.am =================================================================== --- trunk/getdata/src/Makefile.am 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/Makefile.am 2011-08-11 19:36:53 UTC (rev 594) @@ -109,9 +109,9 @@ fragment.c getdata.c globals.c ${GZIP_C} index.c \ include.c ${LEGACY_C} ${LZMA_C} meta_list.c mod.c \ move.c name.c native.c nfields.c nframes.c nmeta.c \ - open.c parse.c protect.c putdata.c raw.c ${SLIM_C} \ - spf.c string.c types.c ${GETDATA_LEGACY_H} internal.h \ - nan.h + open.c parse.c protect.c putdata.c raw.c sie.c \ + ${SLIM_C} spf.c string.c types.c ${GETDATA_LEGACY_H} \ + internal.h nan.h libgetdata_la_LDFLAGS = $(EXPORT_DYNAMIC) -export-symbols-regex '^[^_]' \ -version-info \ ${GETDATA_IFACE_VERSION}:${GETDATA_IMPL_REVISION}:${GETDATA_IFACE_AGE} \ Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/add.c 2011-08-11 19:36:53 UTC (rev 594) @@ -196,8 +196,8 @@ } E->EN(raw,data_type) = entry->EN(raw,data_type); - E->e->u.raw.file[0].fp = E->e->u.raw.file[1].fp = -1; - E->e->u.raw.file[0].encoding = GD_ENC_UNKNOWN; + E->e->u.raw.file[0].idata = E->e->u.raw.file[1].idata = -1; + E->e->u.raw.file[0].subenc = GD_ENC_UNKNOWN; if ((E->e->u.raw.filebase = strdup(E->field)) == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); @@ -214,8 +214,9 @@ ; /* error already set */ else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) ; /* error already set */ - else if ((*_gd_ef[E->e->u.raw.file[0].encoding].touch)( - D->fragment[E->fragment_index].dirfd, E->e->u.raw.file)) + else if ((*_gd_ef[E->e->u.raw.file[0].subenc].touch)( + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, + _GD_FileSwapBytes(D, E->fragment_index))) _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); else if (D->fragment[E->fragment_index].ref_name == NULL) { Modified: trunk/getdata/src/ascii.c =================================================================== --- trunk/getdata/src/ascii.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/ascii.c 2011-08-11 19:36:53 UTC (rev 594) @@ -31,28 +31,35 @@ #include <errno.h> #endif -/* The ASCII encoding uses file->fp as to indicate the current line and +/* The ASCII encoding uses file->idata to indicate the current line and * file->edata for the stream pointer */ -int _GD_AsciiOpen(int dirfd, struct _gd_raw_file* file, int mode, int creat) +int _GD_AsciiOpen(int dirfd, struct _gd_raw_file* file, int swap __gd_unused, + int mode, int creat) { - int fp; + int fd; - dtrace("%i, %p, %i, %i", dirfd, file, mode, creat); + dtrace("%i, %p, <unused>, %i, %i", dirfd, file, mode, creat); - fp = gd_OpenAt(file->D, dirfd, file->name, ((mode == GD_RDWR) ? O_RDWR : + fd = gd_OpenAt(file->D, dirfd, file->name, ((mode == GD_RDWR) ? O_RDWR : O_RDONLY) | (creat ? O_CREAT : 0) | O_BINARY, 0666); - file->edata = fdopen(fp, (mode == GD_RDWR) ? "r+" : "r"); + if (fd < 0) { + dreturn("%i", -1); + return -1; + } - if (file->edata != NULL) { - file->fp = 0; - dreturn("%i", 0); - return 0; + file->edata = fdopen(fd, (mode == GD_RDWR) ? "r+" : "r"); + + if (file->edata == NULL) { + close(fd); + dreturn("%i", -1); + return -1; } - dreturn("%i", -1); - return -1; + file->idata = 0; + dreturn("%i", 0); + return 0; } off64_t _GD_AsciiSeek(struct _gd_raw_file* file, off64_t count, @@ -62,23 +69,23 @@ dtrace("%p, %lli, <unused>, %i", file, count, pad); - if (count < file->fp) { + if (count < file->idata) { rewind((FILE *)file->edata); - file->fp = 0; + file->idata = 0; } - for (; count > file->fp; ++file->fp) + for (; count > file->idata; ++file->idata) if (fgets(line, 64, (FILE *)file->edata) == NULL) break; - if (pad && count > file->fp) { + if (pad && count > file->idata) { strcpy(line, "0\n"); - for (; count > file->fp; ++file->fp) + for (; count > file->idata; ++file->idata) fputs(line, (FILE *)file->edata); } - dreturn("%i", file->fp); - return file->fp; + dreturn("%i", file->idata); + return file->idata; } static void _GD_ScanFormat(char* fmt, gd_type_t data_type) @@ -159,7 +166,7 @@ ret = -1; break; } - file->fp++; + file->idata++; } } else { for (n = 0; n < nmemb; ++n) { @@ -189,7 +196,7 @@ break; } } - file->fp++; + file->idata++; } } @@ -342,7 +349,7 @@ ret = fclose((FILE *)file->edata); if (ret != EOF) { - file->fp = -1; + file->idata = -1; dreturn("%i", 0); return 0; } @@ -352,7 +359,7 @@ } off64_t _GD_AsciiSize(int dirfd, struct _gd_raw_file* file, - gd_type_t data_type __gd_unused) + gd_type_t data_type __gd_unused, int swap __gd_unused) { FILE* stream; char *buffer = NULL; @@ -360,10 +367,10 @@ off64_t n = 0; int fd; - dtrace("%i, %p, <unused>", dirfd, file); + dtrace("%i, %p, <unused>, <unused>", dirfd, file); fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY, 0666); - if (fd == -1) { + if (fd < 0) { dreturn("%i", -1); return -1; } @@ -385,68 +392,41 @@ return n; } -int _GD_AsciiTemp(int dirfd0, int dirfd1, struct _gd_raw_file *file, int method) +int _GD_AsciiTOpen(int fd, struct _gd_raw_file *file, int swap __gd_unused) { - int move_error = 0; - struct stat stat_buf; - mode_t mode; - int fp; + dtrace("%i, %p, <unused>", fd, file); - dtrace("%i, %i, %p, %i", dirfd0, dirfd1, file, method); + file->edata = fdopen(fd, "r+"); - switch(method) { - case GD_TEMP_OPEN: - fp = gd_MakeTempFile(file[1].D, dirfd1, file[1].name); + if (file->edata == NULL) { + dreturn("%i", -1); + return -1; + } - file[1].edata = fdopen(fp, "r+"); + file->idata = 0; - if (file[1].edata == NULL) { + dreturn("%i", 0); + return 0; +} + +int _GD_AsciiTUnlink(int dirfd, struct _gd_raw_file *file) +{ + dtrace("%i, %p", dirfd, file); + + if (file->name != NULL) { + if (file->idata >= 0) + if (_GD_AsciiClose(file)) { dreturn("%i", -1); return -1; } - file[1].fp = 0; - break; - case GD_TEMP_MOVE: - if (file[1].name == NULL) - break; + if (gd_UnlinkAt(file->D, dirfd, file->name, 0)) { + dreturn("%i", -1); + return -1; + } - if (stat(file[0].name, &stat_buf)) - mode = 0644; - else - mode = stat_buf.st_mode; - - if (!gd_RenameAt(file->D, dirfd1, file[1].name, dirfd0, file[0].name)) { - chmod(file[0].name, mode); - free(file[1].name); - file[1].name = NULL; - dreturn("%i", 0); - return 0; - } - move_error = errno; - /* fallthrough on error */ - case GD_TEMP_DESTROY: - if (file[1].name != NULL) { - if (file[1].fp >= 0) - if (_GD_AsciiClose(file + 1)) { - dreturn("%i", -1); - return -1; - } - - if (unlink(file[1].name)) { - dreturn("%i", -1); - return -1; - } - - if (method == GD_TEMP_MOVE) { - errno = move_error; - dreturn("%i", -1); - return -1; - } - free(file[1].name); - file[1].name = NULL; - } - break; + free(file[1].name); + file[1].name = NULL; } dreturn("%i", 0); Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/bzip.c 2011-08-11 19:36:53 UTC (rev 594) @@ -57,7 +57,7 @@ }; /* The bzip encoding scheme uses edata as a gd_bzdata pointer. If a file is - * open, fp = 0 otherwise fp = -1. */ + * open, idata = 0 otherwise idata = -1. */ static struct gd_bzdata *_GD_Bzip2DoOpen(int dirfd, struct _gd_raw_file* file) { @@ -101,10 +101,10 @@ return ptr; } -int _GD_Bzip2Open(int dirfd, struct _gd_raw_file* file, int mode __gd_unused, - int creat __gd_unused) +int _GD_Bzip2Open(int dirfd, struct _gd_raw_file* file, int swap __gd_unused, + int mode __gd_unused, int creat __gd_unused) { - dtrace("%i, %p, <unused>, <unused>", dirfd, file); + dtrace("%i, %p, <unused>, <unused>, <unused>", dirfd, file); file->edata = _GD_Bzip2DoOpen(dirfd, file); @@ -113,7 +113,7 @@ return 1; } - file->fp = 0; + file->idata = 0; dreturn("%i", 0); return 0; } @@ -236,7 +236,7 @@ ptr->bzerror = 0; BZ2_bzReadClose(&ptr->bzerror, ptr->bzfile); if (!fclose(ptr->stream)) { - file->fp = -1; + file->idata = -1; free(file->edata); dreturn("%i", 0); return 0; @@ -246,12 +246,13 @@ return 1; } -off64_t _GD_Bzip2Size(int dirfd, struct _gd_raw_file *file, gd_type_t data_type) +off64_t _GD_Bzip2Size(int dirfd, struct _gd_raw_file *file, gd_type_t data_type, + int swap __gd_unused) { struct gd_bzdata *ptr; off_t n; - dtrace("%i, %p, %x", dirfd, file, data_type); + dtrace("%i, %p, %x, <unused>", dirfd, file, data_type); ptr = _GD_Bzip2DoOpen(dirfd, file); Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/del.c 2011-08-11 19:36:53 UTC (rev 594) @@ -332,7 +332,7 @@ return -1; } - if ((*_gd_ef[E->e->u.raw.file[0].encoding].unlink)( + if ((*_gd_ef[E->e->u.raw.file[0].subenc].unlink)( D->fragment[E->fragment_index].dirfd, E->e->u.raw.file)) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -340,8 +340,8 @@ dreturn("%i", -1); return -1; } - } else if (E->field_type == GD_RAW_ENTRY && E->e->u.raw.file->fp != -1) { - if ((*_gd_ef[E->e->u.raw.file[0].encoding].close)(E->e->u.raw.file)) { + } else if (E->field_type == GD_RAW_ENTRY && E->e->u.raw.file->idata != -1) { + if ((*_gd_ef[E->e->u.raw.file[0].subenc].close)(E->e->u.raw.file)) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); free(del_list); dreturn("%i", -1); Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/encoding.c 2011-08-11 19:36:53 UTC (rev 594) @@ -43,113 +43,105 @@ #endif /* encoding schemas */ +#define GD_EF_NULL_SET NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \ + &_GD_GenericMove, &_GD_GenericUnlink, NULL, &_GD_GenericTMove, NULL +#ifdef USE_MODULES +#define GD_EXT_ENCODING(sc,ex,ec,af,ff) \ +{ sc,ex,ec,af,ff,GD_EF_PROVIDES,GD_EF_NULL_SET } +#else +#define GD_EXT_ENCODING(sc,ex,ec,af,ff) { sc,ex,ec,af,ff,0,GD_INT_FUNCS } +#endif struct encoding_t _gd_ef[GD_N_SUBENCODINGS] = { { GD_UNENCODED, "", 1, NULL, "none", 0, - &_GD_RawOpen, &_GD_RawClose, &_GD_GenericTouch, &_GD_RawSeek, - &_GD_RawRead, &_GD_RawSize, &_GD_RawWrite, &_GD_RawSync, - &_GD_GenericMove, &_GD_GenericUnlink, &_GD_RawTemp + &_GD_RawOpen, &_GD_RawClose, &_GD_GenericTouch, &_GD_RawSeek, &_GD_RawRead, + &_GD_RawSize, &_GD_RawWrite, &_GD_RawSync, &_GD_GenericMove, + &_GD_GenericUnlink, &_GD_RawTOpen, &_GD_GenericTMove, &_GD_RawTUnlink }, -#ifdef USE_MODULES - /* Modules are external */ - { GD_GZIP_ENCODED, ".gz", 1, "Gzip", "gzip", -# ifdef USE_GZIP + +#ifdef USE_GZIP +#define GD_EF_PROVIDES \ + GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE +#define GD_INT_FUNCS \ + &_GD_GzipOpen, &_GD_GzipClose, NULL /* TOUCH */, &_GD_GzipSeek, \ + &_GD_GzipRead, &_GD_GzipSize, NULL /* WRITE */, NULL /* SYNC */, \ + &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ + NULL /* TUNLINK */ +#else +#define GD_EF_PROVIDES 0 +#define GD_INT_FUNCS GD_EF_NULL_SET +#endif + GD_EXT_ENCODING(GD_GZIP_ENCODED, ".gz", 1, "Gzip", "gzip"), +#undef GD_INT_FUNCS +#undef GD_EF_PROVIDES + + +#ifdef USE_BZIP2 +#define GD_EF_PROVIDES \ GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, -# else - 0, -# endif - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL }, - { GD_BZIP2_ENCODED, ".bz2", 1, "Bzip2", "bzip2", -# ifdef USE_BZIP2 +#define GD_INT_FUNCS \ + &_GD_Bzip2Open, &_GD_Bzip2Close, NULL /* TOUCH */, &_GD_Bzip2Seek, \ + &_GD_Bzip2Read, &_GD_Bzip2Size, NULL /* WRITE */, NULL /* SYNC */, \ + &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ + NULL /* TUNLINK */ +#else +#define GD_INT_FUNCS GD_EF_NULL_SET +#define GD_EF_PROVIDES 0 +#endif + GD_EXT_ENCODING(GD_BZIP2_ENCODED, ".bz2", 1, "Bzip2", "bzip2"), +#undef GD_INT_FUNCS +#undef GD_EF_PROVIDES + + +#ifdef USE_SLIM +#define GD_EF_PROVIDES \ + GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, +#define GD_INT_FUNCS \ + &_GD_SlimOpen, &_GD_SlimClose, NULL /* TOUCH */, &_GD_SlimSeek, \ + &_GD_SlimRead, &_GD_SlimSize, NULL /* WRITE */, NULL /* SYNC */, \ + &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ + NULL /* TUNLINK */ +#else +#define GD_INT_FUNCS GD_EF_NULL_SET +#define GD_EF_PROVIDES 0 +#endif + GD_EXT_ENCODING(GD_SLIM_ENCODED, ".slm", 1, "Slim", "slim"), +#undef GD_INT_FUNCS +#undef GD_EF_PROVIDES + + +#ifdef USE_LZMA +#define GD_EF_PROVIDES \ GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, -# else - 0, -# endif - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL }, - { GD_SLIM_ENCODED, ".slm", 1, "Slim", "slim", -# ifdef USE_SLIM - GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, -# else - 0, -# endif - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL }, - { GD_LZMA_ENCODED, ".xz", 1, "Lzma", "lzma", -# ifdef USE_LZMA - GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, -# else - 0, -# endif - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL }, - { GD_LZMA_ENCODED, ".lzma", 1, "Lzma", "lzma", -# ifdef USE_LZMA - GD_EF_OPEN | GD_EF_CLOSE | GD_EF_SEEK | GD_EF_READ | GD_EF_SIZE, -# else - 0, -# endif - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL }, +#define GD_INT_FUNCS \ + &_GD_LzmaOpen, &_GD_LzmaClose, NULL /* TOUCH */, &_GD_LzmaSeek, \ + &_GD_LzmaRead, &_GD_LzmaSize, NULL /* WRITE */, NULL /* SYNC */, \ + &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TOPEN */, &_GD_GenericTMove, \ + NULL /* TUNLINK */ #else - /* Modules are internal */ - { GD_GZIP_ENCODED, ".gz", 1, NULL, "gzip", 0, -# ifdef USE_GZIP - &_GD_GzipOpen, &_GD_GzipClose, NULL /* TOUCH */, - &_GD_GzipSeek, &_GD_GzipRead, &_GD_GzipSize, NULL /* WRITE */, - NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TEMP */ -# else - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL -# endif - }, - { GD_BZIP2_ENCODED, ".bz2", 1, NULL, "bzip2", 0, -# ifdef USE_BZIP2 - &_GD_Bzip2Open, &_GD_Bzip2Close, NULL /* TOUCH */, - &_GD_Bzip2Seek, &_GD_Bzip2Read, &_GD_Bzip2Size, NULL /* WRITE */, - NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TEMP */ -# else - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL -# endif - }, - { GD_SLIM_ENCODED, ".slm", 1, NULL, "slim", 0, -# ifdef USE_SLIM - &_GD_SlimOpen, &_GD_SlimClose, NULL /* TOUCH */, - &_GD_SlimSeek, &_GD_SlimRead, &_GD_SlimSize, NULL /* WRITE */, - NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TEMP */ -# else - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL -# endif - }, - { GD_LZMA_ENCODED, ".xz", 1, NULL, "lzma", 0, -# ifdef USE_LZMA - &_GD_LzmaOpen, &_GD_LzmaClose, NULL /* TOUCH */, - &_GD_LzmaSeek, &_GD_LzmaRead, &_GD_LzmaSize, NULL /* WRITE */, - NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TEMP */ -# else - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL +#define GD_INT_FUNCS GD_EF_NULL_SET +#define GD_EF_PROVIDES 0 #endif - }, - { GD_LZMA_ENCODED, ".lzma", 1, NULL, "lzma", 0, -# ifdef USE_LZMA - &_GD_LzmaOpen, &_GD_LzmaClose, NULL /* TOUCH */, - &_GD_LzmaSeek, &_GD_LzmaRead, &_GD_LzmaSize, NULL /* WRITE */, - NULL /* SYNC */, &_GD_GenericMove, &_GD_GenericUnlink, NULL /* TEMP */ -# else - NULL, NULL, NULL, NULL, NULL, NULL, NULL , NULL, &_GD_GenericMove, - &_GD_GenericUnlink, NULL -# endif - }, -#endif + GD_EXT_ENCODING(GD_LZMA_ENCODED, ".xz", 1, "Lzma", "lzma"), + GD_EXT_ENCODING(GD_LZMA_ENCODED, ".lzma", 1, "Lzma", "lzma"), +#undef GD_INT_FUNCS +#undef GD_EF_PROVIDES + + { GD_TEXT_ENCODED, ".txt", 0, NULL, "text", 0, - &_GD_AsciiOpen, &_GD_AsciiClose, &_GD_GenericTouch, - &_GD_AsciiSeek, &_GD_AsciiRead, &_GD_AsciiSize, &_GD_AsciiWrite, - &_GD_AsciiSync, &_GD_GenericMove, &_GD_GenericUnlink, &_GD_AsciiTemp }, + &_GD_AsciiOpen, &_GD_AsciiClose, &_GD_GenericTouch, &_GD_AsciiSeek, + &_GD_AsciiRead, &_GD_AsciiSize, &_GD_AsciiWrite, &_GD_AsciiSync, + &_GD_GenericMove, &_GD_GenericUnlink, &_GD_AsciiTOpen, &_GD_GenericTMove, + &_GD_AsciiTUnlink }, + + { GD_SIE_ENCODED, ".sie", 0, NULL, "sie", 0, + &_GD_SampIndOpen, &_GD_SampIndClose, &_GD_GenericTouch, &_GD_SampIndSeek, + &_GD_SampIndRead, &_GD_SampIndSize, &_GD_SampIndWrite, &_GD_SampIndSync, + &_GD_GenericMove, &_GD_GenericUnlink, &_GD_SampIndTOpen, &_GD_GenericTMove, + &_GD_SampIndTUnlink }, + { GD_ENC_UNSUPPORTED, "", 0, "", "", 0, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL + }, }; void _GD_InitialiseFramework(void) @@ -173,7 +165,8 @@ #define _GD_EncodingUnderstood(encoding) \ ((encoding == GD_UNENCODED || encoding == GD_SLIM_ENCODED || \ encoding == GD_GZIP_ENCODED || encoding == GD_BZIP2_ENCODED || \ - encoding == GD_TEXT_ENCODED || encoding == GD_LZMA_ENCODED)) + encoding == GD_TEXT_ENCODED || encoding == GD_LZMA_ENCODED || \ + encoding == GD_SIE_ENCODED)) #ifdef USE_MODULES static void* _GD_ResolveSymbol(lt_dlhandle lib, struct encoding_t* enc, @@ -275,8 +268,11 @@ struct _gd_raw_file*))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Unlink"); if (_gd_ef[encoding].provides & GD_EF_TEMP) - _gd_ef[encoding].temp = (int (*)(int, int, struct _gd_raw_file*, + _gd_ef[encoding].temp = (int (*)(int, int, struct _gd_raw_file*, int, int))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Temp"); + if (_gd_ef[encoding].provides & GD_EF_TOPEN) + _gd_ef[encoding].topen = (gd_ef_topen_t)_GD_ResolveSymbol(lib, + _gd_ef + encoding, "TOpen"); /* we tried our best, don't bother trying again */ _gd_ef[encoding].provides = 0; @@ -287,16 +283,18 @@ #endif ret = - (funcs & GD_EF_OPEN && _gd_ef[encoding].open == NULL) || - (funcs & GD_EF_CLOSE && _gd_ef[encoding].close == NULL) || - (funcs & GD_EF_TOUCH && _gd_ef[encoding].touch == NULL) || - (funcs & GD_EF_SEEK && _gd_ef[encoding].seek == NULL) || - (funcs & GD_EF_READ && _gd_ef[encoding].read == NULL) || - (funcs & GD_EF_SIZE && _gd_ef[encoding].size == NULL) || - (funcs & GD_EF_WRITE && _gd_ef[encoding].write == NULL) || - (funcs & GD_EF_SYNC && _gd_ef[encoding].sync == NULL) || - (funcs & GD_EF_UNLINK && _gd_ef[encoding].unlink == NULL) || - (funcs & GD_EF_TEMP && _gd_ef[encoding].temp == NULL); + (funcs & GD_EF_OPEN && _gd_ef[encoding].open == NULL) || + (funcs & GD_EF_CLOSE && _gd_ef[encoding].close == NULL) || + (funcs & GD_EF_TOUCH && _gd_ef[encoding].touch == NULL) || + (funcs & GD_EF_SEEK && _gd_ef[encoding].seek == NULL) || + (funcs & GD_EF_READ && _gd_ef[encoding].read == NULL) || + (funcs & GD_EF_SIZE && _gd_ef[encoding].size == NULL) || + (funcs & GD_EF_WRITE && _gd_ef[encoding].write == NULL) || + (funcs & GD_EF_SYNC && _gd_ef[encoding].sync == NULL) || + (funcs & GD_EF_UNLINK && _gd_ef[encoding].unlink == NULL) || + (funcs & GD_EF_TOPEN && _gd_ef[encoding].topen == NULL) || + (funcs & GD_EF_TMOVE && _gd_ef[encoding].tmove == NULL) || + (funcs & GD_EF_TUNLINK && _gd_ef[encoding].tunlink == NULL); dreturn("%i", ret); return ret; @@ -322,7 +320,7 @@ if (gd_StatAt(D, dirfd, candidate, &statbuf, 0) == 0) if (S_ISREG(statbuf.st_mode)) { if (file != NULL) - file->encoding = i; + file->subenc = i; free(candidate); dreturn("%08lx", _gd_ef[i].scheme); return _gd_ef[i].scheme; @@ -334,7 +332,7 @@ if (scheme != 0 && file != NULL) { for (i = 0; _gd_ef[i].scheme != GD_ENC_UNSUPPORTED; i++) if (scheme == _gd_ef[i].scheme) { - file->encoding = i; + file->subenc = i; dreturn("0x%08lx", _gd_ef[i].scheme); return _gd_ef[i].scheme;; } @@ -357,19 +355,19 @@ /* If the encoding scheme is unknown, complain */ if (D->fragment[E->fragment_index].encoding == GD_AUTO_ENCODED) { - _GD_SetError(D, GD_E_UNKNOWN_ENCODING, 0, NULL, 0, NULL); + _GD_SetError(D, GD_E_UNKNOWN_ENCODING, GD_E_UNENC_UNDET, NULL, 0, NULL); dreturn("%i", 0); return 0; } /* Figure out the encoding subtype, if required */ - if (E->e->u.raw.file[0].encoding == GD_ENC_UNKNOWN) + if (E->e->u.raw.file[0].subenc == GD_ENC_UNKNOWN) _GD_ResolveEncoding(D, E->e->u.raw.filebase, D->fragment[E->fragment_index].encoding, D->fragment[E->fragment_index].dirfd, E->e->u.raw.file); /* check for our function(s) */ - if (_GD_MissingFramework(E->e->u.raw.file[0].encoding, funcs)) { + if (_GD_MissingFramework(E->e->u.raw.file[0].subenc, funcs)) { _GD_SetError(D, GD_E_UNSUPPORTED, 0, NULL, 0, NULL); dreturn("%i", 0); return 0; @@ -387,7 +385,7 @@ if (file->name == NULL) { file->D = D; file->name = (char *)malloc(strlen(base) + (temp ? 8 : - strlen(_gd_ef[file->encoding].ext) + 1)); + strlen(_gd_ef[file->subenc].ext) + 1)); if (file->name == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); dreturn("%i", -1); @@ -395,7 +393,7 @@ } strcat(strcpy(file->name, base), temp ? "_XXXXXX" : - _gd_ef[file->encoding].ext); + _gd_ef[file->subenc].ext); } dreturn("%i (%s)", 0, file->name); @@ -450,10 +448,10 @@ * remove the temporary files */ if (D->error) { for (i = 0; i < n_raw; ++i) - if (_gd_ef[raw_entry[i]->e->u.raw.file[1].encoding].temp != NULL && - (*_gd_ef[raw_entry[i]->e->u.raw.file[1].encoding].temp)( - D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, GD_TEMP_DESTROY)) + if (!_GD_MissingFramework(raw_entry[i]->e->u.raw.file[1].subenc, + GD_EF_TUNLINK) && + (*_gd_ef[raw_entry[i]->e->u.raw.file[1].subenc].tunlink)( + D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file + 1)) { _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, errno, NULL); @@ -464,32 +462,32 @@ memcpy(&temp, raw_entry[i]->e->u.raw.file, sizeof(temp)); raw_entry[i]->e->u.raw.file[0].name = NULL; - raw_entry[i]->e->u.raw.file[0].encoding = - raw_entry[i]->e->u.raw.file[1].encoding; + raw_entry[i]->e->u.raw.file[0].subenc = + raw_entry[i]->e->u.raw.file[1].subenc; if (_GD_SetEncodedName(D, raw_entry[i]->e->u.raw.file, raw_entry[i]->e->u.raw.filebase, 0)) { raw_entry[i]->e->u.raw.file[0].name = temp.name; - raw_entry[i]->e->u.raw.file[0].encoding = temp.encoding; - } else if ( - (*_gd_ef[raw_entry[i]->e->u.raw.file[1].encoding].temp)( + raw_entry[i]->e->u.raw.file[0].subenc = temp.subenc; + } else if ((*_gd_ef[raw_entry[i]->e->u.raw.file[1].subenc].tmove)( D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, GD_TEMP_MOVE)) + raw_entry[i]->e->u.raw.file, + _gd_ef[raw_entry[i]->e->u.raw.file[1].subenc].tunlink)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); D->flags |= GD_INVALID; raw_entry[i]->e->u.raw.file[0].name = temp.name; - raw_entry[i]->e->u.raw.file[0].encoding = temp.encoding; - } else if ((*_gd_ef[temp.encoding].unlink)(D->fragment[fragment].dirfd, + raw_entry[i]->e->u.raw.file[0].subenc = temp.subenc; + } else if ((*_gd_ef[temp.subenc].unlink)(D->fragment[fragment].dirfd, &temp)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); D->flags |= GD_INVALID; raw_entry[i]->e->u.raw.file[0].name = temp.name; - raw_entry[i]->e->u.raw.file[0].encoding = temp.encoding; + raw_entry[i]->e->u.raw.file[0].subenc = temp.subenc; } else free(temp.name); } @@ -506,8 +504,8 @@ D->entry[i]->field_type == GD_RAW_ENTRY) { /* close the old file */ - if (D->entry[i]->e->u.raw.file[0].fp != -1 && - (*_gd_ef[D->entry[i]->e->u.raw.file[0].encoding].close)( + if (D->entry[i]->e->u.raw.file[0].idata != -1 && + (*_gd_ef[D->entry[i]->e->u.raw.file[0].subenc].close)( D->entry[i]->e->u.raw.file)) { _GD_SetError(D, GD_E_RAW_IO, 0, D->entry[i]->e->u.raw.file[1].name, @@ -515,7 +513,7 @@ break; } /* reset encoding subscheme. */ - D->entry[i]->e->u.raw.file[0].encoding = GD_ENC_UNKNOWN; + D->entry[i]->e->u.raw.file[0].subenc = GD_ENC_UNKNOWN; } } @@ -552,7 +550,7 @@ } if (!_GD_EncodingUnderstood(encoding)) { - _GD_SetError(D, GD_E_UNKNOWN_ENCODING, 0, NULL, 0, NULL); + _GD_SetError(D, GD_E_UNKNOWN_ENCODING, GD_E_UNENC_TARGET, NULL, 0, NULL); dreturn("%i", -1); return -1; } @@ -625,7 +623,7 @@ * 2) use mktemp to generate a "unique" file name, and then try to openat it * exclusively; repeat as necessary. */ -int gd_MakeTempFile(const DIRFILE *D gd_unused_d, int dirfd, char *template) +int _GD_MakeTempFile(const DIRFILE *D gd_unused_d, int dirfd, char *template) { int fd = -1; char *tmp = strdup(template); @@ -655,11 +653,11 @@ return fd; } -int _GD_GenericTouch(int dirfd, struct _gd_raw_file* file) +int _GD_GenericTouch(int dirfd, struct _gd_raw_file* file, int swap __gd_unused) { int fd; - dtrace("%i, %p", dirfd, file); + dtrace("%i, %p, <unused>", dirfd, file); fd = gd_OpenAt(file->D, dirfd, file->name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0666); @@ -705,5 +703,44 @@ dreturn("%i", r); return r; } + +int _GD_GenericTMove(int dirfd0, int dirfd1, struct _gd_raw_file *file, + gd_ef_tunlink_t tunlink) +{ +#ifdef HAVE_FCHMOD + struct stat stat_buf; + mode_t mode; +#endif + dtrace("%i, %i, %p, %p", dirfd0, dirfd1, file, tunlink); + + if (file[1].name == NULL) { + dreturn("%i", 0); + return 0; + } + +#ifdef HAVE_FCHMOD + if (gd_StatAt(file[0].D, dirfd0, file[0].name, &stat_buf, 0)) + mode = 0644; + else + mode = stat_buf.st_mode; +#endif + + if (gd_RenameAt(file->D, dirfd1, file[1].name, dirfd0, file[0].name)) { + int move_errno = errno; + (*tunlink)(dirfd1, file + 1); + errno = move_errno; + dreturn("%i", -1); + return -1; + } + +#ifdef HAVE_FCHMOD + int fd = gd_OpenAt(file->D, dirfd0, file[0].name, O_RDONLY, 0666); + fchmod(fd, mode); + close(fd); +#endif + + dreturn("%i", 0); + return 0; +} /* vim: ts=2 sw=2 et tw=80 */ Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/endian.c 2011-08-11 19:36:53 UTC (rev 594) @@ -70,7 +70,7 @@ continue; /* check subencoding support */ - if (!_GD_Supports(D, D->entry[i], GD_EF_TEMP)) + if (!_GD_Supports(D, D->entry[i], GD_EF_TMOVE | GD_EF_TUNLINK)) break; /* add this raw field to the list */ @@ -87,16 +87,18 @@ * remove the temporary files */ if (D->error) { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( - D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, GD_TEMP_DESTROY)) + if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)( + D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file + 1)) + { _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, errno, NULL); + } } else { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( + if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tmove)( D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, GD_TEMP_MOVE)) + raw_entry[i]->e->u.raw.file, + _gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); @@ -202,24 +204,26 @@ dreturnvoid(); } -void _GD_FixEndianness(char* databuffer, size_t size, size_t ns) +void _GD_FixEndianness(void* databuffer, size_t size, size_t ns) { - size_t i, j; - char b; + size_t i; dtrace("%p, %zu, %zu", databuffer, size, ns); - if (size == 1) { - dreturnvoid(); - return; + switch (size) { + case 2: + for (i = 0; i < ns; ++i) + ((uint16_t*)databuffer)[i] = gd_swap16(((uint16_t*)databuffer)[i]); + break; + case 4: + for (i = 0; i < ns; ++i) + ((uint32_t*)databuffer)[i] = gd_swap32(((uint32_t*)databuffer)[i]); + break; + case 8: + for (i = 0; i < ns; ++i) + ((uint64_t*)databuffer)[i] = gd_swap64(((uint64_t*)databuffer)[i]); + break; } - for (i = 0; i < ns; ++i) - for (j = 0; j < size / 2; ++j) { - b = databuffer[size * (i + 1) - j - 1]; - databuffer[size * (i + 1) - j - 1] = databuffer[size * i + j]; - databuffer[size * i + j] = b; - } - dreturnvoid(); } Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/entry.c 2011-08-11 19:36:53 UTC (rev 594) @@ -307,8 +307,8 @@ return NULL; } - if (E->e->u.raw.file[0].encoding == GD_ENC_UNKNOWN) { - _GD_SetError(D, GD_E_UNKNOWN_ENCODING, 0, NULL, 0, NULL); + if (E->e->u.raw.file[0].subenc == GD_ENC_UNKNOWN) { + _GD_SetError(D, GD_E_UNKNOWN_ENCODING, GD_E_UNENC_UNDET, NULL, 0, NULL); dreturn("%p", NULL); return NULL; } else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/errors.c 2011-08-11 19:36:53 UTC (rev 594) @@ -117,7 +117,10 @@ { GD_E_UNSUPPORTED, 0, "Operation not supported by current encoding scheme", 0 }, /* GD_E_UNKNOWN_ENCODING: (nothing) */ - { GD_E_UNKNOWN_ENCODING, 0, "Unable to determine encoding scheme", 0 }, + { GD_E_UNKNOWN_ENCODING, GD_E_UNENC_UNDET, + "Unable to determine encoding scheme", 0 }, + { GD_E_UNKNOWN_ENCODING, GD_E_UNENC_TARGET, "Unknown ouput encoding scheme", + 0 }, /* GD_E_BAD_ENTRY: 3 = parameter */ { GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_TYPE, "Invalid entry type: {3}", 0 }, { GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_SPF, "Samples per frame out of range: {3}", Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/flimits.c 2011-08-11 19:36:53 UTC (rev 594) @@ -57,7 +57,7 @@ if (D->entry[i]->fragment_index == fragment && D->entry[i]->field_type == GD_RAW_ENTRY) { - if (!_GD_Supports(D, D->entry[i], GD_EF_TEMP)) + if (!_GD_Supports(D, D->entry[i], GD_EF_TMOVE | GD_EF_TUNLINK)) break; /* add this raw field to the list */ @@ -74,16 +74,18 @@ * remove the temporary files */ if (D->error) { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( - D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, GD_TEMP_DESTROY)) + if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)( + D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file + 1)) + { _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, errno, NULL); + } } else { for (i = 0; i < n_raw; ++i) - if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( + if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tmove)( D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, - raw_entry[i]->e->u.raw.file, GD_TEMP_MOVE)) + raw_entry[i]->e->u.raw.file, + _gd_ef[raw_entry[i]->e->u.raw.file[0].subenc].tunlink)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); @@ -210,9 +212,9 @@ if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) break; - ns = (*_gd_ef[E->e->u.raw.file[0].encoding].size)( + ns = (*_gd_ef[E->e->u.raw.file[0].subenc].size)( D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - E->EN(raw,data_type)); + E->EN(raw,data_type), _GD_FileSwapBytes(D, E->fragment_index)); if (ns < 0) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/flush.c 2011-08-11 19:36:53 UTC (rev 594) @@ -51,13 +51,13 @@ switch(E->field_type) { case GD_RAW_ENTRY: - if (E->e->u.raw.file[0].fp >= 0) { + if (E->e->u.raw.file[0].idata >= 0) { if ((D->flags & GD_ACCMODE) == GD_RDWR && - _gd_ef[E->e->u.raw.file[0].encoding].sync != NULL && - (*_gd_ef[E->e->u.raw.file[0].encoding].sync)(E->e->u.raw.file)) + _gd_ef[E->e->u.raw.file[0].subenc].sync != NULL && + (*_gd_ef[E->e->u.raw.file[0].subenc].sync)(E->e->u.raw.file)) _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); - else if ((*_gd_ef[E->e->u.raw.file[0].encoding].close)( + else if ((*_gd_ef[E->e->u.raw.file[0].subenc].close)( E->e->u.raw.file)) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, @@ -446,7 +446,7 @@ mode = stat_buf.st_mode; /* open a temporary file */ - fd = gd_MakeTempFile(D, dirfd, temp_file); + fd = _GD_MakeTempFile(D, dirfd, temp_file); if (fd == -1) { _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_MKTMP, NULL, errno, temp_file); dreturnvoid(); Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/getdata.c 2011-08-11 19:36:53 UTC (rev 594) @@ -293,7 +293,7 @@ if (ns > 0) { /** open the file (and cache the fp) if it hasn't been opened yet. */ - if (E->e->u.raw.file[0].fp < 0) { + if (E->e->u.raw.file[0].idata < 0) { if (!_GD_Supports(D, E, GD_EF_OPEN | GD_EF_SEEK | GD_EF_READ)) { free(databuffer); dreturn("%i", 0); @@ -304,9 +304,9 @@ free(databuffer); dreturn("%i", 0); return 0; - } else if ((*_gd_ef[E->e->u.raw.file[0].encoding].open)( + } else if ((*_gd_ef[E->e->u.raw.file[0].subenc].open)( D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, - D->flags & GD_ACCMODE, 0)) + _GD_FileSwapBytes(D, E->fragment_index), D->flags & GD_ACCMODE, 0)) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -316,7 +316,7 @@ } } - if ((*_gd_ef[E->e->u.raw.file[0].encoding].seek)(E->e->u.raw.file, s0, + if ((*_gd_ef[E->e->u.raw.file[0].subenc].seek)(E->e->u.raw.file, s0, E->EN(raw,data_type), 0) == -1) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); @@ -326,7 +326,7 @@ } samples_read = - (*_gd_ef[E->e->u.raw.file[0].encoding].read)(E->e->u.raw.file, + (*_gd_ef[E->e->u.raw.file[0].subenc].read)(E->e->u.raw.file, databuffer + n_read * E->e->u.raw.size, E->EN(raw,data_type), ns); if (samples_read == -1) { @@ -336,7 +336,7 @@ return 0; } - if (_gd_ef[E->e->u.raw.file[0].encoding].ecor) { + if (_gd_ef[E->e->u.raw.file[0].subenc].ecor) { /* convert to/from middle-ended doubles */ if ((E->EN(raw,data_type) == GD_FLOAT64 || E->EN(raw,data_type) == GD_COMPLEX128) && Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/getdata.h.in 2011-08-11 19:36:53 UTC (rev 594) @@ -393,13 +393,14 @@ #define GD_ENCODING 0x0F000000 /* mask */ #define GD_AUTO_ENCODED 0x00000000 /* Encoding scheme unknown */ -#define GD_UNENCODED 0x01000000 /* Dirfile is not encoded */ -#define GD_TEXT_ENCODED 0x02000000 /* Dirfile is text encoded */ -#define GD_SLIM_ENCODED 0x03000000 /* Dirfile is slimlib encoded */ -#define GD_GZIP_ENCODED 0x04000000 /* Dirfile is gzip encoded */ -#define GD_BZIP2_ENCODED 0x05000000 /* Dirfile is bzip2 encoded */ -#define GD_LZMA_ENCODED 0x06000000 /* Dirfile is xz encoded */ -#define GD_ENC_UNSUPPORTED GD_ENCODING /* Dirfile encoding unsupported */ +#define GD_UNENCODED 0x01000000 /* Data are not encoded */ +#define GD_TEXT_ENCODED 0x02000000 /* Data are text encoded */ +#define GD_SLIM_ENCODED 0x03000000 /* Data are slimlib encoded */ +#define GD_GZIP_ENCODED 0x04000000 /* Data are gzip encoded */ +#define GD_BZIP2_ENCODED 0x05000000 /* Data are bzip2 encoded */ +#define GD_LZMA_ENCODED 0x06000000 /* Data are xz encoded */ +#define GD_SIE_ENCODED 0x07000000 /* Data are sample index encoded */ +#define GD_ENC_UNSUPPORTED GD_ENCODING /* Encoding unsupported */ /* delete flags */ #define GD_DEL_META 0x1 Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/gzip.c 2011-08-11 19:36:53 UTC (rev 594) @@ -42,14 +42,14 @@ #endif /* The zlib encoding scheme uses edata as a gzFile object. If a file is - * open, fp = 0 otherwise fp = -1. */ + * open, idata = 0 otherwise idata = -1. */ -int _GD_GzipOpen(int dirfd, struct _gd_raw_file* file, int mode __gd_unused, - int creat __gd_unused) +int _GD_GzipOpen(int dirfd, struct _gd_raw_file* file, int swap __gd_unused, + int mode __gd_unused, int creat __gd_unused) { int fd; - dtrace("%i, %p, <unused>, <unused>", dirfd, file); + dtrace("%i, %p, <unused>, <unused>, <unused>", dirfd, file); fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); @@ -61,7 +61,7 @@ file->edata = gzdopen(fd, "r"); if (file->edata != NULL) { - file->fp = 0; + file->idata = 0; dreturn("%i", 0); return 0; } @@ -113,7 +113,7 @@ ret = gzclose(file->edata); if (!ret) { - file->fp = -1; + file->idata = -1; file->edata = NULL; } @@ -121,12 +121,13 @@ return ret; } -off64_t _GD_GzipSize(int dirfd, struct _gd_raw_file *file, gd_type_t data_type) +off64_t _GD_GzipSize(int dirfd, struct _gd_raw_file *file, gd_type_t data_type, + int swap __gd_unused) { int fd; uint32_t size = 0; - dtrace("%i, %p, %x", file, data_type); + dtrace("%i, %p, %x, <unused>", dirfd, file, data_type); fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); if (fd < 0) { Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-08-10 10:17:09 UTC (rev 593) +++ trunk/getdata/src/internal.h 2011-08-11 19:36:53 UTC (rev 594) @@ -288,6 +288,16 @@ # define gd_stat64 stat #endif +#if HAVE_FSTAT64 +# define gd_fstat64 fstat64 +#elif HAVE__FSTAT64 +# define gd_fstat64 _fstat64 +#elif HAVE__FSTAT +# define gd_fstat64 _fstat +#else +# define gd_fstat64 fstat +#endif + #if HAVE_STRUCT_STAT64 typedef struct stat64 gd_stat64_t; #elif HAVE_STRUCT__STAT64 @@ -342,6 +352,16 @@ #endif #endif +#if defined HAVE_FTRUNCATE64 +#define gd_truncate ftruncate64 +#elif defined HAVE_FTRUNCATE +#define gd_truncate(d,l) ftruncate(d, (off_t)l) +#elif defined HAVE__CHSIZE_S +#define gd_truncate(d,l) _chsize_s(d, (int64_t)l) +#elif defined HAVE__CHSIZE +#define gd_truncate(d,l) _chsize(d, (long)l) +#endif + #if defined __MSVCRT__ && defined HAVE__UNLINK #define unlink _unlink #endif @@ -354,7 +374,47 @@ ssize_t getdelim(char**, size_t*, int, FILE*); #endif +/* byte swapping */ +#ifdef HAVE_BYTESWAP_H +#include <byteswap.h> +#endif +#ifdef HAVE_SYS_ENDIAN_H +#include <sys/endian.h> +#endif +#ifdef HAVE_LIBKERN_OSBYTEORDER_H +#include <libkern/OSByteOrder.h> +#endif +#if defined HAVE_DECL_BSWAP_16 && HAVE_DECL_BSWAP_16 == 1 +# define gd_swap16 bswap_16 +# define gd_swap32 bswap_32 +# define gd_swap64 bswap_64 +#elif defined HAVE_DECL_OSSWAPINT16 && HAVE_DECL_OSSWAPINT16 == 1 +# define gd_swap16 OSSwapInt16 +# define gd_swap32 OSSwapInt32 +# define gd_swap64 OSSwapInt64 +#elif defined HAVE_DECL_BSWAP16 && HAVE_DECL_BSWAP16 == 1 +# define gd_swap16 bswap16 +# define gd_swap32 bswap32 +# define gd_swap64 bswap64 +#else +# define gd_swap16(x) (((uint16_t)(x) << 8) | ((uint16_t)(x) >> 8)) +# define gd_swap32(x) ( \ + (((uint32_t)(x) << 24) & 0xff000000UL) | \ + (((uint32_t)(x) << 8) & 0xff0000UL) | \ + (((uint32_t)(x) >> 8) & 0xff00UL) | \ + ((uint32_t)(x) >> 24)) +#define gd_swap64(x) ( \ + (((uint64_t)(x) << 56) | \\ + (((uint64_t)(x) << 40) & 0xff000000000000ULL) | \\ + (((uint64_t)(x) << 24) & 0xff0000000000ULL) | \\ + (((uint64_t)(x) << 8) & 0xff00000000ULL) | \\ + (((uint64_t)(x) >> 8) & 0xff000000ULL) | \\ + (((uint64_t)(x) >> 24) & 0xff0000ULL) | \\ + (((uint64_t)(x) >> 40) & 0xff00ULL) | \\ + ((uint64_t)(x) >> 56)) +#endif + /* maximum number of recursions */ #define GD_MAX_RECURSE_LEVEL 32 @@ -421,14 +481,17 @@ #define GD_E_FLUSH_OPEN 2 #define GD_E_FLUSH_RENAME 3 +#define GD_E_UNENC_UNDET 1 +#define GD_E_UNENC_TARGET 2 + #define GD_E_VERS_NONE 1 #define GD_E_VERS_MISSING 2 struct _gd_raw_file { char* name; - int fp; + int idata; void* edata; - int encoding; + int subenc; const DIRFILE *D; }; @@ -494,26 +557,25 @@ #define GD_ENC_ASCII 4 #define GD_ENC_LZMA_RAW 5 #define GD_ENC_XZ_RAW 6 -#define GD_ENC_UNKNOWN 7 +#define GD_ENC_SIE 7 +#define GD_ENC_UNKNOWN 8 #define GD_N_SUBENCODINGS (GD_ENC_UNKNOWN + 1) -#define GD_EF_OPEN 0x001 -#define GD_EF_CLOSE 0x002 -#define GD_EF_TOUCH 0x004 -#define GD_EF_SEEK 0x008 -#define GD_EF_READ 0x010 -#define GD_EF_SIZE 0x020 -#define GD_EF_WRITE 0x040 -#define GD_EF_SYNC 0x080 -#define GD_EF_MOVE 0x100 -#define GD_EF_UNLINK 0x200 -#define GD_EF_TEMP 0x400 +#define GD_EF_OPEN 0x0001 +#define GD_EF_CLOSE 0x0002 +#define GD_EF_TOUCH 0x0004 +#define GD_EF_SEEK 0x0008 +#define GD_EF_READ 0x0010 +#define GD_EF_SIZE 0x0020 +#define GD_EF_WRITE 0x0040 +#define GD_EF_SYNC 0x0080 +#define GD_EF_MOVE 0x0100 +#define GD_EF_UNLINK 0x0200 +#define GD_EF_TOPEN 0x0400 +#define GD_EF_TMOVE 0x0800 +#define GD_EF_TUNLINK 0x1000 -#define GD_TEMP_OPEN 0 -#define GD_TEMP_MOVE 1 -#define GD_TEMP_DESTROY 2 - #define BUFFER_SIZE 9000000 #ifndef HAVE_OFF64_T @@ -530,6 +592,21 @@ # define SCREWY_FLOATS #endif +typedef off64_t (*gd_ef_seek_t)(struct _gd_raw_file*, off64_t, gd_type_t, int); +typedef off64_t (*gd_ef_size_t)(int, struct _gd_raw_file*, gd_type_t, int); +typedef ssize_t (*gd_ef_read_t)(struct _gd_raw_file*, void*, gd_type_t, size_t); +typedef ssize_t (*gd_ef_write_t)(struct _gd_raw_file*, const void*, gd_type_t, + size_t); +typedef int (*gd_ef_close_t)(struct _gd_raw_file*); +typedef int (*gd_ef_sync_t)(struct _gd_raw_file*); +typedef int (*gd_ef_tunlink_t)(int, struct _gd_raw_file*); +typedef int (*gd_ef_unlink_t)(int, struct _gd_raw_file*); +typedef int (*gd_ef_topen_t)(int, struct _gd_raw_file*, int); +typedef int (*gd_ef_touch_t)(int, struct _gd_raw_file*, int); +typedef int (*gd_ef_move_t)(int, struct _gd_raw_file*, int, char*); +typedef int (*gd_ef_open_t)(int, struct _gd_raw_file*, int, int, int); +typedef int (*gd_ef_tmove_t)(int, int, struct _gd_raw_file*, gd_ef_tunlink_t); + /* Encoding schemes */ extern struct encoding_t { unsigned long int scheme; @@ -538,18 +615,19 @@ const char* affix; const char* ffname; unsigned int provides; - int (*open)(int, struct _gd_raw_file*, int, int); - int (*close)(struct _gd_raw_file*); - int (*touch)(int, struct _gd_raw_file*); - off64_t (*seek)(struct _gd_raw_file*, off64_t, gd_type_t, int); - ssize_t (*read)(struct _gd_raw_file*, void*, gd_type_t, size_t); - off64_t (*size)(int, struct _gd_raw_file*, gd_type_t); - ssize_t (*write)(struct _gd_raw_file*, const void*, gd_type_t, - size_t); - int (*sync)(struct _gd_raw_file*); - int (*move)(int, struct _gd_raw_file*, int, char*); - int (*unlink)(int, struct _gd_raw_file*); - int (*temp)(int, int, struct _gd_raw_file*, int); + gd_ef_open_t open; + gd_ef_close_t close; + gd_ef_touch_t touch; + gd_ef_seek_t seek; + gd_ef_read_t read; + gd_ef_size_t size; + gd_ef_write_t write; + gd_ef_sync_t sync; + gd_ef_move_t move; + gd_ef_unlink_t unlink; + gd_ef_topen_t topen; + gd_ef_tmove_t tmove; + gd_ef_tunlink_t tunlink; } _gd_ef[GD_N_SUBENCODINGS]; /* Format file fragment metadata */ @@ -681,7 +759,12 @@ gd_entry_t* _GD_FindFieldAndRepr(DIRFILE* D, const char* field_code_in, char** field_code, int* repr, unsigned int *index, int set); uint64_t _GD_FindVersion(DIRFILE *D); -void _GD_FixEndianness(char* databuffer, size_t size, size_t ns); +void _GD_FixEndianness(void* databuffer, size_t size, size_t ns); +#ifdef WORDS_BIGENDIAN +#define _GD_FileSwapBytes(D,i) ((D)->fragment[i].byte_sex & GD_LITTLE_ENDIAN) +#else +#define _GD_FileSwapBytes(D,i) ((D)->fragment[i].byte_sex & GD_BIG_ENDIAN) +#endif void _GD_Flush(DIRFILE* D, gd_entry_t *E); void _GD_FlushMeta(DIRFILE* D, int fragment, int force); void _GD_FreeE(DIRFILE *D, gd_entry_t* E, int priv); @@ -707,7 +790,7 @@ const double *data_in, size_t npts, const struct _gd_lut *lut, size_t n_ln); #define _GD_MakeFullPath gd_MakeFullPath char *_GD_MakeFullPath(const DIRFILE *D, int dirfd, const char *name); -int gd_MakeTempFile(const DIRFILE*, int, char*); +int _GD_MakeTempFile(const DIRFILE*, int, char*); int _GD_MissingFramework(int encoding, unsigned int funcs); int _GD_MogrifyFile(DIRFILE* D, gd_entry_t* E, unsigned long int encoding, unsigned long int byte_sex, off64_t offset, int finalise, int new_fragment, @@ -734,12 +817,13 @@ int standards, int pedantic, int* is_dot); /* generic I/O methods */ -int _GD_GenericTouch(int, struct _gd_raw_file* file); +int _GD_GenericTouch(int, struct _gd_raw_file* file, int); int _GD_GenericMove(int, struct _gd_raw_file* file, int, char* new_path); int _GD_GenericUnlink(int, struct _gd_raw_file* file); +int _GD_GenericTMove(int, int, struct _gd_raw_file*, gd_ef_tunlink_t); /* unencoded I/O methods */ -int _GD_RawOpen(int, struct _gd_raw_file* file, int mode, int creat); +int _GD_RawOpen(int, struct _gd_raw_file* file, int swap, int mode, int creat); off64_t _GD_RawSeek(struct _gd_raw_file* file, off64_t count, gd_type_t data_type, int pad); ssize_t _GD_RawRead(struct _gd_raw_file* file, void *ptr, gd_type_t data_type, @@ -748,11 +832,14 @@ gd_type_t data_type, size_t nmemb); int _GD_RawSync(struct _gd_raw_file* file); int _GD_RawClose(struct _gd_raw_file* file); -off64_t _GD_RawSize(int, struct _gd_raw_file* file, gd_type_t data_type); -int _GD_RawTemp(int, int, struct _gd_raw_file *file, int mode); +off64_t _GD_RawSize(int, struct _gd_raw_file* file, gd_type_t data_type, + int swap); +int _GD_RawTOpen(int, struct _gd_raw_file*, int); +int _GD_RawTUnlink(int, struct _gd_raw_file*); /* text I/O methods */ -int _GD_AsciiOpen(int, struct _gd_raw_file* file, int mode, int creat); +int _GD_AsciiOpen(int, struct _gd_raw_file* file, int swap, int mode, + int creat); off64_t _GD_AsciiSeek(struct _gd_raw_file* file, off64_t count, gd_type_t data_type, int pad); ssize_t _GD_AsciiRead(struct _gd_raw_file* file, void *ptr, gd_type_t data_type, @@ -762,35 +849,41 @@ size_t nmemb); int _GD_AsciiSync(struct _gd_raw_file* file); int _GD_AsciiClose(struct _gd_raw_file* file); -off64_t _GD_AsciiSize(int, struct _gd_raw_file* file, gd_type_t data_type); -int _GD_AsciiTemp(int, int, struct _gd_raw_file *file, int mode); +off64_t _GD_AsciiSize(int, struct _gd_raw_file* file, gd_type_t data_type, + int swap); +int _GD_AsciiTOpen(int, struct _gd_raw_file*, int); +int _GD_AsciiTUnlink(int, struct _gd_raw_file*); /* bzip I/O methods */ -int _GD_Bzip2Open(int, struct _gd_raw_file* file, int mode, int creat); +int _GD_Bzip2Open(int, struct _gd_raw_file* file, int swap, int mode, + int creat); off64_t _GD_Bzip2Seek(struct _gd_raw_file* file, off64_t count, gd_type_t data_type, int pad); ssize_t _GD_Bzip2Read(struct _gd_raw_file* file, void *ptr, gd_type_t data_type, size_t nmemb); int _GD_Bzip2Close(struct _gd_raw_file* file); -off64_t _GD_Bzip2Size(int, struct _gd_raw_file* file, gd_type_t data_type); +off64_t _GD_Bzip2Size(int, struct _gd_raw_file* file, gd_type_t data_type, + int swap); /* gzip I/O methods */ -int _GD_GzipOpen(int, struct _gd_raw_file* file, int mode, int creat); +int _GD_GzipOpen(int, struct _gd_raw_file* file, int swap, int mode, int creat); off64_t _GD_GzipSeek(struct _gd_raw_file* file, off64_t count, gd_type_t data_type, int pad); ssize_t _GD_GzipRead(struct _gd_raw_file* file, void *ptr, gd_type_t data_type, size_t nmemb); int _GD_GzipClose(struct _gd_raw_file* file); -off64_t _GD_GzipSize(int, struct _gd_raw_file* file, gd_type_t data_type); +off64_t _GD_GzipSize(int, struct _gd_raw_file* file, gd_type_t data_type, + int swap); /* lzma I/O methods */ -int _GD_LzmaOpen(int, struct _gd_raw_file* file, int mode, int creat); +int _GD_LzmaOpen(int, struct _gd_raw_file* file, int swap, int mode, int creat); off64_t _GD_LzmaSeek(struct _gd_raw_file* file, off64_t count, gd_type_t data_type, int pad); ssize_t _GD_LzmaRead(struct _gd_raw_file* file, void *ptr, gd_type_t data_type, size_t nmemb); int _GD_LzmaClose(struct _gd_raw_file* file); -off64_t _GD_LzmaSize(int, struct _gd_raw_file* file, gd_type_t data_type); +off64_t _GD_LzmaSize(int, struct _gd_raw_file* file, gd_type_t data_type, + int swap); /* slim... [truncated message content] |
From: <ket...@us...> - 2011-08-10 10:17:15
|
Revision: 593 http://getdata.svn.sourceforge.net/getdata/?rev=593&view=rev Author: ketiltrout Date: 2011-08-10 10:17:09 +0000 (Wed, 10 Aug 2011) Log Message: ----------- Convert perl test to TAP. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/bindings/perl/t/big_test.t Property Changed: ---------------- trunk/getdata/bindings/perl/ Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-07-19 19:47:55 UTC (rev 592) +++ trunk/getdata/ChangeLog 2011-08-10 10:17:09 UTC (rev 593) @@ -1,3 +1,6 @@ +2011-08-10 D. V. Wiebe <ge...@ke...> svn:593 + * bindings/perl/t/big_test.t: Convert to TAP. + 2011-06-13 D. V. Wiebe <ge...@ke...> svn:588 * src/errors.c: Don't append strerror to the GD_E_CREAT_EXCL message. Property changes on: trunk/getdata/bindings/perl ___________________________________________________________________ Modified: svn:ignore - simple_funcs.xs Makefile.in GetData.pm GetData.c deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib debug.c + simple_funcs.xs Makefile.in GetData.pm GetData.c .deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib debug.c GetData.bs Modified: trunk/getdata/bindings/perl/t/big_test.t =================================================================== --- trunk/getdata/bindings/perl/t/big_test.t 2011-07-19 19:47:55 UTC (rev 592) +++ trunk/getdata/bindings/perl/t/big_test.t 2011-08-10 10:17:09 UTC (rev 593) @@ -22,117 +22,90 @@ use GetData; use Math::Complex; use strict; +use Test::More tests => 1135; my $ne = 0; my ($s, @a, %h); sub CheckError { my $e = $_->error; - if ($e != $_[1]) { - print "e[$_[0]] = $e, expected $_[1]\n"; - $ne++; - } + print "\n"; + is ($e, $_[1], "e[$_[0]] = $e, expected $_[1]"); + print "\n"; } sub CheckError2 { my $e = $_->error; - if ($e != $_[2]) { - print "e[$_[0],$_[1]] = $e, expected $_[2]\n"; - $ne++; - } + print "\n"; + is ($e, $_[2], "e[$_[0],$_[1]] = $e, expected $_[2]"); + print "\n"; } sub CheckArray { my $i; - if ($#{$_[1]} != $#_ - 2) { - print "a[$_[0]]: ", 1 + $#{$_[1]}, " elements, expected ", $#_ - 1, "\n"; - $ne++; - } + print "\n"; + is ($#{$_[1]}, $#_ - 2, + "a[$_[0]]: " . (1 + $#{$_[1]}) . " elements, expected " . ($#_ - 1)); for $i (0 .. $#_ - 2) { - next unless (defined ${$_[1]}[$i] or defined $_[$i + 2]); - if (${$_[1]}[$i] != $_[$i + 2]) { - print "a($i)[$_[0]] = ${$_[1]}[$i], expected ", $_[$i + 2], "\n"; - $ne++; - } + is (${$_[1]}[$i], $_[$i + 2], + "a($i)[$_[0]] = ${$_[1]}[$i], expected " . $_[$i + 2]); } + print "\n"; } sub CheckArray2 { my $i; - if ($#{$_[2]} != $#_ - 3) { - print "a[$_[0],$_[1]]: ", 1 + $#{$_[2]}, " elements, expected ", $#_ - 2, - "\n"; - $ne++; - } + print "\n"; + is ($#{$_[2]}, $#_ - 3, + "a[$_[0],$_[1]]: " . (1 + $#{$_[2]}) . " elements, expected " . ($#_ - 2)); for $i (0 .. $#_ - 3) { - next unless (defined ${$_[2]}[$i] or defined $_[$i + 3]); - if (${$_[2]}[$i] != $_[$i + 3]) { - print "a($i)[$_[0],$_[1]] = ${$_[2]}[$i], expected ", $_[$i + 3], "\n"; - $ne++; - } + is (${$_[2]}[$i], $_[$i + 3], "a($i)[$_[0],$_[1]] = " . + ((defined ${$_[2]}[$i]) ? ${$_[2]}[$i] : "undef") . ", expected " . + ((defined $_[$i + 3]) ? $_[$i + 3] : "undef") . "\n"); } + print "\n"; } sub CheckSArray { my $i; - if ($#{$_[1]} != $#_ - 2) { - print "a[$_[0]]: ", 1 + $#{$_[1]}, " elements, expected ", $#_ - 1, "\n"; - $ne++; - } + is ($#{$_[1]}, $#_ - 2, + "a[$_[0]]: " . (1 + $#{$_[1]}) . " elements, expected " . ($#_ - 1)); for $i (0 .. $#_ - 2) { - next unless (defined ${$_[1]}[$i] or defined $_[$i + 2]); - if (${$_[1]}[$i] ne $_[$i + 2]) { - print "n($i)[$_[0]] = \"${$_[1]}[$i]\", expected \"", $_[$i + 2], "\"\n"; - $ne++; - } + is (${$_[1]}[$i], $_[$i + 2], + "n($i)[$_[0]] = \"${$_[1]}[$i]\", expected \"" . $_[$i + 2] . "\""); } } sub CheckSArray2 { my $i; - if ($#{$_[2]} != $#_ - 3) { - print "a[$_[0],$_[1]]: ", 1 + $#{$_[2]}, " elements, expected ", $#_ - 2, - "\n"; - $ne++; - } + is ($#{$_[2]}, $#_ - 3, + "a[$_[0],$_[1]]: " . (1 + $#{$_[2]}) . " elements, expected " . ($#_ - 2)); for $i (0 .. $#_ - 3) { - next unless (defined ${$_[2]}[$i] or defined $_[$i + 3]); - if (${$_[2]}[$i] ne $_[$i + 3]) { - print "n($i)[$_[0],$_[1]] = \"${$_[2]}[$i]\", expected \"", $_[$i + 3], - "\"\n"; - $ne++; - } + is (${$_[2]}[$i], $_[$i + 3], "n($i)[$_[0],$_[1]] = " . + ((defined ${$_[2]}[$i]) ? "\"" . ${$_[2]}[$i] . "\"" : "undef") . + ", expected " . + ((defined $_[$i + 3]) ? "\"" . $_[$i + 3] . "\"" : "undef") . "\n"); } } sub CheckNum { - return unless (defined $_[1] or defined $_[2]); - if ($_[1] != $_[2]) { - print "n[$_[0]] = $_[1], expected $_[2]\n"; - $ne++; - } + is ($_[1], $_[2], "n[$_[0]] = " . + ((defined $_[1]) ? $_[1] : "undef") . ", expected " . + ((defined $_[2]) ? $_[2] : "undef")); } sub CheckNum2 { - return unless (defined $_[2] or defined $_[3]); - if ($_[2] != $_[3]) { - print "n[$_[0],$_[1]] = $_[2], expected $_[3]\n"; - $ne++; - } + is ($_[2], $_[3], "n[$_[0],$_[1]] = " . + ((defined $_[2]) ? $_[2] : "undef") . ", expected " . + ((defined $_[3]) ? $_[3] : "undef")); } sub CheckString { - if ($_[1] ne $_[2]) { - print "s[$_[0]] = \"$_[1]\", expected \"$_[2]\"\n"; - $ne++; - } + is ($_[1], $_[2], "s[$_[0]] = \"$_[1]\", expected \"$_[2]\""); } sub CheckString2 { - if ($_[2] ne $_[3]) { - print "s[$_[0],$_[1]] = \"$_[2]\", expected \"$_[3]\"\n"; - $ne++; - } + is ($_[2], $_[3], "s[$_[0],$_[1]] = \"$_[2]\", expected \"$_[3]\""); } sub CheckOK { &CheckError($_[0], 0) } @@ -1452,8 +1425,5 @@ - $d = $_ = undef; system "rm -rf dirfile"; - -die "ne = $ne" if ($ne > 0); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-07-19 19:48:06
|
Revision: 592 http://getdata.svn.sourceforge.net/getdata/?rev=592&view=rev Author: ketiltrout Date: 2011-07-19 19:47:55 +0000 (Tue, 19 Jul 2011) Log Message: ----------- Make the perl test-suite work. Modified Paths: -------------- trunk/getdata/bindings/perl/Makefile.PL.in trunk/getdata/bindings/perl/Makefile.am trunk/getdata/bindings/perl/t/callback.t trunk/getdata/configure.ac trunk/getdata/src/open.c Property Changed: ---------------- trunk/getdata/bindings/perl/ Property changes on: trunk/getdata/bindings/perl ___________________________________________________________________ Modified: svn:ignore - simple_funcs.xs Makefile.in GetData.pm GetData.c deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib + simple_funcs.xs Makefile.in GetData.pm GetData.c deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib debug.c Modified: trunk/getdata/bindings/perl/Makefile.PL.in =================================================================== --- trunk/getdata/bindings/perl/Makefile.PL.in 2011-07-18 20:34:48 UTC (rev 591) +++ trunk/getdata/bindings/perl/Makefile.PL.in 2011-07-19 19:47:55 UTC (rev 592) @@ -1,16 +1,23 @@ use 5.00800; use ExtUtils::MakeMaker; + +my @gd_cfiles = ("GetData.c"); +push @gd_cfiles, "debug.c" if (@GETDATA_DEBUG@); +my $gd_objects = "GetData\${OBJ_EXT}" . ((@GETDATA_DEBUG@) ? " debug\${OBJ_EXT}" : ""); + WriteMakefile( ABSTRACT_FROM => "GetData.pm", AUTHOR => "The GetData Progject <@PACKAGE_BUGREPORT@>", - C => [ qw(GetData.c) ], + C => \@gd_cfiles, DEFINE => "@DEFS@", FIRST_MAKEFILE => "perl.mk", INC => '-I. -I@top_builddir@/src', LIBS => ['-L@top_builddir@/src/.libs/ -lgetdata'], NAME => "GetData", + OBJECT => $gd_objects, PM => { "GetData.pm" => "\$(INST_LIBDIR)/GetData.pm" }, PREREQ_FATAL => 1, PREREQ_PM => { "Math::Complex" => 1.34 }, VERSION_FROM => "GetData.pm", + depend => { "perl.mk" => "\${VERSION_FROM}" } ); Modified: trunk/getdata/bindings/perl/Makefile.am =================================================================== --- trunk/getdata/bindings/perl/Makefile.am 2011-07-18 20:34:48 UTC (rev 591) +++ trunk/getdata/bindings/perl/Makefile.am 2011-07-19 19:47:55 UTC (rev 592) @@ -20,6 +20,14 @@ # AUTOMAKE_OPTIONS = foreign +if GETDATA_DEBUG +DEBUG_C = debug.c +TEST_VERBOSE="TEST_VERBOSE=1" +debug.c: $(top_srcdir)/src/debug.c + echo "#undef VERSION" > $@ + cat $< >> $@ +endif + simple_funcs.xs: $(srcdir)/simple_funcs.xsin $(srcdir)/simple_funcs.pl $(PERL) simple_funcs.pl $< > $@ @@ -36,7 +44,9 @@ $(PERL) funclist.pl GetData.xs simple_funcs.xs > $@ chmod a-w $@ -all-local: perl.mk +all-local: blib/man3/GetData.3pm + +blib/man3/GetData.3pm: perl.mk $(DEBUG_C) $(MAKE) -f perl.mk perl.mk: Makefile.PL GetData.pm GetData.xs simple_funcs.xs typemap @@ -44,9 +54,12 @@ clean-local: $(MAKE) -f perl.mk clean - rm -f $(BUILT_SOURCES) make_parameters.sed perl.mk.old + rm -f $(BUILT_SOURCES) make_parameters.sed perl.mk.old debug.c +check: + $(MAKE) test + test testdb: - $(MAKE) -f perl.mk $@ + ${DL_LIBRARY_PATH}=${${DL_LIBRARY_PATH}}:../../src/.libs $(MAKE) -f perl.mk $@ ${TEST_VERBOSE} .PHONY: test Modified: trunk/getdata/bindings/perl/t/callback.t =================================================================== --- trunk/getdata/bindings/perl/t/callback.t 2011-07-18 20:34:48 UTC (rev 591) +++ trunk/getdata/bindings/perl/t/callback.t 2011-07-19 19:47:55 UTC (rev 592) @@ -1,15 +1,15 @@ use GetData; use strict; -use Test::More tests => 7; +use Test::More tests => 8; # callback sub callback { my ($pdata, $extra) = @_; - is ($extra, "extra stuff"); - is ($$pdata{'suberror'}, $GetData::E_FORMAT_BAD_LINE); - is ($$pdata{'linenum'}, 2); - is ($$pdata{'filename'}, "dirfile/format"); + is ($extra, "extra stuff", "\$extra parameter good"); + is ($$pdata{'suberror'}, $GetData::E_FORMAT_BAD_LINE, "suberror good"); + is ($$pdata{'linenum'}, 2, "linenum good"); + is ($$pdata{'filename'}, "dirfile/format", "filename good"); $GetData::SYNTAX_IGNORE } @@ -25,8 +25,7 @@ my $d = &GetData::open("dirfile", $GetData::RDONLY, \&callback, "extra stuff"); ok (defined $d, "open created an object"); my $e = &GetData::error($d); -$d.close(); +is ($e, $GetData::E_OK, "no error from open"); +is ($d->close(), 0, "close succeeded"); system "rm -rf dirfile"; - -is($e, $GetData::E_OK); Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-07-18 20:34:48 UTC (rev 591) +++ trunk/getdata/configure.ac 2011-07-19 19:47:55 UTC (rev 592) @@ -104,7 +104,11 @@ AC_DEFINE([GETDATA_DEBUG], [], [ Define to enable debugging messages ]) enable_assert="yes" + GETDATA_DEBUG=1 +else + GETDATA_DEBUG=0 fi +AC_SUBST([GETDATA_DEBUG]) AC_MSG_CHECKING([whether to enable assertions]) AC_MSG_RESULT([$enable_assert]) Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-07-18 20:34:48 UTC (rev 591) +++ trunk/getdata/src/open.c 2011-07-19 19:47:55 UTC (rev 592) @@ -46,7 +46,7 @@ struct stat statbuf; DIR* dir; struct dirent* lamb; - int fd; + int fd = -1; int format_error = 0; FILE* fp = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-07-18 20:35:01
|
Revision: 591 http://getdata.svn.sourceforge.net/getdata/?rev=591&view=rev Author: ketiltrout Date: 2011-07-18 20:34:48 +0000 (Mon, 18 Jul 2011) Log Message: ----------- Build perl bindings via ExtUtils. Modified Paths: -------------- trunk/getdata/bindings/perl/GetData.pm.in trunk/getdata/bindings/perl/GetData.xs trunk/getdata/bindings/perl/Makefile.am trunk/getdata/configure.ac trunk/getdata/m4/perl.m4 Added Paths: ----------- trunk/getdata/bindings/perl/Makefile.PL.in trunk/getdata/bindings/perl/funclist.pl trunk/getdata/bindings/perl/t/ trunk/getdata/bindings/perl/t/big_test.t trunk/getdata/bindings/perl/t/callback.t Removed Paths: ------------- trunk/getdata/bindings/perl/t/Makefile.am trunk/getdata/bindings/perl/t/big_test.pl trunk/getdata/bindings/perl/t/callback.pl trunk/getdata/bindings/perl/test/ Property Changed: ---------------- trunk/getdata/bindings/perl/ Property changes on: trunk/getdata/bindings/perl ___________________________________________________________________ Modified: svn:ignore - simple_funcs.xs Makefile.in GetData.pm GetData.c funclist.sed deps make_parameters.sed Makefile .deps .libs + simple_funcs.xs Makefile.in GetData.pm GetData.c deps make_parameters.sed Makefile Makefile.PL perl.mk pm_to_blib blib Modified: trunk/getdata/bindings/perl/GetData.pm.in =================================================================== --- trunk/getdata/bindings/perl/GetData.pm.in 2011-07-17 03:57:23 UTC (rev 590) +++ trunk/getdata/bindings/perl/GetData.pm.in 2011-07-18 20:34:48 UTC (rev 591) @@ -113,6 +113,8 @@ the caller should check GetData::error() on the returned dirfile to test for success. +=back + =head1 COPYRIGHT Copyright (C) 2011 D. V. Wiebe Modified: trunk/getdata/bindings/perl/GetData.xs =================================================================== --- trunk/getdata/bindings/perl/GetData.xs 2011-07-17 03:57:23 UTC (rev 590) +++ trunk/getdata/bindings/perl/GetData.xs 2011-07-18 20:34:48 UTC (rev 591) @@ -4,6 +4,7 @@ #undef _BSD_SOURCE #undef _POSIX_SOURCE #undef _SVID_SOURCE +#undef VERSION #include "../../src/internal.h" /* Perl 5.8.9 and earlier don't provide hv_fetchs */ Added: trunk/getdata/bindings/perl/Makefile.PL.in =================================================================== --- trunk/getdata/bindings/perl/Makefile.PL.in (rev 0) +++ trunk/getdata/bindings/perl/Makefile.PL.in 2011-07-18 20:34:48 UTC (rev 591) @@ -0,0 +1,16 @@ +use 5.00800; +use ExtUtils::MakeMaker; +WriteMakefile( + ABSTRACT_FROM => "GetData.pm", + AUTHOR => "The GetData Progject <@PACKAGE_BUGREPORT@>", + C => [ qw(GetData.c) ], + DEFINE => "@DEFS@", + FIRST_MAKEFILE => "perl.mk", + INC => '-I. -I@top_builddir@/src', + LIBS => ['-L@top_builddir@/src/.libs/ -lgetdata'], + NAME => "GetData", + PM => { "GetData.pm" => "\$(INST_LIBDIR)/GetData.pm" }, + PREREQ_FATAL => 1, + PREREQ_PM => { "Math::Complex" => 1.34 }, + VERSION_FROM => "GetData.pm", +); Modified: trunk/getdata/bindings/perl/Makefile.am =================================================================== --- trunk/getdata/bindings/perl/Makefile.am 2011-07-17 03:57:23 UTC (rev 590) +++ trunk/getdata/bindings/perl/Makefile.am 2011-07-18 20:34:48 UTC (rev 591) @@ -20,50 +20,33 @@ # AUTOMAKE_OPTIONS = foreign -if CC_WALL -WALL=-Wall -endif - -if GETDATA_DEBUG -DEBUG_C = ../../src/debug.c -endif - -SUBDIRS=test - -perl_LTLIBRARIES=GetData.la -perl_SCRIPTS=GetData.pm - -BUILT_SOURCES=simple_funcs.xs GetData.pm GetData.c -AM_CFLAGS=${WALL} ${PERL_CFLAGS} -AM_CPPFLAGS=${PERL_CPPFLAGS} - -GetData_la_LDFLAGS = -module -avoid-version -GetData_la_LIBADD = ${PERL_LDLFLAGS} ../../src/libgetdata.la -nodist_GetData_la_SOURCES = GetData.c ${DEBUG_C} - -EXTRA_DIST=GetData.xs - simple_funcs.xs: $(srcdir)/simple_funcs.xsin $(srcdir)/simple_funcs.pl $(PERL) simple_funcs.pl $< > $@ -funclist.sed: GetData.c - $(PERL) -ne 'BEGIN { print "s/\@FUNCLIST@/" }' \ - -e 'print "$$1 " if /^XS\(XS_GetData_([a-z].*)\);/;' \ - -e 'END { print "/\n" }' $< > $@ - make_parameters.sed: ../make_parameters ../../src/getdata.h ../make_parameters P > $@ ../make_parameters: $(srcdir)/../make_parameters.c cd .. && ${MAKE} make_parameters -GetData.pm: $(srcdir)/GetData.pm.in make_parameters.sed funclist.sed +GetData.pm: $(srcdir)/GetData.pm.in make_parameters.sed funclist.pl \ + GetData.xs simple_funcs.xs rm -f $@ - $(SED) -f make_parameters.sed $< | $(SED) -f funclist.sed > $@ + $(SED) -f make_parameters.sed $< | \ + $(PERL) funclist.pl GetData.xs simple_funcs.xs > $@ chmod a-w $@ -GetData.c: GetData.xs simple_funcs.xs typemap - $(XSUBPP) -typemap $(srcdir)/typemap $< > $@ +all-local: perl.mk + $(MAKE) -f perl.mk -clean-local: - rm -f $(BUILT_SOURCES) make_parameters.sed funclist.sed +perl.mk: Makefile.PL GetData.pm GetData.xs simple_funcs.xs typemap + perl $< + +clean-local: + $(MAKE) -f perl.mk clean + rm -f $(BUILT_SOURCES) make_parameters.sed perl.mk.old + +test testdb: + $(MAKE) -f perl.mk $@ + +.PHONY: test Added: trunk/getdata/bindings/perl/funclist.pl =================================================================== --- trunk/getdata/bindings/perl/funclist.pl (rev 0) +++ trunk/getdata/bindings/perl/funclist.pl 2011-07-18 20:34:48 UTC (rev 591) @@ -0,0 +1,19 @@ +use strict; +use warnings; + +my $preamble = 1; + +# Generate the list +my @funclist; +for (<>) { + $preamble = 0 if (/^MODULE/); + next if $preamble; + next unless /^(\w*)\(/; + push @funclist, $1; +} +my $funclist = join(' ', sort @funclist); + +for (<STDIN>) { + s/\@FUNCLIST@/$funclist/g; + print $_; +} Deleted: trunk/getdata/bindings/perl/t/Makefile.am =================================================================== --- trunk/getdata/bindings/perl/test/Makefile.am 2011-07-17 03:57:23 UTC (rev 590) +++ trunk/getdata/bindings/perl/t/Makefile.am 2011-07-18 20:34:48 UTC (rev 591) @@ -1,38 +0,0 @@ -# Copyright (C) 2011 D. V. Wiebe -# -########################################################################## -# -# This file is part of the GetData project. -# -# GetData is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the -# Free Software Foundation; either version 2.1 of the License, or (at your -# option) any later version. -# -# GetData is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with GetData; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA -# -AUTOMAKE_OPTIONS = foreign - -TESTS_ENVIRONMENT=${DL_LIBRARY_PATH}=../.libs:${${DL_LIBRARY_PATH}}:../../../src/.libs ${PERL} -I.. -I../.libs -perlTESTS=callback.pl big_test.pl -TESTS=$(addprefix ${srcdir}/,$(perlTESTS)) - -EXTRA_DIST=${perlTESTS} - -# clean up after the tests -check-local: check-TESTS - $(MAKE) getdata-clean-dirs - -getdata-clean-dirs: - echo rm -rf dirfile - -clean-local: - $(MAKE) getdata-clean-dirs - rm -rf *~ Deleted: trunk/getdata/bindings/perl/t/big_test.pl =================================================================== --- trunk/getdata/bindings/perl/test/big_test.pl 2011-07-17 03:57:23 UTC (rev 590) +++ trunk/getdata/bindings/perl/t/big_test.pl 2011-07-18 20:34:48 UTC (rev 591) @@ -1,1459 +0,0 @@ -#!/usr/bin/perl -w -# Copyright (C) 2011 D. V. Wiebe -# -########################################################################## -# -# This file is part of the GetData project. -# -# GetData is free software; you can redistribute it and/or modify it under -# the terms of the GNU Lesser General Public License as published by the -# Free Software Foundation; either version 2.1 of the License, or (at your -# option) any later version. -# -# GetData is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public -# License for more details. -# -# You should have received a copy of the GNU Lesser General Public License -# along with GetData; if not, write to the Free Software Foundation, Inc., -# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - -use GetData; -use Math::Complex; -use strict; - -my $ne = 0; -my ($s, @a, %h); - -sub CheckError { - my $e = $_->error; - if ($e != $_[1]) { - print "e[$_[0]] = $e, expected $_[1]\n"; - $ne++; - } -} - -sub CheckError2 { - my $e = $_->error; - if ($e != $_[2]) { - print "e[$_[0],$_[1]] = $e, expected $_[2]\n"; - $ne++; - } -} - -sub CheckArray { - my $i; - if ($#{$_[1]} != $#_ - 2) { - print "a[$_[0]]: ", 1 + $#{$_[1]}, " elements, expected ", $#_ - 1, "\n"; - $ne++; - } - for $i (0 .. $#_ - 2) { - next unless (defined ${$_[1]}[$i] or defined $_[$i + 2]); - if (${$_[1]}[$i] != $_[$i + 2]) { - print "a($i)[$_[0]] = ${$_[1]}[$i], expected ", $_[$i + 2], "\n"; - $ne++; - } - } -} - -sub CheckArray2 { - my $i; - if ($#{$_[2]} != $#_ - 3) { - print "a[$_[0],$_[1]]: ", 1 + $#{$_[2]}, " elements, expected ", $#_ - 2, - "\n"; - $ne++; - } - for $i (0 .. $#_ - 3) { - next unless (defined ${$_[2]}[$i] or defined $_[$i + 3]); - if (${$_[2]}[$i] != $_[$i + 3]) { - print "a($i)[$_[0],$_[1]] = ${$_[2]}[$i], expected ", $_[$i + 3], "\n"; - $ne++; - } - } -} - -sub CheckSArray { - my $i; - if ($#{$_[1]} != $#_ - 2) { - print "a[$_[0]]: ", 1 + $#{$_[1]}, " elements, expected ", $#_ - 1, "\n"; - $ne++; - } - for $i (0 .. $#_ - 2) { - next unless (defined ${$_[1]}[$i] or defined $_[$i + 2]); - if (${$_[1]}[$i] ne $_[$i + 2]) { - print "n($i)[$_[0]] = \"${$_[1]}[$i]\", expected \"", $_[$i + 2], "\"\n"; - $ne++; - } - } -} - -sub CheckSArray2 { - my $i; - if ($#{$_[2]} != $#_ - 3) { - print "a[$_[0],$_[1]]: ", 1 + $#{$_[2]}, " elements, expected ", $#_ - 2, - "\n"; - $ne++; - } - for $i (0 .. $#_ - 3) { - next unless (defined ${$_[2]}[$i] or defined $_[$i + 3]); - if (${$_[2]}[$i] ne $_[$i + 3]) { - print "n($i)[$_[0],$_[1]] = \"${$_[2]}[$i]\", expected \"", $_[$i + 3], - "\"\n"; - $ne++; - } - } -} - -sub CheckNum { - return unless (defined $_[1] or defined $_[2]); - if ($_[1] != $_[2]) { - print "n[$_[0]] = $_[1], expected $_[2]\n"; - $ne++; - } -} - -sub CheckNum2 { - return unless (defined $_[2] or defined $_[3]); - if ($_[2] != $_[3]) { - print "n[$_[0],$_[1]] = $_[2], expected $_[3]\n"; - $ne++; - } -} - -sub CheckString { - if ($_[1] ne $_[2]) { - print "s[$_[0]] = \"$_[1]\", expected \"$_[2]\"\n"; - $ne++; - } -} - -sub CheckString2 { - if ($_[2] ne $_[3]) { - print "s[$_[0],$_[1]] = \"$_[2]\", expected \"$_[3]\"\n"; - $ne++; - } -} - -sub CheckOK { &CheckError($_[0], 0) } -sub CheckOK2 { &CheckError2(@_, 0) } - -my $nfields = 14; -my @fields = (qw(INDEX bit carray const data div lincom linterp mult phase -polynom recip sbit string)); - -#create the dirfile -system "rm -rf dirfile" if (-e "dirfile" and not -d "dirfile"); -(mkdir "dirfile" or die) unless -e "dirfile"; - -open GLOB, ">dirfile/data" or die; -print GLOB map chr, 1 .. 81; - -open GLOB, ">dirfile/format" or die; -print GLOB <<EOF -/ENDIAN little -data RAW INT8 8 -lincom LINCOM data 1.1 2.2 INDEX 2.2 3.3;4.4 linterp const const -/META data mstr STRING "This is a string constant." -/META data mconst CONST COMPLEX128 3.3;4.4 -/META data mlut LINTERP DATA ./lut -const CONST FLOAT64 5.5 -carray CARRAY FLOAT64 1.1 2.2 3.3 4.4 5.5 6.6 -linterp LINTERP data /look/up/file -polynom POLYNOM data 1.1 2.2 2.2 3.3;4.4 const const -bit BIT data 3 4 -sbit SBIT data 5 6 -mult MULTIPLY data sbit -div DIVIDE mult bit -recip RECIP div 6.5;4.3 -phase PHASE data 11 -string STRING \"Zaphod Beeblebrox\" -EOF - or die; - -open GLOB, ">dirfile/form2" or die; -print GLOB "const2 CONST INT8 -19\n" or die; -close GLOB; - -# 0: error check -$_ = &GetData::open("x", $GetData::RDONLY); -CheckError(0, $GetData::E_OPEN); - -# 1: open check -$_ = &GetData::open("dirfile", $GetData::RDWR); -CheckOK(1); - -# 2: getdata (INT8) check -$s = $_->getdata("data", 5, 0, 1, 0, $GetData::INT8); -CheckOK(2); -CheckString(2, $s, join "", map chr, 41 .. 48); - -# 102: getdata (unpacked) check -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::INT16); -CheckOK(102); -CheckArray(102, \@a, 41 .. 48); - -# 108: getdata (complex unpacked) check -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::COMPLEX128); -CheckOK(108); -CheckArray(108, \@a, 41 .. 48); - -# 3: constant (INT8) check -$s = $_->get_constant("const", $GetData::INT8); -CheckOK(3); -CheckNum(3, $s, 5); - -# 116: constant (COMPLEX128) check -$s = $_->get_constant("const", $GetData::COMPLEX128); -CheckOK(116); -CheckNum(116, $s, 5.5); - -# 6: nfields check -$s = $_->field_list; -CheckOK(6); -CheckNum(6, $s, $nfields); - -# 8: field_list check -@a = $_->field_list; -CheckOK(8); -CheckSArray(8, \@a, @fields); - -# 9: nmfields check -$s = $_->mfield_list("data"); -CheckOK(9); -CheckNum(9, $s, 3); - -# 10: mfield_list check -@a = $_->mfield_list("data"); -CheckOK(10); -CheckSArray(10, \@a, qw(mstr mconst mlut)); - -# 11: nframes check -$s = $_->nframes; -CheckOK(11); -CheckNum(11, $s, 10); - -# 12: spf check -$s = $_->spf("data"); -CheckOK(12); -CheckNum(12, $s, 8); - -# 13: putdata (packed) check -$s = $_->putdata("data", 5, 1, $GetData::UINT8, "\15\16\17\20"); -CheckOK2(13,1); -CheckNum(13,$s,4); - -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); -CheckOK2(13,2); -CheckArray(13, \@a, 41, 015, 016, 017, 020, 46, 47, 48); - -# 118: putdata (typed ref) check -$s = $_->putdata("data", 5, 1, $GetData::UINT16, [ 23, 24, 25, 26 ]); -CheckOK2(118,1); -CheckNum(118,$s,4); - -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); -CheckOK2(118,2); -CheckArray(118, \@a, 41, 23, 24, 25, 26, 46, 47, 48); - -# 120: putdata (untyped ref) check -$s = $_->putdata("data", 5, 1, [ 33, 34, 35, 36 ]); -CheckOK2(120,1); -CheckNum(120,$s,4); - -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); -CheckOK2(120,2); -CheckArray(120, \@a, 41, 33, 34, 35, 36, 46, 47, 48); - -# 122: putdata (simple list) check -$s = $_->putdata("data", 5, 1, 23., 24., 25., 26.); -CheckOK2(122,1); -CheckNum(122,$s,4); - -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); -CheckOK2(122,2); -CheckArray(122, \@a, 41, 23, 24, 25, 26, 46, 47, 48); - -# 124: putdata (undef list) check -$s = $_->putdata("data", 5, 1, undef, 13.+0*i, 14.+0*i, 15.+0*i, 16.+0*i); -CheckOK2(124,1); -CheckNum(124,$s,4); - -@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); -CheckOK2(124,2); -CheckArray(124, \@a, 41, 13, 14, 15, 16, 46, 47, 48); - -# 14: error_string check -$s = $_->getdata("x", 5, 0, 1, 0, $GetData::UINT8); -CheckError(14,$GetData::E_BAD_CODE); -CheckString(14, $_->error_string, "Field not found: x"); - -# 15: get_entry check -$s = $_->entry("data"); -CheckOK(15); -CheckNum(15,$s,$GetData::RAW_ENTRY); - -# 16: get_entry check -%h = $_->entry("data"); -CheckOK(16); -CheckSArray2(16, 0, [ sort keys %h ], - qw(data_type field field_type fragment_index scalar scalar_ind spf)); -CheckNum2(16, 1, $h{'data_type'}, $GetData::INT8); -CheckString2(16, 2, $h{'field'}, "data"); -CheckNum2(16, 3, $h{'field_type'}, $GetData::RAW_ENTRY); -CheckNum2(16, 4, $h{'fragment_index'}, 0); -CheckSArray2(16, 6, $h{'scalar'}, undef); -CheckArray2(16, 7, $h{'scalar_ind'}, undef); -CheckNum2(16, 8, $h{'spf'}, 8); - -# 18: get_entry check -%h = $_->entry("lincom"); -CheckOK(18); -CheckSArray2(18, 1, [ sort keys %h ], qw(b field field_type), - qw(fragment_index in_fields m n_fields scalar scalar_ind)); -CheckArray2(18, 2, $h{'b'}, 2.2, 3.3+4.4*i, 5.5); -CheckString2(18, 5, $h{'field'}, "lincom"); -CheckNum2(18, 6, $h{'field_type'}, $GetData::LINCOM_ENTRY); -CheckNum2(18, 7, $h{'fragment_index'}, 0); -CheckSArray2(18, 8, $h{'in_fields'}, qw(data INDEX linterp)); -CheckArray2(18, 3, $h{'m'}, 1.1, 2.2, 5.5); -CheckNum2(18, 10, $h{'n_fields'}, 3); -CheckSArray2(18, 11, $h{'scalar'}, undef, undef, "const", undef, undef, - "const"); -CheckArray2(18, 12, $h{'scalar_ind'}, undef, undef, -1, undef, undef, -1); - -# 20: get_entry check -%h = $_->entry("polynom"); -CheckOK(20); -CheckSArray2(20, 1, [ sort keys %h ], qw(a field field_type), - qw(fragment_index in_field poly_ord scalar scalar_ind)); -CheckArray2(20, 2, $h{'a'}, 1.1, 2.2, 2.2, 3.3+4.4*i, 5.5, 5.5); -CheckString2(20, 4, $h{'field'}, "polynom"); -CheckNum2(20, 5, $h{'field_type'}, $GetData::POLYNOM_ENTRY); -CheckNum2(20, 6, $h{'fragment_index'}, 0); -CheckString2(20, 7, $h{'in_field'}, "data"); -CheckNum2(20, 8, $h{'poly_ord'}, 5); -CheckSArray2(20, 9, $h{'scalar'}, undef, undef, undef, undef, "const", "const"); -CheckArray2(20, 10, $h{'scalar_ind'}, undef, undef, undef, undef, -1, -1); - -# 21: get_entry check -%h = $_->entry("linterp"); -CheckOK(21); -CheckSArray2(21, 0, [ sort keys %h ], qw(field field_type fragment_index), - qw(in_field table)); -CheckString2(21, 1, $h{'field'}, "linterp"); -CheckNum2(21, 2, $h{'field_type'}, $GetData::LINTERP_ENTRY); -CheckNum2(21, 3, $h{'fragment_index'}, 0); -CheckString2(21, 4, $h{'in_field'}, "data"); -CheckString2(21, 5, $h{'table'}, "/look/up/file"); - -# 22: get_entry check -%h = $_->entry("bit"); -CheckOK(22); -CheckSArray2(22, 0, [ sort keys %h ], qw(bitnum field field_type), - qw(fragment_index in_field numbits scalar scalar_ind)); -CheckNum2(22, 1, $h{'bitnum'}, 3); -CheckString2(22, 2, $h{'field'}, "bit"); -CheckNum2(22, 3, $h{'field_type'}, $GetData::BIT_ENTRY); -CheckNum2(22, 4, $h{'fragment_index'}, 0); -CheckString2(22, 5, $h{'in_field'}, "data"); -CheckNum2(22, 6, $h{'numbits'}, 4); -CheckSArray2(22, 7, $h{'scalar'}, undef, undef); -CheckArray2(22, 8, $h{'scalar_ind'}, undef, undef); - -# 23: get_entry check -%h = $_->entry("sbit"); -CheckOK(23); -CheckSArray2(23, 0, [ sort keys %h ], qw(bitnum field field_type), - qw(fragment_index in_field numbits scalar scalar_ind)); -CheckNum2(23, 1, $h{'bitnum'}, 5); -CheckString2(23, 2, $h{'field'}, "sbit"); -CheckNum2(23, 3, $h{'field_type'}, $GetData::SBIT_ENTRY); -CheckNum2(23, 4, $h{'fragment_index'}, 0); -CheckString2(23, 5, $h{'in_field'}, "data"); -CheckNum2(23, 6, $h{'numbits'}, 6); -CheckSArray2(23, 7, $h{'scalar'}, undef, undef); -CheckArray2(23, 8, $h{'scalar_ind'}, undef, undef); - -# 24: get_entry check -%h = $_->entry("mult"); -CheckOK(24); -CheckSArray2(24, 0, [ sort keys %h ], qw(field field_type fragment_index), - "in_fields"); -CheckString2(24, 1, $h{'field'}, "mult"); -CheckNum2(24, 2, $h{'field_type'}, $GetData::MULTIPLY_ENTRY); -CheckNum2(24, 3, $h{'fragment_index'}, 0); -CheckSArray2(24, 4, $h{'in_fields'}, qw(data sbit)); - -# 25: get_entry check -%h = $_->entry("phase"); -CheckOK(25); -CheckSArray2(25, 0, [ sort keys %h ], qw(field field_type fragment_index), - qw(in_field scalar scalar_ind shift)); -CheckString2(25, 1, $h{'field'}, "phase"); -CheckNum2(25, 2, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(25, 3, $h{'fragment_index'}, 0); -CheckString2(25, 4, $h{'in_field'}, "data"); -CheckSArray2(25, 5, $h{'scalar'}, undef); -CheckArray2(25, 6, $h{'scalar_ind'}, undef); -CheckNum2(25, 7, $h{'shift'}, 11); - -# 26: get_entry check -%h = $_->entry("const"); -CheckOK(26); -CheckSArray2(26, 0, [ sort keys %h ], qw(const_type field field_type), - "fragment_index"); -CheckNum2(26, 1, $h{'const_type'}, $GetData::FLOAT64); -CheckString2(26, 2, $h{'field'}, "const"); -CheckNum2(26, 3, $h{'field_type'}, $GetData::CONST_ENTRY); -CheckNum2(26, 4, $h{'fragment_index'}, 0); - -# 134: get_entry check -%h = $_->entry("string"); -CheckOK(134); -CheckSArray2(134, 0, [ sort keys %h ], qw(field field_type fragment_index)); -CheckString2(134, 1, $h{'field'}, "string"); -CheckNum2(134, 2, $h{'field_type'}, $GetData::STRING_ENTRY); -CheckNum2(134, 3, $h{'fragment_index'}, 0); - -# 27: fragment_index check -$s = $_->fragment_index("data"); -CheckOK(27); -CheckNum(27, $s, 0); - -# 28: add_raw check -$s = $_->add_raw("new1", $GetData::FLOAT64, 3); -CheckOK2(28, 1); -CheckNum2(28, 2, $s, 0); - -%h = $_->entry("new1"); -CheckOK2(28, 3); -CheckNum2(28, 4, $h{'data_type'}, $GetData::FLOAT64); -CheckString2(28, 5, $h{'field'}, "new1"); -CheckNum2(28, 6, $h{'field_type'}, $GetData::RAW_ENTRY); -CheckNum2(28, 7, $h{'fragment_index'}, 0); -CheckSArray2(28, 8, $h{'scalar'}, undef); -CheckArray2(28, 9, $h{'scalar_ind'}, undef); -CheckNum2(28, 10, $h{'spf'}, 3); - -#30: add_lincom check -$s = $_->add_lincom("new3", 2, [ qw(in1 in2) ], [ 1.1+1.2*i, 1.4+1.5*i ], - [ 1.3+1.4*i, 1.6+1.7*i ], 0); -CheckOK2(30, 1); -CheckNum2(30, 2, $s, 0); - -%h = $_->entry("new3"); -CheckOK2(30, 3); -CheckArray2(30, 4, $h{'b'}, 1.3+1.4*i, 1.6+1.7*i); -CheckString2(30, 6, $h{'field'}, "new3"); -CheckNum2(30, 7, $h{'field_type'}, $GetData::LINCOM_ENTRY); -CheckNum2(30, 8, $h{'fragment_index'}, 0); -CheckSArray2(30, 9, $h{'in_fields'}, qw(in1 in2)); -CheckArray2(30, 10, $h{'m'}, 1.1+1.2*i, 1.4+1.5*i); -CheckNum2(30, 11, $h{'n_fields'}, 2); -CheckSArray2(30, 12, $h{'scalar'}, undef, undef, undef, undef, undef); -CheckArray2(30, 13, $h{'scalar_ind'}, undef, undef, undef, undef, undef); - -# 31: add_polynom -$s = $_->add_polynom("new4", 3, "in1", [ 3.9, 4.8, 5.7, 6.6 ], 0); -CheckOK2(31, 1); -CheckNum2(31, 2, $s, 0); - -%h = $_->entry("new4"); -CheckOK2(31, 3); -CheckArray2(31, 4, $h{'a'}, 3.9, 4.8, 5.7, 6.6); -CheckString2(31, 7, $h{'field'}, "new4"); -CheckNum2(31, 8, $h{'field_type'}, $GetData::POLYNOM_ENTRY); -CheckNum2(31, 9, $h{'fragment_index'}, 0); -CheckString2(31, 10, $h{'in_field'}, "in1"); -CheckNum2(31, 11, $h{'poly_ord'}, 3); -CheckSArray2(31, 12, $h{'scalar'}, undef, undef, undef, undef); -CheckArray2(31, 13, $h{'scalar_ind'}, undef, undef, undef, undef); - -# 33: add_linterp -$s = $_->add_linterp("new6", "in", "./some/table"); -CheckOK2(33, 1); -CheckNum2(33, 2, $s, 0); - -%h = $_->entry("new6"); -CheckOK2(33, 2); -CheckString2(33, 3, $h{'field'}, "new6"); -CheckNum2(33, 4, $h{'field_type'}, $GetData::LINTERP_ENTRY); -CheckNum2(33, 5, $h{'fragment_index'}, 0); -CheckString2(33, 6, $h{'in_field'}, "in"); -CheckString2(33, 7, $h{'table'}, "./some/table"); - -# 34: add_bit -$s = $_->add_bit("new7", "in1", 11, 22); -CheckOK2(34, 1); -CheckNum2(34, 2, $s, 0); - -%h = $_->entry("new7"); -CheckOK(34, 2); -CheckNum2(34, 3, $h{'bitnum'}, 11); -CheckString2(34, 4, $h{'field'}, "new7"); -CheckNum2(34, 5, $h{'field_type'}, $GetData::BIT_ENTRY); -CheckNum2(34, 6, $h{'fragment_index'}, 0); -CheckString2(34, 7, $h{'in_field'}, "in1"); -CheckNum2(34, 8, $h{'numbits'}, 22); -CheckSArray2(34, 9, $h{'scalar'}, undef, undef); -CheckArray2(34, 10, $h{'scalar_ind'}, undef, undef); - -# 35: add_sbit -$s = $_->add_sbit("new8", "in2", 5, 10); -CheckOK2(35, 1); -CheckNum2(35, 2, $s, 0); - -%h = $_->entry("new8"); -CheckOK(35, 2); -CheckNum2(35, 3, $h{'bitnum'}, 5); -CheckString2(35, 4, $h{'field'}, "new8"); -CheckNum2(35, 5, $h{'field_type'}, $GetData::SBIT_ENTRY); -CheckNum2(35, 6, $h{'fragment_index'}, 0); -CheckString2(35, 7, $h{'in_field'}, "in2"); -CheckNum2(35, 8, $h{'numbits'}, 10); -CheckSArray2(35, 9, $h{'scalar'}, undef, undef); -CheckArray2(35, 10, $h{'scalar_ind'}, undef, undef); - -# 36: add_mutiply -$s = $_->add_multiply("new9", "in2", "in3"); -CheckOK2(36, 1); -CheckNum2(36, 2, $s, 0); - -%h = $_->entry("new9"); -CheckOK2(36, 3); -CheckString2(36, 4, $h{'field'}, "new9"); -CheckNum2(36, 5, $h{'field_type'}, $GetData::MULTIPLY_ENTRY); -CheckNum2(36, 6, $h{'fragment_index'}, 0); -CheckSArray2(36, 7, $h{'in_fields'}, qw(in2 in3)); - -# 37: add_phase -$s = $_->add_phase("new10", "in6", 42); -CheckOK2(37, 1); -CheckNum2(37, 2, $s, 0); - -%h = $_->entry("new10"); -CheckOK2(37, 2); -CheckString2(37, 3, $h{'field'}, "new10"); -CheckNum2(37, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(37, 5, $h{'fragment_index'}, 0); -CheckString2(37, 6, $h{'in_field'}, "in6"); -CheckSArray2(37, 7, $h{'scalar'}, undef); -CheckArray2(37, 8, $h{'scalar_ind'}, undef); -CheckNum2(37, 9, $h{'shift'}, 42); - -# 38: add_const -$s = $_->add_const("new11", $GetData::FLOAT64, "33.3"); -CheckOK2(38, 1); -CheckNum2(38, 2, $s, 0); - -%h = $_->entry("new11"); -CheckOK2(38, 3); -CheckNum2(38, 4, $h{'const_type'}, $GetData::FLOAT64); -CheckString2(38, 5, $h{'field'}, "new11"); -CheckNum2(38, 6, $h{'field_type'}, $GetData::CONST_ENTRY); -CheckNum2(38, 7, $h{'fragment_index'}, 0); - -$s = $_->get_constant("new11", $GetData::FLOAT64); -CheckOK2(38, 8); -CheckNum2(38, 9, $s, 33.3); - -# 125: add check -$s = $_->add({ - field => "new13", - field_type => $GetData::PHASE_ENTRY, - fragment_index => 0, - in_field => "new9", - shift => -88 - }); -CheckOK2(125,1); -CheckNum2(125, 2, $s, 0); - -%h = $_->entry("new13"); -CheckOK2(125, 2); -CheckString2(125, 3, $h{'field'}, "new13"); -CheckNum2(125, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(125, 5, $h{'fragment_index'}, 0); -CheckString2(125, 6, $h{'in_field'}, "new9"); -CheckSArray2(125, 7, $h{'scalar'}, undef); -CheckArray2(125, 8, $h{'scalar_ind'}, undef); -CheckNum2(125, 9, $h{'shift'}, -88); - -# 39: fragment_name -$s = $_->fragmentname(0); -CheckOK(39); -CheckString(39, $s, "dirfile/format"); - -# 40: nfragments -$s = $_->fragments; -CheckOK(40); -CheckNum(40, $s, 1); - -# 182: fragment list -@a = $_->fragments; -CheckOK(182); -CheckSArray(182, \@a, "dirfile/format"); - -# 41: include -$s = $_->include("form2", 0, 0); -CheckOK2(41, 1); -CheckNum2(41, 2, $s, 1); - -$s = $_->get_constant("const2", $GetData::INT32); -CheckOK2(41, 3); -CheckNum2(41, 4, $s, -19); - -# 42: nfields_by_type -$s = $_->field_list_by_type($GetData::LINCOM_ENTRY); -CheckOK(42); -CheckNum(42, $s, 2); - -# 43: field_list_by_type -@a = $_->field_list_by_type($GetData::LINCOM_ENTRY); -CheckOK(43); -CheckSArray(43, \@a, qw(lincom new3)); - -# 44: nvectors -$s = $_->vector_list; -CheckOK(44); -CheckNum(44, $s, 20); - -# 45: vector_list -@a = $_->vector_list; -CheckOK(45); -CheckSArray(45, \@a, qw(INDEX bit data div lincom linterp mult new1 new10), - qw(new13 new3 new4 new6 new7 new8 new9 phase polynom recip sbit)); - -#47: madd_lincom check -$s = $_->madd_lincom("data", "mnew2", 2, [ qw(in1 in2) ], [ 9.9+8.8*i, 7.7 ], - [ 6.6, 5.5 ]); -CheckOK2(47, 1); -CheckNum2(47, 2, $s, 0); - -%h = $_->entry("data/mnew2"); -CheckOK2(47, 3); -CheckArray2(47, 4, $h{'b'}, 6.6, 5.5); -CheckArray2(47, 5, $h{'m'}, 9.9+8.8*i, 7.7); -CheckString2(47, 7, $h{'field'}, "data/mnew2"); -CheckNum2(47, 8, $h{'field_type'}, $GetData::LINCOM_ENTRY); -CheckNum2(47, 9, $h{'fragment_index'}, 0); -CheckSArray2(47, 10, $h{'in_fields'}, qw(in1 in2)); -CheckNum2(47, 11, $h{'n_fields'}, 2); -CheckSArray2(47, 12, $h{'scalar'}, undef, undef, undef, undef, undef); -CheckArray2(47, 13, $h{'scalar_ind'}, undef, undef, undef, undef, undef); - -# 48: madd_polynom -$s = $_->madd_polynom("data", "mnew3", 3, "in1", [ 3.9, 4.8, 5.7, 6.6 ]); -CheckOK2(48, 1); -CheckNum2(48, 2, $s, 0); - -%h = $_->entry("data/mnew3"); -CheckOK2(48, 3); -CheckArray2(48, 4, $h{'a'}, 3.9, 4.8, 5.7, 6.6); -CheckString2(48, 7, $h{'field'}, "data/mnew3"); -CheckNum2(48, 8, $h{'field_type'}, $GetData::POLYNOM_ENTRY); -CheckNum2(48, 9, $h{'fragment_index'}, 0); -CheckString2(48, 10, $h{'in_field'}, "in1"); -CheckNum2(48, 11, $h{'poly_ord'}, 3); -CheckSArray2(48, 12, $h{'scalar'}, undef, undef, undef, undef); -CheckArray2(48, 13, $h{'scalar_ind'}, undef, undef, undef, undef); - -# 50: madd_linterp -$s = $_->madd_linterp("data", "mnew6", "in", "./more/table"); -CheckOK2(50, 1); -CheckNum2(50, 2, $s, 0); - -%h = $_->entry("data/mnew6"); -CheckOK2(50, 2); -CheckString2(50, 3, $h{'field'}, "data/mnew6"); -CheckNum2(50, 4, $h{'field_type'}, $GetData::LINTERP_ENTRY); -CheckNum2(50, 5, $h{'fragment_index'}, 0); -CheckString2(50, 6, $h{'in_field'}, "in"); -CheckString2(50, 7, $h{'table'}, "./more/table"); - -# 51: madd_bit -$s = $_->madd_bit("data", "mnew7", "in1", 3, 2); -CheckOK2(51, 1); -CheckNum2(51, 2, $s, 0); - -%h = $_->entry("data/mnew7"); -CheckOK(51, 2); -CheckNum2(51, 3, $h{'bitnum'}, 3); -CheckString2(51, 4, $h{'field'}, "data/mnew7"); -CheckNum2(51, 5, $h{'field_type'}, $GetData::BIT_ENTRY); -CheckNum2(51, 6, $h{'fragment_index'}, 0); -CheckString2(51, 7, $h{'in_field'}, "in1"); -CheckNum2(51, 8, $h{'numbits'}, 2); -CheckSArray2(51, 9, $h{'scalar'}, undef, undef); -CheckArray2(51, 10, $h{'scalar_ind'}, undef, undef); - -# 52: madd_sbit -$s = $_->madd_sbit("data", "mnew8", "in2", 4, 5); -CheckOK2(52, 1); -CheckNum2(52, 2, $s, 0); - -%h = $_->entry("data/mnew8"); -CheckOK(52, 2); -CheckNum2(52, 3, $h{'bitnum'}, 4); -CheckString2(52, 4, $h{'field'}, "data/mnew8"); -CheckNum2(52, 5, $h{'field_type'}, $GetData::SBIT_ENTRY); -CheckNum2(52, 6, $h{'fragment_index'}, 0); -CheckString2(52, 7, $h{'in_field'}, "in2"); -CheckNum2(52, 8, $h{'numbits'}, 5); -CheckSArray2(52, 9, $h{'scalar'}, undef, undef); -CheckArray2(52, 10, $h{'scalar_ind'}, undef, undef); - -# 53: madd_mutiply -$s = $_->madd_multiply("data", "mnew9", "in3", "in2"); -CheckOK2(53, 1); -CheckNum2(53, 2, $s, 0); - -%h = $_->entry("data/mnew9"); -CheckOK2(53, 3); -CheckString2(53, 4, $h{'field'}, "data/mnew9"); -CheckNum2(53, 5, $h{'field_type'}, $GetData::MULTIPLY_ENTRY); -CheckNum2(53, 6, $h{'fragment_index'}, 0); -CheckSArray2(53, 7, $h{'in_fields'}, qw(in3 in2)); - -# 54: madd_phase -$s = $_->madd_phase("data", "mnew10", "in6", 44); -CheckOK2(54, 1); -CheckNum2(54, 2, $s, 0); - -%h = $_->entry("data/mnew10"); -CheckOK2(54, 2); -CheckString2(54, 3, $h{'field'}, "data/mnew10"); -CheckNum2(54, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(54, 5, $h{'fragment_index'}, 0); -CheckString2(54, 6, $h{'in_field'}, "in6"); -CheckSArray2(54, 7, $h{'scalar'}, undef); -CheckArray2(54, 8, $h{'scalar_ind'}, undef); -CheckNum2(54, 9, $h{'shift'}, 44); - -# 55: madd_const -$s = $_->madd_const("data", "mnew11", $GetData::FLOAT64, 9.2); -CheckOK2(55, 1); -CheckNum2(55, 2, $s, 0); - -%h = $_->entry("data/mnew11"); -CheckOK2(55, 3); -CheckNum2(55, 4, $h{'const_type'}, $GetData::FLOAT64); -CheckString2(55, 5, $h{'field'}, "data/mnew11"); -CheckNum2(55, 6, $h{'field_type'}, $GetData::CONST_ENTRY); -CheckNum2(55, 7, $h{'fragment_index'}, 0); - -$s = $_->get_constant("data/mnew11", $GetData::FLOAT64); -CheckOK2(55, 8); -CheckNum2(55, 9, $s, 9.2); - -# 126: madd check -$s = $_->madd({ - field => "mnew13", - field_type => $GetData::PHASE_ENTRY, - fragment_index => 0, - in_field => "data", - shift => 2 - }, "data"); -CheckOK2(126,1); -CheckNum2(126, 2, $s, 0); - -%h = $_->entry("data/mnew13"); -CheckOK2(126, 2); -CheckString2(126, 3, $h{'field'}, "data/mnew13"); -CheckNum2(126, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(126, 5, $h{'fragment_index'}, 0); -CheckString2(126, 6, $h{'in_field'}, "data"); -CheckSArray2(126, 7, $h{'scalar'}, undef); -CheckArray2(126, 8, $h{'scalar_ind'}, undef); -CheckNum2(126, 9, $h{'shift'}, 2); - -# 56: get_string -$s = $_->get_string("string"); -CheckOK(56); -CheckString(56, $s, "Zaphod Beeblebrox"); - -# 57: add_string -$s = $_->add_string("new12", "a string"); -CheckOK2(57, 1); -CheckNum2(57, 2, $s, 0); - -%h = $_->entry("new12"); -CheckOK2(57, 3); -CheckString2(57, 4, $h{'field'}, "new12"); -CheckNum2(57, 5, $h{'field_type'}, $GetData::STRING_ENTRY); -CheckNum2(57, 6, $h{'fragment_index'}, 0); - -$s = $_->get_string("new12"); -CheckOK2(57, 7); -CheckString2(57, 8, $s, "a string"); - -# 58: madd_string -$s = $_->madd_string("data", "mnew12", "another string"); -CheckOK2(58, 1); -CheckNum2(58, 2, $s, 0); - -%h = $_->entry("data/mnew12"); -CheckOK2(58, 3); -CheckString2(58, 4, $h{'field'}, "data/mnew12"); -CheckNum2(58, 5, $h{'field_type'}, $GetData::STRING_ENTRY); -CheckNum2(58, 6, $h{'fragment_index'}, 0); - -$s = $_->get_string("data/mnew12"); -CheckOK2(58, 7); -CheckString2(58, 8, $s, "another string"); - -# 59: add_spec -$s = $_->add_spec("lorem STRING \"Lorem ipsum\"", 0); -CheckOK2(59, 1); -CheckNum2(59, 2, $s, 0); - -%h = $_->entry("lorem"); -CheckOK2(59, 3); -CheckString2(59, 4, $h{'field'}, "lorem"); -CheckNum2(59, 5, $h{'field_type'}, $GetData::STRING_ENTRY); -CheckNum2(59, 6, $h{'fragment_index'}, 0); - -$s = $_->get_string("lorem"); -CheckOK2(59, 7); -CheckString2(59, 8, $s, "Lorem ipsum"); - -# 60: add_spec -$s = $_->madd_spec("ipsum STRING \"dolor sit amet.\"", "lorem"); -CheckOK2(60, 1); -CheckNum2(60, 2, $s, 0); - -%h = $_->entry("lorem/ipsum"); -CheckOK2(60, 3); -CheckString2(60, 4, $h{'field'}, "lorem/ipsum"); -CheckNum2(60, 5, $h{'field_type'}, $GetData::STRING_ENTRY); -CheckNum2(60, 6, $h{'fragment_index'}, 0); - -$s = $_->get_string("lorem/ipsum"); -CheckOK2(60, 7); -CheckString2(60, 8, $s, "dolor sit amet."); - -# 61: put_constant -$s = $_->put_constant("const", 61); -CheckOK2(61, 1); -CheckNum2(61, 2, $s, 0); - -$s = $_->get_constant("const", $GetData::FLOAT64); -CheckOK2(61, 3); -CheckNum2(61, 4, $s, 61.); - -# 62: put_string -$s = $_->put_string("string", "Arthur Dent"); -CheckOK2(62, 1); -CheckNum2(62, 2, $s, 12); - -$s = $_->get_string("string"); -CheckOK2(62, 3); -CheckString2(62, 4, $s, "Arthur Dent"); - -# 63: nmfields_by_type -$s = $_->mfield_list_by_type("data", $GetData::LINCOM_ENTRY); -CheckOK(63); -CheckNum(63, $s, 1); - -# 64: mfield_list_by_type -@a = $_->mfield_list_by_type("data", $GetData::LINCOM_ENTRY); -CheckOK(64); -CheckSArray(64, \@a, qw(mnew2)); - -# 65: nmfields_by_type -$s = $_->mvector_list("data"); -CheckOK(65); -CheckNum(65, $s, 9); - -# 66: mfield_list_by_type -@a = $_->mvector_list("data"); -CheckOK(66); -CheckSArray(66, \@a, - qw(mlut mnew2 mnew3 mnew6 mnew7 mnew8 mnew9 mnew10 mnew13)); - -# 67: alter raw -$s = $_->alter_raw("new1", $GetData::INT32, undef); -CheckOK2(67, 1); -CheckNum2(67, 2, $s, 0); - -%h = $_->entry("new1"); -CheckOK2(67, 3); -CheckNum2(67, 4, $h{'data_type'}, $GetData::INT32); -CheckString2(67, 5, $h{'field'}, "new1"); -CheckNum2(67, 6, $h{'field_type'}, $GetData::RAW_ENTRY); -CheckNum2(67, 7, $h{'fragment_index'}, 0); -CheckSArray2(67, 8, $h{'scalar'}, undef); -CheckArray2(67, 9, $h{'scalar_ind'}, undef); -CheckNum2(67, 10, $h{'spf'}, 3); - -#69: alter_lincom check -$s = $_->alter_lincom("new3", undef, [ qw(in3 in4) ], [ 3., 4. ]); -CheckOK2(69, 1); -CheckNum2(69, 2, $s, 0); - -%h = $_->entry("new3"); -CheckOK2(69, 3); -CheckArray2(69, 4, $h{'b'}, 1.3+1.4*i, 1.6+1.7*i); -CheckArray2(69, 5, $h{'m'}, 3, 4); -CheckString2(69, 7, $h{'field'}, "new3"); -CheckNum2(69, 8, $h{'field_type'}, $GetData::LINCOM_ENTRY); -CheckNum2(69, 9, $h{'fragment_index'}, 0); -CheckSArray2(69, 10, $h{'in_fields'}, qw(in3 in4)); -CheckNum2(69, 11, $h{'n_fields'}, 2); -CheckSArray2(69, 12, $h{'scalar'}, undef, undef, undef, undef, undef); -CheckArray2(69, 13, $h{'scalar_ind'}, undef, undef, undef, undef, undef); - -# 71: alter_polynom -$s = $_->alter_polynom("new4", 4, undef, [ 1*i, 2*i, 3*i, 4*i, 5*i ]); -CheckOK2(71, 1); -CheckNum2(71, 2, $s, 0); - -%h = $_->entry("new4"); -CheckOK2(71, 3); -CheckArray2(71, 4, $h{'a'}, 1*i, 2*i, 3*i, 4*i, 5*i); -CheckString2(71, 7, $h{'field'}, "new4"); -CheckNum2(71, 8, $h{'field_type'}, $GetData::POLYNOM_ENTRY); -CheckNum2(71, 9, $h{'fragment_index'}, 0); -CheckString2(71, 10, $h{'in_field'}, "in1"); -CheckNum2(71, 11, $h{'poly_ord'}, 4); -CheckSArray2(71, 12, $h{'scalar'}, undef, undef, undef, undef, undef); -CheckArray2(71, 13, $h{'scalar_ind'}, undef, undef, undef, undef, undef); - -# 72: alter_linterp -$s = $_->alter_linterp("new6", undef, "./other/table"); -CheckOK2(72, 1); -CheckNum2(72, 2, $s, 0); - -%h = $_->entry("new6"); -CheckOK2(72, 2); -CheckString2(72, 3, $h{'field'}, "new6"); -CheckNum2(72, 4, $h{'field_type'}, $GetData::LINTERP_ENTRY); -CheckNum2(72, 5, $h{'fragment_index'}, 0); -CheckString2(72, 6, $h{'in_field'}, "in"); -CheckString2(72, 7, $h{'table'}, "./other/table"); - -# 73: alter_bit -$s = $_->alter_bit("new7", "in3", undef, 8); -CheckOK2(73, 1); -CheckNum2(73, 2, $s, 0); - -%h = $_->entry("new7"); -CheckOK(73, 2); -CheckNum2(73, 3, $h{'bitnum'}, 11); -CheckString2(73, 4, $h{'field'}, "new7"); -CheckNum2(73, 5, $h{'field_type'}, $GetData::BIT_ENTRY); -CheckNum2(73, 6, $h{'fragment_index'}, 0); -CheckString2(73, 7, $h{'in_field'}, "in3"); -CheckNum2(73, 8, $h{'numbits'}, 8); -CheckSArray2(73, 9, $h{'scalar'}, undef, undef); -CheckArray2(73, 10, $h{'scalar_ind'}, undef, undef); - -# 74: alter_sbit -$s = $_->alter_sbit("new8", "in1"); -CheckOK2(74, 1); -CheckNum2(74, 2, $s, 0); - -%h = $_->entry("new8"); -CheckOK(74, 2); -CheckNum2(74, 3, $h{'bitnum'}, 5); -CheckString2(74, 4, $h{'field'}, "new8"); -CheckNum2(74, 5, $h{'field_type'}, $GetData::SBIT_ENTRY); -CheckNum2(74, 6, $h{'fragment_index'}, 0); -CheckString2(74, 7, $h{'in_field'}, "in1"); -CheckNum2(74, 8, $h{'numbits'}, 10); -CheckSArray2(74, 9, $h{'scalar'}, undef, undef); -CheckArray2(74, 10, $h{'scalar_ind'}, undef, undef); - -# 75: alter_mutiply -$s = $_->alter_multiply("new9", "in1"); -CheckOK2(75, 1); -CheckNum2(75, 2, $s, 0); - -%h = $_->entry("new9"); -CheckOK2(75, 3); -CheckString2(75, 4, $h{'field'}, "new9"); -CheckNum2(75, 5, $h{'field_type'}, $GetData::MULTIPLY_ENTRY); -CheckNum2(75, 6, $h{'fragment_index'}, 0); -CheckSArray2(75, 7, $h{'in_fields'}, qw(in1 in3)); - -# 76: alter_phase -$s = $_->alter_phase("new10", undef, -3); -CheckOK2(76, 1); -CheckNum2(76, 2, $s, 0); - -%h = $_->entry("new10"); -CheckOK2(76, 2); -CheckString2(76, 3, $h{'field'}, "new10"); -CheckNum2(76, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(76, 5, $h{'fragment_index'}, 0); -CheckString2(76, 6, $h{'in_field'}, "in6"); -CheckSArray2(76, 7, $h{'scalar'}, undef); -CheckArray2(76, 8, $h{'scalar_ind'}, undef); -CheckNum2(76, 9, $h{'shift'}, -3); - -# 77: alter_const -$s = $_->alter_const("new11", $GetData::FLOAT32); -CheckOK2(77, 1); -CheckNum2(77, 2, $s, 0); - -%h = $_->entry("new11"); -CheckOK2(77, 3); -CheckNum2(77, 4, $h{'const_type'}, $GetData::FLOAT32); -CheckString2(77, 5, $h{'field'}, "new11"); -CheckNum2(77, 6, $h{'field_type'}, $GetData::CONST_ENTRY); -CheckNum2(77, 7, $h{'fragment_index'}, 0); - -# 141: alter check -$s = $_->alter_entry("new13", { - field => undef, - field_type => $GetData::PHASE_ENTRY, - fragment_index => 0, - in_field => "new3", - shift => -2 - }); -CheckOK2(141,1); -CheckNum2(141, 2, $s, 0); - -%h = $_->entry("new13"); -CheckOK2(141, 2); -CheckString2(141, 3, $h{'field'}, "new13"); -CheckNum2(141, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(141, 5, $h{'fragment_index'}, 0); -CheckString2(141, 6, $h{'in_field'}, "new3"); -CheckSArray2(141, 7, $h{'scalar'}, undef); -CheckArray2(141, 8, $h{'scalar_ind'}, undef); -CheckNum2(141, 9, $h{'shift'}, -2); - -# 78: encoding check -$s = $_->encoding(0); -CheckOK(78); -CheckNum(78, $s, $GetData::UNENCODED); - -# 79: endianness check -$s = $_->endianness(0); -CheckOK(79); -CheckNum(79, $s, $GetData::LITTLE_ENDIAN | $GetData::NOT_ARM_ENDIAN); - -# 80: dirfilename -$s = $_->dirfilename; -CheckOK(80); -CheckString(80, $s, "dirfile"); - -# 81: parent_fragment -$s = $_->parent_fragment(1); -CheckOK(81); -CheckNum(81, $s, 0); - -# 82: alter_protection -$s = $_->alter_protection($GetData::PROTECT_DATA, 1); -CheckOK(82); -CheckNum(82, $s, 0); - -# 83: protection -$s = $_->protection(1); -CheckOK(83); -CheckNum(83, $s, $GetData::PROTECT_DATA); - -# 84: raw_filename -$s = $_->raw_filename("data"); -CheckOK(84); -CheckString(84, $s, "dirfile/data"); - -# 85: reference -$s = $_->reference("new1"); -CheckOK(85); -CheckString(85, $s, "new1"); - -# 87: alter_encoding -$s = $_->alter_encoding($GetData::SLIM_ENCODED, 1); -CheckOK2(87, 1); -CheckNum2(87, 2, $s, 0); - -$s = $_->encoding(1); -CheckOK2(87, 3); -CheckNum2(87, 4, $s, $GetData::SLIM_ENCODED); - -# 88: alter_endianness -$s = $_->alter_endianness($GetData::BIG_ENDIAN, 1); -CheckOK2(88, 1); -CheckNum2(88, 2, $s, 0); - -$s = $_->endianness(1); -CheckOK2(88, 3); -CheckNum2(88, 4, $s, $GetData::BIG_ENDIAN); - -# 89: alter_spec -$s = $_->alter_spec("new10 PHASE in const"); -CheckOK2(89, 1); -CheckNum2(89, 2, $s, 0); - -%h = $_->entry("new10"); -CheckOK2(89, 2); -CheckString2(89, 3, $h{'field'}, "new10"); -CheckNum2(89, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(89, 5, $h{'fragment_index'}, 0); -CheckString2(89, 6, $h{'in_field'}, "in"); -CheckSArray2(89, 7, $h{'scalar'}, "const"); -CheckArray2(89, 8, $h{'scalar_ind'}, -1); -CheckNum2(89, 9, $h{'shift'}, 61); - -# 90: delete -$s = $_->delete("new10"); -CheckOK2(90, 0); -CheckNum2(90, 1, $s, 0); - -$s = $_->entry("new10"); -CheckError2(90, 2, $GetData::E_BAD_CODE); -CheckNum2(90, 3, $s, undef); - -# 91: malter_spec -$s = $_->malter_spec("mnew10 PHASE in4 11", "data"); -CheckOK2(91, 0); -CheckNum2(91, 1, $s, 0); - -%h = $_->entry("data/mnew10"); -CheckOK2(91, 2); -CheckString2(91, 3, $h{'field'}, "data/mnew10"); -CheckNum2(91, 4, $h{'field_type'}, $GetData::PHASE_ENTRY); -CheckNum2(91, 5, $h{'fragment_index'}, 0); -CheckString2(91, 6, $h{'in_field'}, "in4"); -CheckSArray2(91, 7, $h{'scalar'}, undef); -CheckArray2(91, 8, $h{'scalar_ind'}, undef); -CheckNum2(91, 9, $h{'shift'}, 11); - -# 92: move -$s = $_->move("new9", 1); -CheckOK2(92, 0); -CheckNum2(92, 1, $s, 0); - -%h = $_->entry("new9"); -CheckOK2(92, 3); -CheckString2(92, 4, $h{'field'}, "new9"); -CheckNum2(92, 5, $h{'field_type'}, $GetData::MULTIPLY_ENTRY); -CheckNum2(92, 6, $h{'fragment_index'}, 1); -CheckSArray2(92, 7, $h{'in_fields'}, qw(in1 in3)); - -# 93: move -$s = $_->rename(qw(new9 newer)); -CheckOK2(93, 0); -CheckNum2(93, 1, $s, 0); - -$s = $_->entry("new9"); -CheckError2(93, 2, $GetData::E_BAD_CODE); - -%h = $_->entry("newer"); -CheckOK2(93, 3); -CheckString2(93, 4, $h{'field'}, "newer"); -CheckNum2(93, 5, $h{'field_type'}, $GetData::MULTIPLY_ENTRY); -CheckNum2(93, 6, $h{'fragment_index'}, 1); -CheckSArray2(93, 7, $h{'in_fields'}, qw(in1 in3)); - -# 94: uninclude -$s = $_->uninclude(1); -CheckOK2(94, 0); -CheckNum2(94, 1, $s, 0); - -$s = $_->entry("newer"); -CheckError2(94, 2, $GetData::E_BAD_CODE); - -# 95: frameoffset -$s = $_->frameoffset(0); -CheckOK(95); -CheckNum(95, $s, 0); - -# 96: alter_frameoffset -$s = $_->alter_frameoffset(33, 0); -CheckOK2(96, 0); -CheckNum2(96, 1, $s, 0); - -$s = $_->frameoffset(0); -CheckOK2(96, 2); -CheckNum2(96, 3, $s, 33); - -# 97: native_type -$s = $_->native_type("data"); -CheckOK(97); -CheckNum(97, $s, $GetData::INT8); - -# 99: validate -$s = $_->validate("new7"); -CheckError(99, $GetData::E_BAD_CODE); -CheckNum(99, $s, undef); - -# 101: framenum -$s = $_->framenum("data", 33.3, 6); -CheckOK(101); -CheckNum(101, $s, 37.0375); - -# 86: gd_eof -$s = $_->eof("lincom"); -CheckOK(86); -CheckNum(86, $s, 345); - -# 142: gd_bof -$s = $_->bof("lincom"); -CheckOK(142); -CheckNum(142, $s, 264); - -# 143: divide entry -%h = $_->entry("div"); -CheckOK(143); -CheckSArray2(143, 0, [ sort keys %h ], qw(field field_type fragment_index), - "in_fields"); -CheckString2(143, 1, $h{'field'}, "div"); -CheckNum2(143, 2, $h{'field_type'}, $GetData::DIVIDE_ENTRY); -CheckNum2(143, 3, $h{'fragment_index'}, 0); -CheckSArray2(143, 4, $h{'in_fields'}, qw(mult bit)); - -# 145: recip entry -%h = $_->entry("recip"); -CheckOK(145); -CheckSArray2(145, 1, [ sort keys %h ], qw(dividend field field_type), - qw(fragment_index in_field scalar scalar_ind)); -CheckNum2(145, 2, $h{'dividend'}, 6.5 + 4.3 * i); -CheckString2(145, 3, $h{'field'}, "recip"); -CheckNum2(145, 4, $h{'field_type'}, $GetData::RECIP_ENTRY); -CheckNum2(145, 5, $h{'fragment_index'}, 0); -CheckString2(145, 6, $h{'in_field'}, "div"); -CheckSArray2(145, 7, $h{'scalar'}, undef); -CheckArray2(145, 8, $h{'scalar_ind'}, undef); - -# 146: add divide -$s = $_->add_divide(qw(new14 in2 in3)); -CheckOK2(146, 0); -CheckNum2(146, 1, $s, 0); - -%h = $_->entry("new14"); -CheckOK(146); -CheckString2(146, 1, $h{'field'}, "new14"); -CheckNum2(146, 2, $h{'field_type'}, $GetData::DIVIDE_ENTRY); -CheckNum2(146, 3, $h{'fragment_index'}, 0); -CheckSArray2(146, 4, $h{'in_fields'}, qw(in2 in3)); - -# 148: add recip -$s = $_->add_recip(qw(new16 in2), 33.3 + 44.4 * i); -CheckOK2(148, 0); -CheckNum2(148, 1, $s, 0); - -%h = $_->entry("new16"); -CheckOK(148); -CheckNum2(148, 2, $h{'dividend'}, 33.3 + 44.4 * i); -CheckString2(148, 3, $h{'field'}, "new16"); -CheckNum2(148, 4, $h{'field_type'}, $GetData::RECIP_ENTRY); -CheckNum2(148, 5, $h{'fragment_index'}, 0); -CheckString2(148, 6, $h{'in_field'}, "in2"); -CheckSArray2(148, 7, $h{'scalar'}, undef); -CheckArray2(148, 8, $h{'scalar_ind'}, undef); - -# 149: madd divide -$s = $_->madd_divide(qw(data mnew14 in1 in8)); -CheckOK2(149, 0); -CheckNum2(149, 1, $s, 0); - -%h = $_->entry("data/mnew14"); -CheckOK(149); -CheckString2(149, 1, $h{'field'}, "data/mnew14"); -CheckNum2(149, 2, $h{'field_type'}, $GetData::DIVIDE_ENTRY); -CheckNum2(149, 3, $h{'fragment_index'}, 0); -CheckSArray2(149, 4, $h{'in_fields'}, qw(in1 in8)); - -# 151: add recip -$s = $_->madd_recip(qw(data mnew16 in2), 1.0); -CheckOK2(151, 0); -CheckNum2(151, 1, $s, 0); - -%h = $_->entry("data/mnew16"); -CheckOK(151); -CheckNum2(151, 2, $h{'dividend'}, 1); -CheckString2(151, 3, $h{'field'}, "data/mnew16"); -CheckNum2(151, 4, $h{'field_type'}, $GetData::RECIP_ENTRY); -CheckNum2(151, 5, $h{'fragment_index'}, 0); -CheckString2(151, 6, $h{'in_field'}, "in2"); -CheckSArray2(151, 7, $h{'scalar'}, undef); -CheckArray2(151, 8, $h{'scalar_ind'}, undef); - -# 152: alter_divide -$s = $_->alter_divide("new14", "in5"); -CheckOK2(152, 1); -CheckNum2(152, 2, $s, 0); - -%h = $_->entry("new14"); -CheckOK2(152, 3); -CheckString2(152, 4, $h{'field'}, "new14"); -CheckNum2(152, 5, $h{'field_type'}, $GetData::DIVIDE_ENTRY); -CheckNum2(152, 6, $h{'fragment_index'}, 0); -CheckSArray2(152, 7, $h{'in_fields'}, qw(in5 in3)); - -# 153: alter recip -$s = $_->alter_recip("new16", "in6", undef); -CheckOK2(153, 1); -CheckNum2(153, 2, $s, 0); - -%h = $_->entry("new16"); -CheckOK(151); -CheckNum2(151, 2, $h{'dividend'}, 33.3 + 44.4 * i); -CheckString2(151, 3, $h{'field'}, "new16"); -CheckNum2(151, 4, $h{'field_type'}, $GetData::RECIP_ENTRY); -CheckNum2(151, 5, $h{'fragment_index'}, 0); -CheckString2(151, 6, $h{'in_field'}, "in6"); -CheckSArray2(151, 7, $h{'scalar'}, undef); -CheckArray2(151, 8, $h{'scalar_ind'}, undef); - -# 155: rewrite fragment -$s = $_->rewrite_fragment(0); -CheckOK(155, 0); -CheckNum(155, $s, 0); - -# 156: invalid dirfile -my $d = $_; -$_ = &GetData::invalid_dirfile; -CheckOK2(156, 0); -$s = $_->fragments; -CheckError2(156, 1, $GetData::E_BAD_DIRFILE); -CheckNum2(156, 2, $s, 0); -$_->close; -$_ = $d; - -# 157: dirfile standards -$s = $_->dirfile_standards; -CheckOK2(157, 1); -CheckNum2(157, 2, $s, $GetData::DIRFILE_STANDARDS_VERSION); - -$s = $_->dirfile_standards(0); -CheckError2(157, 3, $GetData::E_BAD_VERSION); -CheckNum2(157, 4, $s, undef); - -# 158: get_carray -$s = $_->get_carray("carray", $GetData::INT8); -CheckOK(158); -CheckString(158, $s, "\1\2\3\4\5\6"); - -# 164: get_carray_slice -@a = $_->get_carray_slice("carray", 2, 2, $GetData::FLOAT64); -CheckOK(164); -CheckArray(164, \@a, 3.3, 4.4); - -# 167: carrays -$s = $_->carrays($GetData::INT8); -CheckOK2(167, 1); -CheckNum2(167, 2, $#$s, 0); -CheckSArray2(167, 3, $s, "\1\2\3\4\5\6"); - -@a = $_->carrays($GetData::FLOAT64); -CheckOK2(167, 4); -CheckNum2(167, 5, $#a, 0); -CheckArray2(167, 6, $a[0], 1.1, 2.2, 3.3, 4.4, 5.5, 6.6 ); - -# 168: put carray -$s = $_->put_carray("carray", 9, 8, 7, 6, 5, 4); -CheckOK2(168, 1); -CheckNum2(168, 2, $s, 0); - -@a = $_->get_carray("carray", $GetData::INT8); -CheckOK2(168, 3); -CheckArray2(168, 4, \@a, 9, 8, 7, 6, 5, 4); - -#169 put caray slice -$s = $_->put_carray_slice("carray", 2, [ 169, 169 ]); -CheckOK2(168, 1); -CheckNum2(168, 2, $s, 0); - -@a = $_->get_carray("carray", $GetData::UINT8); -CheckOK2(168, 3); -CheckArray2(168, 4, \@a, 9, 8, 169, 169, 5, 4); - -# 177: carray len -$s = $_->carray_len("carray"); -CheckOK(177); -CheckNum(177, $s, 6); - -# 178: carray entry -%h = $_->entry("carray"); -CheckOK2(178, 1); -CheckSArray2(178, 2, [ sort keys %h ], - qw(array_len const_type field field_type fragment_index)); -CheckNum2(178, 3, $h{'array_len'}, 6); -CheckNum2(178, 4, $h{'const_type'}, $GetData::FLOAT64); -CheckString2(178, 5, $h{'field'}, "carray"); -CheckNum2(178, 6, $h{'field_type'}, $GetData::CARRAY_ENTRY); -CheckNum2(178, 7, $h{'fragment_index'}, 0); - -# 179: add carray -$s = $_->add_carray("new17", $GetData::FLOAT64, 0, undef, 1.79, 17.9); -CheckOK2(179, 1); -CheckNum2(179, 2, $s, 0); - -%h = $_->entry("new17"); -CheckOK2(179, 3); -CheckNum2(179, 4, $h{'array_len'}, 2); -CheckNum2(179, 5, $h{'const_type'}, $GetData::FLOAT64); -CheckString2(179, 6, $h{'field'}, "new17"); -CheckNum2(179, 7, $h{'field_type'}, $GetData::CARRAY_ENTRY); -CheckNum2(179, 8, $h{'fragment_index'}, 0); - -@a = $_->get_carray("new17", $GetData::FLOAT64); -CheckOK2(179, 9); -CheckArray2(179, 10, \@a, 1.79, 17.9); - -# 180: add carray -$s = $_->madd_carray("data", "mnew17", $GetData::FLOAT64, undef, 1.80, 18.0); -CheckOK2(180, 1); -CheckNum2(180, 2, $s, 0); - -%h = $_->entry("data/mnew17"); -CheckOK2(180, 3); -CheckNum2(180, 4, $h{'array_len'}, 2); -CheckNum2(180, 5, $h{'const_type'}, $GetData::FLOAT64); -CheckString2(180, 6, $h{'field'}, "data/mnew17"); -CheckNum2(180, 7, $h{'field_type'}, $GetData::CARRAY_ENTRY); -CheckNum2(180, 8, $h{'fragment_index'}, 0); - -@a = $_->get_carray("data/mnew17", $GetData::FLOAT64); -CheckOK2(180, 9); -CheckArray2(180, 10, \@a, 1.80, 18.0); - -# 183: constants -$s = $_->constants($GetData::UINT8); -CheckOK2(183, 0); -CheckString2(183, 1, $s, "=!"); - -@a = $_->constants($GetData::FLOAT64); -CheckOK2(183, 2); -CheckArray2(183, 3, \@a, 61, 33.3); - -# 184: mconstants -$s = $_->mconstants("data", $GetData::UINT8); -CheckOK2(184, 0); -CheckString2(184, 1, $s, "\3\011"); - -@a = $_->mconstants("data", $GetData::FLOAT64); -CheckOK2(184, 2); -CheckArray2(184, 3, \@a, 3.3, 9.2); - -# 185: strings -$s = $_->strings; -CheckOK2(185, 1); -CheckNum2(185, 2, $s, 3); - -@a = $_->strings; -CheckOK2(185, 3); -CheckSArray2(185, 4, \@a, "Lorem ipsum", "a string", "Arthur Dent"); - -# 186: mstrings -$s = $_->mstrings("data"); -CheckOK2(186, 1); -CheckNum2(186, 2, $s, 2); - -@a = $_->mstrings("data"); -CheckOK2(186, 3); -CheckSArray2(186, 4, \@a, "This is a string constant.", "another string"); - - - - - - -$d = $_ = undef; -system "rm -rf dirfile"; - -die "ne = $ne" if ($ne > 0); Copied: trunk/getdata/bindings/perl/t/big_test.t (from rev 590, trunk/getdata/bindings/perl/test/big_test.pl) =================================================================== --- trunk/getdata/bindings/perl/t/big_test.t (rev 0) +++ trunk/getdata/bindings/perl/t/big_test.t 2011-07-18 20:34:48 UTC (rev 591) @@ -0,0 +1,1459 @@ +#!/usr/bin/perl -w +# Copyright (C) 2011 D. V. Wiebe +# +########################################################################## +# +# This file is part of the GetData project. +# +# GetData is free software; you can redistribute it and/or modify it under +# the terms of the GNU Lesser General Public License as published by the +# Free Software Foundation; either version 2.1 of the License, or (at your +# option) any later version. +# +# GetData is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public +# License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with GetData; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +use GetData; +use Math::Complex; +use strict; + +my $ne = 0; +my ($s, @a, %h); + +sub CheckError { + my $e = $_->error; + if ($e != $_[1]) { + print "e[$_[0]] = $e, expected $_[1]\n"; + $ne++; + } +} + +sub CheckError2 { + my $e = $_->error; + if ($e != $_[2]) { + print "e[$_[0],$_[1]] = $e, expected $_[2]\n"; + $ne++; + } +} + +sub CheckArray { + my $i; + if ($#{$_[1]} != $#_ - 2) { + print "a[$_[0]]: ", 1 + $#{$_[1]}, " elements, expected ", $#_ - 1, "\n"; + $ne++; + } + for $i (0 .. $#_ - 2) { + next unless (defined ${$_[1]}[$i] or defined $_[$i + 2]); + if (${$_[1]}[$i] != $_[$i + 2]) { + print "a($i)[$_[0]] = ${$_[1]}[$i], expected ", $_[$i + 2], "\n"; + $ne++; + } + } +} + +sub CheckArray2 { + my $i; + if ($#{$_[2]} != $#_ - 3) { + print "a[$_[0],$_[1]]: ", 1 + $#{$_[2]}, " elements, expected ", $#_ - 2, + "\n"; + $ne++; + } + for $i (0 .. $#_ - 3) { + next unless (defined ${$_[2]}[$i] or defined $_[$i + 3]); + if (${$_[2]}[$i] != $_[$i + 3]) { + print "a($i)[$_[0],$_[1]] = ${$_[2]}[$i], expected ", $_[$i + 3], "\n"; + $ne++; + } + } +} + +sub CheckSArray { + my $i; + if ($#{$_[1]} != $#_ - 2) { + print "a[$_[0]]: ", 1 + $#{$_[1]}, " elements, expected ", $#_ - 1, "\n"; + $ne++; + } + for $i (0 .. $#_ - 2) { + next unless (defined ${$_[1]}[$i] or defined $_[$i + 2]); + if (${$_[1]}[$i] ne $_[$i + 2]) { + print "n($i)[$_[0]] = \"${$_[1]}[$i]\", expected \"", $_[$i + 2], "\"\n"; + $ne++; + } + } +} + +sub CheckSArray2 { + my $i; + if ($#{$_[2]} != $#_ - 3) { + print "a[$_[0],$_[1]]: ", 1 + $#{$_[2]}, " elements, expected ", $#_ - 2, + "\n"; + $ne++; + } + for $i (0 .. $#_ - 3) { + next unless (defined ${$_[2]}[$i] or defined $_[$i + 3]); + if (${$_[2]}[$i] ne $_[$i + 3]) { + print "n($i)[$_[0],$_[1]] = \"${$_[2]}[$i]\", expected \"", $_[$i + 3], + "\"\n"; + $ne++; + } + } +} + +sub CheckNum { + return unless (defined $_[1] or defined $_[2]); + if ($_[1] != $_[2]) { + print "n[$_[0]] = $_[1], expected $_[2]\n"; + $ne++; + } +} + +sub CheckNum2 { + return unless (defined $_[2] or defined $_[3]); + if ($_[2] != $_[3]) { + print "n[$_[0],$_[1]] = $_[2], expected $_[3]\n"; + $ne++; + } +} + +sub CheckString { + if ($_[1] ne $_[2]) { + print "s[$_[0]] = \"$_[1]\", expected \"$_[2]\"\n"; + $ne++; + } +} + +sub CheckString2 { + if ($_[2] ne $_[3]) { + print "s[$_[0],$_[1]] = \"$_[2]\", expected \"$_[3]\"\n"; + $ne++; + } +} + +sub CheckOK { &CheckError($_[0], 0) } +sub CheckOK2 { &CheckError2(@_, 0) } + +my $nfields = 14; +my @fields = (qw(INDEX bit carray const data div lincom linterp mult phase +polynom recip sbit string)); + +#create the dirfile +system "rm -rf dirfile" if (-e "dirfile" and not -d "dirfile"); +(mkdir "dirfile" or die) unless -e "dirfile"; + +open GLOB, ">dirfile/data" or die; +print GLOB map chr, 1 .. 81; + +open GLOB, ">dirfile/format" or die; +print GLOB <<EOF +/ENDIAN little +data RAW INT8 8 +lincom LINCOM data 1.1 2.2 INDEX 2.2 3.3;4.4 linterp const const +/META data mstr STRING "This is a string constant." +/META data mconst CONST COMPLEX128 3.3;4.4 +/META data mlut LINTERP DATA ./lut +const CONST FLOAT64 5.5 +carray CARRAY FLOAT64 1.1 2.2 3.3 4.4 5.5 6.6 +linterp LINTERP data /look/up/file +polynom POLYNOM data 1.1 2.2 2.2 3.3;4.4 const const +bit BIT data 3 4 +sbit SBIT data 5 6 +mult MULTIPLY data sbit +div DIVIDE mult bit +recip RECIP div 6.5;4.3 +phase PHASE data 11 +string STRING \"Zaphod Beeblebrox\" +EOF + or die; + +open GLOB, ">dirfile/form2" or die; +print GLOB "const2 CONST INT8 -19\n" or die; +close GLOB; + +# 0: error check +$_ = &GetData::open("x", $GetData::RDONLY); +CheckError(0, $GetData::E_OPEN); + +# 1: open check +$_ = &GetData::open("dirfile", $GetData::RDWR); +CheckOK(1); + +# 2: getdata (INT8) check +$s = $_->getdata("data", 5, 0, 1, 0, $GetData::INT8); +CheckOK(2); +CheckString(2, $s, join "", map chr, 41 .. 48); + +# 102: getdata (unpacked) check +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::INT16); +CheckOK(102); +CheckArray(102, \@a, 41 .. 48); + +# 108: getdata (complex unpacked) check +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::COMPLEX128); +CheckOK(108); +CheckArray(108, \@a, 41 .. 48); + +# 3: constant (INT8) check +$s = $_->get_constant("const", $GetData::INT8); +CheckOK(3); +CheckNum(3, $s, 5); + +# 116: constant (COMPLEX128) check +$s = $_->get_constant("const", $GetData::COMPLEX128); +CheckOK(116); +CheckNum(116, $s, 5.5); + +# 6: nfields check +$s = $_->field_list; +CheckOK(6); +CheckNum(6, $s, $nfields); + +# 8: field_list check +@a = $_->field_list; +CheckOK(8); +CheckSArray(8, \@a, @fields); + +# 9: nmfields check +$s = $_->mfield_list("data"); +CheckOK(9); +CheckNum(9, $s, 3); + +# 10: mfield_list check +@a = $_->mfield_list("data"); +CheckOK(10); +CheckSArray(10, \@a, qw(mstr mconst mlut)); + +# 11: nframes check +$s = $_->nframes; +CheckOK(11); +CheckNum(11, $s, 10); + +# 12: spf check +$s = $_->spf("data"); +CheckOK(12); +CheckNum(12, $s, 8); + +# 13: putdata (packed) check +$s = $_->putdata("data", 5, 1, $GetData::UINT8, "\15\16\17\20"); +CheckOK2(13,1); +CheckNum(13,$s,4); + +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); +CheckOK2(13,2); +CheckArray(13, \@a, 41, 015, 016, 017, 020, 46, 47, 48); + +# 118: putdata (typed ref) check +$s = $_->putdata("data", 5, 1, $GetData::UINT16, [ 23, 24, 25, 26 ]); +CheckOK2(118,1); +CheckNum(118,$s,4); + +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); +CheckOK2(118,2); +CheckArray(118, \@a, 41, 23, 24, 25, 26, 46, 47, 48); + +# 120: putdata (untyped ref) check +$s = $_->putdata("data", 5, 1, [ 33, 34, 35, 36 ]); +CheckOK2(120,1); +CheckNum(120,$s,4); + +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); +CheckOK2(120,2); +CheckArray(120, \@a, 41, 33, 34, 35, 36, 46, 47, 48); + +# 122: putdata (simple list) check +$s = $_->putdata("data", 5, 1, 23., 24., 25., 26.); +CheckOK2(122,1); +CheckNum(122,$s,4); + +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); +CheckOK2(122,2); +CheckArray(122, \@a, 41, 23, 24, 25, 26, 46, 47, 48); + +# 124: putdata (undef list) check +$s = $_->putdata("data", 5, 1, undef, 13.+0*i, 14.+0*i, 15.+0*i, 16.+0*i); +CheckOK2(124,1); +CheckNum(124,$s,4); + +@a = $_->getdata("data", 5, 0, 1, 0, $GetData::UINT8); +CheckOK2(124,2); +CheckArray(124, \@a, 41, 13, 14, 15, 16, 46, 47, 48); + +# 14: error_string check +$s = $_->getdata("x", 5, 0, 1, 0, $GetData::UINT8); +CheckError(14,$GetData::E_BAD_CODE); +CheckString(14, $_->error_string, "Field not found: x"); + +# 15: get_entry check +$s = $_->entry("data"); +CheckOK(15); +CheckNum(15,$s,$GetData::RAW_ENTRY); + +# 16: get_entry check +%h = $_->entry("data"); +CheckOK(16); +CheckSArray2(16, 0, [ sort keys %h ], + qw(data_type field field_type fragment_index scalar scalar_ind spf)); +CheckNum2(16, 1, $h{'data_type'}, $GetData::INT8); +CheckString2(16, 2, $h{'field'}, "data"); +CheckNum2(16, 3, $h{'field_type'}, $GetData::RAW_ENTRY); +CheckNum2(16, 4, $h{'fragment_index'}, 0); +CheckSArray2(16, 6, $h{'scalar'}, undef); +CheckArray2(16, 7, $h{'scalar_ind'}, undef); +CheckNum2(16, 8, $h{'spf'}, 8); + +# 18: get_entry check +%h = $_->entry("lincom"); +CheckOK(18); +CheckSArray2(18, 1, [ sort keys %h ], qw(b field field_type), + qw(fragment_index in_fields m n_fields scalar scalar_ind)); +CheckArray2(18, 2, $h{'b'}, 2.2, 3.3+4.4*i, 5.5); +CheckString2(18, 5, $h{'field'}, "lincom"); +CheckNum2(18, 6, $h{'field_type'}, $GetData::LINCOM_ENTRY); +CheckNum2(18, 7, $h{'fragment_index'}, 0); +CheckSArray2(18, 8, $h{'in_fields'}, qw(data INDEX linterp)); +CheckArray2(18, 3, $h{'m'}, 1.1, 2.2, 5.5); +CheckNum2(18, 10, $h{'n_fields'}, 3); +CheckSArray2(18, 11, $h{'scalar'}, undef, undef, "const", undef, undef, + "const"); +CheckArray2(18, 12, $h{'scalar_ind'}, undef, undef, -1, undef, undef, -1); + +# 20: get_entry check +%h = $_->entry("polynom"); +CheckOK(20); +CheckSArray2(20, 1, [ sort keys %h ], qw(a field field_type), + qw(fragment_index in_field poly_ord scalar scalar_ind)); +CheckArray2(20, 2, $h{'a'}, 1.1, 2.2, 2.2, 3.3+4.4*i, 5.5, 5.5); +CheckString2(20, 4, $h{'field'}, "polynom"); +CheckNum2(20, 5, $h{'field_type'}, $GetData::POLYNOM_ENTRY); +CheckNum2(20, 6, $h{'fragment_index'}, 0); +CheckString2(20, 7, $h{'in_field'}, "data"); +CheckNum2(20, 8, $h{'poly_ord'}, 5); +CheckSArray2(20, 9, $h{'scalar'}, undef, undef, undef, undef, "const", "const"); +CheckArray2(20, 10, $h{'scalar_ind'}, undef, undef, undef, undef, -1, -1); + +# 21: get_entry check +%h = $_->entry("linterp"); +CheckOK(21); +CheckSArray2(21, 0, [ sort keys %h ], qw(field field_type fragment_index), + qw(in_field table)); +CheckString2(21, 1, $h{'field'}, "... [truncated message content] |
From: <ket...@us...> - 2011-07-17 03:57:30
|
Revision: 590 http://getdata.svn.sourceforge.net/getdata/?rev=590&view=rev Author: ketiltrout Date: 2011-07-17 03:57:23 +0000 (Sun, 17 Jul 2011) Log Message: ----------- Win32: No symlinks. Modified Paths: -------------- trunk/getdata/configure.ac trunk/getdata/src/compat.c trunk/getdata/src/internal.h trunk/getdata/src/open.c trunk/getdata/src/raw.c Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-06-27 22:46:00 UTC (rev 589) +++ trunk/getdata/configure.ac 2011-07-17 03:57:23 UTC (rev 590) @@ -518,9 +518,9 @@ dnl functions AC_CHECK_FUNCS([_commit fchmod _fdopen fdopendir fseeko fseeko64 _fstat \ fstatat fstatat64 fsync ftello ftello64 getcwd _getcwd \ - getdelim gmtime_r _lseeki64 _mkdir nan _open openat _read \ - renameat _rmdir _snprintf stat64 _stat64 _strtoi64 strtoll \ - _strtoui64 strtoull _unlink unlinkat _write]) + getdelim gmtime_r _lseeki64 lstat _mkdir nan _open openat \ + _read renameat _rmdir _snprintf stat64 _stat64 _strtoi64 \ + strtoll _strtoui64 strtoull _unlink unlinkat _write]) if test "x$disable_c99" = "xno"; then AC_CHECK_FUNCS([cabs]) fi Modified: trunk/getdata/src/compat.c =================================================================== --- trunk/getdata/src/compat.c 2011-06-27 22:46:00 UTC (rev 589) +++ trunk/getdata/src/compat.c 2011-07-17 03:57:23 UTC (rev 590) @@ -30,6 +30,10 @@ #include <time.h> #endif +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif + /* The MSVCRT gmtime() is threadsafe */ #ifndef HAVE_GMTIME_R struct tm *gmtime_r(const time_t *timep, struct tm *result) @@ -161,7 +165,7 @@ char *ptr; dtrace("%i, %p, %zu", errnum, buf, buflen); - + ptr = strerror(errnum); strncpy(buf, ptr, buflen); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-06-27 22:46:00 UTC (rev 589) +++ trunk/getdata/src/internal.h 2011-07-17 03:57:23 UTC (rev 590) @@ -30,6 +30,7 @@ #include <string.h> #include <errno.h> #include <fcntl.h> +#include <sys/stat.h> #ifdef HAVE_UNISTD_H #include <unistd.h> @@ -218,6 +219,10 @@ # endif #endif +#ifndef HAVE_LSTAT +# define lstat stat +#endif + #ifdef HAVE__STRTOI64 # define gd_strtoll _strtoi64 #elif defined(HAVE_STRTOLL) Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-06-27 22:46:00 UTC (rev 589) +++ trunk/getdata/src/open.c 2011-07-17 03:57:23 UTC (rev 590) @@ -155,7 +155,12 @@ } /* only delete regular files */ - if (S_ISREG(statbuf.st_mode) || S_ISLNK(statbuf.st_mode)) { + if (S_ISREG(statbuf.st_mode) +#ifdef S_ISLNK + || S_ISLNK(statbuf.st_mode) +#endif + ) + { if (gd_UnlinkAt(D, dirfd, lamb->d_name, 0)) { char *name = (char *)malloc(strlen(filedir) + strlen(lamb->d_name) + 2); Modified: trunk/getdata/src/raw.c =================================================================== --- trunk/getdata/src/raw.c 2011-06-27 22:46:00 UTC (rev 589) +++ trunk/getdata/src/raw.c 2011-07-17 03:57:23 UTC (rev 590) @@ -151,7 +151,9 @@ if (!gd_RenameAt(file->D, dirfd1, file[1].name, dirfd0, file[0].name)) { int fd = gd_OpenAt(file->D, dirfd0, file[0].name, O_RDONLY, 0666); +#ifdef HAVE_FCHMOD fchmod(fd, mode); +#endif close(fd); free(file[1].name); file[1].name = NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-06-27 22:46:07
|
Revision: 589 http://getdata.svn.sourceforge.net/getdata/?rev=589&view=rev Author: ketiltrout Date: 2011-06-27 22:46:00 +0000 (Mon, 27 Jun 2011) Log Message: ----------- copy edit Modified Paths: -------------- trunk/getdata/man/gd_cbopen.3 Modified: trunk/getdata/man/gd_cbopen.3 =================================================================== --- trunk/getdata/man/gd_cbopen.3 2011-06-14 01:42:39 UTC (rev 588) +++ trunk/getdata/man/gd_cbopen.3 2011-06-27 22:46:00 UTC (rev 589) @@ -1,6 +1,6 @@ .\" gd_cbopen.3. The gd_cbopen man page. .\" -.\" Copyright (C) 2008, 2009, 2010 D. V. Wiebe +.\" Copyright (C) 2008, 2009, 2010, 2011 D. V. Wiebe .\" .\"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" .\" @@ -77,7 +77,7 @@ Specifies that double precision floating point raw data on disk is, or is not, stored in the middle-endian format used by older ARM processors. -These flag are only set the default endianness, and will be overridden when an +These flag only set the default endianness, and will be overridden when an .B /ENDIAN directive specifies the byte sex of .B RAW @@ -106,7 +106,7 @@ endianness of the data is opposite to that of the native architecture, whatever that might be. -These flag are only set the default endianness, and will be overridden when an +These flag only set the default endianness, and will be overridden when an .B /ENDIAN directive specifies the byte sex of .B RAW @@ -332,7 +332,7 @@ In .I pedantic -mode, the parser conforms to one specified Standards Version. This target +mode, the parser conforms to one specific Standards Version. This target version may change any number of times in the course of scanning a single format specification. If invoked using the .B GD_PEDANTIC This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-06-14 01:42:45
|
Revision: 588 http://getdata.svn.sourceforge.net/getdata/?rev=588&view=rev Author: ketiltrout Date: 2011-06-14 01:42:39 +0000 (Tue, 14 Jun 2011) Log Message: ----------- Fix perl CFLAGS computation. Fix GD_E_CREAT_EXCL error message. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/m4/perl.m4 trunk/getdata/src/errors.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-05-05 15:53:15 UTC (rev 587) +++ trunk/getdata/ChangeLog 2011-06-14 01:42:39 UTC (rev 588) @@ -1,3 +1,8 @@ +2011-06-13 D. V. Wiebe <ge...@ke...> svn:588 + * src/errors.c: Don't append strerror to the GD_E_CREAT_EXCL message. + + * m4/perl.m4: Fix perl CFLAGS. + 2011-05-05 D. V. Wiebe <ge...@ke...> svn:587 * src/open.c (_GD_CreateDirfile): Handle missing fdopendir. Modified: trunk/getdata/m4/perl.m4 =================================================================== --- trunk/getdata/m4/perl.m4 2011-05-05 15:53:15 UTC (rev 587) +++ trunk/getdata/m4/perl.m4 2011-06-14 01:42:39 UTC (rev 588) @@ -53,7 +53,8 @@ [ first_perl=5.8.0 perl_prog_list="perl perl5 \ -perl5.12 perl5.10 perl5.8 \ +perl5.14 perl5.12 perl5.10 perl5.8 \ +perl5.14.0 \ perl5.12.3 perl5.12.2 perl5.12.1 perl5.12.0 \ perl5.10.1 perl5.10.0 \ perl5.8.9 perl5.8.8 perl5.8.7 perl5.8.6 perl5.8.5 perl5.8.4 perl5.8.3 \ @@ -114,15 +115,18 @@ dnl calculate build flags GD_PERL_CONFIG([perl_archdir], [archlibexp]) PERL_CPPFLAGS="-I${perl_archdir}/CORE" - GD_PERL_CONFIG([PERL_CFLAGS], [cccdlflags]) - GD_PERL_CONFIG([PERL_LDFLAGS], [lddlflags]) - AC_MSG_CHECKING([Perl includes]) AC_MSG_RESULT([$PERL_CPPFLAGS]) AC_SUBST([PERL_CPPFLAGS]) + + GD_PERL_CONFIG([PERL_CCCDLFLAGS], [cccdlflags]) + GD_PERL_CONFIG([PERL_CCFLAGS], [ccflags]) + PERL_CFLAGS="${PERL_CCCDLFLAGS} ${PERL_CCFLAGS}" AC_MSG_CHECKING([Perl compiler flags]) AC_MSG_RESULT([$PERL_CFLAGS]) AC_SUBST([PERL_CFLAGS]) + + GD_PERL_CONFIG([PERL_LDFLAGS], [lddlflags]) AC_MSG_CHECKING([Perl linker flags]) AC_MSG_RESULT([$PERL_LDFLAGS]) AC_SUBST([PERL_LDFLAGS]) Modified: trunk/getdata/src/errors.c =================================================================== --- trunk/getdata/src/errors.c 2011-05-05 15:53:15 UTC (rev 587) +++ trunk/getdata/src/errors.c 2011-06-14 01:42:39 UTC (rev 588) @@ -82,7 +82,7 @@ { GD_E_CREAT, GD_E_CREAT_DIR, "Unable to create directory {2}: ", 1 }, { GD_E_CREAT, GD_E_CREAT_FORMAT, "Unable to create format file {2}: ", 1 }, { GD_E_CREAT, GD_E_CREAT_EXCL, "Unable to create dirfile {2}: already exists", - 1 }, + 0 }, /* GD_E_BAD_CODE: 4 = field code */ { GD_E_BAD_CODE, 0, "Field not found: {4}", 0 }, /* GD_E_BAD_TYPE: 1 = data type */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-05-05 15:53:21
|
Revision: 587 http://getdata.svn.sourceforge.net/getdata/?rev=587&view=rev Author: ketiltrout Date: 2011-05-05 15:53:15 +0000 (Thu, 05 May 2011) Log Message: ----------- Handle missing fdopendir. Perl tweaks. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/bindings/perl/GetData.xs trunk/getdata/bindings/perl/test/Makefile.am trunk/getdata/configure.ac trunk/getdata/src/internal.h trunk/getdata/src/open.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-05-05 15:24:29 UTC (rev 586) +++ trunk/getdata/ChangeLog 2011-05-05 15:53:15 UTC (rev 587) @@ -1,3 +1,6 @@ +2011-05-05 D. V. Wiebe <ge...@ke...> svn:587 + * src/open.c (_GD_CreateDirfile): Handle missing fdopendir. + 2011-05-05 D. V. Wiebe <ge...@ke...> svn:586 * src/internal.h: The encoding framework has changed: open, touch, size, move, unlink, and temp now all take the dirfd. Furthermore, to allow Modified: trunk/getdata/bindings/perl/GetData.xs =================================================================== --- trunk/getdata/bindings/perl/GetData.xs 2011-05-05 15:24:29 UTC (rev 586) +++ trunk/getdata/bindings/perl/GetData.xs 2011-05-05 15:53:15 UTC (rev 587) @@ -911,8 +911,8 @@ ALIAS: GetData::Dirfile::get_carray = 1 PPCODE: - dtrace("%p, \"%s\", %03x; %lu", dirfile, field_code, return_type, - GIMME_V); + dtrace("%p, \"%s\", %03x; %i", dirfile, field_code, return_type, + (int)GIMME_V); size_t len = gd_carray_len(dirfile, field_code); data_out = safemalloc(GD_SIZE(return_type) * len); gd_get_carray(dirfile, field_code, return_type, data_out); @@ -940,8 +940,8 @@ ALIAS: GetData::Dirfile::get_carray_slice = 1 PPCODE: - dtrace("%p, \"%s\", %u, %zi, %03x; %lu", dirfile, field_code, return_type, - start, len, GIMME_V); + dtrace("%p, \"%s\", %u, %zi, %03x; %i", dirfile, field_code, start, len, + return_type, (int)GIMME_V); data_out = safemalloc(GD_SIZE(return_type) * len); gd_get_carray_slice(dirfile, field_code, start, len, return_type, data_out); @@ -1007,7 +1007,7 @@ ALIAS: GetData::Dirfile::constants = 1 PPCODE: - dtrace("%p, %03x; %lu", dirfile, return_type, GIMME_V); + dtrace("%p, %03x; %i", dirfile, return_type, (int)GIMME_V); int len = gd_nfields_by_type(dirfile, GD_CONST_ENTRY); data_out = gd_constants(dirfile, return_type); @@ -1030,7 +1030,7 @@ ALIAS: GetData::Dirfile::carrays = 1 PPCODE: - dtrace("%p, %03x; %lu", dirfile, return_type, GIMME_V); + dtrace("%p, %03x; %i", dirfile, return_type, (int)GIMME_V); I32 i, len = (I32)gd_nfields_by_type(dirfile, GD_CARRAY_ENTRY); data_out = gd_carrays(dirfile, return_type); @@ -1061,7 +1061,7 @@ ALIAS: GetData::Dirfile::entry = 1 PPCODE: - dtrace("%p, \"%s\"; %lu", dirfile, field_code, GIMME_V); + dtrace("%p, \"%s\"; %i", dirfile, field_code, (int)GIMME_V); if (GIMME_V == G_ARRAY) { gd_entry_t E; @@ -1219,7 +1219,7 @@ ALIAS: GetData::Dirfile::mconstants = 1 PPCODE: - dtrace("%p, %03x; %lu", dirfile, return_type, GIMME_V); + dtrace("%p, %03x; %i", dirfile, return_type, (int)GIMME_V); int len = gd_nmfields_by_type(dirfile, parent, GD_CONST_ENTRY); data_out = gd_mconstants(dirfile, parent, return_type); @@ -1340,9 +1340,9 @@ ALIAS: GetData::Dirfile::getdata = 1 PPCODE: - dtrace("%p, \"%s\", %lli, %lli, %zi, %zi, %03x; %lu", dirfile, field_code, + dtrace("%p, \"%s\", %lli, %lli, %zi, %zi, %03x; %i", dirfile, field_code, (long long)first_frame, (long long)first_samp, num_frames, num_samp, - return_type, GIMME_V); + return_type, (int)GIMME_V); if (num_frames) { spf = gd_spf(dirfile, field_code); @@ -1375,7 +1375,7 @@ ALIAS: GetData::Dirfile::field_list = 1 PPCODE: - dtrace("%p; %lu", dirfile, GIMME_V); + dtrace("%p; %i", dirfile, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1405,7 +1405,7 @@ ALIAS: GetData::Dirfile::field_list_by_type = 1 PPCODE: - dtrace("%p, %i; %lu", dirfile, type, GIMME_V); + dtrace("%p, %i; %i", dirfile, type, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1434,7 +1434,7 @@ ALIAS: GetData::Dirfile::vector_list = 1 PPCODE: - dtrace("%p; %lu", dirfile, GIMME_V); + dtrace("%p; %i", dirfile, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1463,7 +1463,7 @@ ALIAS: GetData::Dirfile::strings = 1 PPCODE: - dtrace("%p; %lu", dirfile, GIMME_V); + dtrace("%p; %i", dirfile, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1493,7 +1493,7 @@ ALIAS: GetData::Dirfile::mfield_list = 1 PPCODE: - dtrace("%p, \"%s\"; %lu", dirfile, field_code, GIMME_V); + dtrace("%p, \"%s\"; %i", dirfile, field_code, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1524,7 +1524,7 @@ ALIAS: GetData::Dirfile::mfield_list_by_type = 1 PPCODE: - dtrace("%p, \"%s\", %i; %lu", dirfile, parent, type, GIMME_V); + dtrace("%p, \"%s\", %i; %i", dirfile, parent, type, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1554,7 +1554,7 @@ ALIAS: GetData::Dirfile::mvector_list = 1 PPCODE: - dtrace("%p; %lu", dirfile, GIMME_V); + dtrace("%p; %i", dirfile, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1584,7 +1584,7 @@ ALIAS: GetData::Dirfile::mstrings = 1 PPCODE: - dtrace("%p, \"%s\"; %lu", dirfile, field_code, GIMME_V); + dtrace("%p, \"%s\"; %i", dirfile, field_code, (int)GIMME_V); /* in array context, return the field list, otherwise return nfields */ if (GIMME_V == G_ARRAY) { @@ -1617,7 +1617,7 @@ ALIAS: GetData::Dirfile::put_carray = 1 CODE: - dtrace("%p, \"%s\", %p, ...[%li]", dirfile, field_code, d, items - 3); + dtrace("%p, \"%s\", %p, ...[%li]", dirfile, field_code, d, (long)items - 3); din = gdp_convert_data(d, items, ax, 2, gdp_package, "put_carray"); @@ -1645,7 +1645,7 @@ GetData::Dirfile::put_carray_slice = 1 CODE: dtrace("%p, \"%s\", %lli, %p, ...[%li]", dirfile, field_code, - (long long)start, d, items - 4); + (long long)start, d, (long)items - 4); din = gdp_convert_data(d, items, ax, 3, gdp_package, "put_carray"); @@ -1675,7 +1675,7 @@ GetData::Dirfile::add_carray = 1 CODE: dtrace("%p, \"%s\", %03x, %i, %p, ...[%li]", dirfile, field_code, - const_type, fragment_index, d, items - 5); + const_type, fragment_index, d, (long)items - 5); din = gdp_convert_data(d, items, ax, 4, gdp_package, "put_carray"); @@ -1705,7 +1705,7 @@ GetData::Dirfile::madd_carray = 1 CODE: dtrace("%p, \"%s\", \"%s\", %03x, %p, ...[%li]", dirfile, parent, - field_code, const_type, d, items - 5); + field_code, const_type, d, (long)items - 5); din = gdp_convert_data(d, items, ax, 4, gdp_package, "put_carray"); @@ -1735,7 +1735,7 @@ GetData::Dirfile::putdata = 1 CODE: dtrace("%p, \"%s\", %lli, %lli, %p, ...[%li]", dirfile, field_code, - (long long)first_frame, (long long)first_sample, d, items - 5); + (long long)first_frame, (long long)first_sample, d, (long)items - 5); din = gdp_convert_data(d, items, ax, 4, gdp_package, "putdata"); @@ -1843,7 +1843,7 @@ ALIAS: GetData::Dirfile::fragments = 1 PPCODE: - dtrace("%p; %lu", dirfile, GIMME_V); + dtrace("%p; %i", dirfile, (int)GIMME_V); nf = gd_nfragments(dirfile); Modified: trunk/getdata/bindings/perl/test/Makefile.am =================================================================== --- trunk/getdata/bindings/perl/test/Makefile.am 2011-05-05 15:24:29 UTC (rev 586) +++ trunk/getdata/bindings/perl/test/Makefile.am 2011-05-05 15:53:15 UTC (rev 587) @@ -20,8 +20,7 @@ # AUTOMAKE_OPTIONS = foreign -TESTS_ENVIRONMENT=${PERL} -I.. -I../.libs -#TESTS_ENVIRONMENT=valgrind --leak-check=full --track-origins=yes ${PERL} -I.. -I../.libs +TESTS_ENVIRONMENT=${DL_LIBRARY_PATH}=../.libs:${${DL_LIBRARY_PATH}}:../../../src/.libs ${PERL} -I.. -I../.libs perlTESTS=callback.pl big_test.pl TESTS=$(addprefix ${srcdir}/,$(perlTESTS)) Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-05-05 15:24:29 UTC (rev 586) +++ trunk/getdata/configure.ac 2011-05-05 15:53:15 UTC (rev 587) @@ -239,7 +239,7 @@ esac ]) -AC_MSG_CHECKING([whether to include the Python bindings]) +AC_MSG_CHECKING([whether to include the Perl bindings]) if test "x$disable_c99" = "xyes"; then make_perlbindings="no"; AC_MSG_RESULT([no (requires C99 compiler)]) @@ -460,17 +460,21 @@ GD_LANG_F77_COMPILER_INTEL fi +dnl F77 stuff +if test "x$make_f77bindings" != "xno"; then + AC_F77_WRAPPERS + if test "x$ac_cv_f77_mangling" == "xunknown"; then + make_f77bindings=no + make_f95bindings=no + fi +fi + if test "x$make_f95bindings" != "xno"; then GD_PROG_FC_WALL GD_PROG_FC_WEXTRA GD_LANG_FC_COMPILER_INTEL fi -dnl F77 stuff -if test "x$make_f77bindings" != "xno"; then - AC_F77_WRAPPERS -fi - AC_MSG_CHECKING([if we're linking against the Microsoft C Run-Time]) #' AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[#ifndef __MSVCRT__ choke me Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-05-05 15:24:29 UTC (rev 586) +++ trunk/getdata/src/internal.h 2011-05-05 15:53:15 UTC (rev 587) @@ -703,7 +703,7 @@ #define _GD_MakeFullPath gd_MakeFullPath char *_GD_MakeFullPath(const DIRFILE *D, int dirfd, const char *name); int gd_MakeTempFile(const DIRFILE*, int, char*); -int _GD_MissingFramework(unsigned long encoding, unsigned int funcs); +int _GD_MissingFramework(int encoding, unsigned int funcs); int _GD_MogrifyFile(DIRFILE* D, gd_entry_t* E, unsigned long int encoding, unsigned long int byte_sex, off64_t offset, int finalise, int new_fragment, char* new_filebase); Modified: trunk/getdata/src/open.c =================================================================== --- trunk/getdata/src/open.c 2011-05-05 15:24:29 UTC (rev 586) +++ trunk/getdata/src/open.c 2011-05-05 15:53:15 UTC (rev 587) @@ -124,13 +124,19 @@ return NULL; } +#ifdef HAVE_FDOPENDIR /* crawl the directory, and delete everything */ if ((fd = dup(dirfd)) == -1) { _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_DIR, filedir, errno, NULL); dreturn("%p", NULL); return NULL; } - if ((dir = fdopendir(fd)) == NULL) { + dir = fdopendir(fd); +#else + dir = opendir(filedir); +#endif + + if (dir == NULL) { _GD_SetError(D, GD_E_TRUNC, GD_E_TRUNC_DIR, filedir, errno, NULL); dreturn("%p", NULL); return NULL; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ket...@us...> - 2011-05-05 15:24:38
|
Revision: 586 http://getdata.svn.sourceforge.net/getdata/?rev=586&view=rev Author: ketiltrout Date: 2011-05-05 15:24:29 +0000 (Thu, 05 May 2011) Log Message: ----------- A big update concerning how we deal with directories. The first part of the solution to Matt's chdir() problem. Basically, we now open() the directories which concern us to keep track of them, and then use the POSIX.1-2008 at functions to run around. This doesn't really work yet. Also fixed a few minor bugs. Modified Paths: -------------- trunk/getdata/ChangeLog trunk/getdata/configure.ac trunk/getdata/m4/version.m4 trunk/getdata/src/add.c trunk/getdata/src/ascii.c trunk/getdata/src/bzip.c trunk/getdata/src/close.c trunk/getdata/src/common.c trunk/getdata/src/compat.c trunk/getdata/src/del.c trunk/getdata/src/encoding.c trunk/getdata/src/endian.c trunk/getdata/src/entry.c trunk/getdata/src/flimits.c trunk/getdata/src/flush.c trunk/getdata/src/getdata.c trunk/getdata/src/getdata.h.in trunk/getdata/src/gzip.c trunk/getdata/src/include.c trunk/getdata/src/internal.h trunk/getdata/src/legacy.c trunk/getdata/src/lzma.c trunk/getdata/src/mod.c trunk/getdata/src/move.c trunk/getdata/src/name.c trunk/getdata/src/nframes.c trunk/getdata/src/open.c trunk/getdata/src/parse.c trunk/getdata/src/putdata.c trunk/getdata/src/raw.c trunk/getdata/src/slim.c trunk/getdata/test/add_raw.c trunk/getdata/test/error_num.c trunk/getdata/test/file.c Modified: trunk/getdata/ChangeLog =================================================================== --- trunk/getdata/ChangeLog 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/ChangeLog 2011-05-05 15:24:29 UTC (rev 586) @@ -1,3 +1,67 @@ +2011-05-05 D. V. Wiebe <ge...@ke...> svn:586 + * src/internal.h: The encoding framework has changed: open, touch, size, + move, unlink, and temp now all take the dirfd. Furthermore, to allow + operation on non-POSIX.1-2008 systems, we hide the DIRFILE pointer in + _gd_raw_file, so callback can be made to the compatibility layer. All + framework callers have been updated to pass dirfds. fragment->sname is no + longer malloc'd and is now marked const; also, fragments now carry their + dirfd. D->dir and D->ndir added. + * src/encoding.c (gd_MakeTempFile) src/compat.c (gd_OpenAt gd_RenameAt + gd_StatAt gd_StatAt64 gd_UnlinkAt) src/common.c (_GD_DirName + _GD_MakeFullPath _GD_GrabDir _GD_ReleaseDir): Added. + * src/open.c (gd_cbopen): Open the dirfile directory as soon as possible, + then work as much as possible with the descriptor instead of the path + itself. + * src/open.c (_GD_CreateDirfile): Use the dirfd produced by cb_open() + instead of relying on the pathname except with GD_CREAT. As a side effect, + no longer need to compute fullname when truncating. + * src/entry.c (_GD_FreeE): Release LUT directory. This requires passing the + DIRFILE to this function. + * src/close.c (_GD_FreeD): Don't free fragment->sname (it's no longer + malloc'd). Free D->dir. + * src/close.c (_GD_ShutdownDirfile): Close all open directories. + * src/flush.c (_GD_FlushFragment): Call gd_MakeTempFile instead of mkstemp. + * src/encoding.c (_GD_SetEncodedName): set file->D to the DIRFILE pointer, + so the encoding framework has access to it. + * src/encoding.c (_GD_ResolveEncoding): Take dirfd for I/O purposes. + * src/move.c (_GD_MogrifyFile): Consider changes in dirfd. + * src/parse.c (_GD_ParseRaw): E->e->u.raw.filebase is a copy of E->field + now, (and could be removed, except we'll need it shortly). The fragment + index (me) is no longer needed in this function. + * src/mod.c (_GD_Change): Release the LUT directory if it changes. + * src/include.c (_GD_Include): Open the grab the included fragment's + directory and store it in fragment->dirfd. fragment->sname is now just the + value returned by _GD_DirName, and not malloc'd. + * src/include.c (gd_uninclude): Release the directory. + * src/compat.c (mkstemp _GD_Rename): Removed. + * src/common.c (_GD_SetTablePath): Open the directory. table_path is + replaced with table_file. + + * src/encoding.c (_GD_GenericTouch _GD_GenericUnlink _GD_GenericMove) + src/slim.c (_GD_SlimOpen _GD_SlimSize) src/gzip.c (_GD_GzipOpen _GD_GzipSize) + src/ascii.c (_GD_AsciiOpen _GD_AsciiSize _GD_AsciiTemp) src/lzma.c + (_GD_LzmaOpen _GD_LzmaSize) src/bzip.c (_GD_Bzip2Open _GD_Bzip2Size): Update + for changes in the encoding framework. + + * src/slim.c (_GD_SlimOpen _GD_SlimSize): Slimlib doesn't accept file + descriptors, so compute the full path before calling it. This has the + potential for breakage. + * src/gzip.c (_GD_GzipOpen _GD_GzipSize): Use gzdopen instead of gzopen. + * src/lzma.c (_GD_LzmaDoOpen) src/bzip.c (_GD_Bzip2DoOpen): Use dirfd to + create stream. + + * src/legacy.c (_GD_GetDirfile) src/name.c (gd_rename) src/encoding.c + (_GD_MissingFramework _GD_ResolveEncoding) src/move.c (gd_move) + src/include.c (_GD_Include) src/add.c (_GD_Add): Remove the FILENAME_MAX + crutch. + + * src/add.c (_GD_Add): Fix memory leak of new_ref. + + * src/entry.c (gd_raw_filename): Return a malloc'd string. + + * configure.ac: Fix am__fastdepCXX_* for --disable-cplusplus. This is + presumably a autotools bug. Look for ...at() functions. + 2011-04-21 D. V. Wiebe <ge...@ke...> svn:581 * bindings/python/pydirfile.c (gdpy_dirfile_geterrorcount): Added. * bindings/cxx/dirfile.cpp (Dirfile::ErrorCount): Added. Modified: trunk/getdata/configure.ac =================================================================== --- trunk/getdata/configure.ac 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/configure.ac 2011-05-05 15:24:29 UTC (rev 586) @@ -139,6 +139,7 @@ make_f77bindings="no" make_pybindings="no" make_idlbindings="no" + make_perlbindings="no" fi ]) @@ -334,6 +335,9 @@ echo AC_PROG_CXX AC_PROG_CXX_C_O +else + am__fastdepCXX_TRUE= + am__fastdepCXX_FALSE='#' fi if test "x$make_f77bindings" != "xno"; then echo @@ -508,10 +512,11 @@ fi dnl functions -AC_CHECK_FUNCS([_commit fchmod _fdopen fseeko fseeko64 fsync ftello ftello64 \ - getcwd _getcwd getdelim gmtime_r _lseeki64 _mkdir mkstemp nan \ - _open _read _rmdir _snprintf stat64 _stat64 _strtoi64 strtoll \ - _strtoui64 strtoull _unlink _write]) +AC_CHECK_FUNCS([_commit fchmod _fdopen fdopendir fseeko fseeko64 _fstat \ + fstatat fstatat64 fsync ftello ftello64 getcwd _getcwd \ + getdelim gmtime_r _lseeki64 _mkdir nan _open openat _read \ + renameat _rmdir _snprintf stat64 _stat64 _strtoi64 strtoll \ + _strtoui64 strtoull _unlink unlinkat _write]) if test "x$disable_c99" = "xno"; then AC_CHECK_FUNCS([cabs]) fi Modified: trunk/getdata/m4/version.m4 =================================================================== --- trunk/getdata/m4/version.m4 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/m4/version.m4 2011-05-05 15:24:29 UTC (rev 586) @@ -19,9 +19,9 @@ dnl 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA m4_define(getdata_major, 0) -m4_define(getdata_minor, 7) -m4_define(getdata_revision, 2) -m4_define(getdata_extra, []) +m4_define(getdata_minor, 8) +m4_define(getdata_revision, 0) +m4_define(getdata_extra, [a]) m4_define(getdata_version, getdata_major.getdata_minor.getdata_revision[]getdata_extra) Modified: trunk/getdata/src/add.c =================================================================== --- trunk/getdata/src/add.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/add.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -22,7 +22,6 @@ #ifdef STDC_HEADERS #include <stdlib.h> -#include <stdio.h> #include <string.h> #include <errno.h> #endif @@ -34,7 +33,7 @@ /* add an entry */ static int _GD_Add(DIRFILE* D, const gd_entry_t* entry, const char* parent) { - char temp_buffer[FILENAME_MAX]; + char *temp_buffer; int i, is_dot; int copy_scalar[GD_MAX_POLYORD + 1]; void* new_list; @@ -89,18 +88,28 @@ return -1; } - snprintf(temp_buffer, FILENAME_MAX, "%s/%s", parent, entry->field); + temp_buffer = (char *)malloc(strlen(parent) + strlen(entry->field) + 2); + if (temp_buffer) + strcat(strcat(strcpy(temp_buffer, parent), "/"), entry->field); } else - snprintf(temp_buffer, FILENAME_MAX, "%s", entry->field); + temp_buffer = strdup(entry->field); + if (temp_buffer == NULL) { + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + /* check for duplicate field */ E = _GD_FindField(D, temp_buffer, D->entry, D->n_entries, &u); if (E != NULL) { /* matched */ _GD_SetError(D, GD_E_DUPLICATE, 0, NULL, 0, temp_buffer); + free(temp_buffer); dreturn("%i", -1); return -1; } + free(temp_buffer); /* check for bad field type */ if (entry->field_type != GD_RAW_ENTRY && @@ -153,12 +162,12 @@ if (E->field == entry->field) { _GD_SetError(D, GD_E_BAD_CODE, 0, NULL, 0, entry->field); E->field = NULL; - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); dreturn("%i", -1); return -1; } else if (E->field == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); dreturn("%i", -1); return -1; } @@ -190,14 +199,10 @@ E->e->u.raw.file[0].fp = E->e->u.raw.file[1].fp = -1; E->e->u.raw.file[0].encoding = GD_ENC_UNKNOWN; - if ((E->e->u.raw.filebase = (char *)malloc(FILENAME_MAX)) == NULL) { + if ((E->e->u.raw.filebase = strdup(E->field)) == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); break; } - - snprintf(E->e->u.raw.filebase, FILENAME_MAX, "%s/%s", - D->fragment[E->fragment_index].sname ? - D->fragment[E->fragment_index].sname : D->name, E->field); if ((E->EN(raw,spf) = entry->EN(raw,spf)) == 0) _GD_SetError(D, GD_E_BAD_ENTRY, GD_E_BAD_ENTRY_SPF, NULL, @@ -209,7 +214,8 @@ ; /* error already set */ else if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) ; /* error already set */ - else if ((*_gd_ef[E->e->u.raw.file[0].encoding].touch)(E->e->u.raw.file)) + else if ((*_gd_ef[E->e->u.raw.file[0].encoding].touch)( + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file)) _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); else if (D->fragment[E->fragment_index].ref_name == NULL) { @@ -413,7 +419,7 @@ if (D->error != GD_E_OK) { free(new_ref); - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); dreturn("%i", -1); return -1; } @@ -421,7 +427,7 @@ new_list = realloc(D->entry, (D->n_entries + 1) * sizeof(gd_entry_t*)); if (new_list == NULL) { free(new_ref); - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); dreturn("%i", -1); return -1; } @@ -431,7 +437,7 @@ new_list = realloc(D->dot_list, (D->n_dot + 1) * sizeof(gd_entry_t*)); if (new_list == NULL) { free(new_ref); - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); dreturn("%i", -1); return -1; } @@ -443,7 +449,7 @@ sizeof(gd_entry_t*)); if (ptr == NULL) { free(new_ref); - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); dreturn("%i", -1); return -1; } @@ -485,6 +491,7 @@ if (D->reference_field == NULL) D->reference_field = E; + free(new_ref); } } @@ -801,7 +808,7 @@ gd_entry_t B; int error; - dtrace("%p, \"%s\", \"%s\", %i, %i, %i\n", D, field_code, in_field, bitnum, + dtrace("%p, \"%s\", \"%s\", %i, %i, %i", D, field_code, in_field, bitnum, numbits, fragment_index); if (D->flags & GD_INVALID) {/* don't crash */ @@ -830,7 +837,7 @@ gd_entry_t B; int error; - dtrace("%p, \"%s\", \"%s\", %i, %i, %i\n", D, field_code, in_field, bitnum, + dtrace("%p, \"%s\", \"%s\", %i, %i, %i", D, field_code, in_field, bitnum, numbits, fragment_index); if (D->flags & GD_INVALID) {/* don't crash */ Modified: trunk/getdata/src/ascii.c =================================================================== --- trunk/getdata/src/ascii.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/ascii.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -34,14 +34,14 @@ /* The ASCII encoding uses file->fp as to indicate the current line and * file->edata for the stream pointer */ -int _GD_AsciiOpen(struct _gd_raw_file* file, int mode, int creat) +int _GD_AsciiOpen(int dirfd, struct _gd_raw_file* file, int mode, int creat) { int fp; - dtrace("%p, %i, %i", file, mode, creat); + dtrace("%i, %p, %i, %i", dirfd, file, mode, creat); - fp = open(file->name, ((mode == GD_RDWR) ? O_RDWR : O_RDONLY) | - (creat ? O_CREAT : 0) | O_BINARY, 0666); + fp = gd_OpenAt(file->D, dirfd, file->name, ((mode == GD_RDWR) ? O_RDWR : + O_RDONLY) | (creat ? O_CREAT : 0) | O_BINARY, 0666); file->edata = fdopen(fp, (mode == GD_RDWR) ? "r+" : "r"); @@ -351,18 +351,25 @@ return 1; } -off64_t _GD_AsciiSize(struct _gd_raw_file* file, +off64_t _GD_AsciiSize(int dirfd, struct _gd_raw_file* file, gd_type_t data_type __gd_unused) { FILE* stream; char *buffer = NULL; size_t len = 0; off64_t n = 0; + int fd; - dtrace("%p, <unused>", file); + dtrace("%i, %p, <unused>", dirfd, file); - stream = fopen(file->name, "r"); + fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY, 0666); + if (fd == -1) { + dreturn("%i", -1); + return -1; + } + stream = fdopen(fd, "r"); + if (stream == NULL) { dreturn("%i", -1); return -1; @@ -378,18 +385,18 @@ return n; } -int _GD_AsciiTemp(struct _gd_raw_file *file, int method) +int _GD_AsciiTemp(int dirfd0, int dirfd1, struct _gd_raw_file *file, int method) { int move_error = 0; struct stat stat_buf; mode_t mode; int fp; - dtrace("%p, %i", file, method); + dtrace("%i, %i, %p, %i", dirfd0, dirfd1, file, method); switch(method) { case GD_TEMP_OPEN: - fp = mkstemp(file[1].name); + fp = gd_MakeTempFile(file[1].D, dirfd1, file[1].name); file[1].edata = fdopen(fp, "r+"); @@ -409,7 +416,7 @@ else mode = stat_buf.st_mode; - if (!_GD_Rename(file[1].name, file[0].name)) { + if (!gd_RenameAt(file->D, dirfd1, file[1].name, dirfd0, file[0].name)) { chmod(file[0].name, mode); free(file[1].name); file[1].name = NULL; Modified: trunk/getdata/src/bzip.c =================================================================== --- trunk/getdata/src/bzip.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/bzip.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -59,23 +59,31 @@ /* The bzip encoding scheme uses edata as a gd_bzdata pointer. If a file is * open, fp = 0 otherwise fp = -1. */ -static struct gd_bzdata *_GD_Bzip2DoOpen(struct _gd_raw_file* file) +static struct gd_bzdata *_GD_Bzip2DoOpen(int dirfd, struct _gd_raw_file* file) { + int fd; struct gd_bzdata *ptr; - dtrace("%p", file); + dtrace("%i, %p", dirfd, file); if ((ptr = (struct gd_bzdata *)malloc(sizeof(struct gd_bzdata))) == NULL) { dreturn("%p", NULL); return NULL; } - if ((ptr->stream = fopen(file->name, "rb")) == NULL) { + if ((fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY, 0666)) == -1) { free(ptr); dreturn("%p", NULL); return NULL; } + if ((ptr->stream = fdopen(fd, "rb")) == NULL) { + close(fd); + free(ptr); + dreturn("%p", NULL); + return NULL; + } + ptr->bzerror = ptr->stream_end = 0; ptr->bzfile = BZ2_bzReadOpen(&ptr->bzerror, ptr->stream, 0, 0, NULL, 0); @@ -93,12 +101,12 @@ return ptr; } -int _GD_Bzip2Open(struct _gd_raw_file* file, int mode __gd_unused, +int _GD_Bzip2Open(int dirfd, struct _gd_raw_file* file, int mode __gd_unused, int creat __gd_unused) { - dtrace("%p, <unused>, <unused>", file); + dtrace("%i, %p, <unused>, <unused>", dirfd, file); - file->edata = _GD_Bzip2DoOpen(file); + file->edata = _GD_Bzip2DoOpen(dirfd, file); if (file->edata == NULL) { dreturn("%i", 1); @@ -238,14 +246,14 @@ return 1; } -off64_t _GD_Bzip2Size(struct _gd_raw_file *file, gd_type_t data_type) +off64_t _GD_Bzip2Size(int dirfd, struct _gd_raw_file *file, gd_type_t data_type) { struct gd_bzdata *ptr; off_t n; - dtrace("%p, %x", file, data_type); + dtrace("%i, %p, %x", dirfd, file, data_type); - ptr = _GD_Bzip2DoOpen(file); + ptr = _GD_Bzip2DoOpen(dirfd, file); if (ptr == NULL) { dreturn("%i", -1); Modified: trunk/getdata/src/close.c =================================================================== --- trunk/getdata/src/close.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/close.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -34,11 +34,10 @@ dtrace("%p", D); for (i = 0; i < D->n_entries; ++i) - _GD_FreeE(D->entry[i], 1); + _GD_FreeE(D, D->entry[i], 1); for (j = 0; j < D->n_fragment; ++j) { free(D->fragment[j].cname); - free(D->fragment[j].sname); free(D->fragment[j].ename); free(D->fragment[j].ref_name); } @@ -59,6 +58,9 @@ free(D->carray_value_list); free(D->fragment); free(D->name); + for (i = 0; i < D->ndir; ++i) + free(D->dir[i].path); + free(D->dir); free(D); dreturnvoid(); @@ -90,6 +92,10 @@ return -1; } + /* close the directory */ + for (i = 0; i < (unsigned int)D->ndir; ++i) + close(D->dir[i].fd); + _GD_FreeD(D); dreturn("%i", 0); Modified: trunk/getdata/src/common.c =================================================================== --- trunk/getdata/src/common.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/common.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2010 D. V. Wiebe + * Copyright (C) 2005-2011 D. V. Wiebe * *************************************************************************** * @@ -188,27 +188,25 @@ dtrace("%p, %p, %p", D, E, e); - if (E->EN(linterp,table)[0] == '/') { - e->u.linterp.table_path = strdup(E->EN(linterp,table)); - if (e->u.linterp.table_path == NULL) { - _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); - dreturn("%i", 1); - return 1; - } - } else { - e->u.linterp.table_path = (char *)malloc(strlen(E->EN(linterp,table)) + 2 + - strlen(D->fragment[E->fragment_index].cname)); - if (e->u.linterp.table_path == NULL) { - _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); - dreturn("%i", 1); - return 1; - } - temp_buffer = strdup(D->fragment[E->fragment_index].cname); - strcpy(e->u.linterp.table_path, dirname(temp_buffer)); - strcat(e->u.linterp.table_path, "/"); - strcat(e->u.linterp.table_path, E->EN(linterp,table)); + e->u.linterp.table_dirfd = _GD_GrabDir(D, + D->fragment[E->fragment_index].dirfd, E->EN(linterp,table)); + + temp_buffer = strdup(E->EN(linterp,table)); + if (temp_buffer == NULL) { + _GD_ReleaseDir(D, e->u.linterp.table_dirfd); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", 1); + return 1; + } + e->u.linterp.table_file = strdup(basename(temp_buffer)); + if (e->u.linterp.table_file == NULL) { + _GD_ReleaseDir(D, e->u.linterp.table_dirfd); free(temp_buffer); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", 1); + return 1; } + free(temp_buffer); dreturn("%i", 0); return 0; @@ -227,7 +225,7 @@ { FILE *fp; struct _gd_lut *ptr; - int i; + int i, fd; int dir = -1; char *line; size_t n = 0; @@ -237,16 +235,25 @@ dtrace("%p, %p", D, E); - if (E->e->u.linterp.table_path == NULL) + if (E->e->u.linterp.table_file == NULL) if (_GD_SetTablePath(D, E, E->e)) { dreturnvoid(); return; } - fp = fopen(E->e->u.linterp.table_path, "r"); + fd = gd_OpenAt(D, E->e->u.linterp.table_dirfd, E->e->u.linterp.table_file, + O_RDONLY, 0666); + if (fd == -1) { + _GD_SetError(D, GD_E_OPEN_LINFILE, GD_E_LINFILE_OPEN, NULL, 0, + E->EN(linterp,table)); + dreturnvoid(); + return; + } + + fp = fdopen(fd, "r"); if (fp == NULL) { _GD_SetError(D, GD_E_OPEN_LINFILE, GD_E_LINFILE_OPEN, NULL, 0, - E->e->u.linterp.table_path); + E->EN(linterp,table)); dreturnvoid(); return; } @@ -259,12 +266,12 @@ } else { if (errno == EOVERFLOW) /* line too long */ - _GD_SetError(D, GD_E_LINE_TOO_LONG, 0, E->e->u.linterp.table_path, - linenum, NULL); + _GD_SetError(D, GD_E_LINE_TOO_LONG, 0, E->EN(linterp,table), linenum, + NULL); else /* no data in file! */ _GD_SetError(D, GD_E_OPEN_LINFILE, GD_E_LINFILE_LENGTH, NULL, 0, - E->e->u.linterp.table_path); + E->EN(linterp,table)); fclose(fp); dreturnvoid(); return; @@ -321,7 +328,7 @@ if (i < 2) { free(E->e->u.linterp.lut); _GD_SetError(D, GD_E_OPEN_LINFILE, GD_E_LINFILE_LENGTH, NULL, 0, - E->e->u.linterp.table_path); + E->EN(linterp,table)); fclose(fp); dreturnvoid(); return; @@ -677,7 +684,7 @@ do { \ for (i = 0; i < n_read; i++) { \ const t d = ((t *)data)[2 * i] * ((t *)data)[2 * i] + \ - ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ + ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ ((t *)data)[2 * i] = (t)(dividend * ((t *)data)[2 * i] / d); \ ((t *)data)[2 * i + 1] = (t)(-dividend * ((t *)data)[2 * i + 1] / d); \ } \ @@ -725,7 +732,7 @@ do { \ for (i = 0; i < n_read; i++) { \ const t d = ((t *)data)[2 * i] * ((t *)data)[2 * i] + \ - ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ + ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ ((t *)data)[2 * i] = (t)((dividend[0] * ((t *)data)[2 * i] - \ dividend[1] * ((t *)data)[2 * i + 1]) / d); \ ((t *)data)[2 * i + 1] = (t)((dividend[1] * ((t *)data)[2 * i] - \ @@ -737,7 +744,7 @@ do { \ for (i = 0; i < n_read; i++) { \ const t d = ((t *)data)[2 * i] * ((t *)data)[2 * i] + \ - ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ + ((t *)data)[2 * i + 1] * ((t *)data)[2 * i + 1]; \ ((t *)data)[2 * i] = (t)((dividend[0] * ((t *)data)[2 * i] - \ dividend[1] * ((t *)data)[2 * i + 1]) / d); \ } \ @@ -883,5 +890,149 @@ dreturn("%p %i", E, *repr); return E; } + +const char *_GD_DirName(const DIRFILE *D, int dirfd) +{ + unsigned int i; + + dtrace("%p, %i", D, dirfd); + + for (i = 0; i < D->ndir; ++i) + if (dirfd == D->dir[i].fd) { + dreturn("\"%s\"", D->dir[i].path); + return D->dir[i].path; + } + + /* we only get here in the early stages of opening a dirfile */ + dreturn("%p", D->name); + return D->name; +} + +char *_GD_MakeFullPath(const DIRFILE *D, int dirfd, const char *name) +{ + const char *dir; + char *filepath; + dtrace("%p, %i, \"%s\"", D, dirfd, name); + + dir = _GD_DirName(D, dirfd); + if (dir == NULL) { + dreturn("%p", NULL); + return NULL; + } + + filepath = (char *)malloc(strlen(dir) + strlen(name) + 2); + if (filepath == NULL) { + dreturn("%p", NULL); + return NULL; + } + + strcat(strcat(strcpy(filepath, dir), "/"), name); + + dreturn("\"%s\"", filepath); + return filepath; +} + +int _GD_GrabDir(DIRFILE *D, int dirfd, const char *name) +{ + unsigned int i; + char *path, *dir = NULL; + void *ptr; + int abs = ( +#if defined _WIN32 || defined _WIN64 + name[0] != '\0' && name[1] == ':' +#else + name[0] == '/' +#endif + ); + + dtrace("%p, %i, \"%s\"", D, dirfd, name); + + if (abs) + path = strdup(name); + else + path = _GD_MakeFullPath(D, dirfd, name); + + if (path == NULL) { + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + + dir = dirname(path); + + for (i = 0; i < D->ndir; ++i) + if (strcmp(dir, D->dir[i].path) == 0) { + D->dir[i].rc++; + free(path); + dreturn("%i", D->dir[i].fd); + return D->dir[i].fd; + } + + /* new one */ + ptr = realloc(D->dir, sizeof(struct gd_dir_t) * (D->ndir + 1)); + + if (ptr == NULL) { + free(path); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + + D->dir = ptr; + D->dir[D->ndir].rc = 1; + D->dir[D->ndir].path = strdup(dir); + + if (D->dir[D->ndir].path == NULL) { + free(path); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + + if (abs) { + D->dir[D->ndir].fd = open(dir, O_RDONLY); + } else { + free(path); + path = strdup(name); + if (path == NULL) { + free(D->dir[D->ndir].path); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + D->dir[D->ndir].fd = gd_OpenAt(D, dirfd, dirname(path), O_RDONLY, 0666); + } + free(path); + + if (D->dir[D->ndir].fd == -1) { + free(D->dir[D->ndir].path); + dreturn("%i", -1); + return -1; + } + D->ndir++; + + dreturn("%i", D->dir[D->ndir - 1].fd); + return D->dir[D->ndir - 1].fd; +} + +void _GD_ReleaseDir(DIRFILE *D, int dirfd) +{ + unsigned int i; + + dtrace("%p, %i", D, dirfd); + + for (i = 0; i < D->ndir; ++i) + if (D->dir[i].fd == dirfd) { + if (--D->dir[i].rc == 0) { + free(D->dir[i].path); + close(D->dir[i].fd); + D->dir[i] = D->dir[--D->ndir]; + } + break; + } + + dreturnvoid(); +} + /* vim: ts=2 sw=2 et tw=80 */ Modified: trunk/getdata/src/compat.c =================================================================== --- trunk/getdata/src/compat.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/compat.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2010 D. V. Wiebe +/* Copyright (C) 2010, 2011 D. V. Wiebe * *************************************************************************** * @@ -49,59 +49,111 @@ } #endif -/* MSVCRT based implementation of mkstemp(3). */ -#ifndef HAVE_MKSTEMP -int mkstemp(char *template) { - int ret = -1; - char *template_template; +#ifndef HAVE_OPENAT +int gd_OpenAt(const DIRFILE *D, int dirfd, const char *name, int flags, + mode_t mode) +{ + int ret; + char *path; - dtrace("\"%s\"", template); + dtrace("%p, %i, \"%s\", %x, 0%o", D, dirfd, name, flags, mode); - template_template = strdup(template); + path = _GD_MakeFullPath(D, dirfd, name); + ret = open(path, flags, mode); + free(path); - /* for sanity's sake */ - errno = 0; - - /* loop while open returns EEXIST */ - do { - char *ptr; - strcpy(template, template_template); - ptr = mktemp(template); - - if (ptr == NULL) - errno = EINVAL; - else - ret = open(ptr, O_RDWR | O_BINARY | O_CREAT | O_EXCL | O_BINARY, 0600); - } while (errno == EEXIST); - - free(template_template); dreturn("%i", ret); return ret; } #endif -/* An overwriting rename for use with the MSVCRT */ -#ifdef __MSVCRT__ -int _GD_Rename(const char *oldname, const char *newname) +#ifndef HAVE_RENAMEAT +int gd_RenameAt(const DIRFILE *D, int olddirfd, const char *oldname, + int newdirfd, const char *newname) { int ret; + char *oldpath, *newpath; - dtrace("\"%s\", \"%s\"", oldname, newname); + dtrace("%p, %i, \"%s\", %i, \"%s\"", D, olddirfd, oldname, newdirfd, newname); - if (unlink(newname)) { + newpath = _GD_MakeFullPath(D, newdirfd, newname); +#ifdef __MSVCRT__ + if (unlink(newpath)) { if (errno != ENOENT) { + free(newpath); dreturn("%i", -1); return -1; } } +#endif - ret = rename(oldname, newname); + oldpath = _GD_MakeFullPath(D, olddirfd, oldname); + ret = rename(oldpath, newpath); + free(newpath); + free(oldpath); dreturn("%i", ret); return ret; } #endif +#ifndef HAVE_FSTATAT +int gd_StatAt(const DIRFILE* D, int dirfd, const char* name, struct stat* buf, + int flags) +{ + int ret; + char *path; + + dtrace("%p, %i, \"%s\", %p, %x", D, dirfd, name, buf, flags); + + path = _GD_MakeFullPath(D, dirfd, name); + if (flags & AT_SYMLINK_NOFOLLOW) + ret = lstat(path, buf); + else + ret = stat(path, buf); + free(path); + + dreturn("%i", ret); + return ret; +} +#endif + +#ifndef HAVE_FSTATAT64 +int gd_StatAt64(const DIRFILE* D, int dirfd, const char* name, gd_stat64_t* buf, + int flags __gd_unused) +{ + int ret; + char *path; + + dtrace("%p, %i, \"%s\", %p, <unused>", D, dirfd, name, buf); + + path = _GD_MakeFullPath(D, dirfd, name); + ret = gd_stat64(path, buf); + free(path); + + dreturn("%i", ret); + return ret; +} +#endif + +#ifndef HAVE_UNLINKAT +int gd_UnlinkAt(const DIRFILE *D, int dirfd, const char *name, + int flags __gd_unused) +{ + int ret; + char *path; + + dtrace("%p, %i, \"%s\", <unused>", D, dirfd, name); + + path = _GD_MakeFullPath(D, dirfd, name); + ret = unlink(path); + free(path); + + dreturn("%i", ret); + return ret; +} +#endif + /* Non-threadsafe version of strerror_r */ #ifndef HAVE_STRERROR_R int strerror_r(int errnum, char *buf, size_t buflen) Modified: trunk/getdata/src/del.c =================================================================== --- trunk/getdata/src/del.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/del.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -332,7 +332,9 @@ return -1; } - if ((*_gd_ef[E->e->u.raw.file[0].encoding].unlink)(E->e->u.raw.file)) { + if ((*_gd_ef[E->e->u.raw.file[0].encoding].unlink)( + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file)) + { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, NULL); free(del_list); dreturn("%i", -1); @@ -429,7 +431,7 @@ if (E->e->n_meta > 0) { /* Remove all meta fields -- there are no RAW fields here */ for (j = first; j <= last; ++j) - _GD_FreeE(D->entry[j], 1); + _GD_FreeE(D, D->entry[j], 1); memmove(D->entry + first, D->entry + last + 1, sizeof(gd_entry_t*) * (D->n_entries - last - 1)); @@ -466,7 +468,7 @@ /* Remove the entry from the list -- we need not worry about the way we've * already modified D->entry, since E is guaranteed to be before the stuff * we've already removed */ - _GD_FreeE(E, 1); + _GD_FreeE(D, E, 1); memmove(D->entry + index, D->entry + index + 1, sizeof(gd_entry_t *) * (D->n_entries - index - 1)); Modified: trunk/getdata/src/encoding.c =================================================================== --- trunk/getdata/src/encoding.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/encoding.c 2011-05-05 15:24:29 UTC (rev 586) @@ -197,7 +197,7 @@ { int ret; - dtrace("%x, %x", encoding, funcs); + dtrace("%i, %x", encoding, funcs); #ifdef USE_MODULES #ifdef USE_PTHREAD @@ -206,21 +206,31 @@ /* set up the encoding library if required */ if (_gd_ef[encoding].provides) { - char library[FILENAME_MAX]; + char *library; lt_dlhandle lib; /* make the library name */ - sprintf(library, "%s/libgetdata%s-%s", GETDATA_MODULEDIR, - _gd_ef[encoding].affix, PACKAGE_VERSION); + library = (char *)malloc(sizeof(GETDATA_MODULEDIR) + + strlen(_gd_ef[encoding].affix) + sizeof(PACKAGE_VERSION) + 13); + if (!library) { + _gd_ef[encoding].provides = 0; +#ifdef USE_PTHREAD + pthread_mutex_unlock(&_gd_mutex); +#endif + dreturn("%i", 1); + return 1; + } + + strcat(strcat(strcpy(library, GETDATA_MODULEDIR "/libgetdata"), + _gd_ef[encoding].affix), "-" PACKAGE_VERSION); library[sizeof(GETDATA_MODULEDIR) + 10] -= 'A' - 'a'; /* open */ if ((lib = lt_dlopenext(library)) == NULL) { /* if that didn't work, look for it in the search path */ - sprintf(library, "libgetdata%s-%s", _gd_ef[encoding].affix, - PACKAGE_VERSION); - library[10] -= 'A' - 'a'; - if ((lib = lt_dlopenext(library)) == NULL) { + if ((lib = lt_dlopenext(library + sizeof(GETDATA_MODULEDIR))) == NULL) + { + free(library); _gd_ef[encoding].provides = 0; #ifdef USE_PTHREAD pthread_mutex_unlock(&_gd_mutex); @@ -229,17 +239,18 @@ return 1; } } + free(library); /* Try to resolve the symbols */ if (_gd_ef[encoding].provides & GD_EF_OPEN) - _gd_ef[encoding].open = (int (*)(struct _gd_raw_file*, int, + _gd_ef[encoding].open = (int (*)(int, struct _gd_raw_file*, int, int))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Open"); if (_gd_ef[encoding].provides & GD_EF_CLOSE) _gd_ef[encoding].close = (int (*)(struct _gd_raw_file*))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Close"); if (_gd_ef[encoding].provides & GD_EF_TOUCH) - _gd_ef[encoding].touch = (int (*)(struct _gd_raw_file*)) + _gd_ef[encoding].touch = (int (*)(int, struct _gd_raw_file*)) _GD_ResolveSymbol(lib, _gd_ef + encoding, "Touch"); if (_gd_ef[encoding].provides & GD_EF_SEEK) _gd_ef[encoding].seek = (off64_t (*)(struct _gd_raw_file*, off64_t, @@ -249,7 +260,7 @@ gd_type_t, size_t))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Read"); if (_gd_ef[encoding].provides & GD_EF_SIZE) - _gd_ef[encoding].size = (off64_t (*)(struct _gd_raw_file*, + _gd_ef[encoding].size = (off64_t (*)(int, struct _gd_raw_file*, gd_type_t))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Size"); if (_gd_ef[encoding].provides & GD_EF_WRITE) _gd_ef[encoding].write = (ssize_t (*)(struct _gd_raw_file*, const void*, @@ -260,11 +271,11 @@ (int (*)(struct _gd_raw_file*))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Sync"); if (_gd_ef[encoding].provides & GD_EF_UNLINK) - _gd_ef[encoding].unlink = - (int (*)(struct _gd_raw_file*))_GD_ResolveSymbol(lib, _gd_ef + encoding, + _gd_ef[encoding].unlink = (int (*)(int, + struct _gd_raw_file*))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Unlink"); if (_gd_ef[encoding].provides & GD_EF_TEMP) - _gd_ef[encoding].temp = (int (*)(struct _gd_raw_file*, + _gd_ef[encoding].temp = (int (*)(int, int, struct _gd_raw_file*, int))_GD_ResolveSymbol(lib, _gd_ef + encoding, "Temp"); /* we tried our best, don't bother trying again */ @@ -292,31 +303,31 @@ } /* Figure out the encoding scheme */ -static unsigned long _GD_ResolveEncoding(const char* name, unsigned long scheme, +static unsigned long _GD_ResolveEncoding(const DIRFILE *D gd_unused_d, + const char* name, unsigned long scheme, int dirfd, struct _gd_raw_file *file) { - char candidate[FILENAME_MAX]; - char* ptr; - int i, len = strlen(name); - gd_stat64_t statbuf; + char *candidate; + int i; + const size_t len = strlen(name); + struct stat statbuf; - dtrace("\"%s\", 0x%08lx, %p", name, scheme, file); + dtrace("%p, \"%s\", 0x%08lx, %i, %p", D, name, scheme, dirfd, file); - strcpy(candidate, name); - ptr = candidate + len; - len = FILENAME_MAX - len; - for (i = 0; _gd_ef[i].scheme != GD_ENC_UNSUPPORTED; i++) { if (scheme == GD_AUTO_ENCODED || scheme == _gd_ef[i].scheme) { - strcpy(ptr, _gd_ef[i].ext); + candidate = (char *)malloc(len + strlen(_gd_ef[i].ext) + 1); + strcat(strcpy(candidate, name), _gd_ef[i].ext); - if (gd_stat64(candidate, &statbuf) == 0) + if (gd_StatAt(D, dirfd, candidate, &statbuf, 0) == 0) if (S_ISREG(statbuf.st_mode)) { if (file != NULL) file->encoding = i; + free(candidate); dreturn("%08lx", _gd_ef[i].scheme); return _gd_ef[i].scheme; } + free(candidate); } } @@ -340,8 +351,8 @@ /* Figure out the dirfile encoding type, if required */ if (D->fragment[E->fragment_index].encoding == GD_AUTO_ENCODED) { D->fragment[E->fragment_index].encoding = - _GD_ResolveEncoding(E->e->u.raw.filebase, GD_AUTO_ENCODED, - E->e->u.raw.file); + _GD_ResolveEncoding(D, E->e->u.raw.filebase, GD_AUTO_ENCODED, + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file); } /* If the encoding scheme is unknown, complain */ @@ -353,8 +364,9 @@ /* Figure out the encoding subtype, if required */ if (E->e->u.raw.file[0].encoding == GD_ENC_UNKNOWN) - _GD_ResolveEncoding(E->e->u.raw.filebase, - D->fragment[E->fragment_index].encoding, E->e->u.raw.file); + _GD_ResolveEncoding(D, E->e->u.raw.filebase, + D->fragment[E->fragment_index].encoding, + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file); /* check for our function(s) */ if (_GD_MissingFramework(E->e->u.raw.file[0].encoding, funcs)) { @@ -373,14 +385,16 @@ dtrace("%p, %p, \"%s\", %i", D, file, base, temp); if (file->name == NULL) { - file->name = (char *)malloc(FILENAME_MAX); + file->D = D; + file->name = (char *)malloc(strlen(base) + (temp ? 8 : + strlen(_gd_ef[file->encoding].ext) + 1)); if (file->name == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); dreturn("%i", -1); return -1; } - snprintf(file->name, FILENAME_MAX, "%s%s", base, temp ? "_XXXXXX" : + strcat(strcpy(file->name, base), temp ? "_XXXXXX" : _gd_ef[file->encoding].ext); } @@ -438,6 +452,7 @@ for (i = 0; i < n_raw; ++i) if (_gd_ef[raw_entry[i]->e->u.raw.file[1].encoding].temp != NULL && (*_gd_ef[raw_entry[i]->e->u.raw.file[1].encoding].temp)( + D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file, GD_TEMP_DESTROY)) { _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, @@ -459,6 +474,7 @@ raw_entry[i]->e->u.raw.file[0].encoding = temp.encoding; } else if ( (*_gd_ef[raw_entry[i]->e->u.raw.file[1].encoding].temp)( + D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file, GD_TEMP_MOVE)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, @@ -466,7 +482,9 @@ D->flags |= GD_INVALID; raw_entry[i]->e->u.raw.file[0].name = temp.name; raw_entry[i]->e->u.raw.file[0].encoding = temp.encoding; - } else if ((*_gd_ef[temp.encoding].unlink)(&temp)) { + } else if ((*_gd_ef[temp.encoding].unlink)(D->fragment[fragment].dirfd, + &temp)) + { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, D->fragment[D->entry[i]->fragment_index].cname, 0, NULL); D->flags |= GD_INVALID; @@ -584,7 +602,8 @@ D->entry[i]->field_type == GD_RAW_ENTRY) { D->fragment[fragment].encoding = - _GD_ResolveEncoding(D->entry[i]->e->u.raw.filebase, GD_AUTO_ENCODED, + _GD_ResolveEncoding(D, D->entry[i]->e->u.raw.filebase, + GD_AUTO_ENCODED, D->fragment[fragment].dirfd, D->entry[i]->e->u.raw.file); if (D->fragment[fragment].encoding != GD_AUTO_ENCODED) @@ -599,13 +618,51 @@ return reported_encoding; } -int _GD_GenericTouch(struct _gd_raw_file* file) +/* This is basically the non-existant POSIX funcion mkstempat. There are two + * approaches we could take here: + * 1) fchdir to dirfd, use mkstemp to grab a file descriptor; fchdir back to + * cwd, but this isn't thread-safe, so we're stuck with: + * 2) use mktemp to generate a "unique" file name, and then try to openat it + * exclusively; repeat as necessary. + */ +int gd_MakeTempFile(const DIRFILE *D gd_unused_d, int dirfd, char *template) { + int fd = -1; + char *tmp = strdup(template); + + dtrace("%i, \"%s\"", dirfd, template); + + if (!tmp) { + dreturn("%i", -1); + return -1; + } + + do { + strcpy(template, tmp); + mktemp(template); + if (template[0] == 0) { + free(tmp); + dreturn("%i", -1); + return -1; + } + + fd = gd_OpenAt(D, dirfd, template, O_RDWR | O_CREAT | O_EXCL, 0666); + } while (errno == EEXIST); + + free(tmp); + + dreturn("%i", fd); + return fd; +} + +int _GD_GenericTouch(int dirfd, struct _gd_raw_file* file) +{ int fd; - dtrace("%p", file); + dtrace("%i, %p", dirfd, file); - fd = open(file->name, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0666); + fd = gd_OpenAt(file->D, dirfd, file->name, O_RDWR | O_CREAT | O_TRUNC + | O_BINARY, 0666); if (fd != -1) fd = close(fd); @@ -614,25 +671,26 @@ return fd; } -int _GD_GenericUnlink(struct _gd_raw_file* file) +int _GD_GenericUnlink(int dirfd, struct _gd_raw_file* file) { int r; - dtrace("%p", file); + dtrace("%i, %p", dirfd, file); - r = unlink(file->name); + r = gd_UnlinkAt(file->D, dirfd, file->name, 0); dreturn("%i", r); return r; } -int _GD_GenericMove(struct _gd_raw_file* file, char* new_path) +int _GD_GenericMove(int olddirfd, struct _gd_raw_file* file, int newdirfd, + char* new_path) { int r, rename_errno; - dtrace("%p, \"%s\"", file, new_path); + dtrace("%i, %p, %i, \"%s\"", olddirfd, file, newdirfd, new_path); - r = _GD_Rename(file->name, new_path); + r = gd_RenameAt(file->D, olddirfd, file->name, newdirfd, new_path); rename_errno = errno; Modified: trunk/getdata/src/endian.c =================================================================== --- trunk/getdata/src/endian.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/endian.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -88,12 +88,14 @@ if (D->error) { for (i = 0; i < n_raw; ++i) if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( + D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file, GD_TEMP_DESTROY)) _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, errno, NULL); } else { for (i = 0; i < n_raw; ++i) if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( + D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file, GD_TEMP_MOVE)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, Modified: trunk/getdata/src/entry.c =================================================================== --- trunk/getdata/src/entry.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/entry.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -25,11 +25,15 @@ #include <stdlib.h> #endif -void _GD_FreeE(gd_entry_t* entry, int priv) +#ifdef HAVE_LIBGEN_H +#include <libgen.h> +#endif + +void _GD_FreeE(DIRFILE *D, gd_entry_t* entry, int priv) { int i; - dtrace("%p, %i", entry, priv); + dtrace("%p, %p, %i", D, entry, priv); if (!entry || entry->field_type == GD_NO_ENTRY) { dreturnvoid(); @@ -50,7 +54,9 @@ free(entry->in_fields[0]); free(entry->EN(linterp,table)); if (priv) { - free(entry->e->u.linterp.table_path); + if (entry->e->u.linterp.table_dirfd > 0) + _GD_ReleaseDir(D, entry->e->u.linterp.table_dirfd); + free(entry->e->u.linterp.table_file); free(entry->e->u.linterp.lut); } break; @@ -125,7 +131,7 @@ { dtrace("%p", entry); - _GD_FreeE(entry, 0); + _GD_FreeE(NULL, entry, 0); dreturn("%p", entry); return entry; @@ -261,10 +267,10 @@ return E->e->calculated; } -const char* gd_raw_filename(DIRFILE* D, const char* field_code_in) gd_nothrow +char* gd_raw_filename(DIRFILE* D, const char* field_code_in) gd_nothrow { int repr; - char* field_code; + char *field_code, *filename; gd_entry_t *E; dtrace("%p, \"%s\"", D, field_code_in); @@ -312,8 +318,16 @@ } } - dreturn("%p", E->e->u.raw.file[0].name); - return E->e->u.raw.file[0].name; + filename = _GD_MakeFullPath(D, D->fragment[E->fragment_index].dirfd, + E->e->u.raw.file->name); + if (filename == NULL) { + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%p", NULL); + return NULL; + } + + dreturn("%p", filename); + return filename; } int gd_entry(DIRFILE* D, const char* field_code_in, gd_entry_t* entry) Modified: trunk/getdata/src/flimits.c =================================================================== --- trunk/getdata/src/flimits.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/flimits.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -75,12 +75,14 @@ if (D->error) { for (i = 0; i < n_raw; ++i) if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( + D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file, GD_TEMP_DESTROY)) _GD_SetError(D, GD_E_RAW_IO, 0, raw_entry[i]->e->u.raw.file[0].name, errno, NULL); } else { for (i = 0; i < n_raw; ++i) if ((*_gd_ef[raw_entry[i]->e->u.raw.file[0].encoding].temp)( + D->fragment[fragment].dirfd, D->fragment[fragment].dirfd, raw_entry[i]->e->u.raw.file, GD_TEMP_MOVE)) { _GD_SetError(D, GD_E_UNCLEAN_DB, 0, @@ -208,7 +210,8 @@ if (_GD_SetEncodedName(D, E->e->u.raw.file, E->e->u.raw.filebase, 0)) break; - ns = (*_gd_ef[E->e->u.raw.file[0].encoding].size)(E->e->u.raw.file, + ns = (*_gd_ef[E->e->u.raw.file[0].encoding].size)( + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, E->EN(raw,data_type)); if (ns < 0) { Modified: trunk/getdata/src/flush.c =================================================================== --- trunk/getdata/src/flush.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/flush.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -30,6 +30,10 @@ #include <limits.h> #endif +#ifdef HAVE_LIBGEN_H +#include <libgen.h> +#endif + #define GD_MAX_PRETTY_FIELD_WIDTH 80 void _GD_Flush(DIRFILE* D, gd_entry_t *E) @@ -421,17 +425,17 @@ int j; FILE* stream; char buffer[GD_MAX_LINE_LENGTH]; - char *temp_file; + char temp_file[] = "format_XXXXXX"; char* ptr; struct tm now; int fd; int pretty = 0; size_t max_len = 0; - const size_t name_len = strlen(D->name); unsigned int u; mode_t mode; struct stat stat_buf; time_t t; + int dirfd = D->fragment[i].dirfd; dtrace("%p, %i, %i", D, i, permissive); @@ -442,19 +446,15 @@ mode = stat_buf.st_mode; /* open a temporary file */ - temp_file = (char *)malloc(name_len + 15); - snprintf(temp_file, name_len + 15, "%s/format_XXXXXX", D->name); - fd = mkstemp(temp_file); + fd = gd_MakeTempFile(D, dirfd, temp_file); if (fd == -1) { _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_MKTMP, NULL, errno, temp_file); - free(temp_file); dreturnvoid(); return; } stream = fdopen(fd, "w+"); if (stream == NULL) { _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_OPEN, NULL, errno, temp_file); - free(temp_file); dreturnvoid(); return; } @@ -592,23 +592,24 @@ /* If no error was encountered, move the temporary file over the * old format file, otherwise abort */ - if (D->error != GD_E_OK) { - unlink(temp_file); - free(temp_file); + ptr = strdup(D->fragment[i].cname); + if (ptr == NULL) { + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); dreturnvoid(); return; - /* Only assume we've synced the file if the rename succeeds */ - } else if (_GD_Rename(temp_file, D->fragment[i].cname)) { + } + + /* Only assume we've synced the file if the rename succeeds */ + if (D->error != GD_E_OK) + gd_UnlinkAt(D, dirfd, temp_file, 0); + else if (gd_RenameAt(D, dirfd, temp_file, dirfd, basename(ptr))) { _GD_SetError(D, GD_E_FLUSH, GD_E_FLUSH_RENAME, NULL, errno, D->fragment[i].cname); - unlink(temp_file); - free(temp_file); - dreturnvoid(); - return; + gd_UnlinkAt(D, dirfd, temp_file, 0); } else D->fragment[i].modified = 0; - free(temp_file); + free(ptr); dreturnvoid(); } Modified: trunk/getdata/src/getdata.c =================================================================== --- trunk/getdata/src/getdata.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/getdata.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,5 +1,5 @@ /* Copyright (C) 2002-2005 C. Barth Netterfield - * Copyright (C) 2005-2010 D. V. Wiebe + * Copyright (C) 2005-2011 D. V. Wiebe * *************************************************************************** * @@ -304,7 +304,8 @@ free(databuffer); dreturn("%i", 0); return 0; - } else if ((*_gd_ef[E->e->u.raw.file[0].encoding].open)(E->e->u.raw.file, + } else if ((*_gd_ef[E->e->u.raw.file[0].encoding].open)( + D->fragment[E->fragment_index].dirfd, E->e->u.raw.file, D->flags & GD_ACCMODE, 0)) { _GD_SetError(D, GD_E_RAW_IO, 0, E->e->u.raw.file[0].name, errno, Modified: trunk/getdata/src/getdata.h.in =================================================================== --- trunk/getdata/src/getdata.h.in 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/getdata.h.in 2011-05-05 15:24:29 UTC (rev 586) @@ -102,7 +102,7 @@ #endif /* formerly, this was the maximum length of a format file line. We keep it - * around for legacy reasons. (The actualy maximum length of a format file + * around for legacy reasons. (The actual maximum length of a format file * line is the maximum value of ssize_t, i.e. 2**(n-1)-1 on a n-bit system.) */ #define GD_MAX_LINE_LENGTH 4096 @@ -724,7 +724,7 @@ extern int gd_protection(DIRFILE *dirfile, int fragment_index) gd_nothrow gd_nonnull ((1)); -extern const char *gd_raw_filename(DIRFILE *dirfile, +extern char *gd_raw_filename(DIRFILE *dirfile, const char *field_code) gd_nothrow gd_nonnull ((1, 2)); extern const char *gd_reference(DIRFILE *dirfile, Modified: trunk/getdata/src/gzip.c =================================================================== --- trunk/getdata/src/gzip.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/gzip.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -44,19 +44,29 @@ /* The zlib encoding scheme uses edata as a gzFile object. If a file is * open, fp = 0 otherwise fp = -1. */ -int _GD_GzipOpen(struct _gd_raw_file* file, int mode __gd_unused, +int _GD_GzipOpen(int dirfd, struct _gd_raw_file* file, int mode __gd_unused, int creat __gd_unused) { - dtrace("%p, <unused>, <unused>", file); + int fd; - file->edata = gzopen(file->name, "rb" /* writing not supported */); + dtrace("%i, %p, <unused>, <unused>", dirfd, file); + fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); + + if (fd == -1) { + dreturn("%i", 0); + return 0; + } + + file->edata = gzdopen(fd, "r"); + if (file->edata != NULL) { file->fp = 0; dreturn("%i", 0); return 0; } + close(fd); dreturn("%i", 1); return 1; } @@ -111,14 +121,14 @@ return ret; } -off64_t _GD_GzipSize(struct _gd_raw_file *file, gd_type_t data_type) +off64_t _GD_GzipSize(int dirfd, struct _gd_raw_file *file, gd_type_t data_type) { int fd; uint32_t size = 0; - dtrace("%p, %x", file, data_type); + dtrace("%i, %p, %x", file, data_type); - fd = open(file->name, O_RDONLY | O_BINARY); + fd = gd_OpenAt(file->D, dirfd, file->name, O_RDONLY | O_BINARY, 0666); if (fd < 0) { dreturn("%i", -1); return -1; Modified: trunk/getdata/src/include.c =================================================================== --- trunk/getdata/src/include.c 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/include.c 2011-05-05 15:24:29 UTC (rev 586) @@ -1,4 +1,4 @@ -/* Copyright (C) 2008-2010 D. V. Wiebe +/* Copyright (C) 2008-2011 D. V. Wiebe * *************************************************************************** * @@ -39,33 +39,42 @@ int linenum, char** ref_name, int me, int* standards, unsigned long *flags) { int i; - int abs = 0; - int sname_null_ok = 0; int found = 0; - char temp_buf1[FILENAME_MAX]; - char temp_buf2[FILENAME_MAX]; - void* ptr; + int dirfd = -1; + char *temp_buf1, *temp_buf2; + const char *base; + void *ptr = NULL; FILE* new_fp = NULL; - dtrace("%p, \"%s\", \"%s\", %p, %i, %i, %p, %p\n", D, ename, format_file, + dtrace("%p, \"%s\", \"%s\", %p, %i, %i, %p, %p", D, ename, format_file, ref_name, linenum, me, standards, flags); - /* create the format filename */ - if ( - /* check for absolute path */ -#if defined _WIN32 || defined _WIN64 - ename[0] != '\0' && ename[1] == ':' -#else - ename[0] == '/' -#endif - ) { - strncpy(temp_buf1, ename, FILENAME_MAX - 1); - temp_buf1[FILENAME_MAX - 1] = '\0'; - abs = 1; - } else - snprintf(temp_buf1, FILENAME_MAX, "%s/%s", D->fragment[me].sname ? - D->fragment[me].sname : D->name, ename); + temp_buf2 = strdup(ename); + if (temp_buf2 == NULL) { + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + base = basename(temp_buf2); + /* Open the containing directory */ + dirfd = _GD_GrabDir(D, D->fragment[me].dirfd, ename); + if (dirfd == -1 && D->error == GD_E_OK) + _GD_SetError(D, GD_E_OPEN_FRAGMENT, errno, format_file, linenum, ename); + if (D->error) { + dreturn("%i", -1); + return -1; + } + + temp_buf1 = _GD_MakeFullPath(D, dirfd, base); + free(temp_buf2); + if (temp_buf1 == NULL) { + _GD_ReleaseDir(D, dirfd); + _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + dreturn("%i", -1); + return -1; + } + /* Run through the include list to see if we've already included this * file */ for (i = 0; i < D->n_fragment; ++i) @@ -76,28 +85,35 @@ /* If we found the file, we won't reopen it. Continue parsing. */ if (found) { + _GD_ReleaseDir(D, dirfd); + free(temp_buf1); dreturn("%i", i); return i; } - /* Otherwise, try to open the file */ - if ((D->flags & GD_ACCMODE) == GD_RDWR) { - i = open(temp_buf1, O_RDWR | ((*flags & GD_CREAT) ? O_CREAT : 0) | - ((*flags & GD_TRUNC) ? O_TRUNC : 0) | ((*flags & GD_EXCL) ? O_EXCL : 0) - | O_BINARY, 0666); - if (i < 0) { - _GD_SetError(D, GD_E_OPEN_FRAGMENT, errno, format_file, linenum, - temp_buf1); - dreturn("%i", -1); - return -1; - } - new_fp = fdopen(i, "r+"); - } else - new_fp = fopen(temp_buf1, "r"); + /* Try to open the file */ + temp_buf2 = strdup(temp_buf1); + i = gd_OpenAt(D, dirfd, basename(temp_buf2), + (((D->flags & GD_ACCMODE) == GD_RDWR) ? O_RDWR : O_RDONLY) | + ((*flags & GD_CREAT) ? O_CREAT : 0) | + ((*flags & GD_TRUNC) ? O_TRUNC : 0) | ((*flags & GD_EXCL) ? O_EXCL : 0) + | O_BINARY, 0666); + free(temp_buf2); + if (i < 0) { + _GD_SetError(D, GD_E_OPEN_FRAGMENT, errno, format_file, linenum, + temp_buf1); + free(temp_buf1); + dreturn("%i", -1); + return -1; + } + + new_fp = fdopen(i, ((D->flags & GD_ACCMODE) == GD_RDWR) ? "r+" : "r"); + /* If opening the file failed, set the error code and abort parsing. */ if (new_fp == NULL) { _GD_SetError(D, GD_E_OPEN_FRAGMENT, errno, format_file, linenum, temp_buf1); + free(temp_buf1); dreturn("%i", -1); return -1; } @@ -105,16 +121,19 @@ /* If we got here, we managed to open the included file; parse it */ ptr = realloc(D->fragment, (++D->n_fragment) * sizeof(struct gd_fragment_t)); if (ptr == NULL) { + D->n_fragment--; _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); + free(temp_buf1); dreturn("%i", -1); return -1; } D->fragment = (struct gd_fragment_t *)ptr; - D->fragment[D->n_fragment - 1].cname = strdup(temp_buf1); + D->fragment[D->n_fragment - 1].cname = temp_buf1; D->fragment[D->n_fragment - 1].ename = strdup(ename); D->fragment[D->n_fragment - 1].modified = 0; D->fragment[D->n_fragment - 1].parent = me; + D->fragment[D->n_fragment - 1].dirfd = dirfd; D->fragment[D->n_fragment - 1].encoding = *flags & GD_ENCODING; D->fragment[D->n_fragment - 1].byte_sex = #ifdef WORDS_BIGENDIAN @@ -129,9 +148,7 @@ D->fragment[D->n_fragment - 1].vers = (*flags & GD_PEDANTIC) ? 1ULL << *standards : 0; - if (D->fragment[D->n_fragment - 1].cname == NULL || - D->fragment[D->n_fragment - 1].ename == NULL) - { + if (D->fragment[D->n_fragment - 1].ename == NULL) { _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); dreturn("%i", -1); return -1; @@ -139,31 +156,8 @@ /* extract the subdirectory name - dirname both returns a volatile string * and modifies its argument, ergo strcpy */ - strncpy(temp_buf1, ename, FILENAME_MAX); - if (abs) - D->fragment[D->n_fragment - 1].sname = strdup(dirname(temp_buf1)); - else { - strcpy(temp_buf2, dirname(temp_buf1)); - if (temp_buf2[0] == '.' && temp_buf2[1] == '\0') { - if (D->fragment[me].sname) - D->fragment[D->n_fragment - 1].sname = strdup(D->fragment[me].sname); - else { - D->fragment[D->n_fragment - 1].sname = NULL; - sname_null_ok = 1; - } - } else { - strncpy(temp_buf1, ename, FILENAME_MAX); - snprintf(temp_buf2, FILENAME_MAX, "%s/%s", D->fragment[me].sname ? - D->fragment[me].sname : D->name, dirname(temp_buf1)); - D->fragment[D->n_fragment - 1].sname = strdup(temp_buf2); - } - } - if (!sname_null_ok && D->fragment[D->n_fragment - 1].sname == NULL) { - _GD_SetError(D, GD_E_ALLOC, 0, NULL, 0, NULL); - dreturn("%i", -1); - return -1; - } + D->fragment[D->n_fragment - 1].sname = _GD_DirName(D, dirfd); *ref_name = _GD_ParseFragment(new_fp, D, D->n_fragment - 1, standards, flags); @@ -401,7 +395,7 @@ } else D->n_meta--; - _GD_FreeE(D->entry[i], 1); + _GD_FreeE(D, D->entry[i], 1); } else D->entry[o++] = D->entry[i]; @@ -411,8 +405,8 @@ /* delete the fragments -- again, don't bother resizing D->fragment */ for (j = 0; j < nf; ++j) { + _GD_ReleaseDir(D, D->fragment[f[j]].dirfd); free(D->fragment[f[j]].cname); - free(D->fragment[f[j]].sname); free(D->fragment[f[j]].ename); free(D->fragment[f[j]].ref_name); Modified: trunk/getdata/src/internal.h =================================================================== --- trunk/getdata/src/internal.h 2011-05-03 20:08:44 UTC (rev 585) +++ trunk/getdata/src/internal.h 2011-05-05 15:24:29 UTC (rev 586) @@ -109,7 +109,7 @@ #endif #endif -/* For FILENAME_MAX */ +/* For FILE */ #include <stdio.h> /* For the C99 integer types */ @@ -263,10 +263,6 @@ #define EOVERFLOW EINVAL #endif -#ifndef HAVE_MKSTEMP -int mkstemp(char*); -#endif - #if defined __MSVCRT__ && defined HAVE__OPEN #define o... [truncated message content] |