/usr/include/ComTerp/iofunc.h is in ivtools-dev 1.2.11a1-11.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 | /*
* Copyright (c) 2000 IET Inc.
* Copyright (c) 1998,1999 Vectaport Inc.
*
* Permission to use, copy, modify, distribute, and sell this software and
* its documentation for any purpose is hereby granted without fee, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the names of the copyright holders not be used in
* advertising or publicity pertaining to distribution of the software
* without specific, written prior permission. The copyright holders make
* no representations about the suitability of this software for any purpose.
* It is provided "as is" without express or implied warranty.
*
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
* SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS.
* IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL,
* INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
* FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
* NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
* WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
/*
* collection of io functions
*/
#if !defined(_iofunc_h)
#define _iofunc_h
#include <ComTerp/comfunc.h>
class ComTerp;
class ComValue;
//: value printing command for ComTerp.
// [str]=print([fmtstr] [val [val1 [... valn]]] :string|:str :symbol|:sym :out :err :file fileobj|pipeobj :prefix str) -- print value(s) with optional format string
class PrintFunc : public ComFunc {
public:
PrintFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
return "[str]=%s([fmtstr] [val [val1 [... valn]]] :string|:str :symbol|:sym :out :err :file fileobj|pipeobj :prefix str) -- print value with optional format string"; }
static int format_extent(const char* fstr);
};
//: open file command
// fileobj|pipeobj=open([filename modestr] :pipe :out :err) -- open file command
class OpenFileFunc : public ComFunc {
public:
OpenFileFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
return "fileobj|pipeobj=open([filename [modestr]] :pipe :in :out :err) -- open file command"; }
};
//: close file command
// close(fileobj|pipeobj) -- close file command
class CloseFileFunc : public ComFunc {
public:
CloseFileFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
return "close(fileobj|pipeobj) -- close file command"; }
};
class FileObj {
public:
FileObj(const char* filename, const char* mode, int pipeflag);
FileObj(FILE* fptr);
virtual ~FileObj();
const char* filename() { return _filename; }
const char* mode() { return _mode; }
FILE* fptr() { return _fptr; }
protected:
char* _filename;
char* _mode;
FILE* _fptr;
FILE* _fptr2;
int _pipe;
pid_t _pid;
CLASS_SYMID("FileObj");
};
class PipeObj {
public:
PipeObj(const char* command);
virtual ~PipeObj();
const char* command() { return _command; }
int pid() { return _pid; }
int wrfd() { return _wrfd; }
int rdfd() { return _rdfd; }
FILE* wrfptr() { return _wrfptr ? _wrfptr : _wrfptr=fdopen(_wrfd, "w"); }
FILE* rdfptr() { return _rdfptr ? _rdfptr : _rdfptr=fdopen(_rdfd, "r"); }
void close();
protected:
char* _command;
pid_t _pid;
int _wrfd;
int _rdfd;
FILE* _wrfptr;
FILE* _rdfptr;
CLASS_SYMID("PipeObj");
};
//: get string from FileObj
// str=gets(fileobj) -- gets a new-line terminated string from a file
class GetStringFunc : public ComFunc {
public:
GetStringFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
return "str=%s(fileobj|pipeobj) -- gets a new-line terminated string from a file"; }
};
//: return command line argument
// str=arg(n) -- return command line argument
class GetArgFunc : public ComFunc {
public:
GetArgFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
return "str=%s(n) -- return command line argument"; }
};
//: return number of command line arguments
// n=narg() -- return number of command line arguments
class NumArgFunc : public ComFunc {
public:
NumArgFunc(ComTerp*);
virtual void execute();
virtual const char* docstring() {
return "n=%s() -- return number of command line arguments"; }
};
#endif /* !defined(_iofunc_h) */
|