xref: /plan9/sys/src/cmd/gs/src/dwinst.h (revision 593dc095aefb2a85c828727bbfa9da139a49bdf4)
1 /* Copyright (C) 1999-2002, Ghostgum Software Pty Ltd.  All rights reserved.
2 
3   This software is provided AS-IS with no warranty, either express or
4   implied.
5 
6   This software is distributed under license and may not be copied,
7   modified or distributed except as expressly authorized under the terms
8   of the license contained in the file LICENSE in this distribution.
9 
10   For more information about licensing, please refer to
11   http://www.ghostscript.com/licensing/. For information on
12   commercial licensing, go to http://www.artifex.com/licensing/ or
13   contact Artifex Software, Inc., 101 Lucas Valley Road #110,
14   San Rafael, CA  94903, U.S.A., +1(415)492-9861.
15 */
16 
17 // $Id: dwinst.h,v 1.7 2004/11/18 06:48:41 ghostgum Exp $
18 
19 #ifndef dwinst_INCLUDED
20 #  define dwinst_INCLUDED
21 
22 // Definitions for Ghostscript installer
23 
24 #ifndef MAXSTR
25 #ifdef MAX_PATH
26 #define MAXSTR MAX_PATH
27 #else
28 #define MAXSTR 256
29 #endif
30 #endif
31 
32 class CInstall
33 {
34 public:
35 	CInstall();
36 	virtual ~CInstall();
37 	void SetMessageFunction(void(*fn)(const char *));
38 	void AddMessage(const char *message);
39 	const char *GetMainDir();
40 	const char *GetUninstallName();
41 	BOOL GetPrograms(BOOL bUseCommon, char *buf, int buflen);
42 	BOOL Init(const char *szSourceDir, const char *szFileList);
43 	BOOL InstallFiles(BOOL bNoCopy, BOOL *pbQuit);
44 	BOOL InstallFile(char *filename, BOOL bNoCopy);
45 	BOOL MakeDir(const char *dirname);
46 	FILE * MakeTemp(char *name);
47 
48 	BOOL SetAllUsers(BOOL bUseCommon);
49 	void SetTargetDir(const char *szTargetDir);
50 	void SetTargetGroup(const char *szTargetGroup);
51 
52 	BOOL StartMenuBegin();
53 	BOOL StartMenuEnd();
54 	BOOL StartMenuAdd(const char *szDescription, const char *szProgram, const char *szArguments);
55 
56 	BOOL UpdateRegistryBegin();
57 	BOOL UpdateRegistryKey(const char *product, const char *version);
58 	BOOL UpdateRegistryValue(const char *product, const char *version, const char *name, const char *value);
59 	BOOL UpdateRegistryEnd();
60 
61 	BOOL WriteUninstall(const char *prog, BOOL bNoCopy);
62 	BOOL MakeLog(void);
63 
64 	void CleanUp(void);
65 
66         void AppendFileNew(const char *filename);
67 
68 private:
69 	BOOL m_bNoCopy;
70 	BOOL m_bUseCommon;
71 	BOOL m_bQuit;
72 
73 	// Source directory
74 	char m_szSourceDir[MAXSTR];
75 
76 	// File containing list of files to install
77 	char m_szFileList[MAXSTR];
78 
79 	// Target directory for program and fonts.
80 	char m_szTargetDir[MAXSTR];
81 
82 	// Target Group for shortcut
83 	char m_szTargetGroup[MAXSTR];
84 
85 	// Directory where the Start Menu is located.
86 	char m_szPrograms[MAXSTR];
87 
88 	// Name used for uninstall
89 	char m_szUninstallName[MAXSTR];
90 
91 	// Main directory prefix, where log files should be written
92 	char m_szMainDir[MAXSTR];
93 
94 	// Full directory where log files should be written
95 	char m_szLogDir[MAXSTR];
96 
97 	// Temporary log files for uninstall
98 	char m_szFileNew[MAXSTR];
99 	char m_szRegistryNew[MAXSTR];
100 	char m_szRegistryOld[MAXSTR];
101 	char m_szShellNew[MAXSTR];
102 	char m_szShellOld[MAXSTR];
103 
104 	// Log files
105 	FILE * m_fLogNew;
106 	FILE * m_fLogOld;
107 
108 
109 	BOOL SetRegistryValue(HKEY hkey, const char *value_name, const char *value);
110 	BOOL CreateShellLink(LPCSTR description, LPCSTR program, LPCSTR arguments, LPCSTR icon = NULL, int nIconIndex = 0);
111 	void CopyFileContents(FILE *df, FILE *sf);
112 	void ResetReadonly(const char *filename);
113 
114 	void(*AddMessageFn)(const char *);
115 
116 };
117 
118 
119 #endif /* dwinst_INCLUDED */
120