dbview-1.0.4/0000755000076500001440000000000010532567173011677 5ustar joeyusersdbview-1.0.4/CHANGES0000644000076500001440000000033310532550622012660 0ustar joeyusers1.0.4 -- 2006-11-27 - Support for deleted records Added --deleted|-D to display deleted records as well. - Improved handling of differences between dBase III and dBase III+ files. - Improved error handling dbview-1.0.4/Makefile0000644000076500001440000000307110530131205013315 0ustar joeyusers# Copyright (c) 1995,96,2003,6 Martin Schulze # # This file is part of the dbview package, a viewer for dBase II files # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program 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 General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. MAN=man CC= gcc CFLAGS= -O6 -fomit-frame-pointer -Wall -pipe # CFLAGS= -g -fomit-frame-pointer -Wall -pipe # Look where your install program is # INSTALL = /usr/bin/install prefix = /usr bindir = $(prefix)/bin mandir = $(prefix)/share/$(MAN) obj = db_dump.o dbview.o version.o .c.o: $(CC) ${CFLAGS} -c $*.c all: dbview dbview: $(obj) $(CC) $(CFLAGS) -o dbview $(obj) depend: makedepend *.c install: all $(INSTALL) -d -o root -g root -m 755 $(bindir) $(INSTALL) -s -o root -g root -m 755 dbview $(bindir) $(INSTALL) -d -o $(MAN) -g $(MAN) -m 755 $(mandir)/man1 $(INSTALL) -o $(MAN) -g $(MAN) -m 644 dbview.1 $(mandir)/man1 clean: rm -f dbview *.o *.log *~ *.orig Makefile.bak; clobber: clean rm -f TAGS; # DO NOT DELETE dbview-1.0.4/README0000644000076500001440000000123607723727543012570 0ustar joeyusersThe file db_dump.c if of unknown source, at least it is provided as a gift so we can work with it. I have obtained it from ftp://nic.funet.fi/pub/msdos/languages/c/dbase.c. The file contains a posting to comp.sys.ibm.pc from 1987. I have saved the header in db_dump.header. The file dBASE contains a description of the dBase II file format. I have obtained it from one of the various CPAN Comprehensive Perl Archive Network) ftp server in the Internet, e.g. ftp://ftp.switch.ch/mirror/CPAN/modules/dbperl/refinfo/formats/dBASE The native site for this package is . New versions will first occur there. Regards, Joey dbview-1.0.4/dBASE0000644000076500001440000000665010514741474012505 0ustar joeyusersArticle 18999 of comp.databases: Xref: ig.co.uk comp.databases:18999 alt.msdos.programmer:1555 Newsgroups: comp.databases,alt.msdos.programmer,comp.msdos.programmer,comp.sys.ibm.pc.programmer Path: ig.co.uk!demon!news.sprintlink.net!howland.reston.ans.net!europa.eng.gtefsd.com!news.umbc.edu!eff!news.kei.com!world!decwrl!borland.com!genghis!koterski From: koterski@genghis (Steve Koterski) Subject: Re: Need DBASE IV file format Message-ID: Followup-To: comp.databases,alt.msdos.programmer,comp.msdos.programmer,comp.sys.ibm.pc.programmer Sender: news@borland.com (News Admin) Organization: Borland International, Scotts Valley, California X-Newsreader: TIN [version 1.2 PL2] References: Date: Mon, 31 Oct 1994 20:29:32 GMT Lines: 84 Mark J Visser (mvisser@cmita10.dow.on.doe.ca) wrote: : Anyone have a description of the DBASE IV .DBF file, or point me to somewhere that : does? The header for a dBASE IV 2.0 table file is comprised of the following structure: Byte Contents Meaning ------- ---------- ------------------------------------------------- 0 1byte Valid dBASE IV file; bits 0-2 indicate version number, bit 3 the presence of a dBASE IV memo file, bits 4-6 the presence of an SQL table, bit 7 the presence of any memo file (either dBASE III PLUS or dBASE IV). 1-3 3 bytes Date of last update; formattted as YYMMDD. 4-7 32-bit number Number of records in the file. 8-9 16-bit number Number of bytes in the header. 10-11 16-bit number Number of bytes in the record. 12-13 2 bytes Reserved; fill with 0. 14 1 byte Flag indicating incomplete transaction. 15 1 byte Encryption flag. 16-27 12 bytes Reserved for dBASE IV in a multi-user environment. 28 1 bytes Production MDX file flag; 01H if there is an MDX, 00H if not. 29 1 byte Language driver ID. 30-31 2 bytes Reserved; fill with 0. 32-n* 32 bytes each Field descriptor array (see below). n + 1 1 byte 0DH as the field terminator. n + 2 1 byte 00H only in dBase III (not in dBase III+ or dBase IV) * n is the last byte in the field descriptor array. The size of the array depends on the number of fields in the database file. The field descriptor array is as follows: Byte Contents Meaning ------- --------------- -------------------------------------------------- 0-10 11 bytes Field name in ASCII (zero-filled). 11 1 byte Field type in ASCII (C, D, F, L, M, or N). 12-15 4 bytes Reserved. 16 1 byte Field length in binary. 17 1 byte Field decimal count in binary. 18-19 2 bytes Reserved. 20 1 byte Work area ID. 21-30 10 bytes Reserved. 31 1 byte Production MDX field flag; 01H if field has an index tag in the production MDX file, 00H if not. Database records: The records follow the header in the database file. Data records are preceded by one byte; that is, a space (20H) if the record is not deleted, an asterisk (2AH) if the record is deleted. Fields are packed into records without field separators or record terminators. The end of the file is marked by a single byte, with the end-of-file marker an ASCII 26 (1AH) character. This information is from the dBASE IV Language Reference manual. -- _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/ Steve Koterski _/ The opinions expressed here are _/ _/ koterski@borland.com _/ exclusively my own _/ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ dbview-1.0.4/db_dump.c0000644000076500001440000002332210532550475013454 0ustar joeyusers/* db_dump.c - Routines for reading dBase III files Copyright (c) 1995,96,2003,6 Martin Schulze This file is part of the dbview package, a viewer for dBase II files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ /* Most of the code in this file comes from Greg Twaites anno 87. I only took the file and wrote a program around it. I enclude the whole header. I have obtained this file from a free software archive, namely nic.funet.fi. It is supposed to be placed in the public domain. Hence, adding GPL code around and distributinng the entire file under the GPL should be fine. ftp://nic.funet.fi/pub/msdos/languages/c/dbase.c */ /* * These functions are used to read dbase files. * * These functions are provided by Valour Software as a gift. * * The program is for test purposes only. No warranty is expressed nor * implied. USE AT YOUR OWN RISK! * * Fri Jun 21 19:30:44 1996: Martin Schulze * Fixed a bug which causes dbview to eat a character at the end * of beginning of a line. Thanks to Chris Childs * for submitting a patch. * * Thu Sep 26 21:38:33 1996: Martin Schulze * Modified on some places based on corrections from Vladimir * Michl * * Mon Sep 25 17:09:46 2006: Gergely Szasz * Added --deleted|-D to display deleted records as well. * * Mon Oct 16 18:34:23 CEST 2006: Joey Schulze * Improved error handling. Improved handling of differences between * dBase III and dBase III+ files. * * Mon Nov 20 16:58:35 CET 2006: Joey Schulze * Adjusted type handling and proper casts. */ #include "db_dump.h" #include #include #include #include #include #include #include #include #include #include #define TRUE 1 #define FALSE 0 DBASE_HEAD dbhead={0}; FLD_LIST *db_fld_root=0; char *Buffer; char buf_work[255]; FILE *dbfile; /*----------------------------------------------------helpers------------*/ #if BYTE_ORDER == BIG_ENDIAN size_t db3_fread (void *ptr, size_t size, size_t nmemb, FILE *stream) { size_t ret; size_t i; uint16_t *p = (uint16_t *) ptr; uint32_t *pp = (uint32_t *) ptr; ret = fread(ptr, size, nmemb, stream); switch (size) { case 2: for (i = 0; i < ret; i++) p[i] = bswap_16(p[i]); break; case 4: for (i = 0; i < ret; i++) pp[i] = bswap_32(pp[i]); break; default: break; } return ret; } #define fread db3_fread #endif /*------------------------------------------------------------code-------*/ int db3_process(dbfn, flags, delim) char *dbfn; int flags; char delim; { dbfile=fopen(dbfn,"r"); if (dbfile == NULL) { printf("Unable to open file `%s'\n", dbfn); return FALSE; } if (db3_read_dic(flags)) { if ( ! (flags & DB_FL_OMIT)) db3_print_recs(dbhead.count, flags, delim); } fclose(dbfile); return TRUE; } /****************************************************** db3_rm_ld_spc() This function removes leading space characters and returns a new string; ******************************************************/ char * db3_rm_ld_spc (var) char *var; { static char rvar[257]; /* dBase fields can only * be 256 byts long, max. */ char *c; bzero (rvar, sizeof(rvar)); for (c=var; isspace (*c); c++); strcpy(rvar, c); return rvar; } /****************************************************** db3_rm_tr_spc() This function removes trailing space characters and returns a new string; ******************************************************/ char * db3_rm_tr_spc (var) char *var; { char *c=var; for (c+=strlen(var)-1; isspace (*c); c--); *(++c) = '\0'; return var; } /****************************************************** db3_cvt_fld() This function is called with a valid db3 field specifier. It will convert the fieldname into a more friendly look. This is done by tr '_' ' ' and tr [:upper:] [:lower:]. ******************************************************/ void db3_cvt_fld (fld) DBASE_FIELD *fld; { uint8_t *c; uint8_t first; first = 1; for (c=fld->name; *c; c++) if (!first) { if (isupper(*c)) *c = tolower(*c); else if (*c == '_') { *c = ' '; first = 1; } first = 0; } else first = 0; } void db3_read_head(dbh) DBASE_HEAD *dbh; { fread(&dbh->version, 1, 1, dbfile); fread(dbh->l_update, 1, 3, dbfile); fread(&dbh->count, 4, 1, dbfile); fread(&dbh->header, 2, 1, dbfile); fread(&dbh->lrecl, 2, 1, dbfile); fread(dbh->reserv, 1, 20, dbfile); } void db3_read_field(fld) DBASE_FIELD *fld; { fread(fld->name, 1, 11, dbfile); fread(&fld->type, 1, 1, dbfile); /* "duh" believe me, it used to do just that before */ fread(&fld->data_ptr, 4, 1, dbfile); fread(&fld->length, 1, 1, dbfile); fread(&fld->dec_point, 1, 1, dbfile); fread(fld->fill, 1, 14, dbfile); } /****************************************************** db3_read_dic() This function is called with a file name to read to create a record type to support the dbase file ******************************************************/ int db3_read_dic(flags) int flags; { int fields; DBASE_FIELD *fld; if(dbfile==NULL) { printf("open failed"); return FALSE; } db3_read_head(&dbhead); if( !(dbhead.version==3 || dbhead.version==0x83) ) { printf ("Version %d not supported\n",dbhead.version); if(dbhead.version==0x8b ) { printf ("dBase IV - partially known...\n"); } return FALSE; } if (flags & DB_FL_INFO) { printf("File version : %d\n",dbhead.version); printf("Last update : %02d/%02d/%2d\n", dbhead.l_update[1],dbhead.l_update[2],dbhead.l_update[0]+1900); printf("Number of recs: %d\n",dbhead.count); printf("Header length : %d\n",dbhead.header); printf("Record length : %d\n",dbhead.lrecl); } Buffer=malloc(dbhead.lrecl); fields=(dbhead.header-1)/32-1; if (flags & DB_FL_DESCR) { printf("Field Name\tType\tLength\tDecimal Pos\n"); } while(fields--) { fld=(DBASE_FIELD *)malloc(sizeof(DBASE_FIELD)); if (!fld) { printf ("Not enough memory\n"); return FALSE; } db3_read_field(fld); if (! (flags & DB_FL_RESERVE)) db3_cvt_fld (fld); if (flags & DB_FL_DESCR) { printf("%-10s\t %c\t %3d\t %3d\n", fld->name, fld->type, fld->length,fld->dec_point); } stack_field(fld); } /* Jump to where the data starts */ fseek(dbfile, dbhead.header, SEEK_SET); return TRUE; } /****************************************************** db3_print_recs() Read records and print the data ******************************************************/ void db3_print_recs(cnt, flags, delim) int cnt; int flags; char delim; { int bytes; while(cnt) { bytes=fread(Buffer,1,dbhead.lrecl,dbfile); if(bytes!=dbhead.lrecl) break; /* Check if deleted == '*' */ if(flags & DB_FL_DELETED || Buffer[0]==' ') { db3_print(flags, delim, Buffer[0]); cnt--; } } return; } /****************************************************** db3_print() Print a single record ******************************************************/ void db3_print(flags, delim, deleted) int flags; char delim; char deleted; { FLD_LIST *temp; temp=db_fld_root; if ((flags & DB_FL_DELETED) && (flags & DB_FL_BROWSE)) printf("%c%c", deleted, delim); while (temp) { memcpy(buf_work,temp->data,temp->fld->length); buf_work[temp->fld->length] = '\0'; if (flags & DB_FL_BROWSE) if (flags & DB_FL_TRIM) printf("%s%c",db3_rm_tr_spc(db3_rm_ld_spc(buf_work)), delim); else printf("%s%c",buf_work, delim); else printf("%-11s: %s\n",temp->fld->name,db3_rm_tr_spc(db3_rm_ld_spc(buf_work))); temp=temp->next; } if ((flags & DB_FL_DELETED) && ((flags & DB_FL_BROWSE) == 0) && (deleted != ' ')) printf("*Deleted* : %c\n", deleted); printf("\n"); return; } /****************************************************** stack_field() Add a field to the linked list of fields ******************************************************/ void stack_field(fld) DBASE_FIELD *fld; { FLD_LIST *list, *temp; list=(FLD_LIST *)calloc(1,sizeof(FLD_LIST)); if (!list) { printf ("Not enough memory\n"); return; } list->fld=fld; if(!db_fld_root) { list->data = (uint8_t *)Buffer+1; /*skip delete byte*/ db_fld_root=list; return; } temp=db_fld_root; while(temp->next) temp=temp->next; temp->next=list; list->data=temp->data + temp->fld->length; return; } dbview-1.0.4/db_dump.h0000644000076500001440000000772110530137226013457 0ustar joeyusers/* db_dump.h - Routines for reading dBase III files Copyright (c) 1995,96,2003 Martin Schulze This file is part of the dbview package, a viewer for dBase II files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ /* Most of the code in this file comes from Greg Twaites anno 87. I only took the file and wrote a program around it. I enclude the whole header. I have obtained this file from a free software archive, namely nic.funet.fi. It is supposed to be placed in the public domain. Hence, adding GPL code around and distributinng the entire file under the GPL should be fine. ftp://nic.funet.fi/pub/msdos/languages/c/dbase.c */ /* * These functions are used to read dbase files. * * These functions are provided by Valour Software as a gift. * * The program is for test purposes only. No warranty is expressed nor * implied. USE AT YOUR OWN RISK! * * */ #include #define DB_FL_BROWSE 0x01 #define DB_FL_INFO 0x02 #define DB_FL_DESCR 0x04 #define DB_FL_RESERVE 0x08 #define DB_FL_OMIT 0x10 #define DB_FL_TRIM 0x20 #define DB_FL_DELETED 0x40 typedef struct dbase_head { uint8_t version; /* 03 for dbIII and 83 for dbIII w/memo file */ uint8_t l_update[3]; /* yymmdd for last update*/ uint32_t count; /* number of records in file*/ uint16_t header; /* length of the header * includes the \r at end */ uint16_t lrecl; /* length of a record * includes the delete * byte */ uint8_t reserv[20]; } DBASE_HEAD; #define DB_FLD_CHAR 'C' #define DB_FLD_NUM 'N' #define DB_FLD_LOGIC 'L' #define DB_FLD_MEMO 'M' #define DB_FLD_DATE 'D' typedef struct dbase_fld { uint8_t name[11]; /*field name*/ uint8_t type; /*field type*/ /* A-T uses large data model but drop it for now */ uint8_t *data_ptr; /*pointer into buffer*/ uint8_t length; /*field length*/ uint8_t dec_point; /*field decimal point*/ uint8_t fill[14]; } DBASE_FIELD; typedef struct fld_list { struct fld_list *next; DBASE_FIELD *fld; uint8_t *data; } FLD_LIST; int db3_process(char*, int, char); /****************************************************** db3_read_dic() This function is called with a file name to read to create a record type to support the dbase file ******************************************************/ int db3_read_dic(int); /****************************************************** db3_print_recs() Read records and print the data ******************************************************/ void db3_print_recs(int, int, char); /****************************************************** db3_print() Print a single record ******************************************************/ void db3_print(int, char, char); /****************************************************** stack_field() Add a field to the linked list of fields ******************************************************/ void stack_field(DBASE_FIELD *); dbview-1.0.4/db_dump.header0000644000076500001440000000116607414132360014456 0ustar joeyusersPath: clinet!santra!tut!enea!mcvax!seismo!uwvax!oddjob!hao!noao!mcdsun!sunburn!sicom!twaites From: twaites@sicom.UUCP (Greg Twaites) Newsgroups: comp.sys.ibm.pc Subject: C source to read dBASE files Keywords: c source dbase Message-ID: <121@sicom.UUCP> Date: 29 May 87 04:23:49 GMT Lines: 212 Posted: Thu May 28 21:23:49 1987 Here is the C code that allows you to read a DBASE-III file. I verified that it works under Microsoft C v4.0. Hope it does every thing you need. I am not sure where it came from, so hopefully I am not violating anyones copyrights :-). Have fun. Greg Twaites SICOM Inc. !ihnp4!sun!sunburn!sicom!twaites dbview-1.0.4/dbview.10000644000076500001440000001145110530350130013220 0ustar joeyusers.\" Copyright (c) 1996,2003,6 Martin Schulze .\" .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual 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 General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, write to the Free .\" Software Foundation, Inc., 59 Temple Place - Suite 330, .\" Boston, MA 02111, USA. .\" .TH DBVIEW 1 "November 20th, 2006" "Unix" "Database Management" .SH NAME dbview \- View dBase III files .SH SYNOPSIS .B dbview .RB [ \-b | \-\-browse ] .RB [ \-d .IR delim | .B \-\-delimiter .IR delim ] .RB [ \-D | \-\-deleted ] .RB [ \-e | \-\-description ] .RB [ \-h | \-\-help ] .RB [ \-i | \-\-info ] .RB [ \-o | \-\-omit ] .RB [ \-v | \-\-version ] .RB [ \-r | \-\-reserve ] .RB [ \-t | \-\-trim ] .I dbfile .SH DESCRIPTION .B Dbview is a little tool that will display dBase III files. You can also use it to convert your old .dbf files for further use with Unix. It should also work with dBase IV files, but this is mostly untested. By default .B dbview displays the contents of a dBase III or IV database file. This is be done by displaying both the name of the field itself and its value. At the end of every record a newline is appended. .SH OPTIONS If no option given .B dbview only displays the database in its most friendly way. .TP .B "\-\-browse, \-b" switches into browse mode. Using this mode no fieldnames will be displayed, instead every record will displayed in one line using a delimiter to separate fields. .TP .BI "\-\-delimiter, \-d "delimiter The default delimiter in browse mode is the colon sign ``:''. This parameter overrides it. This can be useful especially if you plan to examine the output with scripts. .TP .B "\-\-deleted, \-D" displays deleted records as well as the delete state in each record in the database. .TP .B "\-\-description, \-e" displays the field description of the database. .TP .B "\-\-help, \-h" displays a complete (or short) help screen. .TP .B "\-\-info, \-i" displays some (partially technical) information about the database like number of records and length of each record. .TP .B "\-\-omit, \-o" omits displaying the whole database. Using this parameter can be useful if you're only interested in the structure. .TP .B "\-\-reserve, \-r" Normally fieldnames are converted into a more friendly format. They are stored in capital letters, but that looks like shouting. This parameter supresses the conversion. .TP .B "\-\-trim, \-t" When this option is specified, leading and trailing spaces are omitted. This might be useful when in browse mode. .TP .B "\-\-version, \-v" displays version and exits. .SH NOTES As dBase is DOS, umlauts are stored using a different code table (namely ASCII) than most modern unices (namely ANSI). If you encounter such a file, I would recommend piping the output through .BR recode (1) with .B ibmpc:latin1 as it's argument. If you want to examine the output generated by the browse mode, just take .BR cut (1) and set its delimiter to the used delimiter or take .BR awk (1) and continue. .SH COPYRIGHT .B Dbview is free software. It is based on routines from unknown source that I found on nic.funet.fi in /pub/msdos/languages/c as dbase.c. The file contained the following notice: These functions are provided by Valour Software as a gift. I have modified and included this file and wrote a skeleton around it. All together provides a powerful tool for dBase III and IV database manipulation under Unix. I mainly have written this program, because I've got several dbase files containing important information for me. As I won't go running DOS everytime I need some of the stored information, I had to find a viewer that runs unter Unix, resp. Linux, but unfortunately didn't find one. So it was my turn. This package as a whole is published under the GNU Public License, which is a great invention. It wasn't the intention to write a freaking viewer and reinvent the wheel again. Instead .B dbview is intend to be used in conjunction with your favourite unix text utilities like .BR cut , .B recode and .BR more . Martin Schulze .br Infodrom Oldenburg .br joey@infodrom.north.de .SH "SEE ALSO" .BR recode (1), .BR more (1), .BR awk (1), .BR cut (1). dbview-1.0.4/dbview.c0000644000076500001440000000755710530137227013330 0ustar joeyusers/* dbview.c - View dBase III files Copyright (c) 1995,96,2003 Martin Schulze This file is part of the dbview package, a viewer for dBase II files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ /* * Thu Sep 26 21:38:33 1996: Martin Schulze * Added trimming option (-t) to also get untrimmed browse output. * Thanks to Magnus Lassus for the idea and * providing me with a patch. */ #include "version.h" #include "db_dump.h" #include #include #include #include void help_short() { printf ("%s %s - %s, (c) 1996 by Martin Schulze\n", progname, version, longname); printf ("\n"); printf ("%s [-b [-t]] [-d delim] [-e] [-h] [-i] [-D] [-o] [-v] dbfile\n", progname); } void help_long() { printf ("%s %s - %s, (c) 1996 by Martin Schulze\n", progname, version, longname); printf ("\n"); printf (" --browse, -b browse the database\n"); printf (" --delimiter, -d set the delimiter for browse output\n"); printf (" --description, -e display field description\n"); printf (" --help, -h display help\n"); printf (" --info, -i display db information\n"); printf (" --deleted, -D display deleted records\n"); printf (" --omit, -o omit db records\n"); printf (" --reserve, -r reserve fieldnames from beeing translated\n"); printf (" --trim, -t trim browse fields\n"); printf (" --version, -v display version\n"); } int main (int argc, char **argv) { int opt_index; int c; static const struct option long_options[] = { {"browse", no_argument, 0, 'b'}, {"delimiter", required_argument, 0, 'd'}, {"description", no_argument, 0, 'e'}, {"help", no_argument, 0, 'H'}, {"info", no_argument, 0, 'i'}, {"omit", no_argument, 0, 'o'}, {"deleted", no_argument, 0, 'D'}, {"reserve", no_argument, 0, 'r'}, {"trim", no_argument, 0, 't'}, {"version", no_argument, 0, 'v'}, {0, 0, 0, 0} }; char dbfile[256]; int flags = 0; char delim = ':'; optind = 0; while ( (c = getopt_long(argc, argv, "Hbd:ehiDortv", long_options, &opt_index)) != -1 ) { switch (c) { case 'H': /* --help */ help_long (); exit (0); case 'b': flags |= DB_FL_BROWSE; break; case 'd': if (!argv[optind]) { printf ("Too few arguments.\n"); break; } delim = optarg[0]; break; case 'e': flags |= DB_FL_DESCR; break; case 'h': help_short (); exit (0); case 'i': flags |= DB_FL_INFO; break; case 'D': flags |= DB_FL_DELETED; break; case 'o': flags |= DB_FL_OMIT; break; case 'r': flags |= DB_FL_RESERVE; break; case 't': flags |= DB_FL_TRIM; break; case 'v': /* --version */ printf ("%s %s - %s\n", progname, version, longname); exit (0); } /* switch */ } /* while */ /* printf ("argc=%d, optind=%d\n", argc, optind); */ if ( argc - optind < 1) { help_short(); exit (0); } strcpy(dbfile, argv[optind]); /* if ! -f dbfile thnen -f dbfile.dbf */ exit (db3_process (dbfile, flags, delim)); } dbview-1.0.4/version.c0000644000076500001440000000174510530250472013524 0ustar joeyusers/* version.c - version string Copyright (c) 1995,96,2003,6 Martin Schulze This file is part of the dbview package, a viewer for dBase II files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ char progname[] = "dbview"; char longname[] = "View dBase III files"; char version[] = "1.0.4"; dbview-1.0.4/version.h0000644000076500001440000000171107723724170013535 0ustar joeyusers/* version.h - version string Copyright (c) 1995,96,2003 Martin Schulze This file is part of the dbview package, a viewer for dBase II files. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program 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 General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */ extern char progname[]; extern char longname[]; extern char version[];