mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
Release calc version 2.10.2t30
This commit is contained in:
165
calc.h
Normal file
165
calc.h
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright (c) 1995 David I. Bell
|
||||
* Permission is granted to use, distribute, or modify this source,
|
||||
* provided that this copyright notice remains intact.
|
||||
*
|
||||
* Definitions for calculator program.
|
||||
*/
|
||||
|
||||
#ifndef CALC_H
|
||||
#define CALC_H
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
#include "value.h"
|
||||
|
||||
|
||||
/*
|
||||
* Configuration definitions
|
||||
*/
|
||||
#define CALCPATH "CALCPATH" /* environment variable for files */
|
||||
#define CALCRC "CALCRC" /* environment variable for startup */
|
||||
#define CALCBINDINGS "CALCBINDINGS" /* environment variable for hist bindings */
|
||||
#define HOME "HOME" /* environment variable for home dir */
|
||||
#define PAGER "PAGER" /* environment variable for help */
|
||||
#define SHELL "SHELL" /* environment variable for shell */
|
||||
#define DEFAULTCALCHELP "help" /* help file that -h prints */
|
||||
#define DEFAULTSHELL "sh" /* default shell to use */
|
||||
#define CALCEXT ".cal" /* extension for files read in */
|
||||
#define PATHSIZE 1024 /* maximum length of path name */
|
||||
#define HOMECHAR '~' /* char which indicates home directory */
|
||||
#define DOTCHAR '.' /* char which indicates current directory */
|
||||
#define PATHCHAR '/' /* char which separates path components */
|
||||
#define LISTCHAR ':' /* char which separates paths in a list */
|
||||
#define MAXCMD 16384 /* maximum length of command invocation */
|
||||
#define MAXERROR 512 /* maximum length of error message string */
|
||||
|
||||
#define SYMBOLSIZE 256 /* maximum symbol name size */
|
||||
#define MAXINDICES 20 /* maximum number of indices for objects */
|
||||
#define MAXLABELS 100 /* maximum number of user labels in function */
|
||||
#define MAXOBJECTS 10 /* maximum number of object types */
|
||||
#define MAXSTRING 1024 /* maximum size of string constant */
|
||||
#define MAXSTACK 1000 /* maximum depth of evaluation stack */
|
||||
#define MAXFILES 20 /* maximum number of opened files */
|
||||
#define PROMPT1 "> " /* default normal prompt*/
|
||||
#define PROMPT2 ">> " /* default prompt inside multi-line input */
|
||||
|
||||
|
||||
#define TRACE_NORMAL 0x00 /* normal trace flags */
|
||||
#define TRACE_OPCODES 0x01 /* trace every opcode */
|
||||
#define TRACE_NODEBUG 0x02 /* suppress debugging opcodes */
|
||||
#define TRACE_LINKS 0x04 /* display links for real and complex numbers */
|
||||
#define TRACE_FNCODES 0x08 /* display code for newly defined function */
|
||||
#define TRACE_MAX 0x0f /* maximum value for trace flag */
|
||||
|
||||
#define ABORT_NONE 0 /* abort not needed yet */
|
||||
#define ABORT_STATEMENT 1 /* abort on statement boundary */
|
||||
#define ABORT_OPCODE 2 /* abort on any opcode boundary */
|
||||
#define ABORT_MATH 3 /* abort on any math operation */
|
||||
#define ABORT_NOW 4 /* abort right away */
|
||||
|
||||
/*
|
||||
* File ids corresponding to standard in, out, error, and when not in use.
|
||||
*/
|
||||
#define FILEID_STDIN ((FILEID) 0)
|
||||
#define FILEID_STDOUT ((FILEID) 1)
|
||||
#define FILEID_STDERR ((FILEID) 2)
|
||||
#define FILEID_NONE ((FILEID) -1)
|
||||
|
||||
/*
|
||||
* File I/O routines.
|
||||
*/
|
||||
extern FILEID openid(char *name, char *mode);
|
||||
extern FILEID indexid(long index);
|
||||
extern BOOL validid(FILEID id);
|
||||
extern BOOL errorid(FILEID id);
|
||||
extern BOOL eofid(FILEID id);
|
||||
extern int closeid(FILEID id);
|
||||
extern int getcharid(FILEID id);
|
||||
extern int idprintf(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
extern int idfputc(FILEID id, int ch);
|
||||
extern int idfputs(FILEID id, char *str);
|
||||
extern int printid(FILEID id, int flags);
|
||||
extern int flushid(FILEID id);
|
||||
extern int readid(FILEID id, int flags, char **retptr);
|
||||
extern int getloc(FILEID id, ZVALUE *loc);
|
||||
extern int setloc(FILEID id, ZVALUE zpos);
|
||||
extern int getsize(FILEID id, ZVALUE *size);
|
||||
extern int get_device(FILEID id, ZVALUE *dev);
|
||||
extern int get_inode(FILEID id, ZVALUE *ino);
|
||||
extern FILEID reopenid(FILEID id, char *mode, char *name);
|
||||
extern int closeall(void);
|
||||
extern int flushall(void);
|
||||
extern int idfputstr(FILEID id, char *str);
|
||||
extern int rewindid(FILEID id);
|
||||
extern void rewindall(void);
|
||||
extern long filesize(FILEID id);
|
||||
extern void showfiles(void);
|
||||
extern int fscanfid(FILEID id, char *fmt, int count, VALUE **vals);
|
||||
extern int scanfstr(char *str, char *fmt, int count, VALUE **vals);
|
||||
extern long ftellid(FILEID id);
|
||||
extern long fseekid(FILEID id, long offset, int whence);
|
||||
extern int isattyid(FILEID id);
|
||||
long fsearch(FILEID id, char *str, long pos);
|
||||
long frsearch(FILEID id, char *str, long pos);
|
||||
|
||||
/*
|
||||
* Input routines.
|
||||
*/
|
||||
extern FILE *f_open(char *name, char *mode);
|
||||
extern int openstring(char *str);
|
||||
extern int openterminal(void);
|
||||
extern int opensearchfile(char *name, char *pathlist, char *exten, int reopen_ok);
|
||||
extern char *nextline(void);
|
||||
extern int nextchar(void);
|
||||
extern void reread(void);
|
||||
extern void resetinput(void);
|
||||
extern void setprompt(char *);
|
||||
extern BOOL inputisterminal(void);
|
||||
extern char *inputname(void);
|
||||
extern long linenumber(void);
|
||||
extern void runrcfiles(void);
|
||||
extern void closeinput(void);
|
||||
extern FILE *curstream(void);
|
||||
|
||||
|
||||
/*
|
||||
* Other routines.
|
||||
*/
|
||||
extern NUMBER *constvalue(unsigned long index);
|
||||
extern long addnumber(char *str);
|
||||
extern long addqconstant(NUMBER *q);
|
||||
extern void initstack(void);
|
||||
extern void version(FILE *stream);
|
||||
extern void getcommands(BOOL toplevel);
|
||||
extern void givehelp(char *type);
|
||||
extern void hash_init(void);
|
||||
extern void libcalc_call_me_first(void);
|
||||
|
||||
|
||||
/*
|
||||
* Global data definitions.
|
||||
*/
|
||||
extern int abortlevel; /* current level of aborts */
|
||||
extern BOOL inputwait; /* TRUE if in a terminal input wait */
|
||||
extern VALUE *stack; /* execution stack */
|
||||
extern jmp_buf jmpbuf; /* for errors */
|
||||
extern int start_done; /* TRUE => start up processing finished */
|
||||
extern int dumpnames; /* TRUE => dump names rather than indices */
|
||||
|
||||
extern char *calcpath; /* $CALCPATH or default */
|
||||
extern char *calcrc; /* $CALCRC or default */
|
||||
extern char *calcbindings; /* $CALCBINDINGS or default */
|
||||
extern char *home; /* $HOME or default */
|
||||
extern char *shell; /* $SHELL or default */
|
||||
|
||||
extern int allow_read; /* FALSE => may not open any files for reading */
|
||||
extern int allow_write; /* FALSE => may not open any files for writing */
|
||||
extern int allow_exec; /* FALSE => may not execute any commands */
|
||||
|
||||
extern int post_init; /* TRUE => setjmp for math_error is ready */
|
||||
|
||||
#endif
|
||||
|
||||
/* END CODE */
|
Reference in New Issue
Block a user