2000-04-27 22:03:57 +02:00
|
|
|
/**********
|
|
|
|
|
Copyright 1990 Regents of the University of California. All rights reserved.
|
|
|
|
|
Author: 1988 Jeffrey M. Hsu
|
2005-05-30 22:28:29 +02:00
|
|
|
$Id$
|
2000-04-27 22:03:57 +02:00
|
|
|
**********/
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Stand-alone input routine.
|
|
|
|
|
*/
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
#include <config.h>
|
|
|
|
|
#include <ngspice.h>
|
|
|
|
|
|
|
|
|
|
#include <errno.h>
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
#include "fteinput.h"
|
|
|
|
|
#include "input.h"
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
#include "cpextern.h"
|
2005-05-30 22:28:29 +02:00
|
|
|
#include "../display.h"
|
2011-07-05 00:00:18 +02:00
|
|
|
#ifdef _MSC_VER
|
2011-07-05 00:03:16 +02:00
|
|
|
#include "BaseTsd.h" /* for SSIZE_T */
|
2011-07-05 00:00:18 +02:00
|
|
|
#define ssize_t SSIZE_T
|
|
|
|
|
#define read _read
|
|
|
|
|
#endif
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
|
|
|
|
|
/* 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
|
|
|
|
|
* don't use buffering at all
|
|
|
|
|
*/
|
|
|
|
|
int
|
|
|
|
|
inchar(FILE *fp)
|
|
|
|
|
{
|
2000-04-27 22:03:57 +02:00
|
|
|
|
2002-01-03 23:44:21 +01:00
|
|
|
#ifndef HAS_WINDOWS
|
2010-11-06 18:29:28 +01:00
|
|
|
char c;
|
2011-07-05 00:00:18 +02:00
|
|
|
ssize_t i;
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
|
|
|
|
|
if (cp_interactive && !cp_nocc) {
|
|
|
|
|
do {
|
2010-11-06 18:29:28 +01:00
|
|
|
i = read(fileno(fp), &c, 1);
|
|
|
|
|
} while (i == -1 && errno == EINTR);
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
if (i == 0 || c == '\004')
|
|
|
|
|
return (EOF);
|
|
|
|
|
else if (i == -1) {
|
|
|
|
|
perror("read");
|
|
|
|
|
return (EOF);
|
|
|
|
|
} else
|
|
|
|
|
return ((int) c);
|
|
|
|
|
} else
|
2002-01-03 23:44:21 +01:00
|
|
|
#endif
|
2010-11-06 18:29:28 +01:00
|
|
|
return (getc(fp));
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
}
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
int
|
|
|
|
|
input(FILE *fp)
|
2000-04-27 22:03:57 +02:00
|
|
|
{
|
|
|
|
|
|
* frontend/Makefile.am: Updates for new files.
* frontend/breakp2.c, frontend/newcoms.c, frontend/postcoms.c,
frontend/resource.c, frontend/terminal.h, frontend/variable.c,
frontend/variable.h, frontend/com_compose.c,
frontend/com_display.c, frontend/com_setscale.c,
frontend/com_strcmp.c: Include files update.
* parser/var2.c, parser/var2.h: Empty files, removed.
* parser/Makefile.am: Updates for removed files.
* parser/lexical.c: Small adjustments
* parser/input.c, parser/input.h: Input, output and error streams
handled in the frontend. Moved to the frontend directory.
* frontend/streams.c: Its new home.
2000-07-07 16:09:06 +02:00
|
|
|
REQUEST request;
|
|
|
|
|
RESPONSE response;
|
|
|
|
|
|
|
|
|
|
request.option = char_option;
|
|
|
|
|
request.fp = fp;
|
|
|
|
|
Input(&request, &response);
|
2010-08-09 20:36:57 +02:00
|
|
|
return(inchar(fp));
|
2000-04-27 22:03:57 +02:00
|
|
|
|
|
|
|
|
}
|