Fix unterminated string when providing a help string.
[git-cheetah/kirill.git] / factory.c
blob68df04e0670cbeb4eb79d681690a6770867368ea
1 #include <shlobj.h>
2 #include "factory.h"
3 #include "ext.h"
4 #include "menu.h"
6 /*
7 * Since COM objects cannot be constructed like your traditional object (i.e.
8 * with a proper constructor), they have to be constructed by another object,
9 * the class factory.
11 * The class factory is an object which exists exactly once, and it cannot
12 * be constructed or destroyed. Its sole purpose is to construct objects
13 * given an interface.
16 STDMETHODIMP class_factory_query_interface(IClassFactory *this,
17 REFIID guid, void **pointer)
19 if (!IsEqualIID(guid, &IID_IUnknown) &&
20 !IsEqualIID(guid, &IID_IClassFactory)) {
21 *pointer = 0;
22 return E_NOINTERFACE;
25 *pointer = this;
26 return NOERROR;
29 static ULONG STDMETHODCALLTYPE return_one(IClassFactory *this)
31 return(1);
34 static STDMETHODIMP create_instance(IClassFactory *this_,
35 IUnknown *outer, REFIID guid, void **pointer)
37 HRESULT result;
38 struct git_data *data;
40 *pointer = 0;
42 if (outer)
43 return CLASS_E_NOAGGREGATION;
45 if (!(data = GlobalAlloc(GMEM_FIXED, sizeof(struct git_data))))
46 return E_OUTOFMEMORY;
47 memset(data, 0, sizeof(struct git_data));
49 data->shell_ext.virtual_table = &git_shell_ext_virtual_table;
50 data->menu.virtual_table = &git_menu_virtual_table;
51 data->shell_ext.git_data = data->menu.git_data = data;
53 result = query_interface_git_data(data, guid, pointer);
54 if (!result)
55 InterlockedIncrement(&object_count);
56 return result;
59 static STDMETHODIMP lock_server(IClassFactory *this, BOOL lock)
61 if (lock)
62 InterlockedIncrement(&lock_count);
63 else
64 InterlockedDecrement(&lock_count);
66 return NOERROR;
69 IClassFactoryVtbl factory_virtual_table = {
70 class_factory_query_interface,
71 return_one,
72 return_one,
73 create_instance,
74 lock_server
77 IClassFactory factory = {
78 &factory_virtual_table