Browse Source

winmain.c, etc, whitespace cleanup

pre-master-46
rlar 9 years ago
parent
commit
90a205d36d
  1. 48
      src/frontend/wdisp/windisp.c
  2. 5
      src/include/ngspice/wstdio.h
  3. 102
      src/winmain.c
  4. 2
      src/winmain.h

48
src/frontend/wdisp/windisp.c

@ -41,6 +41,7 @@ typedef struct { /* Extra window data */
int FirstFlag; /* 1 before first update */
} tWindowData;
typedef tWindowData *tpWindowData; /* pointer to it */
#define pWindowData(g) ((tpWindowData)(g->devdep))
/* forwards */
@ -48,6 +49,7 @@ LRESULT CALLBACK PlotWindowProc( HWND hwnd, /* window procedure */
UINT uMsg, WPARAM wParam, LPARAM lParam);
void WPRINT_PrintInit(HWND hwnd); /* Windows printer init */
void WaitForIdle(void); /* wait until no more events */
static void WIN_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy);
static LRESULT HcpyPlot(HWND hwnd);
static LRESULT HcpyPlotBW(HWND hwnd);
@ -55,6 +57,7 @@ static LRESULT PrintPlot( HWND hwnd);
static LRESULT PrintInit(HWND hwnd);
//static void RealClose(void);
/* externals */
extern HINSTANCE hInst; /* application instance */
extern int WinLineWidth; /* width of text window */
extern HWND swString; /* string input window of main window */
@ -65,6 +68,7 @@ extern void com_hardcopy(wordlist *wl);
/* defines */
#define RAD_TO_DEG (180.0 / M_PI)
#ifndef M_LN10
#define M_LN10 2.30258509299404568402
#endif
@ -122,6 +126,7 @@ int WIN_Init(void)
if (cieq(colorstring, "white")) isblack = FALSE;
else isblack = TRUE;
}
/* get linewidth information from spinit */
if (!cp_getvar("xbrushwidth", CP_NUM, &linewidth))
linewidth = 0;
@ -157,11 +162,13 @@ int WIN_Init(void)
ColorTable[9] = RGB(128, 64, 0); /* brown */
ColorTable[10] = RGB(128, 0, 255); /* light violett */
ColorTable[11] = RGB(255, 128, 128); /* pink */
/* 2. color bank (with different line style */
if (isblack)
ColorTable[12] = RGB(255, 255, 255); /* white */
else
ColorTable[12] = RGB( 0, 0, 0); /* black */
ColorTable[13] = RGB( 0, 255, 0); /* green */
ColorTable[14] = RGB(255, 0, 0); /* red */
ColorTable[15] = RGB( 0, 0, 255); /* blue */
@ -183,13 +190,16 @@ int WIN_Init(void)
TheWndClass.style = CS_OWNDC | CS_HREDRAW | CS_VREDRAW;
TheWndClass.lpszMenuName = NULL;
TheWndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
if (isblack)
TheWndClass.hbrBackground = GetStockObject(BLACK_BRUSH);
else
TheWndClass.hbrBackground = GetStockObject(WHITE_BRUSH);
TheWndClass.hIcon = LoadIcon(hInst, MAKEINTRESOURCE(2));
TheWndClass.cbClsExtra = 0;
TheWndClass.cbWndExtra = sizeof(GRAPH *);
if (!RegisterClass(&TheWndClass)) return 1;
}
/* not first time */
@ -215,6 +225,7 @@ int WIN_Init(void)
return (0);
}
/* get pointer to graph */
/* (attach to window) */
static GRAPH *pGraph(HWND hwnd)
@ -222,6 +233,7 @@ static GRAPH * pGraph( HWND hwnd)
return (GRAPH *) GetWindowLongPtr(hwnd, 0);
}
/* return line style for plotting */
static int LType(int ColorIndex)
{
@ -231,6 +243,7 @@ static int LType( int ColorIndex)
return PS_SOLID;
}
/* postscript hardcopy from a plot window */
/* called by SystemMenue / Postscript hardcopy */
static LRESULT HcpyPlot(HWND hwnd)
@ -242,6 +255,7 @@ static LRESULT HcpyPlot( HWND hwnd)
return 0;
}
static LRESULT HcpyPlotBW(HWND hwnd)
{
int bgcolor;
@ -299,6 +313,7 @@ PrintEND:
return 0;
}
/* initialze printer */
static LRESULT PrintInit(HWND hwnd)
{
@ -307,6 +322,7 @@ static LRESULT PrintInit( HWND hwnd)
return 0;
}
/* window procedure */
LRESULT CALLBACK PlotWindowProc(HWND hwnd,
UINT uMsg, WPARAM wParam, LPARAM lParam)
@ -464,6 +480,7 @@ LRESULT CALLBACK PlotWindowProc( HWND hwnd,
WIN_ScreentoData(gr, x0, y0, &fx0, &fy0);
}
goto WIN_DEFAULT;
/* get final coordinates upon right mouse button up */
/* copy xlimit, ylimit command into buf */
/* start plot loop with argument buf */
@ -592,6 +609,7 @@ int WIN_NewViewport( GRAPH * graph)
/* allocate device dependency info */
wd = calloc(1, sizeof(tWindowData));
if (!wd) return 1;
graph->devdep = wd;
/* Create the window */
@ -666,6 +684,7 @@ int WIN_NewViewport( GRAPH * graph)
return(0);
}
/******************************************************************************
WIN_Close is essentially the counterpart to WIN_Init. unfortunately it might
happen, that WIN_Close is called during plotting, because one wants to switch
@ -677,6 +696,8 @@ int WIN_Close(void)
{
return (0);
}
/*
static void RealClose(void)
{
@ -691,10 +712,14 @@ static void RealClose(void)
}
}
*/
int WIN_Clear(void)
{
tpWindowData wd;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -713,6 +738,7 @@ int WIN_DrawLine(int x1, int y1, int x2, int y2)
HPEN NewPen;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -746,6 +772,7 @@ int WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta)
double dy0;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -781,11 +808,15 @@ int WIN_Arc(int x0, int y0, int radius, double theta, double delta_theta)
return 0;
}
/*
int WIN_Text_old(char * text, int x, int y, int degrees)
{
tpWindowData wd;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -796,6 +827,7 @@ int WIN_Text_old( char * text, int x, int y, int degrees)
}
*/
int WIN_Text(char * text, int x, int y)
{
tpWindowData wd;
@ -805,6 +837,7 @@ int WIN_Text( char * text, int x, int y)
int CentiDegrees = 0;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -826,6 +859,7 @@ int WIN_Text( char * text, int x, int y)
if (!cp_getvar("wfont", CP_STRING, lf.lfFaceName)) {
(void) lstrcpy(lf.lfFaceName, DEF_FONTW);
}
if (!cp_getvar("wfont_size", CP_NUM, &(lf.lfHeight))) {
lf.lfHeight = (int) (1.1 * currentgraph->fontheight);
}
@ -854,6 +888,7 @@ int WIN_DefineColor(int colorid, double red, double green, double blue)
return (0);
}
int WIN_DefineLinestyle(int num, int mask)
{
/* nothing */
@ -862,6 +897,7 @@ int WIN_DefineLinestyle(int num, int mask)
return (0);
}
int WIN_SetLinestyle(int style)
{
/* nothing */
@ -869,10 +905,13 @@ int WIN_SetLinestyle(int style)
return (0);
}
int WIN_SetColor(int color)
{
tpWindowData wd;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -881,10 +920,13 @@ int WIN_SetColor( int color)
return (0);
}
int WIN_Update(void)
{
tpWindowData wd;
if (!currentgraph) return 0;
wd = pWindowData(currentgraph);
if (!wd) return 0;
@ -894,20 +936,26 @@ int WIN_Update(void)
wd->FirstFlag = 0;
return 0;
}
/*
int WIN_DiagramReady(void)
{
return 0;
}
*/
void RemoveWindow(GRAPH* dgraph)
{
tpWindowData wd;
wd = pWindowData(dgraph);
if (wd)
SendMessage(wd->wnd, WM_CLOSE, (WPARAM) wd->hDC, 0);
}
/* Function borrowed from x11.c */
static void WIN_ScreentoData(GRAPH *graph, int x, int y, double *fx, double *fy)
{

5
src/include/ngspice/wstdio.h

@ -5,6 +5,7 @@
#ifndef ngspice_WSTDIO_H
#define ngspice_WSTDIO_H
#include <stdio.h> /* original definitions */
#undef getc /* old macros removed */
@ -42,6 +43,7 @@ int win_x_vfprintf(FILE * stream, const char * format, void * arglist);
/* int win_x_vfscanf(FILE *stream, const char *format, void *arglist); */
int win_x_vprintf(const char *format, void *arglist);
/* int win_x_vscanf(const char *format, void *arglist); */
#ifdef _MSC_VER
#if _MSC_VER < 1500
/* VC++ 6.0, VC++ 2005 */
@ -53,6 +55,7 @@ _CRTIMP int __cdecl read(int fd, _Out_bytecap_(_MaxCharCount) void * buf, _In_ u
#else
int win_x_read(int fd, char *buf, int n);
#endif
int win_x_getc(FILE *fp);
int win_x_getchar(void);
int win_x_putchar(const int c);
@ -97,8 +100,6 @@ int win_x_fputchar(int c);
#define ferror win_x_ferror
#define fputchar win_x_fputchar
/*----------------------------------------------------------------------------*/
#endif

102
src/winmain.c

@ -4,7 +4,9 @@
Autor: Holger Vogt
Stand: 17.10.2009
*/
#include "ngspice/config.h"
#ifdef HAS_WINGUI
#define STRICT // strict type checking
@ -109,6 +111,7 @@ static void HistoryInit(void)
HistBuffer[i][0] = SE;
}
/* Delete first line of buffer, all other lines move one down */
static void HistoryScroll(void)
{
@ -118,16 +121,20 @@ static void HistoryScroll(void)
if (HistPtr) HistPtr--;
}
/* Enter new input line into history buffer */
static void HistoryEnter(char *newLine)
{
if (!newLine || !*newLine) return;
if (HistPtr == HistSize) HistoryScroll();
strcpy(HistBuffer[HistPtr], newLine);
HistPtr++;
HistIndex = HistPtr;
}
// Mit dem Index eine Zeile zurueckgehen und den dort stehenden Eintrag zurueckgeben
static char *HistoryGetPrev(void)
{
@ -135,6 +142,7 @@ static char * HistoryGetPrev(void)
return &(HistBuffer[HistIndex][0]);
}
// Mit dem Index eine Zeile vorgehen und den dort stehenden Eintrag zurueckgeben
static char *HistoryGetNext(void)
{
@ -143,6 +151,7 @@ static char * HistoryGetNext(void)
return &(HistBuffer[HistIndex][0]);
}
// ---------------------------<Message Handling>-------------------------------
// Warte, bis keine Messages mehr zu bearbeiten sind
@ -156,6 +165,7 @@ void WaitForIdle(void)
}
}
// ---------------------------<Message Handling>-------------------------------
// Warte, bis keine Messages mehr zu bearbeiten sind,
@ -171,6 +181,7 @@ static void WaitForMessage(void)
WaitMessage();
}
// -----------------------------<Stringfenster>--------------------------------
// Loeschen des Stringfensters
@ -191,11 +202,14 @@ void SetSource( char * Name)
}
}
// ------------------------------<Analyse-Fenster>-----------------------------
/* New progress report into analysis window.
Update only every DELTATIME milliseconds */
#define DELTATIME 150
void SetAnalyse(
char *Analyse, /* in: analysis type */
int DecaPercent /* in: 10 times the progress [%]*/
@ -209,7 +223,9 @@ void SetAnalyse(
int diffsec, diffmillisec; /* differences actual minus prev. time stamp */
WaitForIdle();
if ((DecaPercent == OldPercent) && !strcmp(OldAn, Analyse)) return;
/* get actual time */
ftime(&timenow);
timediff(&timenow, &timebefore, &diffsec, &diffmillisec);
@ -221,6 +237,7 @@ void SetAnalyse(
if ((int)((double)DecaPercent/10.) > (int)((double)OldPercent/10.)) {
win_x_printf("%3.1f%% percent progress after %4.2f seconds.\n", (double)DecaPercent/10., seconds());
}
OldPercent = DecaPercent;
/* output only into hwAnalyse window and if time elapsed is larger than
DELTATIME given value, or if analysis has changed, else return */
@ -261,6 +278,7 @@ void SetAnalyse(
UpdateWindow(hwMain);
}
// ------------------------------<Textfenster>---------------------------------
// Anpassen des Scrollers im Textfenster
@ -273,12 +291,15 @@ static void AdjustScroller(void)
LineCount = Edit_GetLineCount(twText);
FirstLine = Edit_GetFirstVisibleLine(twText);
MyFirstLine = LineCount - VisibleRows;
if (MyFirstLine < 0 ) MyFirstLine = 0;
Edit_Scroll(twText, MyFirstLine - FirstLine, 0);
// Das wars
DoUpdate = FALSE;
}
// Loeschen einer Zeile im Textbuffer
static void _DeleteFirstLine(void)
{
@ -295,6 +316,7 @@ static void _DeleteFirstLine(void)
TBuffer[TBufEnd] = SE;
}
// Anfuegen eines chars an den TextBuffer
static void AppendChar(char c)
{
@ -310,6 +332,7 @@ static void AppendChar( char c)
DisplayText();
}
// Anfuegen eines Strings an den TextBuffer
static void AppendString(const char *Line)
{
@ -327,6 +350,7 @@ static void AppendString( const char * Line)
DoUpdate = TRUE;
}
// Text neu darstellen
static void DisplayText(void)
{
@ -335,6 +359,8 @@ static void DisplayText( void)
// Scroller updaten, neuen Text darstellen
AdjustScroller();
}
/*
// Anfuegen einer Zeile an den Textbuffer
void AppendLine(const char *Line)
@ -348,6 +374,8 @@ void AppendLine( const char * Line)
AppendString(CRLF);
}
*/
// -----------------------------------<User-IO>--------------------------------
// Lese ein Zeichen ein
@ -382,6 +410,7 @@ static int w_getch(void)
return c;
}
// Gebe ein Zeichen aus
static int w_putch(int c)
{
@ -390,6 +419,7 @@ static int w_putch( int c)
return c;
}
/* -------------------------------<Window procedures>-------------------------- */
/* Main window changes size */
@ -417,6 +447,7 @@ static void Main_OnSize(HWND hwnd, UINT state, int cx, int cy)
h, QuitButtonLength, StatusElHeight, TRUE);
}
/* Write a command into the command buffer */
static void PostSpiceCommand(const char *const cmd)
{
@ -424,6 +455,7 @@ static void PostSpiceCommand( const char * const cmd)
strcat(SBuffer, CRLF);
}
/* Main Window procedure */
static LRESULT CALLBACK MainWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -459,6 +491,7 @@ DEFAULT_AFTER:
}
}
/* Procedure for string window */
static LRESULT CALLBACK StringWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -480,8 +513,6 @@ static LRESULT CALLBACK StringWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam, L
ClearInput();
return 0;
}
goto DEFAULT;
case WM_CHAR:
@ -514,6 +545,7 @@ DEFAULT:
}
}
/* Procedure for text window */
static LRESULT CALLBACK TextWindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
@ -634,6 +666,7 @@ static LRESULT CALLBACK ElementWindowProc( HWND hwnd, UINT uMsg, WPARAM wParam,
0 on success
-1 on failure
*/
static int MakeArgcArgv(char *cmdline, int *argc, char ***argv)
{
char *pC1; /* a temporary character pointer */
@ -656,8 +689,10 @@ static int MakeArgcArgv(char *cmdline,int *argc,char ***argv)
status = -1;
goto outahere;
}
*argc = 0; /* set the count to zero to start */
*argv = NULL; /* set the pointer to NULL to start */
/* if the string passed in was a NULL pointer, consider this
to be an empty command line and give back only
an argc of 1 and an argv[0] */
@ -710,6 +745,7 @@ static int MakeArgcArgv(char *cmdline,int *argc,char ***argv)
break;
}
}
/* Now, we should have ctrl-Zs everywhere that
there used to be a space not protected by
quote marks. We should also have the number
@ -750,10 +786,12 @@ static int MakeArgcArgv(char *cmdline,int *argc,char ***argv)
/* copy the working values over to the arguments */
*argc = numargs;
*argv = tmpargv;
outahere:
/* free the working string if one was allocated */
if (pWorkString)
free(pWorkString);
/* return status */
return status;
}
@ -795,24 +833,29 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
hwMainClass.hbrBackground = GetStockObject(LTGRAY_BRUSH);
hwMainClass.lpszMenuName = NULL;
hwMainClass.lpszClassName = hwClassName;
if (!RegisterClass(&hwMainClass)) goto THE_END;
/* Define text window class */
if (!GetClassInfo(NULL, "EDIT", &twTextClass)) goto THE_END;
twProc = twTextClass.lpfnWndProc;
twTextClass.lpfnWndProc = TextWindowProc;
twTextClass.hInstance = hInst;
twTextClass.lpszMenuName = NULL;
twTextClass.lpszClassName = twClassName;
if (!RegisterClass(&twTextClass)) goto THE_END;
/* Define string window class */
if (!GetClassInfo(NULL, "EDIT", &swStringClass)) goto THE_END;
swProc = swStringClass.lpfnWndProc;
swStringClass.lpfnWndProc = StringWindowProc;
swStringClass.hInstance = hInst;
swStringClass.lpszMenuName = NULL;
swStringClass.lpszClassName = swClassName;
if (!RegisterClass(&swStringClass)) goto THE_END;
/* Define status element class */
@ -826,6 +869,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
hwElementClass.hbrBackground = GetStockObject(LTGRAY_BRUSH);
hwElementClass.lpszMenuName = NULL;
hwElementClass.lpszClassName = hwElementClassName;
if (!RegisterClass(&hwElementClass)) goto THE_END;
/*Create main window */
@ -845,6 +889,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
ES_LEFT | ES_MULTILINE | ES_READONLY | WS_CHILD | WS_BORDER | WS_VSCROLL,
20, 20, 300, 100, hwMain, NULL, hInst, NULL);
if (!twText) goto THE_END;
/* Ansii fixed font */
{
HDC textDC;
@ -867,6 +912,7 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
swString = CreateWindowEx(WS_EX_NOPARENTNOTIFY, swClassName, swWindowName,
ES_LEFT | WS_CHILD | WS_BORDER, 20,20,300,100, hwMain, NULL, hInst, NULL);
if (!swString) goto THE_END;
{
HDC stringDC;
TEXTMETRIC tm;
@ -925,7 +971,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLi
/* Go to main() */
nReturnCode = xmain(argc, argv);
THE_END:
/* terminate */
@ -949,6 +994,7 @@ int win_x_fflush( FILE * stream)
return fflush(stream);
}
int win_x_fgetc(FILE *stream)
{
if (stream == stdin) {
@ -961,6 +1007,7 @@ int win_x_fgetc( FILE * stream)
return fgetc(stream);
}
int win_x_fgetpos(FILE *stream, fpos_t *pos)
{
int result;
@ -972,6 +1019,7 @@ int win_x_fgetpos( FILE * stream, fpos_t * pos)
return result;
}
char *win_x_fgets(char *s, int n, FILE *stream)
{
if (stream == stdin) {
@ -992,6 +1040,7 @@ char * win_x_fgets(char * s, int n, FILE * stream)
return fgets(s, n, stream);
}
int win_x_fputc(int c, FILE *stream)
{
if (!flogp && ((stream == stdout) || (stream == stderr))) {
@ -1005,6 +1054,7 @@ int win_x_fputc(int c, FILE * stream)
return fputc(c, stream);
}
int win_x_fputs(const char *s, FILE *stream)
{
// if (((stream == stdout) && !flogp) || (stream == stderr)) { hvogt 14.6.2000
@ -1023,11 +1073,13 @@ int win_x_fputs(const char * s, FILE * stream)
return fputs(s, stream);
}
int win_x_fprintf(FILE *stream, const char *format, ...)
{
int result;
char s[IOBufSize];
va_list args;
va_start(args, format);
// if (((stream == stdout) && !flogp) || (stream == stderr)) {
@ -1043,6 +1095,7 @@ int win_x_fprintf(FILE * stream, const char * format, ...)
return result;
}
int win_x_fclose(FILE *stream)
{
if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) {
@ -1052,6 +1105,7 @@ int win_x_fclose( FILE * stream)
return fclose(stream);
}
size_t win_x_fread(void *ptr, size_t size, size_t n, FILE *stream)
{
// if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) {
@ -1077,9 +1131,11 @@ size_t win_x_fread(void * ptr, size_t size, size_t n, FILE * stream)
ptr = &s[0];
return (size_t)(i / size);
}
return fread(ptr, size, n, stream);
}
FILE *win_x_freopen(const char *path, const char *mode, FILE *stream)
{
if ((stream == stdin)/* || ((stream == stdout) && !flogp) || (stream == stderr)*/) {
@ -1089,10 +1145,12 @@ FILE * win_x_freopen(const char * path, const char * mode, FILE * stream)
return freopen(path, mode, stream);
}
int win_x_fscanf(FILE *stream, const char *format, ...)
{
int result;
va_list args;
va_start(args, format);
if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) {
assert(FALSE);
@ -1103,6 +1161,7 @@ int win_x_fscanf(FILE * stream, const char * format, ...)
return result;
}
int win_x_fseek(FILE *stream, long offset, int whence)
{
if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) {
@ -1112,6 +1171,7 @@ int win_x_fseek(FILE * stream, long offset, int whence)
return fseek(stream, offset, whence);
}
int win_x_fsetpos(FILE *stream, const fpos_t *pos)
{
if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) {
@ -1121,6 +1181,7 @@ int win_x_fsetpos(FILE * stream, const fpos_t *pos)
return fsetpos(stream, pos);
}
long win_x_ftell(FILE *stream)
{
if ((stream == stdin) || ((stream == stdout) && !flogp) || (stream == stderr)) {
@ -1130,6 +1191,7 @@ long win_x_ftell(FILE * stream)
return ftell(stream);
}
size_t win_x_fwrite(const void *ptr, size_t size, size_t n, FILE *stream)
{
// win_x_printf("entered fwrite, size %d, n %d \n", size, n);
@ -1147,6 +1209,7 @@ size_t win_x_fwrite(const void * ptr, size_t size, size_t n, FILE * stream)
// win_x_printf("test1 %s\n", s);
if (!s) return 0 /* EOF */;
for (i = 0; i < (size * n); i++) {
if (*s) {
c = *s++;
@ -1162,11 +1225,13 @@ size_t win_x_fwrite(const void * ptr, size_t size, size_t n, FILE * stream)
return fwrite(ptr, size, n, stream);
}
char *win_x_gets(char *s)
{
return win_x_fgets(s, 10000, stdin);
}
void win_x_perror(const char *s)
{
const char *cp;
@ -1178,25 +1243,29 @@ void win_x_perror(const char * s)
if (!flogp) winmessage(s);*/
}
int win_x_printf(const char *format, ...)
{
int result;
char s[IOBufSize];
va_list args;
va_start(args, format);
va_start(args, format);
s[0] = SE;
result = vsprintf(s, format, args);
win_x_fputs(s, stdout);
va_end(args);
return result;
}
int win_x_puts(const char *s)
{
return win_x_fputs(s, stdout);
}
int win_x_scanf(const char *format, ...)
{
NG_IGNORE(format);
@ -1204,6 +1273,7 @@ int win_x_scanf(const char * format, ...)
return FALSE;
}
int win_x_ungetc(int c, FILE *stream)
{
NG_IGNORE(c);
@ -1212,6 +1282,7 @@ int win_x_ungetc(int c, FILE * stream)
return FALSE;
}
int win_x_vfprintf(FILE *stream, const char *format, void *arglist)
{
int result;
@ -1228,6 +1299,7 @@ int win_x_vfprintf(FILE * stream, const char * format, void * arglist)
return result;
}
/*int win_x_vfscanf(FILE *stream, const char *format, void *arglist)
{
if (stream == stdin) {
@ -1237,6 +1309,8 @@ int win_x_vfprintf(FILE * stream, const char * format, void * arglist)
return vfscanf(stream, format, arglist);
}
*/
int win_x_vprintf(const char *format, void *arglist)
{
int result;
@ -1248,12 +1322,14 @@ int win_x_vprintf(const char * format, void * arglist)
return result;
}
/*int win_x_vscanf(const char *format, void *arglist)
{
assert(FALSE);
return FALSE;
} */
int win_x_read(int fd, char *buf, int n)
{
if (fd == 0) {
@ -1277,26 +1353,32 @@ int win_x_read(int fd, char * buf, int n)
return _read(fd, buf, n);
}
}
int win_x_getc(FILE *fp)
{
return win_x_fgetc(fp);
}
int win_x_getchar(void)
{
return win_x_fgetc(stdin);
}
int win_x_putchar(const int c)
{
return win_x_fputc(c, stdout);
}
int win_x_putc(const int c, FILE *fp)
{
return win_x_fputc(c, fp);
}
int win_x_feof(FILE *fp)
{
if ((fp == stdin) || (fp == stdout) || (fp == stderr)) {
@ -1306,6 +1388,7 @@ int win_x_feof(FILE * fp)
return feof(fp);
}
int win_x_ferror(FILE *fp)
{
if ((fp == stdin) || (fp == stdout) || (fp == stderr)) {
@ -1315,12 +1398,15 @@ int win_x_ferror(FILE * fp)
return ferror(fp);
}
int win_x_fputchar(int c)
{
return win_x_fputc(c, stdout);
}
// --------------------------<Verfuegbarer Speicher>----------------------------
/*
size_t _memavl(void)
{
@ -1332,7 +1418,9 @@ size_t _memavl(void)
return (size_t) sum;
}
// ---------------------<Aufruf eines anderen Programms>-----------------------
#ifndef _MSC_VER
int system(const char *command)
{
@ -1381,7 +1469,9 @@ int system( const char * command)
#endif
*/
#ifdef __CYGWIN__
/* Strip leading spaces, return a copy of s */
static char *
rlead(char *s)
@ -1405,8 +1495,10 @@ rlead(char *s)
temp[j] = '\0';
return copy(temp);
}
#endif
void winmessage(char *new_msg)
{
/* open a message box only if message is not written into -o xxx.log */
@ -1414,5 +1506,5 @@ void winmessage(char* new_msg)
MessageBox(NULL, new_msg, "Ngspice Info", MB_OK | MB_ICONERROR);
}
#endif /* HAS_WINGUI */
#endif /* HAS_WINGUI */

2
src/winmain.h

@ -4,10 +4,12 @@
/* Forward definition of main() */
int xmain(int argc, char *argv[]);
/* forward of Update function */
#ifdef __CYGWIN__
static char* rlead(char*);
#endif
void winmessage(char*);
static void HistoryInit(void);

Loading…
Cancel
Save