diff --git a/log/Makefile b/log/Makefile index e27a46789ec42872a73ca31a23fd9137fb8fdcfc..098a02311305ca08bfa30af6abcae33e57cdef7d 100644 --- a/log/Makefile +++ b/log/Makefile @@ -51,7 +51,7 @@ CHIPMUNKFLAGS = $(ARCH_OPT) STDC = c11 CFLAGS = $(CHIPMUNKFLAGS) -I$(LOGINC) -I$(LOCINC) -I$(XINCLUDEDIR) \ - -DLOGLIB=\"$(LOGLIBDIR)\" -DF_OK=0 -std=$(STDC) -g -w + -DLOGLIB=\"$(LOGLIBDIR)\" -DF_OK=0 -std=$(STDC) -g -Wall -Wextra DIGOBJ = $(TARGET_DIR)/logsim.o $(TARGET_DIR)/logdig.o \ $(TARGET_DIR)/logsimasm.o $(TARGET_DIR)/logsimed.o \ @@ -84,7 +84,7 @@ TOOLOBJ = $(SIMOBJ) $(TARGET_DIR)/logspc.o $(TARGET_DIR)/logntk.o \ $(TARGET_DIR)/label.o $(TARGET_DIR)/wire.o \ $(TARGET_DIR)/page.o $(TARGET_DIR)/gate.o \ $(TARGET_DIR)/screen.o $(TARGET_DIR)/node.o \ - $(TARGET_DIR)/tool.o + $(TARGET_DIR)/tool.o $(TARGET_DIR)/utils.o $(TARGET_DIR)/ana/%.o: $(SRC_DIR)/ana/%.c diff --git a/log/include/gate.h b/log/include/gate.h index 9df1f6f61c89df96819329431daa8dbd8d59d878..b8754ad254e939d87fb55a38689c45673e4b36e6 100644 --- a/log/include/gate.h +++ b/log/include/gate.h @@ -3,24 +3,24 @@ #include "logdef.h" -static void uaddgate(short x, short y, short gtype); +void uaddgate(short x, short y, short gtype); -static void addgate1(short x, short y, short gtype); +void addgate1(short x, short y, short gtype); -static void pconnectgate(log_grec *g, int *success); +void pconnectgate(log_grec *g, int *success); -static void delgate(log_grec *g); +void delgate(log_grec *g); -static void disconnectgate(log_grec *g); +void disconnectgate(log_grec *g); -static void closergate(short x, short y); +void closergate(short x, short y); -static void disposegate(log_grec **g); +void disposegate(log_grec **g); -static void copygate(log_grec *old, log_grec **g); +void copygate(log_grec *old, log_grec **g); -static void newgate(log_grec **g, short gt); +void newgate(log_grec **g, short gt); -static void eragate(log_grec *g); +void eragate(log_grec *g); #endif diff --git a/log/include/label.h b/log/include/label.h index 8efe5a7d49d689718bcfc0b049b105df1ca2ea60..749a55f2a933474eac675c97967cfad79aed42b4 100644 --- a/log/include/label.h +++ b/log/include/label.h @@ -3,6 +3,6 @@ #include "logdef.h" -static void parselabel(na_strlist_t **lbl, short *numattrs, log_kattrrec **attr); +void parselabel(na_strlist_t **lbl, short *numattrs, log_kattrrec **attr); #endif diff --git a/log/include/logglobals.h b/log/include/logglobals.h index 7c446464a2b95eccccbe46ed0a7cc549c5295d1b..eac087ba2ec5f4523c998829b33eabf323966d9a 100644 --- a/log/include/logglobals.h +++ b/log/include/logglobals.h @@ -1,6 +1,8 @@ #ifndef LOGGLOBALS #define LOGGLOBALS +#include <p2c/p2c.h> +#include <p2c/newkbd.h> #include "settings.h" #include "logstructs.h" @@ -145,9 +147,9 @@ extern log_krec *modeprobekind; extern nk_keytransinfo *curkeytrans; /* Current keyboard definitions */ -extern enum { - normal, grid, delete__, copy_, paste, boxcursor -} cursortype, oldcursortype; +enum cursors { normal, grid, delete__, copy_, paste, boxcursor}; +extern enum cursors cursortype; +extern enum cursors oldcursortype; /* Type of cursor */ /* menupicture, errorpicture : m_picturevar; { Various saved images */ diff --git a/log/include/node.h b/log/include/node.h index 2189e4189a149132dc311a9cb5316bc5867b73c2..e15bcfceda8a6f5259e7874ce712cafcbeb0c1d1 100644 --- a/log/include/node.h +++ b/log/include/node.h @@ -3,15 +3,15 @@ #include "logdef.h" -static void dumpnodes(); +void dumpnodes(); -static void switchnode(log_nrec **n, log_nrec *n2); +void switchnode(log_nrec **n, log_nrec *n2); -static void disposenode(log_nrec **n); +void disposenode(log_nrec **n); -static void copynode(log_nrec *old, log_nrec **n); +void copynode(log_nrec *old, log_nrec **n); -static void newnode(log_nrec **n, uchar st); +void newnode(log_nrec **n, uchar st); /* Local variables for checkcombine: */ struct LOC_checkcombine { diff --git a/log/include/page.h b/log/include/page.h index 3f65d1d328af0d2193098463f111ff1d8c33b633..0e47e94e701dab73ed871f7fcfc47d180de93659 100644 --- a/log/include/page.h +++ b/log/include/page.h @@ -1,6 +1,6 @@ #ifndef PAGE_H #define PAGE_H -static void chpage(short pg); +void chpage(short pg); #endif diff --git a/log/include/screen.h b/log/include/screen.h index 603ef74e22a49b33953bc1bfe3a1c74b3f949b8e..2f447d94b80f05a21a335703990bcaa313f125da 100644 --- a/log/include/screen.h +++ b/log/include/screen.h @@ -3,58 +3,58 @@ #include "logdef.h" -static void plainxformcoords(log_grec *g, short *x, short *y); +void plainxformcoords(log_grec *g, short *x, short *y); -static void clipoff(); +void clipoff(); -static void initscreen(); +void initscreen(); -static void initscreen2(); +void initscreen2(); -static void refrscreen1(); +void refrscreen1(); -static void refrscreen(); +void refrscreen(); -static void endbottom(); +void endbottom(); -static void beginbottom(); +void beginbottom(); -static void refreshsoon(); +void refreshsoon(); -static void refresh(); +void refresh(); -static void drawnodec(log_nrec *n, short c); +void drawnodec(log_nrec *n, short c); -static void drawgatex(log_grec *g); +void drawgatex(log_grec *g); -static void drawgatexc(log_grec *g, short c); +void drawgatexc(log_grec *g, short c); -static void udrawgatec(short x, short y, short g, short c); +void udrawgatec(short x, short y, short g, short c); -static void drawgatec(short x, short y, short g, short c); +void drawgatec(short x, short y, short g, short c); -static void clearscreen(); +void clearscreen(); -static void remcursor(); +void remcursor(); -static void clipon(); +void clipon(); -static void centerstr2(short x, short y, char *s); +void centerstr2(short x, short y, char *s); -static void rightstr2(short x, short y, char *s); +void rightstr2(short x, short y, char *s); -static void drawstr2(short x, short y, char *s); +void drawstr2(short x, short y, char *s); -static void clearalpha(); +void clearalpha(); -static void xformcoords(log_grec *g, short *x, short *y); +void xformcoords(log_grec *g, short *x, short *y); -static void setdimgate(log_grec *g, int dim); +void setdimgate(log_grec *g, int dim); -static void hidecursorrect_hook(long x1, long y1, long x2, long y2); +void hidecursorrect_hook(long x1, long y1, long x2, long y2); -static void unhidecursor_hook(); +void unhidecursor_hook(); -static void hidecursor_hook(); +void hidecursor_hook(); #endif diff --git a/log/include/utils.h b/log/include/utils.h new file mode 100644 index 0000000000000000000000000000000000000000..62d602fbfe205b3def68e6c5c978341797e8b47e --- /dev/null +++ b/log/include/utils.h @@ -0,0 +1,8 @@ +#ifndef UTILS_H +#define UTILS_H + +void working(); +void readreal(char s_[], double *r); +void stamp(long *i); +void getword(char *buf, char *wrd); +#endif diff --git a/log/include/wire.h b/log/include/wire.h index 4bcd797e958272e6f0df349ed1fa1656523041d4..370fc06c1595ceb13049be597552db17db6f6ee0 100644 --- a/log/include/wire.h +++ b/log/include/wire.h @@ -3,15 +3,15 @@ #include "logdef.h" -static void addvwire2(short x, short y1, short y2); +void addvwire2(short x, short y1, short y2); -static void addhwire2(short x1, short x2, short y); +void addhwire2(short x1, short x2, short y); -static void delvwire(log_vwrec *vw); +void delvwire(log_vwrec *vw); -static void delhwire(log_hwrec *hw); +void delhwire(log_hwrec *hw); -static void closerwire(short x, short y); +void closerwire(short x, short y); /* Local variables for wantsolder: */ struct LOC_wantsolder diff --git a/log/src/gate.c b/log/src/gate.c index d9b76e0b511dcbf6dd5e7874f984d8dbfff3fa23..1391f92c6ecb550d2b4a269f7e3e95b4d0b3b212 100644 --- a/log/src/gate.c +++ b/log/src/gate.c @@ -3,6 +3,7 @@ #include <p2c/newkbd.h> #include "logfont.h" #include "logglobals.h" +#include "utils.h" #include "gate.h" /*================ INSIDEGATE ==================*/ @@ -13,7 +14,7 @@ /* new version by Tim Edwards, Dec 1996 */ -static int insidegate(log_grec *g, short x, short y) +int insidegate(log_grec *g, short x, short y) { short xx1, xx2, yy1, yy2, z; short loc_x1, loc_x2; @@ -69,7 +70,7 @@ static int insidegate(log_grec *g, short x, short y) /*= =*/ /*================================================*/ -static void eragate(log_grec *g) +void eragate(log_grec *g) { log_grec *g1, *g2; @@ -110,7 +111,7 @@ static void eragate(log_grec *g) /*= =*/ /*================================================*/ -static void linkgate(log_grec **g) +void linkgate(log_grec **g) { (*g)->next = gg.gbase[gg.curpage - 1]; gg.gbase[gg.curpage - 1] = *g; @@ -125,7 +126,7 @@ static void linkgate(log_grec **g) /*= =*/ /*================================================*/ -static void newgptr(log_grec **g) +void newgptr(log_grec **g) { if (freegate == NULL) { @@ -139,7 +140,7 @@ static void newgptr(log_grec **g) } -static void newgate2(log_grec **g, short gt, short sig, log_gattrrec *attrs) +void newgate2(log_grec **g, short gt, short sig, log_gattrrec *attrs) { short i; char name[256]; @@ -188,7 +189,7 @@ static void newgate2(log_grec **g, short gt, short sig, log_gattrrec *attrs) } -static void newgate(log_grec **g, short gt) +void newgate(log_grec **g, short gt) { newgate2(g, gt, 0, NULL); } @@ -200,7 +201,7 @@ static void newgate(log_grec **g, short gt) /*= =*/ /*================================================*/ -static void copygate(log_grec *old, log_grec **g) +void copygate(log_grec *old, log_grec **g) { long i, FORLIM; @@ -233,7 +234,7 @@ static void copygate(log_grec *old, log_grec **g) /*= =*/ /*================================================*/ -static void unlkgate(log_grec **g) +void unlkgate(log_grec **g) { log_grec *g1; @@ -256,7 +257,7 @@ static void unlkgate(log_grec **g) /*= =*/ /*================================================*/ -static void disposegptr(log_grec **g) +void disposegptr(log_grec **g) { (*g)->next = freegate; freegate = *g; @@ -266,7 +267,7 @@ static void disposegptr(log_grec **g) #define rtn "DISPOSEGATE" -static void disposegate(log_grec **g) +void disposegate(log_grec **g) { log_grec *g1, *g2; @@ -304,7 +305,7 @@ static void disposegate(log_grec **g) /*= =*/ /*================================================*/ -static void closergate(short x, short y) +void closergate(short x, short y) { if (gg.textinvisible) gg.nearlabel = NULL; @@ -346,7 +347,7 @@ static void closergate(short x, short y) #define rtn "CHGGATE" -static void chggate(log_grec *g, int i, log_nrec *oldnode, log_nrec *n) +void chggate(log_grec *g, int i, log_nrec *oldnode, log_nrec *n) { log_hwrec *hw; log_vwrec *vw; @@ -420,7 +421,7 @@ static void chggate(log_grec *g, int i, log_nrec *oldnode, log_nrec *n) #undef rtn -static void chggatepin(log_grec *g, short i, log_nrec **oldnode, log_nrec **savenode) +void chggatepin(log_grec *g, short i, log_nrec **oldnode, log_nrec **savenode) { log_nrec *n; log_hwrec *hw; @@ -477,7 +478,7 @@ static void chggatepin(log_grec *g, short i, log_nrec **oldnode, log_nrec **save } -static void disconnectgate(log_grec *g) +void disconnectgate(log_grec *g) { log_nrec *savenode; short i, j; @@ -520,7 +521,7 @@ static void disconnectgate(log_grec *g) } -static void delgate(log_grec *g) +void delgate(log_grec *g) { clipon(); eragate(g); @@ -529,7 +530,7 @@ static void delgate(log_grec *g) clipoff(); } -static void frygate(log_grec *g) +void frygate(log_grec *g) { long t0; @@ -552,7 +553,7 @@ static void frygate(log_grec *g) /*= =*/ /*================================================*/ -static void initpinpos(log_grec *g) +void initpinpos(log_grec *g) { short i, rxx, rxy, ryx, ryy; log_krec *WITH; @@ -572,7 +573,7 @@ static void initpinpos(log_grec *g) } -static int connectgate(log_grec *g) +int connectgate(log_grec *g) { int Result; cnrec *cnbase; @@ -689,7 +690,7 @@ _L1: } -static void pconnectgate(log_grec *g, int *success) +void pconnectgate(log_grec *g, int *success) { *success = connectgate(g); } @@ -701,7 +702,7 @@ static void pconnectgate(log_grec *g, int *success) /*= =*/ /*================================================*/ -static void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) +void addgate2(short x, short y, short gtype, short sig, log_gattrrec *attrs) { log_grec *g, *g1; short i, gmax; @@ -747,12 +748,12 @@ static void addgate2(short x, short y, short gtype, short sig, log_gattrrec *att } -static void addgate1(short x, short y, short gtype) +void addgate1(short x, short y, short gtype) { addgate2(x, y, gtype, 0, NULL); } -static void uaddgate(short x, short y, short gtype) +void uaddgate(short x, short y, short gtype) { short xx, yy; log_grec *g; @@ -789,7 +790,7 @@ static void uaddgate(short x, short y, short gtype) /*= =*/ /*================================================*/ -static void movexorgate(short x, short y, short g, short sig, short yy) +void movexorgate(short x, short y, short g, short sig, short yy) { clipoff(); m_colormode((long)m_xor); @@ -811,7 +812,7 @@ static void movexorgate(short x, short y, short g, short sig, short yy) } -static int addgate(short gtype, short sig, log_gattrrec *attrs) +int addgate(short gtype, short sig, log_gattrrec *attrs) { int Result; short yy; diff --git a/log/src/label.c b/log/src/label.c index 2aeaea8c936abedce3721b884ec41b03d3c572c4..c508a457e7ca2bbfb0648df51cbe411b8d62737e 100644 --- a/log/src/label.c +++ b/log/src/label.c @@ -4,14 +4,16 @@ #include "settings.h" #include "logglobals.h" #include "logfont.h" +#include "utils.h" #include "label.h" + /** * @param lbl: list of character to parse * @param numattrs: number of found attributs * @param attr: vector containing parsed attributs */ -static void parselabel(na_strlist_t **lbl, short *numattrs, log_kattrrec **attr) +void parselabel(na_strlist_t **lbl, short *numattrs, log_kattrrec **attr) { short j, j1, j2, j3, yy, maxx; na_strlist_t *l1, *l2, *l3, *attrnames; @@ -318,7 +320,7 @@ static void parselabel(na_strlist_t **lbl, short *numattrs, log_kattrrec **attr) /*= =*/ /*================================================*/ -static void eralabel(log_lrec *l) +void eralabel(log_lrec *l) { m_color((long)gg.color.backgr); m_drawstr(l->x * gg.scale - gg.xoff, l->y * gg.scale - gg.yoff + 2, @@ -332,7 +334,7 @@ static void eralabel(log_lrec *l) /*= =*/ /*================================================*/ -static void xorlabel(short x, short y, log_lrec *l) +void xorlabel(short x, short y, log_lrec *l) { m_colormode((long)m_xor); m_color((long)gg.color.labeltext); @@ -347,7 +349,7 @@ static void xorlabel(short x, short y, log_lrec *l) /*= =*/ /*================================================*/ -static void linklabel(log_lrec *l) +void linklabel(log_lrec *l) { l->next = gg.lbase[gg.curpage - 1]; gg.lbase[gg.curpage - 1] = l; @@ -355,7 +357,7 @@ static void linklabel(log_lrec *l) } -static void newlabel(log_lrec **l) +void newlabel(log_lrec **l) { *l = (log_lrec *)Malloc(sizeof(log_lrec)); (*l)->temp = (na_long)0; @@ -369,7 +371,7 @@ static void newlabel(log_lrec **l) /*= =*/ /*================================================*/ -static void unlinklabel(log_lrec *l) +void unlinklabel(log_lrec *l) { log_lrec *l1; @@ -385,7 +387,7 @@ static void unlinklabel(log_lrec *l) } -static void displabel(log_lrec **l) +void displabel(log_lrec **l) { unlinklabel(*l); Free(*l); diff --git a/log/src/log.c b/log/src/log.c index 44f6aa78df814f6cfafb4594b6263a6059b7d617..7fd6d373d2fd7e211d69870db0f05c4f4e95d883 100644 --- a/log/src/log.c +++ b/log/src/log.c @@ -65,6 +65,7 @@ #include <p2c/newasm.h> #include <p2c/newcrt.h> +/* @ home */ #include "settings.h" #include "logstructs.h" #include "logglobals.h" @@ -75,12 +76,15 @@ #include "wire.h" #include "node.h" #include "page.h" +#include "utils.h" char *GetChipmunkPath(); char *my_strdup(); int findprocedure (char *name, void (**start)()); - +enum cursors; +enum cursors cursortype; +enum cursors oldcursortype; /* 0*/ /* If the pen is in "this" sector, */ /* 1*/ @@ -368,17 +372,6 @@ static char *ioresult_message(char *Result, long iores) return strcpy(Result, s); } - -/*================== WORKING ===================*/ -/*= =*/ -/*= Reserved for future use. =*/ -/*= =*/ -/*================================================*/ - -static void working() -{ -} - /*=================== ALERT ====================*/ /*= =*/ /*= Produce an audible alert from the keyboard. =*/ @@ -415,10 +408,10 @@ static void clearshowalpha (); /*= =*/ /*================================================*/ -static void message (char *msg); +extern void message (char *msg); -static void report(short num, char *s) +extern void report(short num, char *s) { char ch; char STR2[256]; @@ -453,7 +446,7 @@ static void report(short num, char *s) static void refreditmode (); -static void log_setmode(const char *s) +extern void log_setmode(const char *s) { time_t h; char *cp; @@ -494,82 +487,7 @@ static void log_setmode(const char *s) drawstr2(across + menux3, line2, modename); } - -static void dounits(char *s, double *r) -{ - char ch; - - if (*s == '\0') - return; - ch = s[0]; - if (ch >= 'a') - ch -= 32; - if (ch == 'F') - { - *r *= 1e-15; - return; - } - if (ch == 'P') - { - *r *= 1e-12; - return; - } - if (ch == 'N') - { - *r *= 1e-9; - return; - } - if (ch == 'U') - { - *r *= 1e-6; - return; - } - if (ch == 'K') - { - *r *= 1e3; - return; - } - if (ch == 'G') - { - *r *= 1e9; - return; - } - if (ch == 'T') - { - *r *= 1e12; - return; - } - if (ch != 'M') - return; - if (strlen(s) >= 3 && (s[1] == 'E' || s[1] == 'e') && - (s[2] == 'G' || s[2] == 'g')) - *r *= 1e6; - else - *r *= 1e-3; -} - - -static void readreal(char *s_, double *r) -{ - char s[256]; - long i; - char *STR1; - char STR2[256]; - - strcpy(s, s_); - if (!(*s != '\0' && - (s[0] == '.' || s[0] == '+' || s[0] == '-' || isdigit(s[0])))) - return; - *r = strtod(s, &STR1); - i = STR1 - s + 1; - strcpy_overlap(s, s + i - 1); - strcpy(STR2, strltrim(s)); - strcpy(s, STR2); - dounits(s, r); -} - - -static void strwordx(char *buf, char *wrd) +extern void strwordx(char *buf, char *wrd) { size_t i; char STR1[256]; @@ -589,24 +507,6 @@ static void strwordx(char *buf, char *wrd) strcpy_overlap(buf, buf + i); } - -static void getword(char *buf, char *wrd) -{ - char STR1[256]; - char STR2[256]; - - strcpy(STR1, strltrim(strrtrim(strcpy(STR2, buf)))); - strcpy(buf, STR1); - if (*buf == '"') - strwordx(buf, wrd); - else - { - strwordx(buf, wrd); - strupper(wrd, wrd); - } -} - - static long getint(char *s, long def) { char w[10]; @@ -702,7 +602,7 @@ static void getbool(char *buf, int *b) /*= =*/ /*================================================*/ -static void sortshints(short *x, short *y) +extern void sortshints(short *x, short *y) { short temp; @@ -861,14 +761,6 @@ static void checkprobe(short xx, short yy) unprobe(); } - -static void stamp(long *i) -{ - gg.curstamp++; - *i = gg.curstamp; -} - - static void send_general(log_tool *sim, char *act) { char savefunc[17]; @@ -996,7 +888,7 @@ static void send_allgates(char *act) } -static long glowcol(log_nrec *n, long def) +extern long glowcol(log_nrec *n, long def) { gg.actx = def; calltoolnode(n, act_glowcol); @@ -1004,7 +896,7 @@ static long glowcol(log_nrec *n, long def) } -static void resetmessages() +extern void resetmessages() { short opos; @@ -1070,7 +962,7 @@ static int pollkbd2() } -static void pen() +extern void pen() { #define ALERTNESS 2 /* Time to get bored (in cs) */ @@ -1385,7 +1277,7 @@ static int inbox(short x, short y, short x1, short y1) #define spacing 10 -static void message(char *msg) +extern void message(char *msg) { na_strlist_t *l1; @@ -1450,7 +1342,7 @@ static void vmessageflag(char *msg, int b) } } -static void tracemessage(char *msg) +extern void tracemessage(char *msg) { if (!gg.traceflag) return; @@ -1700,7 +1592,7 @@ static void getnodeval(log_nrec *n, double *val, char *opts) /*= =*/ /*================================================*/ -static void pass() +extern void pass() { log_grec *g, *g1, *g2; log_nrec *n, *n1, *n2; @@ -2205,10 +2097,10 @@ static void clearconflicts(log_tool *tool) } -static short getsignal (int d, char *n); +extern short getsignal (int d, char *n); -static void newattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr) +extern void newattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr) { short i; @@ -2253,7 +2145,7 @@ static void newattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr) } -static void disposeattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr) +extern void disposeattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kattr) { short i; @@ -2275,7 +2167,7 @@ static void disposeattrs(log_gattrrec **gattr, short numattrs, log_kattrrec *kat } -static void copyattrs(log_gattrrec **gattr, log_gattrrec *oldattr, short numattrs, log_kattrrec *kattr) +extern void copyattrs(log_gattrrec **gattr, log_gattrrec *oldattr, short numattrs, log_kattrrec *kattr) { short i; @@ -2364,7 +2256,7 @@ static void defsimulator(log_action_t *act) } -static log_tool *findsimtype(uchar st) +extern log_tool *findsimtype(uchar st) { char simname[17]; log_tool *stp; @@ -2527,7 +2419,7 @@ static void purgesignaltab() /*= =*/ /*================================================*/ -static void garbagecoll() +extern void garbagecoll() { log_nrec *n, *n1; log_grec *g; @@ -2596,7 +2488,7 @@ static void garbagecoll() /*= =*/ /*================================================*/ -static short getsignal(int d, char *n_) +extern short getsignal(int d, char *n_) { char n[256]; short i; @@ -2670,7 +2562,7 @@ static void getsigname(char *name, log_sigrec **sig) /*= =*/ /*================================================*/ -static void setscale(short s) +extern void setscale(short s) { zoom = s; gg.scale = zoomscales[s + 2]; @@ -2722,7 +2614,7 @@ static void setupregion(log_regrec **r, short pagenum) /*= =*/ /*================================================*/ -static char *colorname(char *Result, short c) +extern char *colorname(char *Result, short c) { if (c == log_wcol_normal) return strcpy(Result, "U"); @@ -2910,7 +2802,7 @@ static void zoomto(short z) } -static void scroll() +extern void scroll() { char ch, TEMP; @@ -3316,7 +3208,7 @@ static void assertfunc(char *name_) /*= =*/ /*================================================*/ -static void trykbd() +extern void trykbd() { long t; int moving; @@ -3433,7 +3325,7 @@ static void trykbdscroll() } -static void markcolor(log_hwrec **hw, struct LOC_wantsolder *LINK) +extern void markcolor(log_hwrec **hw, struct LOC_wantsolder *LINK) { if (*hw == NULL) return; @@ -3459,7 +3351,7 @@ static void markcolor(log_hwrec **hw, struct LOC_wantsolder *LINK) } -static void confirmsimtype(log_nrec *n) +extern void confirmsimtype(log_nrec *n) { log_grec *g; short i, pg; @@ -3509,7 +3401,7 @@ static void confirmsimtype(log_nrec *n) } -static void scancn (cnrec *cn, struct LOC_checkcombine *LINK); +extern void scancn (cnrec *cn, struct LOC_checkcombine *LINK); /* Local variables for scancn: */ struct LOC_scancn { @@ -3533,7 +3425,7 @@ static void scan(log_nrec **n, struct LOC_scancn *LINK) } } -static void scancn(cnrec *cn, struct LOC_checkcombine *LINK) +extern void scancn(cnrec *cn, struct LOC_checkcombine *LINK) { struct LOC_scancn V; @@ -3562,7 +3454,7 @@ static void frysolder(short x, short y) } -static void addblobs(blobrec **blbase, short x1, short y1, short x2, short y2) +extern void addblobs(blobrec **blbase, short x1, short y1, short x2, short y2) { blobrec *blp; log_srec *s; @@ -3584,7 +3476,7 @@ static void addblobs(blobrec **blbase, short x1, short y1, short x2, short y2) } -static void doblobs(blobrec *blp) +extern void doblobs(blobrec *blp) { log_hwrec *hw; log_vwrec *vw; @@ -3616,7 +3508,7 @@ static void doblobs(blobrec *blp) } -static void dispblobs(blobrec **blbase) +extern void dispblobs(blobrec **blbase) { blobrec *blp; @@ -4218,7 +4110,7 @@ static void changekind2(short i, short gtype, short sig, log_gattrrec *attrs) } -static void changekind(short gtype, short sig, log_gattrrec *attrs) +extern void changekind(short gtype, short sig, log_gattrrec *attrs) { short i; diff --git a/log/src/node.c b/log/src/node.c index d35e30519a7ab32b50c966c6f1849cb5845d3301..5cea13ab09e42e314f429125418d194da7c3e688 100644 --- a/log/src/node.c +++ b/log/src/node.c @@ -2,6 +2,7 @@ #include <p2c/p2c.h> #include <p2c/newkbd.h> #include "logglobals.h" +#include "utils.h" #include "node.h" /*================== ADDNODE ===================*/ @@ -10,7 +11,7 @@ /*= =*/ /*================================================*/ -static void newnptr(log_nrec **n) +void newnptr(log_nrec **n) { if (freenode == NULL) { @@ -24,7 +25,7 @@ static void newnptr(log_nrec **n) } -static void newnode(log_nrec **n, uchar st) +void newnode(log_nrec **n, uchar st) { newnptr(n); (*n)->simtype = findsimtype(st); @@ -53,7 +54,7 @@ static void newnode(log_nrec **n, uchar st) /*= =*/ /*================================================*/ -static void copynode(log_nrec *old, log_nrec **n) +void copynode(log_nrec *old, log_nrec **n) { newnptr(n); **n = *old; @@ -80,7 +81,7 @@ static void copynode(log_nrec *old, log_nrec **n) /*= =*/ /*================================================*/ -static void disposenptr(log_nrec **n) +void disposenptr(log_nrec **n) { (*n)->next = freenode; freenode = *n; @@ -90,7 +91,7 @@ static void disposenptr(log_nrec **n) #define rtn "DISPNODE" -static void disposenode(log_nrec **n) +void disposenode(log_nrec **n) { log_nrec *n1, *n2; @@ -139,7 +140,7 @@ static void disposenode(log_nrec **n) #undef rtn -static int nodeexists(log_nrec *n) +int nodeexists(log_nrec *n) { log_nrec *n1; @@ -150,14 +151,14 @@ static int nodeexists(log_nrec *n) } -static void newnoderef(log_nrec **n, uchar st, long ref) +void newnoderef(log_nrec **n, uchar st, long ref) { newnode(n, st); (*n)->ref = ref; } -static log_nrec *refnode(log_nrec *n) +log_nrec *refnode(log_nrec *n) { if (n == NULL) return n; @@ -171,7 +172,7 @@ static log_nrec *refnode(log_nrec *n) #define rtn "UNREFNODE" -static void unrefnode(log_nrec **n) +void unrefnode(log_nrec **n) { if (*n == NULL) return; @@ -191,7 +192,7 @@ static void unrefnode(log_nrec **n) #undef rtn -static void switchnode(log_nrec **n, log_nrec *n2) +void switchnode(log_nrec **n, log_nrec *n2) { if (*n != n2) { @@ -207,7 +208,7 @@ static void switchnode(log_nrec **n, log_nrec *n2) /*= =*/ /*================================================*/ -static void dumpnodes() +void dumpnodes() { log_nrec *n, *n1; log_hwrec *hw; @@ -369,7 +370,7 @@ static void dumpnodes() "\n\n-------------------------------------------------------------------------\n\n\n"); } -static void delgetnode(log_nrec **save, log_nrec **old, log_nrec **n) +void delgetnode(log_nrec **save, log_nrec **old, log_nrec **n) { /* if save <> nil then begin @@ -391,7 +392,7 @@ else /*= =*/ /*================================================*/ -static void combinenodes(log_nrec **n2, log_nrec **n1, cnrec *cnbase) +void combinenodes(log_nrec **n2, log_nrec **n1, cnrec *cnbase) { log_nrec *nn1, *nn2, *n3; log_hwrec *hw; @@ -519,7 +520,7 @@ static void combinenodes(log_nrec **n2, log_nrec **n1, cnrec *cnbase) that N2 must be assigned a node, but we don't have anything to connect to it yet. */ -static void queuecombine(cnrec **cnbase, log_nrec **n, log_nrec **n2) +void queuecombine(cnrec **cnbase, log_nrec **n, log_nrec **n2) { cnrec *cn; @@ -534,7 +535,7 @@ static void queuecombine(cnrec **cnbase, log_nrec **n, log_nrec **n2) cn->np = n2; } -static void checknode(log_nrec *n, struct LOC_checkcombine *LINK) +void checknode(log_nrec *n, struct LOC_checkcombine *LINK) { log_tool *newsimtype; char STR1[94]; @@ -542,16 +543,16 @@ static void checknode(log_nrec *n, struct LOC_checkcombine *LINK) newsimtype = n->simtype; if (newsimtype->simtype < 8) return; - + if (LINK->cursimtype->simtype < 8) { LINK->cursimtype = newsimtype; return; } - + if (LINK->cursimtype->simtype == newsimtype->simtype) return; - + if (LINK->passcount == 2) { sprintf(STR1, "Tried to connect %s signal to %s", @@ -564,7 +565,7 @@ static void checknode(log_nrec *n, struct LOC_checkcombine *LINK) /* Merge all queued nodes. If any simtype conflicts would result, don't merge any nodes. If a node doesn't have anything merged into it, make a new node. */ -static int checkcombine(cnrec **cnbase_) +int checkcombine(cnrec **cnbase_) { struct LOC_checkcombine V; cnrec *cn; @@ -587,7 +588,7 @@ static int checkcombine(cnrec **cnbase_) scancn(cn, &V); cn = cn->next; } - + if (!V.good && V.passcount == 1) { cn = *V.cnbase; @@ -598,13 +599,13 @@ static int checkcombine(cnrec **cnbase_) cn = cn->next; } } - + if (gg.traceflag && *V.cnbase != NULL) fprintf(tracefile, "Check-combine (pass %d) finds %s\n", V.passcount, V.good ? " TRUE" : "FALSE"); V.passcount++; } while (!(V.good || V.passcount > 2)); - + if (V.good) { cn = *V.cnbase; @@ -614,7 +615,7 @@ static int checkcombine(cnrec **cnbase_) cn = cn->next; } } - + while (*V.cnbase != NULL) { cn = (*V.cnbase)->next; @@ -625,7 +626,7 @@ static int checkcombine(cnrec **cnbase_) } -static int trycombinenodes(log_nrec **n1, log_nrec **n2) +int trycombinenodes(log_nrec **n1, log_nrec **n2) { cnrec *cnbase; @@ -633,5 +634,3 @@ static int trycombinenodes(log_nrec **n1, log_nrec **n2) queuecombine(&cnbase, n1, n2); return (checkcombine(&cnbase)); } - - diff --git a/log/src/page.c b/log/src/page.c index cee935b8488a47701f510f8e1c17e4f43ca6ced3..975f6d900b1a652c69dbf9050bbc697528579733 100644 --- a/log/src/page.c +++ b/log/src/page.c @@ -2,9 +2,10 @@ #include <p2c/p2c.h> #include <p2c/newkbd.h> #include "logglobals.h" +#include "utils.h" #include "page.h" -static void chpage(short pg) +void chpage(short pg) { log_regrec *r; @@ -18,7 +19,7 @@ static void chpage(short pg) } -static void chpageplace(short pg, short x1, short y1, short x2, short y2) +void chpageplace(short pg, short x1, short y1, short x2, short y2) { log_regrec *r; @@ -38,7 +39,7 @@ static void chpageplace(short pg, short x1, short y1, short x2, short y2) } -static int pageempty(int pg) +int pageempty(int pg) { return (gg.gbase[pg - 1] == NULL && gg.hwbase[pg - 1] == NULL && gg.vwbase[pg - 1] == NULL && gg.bbase[pg - 1] == NULL && @@ -46,18 +47,18 @@ static int pageempty(int pg) } -static int pagenull(short pg) +int pagenull(short pg) { return (pageempty(pg) && gg.pageregions[pg - 1] == NULL); } -static int pagechanged(short pg) +int pagechanged(short pg) { return (gg.pagechanged[pg - 1] && !pageempty(pg)); } -static int anychanged() +int anychanged() { short i; @@ -73,7 +74,7 @@ static int anychanged() /*= =*/ /*================================================*/ -static void newpage(short p) +void newpage(short p) { short i; diff --git a/log/src/screen.c b/log/src/screen.c index bbdc6e51c708be2ad0ca46857c80f3ed3f4096c0..01dfcb80804cc89e5841b320f94daeea73af835e 100644 --- a/log/src/screen.c +++ b/log/src/screen.c @@ -35,6 +35,7 @@ #include <p2c/newcrt.h> #include "logglobals.h" #include "logfont.h" +#include "utils.h" #include "screen.h" /*================= INITSCREEN =================*/ @@ -44,7 +45,7 @@ /*= =*/ /*================================================*/ -static void initcolormap() +void initcolormap() { m_setcolor((long)log_gray, 4L, 4L, 4L); m_setcolor((long)log_red, 15L, 0L, 0L); @@ -71,7 +72,7 @@ static void initcolormap() } -static void fixcolormap() +void fixcolormap() { m_vsetcolors(0L, 16L, rcolormap, gcolormap, bcolormap); recolor_log_cursors(gg.color.cursor, true); @@ -79,7 +80,7 @@ static void fixcolormap() -static void initscreen() +void initscreen() { m_init_screen(); m_upside_down(); @@ -114,7 +115,7 @@ static void initscreen() } -static void initscreen2() +void initscreen2() { initscreen(); m_clear(); @@ -127,7 +128,7 @@ static void initscreen2() /*= =*/ /*================================================*/ -static void noblink() +void noblink() { nc_cursXY(-1, -1); /* oldx := xpos; @@ -140,7 +141,7 @@ ypos := oldy; */ } -static void clearalpha() +void clearalpha() { if (!onescreen) { @@ -152,7 +153,7 @@ static void clearalpha() } -static void showalpha() +void showalpha() { m_graphics_off(); m_alpha_on(); @@ -164,7 +165,7 @@ static void showalpha() /*= =*/ /*================================================*/ -static void line(short x1, short y1, short x2, short y2) +void line(short x1, short y1, short x2, short y2) { m_drawline(x1 * gg.scale - gg.xoff, y1 * gg.scale - gg.yoff, x2 * gg.scale - gg.xoff, y2 * gg.scale - gg.yoff); @@ -178,7 +179,7 @@ static void line(short x1, short y1, short x2, short y2) /*= =*/ /*================================================*/ -static void hline(short x1, short x2, short y) +void hline(short x1, short x2, short y) { short yy; @@ -194,7 +195,7 @@ static void hline(short x1, short x2, short y) /*= =*/ /*================================================*/ -static void vline(short x, short y1, short y2) +void vline(short x, short y1, short y2) { short xx; @@ -210,7 +211,7 @@ static void vline(short x, short y1, short y2) /*= =*/ /*================================================*/ -static void point(short x, short y) +void point(short x, short y) { m_drawpoint(x * gg.scale - gg.xoff, y * gg.scale - gg.yoff); } @@ -222,7 +223,7 @@ static void point(short x, short y) /*= =*/ /*================================================*/ -static void rect(short x1, short y1, short x2, short y2) +void rect(short x1, short y1, short x2, short y2) { m_drawrect(x1 * gg.scale - gg.xoff, y1 * gg.scale - gg.yoff, x2 * gg.scale - gg.xoff, y2 * gg.scale - gg.yoff); @@ -234,7 +235,7 @@ static void rect(short x1, short y1, short x2, short y2) /*= =*/ /*================================================*/ -static void box(short x1, short y1, short x2, short y2) +void box(short x1, short y1, short x2, short y2) { m_fillrect(x1 * gg.scale - gg.xoff, y1 * gg.scale - gg.yoff, x2 * gg.scale - gg.xoff, y2 * gg.scale - gg.yoff); @@ -246,7 +247,7 @@ static void box(short x1, short y1, short x2, short y2) /*= =*/ /*================================================*/ -static void drawstr2(short x, short y, char *s) +void drawstr2(short x, short y, char *s) { long save; @@ -262,7 +263,7 @@ static void drawstr2(short x, short y, char *s) } -static void rightstr2(short x, short y, char *s) +void rightstr2(short x, short y, char *s) { long save; @@ -277,7 +278,7 @@ static void rightstr2(short x, short y, char *s) } -static void centerstr2(short x, short y, char *s) +void centerstr2(short x, short y, char *s) { short w; long save; @@ -301,7 +302,7 @@ static void centerstr2(short x, short y, char *s) /*= =*/ /*================================================*/ -static void drawnum1(short x, short y, short n) +void drawnum1(short x, short y, short n) { char s[2]; @@ -319,7 +320,7 @@ static void drawnum1(short x, short y, short n) /*= =*/ /*================================================*/ -static void drawnum2(short x, short y, short n) +void drawnum2(short x, short y, short n) { char s[3]; @@ -332,7 +333,7 @@ static void drawnum2(short x, short y, short n) } -static void xformcoords(log_grec *g, short *x, short *y) +void xformcoords(log_grec *g, short *x, short *y) { short xx, yy; @@ -351,7 +352,7 @@ static void xformcoords(log_grec *g, short *x, short *y) } -static void plainxformcoords(log_grec *g, short *x, short *y) +void plainxformcoords(log_grec *g, short *x, short *y) { short xx; @@ -373,7 +374,7 @@ static void plainxformcoords(log_grec *g, short *x, short *y) /*= =*/ /*================================================*/ -static void clipon() +void clipon() { m_clip(0L, 0L, (long)across, baseline - 1L); } @@ -385,7 +386,7 @@ static void clipon() /*= =*/ /*================================================*/ -static void clipoff() +void clipoff() { m_noclip(); } @@ -397,7 +398,7 @@ static void clipoff() /*= =*/ /*================================================*/ -static void uerase(short x1, short y1, short x2, short y2) +void uerase(short x1, short y1, short x2, short y2) { m_color((long)gg.color.backgr); m_fillrect((long)x1, (long)y1, (long)x2, (long)y2); @@ -411,7 +412,7 @@ static void uerase(short x1, short y1, short x2, short y2) /*= =*/ /*================================================*/ -static void erase(short x1, short y1, short x2, short y2) +void erase(short x1, short y1, short x2, short y2) { m_color((long)gg.color.backgr); box(x1, y1, x2, y2); @@ -425,7 +426,7 @@ static void erase(short x1, short y1, short x2, short y2) /*= =*/ /*================================================*/ -static void norabbits() +void norabbits() { short i; @@ -448,7 +449,7 @@ static void norabbits() /*= =*/ /*================================================*/ -static void addrabbit() +void addrabbit() { short i, j, rx, ry; int nogood; @@ -502,7 +503,7 @@ static void addrabbit() /*= =*/ /*================================================*/ -static int hvline(short x1, short y1, short *x2, short *y2) +int hvline(short x1, short y1, short *x2, short *y2) { int Result; @@ -530,7 +531,7 @@ static int hvline(short x1, short y1, short *x2, short *y2) /*= =*/ /*================================================*/ -static void fixxy(short *x, short *y) +void fixxy(short *x, short *y) { *x = (*x + gg.xoff + gg.hscale) / gg.scale * gg.scale - gg.xoff; *y = (*y + gg.yoff + gg.hscale) / gg.scale * gg.scale - gg.yoff; @@ -543,7 +544,7 @@ static void fixxy(short *x, short *y) /*= =*/ /*================================================*/ -static void nocrosshair() +void nocrosshair() { chairflag2 = false; } @@ -556,7 +557,7 @@ static void nocrosshair() /*= =*/ /*================================================*/ -static void crosshair(short x, short y) +void crosshair(short x, short y) { chairx = x * gg.scale - gg.xoff; chairy = y * gg.scale - gg.yoff; @@ -583,7 +584,7 @@ static void crosshair(short x, short y) /*= =*/ /*================================================*/ -static void xorcursor() +void xorcursor() { long curcm; short cx0, cy0; @@ -694,14 +695,14 @@ static void xorcursor() /*= =*/ /*================================================*/ -static void hidecursor() +void hidecursor() { if (cursorflag) xorcursor(); } -static void hidecursor_hook() +void hidecursor_hook() { if (!cursorhide) hidecursor(); @@ -709,7 +710,7 @@ static void hidecursor_hook() } -static void unhidecursor_hook() +void unhidecursor_hook() { if (cursorhide) hidecursor(); @@ -717,7 +718,7 @@ static void unhidecursor_hook() } -static void hidecursorrect_hook(long x1, long y1, long x2, long y2) +void hidecursorrect_hook(long x1, long y1, long x2, long y2) { if (!cursorhide && x1 <= gg.cx_max && x2 >= gg.cx_min && y1 <= gg.cy_max && y2 >= gg.cy_min) @@ -732,7 +733,7 @@ static void hidecursorrect_hook(long x1, long y1, long x2, long y2) /*= =*/ /*================================================*/ -static void drawcursor(short x, short y) +void drawcursor(short x, short y) { if (x != cursx || y != cursy || !cursorflag || cursortype != oldcursortype) { @@ -769,7 +770,7 @@ static void drawcursor(short x, short y) /*= =*/ /*================================================*/ -static void remcursor() +void remcursor() { prevcursorflag = cursorflag; if (cursorflag) @@ -786,7 +787,7 @@ static void remcursor() /*= =*/ /*================================================*/ -static void restorecursor() +void restorecursor() { if (prevcursorflag != cursorflag) xorcursor(); @@ -799,7 +800,7 @@ static void restorecursor() /*= =*/ /*================================================*/ -static void clearscreen() +void clearscreen() { remcursor(); m_noclip(); @@ -814,7 +815,7 @@ static void clearscreen() } -static void clearshowalpha() +void clearshowalpha() { if (onescreen) clearscreen(); @@ -831,7 +832,7 @@ static void clearshowalpha() /*= =*/ /*================================================*/ -static void drawvector2(log_vectorrec *v, long x1, long y1, long x2, long y2) +void drawvector2(log_vectorrec *v, long x1, long y1, long x2, long y2) { long diam, savecol, coord; @@ -931,7 +932,7 @@ static void drawvector2(log_vectorrec *v, long x1, long y1, long x2, long y2) } -static void drawvector4(log_vectorrec *v, long x1, long y1, long x2, long y2, long x3, long y3, long x4, long y4) +void drawvector4(log_vectorrec *v, long x1, long y1, long x2, long y2, long x3, long y3, long x4, long y4) { long xarr[4], yarr[4]; @@ -961,7 +962,7 @@ static void drawvector4(log_vectorrec *v, long x1, long y1, long x2, long y2, lo #define big2 "0.,\000123-456\000789 " -static void drawtext(log_vectorrec *v, long scale, long rot, long xx, long yy) +void drawtext(log_vectorrec *v, long scale, long rot, long xx, long yy) { long sc, i, j, tx, ty; char mode; @@ -1142,7 +1143,7 @@ static void drawtext(log_vectorrec *v, long scale, long rot, long xx, long yy) #undef big2 -static void plaindrawgatec(short x, short y, short g, short c) +void plaindrawgatec(short x, short y, short g, short c) { short i, z, rxx, rxy, ryx, ryy; log_krec *k; @@ -1313,7 +1314,7 @@ static void plaindrawgatec(short x, short y, short g, short c) } -static void udrawgatec(short x, short y, short g, short c) +void udrawgatec(short x, short y, short g, short c) { short i, z, rxx, rxy, ryx, ryy; log_krec *k; @@ -1430,7 +1431,7 @@ static void udrawgatec(short x, short y, short g, short c) /*= =*/ /*================================================*/ -static void drawgatedotsc(short x, short y, short g, short c) +void drawgatedotsc(short x, short y, short g, short c) { short i, z, rxx, rxy, ryx, ryy; log_krec *WITH; @@ -1460,7 +1461,7 @@ static void drawgatedotsc(short x, short y, short g, short c) } -static void drawgatec(short x, short y, short g, short c) +void drawgatec(short x, short y, short g, short c) { short i, xx, yy, z, rxx, rxy, ryx, ryy; long savecol; @@ -1615,7 +1616,7 @@ static void drawgatec(short x, short y, short g, short c) } -static void signallabel(short x, short y, short gtype, short sig, short c) +void signallabel(short x, short y, short gtype, short sig, short c) { log_krec *k; char STR1[256]; @@ -1634,7 +1635,7 @@ static void signallabel(short x, short y, short gtype, short sig, short c) } -static void gsignallabel(short x, short y, log_grec *g, short c) +void gsignallabel(short x, short y, log_grec *g, short c) { signallabel((int)(x * gg.scale - gg.xoff), (int)(y * gg.scale - gg.yoff), g->g, g->sig, c); @@ -1643,7 +1644,7 @@ static void gsignallabel(short x, short y, log_grec *g, short c) typedef enum {inside,north,east,south,west} placement; -static void drawpnums(log_grec *g, short c) +void drawpnums(log_grec *g, short c) { short rxx, rxy, ryx, ryy, i, j, k; char s[7]; @@ -1726,10 +1727,10 @@ static void drawpnums(log_grec *g, short c) #undef totab -static void setscale (short s); +void setscale (short s); -static void kdrawgatec(short i, short c) +void kdrawgatec(short i, short c) { short x, y; short ozoom = zoom; @@ -1751,7 +1752,7 @@ static void kdrawgatec(short i, short c) /*= =*/ /*================================================*/ -static void drawgatexc(log_grec *g, short c) +void drawgatexc(log_grec *g, short c) { if (g->dimcolor && c == gg.color.gate) c = gg.color.dimgate; @@ -1763,13 +1764,13 @@ static void drawgatexc(log_grec *g, short c) } -static void drawgatex(log_grec *g) +void drawgatex(log_grec *g) { drawgatexc(g, gg.color.gate); } -static void setdimgate(log_grec *g, int dim) +void setdimgate(log_grec *g, int dim) { log_grec *g1; @@ -1796,7 +1797,7 @@ static void setdimgate(log_grec *g, int dim) /*= =*/ /*================================================*/ -static void drawsolderc(short x, short y, short c) +void drawsolderc(short x, short y, short c) { if (!showsolder) return; @@ -1832,7 +1833,7 @@ static void drawsolderc(short x, short y, short c) /*= =*/ /*================================================*/ -static void drawtransc(short x, short y, short c) +void drawtransc(short x, short y, short c) { if (!vlsi) return; @@ -1851,7 +1852,7 @@ static void drawtransc(short x, short y, short c) /*= =*/ /*================================================*/ -static void drawboxc0(short x1, short y1, short x2, short y2, short c) +void drawboxc0(short x1, short y1, short x2, short y2, short c) { m_color((long)c); m_linestyle(1L); @@ -1860,7 +1861,7 @@ static void drawboxc0(short x1, short y1, short x2, short y2, short c) } -static void drawboxc(log_brec *b, short c) +void drawboxc(log_brec *b, short c) { drawboxc0(b->x1, b->y1, b->x2, b->y2, c); } @@ -1872,7 +1873,7 @@ static void drawboxc(log_brec *b, short c) /*= =*/ /*================================================*/ -static void drawmarkersc(short c) +void drawmarkersc(short c) { clipon(); m_color((long)c); @@ -1891,7 +1892,7 @@ static void drawmarkersc(short c) /*= =*/ /*================================================*/ -static void drawnodec(log_nrec *n, short c) +void drawnodec(log_nrec *n, short c) { log_hwrec *hw; log_vwrec *vw; @@ -1970,7 +1971,7 @@ static void drawnodec(log_nrec *n, short c) /*= =*/ /*================================================*/ -static void drawnode(log_nrec *n) +void drawnode(log_nrec *n) { drawnodec(n, -1); } @@ -1981,10 +1982,10 @@ static void drawnode(log_nrec *n) /*= =*/ /*================================================*/ -static int pageempty (int pg); +int pageempty (int pg); -static void refrpagedisp() +void refrpagedisp() { short num; @@ -2008,7 +2009,7 @@ static void refrpagedisp() /*= =*/ /*================================================*/ -static void refreditmode() +void refreditmode() { hidecursor(); m_color((long)gg.color.backgr); @@ -2047,7 +2048,7 @@ static void refreditmode() /*= =*/ /*================================================*/ -static void refrbaseline(int always) +void refrbaseline(int always) { short c; @@ -2078,7 +2079,7 @@ static void refrbaseline(int always) /*= =*/ /*================================================*/ -static void refresh() +void refresh() { long x1, y1, x2, y2; log_grec *g; @@ -2259,7 +2260,7 @@ static void refresh() /*= =*/ /*================================================*/ -static void refreshsoon() +void refreshsoon() { refrtimer0 = refrdelay; refrtimer = refrdelay; @@ -2272,7 +2273,7 @@ static void refreshsoon() /*= =*/ /*================================================*/ -static void refrmenu() +void refrmenu() { short i, FORLIM; @@ -2302,7 +2303,7 @@ static void refrmenu() } -static void beginbottom() +void beginbottom() { remcursor(); clipoff(); @@ -2319,7 +2320,7 @@ static void beginbottom() } -static void endbottom() +void endbottom() { remcursor(); bottomcount--; @@ -2344,7 +2345,7 @@ static void endbottom() /*= =*/ /*================================================*/ -static void refrscreen1() +void refrscreen1() { m_colormode((long)m_normal); m_noclip(); @@ -2362,7 +2363,7 @@ static void refrscreen1() /*= =*/ /*================================================*/ -static void refrscreen() +void refrscreen() { gg.showpage = gg.curpage; bottomcount = 0; @@ -2375,7 +2376,7 @@ static void refrscreen() m_graphics_on(); } -static void resize_screen() +void resize_screen() { initscreen2(); initscreen(); @@ -2388,7 +2389,7 @@ static void resize_screen() /*= =*/ /*================================================*/ -static void showcatalog() +void showcatalog() { short i; catboxrec *cb; diff --git a/log/src/tool.c b/log/src/tool.c index 5e2df6d18c3ce673460e5a0315f5411057728d01..66145bfe646f119483275d19f746c8a2969fcbfa 100644 --- a/log/src/tool.c +++ b/log/src/tool.c @@ -3,8 +3,9 @@ #include <p2c/newkbd.h> #include "logdef.h" #include "logglobals.h" +#include "utils.h" -static void newtool(log_tool **t, char *name) +void newtool(log_tool **t, char *name) { log_tool *t2; @@ -35,7 +36,7 @@ static void newtool(log_tool **t, char *name) } -static log_tool *findtool(char *name_) +log_tool *findtool(char *name_) { log_tool *Result; char name[17]; @@ -123,7 +124,7 @@ static log_tool *findtool(char *name_) } -static void calltool(log_tool *t, log_actionkinds act) +void calltool(log_tool *t, log_actionkinds act) { log_tool *savetool; @@ -135,26 +136,26 @@ static void calltool(log_tool *t, log_actionkinds act) } -static void calltoolgate(log_grec *g, log_actionkinds act) +void calltoolgate(log_grec *g, log_actionkinds act) { gg.actgate = g; calltool(g->kind->simtype, act); } -static void calltoolnode(log_nrec *n, log_actionkinds act) +void calltoolnode(log_nrec *n, log_actionkinds act) { gg.actnode = n; calltool(n->simtype, act); } -static void calltoolkind(log_krec *k, log_actionkinds act) +void calltoolkind(log_krec *k, log_actionkinds act) { gg.actkind = k; calltool(k->simtype, act); } -static void calltools(log_actionkinds act) +void calltools(log_actionkinds act) { log_tool *tp; @@ -168,7 +169,7 @@ static void calltools(log_actionkinds act) } -static void callsimtools(log_actionkinds act) +void callsimtools(log_actionkinds act) { log_tool *tp; @@ -181,7 +182,7 @@ static void callsimtools(log_actionkinds act) } } -static void closetool(log_tool *tp) +void closetool(log_tool *tp) { if (tp->ready) calltool(tp, act_exit); @@ -189,7 +190,7 @@ static void closetool(log_tool *tp) } -static void closetools() +void closetools() { log_tool *tp; diff --git a/log/src/utils.c b/log/src/utils.c new file mode 100644 index 0000000000000000000000000000000000000000..88b6946831e8eef9d9487bcbb15d6d8695c2f614 --- /dev/null +++ b/log/src/utils.c @@ -0,0 +1,120 @@ +#include <p2c/p2c.h> +#include <stdlib.h> +#include <ctype.h> +#include <string.h> +#include "logglobals.h" +#include "utils.h" + +/** + * Reserved for future use. + */ +void working() +{ +} + +void getword(char *buf, char *wrd) +{ + char STR1[256]; + char STR2[256]; + + strcpy(STR1, strltrim(strrtrim(strcpy(STR2, buf)))); + strcpy(buf, STR1); + if (*buf == '"') + strwordx(buf, wrd); + else + { + strwordx(buf, wrd); + strupper(wrd, wrd); + } +} + +/* char *strcpy_overlap(char *dst, char *src) */ +/* { */ +/* size_t i = 0; */ + +/* do { */ +/* dst[i] = src[i]; */ +/* if (src[i++] == '\0') */ +/* break; */ +/* } while (1); */ +/* return dst; */ +/* } */ + + +void stamp(long *i) +{ + gg.curstamp++; + *i = gg.curstamp; +} + +void dounits(char *s, double *r) +{ + char ch; + + if (*s == '\0') + return; + ch = s[0]; + if (ch >= 'a') + ch -= 32; + if (ch == 'F') + { + *r *= 1e-15; + return; + } + if (ch == 'P') + { + *r *= 1e-12; + return; + } + if (ch == 'N') + { + *r *= 1e-9; + return; + } + if (ch == 'U') + { + *r *= 1e-6; + return; + } + if (ch == 'K') + { + *r *= 1e3; + return; + } + if (ch == 'G') + { + *r *= 1e9; + return; + } + if (ch == 'T') + { + *r *= 1e12; + return; + } + if (ch != 'M') + return; + if (strlen(s) >= 3 && (s[1] == 'E' || s[1] == 'e') && + (s[2] == 'G' || s[2] == 'g')) + *r *= 1e6; + else + *r *= 1e-3; +} + + +void readreal(char s_[], double *r) +{ + char s[256]; + long i; + char *STR1; + char STR2[256]; + + strcpy(s, s_); + if (!(*s != '\0' && (s[0] == '.' || s[0] == '+' || s[0] == '-' || isdigit(s[0])))) + return; + *r = strtod(s, &STR1); + i = STR1 - s + 1; + strcpy_overlap(s, s + i - 1); + strcpy(STR2, strltrim(s)); + strcpy(s, STR2); + dounits(s, r); +} diff --git a/log/src/wire.c b/log/src/wire.c index abb3d304e03a70ce8d47a77417cbb7d5ce19ce7b..3ed485c16bcc9aec655304825d320b837e7ffc9a 100644 --- a/log/src/wire.c +++ b/log/src/wire.c @@ -3,10 +3,11 @@ #include <p2c/newkbd.h> #include "logglobals.h" #include "logdef.h" +#include "utils.h" #include "wire.h" -static void fryhwire(log_hwrec *hw); -static void fryvwire(log_vwrec *vw); +void fryhwire(log_hwrec *hw); +void fryvwire(log_vwrec *vw); /*=================== NEWHW ====================*/ /*= =*/ @@ -14,7 +15,7 @@ static void fryvwire(log_vwrec *vw); /*= =*/ /*================================================*/ -static void newhw(log_hwrec **hw) +void newhw(log_hwrec **hw) { *hw = (log_hwrec *)Malloc(sizeof(log_hwrec)); (*hw)->next = gg.hwbase[gg.curpage - 1]; @@ -32,7 +33,7 @@ static void newhw(log_hwrec **hw) /*= =*/ /*================================================*/ -static void disphw(log_hwrec **hw) +void disphw(log_hwrec **hw) { log_hwrec *hw1; @@ -67,7 +68,7 @@ static void disphw(log_hwrec **hw) /*= =*/ /*================================================*/ -static void newvw(log_vwrec **vw) +void newvw(log_vwrec **vw) { *vw = (log_vwrec *)Malloc(sizeof(log_vwrec)); (*vw)->next = gg.vwbase[gg.curpage - 1]; @@ -85,7 +86,7 @@ static void newvw(log_vwrec **vw) /*= =*/ /*================================================*/ -static void dispvw(log_vwrec **vw) +void dispvw(log_vwrec **vw) { log_vwrec *vw1; @@ -119,7 +120,7 @@ static void dispvw(log_vwrec **vw) /*= =*/ /*================================================*/ -static void newsolder(log_srec **s) +void newsolder(log_srec **s) { *s = (log_srec *)Malloc(sizeof(log_srec)); (*s)->next = gg.sbase[gg.curpage - 1]; @@ -141,7 +142,7 @@ static void newsolder(log_srec **s) /*= =*/ /*================================================*/ -static void dispsolder(log_srec **s) +void dispsolder(log_srec **s) { log_srec *s1; @@ -176,7 +177,7 @@ static void dispsolder(log_srec **s) /*= =*/ /*================================================*/ -static void closerwire(short x, short y) +void closerwire(short x, short y) { if (gg.invisible || gg.showconflicts) { @@ -205,7 +206,7 @@ static void closerwire(short x, short y) /*= =*/ /*================================================*/ -static void addsolder(short x, short y, log_hwrec *hw, log_hwrec *hw2, log_vwrec *vw, log_vwrec *vw2) +void addsolder(short x, short y, log_hwrec *hw, log_hwrec *hw2, log_vwrec *vw, log_vwrec *vw2) { log_srec *s; log_nrec *n; @@ -279,7 +280,7 @@ static void addsolder(short x, short y, log_hwrec *hw, log_hwrec *hw2, log_vwrec /*= =*/ /*================================================*/ -static log_srec *findsolder(short x, short y) +log_srec *findsolder(short x, short y) { log_srec *s; @@ -297,7 +298,7 @@ static log_srec *findsolder(short x, short y) /*= =*/ /*================================================*/ -static void addsoldert(log_hwrec *hw, log_vwrec *vw) +void addsoldert(log_hwrec *hw, log_vwrec *vw) { if (hw->x1 == vw->x && hw->y != vw->y1 && hw->y != vw->y2) { @@ -322,15 +323,15 @@ static void addsoldert(log_hwrec *hw, log_vwrec *vw) /*= =*/ /*================================================*/ -static void chggate (log_grec *g, int i, log_nrec *oldnode, log_nrec *n); +void chggate (log_grec *g, int i, log_nrec *oldnode, log_nrec *n); -static void chgvw (log_vwrec *vw, log_nrec *oldnode, log_nrec *n); +void chgvw (log_vwrec *vw, log_nrec *oldnode, log_nrec *n); #define rtn "CHGHW" -static void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) +void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) { log_vwrec *vw; log_hwrec *hw1; @@ -398,7 +399,7 @@ static void chghw(log_hwrec *hw, log_nrec *oldnode, log_nrec *n) #define rtn "CHGVW" -static void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) +void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) { log_hwrec *hw; log_vwrec *vw1; @@ -465,7 +466,7 @@ static void chgvw(log_vwrec *vw, log_nrec *oldnode, log_nrec *n) /*= =*/ /*================================================*/ -static int wantsolder(log_srec *s) +int wantsolder(log_srec *s) { struct LOC_wantsolder V; @@ -480,7 +481,7 @@ static int wantsolder(log_srec *s) return (V.hasblue && (V.hasgreen || V.hasyellow || V.hasred)); } -static void delhwire(log_hwrec *hw) +void delhwire(log_hwrec *hw) { log_vwrec *vw; log_hwrec *hw1; @@ -574,7 +575,7 @@ static void delhwire(log_hwrec *hw) } -static void delvwire(log_vwrec *vw) +void delvwire(log_vwrec *vw) { log_hwrec *hw; log_vwrec *vw1; @@ -683,7 +684,7 @@ static void delvwire(log_vwrec *vw) /*= =*/ /*================================================*/ -static void addhwire(short x1, short x2, short y, short colr) +void addhwire(short x1, short x2, short y, short colr) { cnrec *cnbase; log_hwrec *hw, *hw1, *hw2; @@ -818,7 +819,7 @@ _L1: #undef rtn -static void addhwire2(short x1, short x2, short y) +void addhwire2(short x1, short x2, short y) { addhwire(x1, x2, y, log_wcol_normal); } @@ -827,7 +828,7 @@ static void addhwire2(short x1, short x2, short y) #define rtn "ADDHWIRE" -static void addvwire(short x, short y1, short y2, short colr) +void addvwire(short x, short y1, short y2, short colr) { cnrec *cnbase; log_vwrec *vw, *vw1, *vw2; @@ -963,12 +964,12 @@ _L1: #undef rtn -static void addvwire2(short x, short y1, short y2) +void addvwire2(short x, short y1, short y2) { addvwire(x, y1, y2, log_wcol_normal); } -static void fryhwire(log_hwrec *hw) +void fryhwire(log_hwrec *hw) { long t0; @@ -987,7 +988,7 @@ static void fryhwire(log_hwrec *hw) } -static void fryvwire(log_vwrec *vw) +void fryvwire(log_vwrec *vw) { long t0;