File:  [CSRG BSD Unix] / 43BSDReno / contrib / isode-beta / quipu / turbo / edbcat.c
Revision 1.1: download - view: text, annotated - select for diffs
Tue Apr 24 16:12:56 2018 UTC (8 years, 1 month ago) by root
CVS tags: MAIN, HEAD
Initial revision

#include <stdio.h>
#include <gdbm.h>
#include <sys/file.h>
#include <ctype.h>

extern int gdbm_errno;

main (argc, argv)
int	argc;
char	**argv;
{
	GDBM_FILE	db;
	datum		key, content;
	char		buf[4096], kbuf[256];
	char		*bp, *rc;
	int		buflen, len;
	char		type[80], version[256];
	char		gfname[1024];
	char		*TidyString();

	if ( argc != 2 ) {
		printf("usage: %s edbdbmfile\n", argv[0]);
		exit(1);
	}

	strcpy(gfname, argv[1]);
	strcat(gfname, ".gdbm");
	if ( (db = gdbm_open(gfname, 0, GDBM_READER, 0, 0)) == NULL ) {
		printf("Can't open (%s)\ndbm_error is (%d)\n",gfname,gdbm_errno);
		exit(1);
	}

	key.dptr = "HEADER";
	key.dsize = sizeof("HEADER");
	content = gdbm_fetch(db, key);
	if ( content.dptr == NULL ) 
		printf("No header!  Continuing...\n");
	else
		printf("%s\n", content.dptr);

	for ( key = gdbm_firstkey(db); key.dptr; key = gdbm_nextkey(db, key) ) {
		if ( strcmp(key.dptr, "HEADER") == 0 )
			continue;

		content = gdbm_fetch(db, key);
		printf("%s", content.dptr);
		free(content.dptr);
		content.dptr = NULL;
	}

	(void) gdbm_close(db);
}

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.