Replace strncpy with memcpy or lstrcpyn.
[wine] / programs / winecfg / winecfg.h
1 /*
2  * WineCfg configuration management
3  *
4  * Copyright 2002 Jaco Greeff
5  * Copyright 2003 Dimitrie O. Paun
6  * Copyright 2004 Mike Hearn
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  *
22  */
23
24 #ifndef WINE_CFG_H
25 #define WINE_CFG_H
26
27 #include <stdarg.h>
28
29 #include "windef.h"
30 #include "winbase.h"
31 #include "wingdi.h"
32 #include "winuser.h"
33 #include "winnls.h"
34 #include "properties.h"
35
36 #define IS_OPTION_TRUE(ch) \
37     ((ch) == 'y' || (ch) == 'Y' || (ch) == 't' || (ch) == 'T' || (ch) == '1')
38 #define IS_OPTION_FALSE(ch) \
39     ((ch) == 'n' || (ch) == 'N' || (ch) == 'f' || (ch) == 'F' || (ch) == '0')
40
41 extern char *current_app; /* NULL means editing global settings  */
42
43 /* Use get and set to alter registry settings. The changes made through set
44    won't be committed to the registry until process_all_settings is called,
45    however get will still return accurate information.
46
47    You are expected to release the result of get. The parameters to set will
48    be copied, so release them too when necessary.
49  */
50
51 void set(char *path, char *name, char *value);
52 char *get(char *path, char *name, char *def);
53 BOOL exists(char *path, char *name);
54 void apply(void);
55 char **enumerate_values(char *path);
56
57 /* returns a string of the form "AppDefaults\\appname.exe\\section", or just "section" if
58    the user is editing the global settings.
59  
60    no explicit free is needed of the string returned by this function
61  */
62 char *keypath(char *section); 
63
64 int initialize(void);
65 extern HKEY config_key;
66
67 /* hack for the property sheet control  */
68 void set_window_title(HWND dialog);
69
70 /* Window procedures */
71 INT_PTR CALLBACK GraphDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
72 INT_PTR CALLBACK DriveDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
73 INT_PTR CALLBACK DriveEditDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
74 INT_PTR CALLBACK AppDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
75 INT_PTR CALLBACK LibrariesDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
76 INT_PTR CALLBACK AudioDlgProc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
77
78 /* Drive management  */
79 void load_drives();
80 int autodetect_drives();
81
82 struct drive
83 {
84     char letter;
85     char *unixpath;
86     char *label;
87     char *serial;
88     DWORD type; /* one of the DRIVE_ constants from winbase.h  */
89
90     BOOL in_use;
91 };
92
93 #define DRIVE_MASK_BIT(B) 1 << (toupper(B) - 'A')
94
95 long drive_available_mask(char letter);
96 BOOL add_drive(char letter, char *targetpath, char *label, char *serial, unsigned int type);
97 void delete_drive(struct drive *pDrive);
98 void apply_drive_changes();
99 extern struct drive drives[26]; /* one for each drive letter */
100
101 BOOL gui_mode;
102
103 /* Some basic utilities to make win32 suck less */
104 #define disable(id) EnableWindow(GetDlgItem(dialog, id), 0);
105 #define enable(id) EnableWindow(GetDlgItem(dialog, id), 1);
106 void PRINTERROR(void); /* WINE_TRACE() the plaintext error message from GetLastError() */
107
108 /* returns a string in the win32 heap  */
109 static inline char *strdupA(char *s)
110 {
111     char *r = HeapAlloc(GetProcessHeap(), 0, strlen(s)+1);
112     return strcpy(r, s);
113 }
114
115 static inline char *get_text(HWND dialog, WORD id)
116 {
117     HWND item = GetDlgItem(dialog, id);
118     int len = GetWindowTextLength(item) + 1;
119     char *result = len ? HeapAlloc(GetProcessHeap(), 0, len) : NULL;
120     if (!result || GetWindowText(item, result, len) == 0) return NULL;
121     return result;
122 }
123
124 static inline void set_text(HWND dialog, WORD id, char *text)
125 {
126     SetWindowText(GetDlgItem(dialog, id), text);
127 }
128
129 #define WINE_KEY_ROOT "Software\\Wine\\Testing\\Config"
130
131 #endif