ReactOS  0.4.14-dev-552-g2fad488
storages.c File Reference
#include <stdarg.h>
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winerror.h"
#include "ole2.h"
#include "msi.h"
#include "msiquery.h"
#include "objbase.h"
#include "msipriv.h"
#include "query.h"
#include "wine/debug.h"
Include dependency graph for storages.c:

Go to the source code of this file.

Classes

struct  tabSTORAGE
 
struct  tagMSISTORAGESVIEW
 

Macros

#define COBJMACROS
 
#define NUM_STORAGES_COLS   2
 
#define MAX_STORAGES_NAME_LEN   62
 

Typedefs

typedef struct tabSTORAGE STORAGE
 
typedef struct tagMSISTORAGESVIEW MSISTORAGESVIEW
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (msidb)
 
static BOOL storages_set_table_size (MSISTORAGESVIEW *sv, UINT size)
 
static STORAGEcreate_storage (MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg)
 
static UINT STORAGES_fetch_int (struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
 
static UINT STORAGES_fetch_stream (struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
 
static UINT STORAGES_get_row (struct tagMSIVIEW *view, UINT row, MSIRECORD **rec)
 
static HRESULT stream_to_storage (IStream *stm, IStorage **stg)
 
static UINT STORAGES_set_row (struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
 
static UINT STORAGES_insert_row (struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary)
 
static UINT STORAGES_delete_row (struct tagMSIVIEW *view, UINT row)
 
static UINT STORAGES_execute (struct tagMSIVIEW *view, MSIRECORD *record)
 
static UINT STORAGES_close (struct tagMSIVIEW *view)
 
static UINT STORAGES_get_dimensions (struct tagMSIVIEW *view, UINT *rows, UINT *cols)
 
static UINT STORAGES_get_column_info (struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
 
static UINT storages_find_row (MSISTORAGESVIEW *sv, MSIRECORD *rec, UINT *row)
 
static UINT storages_modify_update (struct tagMSIVIEW *view, MSIRECORD *rec)
 
static UINT storages_modify_assign (struct tagMSIVIEW *view, MSIRECORD *rec)
 
static UINT STORAGES_modify (struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
 
static UINT STORAGES_delete (struct tagMSIVIEW *view)
 
static UINT STORAGES_find_matching_rows (struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle)
 
static INT add_storages_to_table (MSISTORAGESVIEW *sv)
 
UINT STORAGES_CreateView (MSIDATABASE *db, MSIVIEW **view)
 

Variables

static const MSIVIEWOPS storages_ops
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 23 of file storages.c.

◆ MAX_STORAGES_NAME_LEN

#define MAX_STORAGES_NAME_LEN   62

Definition at line 41 of file storages.c.

◆ NUM_STORAGES_COLS

#define NUM_STORAGES_COLS   2

Definition at line 40 of file storages.c.

Typedef Documentation

◆ MSISTORAGESVIEW

◆ STORAGE

Function Documentation

◆ add_storages_to_table()

static INT add_storages_to_table ( MSISTORAGESVIEW sv)
static

Definition at line 470 of file storages.c.

471 {
472  STORAGE *storage = NULL;
473  IEnumSTATSTG *stgenum = NULL;
474  STATSTG stat;
475  HRESULT hr;
476  UINT count = 0, size;
477 
478  hr = IStorage_EnumElements(sv->db->storage, 0, NULL, 0, &stgenum);
479  if (FAILED(hr))
480  return -1;
481 
482  sv->max_storages = 1;
483  sv->storages = msi_alloc(sizeof(STORAGE *));
484  if (!sv->storages)
485  return -1;
486 
487  while (TRUE)
488  {
489  size = 0;
490  hr = IEnumSTATSTG_Next(stgenum, 1, &stat, &size);
491  if (FAILED(hr) || !size)
492  break;
493 
494  if (stat.type != STGTY_STORAGE)
495  {
496  CoTaskMemFree(stat.pwcsName);
497  continue;
498  }
499 
500  TRACE("enumerated storage %s\n", debugstr_w(stat.pwcsName));
501 
502  storage = create_storage(sv, stat.pwcsName, NULL);
503  if (!storage)
504  {
505  count = -1;
506  CoTaskMemFree(stat.pwcsName);
507  break;
508  }
509 
510  IStorage_OpenStorage(sv->db->storage, stat.pwcsName, NULL,
512  &storage->storage);
513  CoTaskMemFree(stat.pwcsName);
514 
515  if (!storages_set_table_size(sv, ++count))
516  {
517  count = -1;
518  break;
519  }
520 
521  sv->storages[count - 1] = storage;
522  }
523 
524  IEnumSTATSTG_Release(stgenum);
525  return count;
526 }
#define TRUE
Definition: types.h:120
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:420
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
GLuint GLuint GLsizei count
Definition: gl.h:1545
IStorage * storage
Definition: storages.c:46
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
static STORAGE * create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg)
Definition: storages.c:72
#define STGM_READ
Definition: objbase.h:916
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
static BOOL storages_set_table_size(MSISTORAGESVIEW *sv, UINT size)
Definition: storages.c:59
Definition: stat.h:55
MSIDATABASE * db
Definition: storages.c:52
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
unsigned int UINT
Definition: ndis.h:50
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1204
IStorage * storage
Definition: msipriv.h:98
STORAGE ** storages
Definition: storages.c:53

Referenced by STORAGES_CreateView().

◆ create_storage()

static STORAGE* create_storage ( MSISTORAGESVIEW sv,
LPCWSTR  name,
IStorage stg 
)
static

Definition at line 72 of file storages.c.

73 {
74  STORAGE *storage;
75 
76  storage = msi_alloc(sizeof(STORAGE));
77  if (!storage)
78  return NULL;
79 
81  storage->storage = stg;
82 
83  if (storage->storage)
84  IStorage_AddRef(storage->storage);
85 
86  return storage;
87 }
IStorage * storage
Definition: storages.c:46
BOOL msi_add_string(string_table *st, const WCHAR *data, int len, enum StringPersistence persistence) DECLSPEC_HIDDEN
Definition: string.c:307
string_table * strings
Definition: msipriv.h:99
smooth NULL
Definition: ftsmooth.c:416
UINT str_index
Definition: storages.c:45
MSIDATABASE * db
Definition: storages.c:52
Definition: name.c:38
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1204

Referenced by add_storages_to_table(), and STORAGES_set_row().

◆ STORAGES_close()

static UINT STORAGES_close ( struct tagMSIVIEW view)
static

Definition at line 265 of file storages.c.

266 {
267  TRACE("(%p)\n", view);
268  return ERROR_SUCCESS;
269 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRACE(s)
Definition: solgame.cpp:4

◆ STORAGES_CreateView()

UINT STORAGES_CreateView ( MSIDATABASE db,
MSIVIEW **  view 
)

Definition at line 528 of file storages.c.

529 {
530  MSISTORAGESVIEW *sv;
531  INT rows;
532 
533  TRACE("(%p, %p)\n", db, view);
534 
535  sv = msi_alloc_zero( sizeof(MSISTORAGESVIEW) );
536  if (!sv)
537  return ERROR_FUNCTION_FAILED;
538 
539  sv->view.ops = &storages_ops;
540  sv->db = db;
541 
542  rows = add_storages_to_table(sv);
543  if (rows < 0)
544  {
545  msi_free( sv );
546  return ERROR_FUNCTION_FAILED;
547  }
548  sv->num_rows = rows;
549 
550  *view = (MSIVIEW *)sv;
551 
552  return ERROR_SUCCESS;
553 }
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT
Definition: typedefs.h:56
static void * msi_alloc_zero(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1210
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4
const MSIVIEWOPS * ops
Definition: msipriv.h:348
static INT add_storages_to_table(MSISTORAGESVIEW *sv)
Definition: storages.c:470
MSIDATABASE * db
Definition: storages.c:52
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
static const MSIVIEWOPS storages_ops
Definition: storages.c:447

Referenced by TABLE_CreateView().

◆ STORAGES_delete()

static UINT STORAGES_delete ( struct tagMSIVIEW view)
static

Definition at line 397 of file storages.c.

398 {
400  UINT i;
401 
402  TRACE("(%p)\n", view);
403 
404  for (i = 0; i < sv->num_rows; i++)
405  {
406  if (sv->storages[i]->storage)
407  IStorage_Release(sv->storages[i]->storage);
408  msi_free(sv->storages[i]);
409  }
410 
411  msi_free(sv->storages);
412  sv->storages = NULL;
413  msi_free(sv);
414 
415  return ERROR_SUCCESS;
416 }
#define ERROR_SUCCESS
Definition: deptool.c:10
IStorage * storage
Definition: storages.c:46
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int UINT
Definition: ndis.h:50
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
STORAGE ** storages
Definition: storages.c:53

◆ STORAGES_delete_row()

static UINT STORAGES_delete_row ( struct tagMSIVIEW view,
UINT  row 
)
static

Definition at line 253 of file storages.c.

254 {
255  FIXME("(%p %d): stub!\n", view, row);
256  return ERROR_SUCCESS;
257 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define FIXME(fmt,...)
Definition: debug.h:110
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

◆ STORAGES_execute()

static UINT STORAGES_execute ( struct tagMSIVIEW view,
MSIRECORD record 
)
static

Definition at line 259 of file storages.c.

260 {
261  TRACE("(%p, %p)\n", view, record);
262  return ERROR_SUCCESS;
263 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRACE(s)
Definition: solgame.cpp:4

◆ STORAGES_fetch_int()

static UINT STORAGES_fetch_int ( struct tagMSIVIEW view,
UINT  row,
UINT  col,
UINT val 
)
static

Definition at line 89 of file storages.c.

90 {
92 
93  TRACE("(%p, %d, %d, %p)\n", view, row, col, val);
94 
95  if (col != 1)
97 
98  if (row >= sv->num_rows)
99  return ERROR_NO_MORE_ITEMS;
100 
101  *val = sv->storages[row]->str_index;
102 
103  return ERROR_SUCCESS;
104 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
GLuint GLfloat * val
Definition: glext.h:7180
UINT str_index
Definition: storages.c:45
#define TRACE(s)
Definition: solgame.cpp:4
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
STORAGE ** storages
Definition: storages.c:53

Referenced by storages_find_row().

◆ STORAGES_fetch_stream()

static UINT STORAGES_fetch_stream ( struct tagMSIVIEW view,
UINT  row,
UINT  col,
IStream **  stm 
)
static

Definition at line 106 of file storages.c.

107 {
109 
110  TRACE("(%p, %d, %d, %p)\n", view, row, col, stm);
111 
112  if (row >= sv->num_rows)
113  return ERROR_FUNCTION_FAILED;
114 
115  return ERROR_INVALID_DATA;
116 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_INVALID_DATA
Definition: winerror.h:116
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

◆ STORAGES_find_matching_rows()

static UINT STORAGES_find_matching_rows ( struct tagMSIVIEW view,
UINT  col,
UINT  val,
UINT row,
MSIITERHANDLE handle 
)
static

Definition at line 418 of file storages.c.

420 {
423 
424  TRACE("(%d, %d): %d\n", *row, col, val);
425 
426  if (col == 0 || col > NUM_STORAGES_COLS)
428 
429  while (index < sv->num_rows)
430  {
431  if (sv->storages[index]->str_index == val)
432  {
433  *row = index;
434  break;
435  }
436 
437  index++;
438  }
439 
440  *handle = UlongToPtr(++index);
441  if (index >= sv->num_rows)
442  return ERROR_NO_MORE_ITEMS;
443 
444  return ERROR_SUCCESS;
445 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
#define ERROR_NO_MORE_ITEMS
Definition: compat.h:95
#define NUM_STORAGES_COLS
Definition: storages.c:40
GLuint index
Definition: glext.h:6031
#define UlongToPtr(u)
Definition: config.h:106
#define PtrToUlong(u)
Definition: config.h:107
GLuint GLfloat * val
Definition: glext.h:7180
UINT str_index
Definition: storages.c:45
#define TRACE(s)
Definition: solgame.cpp:4
int JSAMPARRAY int int num_rows
Definition: jpegint.h:412
#define index(s, c)
Definition: various.h:29
unsigned int UINT
Definition: ndis.h:50
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
STORAGE ** storages
Definition: storages.c:53

◆ storages_find_row()

static UINT storages_find_row ( MSISTORAGESVIEW sv,
MSIRECORD rec,
UINT row 
)
static

Definition at line 309 of file storages.c.

310 {
311  LPCWSTR str;
312  UINT r, i, id, data;
313 
314  str = MSI_RecordGetString(rec, 1);
315  r = msi_string2id(sv->db->strings, str, -1, &id);
316  if (r != ERROR_SUCCESS)
317  return r;
318 
319  for (i = 0; i < sv->num_rows; i++)
320  {
321  STORAGES_fetch_int(&sv->view, i, 1, &data);
322 
323  if (data == id)
324  {
325  *row = i;
326  return ERROR_SUCCESS;
327  }
328  }
329 
330  return ERROR_FUNCTION_FAILED;
331 }
#define ERROR_SUCCESS
Definition: deptool.c:10
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
string_table * strings
Definition: msipriv.h:99
const WCHAR * str
const WCHAR * MSI_RecordGetString(const MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:482
UINT msi_string2id(const string_table *st, const WCHAR *data, int len, UINT *id) DECLSPEC_HIDDEN
Definition: string.c:404
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
MSIDATABASE * db
Definition: storages.c:52
static UINT STORAGES_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
Definition: storages.c:89
unsigned int UINT
Definition: ndis.h:50
GLenum GLuint id
Definition: glext.h:5579
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by storages_modify_assign(), and storages_modify_update().

◆ STORAGES_get_column_info()

static UINT STORAGES_get_column_info ( struct tagMSIVIEW view,
UINT  n,
LPCWSTR name,
UINT type,
BOOL temporary,
LPCWSTR table_name 
)
static

Definition at line 283 of file storages.c.

285 {
286  TRACE("(%p, %d, %p, %p, %p, %p)\n", view, n, name, type, temporary,
287  table_name);
288 
289  if (n == 0 || n > NUM_STORAGES_COLS)
291 
292  switch (n)
293  {
294  case 1:
295  if (name) *name = szName;
297  break;
298 
299  case 2:
300  if (name) *name = szData;
302  break;
303  }
304  if (table_name) *table_name = szStorages;
305  if (temporary) *temporary = FALSE;
306  return ERROR_SUCCESS;
307 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR szData[]
Definition: msipriv.h:1195
GLdouble n
Definition: glext.h:7729
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define MSITYPE_STRING
Definition: msipriv.h:47
#define NUM_STORAGES_COLS
Definition: storages.c:40
#define MSITYPE_NULLABLE
Definition: msipriv.h:48
#define TRACE(s)
Definition: solgame.cpp:4
static const WCHAR szStorages[]
Definition: msipriv.h:1179
#define MAX_STORAGES_NAME_LEN
Definition: storages.c:41
#define MSITYPE_VALID
Definition: msipriv.h:45
Definition: name.c:38
static const WCHAR szName[]
Definition: msipriv.h:1194

◆ STORAGES_get_dimensions()

static UINT STORAGES_get_dimensions ( struct tagMSIVIEW view,
UINT rows,
UINT cols 
)
static

Definition at line 271 of file storages.c.

272 {
274 
275  TRACE("(%p, %p, %p)\n", view, rows, cols);
276 
277  if (cols) *cols = NUM_STORAGES_COLS;
278  if (rows) *rows = sv->num_rows;
279 
280  return ERROR_SUCCESS;
281 }
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NUM_STORAGES_COLS
Definition: storages.c:40
#define TRACE(s)
Definition: solgame.cpp:4

◆ STORAGES_get_row()

static UINT STORAGES_get_row ( struct tagMSIVIEW view,
UINT  row,
MSIRECORD **  rec 
)
static

Definition at line 118 of file storages.c.

119 {
121 
122  FIXME("%p %d %p\n", sv, row, rec);
123 
125 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

◆ STORAGES_insert_row()

static UINT STORAGES_insert_row ( struct tagMSIVIEW view,
MSIRECORD rec,
UINT  row,
BOOL  temporary 
)
static

Definition at line 238 of file storages.c.

239 {
241 
242  if (!storages_set_table_size(sv, ++sv->num_rows))
243  return ERROR_FUNCTION_FAILED;
244 
245  if (row == -1)
246  row = sv->num_rows - 1;
247 
248  /* FIXME have to readjust rows */
249 
250  return STORAGES_set_row(view, row, rec, 0);
251 }
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
static BOOL storages_set_table_size(MSISTORAGESVIEW *sv, UINT size)
Definition: storages.c:59
static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
Definition: storages.c:176
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by STORAGES_modify(), and storages_modify_assign().

◆ STORAGES_modify()

static UINT STORAGES_modify ( struct tagMSIVIEW view,
MSIMODIFY  eModifyMode,
MSIRECORD rec,
UINT  row 
)
static

Definition at line 357 of file storages.c.

358 {
359  UINT r;
360 
361  TRACE("%p %d %p\n", view, eModifyMode, rec);
362 
363  switch (eModifyMode)
364  {
365  case MSIMODIFY_ASSIGN:
366  r = storages_modify_assign(view, rec);
367  break;
368 
369  case MSIMODIFY_INSERT:
370  r = STORAGES_insert_row(view, rec, -1, FALSE);
371  break;
372 
373  case MSIMODIFY_UPDATE:
374  r = storages_modify_update(view, rec);
375  break;
376 
379  case MSIMODIFY_REFRESH:
380  case MSIMODIFY_REPLACE:
381  case MSIMODIFY_MERGE:
382  case MSIMODIFY_DELETE:
383  case MSIMODIFY_VALIDATE:
386  FIXME("%p %d %p - mode not implemented\n", view, eModifyMode, rec );
388  break;
389 
390  default:
392  }
393 
394  return r;
395 }
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT STORAGES_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary)
Definition: storages.c:238
static UINT storages_modify_assign(struct tagMSIVIEW *view, MSIRECORD *rec)
Definition: storages.c:345
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRACE(s)
Definition: solgame.cpp:4
static UINT storages_modify_update(struct tagMSIVIEW *view, MSIRECORD *rec)
Definition: storages.c:333
#define ERROR_INVALID_DATA
Definition: winerror.h:116
unsigned int UINT
Definition: ndis.h:50
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92

◆ storages_modify_assign()

static UINT storages_modify_assign ( struct tagMSIVIEW view,
MSIRECORD rec 
)
static

Definition at line 345 of file storages.c.

346 {
348  UINT r, row;
349 
350  r = storages_find_row(sv, rec, &row);
351  if (r == ERROR_SUCCESS)
352  return storages_modify_update(view, rec);
353 
354  return STORAGES_insert_row(view, rec, -1, FALSE);
355 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
static UINT STORAGES_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary)
Definition: storages.c:238
static UINT storages_find_row(MSISTORAGESVIEW *sv, MSIRECORD *rec, UINT *row)
Definition: storages.c:309
static UINT storages_modify_update(struct tagMSIVIEW *view, MSIRECORD *rec)
Definition: storages.c:333
unsigned int UINT
Definition: ndis.h:50
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by STORAGES_modify().

◆ storages_modify_update()

static UINT storages_modify_update ( struct tagMSIVIEW view,
MSIRECORD rec 
)
static

Definition at line 333 of file storages.c.

334 {
336  UINT r, row;
337 
338  r = storages_find_row(sv, rec, &row);
339  if (r != ERROR_SUCCESS)
340  return ERROR_FUNCTION_FAILED;
341 
342  return STORAGES_set_row(view, row, rec, 0);
343 }
#define ERROR_SUCCESS
Definition: deptool.c:10
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
static UINT storages_find_row(MSISTORAGESVIEW *sv, MSIRECORD *rec, UINT *row)
Definition: storages.c:309
unsigned int UINT
Definition: ndis.h:50
static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
Definition: storages.c:176
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78

Referenced by STORAGES_modify(), and storages_modify_assign().

◆ STORAGES_set_row()

static UINT STORAGES_set_row ( struct tagMSIVIEW view,
UINT  row,
MSIRECORD rec,
UINT  mask 
)
static

Definition at line 176 of file storages.c.

177 {
179  IStorage *stg, *substg = NULL;
180  IStream *stm;
181  LPWSTR name = NULL;
182  HRESULT hr;
184 
185  TRACE("(%p, %p)\n", view, rec);
186 
187  if (row > sv->num_rows)
188  return ERROR_FUNCTION_FAILED;
189 
190  r = MSI_RecordGetIStream(rec, 2, &stm);
191  if (r != ERROR_SUCCESS)
192  return r;
193 
194  r = stream_to_storage(stm, &stg);
195  if (r != ERROR_SUCCESS)
196  {
197  IStream_Release(stm);
198  return r;
199  }
200 
201  name = strdupW(MSI_RecordGetString(rec, 1));
202  if (!name)
203  {
205  goto done;
206  }
207 
208  hr = IStorage_CreateStorage(sv->db->storage, name,
210  0, 0, &substg);
211  if (FAILED(hr))
212  {
214  goto done;
215  }
216 
217  hr = IStorage_CopyTo(stg, 0, NULL, NULL, substg);
218  if (FAILED(hr))
219  {
221  goto done;
222  }
223 
224  sv->storages[row] = create_storage(sv, name, stg);
225  if (!sv->storages[row])
227 
228 done:
229  msi_free(name);
230 
231  if (substg) IStorage_Release(substg);
232  IStorage_Release(stg);
233  IStream_Release(stm);
234 
235  return r;
236 }
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define STGM_SHARE_EXCLUSIVE
Definition: objbase.h:922
static WCHAR * strdupW(const WCHAR *src)
Definition: main.c:92
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
UINT MSI_RecordGetIStream(MSIRECORD *, UINT, IStream **) DECLSPEC_HIDDEN
Definition: record.c:905
#define ERROR_FUNCTION_FAILED
Definition: winerror.h:985
smooth NULL
Definition: ftsmooth.c:416
static STORAGE * create_storage(MSISTORAGESVIEW *sv, LPCWSTR name, IStorage *stg)
Definition: storages.c:72
#define STGM_WRITE
Definition: objbase.h:917
const WCHAR * MSI_RecordGetString(const MSIRECORD *, UINT) DECLSPEC_HIDDEN
Definition: record.c:482
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:77
static HRESULT stream_to_storage(IStream *stm, IStorage **stg)
Definition: storages.c:127
MSIDATABASE * db
Definition: storages.c:52
unsigned int UINT
Definition: ndis.h:50
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
Definition: name.c:38
IStorage * storage
Definition: msipriv.h:98
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
STORAGE ** storages
Definition: storages.c:53

Referenced by STORAGES_insert_row(), and storages_modify_update().

◆ storages_set_table_size()

static BOOL storages_set_table_size ( MSISTORAGESVIEW sv,
UINT  size 
)
static

Definition at line 59 of file storages.c.

60 {
61  if (size >= sv->max_storages)
62  {
63  sv->max_storages *= 2;
64  sv->storages = msi_realloc(sv->storages, sv->max_storages * sizeof(STORAGE *));
65  if (!sv->storages)
66  return FALSE;
67  }
68 
69  return TRUE;
70 }
#define TRUE
Definition: types.h:120
static void * msi_realloc(void *mem, size_t len) __WINE_ALLOC_SIZE(2)
Definition: msipriv.h:1216
GLsizeiptr size
Definition: glext.h:5919
STORAGE ** storages
Definition: storages.c:53

Referenced by add_storages_to_table(), and STORAGES_insert_row().

◆ stream_to_storage()

static HRESULT stream_to_storage ( IStream stm,
IStorage **  stg 
)
static

Definition at line 127 of file storages.c.

128 {
129  ILockBytes *lockbytes = NULL;
130  STATSTG stat;
131  LPVOID data;
132  HRESULT hr;
133  DWORD size, read;
135 
136  hr = IStream_Stat(stm, &stat, STATFLAG_NONAME);
137  if (FAILED(hr))
138  return hr;
139 
140  if (stat.cbSize.QuadPart >> 32)
141  {
142  ERR("Storage is too large\n");
143  return E_FAIL;
144  }
145 
146  size = stat.cbSize.QuadPart;
147  data = msi_alloc(size);
148  if (!data)
149  return E_OUTOFMEMORY;
150 
151  hr = IStream_Read(stm, data, size, &read);
152  if (FAILED(hr) || read != size)
153  goto done;
154 
155  hr = CreateILockBytesOnHGlobal(NULL, TRUE, &lockbytes);
156  if (FAILED(hr))
157  goto done;
158 
159  ZeroMemory(&offset, sizeof(ULARGE_INTEGER));
160  hr = ILockBytes_WriteAt(lockbytes, offset, data, size, &read);
161  if (FAILED(hr) || read != size)
162  goto done;
163 
164  hr = StgOpenStorageOnILockBytes(lockbytes, NULL,
166  NULL, 0, stg);
167  if (FAILED(hr))
168  goto done;
169 
170 done:
171  msi_free(data);
172  if (lockbytes) ILockBytes_Release(lockbytes);
173  return hr;
174 }
#define STGM_SHARE_DENY_NONE
Definition: objbase.h:919
#define TRUE
Definition: types.h:120
HRESULT WINAPI CreateILockBytesOnHGlobal(HGLOBAL global, BOOL delete_on_release, ILockBytes **ret)
Definition: memlockbytes.c:98
HRESULT hr
Definition: shlfolder.c:183
GLintptr offset
Definition: glext.h:5920
#define ZeroMemory
Definition: winbase.h:1642
#define E_FAIL
Definition: ddrawi.h:102
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
LONG HRESULT
Definition: typedefs.h:77
unsigned long DWORD
Definition: ntddk_ex.h:95
HRESULT WINAPI StgOpenStorageOnILockBytes(ILockBytes *plkbyt, IStorage *pstgPriority, DWORD grfMode, SNB snbExclude, DWORD reserved, IStorage **ppstgOpen)
Definition: storage32.c:8984
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: stat.h:55
#define STGM_READWRITE
Definition: objbase.h:918
#define ERR(fmt,...)
Definition: debug.h:109
_CRTIMP int __cdecl stat(const char *_Filename, struct stat *_Stat)
Definition: stat.h:345
static BOOL msi_free(void *mem)
Definition: msipriv.h:1227
static void * msi_alloc(size_t len) __WINE_ALLOC_SIZE(1)
Definition: msipriv.h:1204
_CRTIMP int __cdecl read(_In_ int _FileHandle, _Out_writes_bytes_(_MaxCharCount) void *_DstBuf, _In_ unsigned int _MaxCharCount)

Referenced by STORAGES_set_row().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( msidb  )

Variable Documentation

◆ storages_ops

const MSIVIEWOPS storages_ops
static
Initial value:
=
{
}
static UINT STORAGES_close(struct tagMSIVIEW *view)
Definition: storages.c:265
static UINT STORAGES_get_column_info(struct tagMSIVIEW *view, UINT n, LPCWSTR *name, UINT *type, BOOL *temporary, LPCWSTR *table_name)
Definition: storages.c:283
static UINT STORAGES_fetch_stream(struct tagMSIVIEW *view, UINT row, UINT col, IStream **stm)
Definition: storages.c:106
static UINT STORAGES_get_row(struct tagMSIVIEW *view, UINT row, MSIRECORD **rec)
Definition: storages.c:118
static UINT STORAGES_insert_row(struct tagMSIVIEW *view, MSIRECORD *rec, UINT row, BOOL temporary)
Definition: storages.c:238
static UINT STORAGES_delete(struct tagMSIVIEW *view)
Definition: storages.c:397
smooth NULL
Definition: ftsmooth.c:416
static UINT STORAGES_find_matching_rows(struct tagMSIVIEW *view, UINT col, UINT val, UINT *row, MSIITERHANDLE *handle)
Definition: storages.c:418
static UINT STORAGES_modify(struct tagMSIVIEW *view, MSIMODIFY eModifyMode, MSIRECORD *rec, UINT row)
Definition: storages.c:357
static UINT STORAGES_get_dimensions(struct tagMSIVIEW *view, UINT *rows, UINT *cols)
Definition: storages.c:271
static UINT STORAGES_delete_row(struct tagMSIVIEW *view, UINT row)
Definition: storages.c:253
static UINT STORAGES_fetch_int(struct tagMSIVIEW *view, UINT row, UINT col, UINT *val)
Definition: storages.c:89
static UINT STORAGES_set_row(struct tagMSIVIEW *view, UINT row, MSIRECORD *rec, UINT mask)
Definition: storages.c:176
static UINT STORAGES_execute(struct tagMSIVIEW *view, MSIRECORD *record)
Definition: storages.c:259

Definition at line 447 of file storages.c.

Referenced by STORAGES_CreateView().