                   Creating FILES.BBS automatically

                            Matthew Probert


                           Servile  Software


This program was released as freeware by Servile Software in March 
1996. It essentialy assists BBS sysops who have been uploaded a batch 
of files without a description. The program (MKLIST) scans each .ZIP 
archive and extracts a desc.sdi (or failing that a file_id.diz) from 
the archive and uses it as a description to create a FILES.BBS list 
which then helps to import the uploaded files information into the 
BBS.

I originally wrote this to create a FILES.BBS list to accompany an 
archive of dozens of archives which were being uploaded to save me 
typing in the file descriptions (just not possible on 100 files!)

References to PKZIP can easily be changed to ARJ or anyother archiver 
if you prefer, the program simply issues a command out to DOS for each 
archive it encounters to extract the description file which is then 
read and deleted before the next one is processed.

------------------------------Cut Here------------------------------
/*
    Create a FILES.BBS list of all .ZIP archives in the current
    directory using desc.sdi or file_id.diz description files
    contained in the archives for a description.

    Matthew Probert
    Compile with Borland C, any memory model (why not small?)
*/

#include <stdio.h>
#include <dir.h>
#include <string.h>
#include <stdlib.h>

FILE *fp;              /* File stream to FILES.BBS */
FILE *src;             /* File stream to description file */
int done;              /* Any more archives to process flag */
struct ffblk ffblk;    /* DTA structure */
char comstr[100];      /* Command string passed to DOS */

void DO_ZIP(void);

void main()
{
    /*
        A quick reminder of who wrote this software
    */
    fprintf(stderr,"\nServile Software Make FILES.BBS list Version 1.0\n");

    /*
        Now do the business
    */
    DO_ZIP();
}

void DO_ZIP()
{
    /*
        Can we locate pkunzip.exe in the searchpath?
    */
    if (searchpath("pkunzip.exe") == NULL)
    {
        /*
            No is the answer to that! So pack up and go home.
        */
        fprintf(stderr,"ERROR: Unable to locate pkunzip.exe\n");
        exit(0);
    }

    /*
        Yes we have access to pkunzip, we can continue
    */
    fprintf(stderr,"Now building files.bbs. Please wait....\n");

    /*
        Create a new file called files.bbs
    */
    fp = fopen("files.bbs","w+");
    if (fp == NULL)
    {
        fprintf(stderr,"ERROR: Unable to create a FILES.BBS file in this directory\n");
        exit(0);
    }

    /*
        Now locate all .ZIP archives in this directory
    */
    done = findfirst("*.zip",&ffblk,0);
    while(!done)
    {
        /*
            Call pkunzip to extract desc.sdi from the archive
        */
        sprintf(comstr,"pkunzip -o %s desc.sdi",ffblk.ff_name);
        system(comstr);

        /*
            Try to read the desc.sdi file
        */
        src = fopen("desc.sdi","r");
        if (src)
        {
            /*
                Ar good we can read it!
            */
            fgets(comstr,90,src);
            if (comstr[strlen(comstr) - 1] == '\n')
                comstr[strlen(comstr) - 1] = 0;
            /*
                Create an entry in FILES.BBS
            */
            fprintf(fp,"%s %s\n",ffblk.ff_name,comstr);
            /*
                Close the file stream to desc.sdi
            */
            fclose(src);
            /*
                And delete the desc.sdi file
            */
            unlink("desc.sdi");
        }
        else
        {
            /*
                Okay, no desc.sdi found (or maybe we ran out of file
                handles?
                In any event we will try to extract a file_id.diz
                description file from the archive
            */
            sprintf(comstr,"pkunzip %s file_id.diz",ffblk.ff_name);
            system(comstr);

            src = fopen("file_id.diz","r");
            if (src)
            {
                fgets(comstr,90,src);
                if (comstr[strlen(comstr) - 1] == '\n')
                    comstr[strlen(comstr) - 1] = 0;
                fprintf(fp,"%s %s\n",ffblk.ff_name,comstr);
                fclose(src);
                unlink("file_id.diz");
            }
            else
                fprintf(fp,"%s NO DESCRIPTION!\n",ffblk.ff_name);
        }
        done = findnext(&ffblk);
    }
}

------------------------------Cut Here------------------------------

