summaryrefslogtreecommitdiffstats
path: root/include/libmsi.h
blob: d28106c90621e2a4ad5830b383799aa7e17bfa50 (plain)
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
/*
 * Copyright (C) 2002,2003 Mike McCormack
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 */

#ifndef _LIBMSI_H
#define _LIBMSI_H

#include <stdint.h>
#include <stdbool.h>

struct LibmsiObject;
typedef struct LibmsiObject LibmsiObject;

typedef enum LibmsiCondition
{
    LIBMSI_CONDITION_FALSE = 0,
    LIBMSI_CONDITION_TRUE  = 1,
    LIBMSI_CONDITION_NONE  = 2,
    LIBMSI_CONDITION_ERROR = 3,
} LibmsiCondition;

#define MSI_NULL_INTEGER 0x80000000

typedef enum LibmsiColInfo
{
    LIBMSI_COL_INFO_NAMES = 0,
    LIBMSI_COL_INFO_TYPES = 1
} LibmsiColInfo;

typedef enum LibmsiModify
{
    LIBMSI_MODIFY_SEEK = -1,
    LIBMSI_MODIFY_REFRESH = 0,
    LIBMSI_MODIFY_INSERT = 1,
    LIBMSI_MODIFY_UPDATE = 2,
    LIBMSI_MODIFY_ASSIGN = 3,
    LIBMSI_MODIFY_REPLACE = 4,
    LIBMSI_MODIFY_MERGE = 5,
    LIBMSI_MODIFY_DELETE = 6,
    LIBMSI_MODIFY_INSERT_TEMPORARY = 7,
    LIBMSI_MODIFY_VALIDATE = 8,
    LIBMSI_MODIFY_VALIDATE_NEW = 9,
    LIBMSI_MODIFY_VALIDATE_FIELD = 10,
    LIBMSI_MODIFY_VALIDATE_DELETE = 11
} LibmsiModify;

#define LIBMSI_DB_OPEN_READONLY (const char *)0
#define LIBMSI_DB_OPEN_TRANSACT (const char *)1
#define LIBMSI_DB_OPEN_DIRECT   (const char *)2
#define LIBMSI_DB_OPEN_CREATE   (const char *)3
#define LIBMSI_DB_OPEN_CREATEDIRECT (const char *)4

#define LIBMSI_DB_OPEN_PATCHFILE 32 / sizeof(*LIBMSI_DB_OPEN_READONLY)

typedef enum LibmsiDBError
{
    LIBMSI_DB_ERROR_INVALIDARG = -3,
    LIBMSI_DB_ERROR_MOREDATA = -2,
    LIBMSI_DB_ERROR_FUNCTIONERROR = -1,
    LIBMSI_DB_ERROR_NOERROR = 0,
    LIBMSI_DB_ERROR_DUPLICATEKEY = 1,
    LIBMSI_DB_ERROR_REQUIRED = 2,
    LIBMSI_DB_ERROR_BADLINK = 3,
    LIBMSI_DB_ERROR_OVERFLOW = 4,
    LIBMSI_DB_ERROR_UNDERFLOW = 5,
    LIBMSI_DB_ERROR_NOTINSET = 6,
    LIBMSI_DB_ERROR_BADVERSION = 7,
    LIBMSI_DB_ERROR_BADCASE = 8,
    LIBMSI_DB_ERROR_BADGUID = 9,
    LIBMSI_DB_ERROR_BADWILDCARD = 10,
    LIBMSI_DB_ERROR_BADIDENTIFIER = 11,
    LIBMSI_DB_ERROR_BADLANGUAGE = 12,
    LIBMSI_DB_ERROR_BADFILENAME = 13,
    LIBMSI_DB_ERROR_BADPATH = 14,
    LIBMSI_DB_ERROR_BADCONDITION = 15,
    LIBMSI_DB_ERROR_BADFORMATTED = 16,
    LIBMSI_DB_ERROR_BADTEMPLATE = 17,
    LIBMSI_DB_ERROR_BADDEFAULTDIR = 18,
    LIBMSI_DB_ERROR_BADREGPATH = 19,
    LIBMSI_DB_ERROR_BADCUSTOMSOURCE = 20,
    LIBMSI_DB_ERROR_BADPROPERTY = 21,
    LIBMSI_DB_ERROR_MISSINGDATA = 22,
    LIBMSI_DB_ERROR_BADCATEGORY = 23,
    LIBMSI_DB_ERROR_BADKEYTABLE = 24,
    LIBMSI_DB_ERROR_BADMAXMINVALUES = 25,
    LIBMSI_DB_ERROR_BADCABINET = 26,
    LIBMSI_DB_ERROR_BADSHORTCUT= 27,
    LIBMSI_DB_ERROR_STRINGOVERFLOW = 28,
    LIBMSI_DB_ERROR_BADLOCALIZEATTRIB = 29
} LibmsiDBError; 

