From 67ff1b3a832bae3b212384602580105fe73d03c4 Mon Sep 17 00:00:00 2001 From: sjborley Date: Mon, 30 May 2005 20:28:29 +0000 Subject: [PATCH] Tidy up of the header files in src/frontend and sub-directories. Motivation is to remove extern declarations within .c files and place them in .h files. Added new header files where necessary (and adjusted makefile.am files where required) --- src/frontend/Makefile.am | 8 + src/frontend/aspice.c | 10 +- src/frontend/breakp.c | 8 +- src/frontend/breakp2.c | 5 +- src/frontend/com_chdir.c | 11 +- src/frontend/com_chdir.h | 13 + src/frontend/com_echo.c | 6 + src/frontend/com_echo.h | 13 + src/frontend/com_rehash.c | 11 +- src/frontend/com_rehash.h | 13 + src/frontend/com_shell.c | 7 +- src/frontend/com_shell.h | 11 + src/frontend/com_shift.c | 6 + src/frontend/com_shift.h | 11 + src/frontend/com_unset.c | 8 +- src/frontend/com_unset.h | 13 + src/frontend/commands.c | 10 +- src/frontend/control.h | 13 +- src/frontend/display.c | 86 +-- src/frontend/dotcards.c | 6 +- src/frontend/hpgl.c | 7 +- src/frontend/hpgl.h | 21 + src/frontend/inp.c | 8 +- src/frontend/linear.c | 7 +- src/frontend/mw_coms.c | 7 +- src/frontend/nutinp.c | 5 +- src/frontend/options.c | 2 + src/frontend/outitf.c | 11 +- src/frontend/parser/backq.c | 2 +- src/frontend/parser/backq.h | 4 +- src/frontend/parser/cshpar.c | 6 +- src/frontend/parser/cshpar.h | 10 +- src/frontend/parser/input.c | 4 +- src/frontend/plotting/graf.h | 9 +- src/frontend/plotting/graphdb.c | 5 +- src/frontend/plotting/grid.c | 14 +- src/frontend/plotting/plot5.c | 30 +- src/frontend/plotting/plot5.h | 17 +- src/frontend/plotting/x11.c | 1153 ++++++++++++++++--------------- src/frontend/plotting/x11.h | 28 +- src/frontend/postsc.c | 102 +-- src/frontend/postsc.h | 14 +- src/frontend/runcoms.c | 2 - src/frontend/runcoms2.c | 14 +- src/frontend/spec.c | 2 +- src/frontend/spiceif.c | 2 +- src/frontend/spiceif.h | 8 +- src/frontend/streams.c | 8 +- src/frontend/streams.h | 25 +- src/frontend/subckt.c | 12 +- src/frontend/wdisp/Makefile.am | 5 + src/frontend/wdisp/windisp.h | 23 + src/frontend/wdisp/winprint.h | 23 + 53 files changed, 1011 insertions(+), 848 deletions(-) create mode 100644 src/frontend/com_chdir.h create mode 100644 src/frontend/com_echo.h create mode 100644 src/frontend/com_rehash.h create mode 100644 src/frontend/com_shell.h create mode 100644 src/frontend/com_shift.h create mode 100644 src/frontend/com_unset.h create mode 100644 src/frontend/hpgl.h create mode 100644 src/frontend/wdisp/windisp.h create mode 100644 src/frontend/wdisp/winprint.h diff --git a/src/frontend/Makefile.am b/src/frontend/Makefile.am index 235a865b1..7e4bd9239 100644 --- a/src/frontend/Makefile.am +++ b/src/frontend/Makefile.am @@ -1,4 +1,5 @@ ## Process this file with automake to produce Makefile.in +## $Id$ SUBDIRS = plotting help parser wdisp @NUMPARAMDIR@ DIST_SUBDIRS = plotting help parser wdisp numparam @@ -17,6 +18,7 @@ libfte_a_SOURCES = \ com_cdump.c \ com_cdump.h \ com_chdir.c \ + com_chdir.h \ com_compose.c \ com_compose.h \ com_dl.c \ @@ -26,6 +28,7 @@ libfte_a_SOURCES = \ com_dump.c \ com_dump.h \ com_echo.c \ + com_echo.h \ com_ghelp.c \ com_ghelp.h \ com_hardcopy.c \ @@ -41,17 +44,21 @@ libfte_a_SOURCES = \ com_plot.c \ com_plot.h \ com_rehash.c \ + com_rehash.h \ com_set.c \ com_set.h \ com_setscale.c \ com_setscale.h \ com_shell.c \ + com_shell.h \ com_shift.c \ + com_shift.h \ com_state.c \ com_state.h \ com_strcmp.c \ com_strcmp.h \ com_unset.c \ + com_unset.h \ com_xgraph.c \ com_xgraph.h \ completion.h \ @@ -104,6 +111,7 @@ libfte_a_SOURCES = \ gens.c \ gens.h \ hpgl.c \ + hpgl.h \ inp.c \ inp.h \ inpcom.c \ diff --git a/src/frontend/aspice.c b/src/frontend/aspice.c index 1a8083321..cbe30ca26 100644 --- a/src/frontend/aspice.c +++ b/src/frontend/aspice.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -55,15 +56,6 @@ struct proc { static struct proc *running = NULL; static int numchanged = 0; /* How many children have changed in state. */ - -extern pid_t fork (void); -extern int dup2 (int, int); -extern int execl (const char *, const char *, ...); -extern int unlink (const char *); -extern int pipe (int *); -extern int close (int); -extern int execlp (const char *, const char *, ...); - void com_aspice(wordlist *wl) { diff --git a/src/frontend/breakp.c b/src/frontend/breakp.c index 5b5e702b1..4dd1e1ee0 100644 --- a/src/frontend/breakp.c +++ b/src/frontend/breakp.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -13,15 +14,13 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "dvec.h" #include "ftedebug.h" #include "breakp.h" +#include "breakp2.h" #include "completion.h" static bool satisfied(struct dbcomm *d, struct plot *plot); static void printcond(struct dbcomm *d, FILE *fp); -void dbfree(struct dbcomm *db); -extern struct dbcomm *dbs; /* export for iplot */ -extern int debugnumber; static int howmanysteps = 0; static int steps = 0; @@ -32,9 +31,6 @@ static int steps = 0; * If more than one is given on a command line, then this is a conjunction. */ - -extern void settrace (wordlist *wl, int what, char *name); - void com_stop(wordlist *wl) { diff --git a/src/frontend/breakp2.c b/src/frontend/breakp2.c index c714002c6..105d3e581 100644 --- a/src/frontend/breakp2.c +++ b/src/frontend/breakp2.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -12,14 +13,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "ftedefs.h" #include "dvec.h" #include "ftedebug.h" - #include "quote.h" #include "breakp2.h" - struct dbcomm *dbs = NULL; /* export for iplot */ int debugnumber = 1; -void settrace(wordlist *wl, int what, char *name); /* Set a breakpoint. Possible commands are: * stop after n @@ -126,4 +124,3 @@ ft_getSaves(struct save_info **savesp) return (count); } - diff --git a/src/frontend/com_chdir.c b/src/frontend/com_chdir.c index 18e61bcee..7057ad0f1 100644 --- a/src/frontend/com_chdir.c +++ b/src/frontend/com_chdir.c @@ -1,8 +1,18 @@ +/************* +* com_chdir.c +* $Id$ +************/ + #include #include #include +#ifdef HAVE_PWD_H +#include +#endif + +#include "com_chdir.h" #include "quote.h" #include "streams.h" @@ -12,7 +22,6 @@ com_chdir(wordlist *wl) { char *s; struct passwd *pw; - extern struct passwd *getpwuid(uid_t); char localbuf[257]; int copied = 0; diff --git a/src/frontend/com_chdir.h b/src/frontend/com_chdir.h new file mode 100644 index 000000000..00b1bf787 --- /dev/null +++ b/src/frontend/com_chdir.h @@ -0,0 +1,13 @@ +/************* +* Header file for com_chdir.c +* $Id$ +************/ + +#ifndef COM_CHDIR_H +#define COM_CHDIR_H + +#include + +void com_chdir(wordlist *wl); + +#endif /* COM_CHDIR_H */ diff --git a/src/frontend/com_echo.c b/src/frontend/com_echo.c index 6c980b4b3..91d1583ae 100644 --- a/src/frontend/com_echo.c +++ b/src/frontend/com_echo.c @@ -1,8 +1,14 @@ +/************* +* com_echo.c +* $Id$ +************/ + #include #include #include #include +#include "com_echo.h" #include "quote.h" #include "streams.h" diff --git a/src/frontend/com_echo.h b/src/frontend/com_echo.h new file mode 100644 index 000000000..5bf5cd513 --- /dev/null +++ b/src/frontend/com_echo.h @@ -0,0 +1,13 @@ +/************* +* Header file for com_echo.c +* $Id$ +************/ + +#ifndef COM_ECHO_H +#define COM_ECHO_H + +#include + +void com_echo(wordlist *wlist); + +#endif /* COM_ECHO_H */ diff --git a/src/frontend/com_rehash.c b/src/frontend/com_rehash.c index 589372b04..69262111d 100644 --- a/src/frontend/com_rehash.c +++ b/src/frontend/com_rehash.c @@ -1,9 +1,15 @@ +/************* +* com_rehash.c +* $Id$ +************/ + #include #include #include -#include - +#include "com_rehash.h" +#include "streams.h" +#include "control.h" void com_rehash(wordlist *wl) @@ -21,4 +27,3 @@ com_rehash(wordlist *wl) fprintf(cp_err, "Error: no PATH in environment.\n"); return; } - diff --git a/src/frontend/com_rehash.h b/src/frontend/com_rehash.h new file mode 100644 index 000000000..4e8404d4b --- /dev/null +++ b/src/frontend/com_rehash.h @@ -0,0 +1,13 @@ +/************* +* Header file for com_rehsh.c +* $Id$ +************/ + +#ifndef COM_REHASH_H +#define COM_REHASH_H + +#include + +void com_rehash(wordlist *wl); + +#endif /* COM_REHASH_H */ diff --git a/src/frontend/com_shell.c b/src/frontend/com_shell.c index 145e6c6e5..0763da687 100644 --- a/src/frontend/com_shell.c +++ b/src/frontend/com_shell.c @@ -1,8 +1,13 @@ +/************* +* com_shell.c +* $Id$ +************/ + #include #include #include -#include +#include "com_shell.h" /* Fork a shell. */ diff --git a/src/frontend/com_shell.h b/src/frontend/com_shell.h new file mode 100644 index 000000000..92eeb602c --- /dev/null +++ b/src/frontend/com_shell.h @@ -0,0 +1,11 @@ +/************* +* Header file for com_shell.c +* $Id$ +************/ + +#ifndef COM_SHELL_H +#define COM_SHELL_H + +void com_shell(wordlist *wl); + +#endif /* COM_SHELL_H */ diff --git a/src/frontend/com_shift.c b/src/frontend/com_shift.c index a53a816e1..42e93bb36 100644 --- a/src/frontend/com_shift.c +++ b/src/frontend/com_shift.c @@ -1,8 +1,14 @@ +/************* +* com_shift.c +* $Id$ +************/ + #include #include #include #include +#include "com_shift.h" #include "variable.h" #include "streams.h" diff --git a/src/frontend/com_shift.h b/src/frontend/com_shift.h new file mode 100644 index 000000000..c0c53e967 --- /dev/null +++ b/src/frontend/com_shift.h @@ -0,0 +1,11 @@ +/************* +* Header file for com_shift.c +* $Id$ +************/ + +#ifndef COM_SHIFT_H +#define COM_SHIFT_H + +void com_shift(wordlist *wl); + +#endif /* COM_SHIFT_H */ diff --git a/src/frontend/com_unset.c b/src/frontend/com_unset.c index 3f3d8d5a1..7b4d7660e 100644 --- a/src/frontend/com_unset.c +++ b/src/frontend/com_unset.c @@ -1,13 +1,17 @@ +/************* +* com_unset.c +* $Id$ +************/ + #include #include #include #include -#include +#include "com_unset.h" #include "variable.h" - void com_unset(wordlist *wl) { diff --git a/src/frontend/com_unset.h b/src/frontend/com_unset.h new file mode 100644 index 000000000..c4adf797e --- /dev/null +++ b/src/frontend/com_unset.h @@ -0,0 +1,13 @@ +/************* +* Header file for com_unset.c +* $Id$ +************/ + +#ifndef COM_UNSET_H +#define COM_UNSET_H + +#include + +void com_unset(wordlist *wl); + +#endif /* COM_UNSET_H */ diff --git a/src/frontend/commands.c b/src/frontend/commands.c index 104c0daff..5f0f9edd1 100644 --- a/src/frontend/commands.c +++ b/src/frontend/commands.c @@ -1,4 +1,5 @@ /* NG-SPICE -- An electrical circuit simulator + * $Id$ * * Copyright (c) 1990 University of California * Copyright (c) 2000 Arno W. Peters @@ -48,12 +49,17 @@ #include "com_setscale.h" #include "com_xgraph.h" #include "com_state.h" +#include "com_chdir.h" +#include "com_echo.h" +#include "com_rehash.h" +#include "com_shell.h" +#include "com_shift.h" +#include "com_unset.h" #include "fourier.h" #ifdef EXPERIMENTAL_CODE #include "com_option.h" -void com_loadsnap(wordlist *wl); -void com_savesnap(wordlist *wl); +#include "spiceif.h" /* for com_loadsnap() and com_savesnap() */ #endif #include "com_dl.h" diff --git a/src/frontend/control.h b/src/frontend/control.h index d0c0d0ce5..1b6c99317 100644 --- a/src/frontend/control.h +++ b/src/frontend/control.h @@ -1,6 +1,12 @@ -#ifndef _CONTROL_H -#define _CONTROL_H +/********** + * Header file for control.c + * $Id$ +**********/ +#ifndef CONTROL_H +#define CONTROL_H + +#include /* Stuff to do control structures. We keep a history (seperate from * the cshpar history, for now at least) of commands and their event @@ -42,5 +48,6 @@ enum co_command { extern struct control *control[CONTROLSTACKSIZE]; extern struct control *cend[CONTROLSTACKSIZE]; extern int stackp; +extern bool cp_dounixcom; -#endif +#endif /* CONTROL_H */ diff --git a/src/frontend/display.c b/src/frontend/display.c index 1c032864e..5e01aa619 100644 --- a/src/frontend/display.c +++ b/src/frontend/display.c @@ -1,5 +1,6 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. +$Id$ **********/ @@ -12,6 +13,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. #include "display.h" #include "variable.h" +#include "error.h" /* static declarations */ static void gen_DatatoScreen(GRAPH *graph, double x, double y, int *screenx, int *screeny); @@ -19,47 +21,20 @@ static int gen_Input(REQUEST *request, RESPONSE *response); static int nop(void); static int nodev(void); - - - #ifndef X_DISPLAY_MISSING -extern int X11_Init(void), X11_NewViewport(GRAPH *graph), X11_Close(void), X11_Clear(void), - X11_DrawLine(int x1, int y1, int x2, int y2), X11_Arc(int x0, int y0, int radius, double theta1, double theta2), X11_Text(char *text, int x, int y), X11_DefineColor(int colorid, double red, double green, double blue), - X11_DefineLinestyle(int linestyleid, int mask), X11_SetLinestyle(int linestyleid), X11_SetColor(int colorid), - X11_Update(void), - X11_Input(REQUEST *request, RESPONSE *response); +#include "plotting/x11.h" #endif - #ifdef HAS_WINDOWS /* Graphic-IO under MS Windows */ -extern int WIN_Init(), WIN_NewViewport(), WIN_Close(), WIN_Clear(), - WIN_DrawLine(), WIN_Arc(), WIN_Text(), WIN_DefineColor(), - WIN_DefineLinestyle(), WIN_SetLinestyle(), WIN_SetColor(), - WIN_Update(), WIN_DiagramReady(); - -extern int WPRINT_Init(), WPRINT_NewViewport(), WPRINT_Close(), WPRINT_Clear(), - WPRINT_DrawLine(), WPRINT_Arc(), WPRINT_Text(), WPRINT_DefineColor(), - WPRINT_DefineLinestyle(), WPRINT_SetLinestyle(), WPRINT_SetColor(), - WPRINT_Update(), WPRINT_DiagramReady(); +#include "windisp/windisp.h" +#include "windisp/winprint.h" #endif +#include "plotting/plot5.h" +#include "postsc.h" +#include "hpgl.h" -extern int Plt5_Init(void), Plt5_NewViewport(GRAPH *graph), Plt5_Close(void), Plt5_Clear(void), - Plt5_DrawLine(int x1, int y1, int x2, int y2), Plt5_Arc(int x0, int y0, int radius, double theta1, double theta2), Plt5_Text(char *text, int x, int y), - Plt5_DefineLinestyle(), Plt5_SetLinestyle(int linestyleid), Plt5_SetColor(int colorid), - Plt5_Update(void); - -extern int PS_Init(void), PS_NewViewport(GRAPH *graph), PS_Close(void), PS_Clear(void), - PS_DrawLine(int x1, int y1, int x2, int y2), PS_Arc(int x0, int y0, int r, double theta1, double theta2), PS_Text(char *text, int x, int y), - PS_DefineLinestyle(), PS_SetLinestyle(int linestyleid), PS_SetColor(int colorid), - PS_Update(void); - -extern int GL_Init(void), GL_NewViewport(GRAPH *graph), GL_Close(void), GL_Clear(void), - GL_DrawLine(int x1, int y1, int x2, int y2), GL_Arc(int x0, int y0, int r, double theta1, double theta2), GL_Text(char *text, int x, int y), - GL_DefineLinestyle(), GL_SetLinestyle(int linestyleid), GL_SetColor(int colorid), - GL_Update(void); - DISPDEVICE device[] = { {"error", 0, 0, 0, 0, 0, 0, nop, nop, @@ -67,7 +42,7 @@ DISPDEVICE device[] = { nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, nop, gen_Input, - (void *)nop,}, + (void*)nop,}, #ifndef X_DISPLAY_MISSING {"X11", 0, 0, 1024, 864, 0, 0, X11_Init, X11_NewViewport, @@ -79,43 +54,41 @@ DISPDEVICE device[] = { #endif #ifdef HAS_WINDOWS /* Graphic-IO under MS Windows */ - {"Windows", 0, 0, 1000, 1000, 0, 0, WIN_Init, WIN_NewViewport, - WIN_Close, WIN_Clear, - WIN_DrawLine, WIN_Arc, WIN_Text, WIN_DefineColor, WIN_DefineLinestyle, - WIN_SetLinestyle, WIN_SetColor, WIN_Update, - nodev, nodev, nodev, gen_Input, - gen_DatatoScreen, WIN_DiagramReady}, - - /* Warning: name "WinPrint" do not change! */ - {"WinPrint", 0, 0, 1000, 1000, 0, 0, WPRINT_Init, WPRINT_NewViewport, - WPRINT_Close, WPRINT_Clear, - WPRINT_DrawLine, WPRINT_Arc, WPRINT_Text, WPRINT_DefineColor, WPRINT_DefineLinestyle, - WPRINT_SetLinestyle, WPRINT_SetColor, WPRINT_Update, - nodev, nodev, nodev, nodev, - gen_DatatoScreen, WPRINT_DiagramReady}, + {"Windows", 0, 0, 1000, 1000, 0, 0, WIN_Init, WIN_NewViewport, + WIN_Close, WIN_Clear, + WIN_DrawLine, WIN_Arc, WIN_Text, WIN_DefineColor, WIN_DefineLinestyle, + WIN_SetLinestyle, WIN_SetColor, WIN_Update, + nodev, nodev, nodev, gen_Input, + gen_DatatoScreen, WIN_DiagramReady}, + /* Warning: name "WinPrint" do not change! */ + {"WinPrint", 0, 0, 1000, 1000, 0, 0, WPRINT_Init, WPRINT_NewViewport, + WPRINT_Close, WPRINT_Clear, + WPRINT_DrawLine, WPRINT_Arc, WPRINT_Text, WPRINT_DefineColor, WPRINT_DefineLinestyle, + WPRINT_SetLinestyle, WPRINT_SetColor, WPRINT_Update, + nodev, nodev, nodev, nodev, + gen_DatatoScreen, WPRINT_DiagramReady}, #endif - {"plot5", 0, 0, 1000, 1000, 0, 0, Plt5_Init, Plt5_NewViewport, Plt5_Close, Plt5_Clear, - Plt5_DrawLine, Plt5_Arc, Plt5_Text, nodev, nodev, + Plt5_DrawLine, Plt5_Arc, Plt5_Text, (void*)nodev, (void*)nodev, Plt5_SetLinestyle, Plt5_SetColor, Plt5_Update, nodev, nodev, nodev, nodev, gen_DatatoScreen,}, {"postscript", 0, 0, 1000, 1000, 0, 0, PS_Init, PS_NewViewport, PS_Close, PS_Clear, - PS_DrawLine, PS_Arc, PS_Text, nodev, nodev, + PS_DrawLine, PS_Arc, PS_Text, (void*)nodev, (void*)nodev, PS_SetLinestyle, PS_SetColor, PS_Update, - nodev, nodev, nodev, nodev, + nodev, nodev, nodev, (void*)nodev, gen_DatatoScreen,}, {"hpgl", 0, 0, 1000, 1000, 0, 0, GL_Init, GL_NewViewport, GL_Close, GL_Clear, - GL_DrawLine, GL_Arc, GL_Text, nodev, nodev, + GL_DrawLine, GL_Arc, GL_Text, (void*)nodev, (void*)nodev, GL_SetLinestyle, GL_SetColor, GL_Update, - nodev, nodev, nodev, nodev, + nodev, nodev, nodev, (void*)nodev, gen_DatatoScreen,}, {"printf", 0, 0, 24, 80, 0, 0, nodev, nodev, @@ -132,9 +105,6 @@ DISPDEVICE *dispdev = device + NUMELEMS(device) - 1; #define XtNumber(arr) (sizeof(arr) / sizeof(arr[0])) -extern void internalerror (char *message); -extern void externalerror (char *message); - DISPDEVICE *FindDev(char *name) { int i; @@ -341,7 +311,7 @@ gen_Input(REQUEST *request, RESPONSE *response) response->option = error_option; break; } -return 0; + return 0; } /* no operation, do nothing */ diff --git a/src/frontend/dotcards.c b/src/frontend/dotcards.c index 14c87c5e4..12d80019c 100644 --- a/src/frontend/dotcards.c +++ b/src/frontend/dotcards.c @@ -2,6 +2,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group Modified: 2000 AlansFixes +$Id$ **********/ /* @@ -21,6 +22,7 @@ Modified: 2000 AlansFixes #include "dotcards.h" #include "variable.h" #include "fourier.h" +#include "breakp2.h" /* Extract all the .save lines */ @@ -30,10 +32,6 @@ static char * fixem(char *string); static wordlist * gettoks(char *s); -extern void com_save2 (wordlist *wl, char *name); - - - static struct plot * setcplot(char *name) { diff --git a/src/frontend/hpgl.c b/src/frontend/hpgl.c index 9fd160435..bc96abb84 100644 --- a/src/frontend/hpgl.c +++ b/src/frontend/hpgl.c @@ -34,8 +34,10 @@ Author: Jim Groves #include "ftedbgra.h" #include "ftedev.h" #include "fteinput.h" - #include "variable.h" +#include "error.h" +#include "plotting/graphdb.h" +#include "hpgl.h" #define RAD_TO_DEG (180.0 / M_PI) #define DEVDEP(g) (*((GLdevdep *) (g)->devdep)) @@ -82,9 +84,6 @@ static double tocm = 0.0025; static double scale; /* Used for fine tuning */ static int hcopygraphid; -extern int DestroyGraph (int id); -extern void internalerror (char *message); - int GL_Init() { if (!cp_getvar("hcopyscale", VT_STRING, psscale)) { diff --git a/src/frontend/hpgl.h b/src/frontend/hpgl.h new file mode 100644 index 000000000..b0c78ee35 --- /dev/null +++ b/src/frontend/hpgl.h @@ -0,0 +1,21 @@ +/************* +* Header file for hpgl.c +* $Id$ +************/ + +#ifndef HPGH_H +#define HPGH_H + +int GL_Init(void); +int GL_NewViewport(GRAPH *graph); +int GL_Close(void); +int GL_Clear(void); +int GL_DrawLine(int x1, int y1, int x2, int y2); +int GL_Arc(int x0, int y0, int r, double theta1, double theta2); +int GL_Text(char *text, int x, int y); +int GL_DefineLinestyle(); +int GL_SetLinestyle(int linestyleid); +int GL_SetColor(int colorid); +int GL_Update(void); + +#endif /* HPGH_H */ diff --git a/src/frontend/inp.c b/src/frontend/inp.c index 3a927c6c5..a9393ae3b 100644 --- a/src/frontend/inp.c +++ b/src/frontend/inp.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher +$Id$ **********/ /* @@ -25,6 +26,7 @@ Author: 1985 Wayne A. Christopher #include "circuits.h" #include "completion.h" #include "variable.h" +#include "breakp2.h" #ifdef XSPICE /* gtri - add - 12/12/90 - wbk - include new stuff */ @@ -39,9 +41,6 @@ static bool doedit(char *filename); /* Do a listing. Use is listing [expanded] [logical] [physical] [deck] */ - -extern int unlink (const char *); - void com_listing(wordlist *wl) { @@ -513,6 +512,9 @@ inp_spsource(FILE *fp, bool comfile, char *filename) } } + /* Hitoshi Tanaka */ + if(dbs) tfree(dbs); /* Added */ + /*saj, to process save commands always, not just in batch mode *(breaks encapsulation of frountend and parsing commands slightly)*/ ft_dotsaves(); diff --git a/src/frontend/linear.c b/src/frontend/linear.c index 302230bcb..b71f52c81 100644 --- a/src/frontend/linear.c +++ b/src/frontend/linear.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. -Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ #include "ngspice.h" @@ -10,15 +11,13 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "circuits.h" #include "linear.h" +#include "interp.h" /* Interpolate all the vectors in a plot to a linear time scale, which * we determine by looking at the transient parameters in the CKT struct. */ - -extern void lincopy (struct dvec *ov, double *newscale, int newlen, struct dvec *oldscale); - void com_linearize(wordlist *wl) { diff --git a/src/frontend/mw_coms.c b/src/frontend/mw_coms.c index f7bdae5f2..23e1c6f95 100644 --- a/src/frontend/mw_coms.c +++ b/src/frontend/mw_coms.c @@ -1,5 +1,5 @@ /* Michael Widlok 2 Jun 1999 */ - +/* $Id$ */ /* New commands for unloading circuits */ #include "ngspice.h" @@ -12,10 +12,7 @@ #include "circuits.h" #include "mw_coms.h" #include "variable.h" - -extern FILE *rawfileFp; -extern bool rawfileBinary; -extern struct dbcomm *dbs; +#include "runcoms.h" /* Clears ckt and removes current circ. form database */ diff --git a/src/frontend/nutinp.c b/src/frontend/nutinp.c index 38c1ddfbe..3aafb7601 100644 --- a/src/frontend/nutinp.c +++ b/src/frontend/nutinp.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher +$Id$ **********/ /* @@ -12,7 +13,6 @@ Author: 1985 Wayne A. Christopher #include "ftedefs.h" #include "dvec.h" #include "fteinp.h" - #include "nutinp.h" #include "variable.h" @@ -22,9 +22,6 @@ Author: 1985 Wayne A. Christopher * after the run is over. */ - -extern int unlink (const char *); - void inp_nutsource(FILE *fp, bool comfile, char *filename) { diff --git a/src/frontend/options.c b/src/frontend/options.c index 78022de0c..800eb57b7 100644 --- a/src/frontend/options.c +++ b/src/frontend/options.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -19,6 +20,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "circuits.h" #include "options.h" #include "variable.h" +#include "control.h" /* static declarations */ diff --git a/src/frontend/outitf.c b/src/frontend/outitf.c index 92c714c6c..b0222fc6b 100644 --- a/src/frontend/outitf.c +++ b/src/frontend/outitf.c @@ -1,7 +1,8 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1988 Wayne A. Christopher, U. C. Berkeley CAD Group -Modified: 2000 AlansFixes +Modified: 2000 AlansFixes +$Id$ **********/ /* @@ -28,8 +29,10 @@ Modified: 2000 AlansFixes #include #include "cktdefs.h" #include +#include "breakp2.h" +#include "runcoms.h" +#include "plotting/graf.h" -extern void gr_end_iplot(void); extern char *spice_analysis_get_name(int index); extern char *spice_analysis_get_description(int index); @@ -70,10 +73,6 @@ static bool printinfo = FALSE; /* Print informational "error messages". */ /* The two "begin plot" routines share all their internals... */ - -extern int ft_getSaves (struct save_info **savesp); -extern bool ft_getOutReq (FILE **fpp, struct plot **plotp, bool *binp, char *name, char *title); - int OUTpBeginPlot(void *circuitPtr, void *analysisPtr, IFuid analName, IFuid refName, int refType, int numNames, IFuid *dataNames, int dataType, void **plotPtr) { diff --git a/src/frontend/parser/backq.c b/src/frontend/parser/backq.c index 4b8afcb60..fe15697ce 100644 --- a/src/frontend/parser/backq.c +++ b/src/frontend/parser/backq.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -88,7 +89,6 @@ backeval(char *string) FILE *proc, *old; wordlist *wl; bool intv; - extern FILE *popen(const char *, const char *); proc = popen(string, "r"); if (proc == NULL) { diff --git a/src/frontend/parser/backq.h b/src/frontend/parser/backq.h index 98a6ce1de..3d42e19db 100644 --- a/src/frontend/parser/backq.h +++ b/src/frontend/parser/backq.h @@ -1,12 +1,14 @@ /************* * Header file for backq.c * 1999 E. Rouat + * $Id$ ************/ #ifndef BACKQ_H_INCLUDED #define BACKQ_H_INCLUDED -wordlist * cp_bquote(wordlist *wlist); +extern char cp_back; +wordlist * cp_bquote(wordlist *wlist); #endif diff --git a/src/frontend/parser/cshpar.c b/src/frontend/parser/cshpar.c index 28b8e2d2c..c84841890 100644 --- a/src/frontend/parser/cshpar.c +++ b/src/frontend/parser/cshpar.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -33,13 +34,11 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include #endif - #ifdef HAVE_SYS_WAIT_H #include #endif - /* Things go as follows: * (1) Read the line and do some initial quoting (by setting the 8th bit), * and command ignoring. Also deal with command completion. @@ -53,8 +52,7 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group * (7) Do io redirection. */ - -void fixdescriptors(void); +/* static functions */ static void pwlist(wordlist *wlist, char *name); diff --git a/src/frontend/parser/cshpar.h b/src/frontend/parser/cshpar.h index 735302a60..b48d288b3 100644 --- a/src/frontend/parser/cshpar.h +++ b/src/frontend/parser/cshpar.h @@ -1,20 +1,12 @@ /************* * Header file for cshpar.c * 1999 E. Rouat + * $Id$ ************/ #ifndef CSHPAR_H_INCLUDED #define CSHPAR_H_INCLUDED wordlist * cp_parse(char *string); -void com_echo(wordlist *wlist); -wordlist * cp_redirect(wordlist *wl); -void cp_ioreset(void); -void com_shell(wordlist *wl); -void fixdescriptors(void); -void com_rehash(wordlist *wl); -void com_chdir(wordlist *wl); -void com_strcmp(wordlist *wl); - #endif diff --git a/src/frontend/parser/input.c b/src/frontend/parser/input.c index 06e75cdc3..0d9d24e90 100644 --- a/src/frontend/parser/input.c +++ b/src/frontend/parser/input.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1988 Jeffrey M. Hsu +$Id$ **********/ /* @@ -14,6 +15,7 @@ Author: 1988 Jeffrey M. Hsu #include "fteinput.h" #include "input.h" #include "cpextern.h" +#include "../display.h" /* A special 'getc' so that we can deal with ^D properly. There is no way for * stdio to know if we have typed a ^D after some other characters, so @@ -45,8 +47,6 @@ inchar(FILE *fp) } -extern void Input(REQUEST *req, RESPONSE *resp); - int input(FILE *fp) { diff --git a/src/frontend/plotting/graf.h b/src/frontend/plotting/graf.h index 54c7342a0..fb991ac22 100644 --- a/src/frontend/plotting/graf.h +++ b/src/frontend/plotting/graf.h @@ -1,10 +1,13 @@ /************* * Header file for graf.c * 1999 E. Rouat + * $Id$ ************/ -#ifndef _GRAF_H -#define _GRAF_H +#ifndef GRAF_H +#define GRAF_H + +#include "graph.h" int gr_init(double *xlims, double *ylims, char *xname, char *plotname, @@ -34,4 +37,4 @@ void gr_iplot(struct plot *plot); void gr_end_iplot(void); double * readtics(char *string); -#endif +#endif /* GRAF_H */ diff --git a/src/frontend/plotting/graphdb.c b/src/frontend/plotting/graphdb.c index 0dc9b0596..9622ef967 100644 --- a/src/frontend/plotting/graphdb.c +++ b/src/frontend/plotting/graphdb.c @@ -14,6 +14,8 @@ $Id$ #include "graphdb.h" #include "../breakp2.h" +#include "../error.h" +#include "../display.h" /* invariant: currentgraph contains the current graph */ @@ -51,9 +53,6 @@ static int RunningId = 1; /* returns NULL on error */ -extern void internalerror (char *message); -extern void SaveText (GRAPH *graph, char *text, int x, int y); - GRAPH *NewGraph(void) { diff --git a/src/frontend/plotting/grid.c b/src/frontend/plotting/grid.c index 5930b7e94..881318cc7 100644 --- a/src/frontend/plotting/grid.c +++ b/src/frontend/plotting/grid.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Modified: 2001 AlansFixes +$Id$ **********/ /* @@ -14,7 +15,7 @@ Modified: 2001 AlansFixes #include #include "grid.h" - +#include "../display.h" #define RAD_TO_DEG (180.0 / M_PI) #define LABEL_CHARS 20 @@ -36,22 +37,11 @@ static double cliparc(double cx, double cy, double rad, double start, double end int iclipy, int icliprad, int flag); - - /* note: scaleunits is static and never changed in this file ie, can get rid of it */ static bool scaleunits = TRUE; -extern void SetColor (int colorid); -extern void SetLinestyle (int linestyleid); -extern void Text (char *text, int x, int y); -void drawloggrid (GRAPH *graph, char *units, int hmt, int lmt, int decsp, int subs, int pp, Axis axis); -void drawlingrid (GRAPH *graph, char *units, int spacing, int nsp, double dst, double lmt, double hmt, bool onedec, int mult, double mag, int digits, Axis axis); -extern void DrawLine (int x1, int y1, int x2, int y2); -extern void Update (void); -extern void Arc (int x0, int y0, int radius, double theta1, double theta2); - void gr_fixgrid(GRAPH *graph, double xdelta, double ydelta, int xtype, int ytype) { diff --git a/src/frontend/plotting/plot5.c b/src/frontend/plotting/plot5.c index d6211dc3f..856682f99 100644 --- a/src/frontend/plotting/plot5.c +++ b/src/frontend/plotting/plot5.c @@ -83,7 +83,7 @@ Plt5_NewViewport(GRAPH *graph) } -void +int Plt5_Close(void) { @@ -91,18 +91,18 @@ Plt5_Close(void) w/o having reached Plt5_NewViewport */ if (plotfile) fclose(plotfile); - + return 0; } -void +int Plt5_Clear(void) { /* do nothing */ - + return 0; } -void +int Plt5_DrawLine(int x1, int y1, int x2, int y2) { @@ -111,18 +111,18 @@ Plt5_DrawLine(int x1, int y1, int x2, int y2) putsi(y1); putsi(x2); putsi(y2); - + return 0; } /* ARGSUSED */ /* until some code gets written */ -void +int Plt5_Arc(int x0, int y0, int radius, double theta1, double theta2) { - + return 0; } -void +int Plt5_Text(char *text, int x, int y) { @@ -143,7 +143,7 @@ Plt5_Text(char *text, int x, int y) /* restore old linestyle */ Plt5_SetLinestyle(savedlstyle); - + return 0; } int @@ -152,7 +152,7 @@ Plt5_SetLinestyle(int linestyleid) if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { internalerror("bad linestyleid"); - return 0; + return 0; } putc('f', plotfile); fprintf(plotfile, "%s\n", linestyle[linestyleid]); @@ -161,19 +161,19 @@ Plt5_SetLinestyle(int linestyleid) } /* ARGSUSED */ -void +int Plt5_SetColor(int colorid) { /* do nothing */ - + return 0; } -void +int Plt5_Update(void) { fflush(plotfile); - + return 0; } diff --git a/src/frontend/plotting/plot5.h b/src/frontend/plotting/plot5.h index 4b4e68528..84d70db6f 100644 --- a/src/frontend/plotting/plot5.h +++ b/src/frontend/plotting/plot5.h @@ -1,6 +1,7 @@ /************* * Header file for plot5.c * 1999 E. Rouat + * $Id$ ************/ #ifndef PLOT5_H_INCLUDED @@ -8,13 +9,13 @@ int Plt5_Init(void); int Plt5_NewViewport(GRAPH *graph); -void Plt5_Close(void); -void Plt5_Clear(void); -void Plt5_DrawLine(int x1, int y1, int x2, int y2); -void Plt5_Arc(int x0, int y0, int radius, double theta1, double theta2); -void Plt5_Text(char *text, int x, int y); +int Plt5_Close(void); +int Plt5_Clear(void); +int Plt5_DrawLine(int x1, int y1, int x2, int y2); +int Plt5_Arc(int x0, int y0, int radius, double theta1, double theta2); +int Plt5_Text(char *text, int x, int y); int Plt5_SetLinestyle(int linestyleid); -void Plt5_SetColor(int colorid); -void Plt5_Update(void); +int Plt5_SetColor(int colorid); +int Plt5_Update(void); -#endif +#endif /* PLOT5_H_INCLUDED */ diff --git a/src/frontend/plotting/x11.c b/src/frontend/plotting/x11.c index 00cbd39ca..0cb760467 100644 --- a/src/frontend/plotting/x11.c +++ b/src/frontend/plotting/x11.c @@ -5,7 +5,7 @@ $Id$ **********/ /* - X11 drivers. + X11 drivers. */ #include @@ -56,13 +56,13 @@ $Id$ #define BOXSIZE 30 /* initial size of bounding box for zoomin */ typedef struct x11info { - Window window; - int isopen; - Widget shell, form, view, buttonbox, buttons[2]; - XFontStruct *font; - GC gc; - int lastx, lasty; /* used in X_DrawLine */ - int lastlinestyle; /* used in X_DrawLine */ + Window window; + int isopen; + Widget shell, form, view, buttonbox, buttons[2]; + XFontStruct *font; + GC gc; + int lastx, lasty; /* used in X_DrawLine */ + int lastlinestyle; /* used in X_DrawLine */ } X11devdep; #define DEVDEP(g) (*((X11devdep *) (g)->devdep)) @@ -70,13 +70,13 @@ typedef struct x11info { static Display *display; static GC xorgc; static char *xlinestyles[NUMLINESTYLES] = { /* test patterns XXX */ - "\001\001\001\001", /* solid */ - "\001\002\001\002", /* dots */ - "\007\007\007\007", /* longdash */ - "\003\003\003\003", /* shortdash */ - "\007\002\002\002", /* dots longdash */ - "\003\002\001\002", /* dots shortdash */ - "\003\003\007\003", /* short/longdash */ + "\001\001\001\001", /* solid */ + "\001\002\001\002", /* dots */ + "\007\007\007\007", /* longdash */ + "\003\003\003\003", /* shortdash */ + "\007\002\002\002", /* dots longdash */ + "\003\002\001\002", /* dots shortdash */ + "\003\003\007\003", /* short/longdash */ }; static Widget toplevel; @@ -94,9 +94,9 @@ static void linear_arc(int x0, int y0, int radius, double theta1, double theta2) int errorhandler(Display *display, XErrorEvent *errorev) { - XGetErrorText(display, errorev->error_code, ErrorMessage, 1024); - externalerror(ErrorMessage); - return 0; + XGetErrorText(display, errorev->error_code, ErrorMessage, 1024); + externalerror(ErrorMessage); + return 0; } @@ -105,68 +105,68 @@ int X11_Init(void) { - char buf[512]; - char *displayname; + char buf[512]; + char *displayname; - XGCValues gcvalues; + XGCValues gcvalues; - /* grrr, Xtk forced contortions */ - char *argv[2]; - int argc = 2; + /* grrr, Xtk forced contortions */ + char *argv[2]; + int argc = 2; - if (cp_getvar("display", VT_STRING, buf)) { - displayname = buf; - } else if (!(displayname = getenv("DISPLAY"))) { - internalerror("Can't open X display."); - return (1); - } + if (cp_getvar("display", VT_STRING, buf)) { + displayname = buf; + } else if (!(displayname = getenv("DISPLAY"))) { + internalerror("Can't open X display."); + return (1); + } # ifdef DEBUG - _Xdebug = 1; + _Xdebug = 1; # endif - argv[0] = "ngspice"; - argv[1] = displayname; + argv[0] = "ngspice"; + argv[1] = displayname; /* - argv[2] = "-geometry"; - argv[3] = "=1x1+2+2"; + argv[2] = "-geometry"; + argv[3] = "=1x1+2+2"; */ - /* initialize X toolkit */ - toplevel = XtInitialize("ngspice", "Nutmeg", NULL, 0, &argc, argv); + /* initialize X toolkit */ + toplevel = XtInitialize("ngspice", "Nutmeg", NULL, 0, &argc, argv); - display = XtDisplay(toplevel); + display = XtDisplay(toplevel); - X11_Open = 1; + X11_Open = 1; - /* "invert" works better than "xor" for B&W */ + /* "invert" works better than "xor" for B&W */ - /* xor gc should be a function of the pixels that are written on */ - /* gcvalues.function = GXxor; */ - /* this patch makes lines visible on true color displays - Guenther Roehrich 22-Jan-99 */ - gcvalues.function = GXinvert; - gcvalues.line_width = 1; - gcvalues.foreground = 1; - gcvalues.background = 0; + /* xor gc should be a function of the pixels that are written on */ + /* gcvalues.function = GXxor; */ + /* this patch makes lines visible on true color displays + Guenther Roehrich 22-Jan-99 */ + gcvalues.function = GXinvert; + gcvalues.line_width = 1; + gcvalues.foreground = 1; + gcvalues.background = 0; - xorgc = XCreateGC(display, DefaultRootWindow(display), - GCLineWidth | GCFunction | GCForeground | GCBackground, - &gcvalues); + xorgc = XCreateGC(display, DefaultRootWindow(display), + GCLineWidth | GCFunction | GCForeground | GCBackground, + &gcvalues); - /* set correct information */ - dispdev->numlinestyles = NUMLINESTYLES; - dispdev->numcolors = NUMCOLORS; + /* set correct information */ + dispdev->numlinestyles = NUMLINESTYLES; + dispdev->numcolors = NUMCOLORS; - dispdev->width = DisplayWidth(display, DefaultScreen(display)); - dispdev->height = DisplayHeight(display, DefaultScreen(display)); + dispdev->width = DisplayWidth(display, DefaultScreen(display)); + dispdev->height = DisplayHeight(display, DefaultScreen(display)); - /* we don't want non-fatal X errors to call exit */ - XSetErrorHandler(errorhandler); + /* we don't want non-fatal X errors to call exit */ + XSetErrorHandler(errorhandler); - numdispplanes = DisplayPlanes(display, DefaultScreen(display)); + numdispplanes = DisplayPlanes(display, DefaultScreen(display)); - return (0); + return (0); } @@ -174,14 +174,14 @@ static void initlinestyles(void) { - int i; + int i; - if (numdispplanes > 1) { - /* Dotted lines are a distraction when we have colors. */ - for (i = 2; i < NUMLINESTYLES; i++) { - xlinestyles[i] = xlinestyles[0]; - } - } + if (numdispplanes > 1) { + /* Dotted lines are a distraction when we have colors. */ + for (i = 2; i < NUMLINESTYLES; i++) { + xlinestyles[i] = xlinestyles[0]; + } + } } @@ -241,8 +241,8 @@ initcolors(GRAPH *graph) } */ } - /* MW. Set Beackgroound here */ - XSetWindowBackground(display, DEVDEP(graph).window, graph->colors[0]); + /* MW. Set Beackgroound here */ + XSetWindowBackground(display, DEVDEP(graph).window, graph->colors[0]); /* if (graph->colors[0] != DEVDEP(graph).view->core.background_pixel) { graph->colors[0] = DEVDEP(graph).view->core.background_pixel; @@ -259,25 +259,25 @@ void handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata) { - XKeyEvent *keyev = (XKeyPressedEvent *) calldata; - GRAPH *graph = (GRAPH *) clientdata; - char text[4]; - int nbytes; - - nbytes = XLookupString(keyev, text, 4, NULL, NULL); - if (!nbytes) return; - /* write it */ - PushGraphContext(graph); - text[nbytes] = '\0'; - SetColor(1); - Text(text, keyev->x, graph->absolute.height - keyev->y); - /* save it */ - SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y); - /* warp mouse so user can type in sequence */ - XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, - keyev->x + XTextWidth(DEVDEP(graph).font, text, nbytes), - keyev->y); - PopGraphContext(); + XKeyEvent *keyev = (XKeyPressedEvent *) calldata; + GRAPH *graph = (GRAPH *) clientdata; + char text[4]; + int nbytes; + + nbytes = XLookupString(keyev, text, 4, NULL, NULL); + if (!nbytes) return; + /* write it */ + PushGraphContext(graph); + text[nbytes] = '\0'; + SetColor(1); + Text(text, keyev->x, graph->absolute.height - keyev->y); + /* save it */ + SaveText(graph, text, keyev->x, graph->absolute.height - keyev->y); + /* warp mouse so user can type in sequence */ + XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, + keyev->x + XTextWidth(DEVDEP(graph).font, text, nbytes), + keyev->y); + PopGraphContext(); } @@ -286,16 +286,16 @@ void handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata) { - XButtonEvent *buttonev = (XButtonEvent *) calldata; + XButtonEvent *buttonev = (XButtonEvent *) calldata; - switch (buttonev->button) { - case Button1: - slopelocation((GRAPH *) clientdata, buttonev->x, buttonev->y); - break; - case Button3: - zoomin((GRAPH *) clientdata); - break; - } + switch (buttonev->button) { + case Button1: + slopelocation((GRAPH *) clientdata, buttonev->x, buttonev->y); + break; + case Button3: + zoomin((GRAPH *) clientdata); + break; + } } @@ -310,167 +310,168 @@ int X11_NewViewport(GRAPH *graph) { - char fontname[513]; /* who knows . . . */ - char *p, *q; - Cursor cursor; - XSetWindowAttributes w_attrs; - XGCValues gcvalues; - static Arg formargs[ ] = { - { XtNleft, (XtArgVal) XtChainLeft }, - { XtNresizable, (XtArgVal) TRUE } - }; - static Arg bboxargs[ ] = { - { XtNfromHoriz, (XtArgVal) NULL }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtChainRight }, - { XtNright, (XtArgVal) XtChainRight } - }; - static Arg buttonargs[ ] = { - { XtNlabel, (XtArgVal) NULL }, - { XtNfromVert, (XtArgVal) NULL }, - { XtNbottom, (XtArgVal) XtChainTop }, - { XtNtop, (XtArgVal) XtChainTop }, - { XtNleft, (XtArgVal) XtRubber }, - { XtNright, (XtArgVal) XtRubber }, - { XtNresizable, (XtArgVal) TRUE } - }; - static Arg viewargs[] = { - { XtNresizable, (XtArgVal) TRUE }, - { XtNwidth, (XtArgVal) 300 }, - { XtNheight, (XtArgVal) 300 }, - { XtNright, (XtArgVal) XtChainRight } - }; - int trys; - - graph->devdep = tmalloc(sizeof(X11devdep)); - - /* set up new shell */ - DEVDEP(graph).shell = XtCreateApplicationShell("shell", - topLevelShellWidgetClass, NULL, 0); - - /* set up form widget */ - DEVDEP(graph).form = XtCreateManagedWidget("form", - formWidgetClass, DEVDEP(graph).shell, formargs, XtNumber(formargs)); - - /* set up viewport */ - DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass, - DEVDEP(graph).form, - viewargs, - XtNumber(viewargs)); - XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, - (XtEventHandler) handlebuttonev, graph); - XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, - (XtEventHandler) handlekeypressed, graph); - XtAddEventHandler(DEVDEP(graph).view, StructureNotifyMask, FALSE, - (XtEventHandler) resize, graph); - XtAddEventHandler(DEVDEP(graph).view, ExposureMask, FALSE, - (XtEventHandler) redraw, graph); - - /* set up button box */ - XtSetArg(bboxargs[1], XtNfromHoriz, DEVDEP(graph).view); - DEVDEP(graph).buttonbox = XtCreateManagedWidget("buttonbox", - boxWidgetClass, DEVDEP(graph).form, bboxargs, XtNumber(bboxargs)); - - /* set up buttons */ - XtSetArg(buttonargs[0], XtNlabel, "quit"); - XtSetArg(bboxargs[1], XtNfromVert, NULL); - DEVDEP(graph).buttons[0] = XtCreateManagedWidget("quit", - commandWidgetClass, DEVDEP(graph).buttonbox, - buttonargs, 1); - XtAddCallback(DEVDEP(graph).buttons[0], XtNcallback, (XtCallbackProc) killwin, graph); - - XtSetArg(buttonargs[0], XtNlabel, "hardcopy"); - XtSetArg(bboxargs[1], XtNfromVert, DEVDEP(graph).buttons[0]); - DEVDEP(graph).buttons[1] = XtCreateManagedWidget("hardcopy", - commandWidgetClass, DEVDEP(graph).buttonbox, - buttonargs, 1); - XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, (XtCallbackProc) hardcopy, graph); - - /* set up fonts */ - if (!cp_getvar("font", VT_STRING, fontname)) { - (void) strcpy(fontname, DEF_FONT); - } + char fontname[513]; /* who knows . . . */ + char *p, *q; + Cursor cursor; + XSetWindowAttributes w_attrs; + XGCValues gcvalues; + static Arg formargs[ ] = { + { XtNleft, (XtArgVal) XtChainLeft }, + { XtNresizable, (XtArgVal) TRUE } + }; + static Arg bboxargs[ ] = { + { XtNfromHoriz, (XtArgVal) NULL }, + { XtNbottom, (XtArgVal) XtChainTop }, + { XtNtop, (XtArgVal) XtChainTop }, + { XtNleft, (XtArgVal) XtChainRight }, + { XtNright, (XtArgVal) XtChainRight } + }; + static Arg buttonargs[ ] = { + { XtNlabel, (XtArgVal) NULL }, + { XtNfromVert, (XtArgVal) NULL }, + { XtNbottom, (XtArgVal) XtChainTop }, + { XtNtop, (XtArgVal) XtChainTop }, + { XtNleft, (XtArgVal) XtRubber }, + { XtNright, (XtArgVal) XtRubber }, + { XtNresizable, (XtArgVal) TRUE } + }; + static Arg viewargs[] = { + { XtNresizable, (XtArgVal) TRUE }, + { XtNwidth, (XtArgVal) 300 }, + { XtNheight, (XtArgVal) 300 }, + { XtNright, (XtArgVal) XtChainRight } + }; + int trys; + + graph->devdep = tmalloc(sizeof(X11devdep)); + + /* set up new shell */ + DEVDEP(graph).shell = XtCreateApplicationShell("shell", + topLevelShellWidgetClass, NULL, 0); + + /* set up form widget */ + DEVDEP(graph).form = XtCreateManagedWidget("form", + formWidgetClass, DEVDEP(graph).shell, formargs, XtNumber(formargs)); + + /* set up viewport */ + DEVDEP(graph).view = XtCreateManagedWidget("viewport", widgetClass, + DEVDEP(graph).form, + viewargs, + XtNumber(viewargs)); + XtAddEventHandler(DEVDEP(graph).view, ButtonPressMask, FALSE, + (XtEventHandler) handlebuttonev, graph); + XtAddEventHandler(DEVDEP(graph).view, KeyPressMask, FALSE, + (XtEventHandler) handlekeypressed, graph); + XtAddEventHandler(DEVDEP(graph).view, StructureNotifyMask, FALSE, + (XtEventHandler) resize, graph); + XtAddEventHandler(DEVDEP(graph).view, ExposureMask, FALSE, + (XtEventHandler) redraw, graph); + + /* set up button box */ + XtSetArg(bboxargs[1], XtNfromHoriz, DEVDEP(graph).view); + DEVDEP(graph).buttonbox = XtCreateManagedWidget("buttonbox", + boxWidgetClass, DEVDEP(graph).form, bboxargs, XtNumber(bboxargs)); + + /* set up buttons */ + XtSetArg(buttonargs[0], XtNlabel, "quit"); + XtSetArg(bboxargs[1], XtNfromVert, NULL); + DEVDEP(graph).buttons[0] = XtCreateManagedWidget("quit", + commandWidgetClass, DEVDEP(graph).buttonbox, + buttonargs, 1); + XtAddCallback(DEVDEP(graph).buttons[0], XtNcallback, (XtCallbackProc) killwin, graph); + + XtSetArg(buttonargs[0], XtNlabel, "hardcopy"); + XtSetArg(bboxargs[1], XtNfromVert, DEVDEP(graph).buttons[0]); + DEVDEP(graph).buttons[1] = XtCreateManagedWidget("hardcopy", + commandWidgetClass, DEVDEP(graph).buttonbox, + buttonargs, 1); + XtAddCallback(DEVDEP(graph).buttons[1], XtNcallback, (XtCallbackProc) hardcopy, graph); + + /* set up fonts */ + if (!cp_getvar("font", VT_STRING, fontname)) { + (void) strcpy(fontname, DEF_FONT); + } - for (p = fontname; *p && *p <= ' '; p++) + for (p = fontname; *p && *p <= ' '; p++) + ; + if (p != fontname) { + for (q = fontname; *p; *q++ = *p++) ; - if (p != fontname) { - for (q = fontname; *p; *q++ = *p++) - ; - *q = 0; - } + *q = 0; + } - trys = 1; - while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) { - sprintf(ErrorMessage, "can't open font %s", fontname); - strcpy(fontname, "fixed"); - if (trys > 1) { - internalerror(ErrorMessage); - RECOVERNEWVIEWPORT(); - return(1); - } - trys += 1; - } + trys = 1; + while (!(DEVDEP(graph).font = XLoadQueryFont(display, fontname))) { + sprintf(ErrorMessage, "can't open font %s", fontname); + strcpy(fontname, "fixed"); + if (trys > 1) { + internalerror(ErrorMessage); + RECOVERNEWVIEWPORT(); + return(1); + } + trys += 1; + } - graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing - - DEVDEP(graph).font->min_bounds.lbearing + 1; - graph->fontheight = DEVDEP(graph).font->max_bounds.ascent + - DEVDEP(graph).font->max_bounds.descent + 1; - - XtRealizeWidget(DEVDEP(graph).shell); - - DEVDEP(graph).window = XtWindow(DEVDEP(graph).view); - DEVDEP(graph).isopen = 0; - w_attrs.bit_gravity = ForgetGravity; - XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity, - &w_attrs); - /* have to note font and set mask GCFont in XCreateGC, p.w.h. */ - gcvalues.font = DEVDEP(graph).font->fid; - gcvalues.line_width = MW_LINEWIDTH; - gcvalues.cap_style = CapNotLast; - gcvalues.function = GXcopy; - DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window, - GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues); - - /* should absolute.positions really be shell.pos? */ - graph->absolute.xpos = DEVDEP(graph).view->core.x; - graph->absolute.ypos = DEVDEP(graph).view->core.y; - graph->absolute.width = DEVDEP(graph).view->core.width; - graph->absolute.height = DEVDEP(graph).view->core.height; - - initlinestyles(); - initcolors(graph); - - /* set up cursor */ - cursor = XCreateFontCursor(display, XC_left_ptr); - XDefineCursor(display, DEVDEP(graph).window, cursor); - - return (0); + graph->fontwidth = DEVDEP(graph).font->max_bounds.rbearing - + DEVDEP(graph).font->min_bounds.lbearing + 1; + graph->fontheight = DEVDEP(graph).font->max_bounds.ascent + + DEVDEP(graph).font->max_bounds.descent + 1; + + XtRealizeWidget(DEVDEP(graph).shell); + + DEVDEP(graph).window = XtWindow(DEVDEP(graph).view); + DEVDEP(graph).isopen = 0; + w_attrs.bit_gravity = ForgetGravity; + XChangeWindowAttributes(display, DEVDEP(graph).window, CWBitGravity, + &w_attrs); + /* have to note font and set mask GCFont in XCreateGC, p.w.h. */ + gcvalues.font = DEVDEP(graph).font->fid; + gcvalues.line_width = MW_LINEWIDTH; + gcvalues.cap_style = CapNotLast; + gcvalues.function = GXcopy; + DEVDEP(graph).gc = XCreateGC(display, DEVDEP(graph).window, + GCFont | GCLineWidth | GCCapStyle | GCFunction, &gcvalues); + + /* should absolute.positions really be shell.pos? */ + graph->absolute.xpos = DEVDEP(graph).view->core.x; + graph->absolute.ypos = DEVDEP(graph).view->core.y; + graph->absolute.width = DEVDEP(graph).view->core.width; + graph->absolute.height = DEVDEP(graph).view->core.height; + + initlinestyles(); + initcolors(graph); + + /* set up cursor */ + cursor = XCreateFontCursor(display, XC_left_ptr); + XDefineCursor(display, DEVDEP(graph).window, cursor); + + return (0); } /* This routine closes the X connection. It is not to be called for finishing a graph. */ -void +int X11_Close(void) { - XCloseDisplay(display); + XCloseDisplay(display); + return 0; } -void +int X11_DrawLine(int x1, int y1, int x2, int y2) { - if (DEVDEP(currentgraph).isopen) - XDrawLine(display, DEVDEP(currentgraph).window, - DEVDEP(currentgraph).gc, - x1, currentgraph->absolute.height - y1, - x2, currentgraph->absolute.height - y2); - + if (DEVDEP(currentgraph).isopen) + XDrawLine(display, DEVDEP(currentgraph).window, + DEVDEP(currentgraph).gc, + x1, currentgraph->absolute.height - y1, + x2, currentgraph->absolute.height - y2); + return 0; } -void +int X11_Arc(int x0, int y0, int radius, double theta1, double theta2) { @@ -486,128 +487,131 @@ X11_Arc(int x0, int y0, int radius, double theta1, double theta2) t1 = 64 * (180.0 / M_PI) * theta1; t2 = 64 * (180.0 / M_PI) * theta2 - t1; if (t2 == 0) - return; + return 0; XDrawArc(display, DEVDEP(currentgraph).window, DEVDEP(currentgraph).gc, x0 - radius, currentgraph->absolute.height - radius - y0, 2 * radius, 2 * radius, t1, t2); } + return 0; } /* note: x and y are the LOWER left corner of text */ -void +int X11_Text(char *text, int x, int y) { -/* We specify text position by lower left corner, so have to adjust for + /* We specify text position by lower left corner, so have to adjust for X11's font nonsense. */ - if (DEVDEP(currentgraph).isopen) - XDrawString(display, DEVDEP(currentgraph).window, - DEVDEP(currentgraph).gc, x, - currentgraph->absolute.height - - (y + DEVDEP(currentgraph).font->max_bounds.descent), - text, strlen(text)); - - /* note: unlike before, we do not save any text here */ + if (DEVDEP(currentgraph).isopen) + XDrawString(display, DEVDEP(currentgraph).window, + DEVDEP(currentgraph).gc, x, + currentgraph->absolute.height + - (y + DEVDEP(currentgraph).font->max_bounds.descent), + text, strlen(text)); + /* note: unlike before, we do not save any text here */ + return 0; } int X11_DefineColor(int colorid, double red, double green, double blue) { - internalerror("X11_DefineColor not implemented."); - return(0); + internalerror("X11_DefineColor not implemented."); + return 0; } -void +int X11_DefineLinestyle(int linestyleid, int mask) { - internalerror("X11_DefineLinestyle not implemented."); + internalerror("X11_DefineLinestyle not implemented."); + return 0; } -void +int X11_SetLinestyle(int linestyleid) { - XGCValues values; - - if (currentgraph->linestyle != linestyleid) { - - if ((linestyleid == 0 || numdispplanes > 1) && linestyleid != 1) { - /* solid if linestyle 0 or if has color, allow only one - * dashed linestyle */ - values.line_style = LineSolid; - } else { - values.line_style = LineOnOffDash; - } - XChangeGC(display, DEVDEP(currentgraph).gc, GCLineStyle, &values); - - currentgraph->linestyle = linestyleid; - XSetDashes(display, DEVDEP(currentgraph).gc, 0, - xlinestyles[linestyleid], 4); - } + XGCValues values; + + if (currentgraph->linestyle != linestyleid) { + + if ((linestyleid == 0 || numdispplanes > 1) && linestyleid != 1) { + /* solid if linestyle 0 or if has color, allow only one + * dashed linestyle */ + values.line_style = LineSolid; + } else { + values.line_style = LineOnOffDash; + } + XChangeGC(display, DEVDEP(currentgraph).gc, GCLineStyle, &values); + + currentgraph->linestyle = linestyleid; + XSetDashes(display, DEVDEP(currentgraph).gc, 0, + xlinestyles[linestyleid], 4); + } + return 0; } -void +int X11_SetColor(int colorid) { - currentgraph->currentcolor = colorid; - XSetForeground(display, DEVDEP(currentgraph).gc, - currentgraph->colors[colorid]); - + currentgraph->currentcolor = colorid; + XSetForeground(display, DEVDEP(currentgraph).gc, + currentgraph->colors[colorid]); + return 0; } -void +int X11_Update(void) { - if (X11_Open) - XSync(display, 0); - + if (X11_Open) + XSync(display, 0); + return 0; } -void +int X11_Clear(void) { - if (!noclear) /* hack so exposures look like they're handled nicely */ - XClearWindow(display, DEVDEP(currentgraph).window); - + if (!noclear) /* hack so exposures look like they're handled nicely */ + XClearWindow(display, DEVDEP(currentgraph).window); + return 0; } static void X_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy) { - double lmin, lmax; - - if (graph->grid.gridtype == GRID_XLOG - || graph->grid.gridtype == GRID_LOGLOG) - { - lmin = log10(graph->datawindow.xmin); - lmax = log10(graph->datawindow.xmax); - *fx = exp(((x - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.width + lmin) - * M_LN10); - } else { - *fx = (x - graph->viewportxoff) * graph->aspectratiox + - graph->datawindow.xmin; - } + double lmin, lmax; + + if (graph->grid.gridtype == GRID_XLOG + || graph->grid.gridtype == GRID_LOGLOG) + { + lmin = log10(graph->datawindow.xmin); + lmax = log10(graph->datawindow.xmax); + *fx = exp(((x - graph->viewportxoff) + * (lmax - lmin) / graph->viewport.width + lmin) + * M_LN10); + } else { + *fx = (x - graph->viewportxoff) * graph->aspectratiox + + graph->datawindow.xmin; + } - if (graph->grid.gridtype == GRID_YLOG - || graph->grid.gridtype == GRID_LOGLOG) - { - lmin = log10(graph->datawindow.ymin); - lmax = log10(graph->datawindow.ymax); - *fy = exp(((graph->absolute.height - y - graph->viewportxoff) - * (lmax - lmin) / graph->viewport.height + lmin) - * M_LN10); - } else { - *fy = ((graph->absolute.height - y) - graph->viewportyoff) - * graph->aspectratioy + graph->datawindow.ymin; - } + if (graph->grid.gridtype == GRID_YLOG + || graph->grid.gridtype == GRID_LOGLOG) + { + lmin = log10(graph->datawindow.ymin); + lmax = log10(graph->datawindow.ymax); + *fy = exp(((graph->absolute.height - y - graph->viewportxoff) + * (lmax - lmin) / graph->viewport.height + lmin) + * M_LN10); + } else { + *fy = ((graph->absolute.height - y) - graph->viewportyoff) + * graph->aspectratioy + graph->datawindow.ymin; + } } @@ -619,69 +623,69 @@ slopelocation(GRAPH *graph, int x0, int y0) /* initial position of mouse */ { - int x1, y1; - int x, y; - Window rootwindow, childwindow; - int rootx, rooty; - unsigned int state; - double fx0, fx1, fy0, fy1; - double angle; - - x1 = x0; - y1 = y0; - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, &childwindow, - &rootx, &rooty, &x, &y, &state); + int x1, y1; + int x, y; + Window rootwindow, childwindow; + int rootx, rooty; + unsigned int state; + double fx0, fx1, fy0, fy1; + double angle; + + x1 = x0; + y1 = y0; + XQueryPointer(display, DEVDEP(graph).window, &rootwindow, &childwindow, + &rootx, &rooty, &x, &y, &state); + XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); + XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); + while (state & Button1Mask) { + if (x != x1 || y != y1) { + XDrawLine(display, DEVDEP(graph).window, xorgc, + x0, y0, x0, y1-1); + XDrawLine(display, DEVDEP(graph).window, xorgc, + x0, y1, x1, y1); + x1 = x; + y1 = y; XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); - while (state & Button1Mask) { - if (x != x1 || y != y1) { - XDrawLine(display, DEVDEP(graph).window, xorgc, - x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, - x0, y1, x1, y1); - x1 = x; - y1 = y; - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); - } - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, - &childwindow, &rootx, &rooty, &x, &y, &state); + } + XQueryPointer(display, DEVDEP(graph).window, &rootwindow, + &childwindow, &rootx, &rooty, &x, &y, &state); + } + XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); + XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); + + X_ScreentoData(graph, x0, y0, &fx0, &fy0); + X_ScreentoData(graph, x1, y1, &fx1, &fy1); + + /* print it out */ + if (x1 == x0 && y1 == y0) { /* only one location */ + fprintf(stdout, "\nx0 = %g, y0 = %g\n", fx0, fy0); + if (graph->grid.gridtype == GRID_POLAR + || graph->grid.gridtype == GRID_SMITH + || graph->grid.gridtype == GRID_SMITHGRID) + { + angle = RAD_TO_DEG * atan2( fy0, fx0 ); + fprintf(stdout, "r0 = %g, a0 = %g\n", + sqrt( fx0*fx0 + fy0*fy0 ), + (angle>0)?angle:(double) 360+angle); } - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y0, x0, y1-1); - XDrawLine(display, DEVDEP(graph).window, xorgc, x0, y1, x1, y1); - - X_ScreentoData(graph, x0, y0, &fx0, &fy0); - X_ScreentoData(graph, x1, y1, &fx1, &fy1); - - /* print it out */ - if (x1 == x0 && y1 == y0) { /* only one location */ - fprintf(stdout, "\nx0 = %g, y0 = %g\n", fx0, fy0); - if (graph->grid.gridtype == GRID_POLAR - || graph->grid.gridtype == GRID_SMITH - || graph->grid.gridtype == GRID_SMITHGRID) - { - angle = RAD_TO_DEG * atan2( fy0, fx0 ); - fprintf(stdout, "r0 = %g, a0 = %g\n", - sqrt( fx0*fx0 + fy0*fy0 ), - (angle>0)?angle:(double) 360+angle); - } - } else { /* need to print info about two points */ - fprintf(stdout, "\nx0 = %g, y0 = %g x1 = %g, y1 = %g\n", - fx0, fy0, fx1, fy1); - fprintf(stdout, "dx = %g, dy = %g\n", fx1-fx0, fy1 - fy0); - if (x1 != x0 && y1 != y0) { - /* add slope info if both dx and dy are zero, - because otherwise either dy/dx or dx/dy is zero, - which is uninteresting - */ - fprintf(stdout, "dy/dx = %g dx/dy = %g\n", - (fy1-fy0)/(fx1-fx0), (fx1-fx0)/(fy1-fy0)); - } - } + } else { /* need to print info about two points */ + fprintf(stdout, "\nx0 = %g, y0 = %g x1 = %g, y1 = %g\n", + fx0, fy0, fx1, fy1); + fprintf(stdout, "dx = %g, dy = %g\n", fx1-fx0, fy1 - fy0); + if (x1 != x0 && y1 != y0) { + /* add slope info if both dx and dy are zero, + because otherwise either dy/dx or dx/dy is zero, + which is uninteresting + */ + fprintf(stdout, "dy/dx = %g dx/dy = %g\n", + (fy1-fy0)/(fx1-fx0), (fx1-fx0)/(fy1-fy0)); + } + } - return; + return; } @@ -691,104 +695,104 @@ zoomin(GRAPH *graph) { /* note: need to add circular boxes XXX */ - int x0, y0, x1, y1; - double fx0, fx1, fy0, fy1, ftemp; - char buf[BSIZE_SP]; - char buf2[128]; - char *t; + int x0, y0, x1, y1; + double fx0, fx1, fy0, fy1, ftemp; + char buf[BSIZE_SP]; + char buf2[128]; + char *t; - Window rootwindow, childwindow; - int rootx, rooty; - unsigned int state; - int x, y, upperx, uppery, lowerx, lowery; + Window rootwindow, childwindow; + int rootx, rooty; + unsigned int state; + int x, y, upperx, uppery, lowerx, lowery; - /* open box and get area to zoom in on */ + /* open box and get area to zoom in on */ - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, - &childwindow, &rootx, &rooty, &x0, &y0, &state); + XQueryPointer(display, DEVDEP(graph).window, &rootwindow, + &childwindow, &rootx, &rooty, &x0, &y0, &state); - x = lowerx = x1 = x0 + BOXSIZE; - y = lowery = y1 = y0 + BOXSIZE; - upperx = x0; - uppery = y0; + x = lowerx = x1 = x0 + BOXSIZE; + y = lowery = y1 = y0 + BOXSIZE; + upperx = x0; + uppery = y0; - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); + XDrawRectangle(display, DEVDEP(graph).window, xorgc, + upperx, uppery, lowerx - upperx, lowery - uppery); /* note: what are src_x, src_y, src_width, and src_height for? XXX */ - XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, x1, y1); - - while (state & Button3Mask) { - if (x != x1 || y != y1) { - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); - x1 = x; - y1 = y; - /* figure out upper left corner */ - /* remember X11's (and X10's) demented coordinate system */ - if (y0 < y1) { - uppery = y0; - upperx = x0; - lowery = y1; - lowerx = x1; - } else { - uppery = y1; - upperx = x1; - lowery = y0; - lowerx = x0; - } - XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); - } - XQueryPointer(display, DEVDEP(graph).window, &rootwindow, - &childwindow, &rootx, &rooty, &x, &y, &state); + XWarpPointer(display, None, DEVDEP(graph).window, 0, 0, 0, 0, x1, y1); + + while (state & Button3Mask) { + if (x != x1 || y != y1) { + XDrawRectangle(display, DEVDEP(graph).window, xorgc, + upperx, uppery, lowerx - upperx, lowery - uppery); + x1 = x; + y1 = y; + /* figure out upper left corner */ + /* remember X11's (and X10's) demented coordinate system */ + if (y0 < y1) { + uppery = y0; + upperx = x0; + lowery = y1; + lowerx = x1; + } else { + uppery = y1; + upperx = x1; + lowery = y0; + lowerx = x0; } XDrawRectangle(display, DEVDEP(graph).window, xorgc, - upperx, uppery, lowerx - upperx, lowery - uppery); + upperx, uppery, lowerx - upperx, lowery - uppery); + } + XQueryPointer(display, DEVDEP(graph).window, &rootwindow, + &childwindow, &rootx, &rooty, &x, &y, &state); + } + XDrawRectangle(display, DEVDEP(graph).window, xorgc, + upperx, uppery, lowerx - upperx, lowery - uppery); - X_ScreentoData(graph, x0, y0, &fx0, &fy0); - X_ScreentoData(graph, x1, y1, &fx1, &fy1); + X_ScreentoData(graph, x0, y0, &fx0, &fy0); + X_ScreentoData(graph, x1, y1, &fx1, &fy1); - if (fx0 > fx1) { - ftemp = fx0; - fx0 = fx1; - fx1 = ftemp; - } - if (fy0 > fy1) { - ftemp = fy0; - fy0 = fy1; - fy1 = ftemp; - } + if (fx0 > fx1) { + ftemp = fx0; + fx0 = fx1; + fx1 = ftemp; + } + if (fy0 > fy1) { + ftemp = fy0; + fy0 = fy1; + fy1 = ftemp; + } - strncpy(buf2, graph->plotname, sizeof(buf2)); - if ((t =strchr(buf2, ':'))) - *t = 0; + strncpy(buf2, graph->plotname, sizeof(buf2)); + if ((t =strchr(buf2, ':'))) + *t = 0; - if (!eq(plot_cur->pl_typename, buf2)) { - (void) sprintf(buf, + if (!eq(plot_cur->pl_typename, buf2)) { + (void) sprintf(buf, "setplot %s; %s xlimit %.20e %.20e ylimit %.20e %.20e; setplot $curplot\n", - buf2, graph->commandline, fx0, fx1, fy0, fy1); - } else { - (void) sprintf(buf, "%s xlimit %e %e ylimit %e %e\n", - graph->commandline, fx0, fx1, fy0, fy1); - } + buf2, graph->commandline, fx0, fx1, fy0, fy1); + } else { + (void) sprintf(buf, "%s xlimit %e %e ylimit %e %e\n", + graph->commandline, fx0, fx1, fy0, fy1); + } /* don't use the following if using GNU Readline or BSD EditLine */ #if !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) - { - wordlist *wl; - int dummy; - - /* hack for Gordon Jacobs */ - /* add to history list if plothistory is set */ - if (cp_getvar("plothistory", VT_BOOL, (char *) &dummy)) { - wl = cp_parse(buf); - (void) cp_addhistent(cp_event++, wl); - } + { + wordlist *wl; + int dummy; + + /* hack for Gordon Jacobs */ + /* add to history list if plothistory is set */ + if (cp_getvar("plothistory", VT_BOOL, (char *) &dummy)) { + wl = cp_parse(buf); + (void) cp_addhistent(cp_event++, wl); } + } #endif /* !defined(HAVE_GNUREADLINE) && !defined(HAVE_BSDEDITLINE) */ - (void) cp_evloop(buf); + (void) cp_evloop(buf); } @@ -796,8 +800,8 @@ void hardcopy(Widget w, caddr_t client_data, caddr_t call_data) { - lasthardcopy = (GRAPH *) client_data; - com_hardcopy(NULL); + lasthardcopy = (GRAPH *) client_data; + com_hardcopy(NULL); } @@ -805,14 +809,13 @@ void killwin(Widget w, caddr_t client_data, caddr_t call_data) { - GRAPH *graph = (GRAPH *) client_data; + GRAPH *graph = (GRAPH *) client_data; - /* Iplots are done asynchronously */ - DEVDEP(graph).isopen = 0; -/* MW. Not sure but DestroyGraph might free() to much - try Xt...() first */ - XtDestroyWidget(DEVDEP(graph).shell); - DestroyGraph(graph->graphid); - + /* Iplots are done asynchronously */ + DEVDEP(graph).isopen = 0; + /* MW. Not sure but DestroyGraph might free() to much - try Xt...() first */ + XtDestroyWidget(DEVDEP(graph).shell); + DestroyGraph(graph->graphid); } @@ -821,39 +824,39 @@ void redraw(Widget w, caddr_t client_data, caddr_t call_data) { - GRAPH *graph = (GRAPH *) client_data; - XExposeEvent *pev = (XExposeEvent *) call_data; - XEvent ev; - XRectangle rects[30]; - int n = 1; - - DEVDEP(graph).isopen = 1; - - - rects[0].x = pev->x; - rects[0].y = pev->y; - rects[0].width = pev->width; - rects[0].height = pev->height; - - /* XXX */ - /* pull out all other expose regions that need to be redrawn */ - while (n < 30 && XCheckWindowEvent(display, DEVDEP(graph).window, - (long) ExposureMask, &ev)) { - pev = (XExposeEvent *) &ev; - rects[n].x = pev->x; - rects[n].y = pev->y; - rects[n].width = pev->width; - rects[n].height = pev->height; - n++; - } - XSetClipRectangles(display, DEVDEP(graph).gc, 0, 0, - rects, n, Unsorted); + GRAPH *graph = (GRAPH *) client_data; + XExposeEvent *pev = (XExposeEvent *) call_data; + XEvent ev; + XRectangle rects[30]; + int n = 1; + + DEVDEP(graph).isopen = 1; + + + rects[0].x = pev->x; + rects[0].y = pev->y; + rects[0].width = pev->width; + rects[0].height = pev->height; + + /* XXX */ + /* pull out all other expose regions that need to be redrawn */ + while (n < 30 && XCheckWindowEvent(display, DEVDEP(graph).window, + (long) ExposureMask, &ev)) { + pev = (XExposeEvent *) &ev; + rects[n].x = pev->x; + rects[n].y = pev->y; + rects[n].width = pev->width; + rects[n].height = pev->height; + n++; + } + XSetClipRectangles(display, DEVDEP(graph).gc, 0, 0, + rects, n, Unsorted); - noclear = True; - gr_redraw(graph); - noclear = False; + noclear = True; + gr_redraw(graph); + noclear = False; - XSetClipMask(display, DEVDEP(graph).gc, None); + XSetClipMask(display, DEVDEP(graph).gc, None); } @@ -861,107 +864,107 @@ void resize(Widget w, caddr_t client_data, caddr_t call_data) { - GRAPH *graph = (GRAPH *) client_data; - XEvent ev; + GRAPH *graph = (GRAPH *) client_data; + XEvent ev; - /* pull out all other exposure events - Also, get rid of other StructureNotify events on this window. */ + /* pull out all other exposure events + Also, get rid of other StructureNotify events on this window. */ - while (XCheckWindowEvent(display, DEVDEP(graph).window, - (long) /* ExposureMask | */ StructureNotifyMask, &ev)) - ; + while (XCheckWindowEvent(display, DEVDEP(graph).window, + (long) /* ExposureMask | */ StructureNotifyMask, &ev)) + ; - XClearWindow(display, DEVDEP(graph).window); - graph->absolute.width = w->core.width; - graph->absolute.height = w->core.height; - gr_resize(graph); + XClearWindow(display, DEVDEP(graph).window); + graph->absolute.width = w->core.width; + graph->absolute.height = w->core.height; + gr_resize(graph); } -void +int X11_Input(REQUEST *request, RESPONSE *response) { - XEvent ev; - int nfds; - fd_set rfds; + XEvent ev; + int nfds; + fd_set rfds; - switch (request->option) { + switch (request->option) { + case char_option: - - nfds = ConnectionNumber(display) > fileno(request->fp) ? - ConnectionNumber(display) : - fileno(request->fp); - - while (1) { - - /* first read off the queue before doing the select */ - while (XtPending()) { - XtNextEvent(&ev); - XtDispatchEvent(&ev); - } - - /* block on ConnectionNumber and request->fp */ - /* PN: added fd_set * casting */ - FD_ZERO(&rfds); - FD_SET(fileno(request->fp), &rfds); - FD_SET(ConnectionNumber(display), &rfds); - select (nfds + 1, - &rfds, - (fd_set *)NULL, - (fd_set *)NULL, - NULL); - - /* handle X events first */ - if (FD_ISSET (ConnectionNumber(display), &rfds)) { - /* handle ALL X events */ - while (XtPending()) { - XtNextEvent(&ev); - XtDispatchEvent(&ev); - } - } - - if (FD_ISSET (fileno(request->fp), &rfds)) { - response->reply.ch = inchar(request->fp); - goto out; - } - - } - break; + nfds = ConnectionNumber(display) > fileno(request->fp) ? + ConnectionNumber(display) : + fileno(request->fp); + + while (1) { + + /* first read off the queue before doing the select */ + while (XtPending()) { + XtNextEvent(&ev); + XtDispatchEvent(&ev); + } + + /* block on ConnectionNumber and request->fp */ + /* PN: added fd_set * casting */ + FD_ZERO(&rfds); + FD_SET(fileno(request->fp), &rfds); + FD_SET(ConnectionNumber(display), &rfds); + select (nfds + 1, + &rfds, + (fd_set *)NULL, + (fd_set *)NULL, + NULL); + + /* handle X events first */ + if (FD_ISSET (ConnectionNumber(display), &rfds)) { + /* handle ALL X events */ + while (XtPending()) { + XtNextEvent(&ev); + XtDispatchEvent(&ev); + } + } + + if (FD_ISSET (fileno(request->fp), &rfds)) { + response->reply.ch = inchar(request->fp); + goto out; + } + + } + break; case click_option: - /* let's fake this */ - response->reply.graph = lasthardcopy; - break; + /* let's fake this */ + response->reply.graph = lasthardcopy; + break; case button_option: - /* sit and handle events until get a button selection */ - internalerror("button_option not implemented"); - response->option = error_option; - return; - break; + /* sit and handle events until get a button selection */ + internalerror("button_option not implemented"); + response->option = error_option; + return 1; + break; case checkup_option: - /* first read off the queue before doing the select */ - while (XtPending()) { - XtNextEvent(&ev); - XtDispatchEvent(&ev); - } - break; + /* first read off the queue before doing the select */ + while (XtPending()) { + XtNextEvent(&ev); + XtDispatchEvent(&ev); + } + break; default: - internalerror("unrecognized input type"); - response->option = error_option; - return; - break; - } + internalerror("unrecognized input type"); + response->option = error_option; + return 1; + break; + } out: - if (response) - response->option = request->option; - return; + if (response) + response->option = request->option; + return 0; } @@ -969,9 +972,9 @@ static void linear_arc(int x0, int y0, int radius, double theta1, double theta2) /* x coordinate of center */ /* y coordinate of center */ - /* radius of arc */ - /* initial angle ( +x axis = 0 rad ) */ - /* final angle ( +x axis = 0 rad ) */ + /* radius of arc */ + /* initial angle ( +x axis = 0 rad ) */ + /* final angle ( +x axis = 0 rad ) */ /* * Notes: * Draws an arc of radius and center at (x0,y0) beginning at @@ -986,21 +989,21 @@ linear_arc(int x0, int y0, int radius, double theta1, double theta2) y2 = y0 + (int) (radius * sin(theta1)); while(theta1 >= theta2) - theta2 += 2 * M_PI; + theta2 += 2 * M_PI; dphi = (theta2 - theta1) / s; if ((theta1 + dphi) == theta1) { - theta2 += 2 * M_PI; - dphi = (theta2 - theta1) / s; + theta2 += 2 * M_PI; + dphi = (theta2 - theta1) / s; } for(phi = theta1 + dphi; phi < theta2; phi += dphi) { - x1 = x2; - y1 = y2; - x2 = x0 + (int)(radius * cos(phi)); - y2 = y0 + (int)(radius * sin(phi)); - X11_DrawLine(x1,y1,x2,y2); + x1 = x2; + y1 = y2; + x2 = x0 + (int)(radius * cos(phi)); + y2 = y0 + (int)(radius * sin(phi)); + X11_DrawLine(x1,y1,x2,y2); } x1 = x2; diff --git a/src/frontend/plotting/x11.h b/src/frontend/plotting/x11.h index 67d6e66c9..5c5368cca 100644 --- a/src/frontend/plotting/x11.h +++ b/src/frontend/plotting/x11.h @@ -1,23 +1,28 @@ /************* * Header file for x11.c * 1999 E. Rouat + * $Id$ ************/ #ifndef X11_H_INCLUDED #define X11_H_INCLUDED +#ifndef X_DISPLAY_MISSING + +#include /* required for Widget */ + int X11_Init(void); int X11_NewViewport(GRAPH *graph); -void X11_Close(void); -void X11_DrawLine(int x1, int y1, int x2, int y2); -void X11_Arc(int x0, int y0, int radius, double theta1, double theta2); -void X11_Text(char *text, int x, int y); +int X11_Close(void); +int X11_DrawLine(int x1, int y1, int x2, int y2); +int X11_Arc(int x0, int y0, int radius, double theta1, double theta2); +int X11_Text(char *text, int x, int y); int X11_DefineColor(int colorid, double red, double green, double blue); -void X11_DefineLinestyle(int linestyleid, int mask); -void X11_SetLinestyle(int linestyleid); -void X11_SetColor(int colorid); -void X11_Update(void); -void X11_Clear(void); +int X11_DefineLinestyle(int linestyleid, int mask); +int X11_SetLinestyle(int linestyleid); +int X11_SetColor(int colorid); +int X11_Update(void); +int X11_Clear(void); void handlekeypressed(Widget w, caddr_t clientdata, caddr_t calldata); void handlebuttonev(Widget w, caddr_t clientdata, caddr_t calldata); void slopelocation(GRAPH *graph, int x0, int y0); @@ -26,7 +31,8 @@ void hardcopy(Widget w, caddr_t client_data, caddr_t call_data); void killwin(Widget w, caddr_t client_data, caddr_t call_data); void redraw(Widget w, caddr_t client_data, caddr_t call_data); void resize(Widget w, caddr_t client_data, caddr_t call_data); -void X11_Input(REQUEST *request, RESPONSE *response); +int X11_Input(REQUEST *request, RESPONSE *response); +#endif /* X_DISPLAY_MISSING */ -#endif +#endif /* X11_H_INCLUDED */ diff --git a/src/frontend/postsc.c b/src/frontend/postsc.c index abb974d53..43aafe5f5 100644 --- a/src/frontend/postsc.c +++ b/src/frontend/postsc.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1988 Jeffrey M. Hsu +$Id$ **********/ /* @@ -16,6 +17,8 @@ Author: 1988 Jeffrey M. Hsu #include "postsc.h" #include "variable.h" +#include "error.h" +#include "plotting/graphdb.h" #define RAD_TO_DEG (180.0 / M_PI) #define DEVDEP(g) (*((PSdevdep *) (g)->devdep)) @@ -68,8 +71,6 @@ static int ytadj; /* text adjustment y */ static int hcopygraphid; -extern int DestroyGraph (int id); -extern void internalerror (char *message); void PS_LinestyleColor(int linestyleid, int colorid); void PS_SelectColor(int colorid); void PS_Stroke(void); @@ -157,7 +158,7 @@ PS_Init(void) int PS_NewViewport(GRAPH *graph) { - int x1,x2,y1,y2; + int x1,x2,y1,y2; hcopygraphid = graph->graphid; if (!(plotfile = fopen(graph->devdep, "w"))) { @@ -185,43 +186,43 @@ PS_NewViewport(GRAPH *graph) xoff = scale * XOFF; yoff = scale * YOFF; - x1 = 0.75 * 72; - y1 = x1; - x2 = graph->absolute.width + .75 * 72; - y2 = graph->absolute.height + .75 * 72; + x1 = 0.75 * 72; + y1 = x1; + x2 = graph->absolute.width + .75 * 72; + y2 = graph->absolute.height + .75 * 72; /* start file off with a % */ fprintf(plotfile, "%%!PS-Adobe-3.0 EPSF-3.0\n"); fprintf(plotfile, "%%%%Creator: nutmeg\n"); - fprintf(plotfile, "%%%%BoundingBox: %d %d %d %d\n",x1,y1,x2,y2); + fprintf(plotfile, "%%%%BoundingBox: %d %d %d %d\n",x1,y1,x2,y2); fprintf(plotfile, "%g %g scale\n", 1.0 / scale, 1.0 / scale); - if (colorflag == 1){ /* set the background to color0 */ - PS_SelectColor(0); - fprintf(plotfile,"%s setrgbcolor\n",pscolor); - fprintf(plotfile,"newpath\n"); - fprintf(plotfile,"%d %d moveto %d %d lineto\n",x1,y1,x2,y1); - fprintf(plotfile,"%d %d lineto %d %d lineto\n",x2,y2,x1,y2); - fprintf(plotfile,"closepath fill\n"); - } + if (colorflag == 1){ /* set the background to color0 */ + PS_SelectColor(0); + fprintf(plotfile,"%s setrgbcolor\n",pscolor); + fprintf(plotfile,"newpath\n"); + fprintf(plotfile,"%d %d moveto %d %d lineto\n",x1,y1,x2,y1); + fprintf(plotfile,"%d %d lineto %d %d lineto\n",x2,y2,x1,y2); + fprintf(plotfile,"closepath fill\n"); + } /* set up a reasonable font */ - fprintf(plotfile, "/%s findfont %d scalefont setfont\n\n", + fprintf(plotfile, "/%s findfont %d scalefont setfont\n\n", psfont, (int) (fontsize * scale)); graph->devdep = tmalloc(sizeof(PSdevdep)); DEVDEP(graph).lastlinestyle = -1; - DEVDEP(graph).lastcolor = -1; + DEVDEP(graph).lastcolor = -1; DEVDEP(graph).lastx = -1; DEVDEP(graph).lasty = -1; DEVDEP(graph).linecount = 0; - PS_SelectColor(0); + PS_SelectColor(0); graph->linestyle = -1; return 0; } -void +int PS_Close(void) { @@ -230,27 +231,27 @@ PS_Close(void) if (plotfile) { PS_Stroke(); fprintf(plotfile, "showpage\n%%%%EOF\n"); - fclose(plotfile); - plotfile = NULL; + fclose(plotfile); + plotfile = NULL; } /* In case of hardcopy command destroy the hardcopy graph * and reset currentgraph to graphid 1, if possible */ if (!screenflag) { - DestroyGraph(hcopygraphid); - currentgraph = FindGraph(1); + DestroyGraph(hcopygraphid); + currentgraph = FindGraph(1); } + return 0; } -void +int PS_Clear(void) { - /* do nothing */ - + return 0; } -void +int PS_DrawLine(int x1, int y1, int x2, int y2) { @@ -273,14 +274,15 @@ PS_DrawLine(int x1, int y1, int x2, int y2) DEVDEP(currentgraph).lastx = x2; DEVDEP(currentgraph).lasty = y2; + return 0; } -void +int PS_Arc(int x0, int y0, int r, double theta1, double theta2) { double x1, y1; double angle1, angle2; - PS_Stroke(); + PS_Stroke(); while (theta1 >= theta2) theta2 += 2 * M_PI; @@ -295,23 +297,24 @@ PS_Arc(int x0, int y0, int r, double theta1, double theta2) fprintf(plotfile, "stroke\n"); DEVDEP(currentgraph).linecount = 0; + return 0; } -void +int PS_Text(char *text, int x, int y) { - int savedlstyle, savedcolor; + int savedlstyle, savedcolor; /* set linestyle to solid - or may get funny color text on some plotters */ + or may get funny color text on some plotters */ savedlstyle = currentgraph->linestyle; - savedcolor = currentgraph->currentcolor; + savedcolor = currentgraph->currentcolor; PS_SetLinestyle(SOLID); - PS_SetColor(1); + PS_SetColor(1); - /* stroke the path if there's an open one */ - PS_Stroke(); + /* stroke the path if there's an open one */ + PS_Stroke(); /* move to (x, y) */ fprintf(plotfile, "%d %d moveto\n", x + xoff + xtadj, y + yoff + ytadj); fprintf(plotfile, "(%s) show\n", text); @@ -321,8 +324,9 @@ PS_Text(char *text, int x, int y) /* restore old linestyle */ - PS_SetColor(savedcolor); - PS_SetLinestyle(savedlstyle); + PS_SetColor(savedcolor); + PS_SetLinestyle(savedlstyle); + return 0; } /* PS_DefineColor */ @@ -335,27 +339,29 @@ PS_SetLinestyle(int linestyleid) /* special case get it when PS_Text restores a -1 linestyle */ if (linestyleid == -1) { - currentgraph->linestyle = -1; - return 0; + currentgraph->linestyle = -1; + return 0; } if (linestyleid < 0 || linestyleid > dispdev->numlinestyles) { - internalerror("bad linestyleid inside PS_SetLinestyle"); - return 0; + internalerror("bad linestyleid inside PS_SetLinestyle"); + return 0; } PS_LinestyleColor(linestyleid, currentgraph->currentcolor); return 0; - } +} -void +int PS_SetColor(int colorid) { - PS_LinestyleColor(currentgraph->linestyle, colorid); + PS_LinestyleColor(currentgraph->linestyle, colorid); + return 0; } -void +int PS_Update(void) { - fflush(plotfile); + fflush(plotfile); + return 0; } /**************** PRIVAT FUNCTIONS OF PS FRONTEND *****************************/ diff --git a/src/frontend/postsc.h b/src/frontend/postsc.h index 530d0d787..f7e8556f9 100644 --- a/src/frontend/postsc.h +++ b/src/frontend/postsc.h @@ -8,14 +8,14 @@ int PS_Init(void); int PS_NewViewport(GRAPH *graph); -void PS_Close(void); -void PS_Clear(void); -void PS_DrawLine(int x1, int y1, int x2, int y2); -void PS_Arc(int x0, int y0, int r, double theta1, double theta2); -void PS_Text(char *text, int x, int y); +int PS_Close(void); +int PS_Clear(void); +int PS_DrawLine(int x1, int y1, int x2, int y2); +int PS_Arc(int x0, int y0, int r, double theta1, double theta2); +int PS_Text(char *text, int x, int y); int PS_SetLinestyle(int linestyleid); -void PS_SetColor(int colorid); -void PS_Update(void); +int PS_SetColor(int colorid); +int PS_Update(void); #endif diff --git a/src/frontend/runcoms.c b/src/frontend/runcoms.c index 2fb0fd050..c13915c4d 100644 --- a/src/frontend/runcoms.c +++ b/src/frontend/runcoms.c @@ -30,8 +30,6 @@ $Id$ /* static declarations */ static int dosim(char *what, wordlist *wl); -extern struct dbcomm *dbs; - /* Routines for the commands op, tran, ac, dc, listing, device, state, * resume, stop, trace, run, end. Op, tran, ac, and dc cause the action * to be performed immediately, and run causes whatever actions were diff --git a/src/frontend/runcoms2.c b/src/frontend/runcoms2.c index 455a0f973..c204f1208 100644 --- a/src/frontend/runcoms2.c +++ b/src/frontend/runcoms2.c @@ -1,6 +1,7 @@ /********** Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group +$Id$ **********/ /* @@ -16,16 +17,14 @@ Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group #include "circuits.h" #include "runcoms2.h" +#include "runcoms.h" #include "variable.h" +#include "breakp2.h" +#include "plotting/graf.h" + -extern FILE *rawfileFp; -extern bool rawfileBinary; -/*rawfile output saj*/ -extern char *last_used_rawfile; #define RAWBUF_SIZE 32768 char rawfileBuf[RAWBUF_SIZE]; -/*end saj*/ -extern struct dbcomm *dbs; /* Continue a simulation. If there is non in progress, this is the * equivalent of "run". @@ -39,9 +38,6 @@ extern struct dbcomm *dbs; bool resumption = FALSE; - -extern void reset_trace (void); - void com_resume(wordlist *wl) { diff --git a/src/frontend/spec.c b/src/frontend/spec.c index e904d8bae..d649904b3 100644 --- a/src/frontend/spec.c +++ b/src/frontend/spec.c @@ -1,6 +1,7 @@ /********** Copyright 1994 Macquarie University, Sydney Australia. All rights reserved. Author: 1994 Anthony E. Parker, Department of Electronics, Macquarie Uni. +$Id$ **********/ /* @@ -135,7 +136,6 @@ com_spec(wordlist *wl) } else if (eq(window, "gaussian")) { int order; double scale; - extern double erfc(double); if (!cp_getvar("specwindoworder", VT_NUM, &order)) order = 2; if (order < 2) order = 2; scale = pow(2*M_PI/order,0.5)*(0.5-erfc(pow(order,0.5))); diff --git a/src/frontend/spiceif.c b/src/frontend/spiceif.c index 183b9767f..d580b4446 100644 --- a/src/frontend/spiceif.c +++ b/src/frontend/spiceif.c @@ -1378,4 +1378,4 @@ void com_savesnap(wordlist *wl) { } -#endif +#endif /* EXPERIMENTAL_CODE */ diff --git a/src/frontend/spiceif.h b/src/frontend/spiceif.h index 55346cd05..4195fba3d 100644 --- a/src/frontend/spiceif.h +++ b/src/frontend/spiceif.h @@ -1,6 +1,7 @@ /************* * Header file for spiceif.c * 1999 E. Rouat + * $Id$ ************/ #ifndef SPICEIF_H_INCLUDED @@ -19,9 +20,8 @@ bool if_tranparams(struct circ *ci, double *start, double *stop, double *step); struct variable * if_getstat(void *ckt, char *name); #ifdef EXPERIMENTAL_CODE -void if_loadsnap(wordlist *wl); -void if_savesnap(wordlist *wl); +void com_loadsnap(wordlist *wl); +void com_savesnap(wordlist *wl); #endif - -#endif +#endif /* SPICEIF_H_INCLUDED */ diff --git a/src/frontend/streams.c b/src/frontend/streams.c index 2c7b38049..e91fbd8c4 100644 --- a/src/frontend/streams.c +++ b/src/frontend/streams.c @@ -1,3 +1,8 @@ +/************* +* streams.c +* $Id$ +************/ + #include #include #include @@ -8,7 +13,6 @@ #include "quote.h" #include "streams.h" - bool cp_debug = FALSE; char cp_gt = '>'; char cp_lt = '<'; @@ -25,6 +29,8 @@ FILE *cp_curin = NULL; FILE *cp_curout = NULL; FILE *cp_curerr = NULL; +/* static functions */ +static bool fileexists(char *name); static bool fileexists(char *name) diff --git a/src/frontend/streams.h b/src/frontend/streams.h index 44bc27765..0600b2292 100644 --- a/src/frontend/streams.h +++ b/src/frontend/streams.h @@ -1,8 +1,27 @@ -#ifndef _STREAMS_H -#define _STREAMS_H +/************* +* Header file for streams.c +* $Id$ +************/ +#ifndef STREAMS_H +#define STREAMS_H + +#include +#include + +extern bool cp_debug; +extern char cp_amp; +extern char cp_gt; +extern char cp_lt; extern FILE *cp_in; extern FILE *cp_out; extern FILE *cp_err; +extern FILE *cp_curin; +extern FILE *cp_curout; +extern FILE *cp_curerr; + +void cp_ioreset(void); +void fixdescriptors(void); +wordlist * cp_redirect(wordlist *wl); -#endif +#endif /* STREAMS_H */ diff --git a/src/frontend/subckt.c b/src/frontend/subckt.c index 6e7d02b5a..848c00315 100644 --- a/src/frontend/subckt.c +++ b/src/frontend/subckt.c @@ -2,6 +2,7 @@ Copyright 1990 Regents of the University of California. All rights reserved. Author: 1985 Wayne A. Christopher, U. C. Berkeley CAD Group Modified: 2000 AlansFixes +$Id$ **********/ /*------------------------------------------------------------------------------ @@ -60,18 +61,11 @@ Modified: 2000 AlansFixes #include "subckt.h" #include "variable.h" +#ifdef NUMPARAMS /* Uncomment to turn on tracing for the Numparam */ /*#define TRACE_NUMPARAMS*/ -#ifdef NUMPARAMS -#define NUPADECKCOPY 0 -#define NUPASUBSTART 1 -#define NUPASUBDONE 2 -#define NUPAEVALDONE 3 -extern char * nupa_copy(char *s, int linenum); -extern int nupa_eval(char *s, int linenum); -extern int nupa_signal(int sig, char *info); -extern void nupa_scan(char * s, int linenum); /* SJB added */ +#include "numparam/numpaif.h" #endif /* ----- static declarations ----- */ diff --git a/src/frontend/wdisp/Makefile.am b/src/frontend/wdisp/Makefile.am index 40113c1bc..3f43f2434 100644 --- a/src/frontend/wdisp/Makefile.am +++ b/src/frontend/wdisp/Makefile.am @@ -1,8 +1,13 @@ +## Process this file with automake to produce Makefile.in +## $Id$ + noinst_LIBRARIES = libwindisp.a libwindisp_a_SOURCES = \ windisp.c \ + windisp.h \ winprint.c \ + winprint.h \ ftegraf.h diff --git a/src/frontend/wdisp/windisp.h b/src/frontend/wdisp/windisp.h new file mode 100644 index 000000000..09ab5ff5d --- /dev/null +++ b/src/frontend/wdisp/windisp.h @@ -0,0 +1,23 @@ +/************* +* Header file for windisp.c +* $Id$ +************/ + +#ifndef WINDISP_H +#define WINDISP_H + +extern int WIN_Init(); +extern int WIN_NewViewport(); +extern int WIN_Close(); +extern int WIN_Clear(); +extern int WIN_DrawLine(); +extern int WIN_Arc(); +extern int WIN_Text(); +extern int WIN_DefineColor(); +extern int WIN_DefineLinestyle(); +extern int WIN_SetLinestyle(); +extern int WIN_SetColor(); +extern int WIN_Update(); +extern int WIN_DiagramReady(); + +#endif /* WINDISP_H */ diff --git a/src/frontend/wdisp/winprint.h b/src/frontend/wdisp/winprint.h new file mode 100644 index 000000000..46ce32901 --- /dev/null +++ b/src/frontend/wdisp/winprint.h @@ -0,0 +1,23 @@ +/************* +* Header file for winprint.c +* $Id$ +************/ + +#ifndef WINPRINT_H +#define WINPRINT_H + +extern int WPRINT_Init(); +extern int WPRINT_NewViewport(); +extern int WPRINT_Close(); +extern int WPRINT_Clear(); +extern int WPRINT_DrawLine(); +extern int WPRINT_Arc(); +extern int WPRINT_Text(); +extern int WPRINT_DefineColor(); +extern int WPRINT_DefineLinestyle(); +extern int WPRINT_SetLinestyle(); +extern int WPRINT_SetColor(); +extern int WPRINT_Update(); +extern int WPRINT_DiagramReady(); + +#endif /* WINPRINT_H */