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 <afs/param.h>
13 /*#include <windows.h>*/
23 /*#include <winsock2.h>*/
25 #include "afsd_init.h"
28 char main_statusText[100];
31 extern int traceOnPanic;
32 BOOL InitInstance(struct cmd_syndesc *as, char *arock);
33 extern int afs_shutdown;
36 int afs_current_status = AFS_STATUS_INIT;
39 * Notifier function for use by osi_panic
41 void afsd_notifier(char *msgp, char *filep, long line)
45 sprintf(tbuffer, "Error at file %s, line %d", filep, line);
47 strcpy(tbuffer, "Error at unknown location");
50 msgp = "Assertion failure";
52 /*MessageBox(NULL, tbuffer, msgp, MB_OK|MB_ICONSTOP|MB_SETFOREGROUND);*/
54 afsd_ForceTrace(TRUE);
61 afs_exit(AFS_EXITCODE_PANIC);
64 /* Init function called when window application starts. Inits instance and
65 * application together, since in Win32 they're essentially the same.
67 * Function then goes into a loop handling user interface messages. Most are
68 * used to handle redrawing the icon.
70 int main(int argc, char *argv[])
72 struct cmd_syndesc *ts;
74 fprintf(stderr, "AFS Client for Windows 95.\n");
75 /*fprintf(stderr, "Use Ctrl-C to shut down client.\n\n\n");*/
76 ts = cmd_CreateSyntax((char *) 0, (int (*)()) InitInstance, (char *) 0, "start AFS");
77 cmd_AddParm(ts, "-lanadapt", CMD_SINGLE, CMD_OPTIONAL, "LAN adapter number");
78 cmd_AddParm(ts, "-threads", CMD_SINGLE, CMD_OPTIONAL, "Number of server threads");
79 cmd_AddParm(ts, "-rootvol", CMD_SINGLE, CMD_OPTIONAL, "name of AFS root volume");
80 cmd_AddParm(ts, "-stat", CMD_SINGLE, CMD_OPTIONAL, "number of stat entries");
81 cmd_AddParm(ts, "-memcache", CMD_FLAG, CMD_OPTIONAL, "use memory cache");
82 cmd_AddParm(ts, "-cachedir", CMD_SINGLE, CMD_OPTIONAL, "cache directory");
83 cmd_AddParm(ts, "-mountdir", CMD_SINGLE, CMD_OPTIONAL, "mount location");
84 cmd_AddParm(ts, "-daemons", CMD_SINGLE, CMD_OPTIONAL, "number of daemons to use");
85 cmd_AddParm(ts, "-nosettime", CMD_FLAG, CMD_OPTIONAL, "don't set the time");
86 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "display lots of information");
87 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL, "display debug info");
88 cmd_AddParm(ts, "-chunksize", CMD_SINGLE, CMD_OPTIONAL, "log(2) of chunk size");
89 cmd_AddParm(ts, "-dcache", CMD_SINGLE, CMD_OPTIONAL, "number of dcache entries");
90 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL, "configuration directory");
91 cmd_AddParm(ts, "-logfile", CMD_SINGLE, CMD_OPTIONAL, "Place to keep the CM log");
92 cmd_AddParm(ts, "-waitclose", CMD_FLAG, CMD_OPTIONAL, "make close calls synchronous");
93 cmd_AddParm(ts, "-shutdown", CMD_FLAG, CMD_OPTIONAL, "Shutdown all afs state");
94 cmd_AddParm(ts, "-sysname", CMD_SINGLE, CMD_OPTIONAL, "System name (@sys value)");
95 cmd_AddParm(ts, "-gateway", CMD_FLAG, CMD_OPTIONAL, "machine is a gateway");
96 cmd_AddParm(ts, "-tracebuf", CMD_SINGLE, CMD_OPTIONAL, "trace buffer size");
97 cmd_AddParm(ts, "-startup", CMD_FLAG, CMD_OPTIONAL, "start AFS client");
98 cmd_AddParm(ts, "-diskcache", CMD_SINGLE, CMD_OPTIONAL, "diskcache size");
99 cmd_AddParm(ts, "-afsdb", CMD_FLAG, CMD_OPTIONAL, "use DNS for cell server resolution");
100 cmd_AddParm(ts, "-freelance", CMD_FLAG, CMD_OPTIONAL, "virtual AFS root");
102 return (cmd_Dispatch(argc, argv));
105 /* initialize the process. Reads the init files to get the appropriate
107 void vxd_Shutdown(void);
108 int afsd_shutdown(int);
109 int shutdown_handler(int);
111 BOOL InitInstance(struct cmd_syndesc *as, char *arock)
121 osi_InitPanic(afsd_notifier);
128 code = afsMsg_Init();
130 osi_panic("socket failure", __FILE__, __LINE__);
132 code = afsd_InitCM(&reason, as, arock);
134 osi_panic(reason, __FILE__, __LINE__);
136 code = afsd_InitDaemons(&reason);
138 osi_panic(reason, __FILE__, __LINE__);
140 code = afsd_InitSMB(&reason);
142 osi_panic(reason, __FILE__, __LINE__);
144 signal(SIGINT, shutdown_handler);
146 thrd_Yield(); /* give new threads a chance to run */
148 /* send message to GUI caller indicating successful init */
149 afs_current_status = AFS_STATUS_RUNNING;
150 afsMsg_StatusChange(afs_current_status, 0, NULL);
153 /* Keep the process from just terminating */
154 while(afs_shutdown == 0)
156 /*IOMGR_Sleep(180);*/
158 /* workaround: WaitForKeystroke(nonzero num) calls
159 IOMGR_Select, though Win95 select works only on sockets */
160 /* so, we poll instead */
161 /*if (LWP_WaitForKeystroke(0))
171 int shutdown_handler(int x)
175 fprintf(stderr, "This program should not be shut down manually. It should "
176 "be shut down by the\nWindows AFS Client Control Center. Press Ctrl-C "
177 "again if you really want to do this.\n");
183 fprintf(stderr, "Shutting down AFSD...\n");
189 int afsd_shutdown(int x)
197 fprintf(stderr, "AFSD shutdown complete.\n");
201 void afs_exit(int exitCode)
203 afs_current_status = AFS_STATUS_EXITING;
204 afsMsg_StatusChange(afs_current_status,