2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
10 #include <afsconfig.h>
11 #include <afs/param.h>
32 #include <WINNT\afsreg.h>
34 long fs_ExtractDriveLetter(char *inPathp, char *outPathp)
36 if (inPathp[0] != 0 && inPathp[1] == ':') {
37 /* there is a drive letter */
38 *outPathp++ = *inPathp++;
39 *outPathp++ = *inPathp++;
47 /* strip the drive letter from a component */
48 long fs_StripDriveLetter(char *inPathp, char *outPathp, long outSize)
50 char tempBuffer[1000];
51 strcpy(tempBuffer, inPathp);
52 if (tempBuffer[0] != 0 && tempBuffer[1] == ':') {
53 /* drive letter present */
54 strcpy(outPathp, tempBuffer+2);
57 /* no drive letter present */
58 strcpy(outPathp, tempBuffer);
63 /* take a path with a drive letter, possibly relative, and return a full path
64 * without the drive letter. This is the full path relative to the working
65 * dir for that drive letter. The input and output paths can be the same.
67 long fs_GetFullPath(char *pathp, char *outPathp, long outSize)
77 if (pathp[0] != 0 && pathp[1] == ':') {
78 /* there's a drive letter there */
86 if (*firstp == '\\' || *firstp == '/') {
87 /* already an absolute pathname, just copy it back */
88 strcpy(outPathp, firstp);
92 GetCurrentDirectoryA(sizeof(origPath), origPath);
95 if (pathHasDrive && (*pathp & ~0x20) != (origPath[0] & ~0x20)) {
96 /* a drive has been specified and it isn't our current drive.
97 * to get path, switch to it first. Must case-fold drive letters
98 * for user convenience.
104 if (!SetCurrentDirectoryA(newPath)) {
105 code = GetLastError();
110 /* now get the absolute path to the current wdir in this drive */
111 GetCurrentDirectoryA(sizeof(tpath), tpath);
112 strcpy(outPathp, tpath+2); /* skip drive letter */
113 /* if there is a non-null name after the drive, append it */
115 strcat(outPathp, "\\");
116 strcat(outPathp, firstp);
119 /* finally, if necessary, switch back to our home drive letter */
121 SetCurrentDirectoryA(origPath);
127 /* is this a digit or a digit-like thing? */
128 static int ismeta(int abase, int ac) {
129 /* if (ac == '-' || ac == 'x' || ac == 'X') return 1; */
130 if (ac >= '0' && ac <= '7') return 1;
131 if (abase <= 8) return 0;
132 if (ac >= '8' && ac <= '9') return 1;
133 if (abase <= 10) return 0;
134 if (ac >= 'a' && ac <= 'f') return 1;
135 if (ac >= 'A' && ac <= 'F') return 1;
139 /* given that this is a digit or a digit-like thing, compute its value */
140 static int getmeta(int ac) {
141 if (ac >= '0' && ac <= '9') return ac - '0';
142 if (ac >= 'a' && ac <= 'f') return ac - 'a' + 10;
143 if (ac >= 'A' && ac <= 'F') return ac - 'A' + 10;
147 char *cm_mount_root="afs";
148 char *cm_slash_mount_root="/afs";
149 char *cm_back_slash_mount_root="\\afs";
151 void fs_utils_InitMountRoot()
154 char mountRoot[MAX_PATH+1];
155 char *pmount=mountRoot;
156 DWORD len=sizeof(mountRoot)-1;
157 printf("int mountroot \n");
158 if ((RegOpenKeyExA(HKEY_LOCAL_MACHINE, AFSREG_CLT_SVC_PARAM_SUBKEY, 0,
159 (IsWow64()?KEY_WOW64_64KEY:0)|KEY_QUERY_VALUE, &parmKey)!= ERROR_SUCCESS)
160 || (RegQueryValueExA(parmKey, "Mountroot", NULL, NULL,(LPBYTE)(mountRoot), &len)!= ERROR_SUCCESS)
161 || (len==sizeof(mountRoot)-1)
163 strcpy(mountRoot, "\\afs");
164 RegCloseKey(parmKey);
165 mountRoot[len]=0; /*safety see ms-help://MS.MSDNQTR.2002OCT.1033/sysinfo/base/regqueryvalueex.htm*/
166 cm_mount_root=malloc(len+1);
167 cm_slash_mount_root=malloc(len+2);
168 cm_back_slash_mount_root=malloc(len+2);
169 if ((*pmount=='/') || (*pmount='\\'))
171 strcpy(cm_mount_root,pmount);
172 strcpy(cm_slash_mount_root+1,pmount);
173 cm_slash_mount_root[0]='/';
174 strcpy(cm_back_slash_mount_root+1,pmount);
175 cm_back_slash_mount_root[0]='\\';