|
|
DataMuseum.dkPresents historical artifacts from the history of: Commodore CBM-900 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Commodore CBM-900 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 2388 (0x954)
Types: TextFile
Notes: UNIX file
Names: »dump.c«
└─⟦f27320a65⟧ Bits:30001972 Commodore 900 hard disk image with partial source code
└─⟦f4b8d8c84⟧ UNIX Filesystem
└─⟦this⟧ »unimenu/src/menu/dump.c«
#ifdef DUMPS
static char *SCCSid = "@(#)dump.c 1.1 15:34:34 4/6/85";
/*
* Copyright (c) 1984
*
* LANTECH Systems, Incoroporated
*
* All rights reserved
*/
/*
* Function: dump(file,mp)
*
* Args: file: a character string which is the name of a file
* to which to dump the file.
*
* returns: Probably
*
* History: Original coding by Robert Adams July 84.
*
* Notes: This should produce a Menu Control File syntactically
* equivalent to the original file.
*/
#include "defs.h"
#define lfprintf(fp,lp,v) {if(lp)fprintf(fp,"%s:%s\n",lp->l_key,lp->l_val);}
extern char *MCFile;
dump (file, mp,verbose)
char *file;
struct menu_f *mp;
int verbose;
{
FILE * fp;
struct choice_f *chp;
int i;
if (file == NULL || mp == NULL)
return;
if ((fp = fopen (file, "w")) == NULL)
{
perror (file);
return;
}
if ( verbose )
{
fprintf (fp, "#\n");
fprintf (fp, "# dump file of \"%s\"\n", MCFile);
fprintf (fp, "#\n");
}
/*
* Global keywords.
* First, help exec, and text.
*/
cfprintf (fp, &(mp -> m_global),verbose);
/*
* Next, the exclusively global keywords.
* Prompt and Bad, and oh yeah, Columns
*/
if (mp -> m_prompt)
fprintf (fp, "Prompt:%s\n", mp -> m_prompt);
if (mp -> m_bad)
fprintf (fp, "Bad:%s\n", mp -> m_bad);
fprintf(fp,"Columns:%d\n",mp->m_col);
/*
* Now for the linked list.
*/
chp = mp -> m_list;
i = 0;
while (chp)
{
fprintf (fp, "\n");
if (verbose)
fprintf (fp, "# Choice #%d\n", ++i);
cfprintf (fp, chp,verbose);
chp = chp -> c_next;
}
fclose (fp);
return;
}
cfprintf (fp, chp,verbose)
FILE * fp;
struct choice_f *chp;
int verbose; /* BOOL: use comments? */
{
struct line_f *lp;
if (chp == NULL) /* dont print out garbage.
*/
return;
if (verbose && chp -> c_text)
fprintf(fp,"# Text:\n");
lfprintf (fp, chp -> c_text,verbose); /* print out the ones */
if (verbose && chp -> c_help)
fprintf(fp,"# Help:\n");
lfprintf (fp, chp -> c_help,verbose); /* we know about */
if (verbose && chp -> c_exec)
fprintf(fp,"# Exec:\n");
lfprintf (fp, chp -> c_exec,verbose);
lp = chp -> c_list; /* and the ones we dont */
if (verbose && lp)
fprintf (fp, "#\n"),
fprintf (fp, "# Unknown values, no-ops.\n"),
fprintf (fp, "#\n");
while (lp)
{
lfprintf (fp, lp,verbose);
lp = lp -> l_next; /* walk the linked list */
}
return;
}
#endif