no-more-ini-files-20040713
[openafs.git] / src / WINNT / afsd / afsshare.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  * 
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
8  */
9
10 #include <afs/param.h>
11 #include <afs/stds.h>
12
13 #include <windows.h>
14 #include <stdio.h>
15
16 int
17 main(int argc, char **argv) {
18     BOOL res;
19     HKEY hkSubmounts;
20
21     if (argc < 2 || argc > 3) {
22         fprintf(stderr, "Incorrect arguments\n");
23         exit(1);
24     }
25
26     if (RegCreateKeyEx( HKEY_LOCAL_MACHINE,
27                         "SOFTWARE\\OpenAFS\\Client\\Submounts",
28                         0,
29                         NULL,
30                         REG_OPTION_NON_VOLATILE,
31                         KEY_READ|KEY_WRITE,
32                         NULL,
33                         &hkSubmounts,
34                         NULL) == ERROR_SUCCESS) 
35     {
36         if ( argc == 2 ) {
37             if (RegDeleteValue(hkSubmounts, argv[1])) {
38                 fprintf(stderr,"Submount Deletion failure for [%s]: %lX",
39                          argv[1], GetLastError());
40                 return 1;
41             }
42         } else {
43             if (RegSetValueEx(hkSubmounts, argv[1], 0, REG_SZ, argv[2], strlen(argv[2]+1))) {
44                 fprintf(stderr,"Submount Set failure for [%s]: %lX",
45                          argv[1], GetLastError());
46                 return 2;
47             }
48         }
49         RegCloseKey(hkSubmounts);
50     } else {
51         fprintf(stderr,"Submount access denied: %lX", GetLastError());
52         return 3;
53     }
54     return 0;
55 }