DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T d

⟦55a531b2c⟧ TextFile

    Length: 2495 (0x9bf)
    Types: TextFile
    Names: »dbadd.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/others/rdbm/dbadd.c« 
└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦35176feda⟧ »EurOpenD22/isode/isode-6.tar.Z« 
        └─⟦de7628f85⟧ 
            └─⟦this⟧ »isode-6.0/others/rdbm/dbadd.c« 

TextFile

/* Program    ddadd.c
 * Written    March 1988, William J. Romine
 * Purpose    This filter adds fixed length records to a dbm database.
 */

#include <dbm.h>
#undef	NULL
#include <stdio.h>

int dbopen(), dbclose();

#define  DBOK      1
#define  DBNOTOK   0

static struct m_foo {
  int strs;
#define MAXSTRS    30
  int xs[MAXSTRS];
  int ys[MAXSTRS];
  char str[MAXSTRS][80];
  int items;
  int key;
#define MAXITEMS   30
  int size[MAXITEMS];
  int xd[MAXITEMS];
  int yd[MAXITEMS];
  int up[MAXITEMS];
  int down[MAXITEMS];
  int right[MAXITEMS];
  int left[MAXITEMS];
  int next[MAXITEMS];
  int where[MAXITEMS];
  int rsize;
} m;

static char gstr[1025];

static datum tokey(), todat();
static void movexy(), tostr();

main(argc,argv)
int argc;
char *argv[];
{
  datum key, dat;

  if (dbopen(argv[1]) != DBOK) 
    exit(1);
  while (gets(gstr) != NULL) {
    key = tokey(gstr);
    dat = todat(gstr);
    store(key,dat);
  }
  exit(0);
}
      

int dbopen(fname)
char *fname;
{
  int i;
  FILE *fp;
  char mname[20];

  if (dbminit(fname) != 0) {
    fprintf(stderr,"dbopen: cant open file, %s\n",fname);
    perror("dbopen");
    return(DBNOTOK);
  }
  (void) strcpy(mname,fname);
  (void) strcat(mname,".msk");
  if ((fp = fopen(mname,"r")) == (FILE *) NULL) {
    fprintf(stderr,"dbopen: cant open file %s\n",fname);
    perror("dbopen");
    return(DBNOTOK);
  }
  fscanf(fp,"%d",&m.strs);
  for (i = 0; i < m.strs; i++) {
    if (fscanf(fp,"%d,%d,'%[^']'",&m.xs[i],&m.ys[i],m.str[i]) != 3) {
      fprintf(stderr,"dbopen: cant read mask file string %d\n",i);
      return(DBNOTOK);
    }
  }
  fscanf(fp,"%d,%d",&m.items,&m.key);
  m.rsize = 0;
  for (i = 0; i < m.items; i++)  {
    if (fscanf(fp,"%d,%d,%d,%d,%d,%d,%d,%d",&m.size[i],&m.xd[i],
               &m.yd[i],&m.up[i],&m.down[i],&m.right[i],
               &m.left[i],&m.next[i]) != 8) {
      fprintf(stderr,"dbopen: cant read mask file item %d\n",i);
      return(DBNOTOK);
    }
    m.where[i] = m.rsize;
    m.rsize += m.size[i];
  }
  (void) fclose(fp);
  return(DBOK);
}

static void tostr(key,dat)
datum key;
char *dat;
{
  strncpy(dat,key.dptr,key.dsize);
}

static datum todat(str)
char *str;
{
  static datum dat;
  dat.dptr = str;
  dat.dsize = m.rsize;
  return(dat);
}

static datum tokey(str)
char *str;
{
  static datum key;
  key.dptr =  &str[m.where[m.key]];
  key.dsize = m.size[m.key];
  return(key);
}

static void blank(str)
char *str;
{
  int i;
  for (i = 0; i < m.rsize; i++)
    str[i] = ' ';
}