/************************************************************************/
/*	topuid_cvt.c							*/
/*	Routines to convert to and from topuid binary database to	*/
/*	ascii.  Mainline is in cvt.c.					*/
/************************************************************************/

#include <stdio.h>
#include "inquir.h"

makeascii( dbname )	char *dbname;
    {
    FILE *infile;
    short uid;
    if( dbname == NULL ) dbname = Uidfile;
    if( (infile = fopen(dbname,"r") ) == NULL )
	{
	perror( dbname );
	return -1;
	}
    fread( &uid, sizeof(uid), 1, infile );
    printf("%d\n",uid);
    fclose(infile);
    return 0;
    }

makedb( dbname )	char *dbname;
    {
    FILE *outfile;
    short uid;
    int iuid;
    if( dbname == NULL ) dbname = Uidfile;
    if( (outfile = fopen(dbname,"w") ) == NULL )
	{
	perror( dbname );
	return -1;
	}
    scanf( "%d", &iuid );
    uid = iuid;
    fwrite( &uid, sizeof(uid), 1, outfile );
    fclose( outfile );
    return 0;
    }
