Category : Databases and related files
Archive   : WIZCON.ZIP
Filename : WIZCON.C

 
Output of file : WIZCON.C contained in archive : WIZCON.ZIP
// WIZCON.C
// (C) Jan C. Zawadzki, 1992
//
//
// CODE RELEASED INTO PUBLIC DOMAIN ON 02/02/92
// USE AT YOUR OWN RISK...

#include
#include

#include "wizcon.h"
#include "act.h"


struct record rec; // records
struct actrec arec;

char infilenm[8],outfilenm[8]; // file names

FILE *in, *out; // file handles


int m_number=0; // magic number we are searching for

int recproc =0; // records processed
int recconv =0; // records converted

void convert(); // convert function
char *gender(unsigned char); // find gender
char *status(unsigned char); // set status
char *parse (char *); // parse last name / first name field

main(int argc, char *argv[]){


if (argc!=3) {
printf("\tYou MUST provide output file name,\n");
printf("\tAND the product location NN.\n\n");
printf("\t\twizcon EXPORT.DAT NN\n");
printf("\Where EXPORT.DAT is the output file, NN is product location.\n\n");
exit(1);
}

if (strlen(argv[1]) > 12) {
printf("\tFilename %s is too long!\n", argv[2]);
exit(1);
}

m_number = atoi(argv[2]);

if ((in = fopen("mail.lst", "rb"))== NULL) {
fprintf(stderr, "\n* Cannot open input file %s.\n", "mail.lst");
exit(1);
}

if ((out = fopen(argv[1], "wt"))== NULL) {
fprintf(stderr, "Cannot open output file %s.\n", argv[2]);
exit(1);
}

convert();

return 0;
}

void convert() {
clrscreen(); // clean screen
while (!feof(in)) {
fread(&rec, 256, 1, in);
l_prod(rec.prodpurch);
recproc++;
}
gotoxy(1,10);
printf("Records processed: %5d\nRecords converted: %5d\n\n",
recproc, recconv);
}

clrscreen(){
clrscr();
gotoxy(1,1);
printf("Name:");
gotoxy(1,3);
printf("Address:");
gotoxy(1,4);
printf(" :");
gotoxy(1,5);
printf("City:");
gotoxy(29,5);
printf("State:");
gotoxy(40,5);
printf("Zip:");
gotoxy(57,5);
printf("Country:");
}

printsc() {
gotoxy(75,1);
printf("%5.5d", recproc);

gotoxy(10,1);
printf("%-34.34s",rec.name);

gotoxy(10,2);
printf("%-25.25s",rec.contactname);

gotoxy(10,3);
printf("%-25.25s",rec.adr1);

gotoxy(10,4);
printf("%-25.25s",rec.adr2);

gotoxy(7,5);
printf("%-19.19s",rec.city);

gotoxy(36,5);
printf("%-2.2s", rec.state);

gotoxy(45,5);
printf("%-10.10s",rec.zip);

gotoxy(66,5);
printf("%-14.14s",rec.country);

}



// list product info
l_prod(void *str) {
unsigned char *nr,i,num;


num = m_number-1;
nr = str;
for (i=0;i<25;i++,nr++) {
if (*nr & 1) {
if (i*8 == num) export(rec);
}
if (*nr & 2) {
if (i*8+1 == num) export(rec);
}
if (*nr & 4) {
if (i*8+2 == num) export(rec);
}
if (*nr & 8) {
if (i*8+3 == num) export(rec);
}
if (*nr & 16) {
if (i*8+4 == num) export(rec);
}
if (*nr & 32) {
if (i*8+5 == num) export(rec);
}
if (*nr & 64) {
if (i*8+6 == num) export(rec);
}
if (*nr & 128) {
if (i*8+7 == num) export(rec);
}
}
}

export(struct record rec) {
recconv++;

setmem(arec,sizeof(arec),' ');
strcpy(arec.name, parse(rec.name));
strcpy(arec.contact, parse(rec.contactname));
strncpy(arec.adr1, rec.adr1,25);
strncpy(arec.adr2, rec.adr2,25);
strncpy(arec.city, rec.city,19);
strncpy(arec.state, rec.state,2);
strncpy(arec.zip, rec.zip,10);
strncpy(arec.phone, rec.phone1,10);

strcpy(arec.salut, salut(rec.mtitle));
strcpy(arec.usr2, status(rec.flags));

strcpy(arec.usr4, gender(rec.flags));

strcpy(arec.result,"Moved from Wizard\0");

strcpy(arec.idstat,"Hot prospect\0");

printarec();
}

printarec(struct record rec) {
unsigned char tmp;
printsc();

fprintf(out,"\"%-50.50s\",",arec.name);
fprintf(out,"\"%-30.30s\",",arec.contact);
fprintf(out,"\"%-50.50s\",",arec.adr1);
fprintf(out,"\"%-27.27s\",",arec.adr2);
fprintf(out,"\"\",");
fprintf(out,"\"%-27.27s\",",arec.city);
fprintf(out,"\"%-27.27s\",",arec.state);
fprintf(out,"\"%-27.27s\",",arec.zip);
fprintf(out,"\"%-10.10s\",",arec.phone);
fprintf(out,"\"\","); // extension
fprintf(out,"\"\","); // country
fprintf(out,"\"\","); // title
fprintf(out,"\"%s\",", arec.salut);
fprintf(out,"\"\","); // secretary
fprintf(out,"\"\","); // date catalog sent
fprintf(out,"\"%s\",",arec.usr2); // retail/wholesale
fprintf(out,"\"\","); // shipping title
fprintf(out,"\"%s\",", arec.usr4); // gender
for (tmp=0;tmp<15;tmp++) fprintf(out,"\"\",");
fprintf(out,"\"Transfer from Wizard\",");
fprintf(out,"\"\","); // call
fprintf(out,"\"\","); // meet
fprintf(out,"\"\","); // to do
fprintf(out,"\"Hot prospect\",");
for (tmp=0;tmp<23;tmp++) fprintf(out,"\"\",");
fprintf(out,"\n");
}

salut(char *title) {
switch(*title) {
case 'M': return "Mr.\0"; break;
case 'F': return "ms.\0"; break;
case 'W': return "Mrs.\0"; break;
case 'S': return "Miss\0"; break;
case 'D': return "Dr.\0"; break;
default: return "\0"; break;
}
}

char *gender(unsigned char flags) {
if (flags & 1) return ("Male\0");
if (flags & 2) return ("Female\0");
return("\0");
}

char *status(unsigned char flags) {
if (flags & 4) return ("Wholesale\0");
return("Retail\0");
}

char *parse(char *name){
char fname[34],lname[34], longnm[50];
int i;
char mark = '\xFF',*mk2=NULL;

memset(fname,'\0',34);
memset(lname,'\0',34);
memset(longnm,'\0',50);


mk2 = strchr(name,mark);
if (mk2== NULL) return(name);
strcpy(lname,++mk2);

for (mk2=name,i=0;*mk2!='\xFF';mk2++, i++)
fname[i] = *mk2;

sprintf(longnm,"%s %s\0",lname, fname);

return(longnm);
}


  3 Responses to “Category : Databases and related files
Archive   : WIZCON.ZIP
Filename : WIZCON.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/