* src/sconvert.c src/frontend/circuits.c src/frontend/circuits.h
src/frontend/inp.c src/frontend/inpcom.c src/include/fteext.h src/parser/front.c: ANSIfication, removed some empty functions.
This commit is contained in:
parent
b824ff0bf4
commit
4e605553de
|
|
@ -3,11 +3,8 @@ Copyright 1990 Regents of the University of California. All rights reserved.
|
|||
Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
||||
**********/
|
||||
|
||||
/*
|
||||
*
|
||||
* Routines for dealing with the circuit database. This is currently
|
||||
* unimplemented.
|
||||
*/
|
||||
/* Routines for dealing with the circuit database. This is currently
|
||||
* unimplemented. */
|
||||
|
||||
#include "ngspice.h"
|
||||
#include "cpdefs.h"
|
||||
|
|
@ -19,16 +16,9 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group
|
|||
struct circ *ft_curckt = NULL; /* The default active circuit. */
|
||||
struct circ *ft_circuits = NULL;
|
||||
|
||||
struct subcirc *ft_subcircuits = NULL;
|
||||
|
||||
/* Now stuff to deal with circuits */
|
||||
|
||||
|
||||
void
|
||||
ft_setccirc(char *name)
|
||||
{
|
||||
}
|
||||
|
||||
/* Add a circuit to the circuit list */
|
||||
|
||||
void
|
||||
|
|
@ -38,12 +28,3 @@ ft_newcirc(struct circ *ckt)
|
|||
ft_circuits = ckt;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Add a new subcircuit to the subcircuit list */
|
||||
|
||||
|
||||
void
|
||||
ft_newsubcirc(struct subcirc *sckt)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@
|
|||
#define CIRCUITS_H_INCLUDED
|
||||
|
||||
|
||||
void ft_setccirc(char *name);
|
||||
void ft_newcirc(struct circ *ckt);
|
||||
void ft_newsubcirc(struct subcirc *sckt);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -71,8 +71,9 @@ com_listing(wordlist *wl)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
static char *
|
||||
upper(register char *string)
|
||||
upper(char *string)
|
||||
{
|
||||
|
||||
static char buf[BSIZE_SP];
|
||||
|
|
@ -89,11 +90,10 @@ upper(register char *string)
|
|||
|
||||
}
|
||||
|
||||
/* Provide an input listing on the specified file of the given
|
||||
* card deck. The listing should be of either LS_PHYSICAL or LS_LOGICAL
|
||||
* or LS_DECK lines as specified by the type parameter.
|
||||
*/
|
||||
|
||||
/* Provide an input listing on the specified file of the given card
|
||||
* deck. The listing should be of either LS_PHYSICAL or LS_LOGICAL or
|
||||
* LS_DECK lines as specified by the type parameter. */
|
||||
void
|
||||
inp_list(FILE *file, struct line *deck, struct line *extras, int type)
|
||||
{
|
||||
|
|
@ -105,9 +105,10 @@ inp_list(FILE *file, struct line *deck, struct line *extras, int type)
|
|||
|
||||
if (useout)
|
||||
out_init();
|
||||
(void) cp_getvar("renumber", VT_BOOL, (char *) &renumber);
|
||||
cp_getvar("renumber", VT_BOOL, (char *) &renumber);
|
||||
if (type == LS_LOGICAL) {
|
||||
top1: for (here = deck; here; here = here->li_next) {
|
||||
top1:
|
||||
for (here = deck; here; here = here->li_next) {
|
||||
if (renumber)
|
||||
here->li_linenum = i;
|
||||
i++;
|
||||
|
|
@ -119,10 +120,7 @@ top1: for (here = deck; here; here = here->li_next) {
|
|||
sprintf(out_pbuf, "%6d : %s\n",
|
||||
here->li_linenum,
|
||||
upper(here->li_line));
|
||||
out_send(out_pbuf);
|
||||
/* out_printf("%6d : %s\n",
|
||||
here->li_linenum,
|
||||
upper(here->li_line)); */
|
||||
out_send(out_pbuf);
|
||||
} else
|
||||
fprintf(file, "%6d : %s\n",
|
||||
here->li_linenum,
|
||||
|
|
@ -141,13 +139,13 @@ top1: for (here = deck; here; here = here->li_next) {
|
|||
goto top1;
|
||||
}
|
||||
if (useout) {
|
||||
/* out_printf("%6d : .end\n", i); */
|
||||
sprintf(out_pbuf, "%6d : .end\n", i);
|
||||
out_send(out_pbuf);
|
||||
} else
|
||||
fprintf(file, "%6d : .end\n", i);
|
||||
} else if ((type == LS_PHYSICAL) || (type == LS_DECK)) {
|
||||
top2: for (here = deck; here; here = here->li_next) {
|
||||
top2:
|
||||
for (here = deck; here; here = here->li_next) {
|
||||
if ((here->li_actual == NULL) || (here == deck)) {
|
||||
if (renumber)
|
||||
here->li_linenum = i;
|
||||
|
|
@ -158,28 +156,28 @@ top2: for (here = deck; here; here = here->li_next) {
|
|||
if (type == LS_PHYSICAL) {
|
||||
if (useout) {
|
||||
sprintf(out_pbuf, "%6d : %s\n",
|
||||
here->li_linenum,
|
||||
upper(here->li_line));
|
||||
out_send(out_pbuf);
|
||||
here->li_linenum,
|
||||
upper(here->li_line));
|
||||
out_send(out_pbuf);
|
||||
} else
|
||||
fprintf(file, "%6d : %s\n",
|
||||
here->li_linenum,
|
||||
upper(here->li_line));
|
||||
here->li_linenum,
|
||||
upper(here->li_line));
|
||||
} else {
|
||||
if (useout)
|
||||
out_printf("%s\n",
|
||||
upper(here->li_line));
|
||||
upper(here->li_line));
|
||||
else
|
||||
fprintf(file, "%s\n",
|
||||
upper(here->li_line));
|
||||
upper(here->li_line));
|
||||
}
|
||||
if (here->li_error && (type == LS_PHYSICAL)) {
|
||||
if (useout)
|
||||
out_printf("%s\n",
|
||||
here->li_error);
|
||||
here->li_error);
|
||||
else
|
||||
fprintf(file, "%s\n",
|
||||
here->li_error);
|
||||
here->li_error);
|
||||
}
|
||||
} else {
|
||||
for (there = here->li_actual; there;
|
||||
|
|
@ -191,13 +189,13 @@ top2: for (here = deck; here; here = here->li_next) {
|
|||
if (type == LS_PHYSICAL) {
|
||||
if (useout) {
|
||||
sprintf(out_pbuf, "%6d : %s\n",
|
||||
there->li_linenum,
|
||||
upper(there->li_line));
|
||||
out_send(out_pbuf);
|
||||
there->li_linenum,
|
||||
upper(there->li_line));
|
||||
out_send(out_pbuf);
|
||||
} else
|
||||
fprintf(file, "%6d : %s\n",
|
||||
there->li_linenum,
|
||||
upper(there->li_line));
|
||||
there->li_linenum,
|
||||
upper(there->li_line));
|
||||
} else {
|
||||
if (useout)
|
||||
out_printf("%s\n",
|
||||
|
|
@ -242,12 +240,11 @@ top2: for (here = deck; here; here = here->li_next) {
|
|||
return;
|
||||
}
|
||||
|
||||
/* The routine to source a spice input deck. We read the deck in, take out
|
||||
* the front-end commands, and create a CKT structure. Also we filter out
|
||||
* the following cards: .save, .width, .four, .print, and .plot, to perform
|
||||
* after the run is over.
|
||||
*/
|
||||
|
||||
/* The routine to source a spice input deck. We read the deck in, take
|
||||
* out the front-end commands, and create a CKT structure. Also we
|
||||
* filter out the following cards: .save, .width, .four, .print, and
|
||||
* .plot, to perform after the run is over. */
|
||||
void
|
||||
inp_spsource(FILE *fp, bool comfile, char *filename)
|
||||
{
|
||||
|
|
@ -263,7 +260,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
inp_readall(fp, &deck);
|
||||
|
||||
if (!deck) { /* MW. We must close fp always when returning */
|
||||
(void) fclose(fp);
|
||||
fclose(fp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -280,11 +277,10 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
}
|
||||
fclose(fp);
|
||||
|
||||
/* Now save the IO context and start a new control set. After
|
||||
* we are done with the source we'll put the old file descriptors
|
||||
* back. I guess we could use a FILE stack, but since this routine
|
||||
* is recursive anyway.
|
||||
*/
|
||||
/* Now save the IO context and start a new control set. After we
|
||||
* are done with the source we'll put the old file descriptors
|
||||
* back. I guess we could use a FILE stack, but since this
|
||||
* routine is recursive anyway. */
|
||||
lastin = cp_curin;
|
||||
lastout = cp_curout;
|
||||
lasterr = cp_curerr;
|
||||
|
|
@ -294,13 +290,11 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
|
||||
cp_pushcontrol();
|
||||
|
||||
/* We should now go through the deck and execute front-end
|
||||
/* We should now go through the deck and execute front-end
|
||||
* commands and remove them. Front-end commands are enclosed by
|
||||
* the cards .control and .endc, unless comfile
|
||||
* is TRUE, in which case every line must be a front-end command.
|
||||
* There are too many problems with matching the first word on
|
||||
* the line.
|
||||
*/
|
||||
* the cards .control and .endc, unless comfile is TRUE, in which
|
||||
* case every line must be a front-end command. There are too
|
||||
* many problems with matching the first word on the line. */
|
||||
ld = deck;
|
||||
if (comfile) {
|
||||
/* This is easy. */
|
||||
|
|
@ -311,9 +305,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
if (!ciprefix(".control", dd->li_line) &&
|
||||
!ciprefix(".endc", dd->li_line)) {
|
||||
if (dd->li_line[0] == '*')
|
||||
(void) cp_evloop(dd->li_line + 2);
|
||||
cp_evloop(dd->li_line + 2);
|
||||
else
|
||||
(void) cp_evloop(dd->li_line);
|
||||
cp_evloop(dd->li_line);
|
||||
}
|
||||
tfree(dd->li_line);
|
||||
tfree(dd);
|
||||
|
|
@ -326,7 +320,7 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
ld = dd;
|
||||
continue;
|
||||
}
|
||||
(void) strncpy(name, dd->li_line, BSIZE_SP);
|
||||
strncpy(name, dd->li_line, BSIZE_SP);
|
||||
for (s = name; *s && isspace(*s); s++)
|
||||
;
|
||||
for (t = s; *t && !isspace(*t); t++)
|
||||
|
|
@ -338,8 +332,8 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
tfree(dd->li_line);
|
||||
tfree(dd);
|
||||
if (commands)
|
||||
fprintf(cp_err,
|
||||
"Warning: redundant .control card\n");
|
||||
fprintf(cp_err,
|
||||
"Warning: redundant .control card\n");
|
||||
else
|
||||
commands = TRUE;
|
||||
} else if (ciprefix(".endc", dd->li_line)) {
|
||||
|
|
@ -366,18 +360,21 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
ld->li_next = dd->li_next;
|
||||
tfree(dd);
|
||||
} else if (!*dd->li_line) {
|
||||
/* So blank lines in com files don't get
|
||||
* considered as circuits.
|
||||
*/
|
||||
/* So blank lines in com files don't get considered as
|
||||
* circuits. */
|
||||
ld->li_next = dd->li_next;
|
||||
tfree(dd->li_line);
|
||||
tfree(dd);
|
||||
} else {
|
||||
inp_casefix(s);
|
||||
inp_casefix(dd->li_line);
|
||||
if (eq(s, ".width") || ciprefix(".four", s) || eq(s, ".plot")
|
||||
|| eq(s, ".print") || eq(s, ".save")
|
||||
|| eq(s, ".op") || eq(s, ".tf"))
|
||||
if (eq(s, ".width")
|
||||
|| ciprefix(".four", s)
|
||||
|| eq(s, ".plot")
|
||||
|| eq(s, ".print")
|
||||
|| eq(s, ".save")
|
||||
|| eq(s, ".op")
|
||||
|| eq(s, ".tf"))
|
||||
{
|
||||
if (end) {
|
||||
end->wl_next = alloc(struct wordlist);
|
||||
|
|
@ -401,33 +398,26 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
/* There is something left after the controls. */
|
||||
fprintf(cp_out, "\nCircuit: %s\n\n", tt);
|
||||
|
||||
/* Now expand subcircuit macros. Note that we have to
|
||||
* fix the case before we do this but after we
|
||||
* deal with the commands.
|
||||
*/
|
||||
if (!cp_getvar("nosubckt", VT_BOOL, (char *)
|
||||
&nosubckts))
|
||||
deck->li_next = inp_subcktexpand(deck->
|
||||
li_next);
|
||||
/* Now expand subcircuit macros. Note that we have to fix
|
||||
* the case before we do this but after we deal with the
|
||||
* commands. */
|
||||
if (!cp_getvar("nosubckt", VT_BOOL, (char *) &nosubckts))
|
||||
deck->li_next = inp_subcktexpand(deck->li_next);
|
||||
deck->li_actual = realdeck;
|
||||
inp_dodeck(deck, tt, wl_first, FALSE, options, filename);
|
||||
}
|
||||
|
||||
/* Now that the deck is loaded, do the commands */
|
||||
if (controls) {
|
||||
for (end = wl = wl_reverse(controls); wl;
|
||||
wl = wl->wl_next)
|
||||
(void) cp_evloop(wl->wl_word);
|
||||
|
||||
for (end = wl = wl_reverse(controls); wl; wl = wl->wl_next)
|
||||
cp_evloop(wl->wl_word);
|
||||
|
||||
wl_free(end);
|
||||
/* MW. Memory leak fixed here */
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Now reset everything. Pop the control stack, and fix up the IO
|
||||
* as it was before the source.
|
||||
*/
|
||||
* as it was before the source. */
|
||||
cp_popcontrol();
|
||||
|
||||
cp_curin = lastin;
|
||||
|
|
@ -436,14 +426,14 @@ inp_spsource(FILE *fp, bool comfile, char *filename)
|
|||
return;
|
||||
}
|
||||
|
||||
/* This routine is cut in half here because com_rset has to do what follows
|
||||
* also. End is the list of commands we execute when the job is finished:
|
||||
* we only bother with this if we might be running in batch mode, since
|
||||
* it isn't much use otherwise.
|
||||
*/
|
||||
|
||||
/* This routine is cut in half here because com_rset has to do what
|
||||
* follows also. End is the list of commands we execute when the job
|
||||
* is finished: we only bother with this if we might be running in
|
||||
* batch mode, since it isn't much use otherwise. */
|
||||
void
|
||||
inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *options, char *filename)
|
||||
inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse,
|
||||
struct line *options, char *filename)
|
||||
{
|
||||
struct circ *ct;
|
||||
struct line *dd;
|
||||
|
|
@ -454,8 +444,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *
|
|||
bool noparse, ii;
|
||||
|
||||
/* First throw away any old error messages there might be and fix
|
||||
* the case of the lines.
|
||||
*/
|
||||
* the case of the lines. */
|
||||
for (dd = deck; dd; dd = dd->li_next) {
|
||||
if (dd->li_error) {
|
||||
tfree(dd->li_error);
|
||||
|
|
@ -473,7 +462,7 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *
|
|||
}
|
||||
ft_curckt = ct = alloc(struct circ);
|
||||
}
|
||||
(void) cp_getvar("noparse", VT_BOOL, (char *) &noparse);
|
||||
cp_getvar("noparse", VT_BOOL, (char *) &noparse);
|
||||
if (!noparse)
|
||||
ckt = if_inpdeck(deck, &tab);
|
||||
else
|
||||
|
|
@ -501,19 +490,18 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *
|
|||
} while (p && *p);
|
||||
}
|
||||
|
||||
/* Add this circuit to the circuit list. If reuse is TRUE then
|
||||
* use the ft_curckt structure.
|
||||
*/
|
||||
|
||||
/* Add this circuit to the circuit list. If reuse is TRUE then use
|
||||
* the ft_curckt structure. */
|
||||
if (!reuse) {
|
||||
/* Be sure that ci_devices and ci_nodes are valid */
|
||||
ft_curckt->ci_devices = cp_kwswitch(CT_DEVNAMES,
|
||||
(char *) NULL);
|
||||
(void) cp_kwswitch(CT_DEVNAMES, ft_curckt->ci_devices);
|
||||
cp_kwswitch(CT_DEVNAMES, ft_curckt->ci_devices);
|
||||
ft_curckt->ci_nodes = cp_kwswitch(CT_NODENAMES, (char *) NULL);
|
||||
(void) cp_kwswitch(CT_NODENAMES, ft_curckt->ci_nodes);
|
||||
cp_kwswitch(CT_NODENAMES, ft_curckt->ci_nodes);
|
||||
ft_newcirc(ct);
|
||||
/* ft_setccirc(); */ ft_curckt = ct;
|
||||
/* Assign current circuit */
|
||||
ft_curckt = ct;
|
||||
}
|
||||
ct->ci_name = tt;
|
||||
ct->ci_deck = deck;
|
||||
|
|
@ -576,11 +564,10 @@ inp_dodeck(struct line *deck, char *tt, wordlist *end, bool reuse, struct line *
|
|||
return;
|
||||
}
|
||||
|
||||
/* Edit and re-load the current input deck. Note that if these commands are
|
||||
* used on a non-unix machine, they will leave spice.tmp junk files lying
|
||||
* around.
|
||||
*/
|
||||
|
||||
/* Edit and re-load the current input deck. Note that if these
|
||||
* commands are used on a non-unix machine, they will leave spice.tmp
|
||||
* junk files lying around. */
|
||||
void
|
||||
com_edit(wordlist *wl)
|
||||
{
|
||||
|
|
@ -620,8 +607,9 @@ com_edit(wordlist *wl)
|
|||
inp_list(fp, ft_curckt->ci_deck, ft_curckt->ci_options,
|
||||
LS_DECK);
|
||||
fprintf(cp_err,
|
||||
"Warning: editing a temporary file -- circuit not saved\n");
|
||||
(void) fclose(fp);
|
||||
"Warning: editing a temporary file -- "
|
||||
"circuit not saved\n");
|
||||
fclose(fp);
|
||||
} else if (!ft_curckt) {
|
||||
if (!(fp = fopen(filename, "w"))) {
|
||||
perror(filename);
|
||||
|
|
@ -629,7 +617,7 @@ com_edit(wordlist *wl)
|
|||
return;
|
||||
}
|
||||
fprintf(fp, "SPICE 3 test deck\n");
|
||||
(void) fclose(fp);
|
||||
fclose(fp);
|
||||
}
|
||||
if (!doedit(filename)) {
|
||||
cp_interactive = inter;
|
||||
|
|
@ -643,11 +631,11 @@ com_edit(wordlist *wl)
|
|||
}
|
||||
inp_spsource(fp, FALSE, permfile ? filename : (char *) NULL);
|
||||
|
||||
/* (void) fclose(fp); */
|
||||
/* fclose(fp); */
|
||||
/* MW. inp_spsource already closed fp */
|
||||
|
||||
if (ft_curckt && !ft_curckt->ci_filename)
|
||||
(void) unlink(filename);
|
||||
unlink(filename);
|
||||
}
|
||||
|
||||
cp_interactive = inter;
|
||||
|
|
@ -656,7 +644,7 @@ com_edit(wordlist *wl)
|
|||
|
||||
fprintf(cp_out, "run circuit? ");
|
||||
fflush(cp_out);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
fgets(buf, BSIZE_SP, stdin);
|
||||
if (buf[0] != 'n') {
|
||||
fprintf(cp_out, "running circuit\n");
|
||||
com_run(NULL);
|
||||
|
|
@ -677,10 +665,10 @@ doedit(char *filename)
|
|||
if (Def_Editor && *Def_Editor)
|
||||
editor = Def_Editor;
|
||||
else
|
||||
editor = "/usr/ucb/vi";
|
||||
editor = "/usr/bin/vi";
|
||||
}
|
||||
}
|
||||
(void) sprintf(buf, "%s %s", editor, filename);
|
||||
sprintf(buf, "%s %s", editor, filename);
|
||||
return (system(buf) ? FALSE : TRUE);
|
||||
|
||||
}
|
||||
|
|
@ -710,17 +698,17 @@ com_source(wordlist *wl)
|
|||
while (wl) {
|
||||
if (!(tp = inp_pathopen(wl->wl_word, "r"))) {
|
||||
perror(wl->wl_word);
|
||||
(void) fclose(fp);
|
||||
fclose(fp);
|
||||
cp_interactive = TRUE;
|
||||
(void) unlink(tempfile);
|
||||
unlink(tempfile);
|
||||
return;
|
||||
}
|
||||
while ((i = fread(buf, 1, BSIZE_SP, tp)) > 0)
|
||||
(void) fwrite(buf, 1, i, fp);
|
||||
(void) fclose(tp);
|
||||
fwrite(buf, 1, i, fp);
|
||||
fclose(tp);
|
||||
wl = wl->wl_next;
|
||||
}
|
||||
(void) fseek(fp, (long) 0, 0);
|
||||
fseek(fp, (long) 0, 0);
|
||||
} else
|
||||
fp = inp_pathopen(wl->wl_word, "r");
|
||||
if (fp == NULL) {
|
||||
|
|
@ -737,7 +725,7 @@ com_source(wordlist *wl)
|
|||
inp_spsource(fp, FALSE, tempfile ? (char *) NULL : wl->wl_word);
|
||||
cp_interactive = inter;
|
||||
if (tempfile)
|
||||
(void) unlink(tempfile);
|
||||
unlink(tempfile);
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -242,8 +242,9 @@ inp_readall(FILE *fp, struct line **data)
|
|||
return;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
inp_casefix(register char *string)
|
||||
inp_casefix(char *string)
|
||||
{
|
||||
#ifdef HAVE_CTYPE_H
|
||||
if (string)
|
||||
|
|
@ -254,8 +255,10 @@ inp_casefix(register char *string)
|
|||
#endif
|
||||
if (*string == '"') {
|
||||
*string++ = ' ';
|
||||
while (*string && *string != '"') string++;
|
||||
if (*string == '"') *string = ' ';
|
||||
while (*string && *string != '"')
|
||||
string++;
|
||||
if (*string == '"')
|
||||
*string = ' ';
|
||||
}
|
||||
if (!isspace(*string) && !isprint(*string))
|
||||
*string = '_';
|
||||
|
|
|
|||
|
|
@ -64,9 +64,7 @@ extern void dbfree( );
|
|||
extern struct circ *ft_curckt;
|
||||
extern struct circ *ft_circuits;
|
||||
extern struct subcirc *ft_subcircuits;
|
||||
extern void ft_setccirc();
|
||||
extern void ft_newcirc();
|
||||
extern void ft_newsubcirc();
|
||||
|
||||
/* clip.c */
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
302
src/sconvert.c
302
src/sconvert.c
|
|
@ -32,127 +32,6 @@ char *cp_program = "sconvert";
|
|||
/* doesn't get used, but some unused routine in some file references it */
|
||||
char out_pbuf[BSIZE_SP];
|
||||
|
||||
static void oldwrite();
|
||||
static struct plot *oldread();
|
||||
static char *fixdate();
|
||||
|
||||
int
|
||||
main(ac, av)
|
||||
char **av;
|
||||
{
|
||||
char *sf, *af;
|
||||
char buf[BSIZE_SP];
|
||||
char t, f;
|
||||
struct plot *pl;
|
||||
int i;
|
||||
char *infile;
|
||||
char *outfile;
|
||||
FILE *fp;
|
||||
cp_in = stdin;
|
||||
cp_out = stdout;
|
||||
cp_err = stderr;
|
||||
cp_curin = stdin;
|
||||
cp_curout = stdout;
|
||||
cp_curerr = stderr;
|
||||
|
||||
switch (ac) {
|
||||
case 5:
|
||||
sf = av[2];
|
||||
af = av[4];
|
||||
f = *av[1];
|
||||
t = *av[3];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
f = *av[1];
|
||||
t = *av[2];
|
||||
/* This is a pain, but there is no choice */
|
||||
sf = infile = smktemp("scin");
|
||||
af = outfile = smktemp("scout");
|
||||
if (!(fp = fopen(infile, "w"))) {
|
||||
perror(infile);
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
while ((i = fread(buf, 1, sizeof(buf), stdin)))
|
||||
(void) fwrite(buf, 1, i, fp);
|
||||
(void) fclose(fp);
|
||||
break;
|
||||
|
||||
case 1: printf("Input file: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
sf = copy(buf);
|
||||
printf("Input type: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
f = buf[0];
|
||||
printf("Output file: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
af = copy(buf);
|
||||
printf("Output type: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
t = buf[0];
|
||||
break;
|
||||
default:
|
||||
fprintf(cp_err,
|
||||
"Usage: %s fromtype fromfile totype tofile,\n",
|
||||
cp_program);
|
||||
fprintf(cp_err, "\twhere types are o, b, or a\n");
|
||||
fprintf(cp_err,
|
||||
"\tor, %s fromtype totype, used as a filter.\n",
|
||||
cp_program);
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
switch(f) {
|
||||
case 'o' :
|
||||
pl = oldread(sf);
|
||||
break;
|
||||
|
||||
case 'b' :
|
||||
case 'a' :
|
||||
pl = raw_read(sf);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(cp_err, "Types are o, a, or b\n");
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
if (!pl)
|
||||
exit(EXIT_BAD);
|
||||
|
||||
switch(t) {
|
||||
case 'o' :
|
||||
oldwrite(af, FALSE, pl);
|
||||
break;
|
||||
|
||||
case 'b' :
|
||||
raw_write(af, pl, FALSE, TRUE);
|
||||
break;
|
||||
|
||||
case 'a' :
|
||||
raw_write(af, pl, FALSE, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(cp_err, "Types are o, a, or b\n");
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
if (ac == 3) {
|
||||
/* Gotta finish this stuff up */
|
||||
if (!(fp = fopen(outfile, "r"))) {
|
||||
perror(outfile);
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
while ((i = fread(buf, 1, sizeof(buf), fp)))
|
||||
(void) fwrite(buf, 1, i, stdout);
|
||||
(void) fclose(fp);
|
||||
(void) unlink(infile);
|
||||
(void) unlink(outfile);
|
||||
}
|
||||
exit(EXIT_NORMAL);
|
||||
}
|
||||
|
||||
#define tfread(ptr, siz, nit, fp) if (fread((char *) (ptr), (siz), \
|
||||
(nit), (fp)) != (nit)) { \
|
||||
|
|
@ -164,9 +43,23 @@ main(ac, av)
|
|||
fprintf(cp_err, "Write error\n"); \
|
||||
return; }
|
||||
|
||||
static char *
|
||||
fixdate(char *date)
|
||||
{
|
||||
char buf[20];
|
||||
int i;
|
||||
|
||||
(void) strcpy(buf, date);
|
||||
for (i = 17; i > 8; i--)
|
||||
buf[i] = buf[i - 1];
|
||||
buf[8] = ' ';
|
||||
buf[18] = '\0';
|
||||
return (copy(buf));
|
||||
}
|
||||
|
||||
|
||||
static struct plot *
|
||||
oldread(name)
|
||||
char *name;
|
||||
oldread(char *name)
|
||||
{
|
||||
struct plot *pl;
|
||||
char buf[BSIZE_SP];
|
||||
|
|
@ -288,11 +181,9 @@ oldread(name)
|
|||
return (pl);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
oldwrite(name, app, pl)
|
||||
char *name;
|
||||
bool app;
|
||||
struct plot *pl;
|
||||
oldwrite(char *name, bool app, struct plot *pl)
|
||||
{
|
||||
short four = 4, k;
|
||||
struct dvec *v;
|
||||
|
|
@ -404,37 +295,140 @@ oldwrite(name, app, pl)
|
|||
return;
|
||||
}
|
||||
|
||||
static char *
|
||||
fixdate(date)
|
||||
char *date;
|
||||
{
|
||||
char buf[20];
|
||||
int i;
|
||||
|
||||
(void) strcpy(buf, date);
|
||||
for (i = 17; i > 8; i--)
|
||||
buf[i] = buf[i - 1];
|
||||
buf[8] = ' ';
|
||||
buf[18] = '\0';
|
||||
return (copy(buf));
|
||||
int
|
||||
main(int ac, char **av)
|
||||
{
|
||||
char *sf, *af;
|
||||
char buf[BSIZE_SP];
|
||||
char t, f;
|
||||
struct plot *pl;
|
||||
int i;
|
||||
char *infile = NULL;
|
||||
char *outfile = NULL;
|
||||
FILE *fp;
|
||||
cp_in = stdin;
|
||||
cp_out = stdout;
|
||||
cp_err = stderr;
|
||||
cp_curin = stdin;
|
||||
cp_curout = stdout;
|
||||
cp_curerr = stderr;
|
||||
|
||||
switch (ac) {
|
||||
case 5:
|
||||
sf = av[2];
|
||||
af = av[4];
|
||||
f = *av[1];
|
||||
t = *av[3];
|
||||
break;
|
||||
|
||||
case 3:
|
||||
f = *av[1];
|
||||
t = *av[2];
|
||||
/* This is a pain, but there is no choice */
|
||||
sf = infile = smktemp("scin");
|
||||
af = outfile = smktemp("scout");
|
||||
if (!(fp = fopen(infile, "w"))) {
|
||||
perror(infile);
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
while ((i = fread(buf, 1, sizeof(buf), stdin)))
|
||||
(void) fwrite(buf, 1, i, fp);
|
||||
(void) fclose(fp);
|
||||
break;
|
||||
|
||||
case 1: printf("Input file: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
sf = copy(buf);
|
||||
printf("Input type: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
f = buf[0];
|
||||
printf("Output file: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
af = copy(buf);
|
||||
printf("Output type: ");
|
||||
(void) fflush(stdout);
|
||||
(void) fgets(buf, BSIZE_SP, stdin);
|
||||
t = buf[0];
|
||||
break;
|
||||
default:
|
||||
fprintf(cp_err,
|
||||
"Usage: %s fromtype fromfile totype tofile,\n",
|
||||
cp_program);
|
||||
fprintf(cp_err, "\twhere types are o, b, or a\n");
|
||||
fprintf(cp_err,
|
||||
"\tor, %s fromtype totype, used as a filter.\n",
|
||||
cp_program);
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
switch(f) {
|
||||
case 'o' :
|
||||
pl = oldread(sf);
|
||||
break;
|
||||
|
||||
case 'b' :
|
||||
case 'a' :
|
||||
pl = raw_read(sf);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(cp_err, "Types are o, a, or b\n");
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
if (!pl)
|
||||
exit(EXIT_BAD);
|
||||
|
||||
switch(t) {
|
||||
case 'o' :
|
||||
oldwrite(af, FALSE, pl);
|
||||
break;
|
||||
|
||||
case 'b' :
|
||||
raw_write(af, pl, FALSE, TRUE);
|
||||
break;
|
||||
|
||||
case 'a' :
|
||||
raw_write(af, pl, FALSE, FALSE);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(cp_err, "Types are o, a, or b\n");
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
if (ac == 3) {
|
||||
/* Gotta finish this stuff up */
|
||||
if (!(fp = fopen(outfile, "r"))) {
|
||||
perror(outfile);
|
||||
exit(EXIT_BAD);
|
||||
}
|
||||
while ((i = fread(buf, 1, sizeof(buf), fp)))
|
||||
(void) fwrite(buf, 1, i, stdout);
|
||||
(void) fclose(fp);
|
||||
(void) unlink(infile);
|
||||
(void) unlink(outfile);
|
||||
}
|
||||
exit(EXIT_NORMAL);
|
||||
}
|
||||
|
||||
void cp_pushcontrol() { }
|
||||
void cp_popcontrol() { }
|
||||
void out_init() { }
|
||||
void cp_doquit() { exit(0); }
|
||||
/* ARGSUSED */ void cp_usrvars(v1, v2) struct variable **v1, **v2; { return; }
|
||||
/* ARGSUSED */ int cp_evloop(s) char *s; { return (0); }
|
||||
/* ARGSUSED */ void cp_ccon(o) bool o; { }
|
||||
/* ARGSUSED */ char *if_errstring(c) int c; { return ("error"); }
|
||||
void cp_pushcontrol(void) { }
|
||||
void cp_popcontrol(void) { }
|
||||
void out_init(void) { }
|
||||
void cp_doquit(void) { exit(0); }
|
||||
void cp_usrvars(struct variable **v1, struct variable **v2) { return; }
|
||||
int cp_evloop(char *s) { return (0); }
|
||||
void cp_ccon(bool o) { }
|
||||
char *if_errstring(int c) { return ("error"); }
|
||||
#ifndef out_printf
|
||||
/* VARARGS1 ARGSUSED */ void out_printf(fmt, args) char *fmt; { }
|
||||
void out_printf(char *fmt, int args) { }
|
||||
#endif
|
||||
/* ARGSUSED */ void out_send(string) char *string; {}
|
||||
/* ARGSUSED */ struct variable * cp_enqvar(word) char *word; { return (NULL); }
|
||||
/* ARGSUSED */ struct dvec *vec_get(word) char *word; { return (NULL); }
|
||||
/* ARGSUSED */ void cp_ccom(w, b, e) wordlist *w; char *b; bool e; { return; }
|
||||
/* ARGSUSED */ int cp_usrset(v, i) struct variable *v; bool i;{return(US_OK); }
|
||||
void out_send(char *string) {}
|
||||
struct variable * cp_enqvar(char *word) { return (NULL); }
|
||||
struct dvec *vec_get(char *word) { return (NULL); }
|
||||
void cp_ccom(wordlist *w, char *b, bool e) { return; }
|
||||
int cp_usrset(struct variable *v, bool i) { return(US_OK); }
|
||||
|
||||
int disptype;
|
||||
void XtDispatchEvent(pev) char *pev; {}
|
||||
void XtDispatchEvent(char *pev) { }
|
||||
|
|
|
|||
Loading…
Reference in New Issue