File: CmdFile.hh

package info (click to toggle)
gri 2.8.7-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 4,472 kB
  • ctags: 2,092
  • sloc: cpp: 33,255; lisp: 3,980; perl: 1,037; makefile: 668; sh: 301
file content (73 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download
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
// Object for command files
#if !defined(_CmdFile_hh_)
#define _CmdFile_hh_
#include <string>
#include <stdio.h>
#include "types.hh"
#include "macro.hh"
#include "superus.hh"
unsigned int superuser(void);

class CmdFile
{
public:
	CmdFile() {
		name.assign("");
		fp = (FILE*)NULL;		// for now anyway
		interactive = true;
		save2ps = false;
		line = 0;
	}
	CmdFile(const CmdFile& c) {
		name.assign(c.get_name());
		fp = c.get_fp();
		if (fp == (FILE*)NULL) {
			printf("ERROR at %s:%d -- try to CmdFile copy null  '%s'  from %x    this %x\n",__FILE__,__LINE__,name.c_str(),int(&c),int(this));
			exit(1);
		}
		interactive = c.get_interactive();
		save2ps = c.get_save2ps();
		line = c.get_line();
	}
	~CmdFile() {
#if 0				// BUG 2001-feb-17 -- not sure on next 2 lines
		name.string::~string();	// not executed
#endif
	}
	CmdFile& operator=(const CmdFile& c) {
		name.assign(c.get_name());
		fp = c.get_fp();
		if (fp == (FILE*)NULL) {
			printf("%s:%d try to CmdFile operator= null file this %x\n",__FILE__,__LINE__,int(this));
			exit(1);
		}
		interactive = c.get_interactive();
		save2ps = c.get_save2ps();
		line = c.get_line();
		return *this;
	}
	void set(const char *n, FILE *f, bool i, int l, bool save_in_ps = true) {
		name.assign(n);
		fp = f;
		if (fp == (FILE*)NULL) {
			printf("ERROR at %s:%d -- try to CmdFile set null file this %x\n",__FILE__,__LINE__,int(this));
			exit(1);
		}
		interactive = i;
		save2ps = save_in_ps;
		line = l;
	}
	void increment_line()        { line++;		        }
	const char *get_name() const { return name.c_str();	}
	FILE *get_fp()         const { return fp;		}
	bool get_interactive() const { return interactive;	}
	int  get_line()        const { return line;		}
	bool get_save2ps()     const { return save2ps;          }
private:
	FILE           *fp;
	std::string     name;
	bool            interactive;
	bool            save2ps;
	int             line;
};
#endif