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);
60 afs_exit(AFS_EXITCODE_PANIC);
63 /* Init function called when window application starts. Inits instance and
64 * application together, since in Win32 they're essentially the same.
66 * Function then goes into a loop handling user interface messages. Most are
67 * used to handle redrawing the icon.
69 int main(int argc, char *argv[])
71 struct cmd_syndesc *ts;
73 fprintf(stderr, "AFS Client for Windows 95.\n");
74 /*fprintf(stderr, "Use Ctrl-C to shut down client.\n\n\n");*/
75 ts = cmd_CreateSyntax((char *) 0, (int (*)()) InitInstance, (char *) 0, "start AFS");
76 cmd_AddParm(ts, "-lanadapt", CMD_SINGLE, CMD_OPTIONAL, "LAN adapter number");
77 cmd_AddParm(ts, "-threads", CMD_SINGLE, CMD_OPTIONAL, "Number of server threads");
78 cmd_AddParm(ts, "-rootvol", CMD_SINGLE, CMD_OPTIONAL, "name of AFS root volume");
79 cmd_AddParm(ts, "-stat", CMD_SINGLE, CMD_OPTIONAL, "number of stat entries");
80 cmd_AddParm(ts, "-memcache", CMD_FLAG, CMD_OPTIONAL, "use memory cache");
81 cmd_AddParm(ts, "-cachedir", CMD_SINGLE, CMD_OPTIONAL, "cache directory");
82 cmd_AddParm(ts, "-mountdir", CMD_SINGLE, CMD_OPTIONAL, "mount location");
83 cmd_AddParm(ts, "-daemons", CMD_SINGLE, CMD_OPTIONAL, "number of daemons to use");
84 cmd_AddParm(ts, "-nosettime", CMD_FLAG, CMD_OPTIONAL, "don't set the time");
85 cmd_AddParm(ts, "-verbose", CMD_FLAG, CMD_OPTIONAL, "display lots of information");
86 cmd_AddParm(ts, "-debug", CMD_FLAG, CMD_OPTIONAL, "display debug info");
87 cmd_AddParm(ts, "-chunksize", CMD_SINGLE, CMD_OPTIONAL, "log(2) of chunk size");
88 cmd_AddParm(ts, "-dcache", CMD_SINGLE, CMD_OPTIONAL, "number of dcache entries");
89 cmd_AddParm(ts, "-confdir", CMD_SINGLE, CMD_OPTIONAL, "configuration directory");
90 cmd_AddParm(ts, "-logfile", CMD_SINGLE, CMD_OPTIONAL, "Place to keep the CM log");
91 cmd_AddParm(ts, "-waitclose", CMD_FLAG, CMD_OPTIONAL, "make close calls synchronous");
92 cmd_AddParm(ts, "-shutdown", CMD_FLAG, CMD_OPTIONAL, "Shutdown all afs state");
93 cmd_AddParm(ts, "-sysname", CMD_SINGLE, CMD_OPTIONAL, "System name (@sys value)");
94 cmd_AddParm(ts, "-gateway", CMD_FLAG, CMD_OPTIONAL, "machine is a gateway");
95 cmd_AddParm(ts, "-tracebuf", CMD_SINGLE, CMD_OPTIONAL, "trace buffer size");
96 cmd_AddParm(ts, "-startup", CMD_FLAG, CMD_OPTIONAL, "start AFS client");
97 cmd_AddParm(ts, "-diskcache", CMD_SINGLE, CMD_OPTIONAL, "diskcache size");
98 cmd_AddParm(ts, "-afsdb", CMD_FLAG, CMD_OPTIONAL, "use DNS for cell server resolution");
99 cmd_AddParm(ts, "-freelance", CMD_FLAG, CMD_OPTIONAL, "virtual AFS root");
101 return (cmd_Dispatch(argc, argv));
104 /* initialize the process. Reads the init files to get the appropriate
106 void vxd_Shutdown(void);
107 int afsd_shutdown(int);
108 int shutdown_handler(int);
110 BOOL InitInstance(struct cmd_syndesc *as, char *arock)
120 osi_InitPanic(afsd_notifier);
127 code = afsMsg_Init();
129 osi_panic("socket failure", __FILE__, __LINE__);
131 code = afsd_InitCM(&reason, as, arock);
133 osi_panic(reason, __FILE__, __LINE__);
135 code = afsd_InitDaemons(&reason);
137 osi_panic(reason, __FILE__, __LINE__);
139 code = afsd_InitSMB(&reason);
141 osi_panic(reason, __FILE__, __LINE__);
143 signal(SIGINT, shutdown_handler);
145 thrd_Yield(); /* give new threads a chance to run */
147 /* send message to GUI caller indicating successful init */
148 afs_current_status = AFS_STATUS_RUNNING;
149 afsMsg_StatusChange(afs_current_status, 0, NULL);
152 /* Keep the process from just terminating */
153 while(afs_shutdown == 0)
155 /*IOMGR_Sleep(180);*/
157 /* workaround: WaitForKeystroke(nonzero num) calls
158 IOMGR_Select, though Win95 select works only on sockets */
159 /* so, we poll instead */
160 /*if (LWP_WaitForKeystroke(0))
170 int shutdown_handler(int x)
174 fprintf(stderr, "This program should not be shut down manually. It should "
175 "be shut down by the\nWindows AFS Client Control Center. Press Ctrl-C "
176 "again if you really want to do this.\n");
182 fprintf(stderr, "Shutting down AFSD...\n");
188 int afsd_shutdown(int x)
196 fprintf(stderr, "AFSD shutdown complete.\n");
200 void afs_exit(int exitCode)
202 afs_current_status = AFS_STATUS_EXITING;
203 afsMsg_StatusChange(afs_current_status,