typedef enum LibmsiDBState
{
    LIBMSI_DB_STATE_ERROR = -1,
    LIBMSI_DB_STATE_READ = 0,
    LIBMSI_DB_STATE_WRITE = 1
} LibmsiDBState;


#ifdef __cplusplus
extern "C" {
#endif

#ifndef WINELIB_NAME_AW
#ifdef UNICODE
#define WINELIB_NAME_AW(x) x##W
#else
#define WINELIB_NAME_AW(x) x##A
#endif
#endif

#define MSI_PID_DICTIONARY (0)
#define MSI_PID_CODEPAGE (0x1)
#define MSI_PID_FIRST_USABLE 2
#define MSI_PID_TITLE 2
#define MSI_PID_SUBJECT 3
#define MSI_PID_AUTHOR 4
#define MSI_PID_KEYWORDS 5
#define MSI_PID_COMMENTS 6
#define MSI_PID_TEMPLATE 7
#define MSI_PID_LASTAUTHOR 8
#define MSI_PID_REVNUMBER 9
#define MSI_PID_EDITTIME 10
#define MSI_PID_LASTPRINTED 11
#define MSI_PID_CREATE_DTM 12
#define MSI_PID_LASTSAVE_DTM 13
#define MSI_PID_PAGECOUNT 14
#define MSI_PID_WORDCOUNT 15
#define MSI_PID_CHARCOUNT 16
#define MSI_PID_THUMBNAIL 17
#define MSI_PID_APPNAME 18
#define MSI_PID_SECURITY 19

#define MSI_PID_MSIVERSION MSI_PID_PAGECOUNT
#define MSI_PID_MSISOURCE MSI_PID_WORDCOUNT
#define MSI_PID_MSIRESTRICT MSI_PID_CHARCOUNT


/* view manipulation */
unsigned MsiViewFetch(LibmsiObject *,LibmsiObject **);
unsigned MsiViewExecute(LibmsiObject *,LibmsiObject *);
unsigned MsiViewClose(LibmsiObject *);
unsigned MsiDatabaseOpenViewA(LibmsiObject *,const char *,LibmsiObject **);
unsigned MsiDatabaseOpenViewW(LibmsiObject *,const WCHAR *,LibmsiObject **);
#define     MsiDatabaseOpenView WINELIB_NAME_AW(MsiDatabaseOpenView)
LibmsiDBError MsiViewGetErrorA(LibmsiObject *,char *,unsigned *);
LibmsiDBError MsiViewGetErrorW(LibmsiObject *,WCHAR *,unsigned *);
#define     MsiViewGetError WINELIB_NAME_AW(MsiViewGetError)

LibmsiDBState MsiGetDatabaseState(LibmsiObject *);

/* record manipulation */
LibmsiObject * MsiCreateRecord(unsigned);
unsigned MsiRecordClearData(LibmsiObject *);
unsigned MsiRecordSetInteger(LibmsiObject *,unsigned,int);
unsigned MsiRecordSetStringA(LibmsiObject *,unsigned,const char *);
unsigned MsiRecordSetStringW(LibmsiObject *,unsigned,const WCHAR *);
#define     MsiRecordSetString WINELIB_NAME_AW(MsiRecordSetString)
unsigned MsiRecordGetStringA(LibmsiObject *,unsigned,char *,unsigned *);
unsigned MsiRecordGetStringW(LibmsiObject *,unsigned,WCHAR *,unsigned *);
#define     MsiRecordGetString WINELIB_NAME_AW(MsiRecordGetString)
unsigned MsiRecordGetFieldCount(LibmsiObject *);
int MsiRecordGetInteger(LibmsiObject *,unsigned);
unsigned MsiRecordDataSize(LibmsiObject *,unsigned);
bool MsiRecordIsNull(LibmsiObject *,unsigned);
unsigned MsiFormatRecordA(LibmsiObject *,LibmsiObject *,char *,unsigned *);
unsigned MsiFormatRecordW(LibmsiObject *,LibmsiObject *,WCHAR *,unsigned *);
#define     MsiFormatRecord WINELIB_NAME_AW(MsiFormatRecord)

unsigned MsiRecordSetStream(LibmsiObject *,unsigned,const char *);
unsigned MsiRecordReadStream(LibmsiObject *,unsigned,char*,unsigned *);

unsigned MsiDatabaseGetPrimaryKeysA(LibmsiObject *,const char *,LibmsiObject **);
unsigned MsiDatabaseGetPrimaryKeysW(LibmsiObject *,const WCHAR *,LibmsiObject **);
#define     MsiDatabaseGetPrimaryKeys WINELIB_NAME_AW(MsiDatabaseGetPrimaryKeys)

/* database transforms */
unsigned MsiDatabaseApplyTransformA(LibmsiObject *,const char *,int);
unsigned MsiDatabaseApplyTransformW(LibmsiObject *,const WCHAR *,int);
#define     MsiDatabaseApplyTransform WINELIB_NAME_AW(MsiDatabaseApplyTransform)

unsigned MsiViewGetColumnInfo(LibmsiObject *, LibmsiColInfo, LibmsiObject **);

unsigned MsiCreateTransformSummaryInfoA(LibmsiObject *, LibmsiObject *, const char *, int, int);
unsigned MsiCreateTransformSummaryInfoW(LibmsiObject *, LibmsiObject *, const WCHAR *, int, int);
#define     MsiCreateTransformSummaryInfo WINELIB_NAME_AW(MsiCreateTransformSummaryInfo)

unsigned MsiSummaryInfoGetPropertyA(LibmsiObject *,unsigned,unsigned *,int *,uint64_t*,char *,unsigned *);
unsigned MsiSummaryInfoGetPropertyW(LibmsiObject *,unsigned,unsigned *,int *,uint64_t*,WCHAR *,unsigned *);
#define     MsiSummaryInfoGetProperty WINELIB_NAME_AW(MsiSummaryInfoGetProperty)

unsigned MsiSummaryInfoSetPropertyA(LibmsiObject *, unsigned, unsigned, int, uint64_t*, const char *);
unsigned MsiSummaryInfoSetPropertyW(LibmsiObject *, unsigned, unsigned, int, uint64_t*, const WCHAR *);
#define     MsiSummaryInfoSetProperty WINELIB_NAME_AW(MsiSummaryInfoSetProperty)

unsigned MsiDatabaseExportA(LibmsiObject *, const char *, const char *, const char *);
unsigned MsiDatabaseExportW(LibmsiObject *, const WCHAR *, const WCHAR *, const WCHAR *);
#define     MsiDatabaseExport WINELIB_NAME_AW(MsiDatabaseExport)

unsigned MsiDatabaseImport(LibmsiObject *, const char *, const char *);

unsigned MsiOpenDatabase(const char *, const char *, LibmsiObject **);

LibmsiCondition MsiDatabaseIsTablePersistentA(LibmsiObject *, const char *);
LibmsiCondition MsiDatabaseIsTablePersistentW(LibmsiObject *, const WCHAR *);
#define     MsiDatabaseIsTablePersistent WINELIB_NAME_AW(MsiDatabaseIsTablePersistent)

unsigned MsiSummaryInfoPersist(LibmsiObject *);
unsigned MsiSummaryInfoGetPropertyCount(LibmsiObject *,unsigned *);

unsigned MsiViewModify(LibmsiObject *, LibmsiModify, LibmsiObject *);

unsigned MsiDatabaseMergeA(LibmsiObject *, LibmsiObject *, const char *);
unsigned MsiDatabaseMergeW(LibmsiObject *, LibmsiObject *, const WCHAR *);
#define     MsiDatabaseMerge WINELIB_NAME_AW(MsiDatabaseMerge)

/* Non Unicode */
unsigned MsiGetSummaryInformation(LibmsiObject *, unsigned, LibmsiObject **);
unsigned MsiDatabaseCommit(LibmsiObject *);
unsigned MsiCloseHandle(LibmsiObject *);

LibmsiObject * MsiGetLastErrorRecord(void);

#ifdef __cplusplus
}
#endif

#endif /* _LIBMSI_H */