Make the cmd config file parser build on Windows
authorSimon Wilkinson <sxw@your-file-system.com>
Sun, 22 Apr 2012 14:20:18 +0000 (10:20 -0400)
committerDerrick Brashear <shadow@dementix.org>
Fri, 11 May 2012 23:40:55 +0000 (16:40 -0700)
Change-Id: Id6c3515869529b6fb5c48a06661b63bed974e436
Reviewed-on: http://gerrit.openafs.org/7141
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@secure-endpoints.com>

src/cmd/NTMakefile
src/cmd/krb5_locl.h

index 053a10c..9033e9b 100644 (file)
@@ -15,6 +15,8 @@ INCFILEDIR = $(DESTDIR)\include\afs
 INCFILES =\
        $(INCFILEDIR)\cmd.h
 
+HEIMDAL = ..\external\heimdal\krb5
+
 
 # build afscmd.lib
 LIBFILE = $(DESTDIR)\lib\afs\afscmd.lib
@@ -23,11 +25,21 @@ LIBOBJS =\
        $(OUT)\cmd_errors.obj \
        $(OUT)\cmd.obj \
        $(OUT)\AFS_component_version_number.obj
-       
+
+HEIMOBJS =\
+        $(OUT)\config_file.obj \
+       $(OUT)\expand_path.obj
+
 $(LIBOBJS): $$(@B).c
     $(C2OBJ) $**
 
-$(LIBFILE): $(LIBOBJS)
+$(OUT)\expand_path.obj: $(HEIMDAL)\$$(@B).c
+       $(C2OBJ) -I$(HEIMDAL) -DEXPAND_PATH_HEADER $**
+
+$(OUT)\config_file.obj: $(HEIMDAL)\$$(@B).c
+        $(C2OBJ) -I$(HEIMDAL) -DKRB5_USE_PATH_TOKENS $**
+
+$(LIBFILE): $(LIBOBJS) $(HEIMOBJS)
        $(LIBARCH) 
 
 $(INCFILES):$$(@F)
index bbb1798..fde8846 100644 (file)
@@ -7,22 +7,15 @@
 #include <afsconfig.h>
 #include <afs/stds.h>
 
+#include <roken.h>
+
 #include <assert.h>
 #include <ctype.h>
-#include <errno.h>
-#include <pwd.h>
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <time.h>
-#include <unistd.h>
-
-#include <roken.h>
 
 #include "cmd.h"
 
+#define PACKAGE "openafs"
+
 #ifndef TRUE
 # define TRUE 1
 #endif
@@ -37,8 +30,6 @@
 
 #define KRB5_DEPRECATED_FUNCTION(x)
 
-#define KRB5_CONFIG_BADFORMAT                    CMD_BADFORMAT
-
 #define N_(X,Y) X
 
 typedef struct cmd_config_binding krb5_config_binding;
@@ -56,6 +47,41 @@ typedef int krb5_error_code;
 typedef int krb5_boolean;
 typedef time_t krb5_deltat;
 
+static void krb5_set_error_message(krb5_context context, krb5_error_code ret,
+                                  const char *fmt, ...) {
+    return;
+}
+
+#ifdef EXPAND_PATH_HEADER
+
+#include <shlobj.h>
+
+static int _krb5_expand_path_tokens(krb5_context, const char *, char**);
+
+int
+_cmd_ExpandPathTokens(krb5_context context, const char *in, char **out) {
+    return _krb5_expand_path_tokens(context, in, out);
+}
+
+HINSTANCE _krb5_hInstance = NULL;
+
+/* This bodge avoids the need for everything linking against cmd to also
+ * link against the shell library on Windows */
+#undef SHGetFolderPath
+#define SHGetFolderPath internal_getpath
+
+HRESULT internal_getpath(void *a, int b, void *c, DWORD d, LPTSTR out) {
+    return E_INVALIDARG;
+}
+
+#else
+
+#define KRB5_CONFIG_BADFORMAT                    CMD_BADFORMAT
+
+#define _krb5_expand_path_tokens _cmd_ExpandPathTokens
+
+extern int _cmd_ExpandPathTokens(krb5_context, const char *, char **);
+
 static const void *_krb5_config_vget(krb5_context,
                                     const krb5_config_section *, int,
                                     va_list);
@@ -92,10 +118,6 @@ KRB5_LIB_FUNCTION void krb5_clear_error_message(krb5_context context) {
     return;
 }
 
-static void krb5_set_error_message(krb5_context context, krb5_error_code ret,
-                                  const char *fmt, ...) {
-    return;
-}
 
 static int _krb5_homedir_access(krb5_context context) {
     return 0;
@@ -115,6 +137,7 @@ krb5_abortx(krb5_context context, const char *fmt, ...)
 
 /* Wrappers */
 
+
 int
 cmd_RawConfigParseFileMulti(const char *fname, cmd_config_section **res) {
     return krb5_config_parse_file_multi(NULL, fname, res);
@@ -187,3 +210,4 @@ cmd_RawConfigGetList(const cmd_config_section *c, ...)
 
     return ret;
 }
+#endif