Skip to content

Commit cb29fb8

Browse files
committed
Merge branch 'mh/use-wincred-from-system'
Code clean-up. * mh/use-wincred-from-system: credential/wincred: include wincred.h
2 parents 91428f0 + 818b4f8 commit cb29fb8

File tree

1 file changed

+1
-60
lines changed

1 file changed

+1
-60
lines changed

contrib/credential/wincred/git-credential-wincred.c

Lines changed: 1 addition & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include <stdio.h>
77
#include <io.h>
88
#include <fcntl.h>
9+
#include <wincred.h>
910

1011
/* common helpers */
1112

@@ -33,64 +34,6 @@ static void *xmalloc(size_t size)
3334
return ret;
3435
}
3536

36-
/* MinGW doesn't have wincred.h, so we need to define stuff */
37-
38-
typedef struct _CREDENTIAL_ATTRIBUTEW {
39-
LPWSTR Keyword;
40-
DWORD Flags;
41-
DWORD ValueSize;
42-
LPBYTE Value;
43-
} CREDENTIAL_ATTRIBUTEW, *PCREDENTIAL_ATTRIBUTEW;
44-
45-
typedef struct _CREDENTIALW {
46-
DWORD Flags;
47-
DWORD Type;
48-
LPWSTR TargetName;
49-
LPWSTR Comment;
50-
FILETIME LastWritten;
51-
DWORD CredentialBlobSize;
52-
LPBYTE CredentialBlob;
53-
DWORD Persist;
54-
DWORD AttributeCount;
55-
PCREDENTIAL_ATTRIBUTEW Attributes;
56-
LPWSTR TargetAlias;
57-
LPWSTR UserName;
58-
} CREDENTIALW, *PCREDENTIALW;
59-
60-
#define CRED_TYPE_GENERIC 1
61-
#define CRED_PERSIST_LOCAL_MACHINE 2
62-
#define CRED_MAX_ATTRIBUTES 64
63-
64-
typedef BOOL (WINAPI *CredWriteWT)(PCREDENTIALW, DWORD);
65-
typedef BOOL (WINAPI *CredEnumerateWT)(LPCWSTR, DWORD, DWORD *,
66-
PCREDENTIALW **);
67-
typedef VOID (WINAPI *CredFreeT)(PVOID);
68-
typedef BOOL (WINAPI *CredDeleteWT)(LPCWSTR, DWORD, DWORD);
69-
70-
static HMODULE advapi;
71-
static CredWriteWT CredWriteW;
72-
static CredEnumerateWT CredEnumerateW;
73-
static CredFreeT CredFree;
74-
static CredDeleteWT CredDeleteW;
75-
76-
static void load_cred_funcs(void)
77-
{
78-
/* load DLLs */
79-
advapi = LoadLibraryExA("advapi32.dll", NULL,
80-
LOAD_LIBRARY_SEARCH_SYSTEM32);
81-
if (!advapi)
82-
die("failed to load advapi32.dll");
83-
84-
/* get function pointers */
85-
CredWriteW = (CredWriteWT)GetProcAddress(advapi, "CredWriteW");
86-
CredEnumerateW = (CredEnumerateWT)GetProcAddress(advapi,
87-
"CredEnumerateW");
88-
CredFree = (CredFreeT)GetProcAddress(advapi, "CredFree");
89-
CredDeleteW = (CredDeleteWT)GetProcAddress(advapi, "CredDeleteW");
90-
if (!CredWriteW || !CredEnumerateW || !CredFree || !CredDeleteW)
91-
die("failed to load functions");
92-
}
93-
9437
static WCHAR *wusername, *password, *protocol, *host, *path, target[1024];
9538

9639
static void write_item(const char *what, LPCWSTR wbuf, int wlen)
@@ -313,8 +256,6 @@ int main(int argc, char *argv[])
313256

314257
read_credential();
315258

316-
load_cred_funcs();
317-
318259
if (!protocol || !(host || path))
319260
return 0;
320261

0 commit comments

Comments
 (0)