Improve Windows Build System By Using MT-safe Versions of Libraries
[openafs.git] / src / WINNT / afsd / fs_utils.c
index 70ed624..9f18f78 100644 (file)
@@ -74,8 +74,7 @@ long fs_GetFullPath(char *pathp, char *outPathp, long outSize)
                /* there's a drive letter there */
         firstp = pathp+2;
         pathHasDrive = 1;
-    }
-    else {
+    } else {
         firstp = pathp;
                pathHasDrive = 0;
        }   
@@ -86,7 +85,7 @@ long fs_GetFullPath(char *pathp, char *outPathp, long outSize)
         return 0;
     }
         
-    GetCurrentDirectory(sizeof(origPath), origPath);
+    GetCurrentDirectoryA(sizeof(origPath), origPath);
         
        doSwitch = 0;
     if (pathHasDrive && (*pathp & ~0x20) != (origPath[0] & ~0x20)) {
@@ -98,14 +97,14 @@ long fs_GetFullPath(char *pathp, char *outPathp, long outSize)
         newPath[0] = *pathp;
         newPath[1] = ':';
         newPath[2] = 0;
-        if (!SetCurrentDirectory(newPath)) {
+        if (!SetCurrentDirectoryA(newPath)) {
                        code = GetLastError();
             return code;
         }
     }
         
     /* now get the absolute path to the current wdir in this drive */
-    GetCurrentDirectory(sizeof(tpath), tpath);
+    GetCurrentDirectoryA(sizeof(tpath), tpath);
     strcpy(outPathp, tpath+2); /* skip drive letter */
        /* if there is a non-null name after the drive, append it */
        if (*firstp != 0) {
@@ -115,7 +114,7 @@ long fs_GetFullPath(char *pathp, char *outPathp, long outSize)
 
        /* finally, if necessary, switch back to our home drive letter */
     if (doSwitch) {
-               SetCurrentDirectory(origPath);
+        SetCurrentDirectoryA(origPath);
     }
         
     return 0;
@@ -141,51 +140,6 @@ static int getmeta(int ac) {
     return 0;
 }
 
-afs_int32 util_GetInt32 (char *as, afs_int32 *aval)
-{
-    register long total;
-    register int tc;
-    int base;
-    int negative;
-
-    total = 0; /* initialize things */
-    negative = 0;
-
-    /* skip over leading spaces */
-    while (tc = *as) {
-       if (tc != ' ' && tc != '\t') break;
-    }
-
-    /* compute sign */
-    if (*as == '-') {
-       negative = 1;
-       as++;   /* skip over character */
-    }
-
-    /* compute the base */
-    if (*as == '0') {
-       as++;
-       if (*as == 'x' || *as == 'X') {
-           base = 16;
-           as++;
-       }
-       else base = 8;
-    }
-    else base = 10;
-
-    /* compute the # itself */
-    while(tc = *as) {
-       if (!ismeta(tc, base)) return -1;
-       total *= base;
-       total += getmeta(tc);
-       as++;
-    }
-
-    if (negative) *aval = -total;
-    else *aval = total;
-    return 0;
-}
-
 char *cm_mount_root="afs"; 
 char *cm_slash_mount_root="/afs";
 char *cm_back_slash_mount_root="\\afs";
@@ -197,8 +151,9 @@ void fs_utils_InitMountRoot()
     char *pmount=mountRoot;
     DWORD len=sizeof(mountRoot)-1;
     printf("int mountroot \n");
-    if ((RegOpenKeyEx(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, 0, KEY_QUERY_VALUE, &parmKey)!= ERROR_SUCCESS) 
-         || (RegQueryValueEx(parmKey, "Mountroot", NULL, NULL,(LPBYTE)(mountRoot), &len)!= ERROR_SUCCESS)
+    if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, 0, 
+                      (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey)!= ERROR_SUCCESS)
+        || (RegQueryValueExA(parmKey, "Mountroot", NULL, NULL,(LPBYTE)(mountRoot), &len)!= ERROR_SUCCESS)
          || (len==sizeof(mountRoot)-1)
          ) 
         strcpy(mountRoot, "\\afs"); 
@@ -215,4 +170,3 @@ void fs_utils_InitMountRoot()
     strcpy(cm_back_slash_mount_root+1,pmount);
     cm_back_slash_mount_root[0]='\\';
 }
-