Project

General

Profile

« Previous | Next » 

Revision 9c69afef

Added by Hamish Coleman over 15 years ago

  • ID 9c69afef574e321319fdb191753636703c3bcfbc

Fix the bugs with the new scm console code

View differences:

scm.h
struct SCM_def {
char *name;
char *desc;
int mode; /* set to SVC_CONSOLE by the *-scm.c code */
int (*init)(int, char **);
int (*main)(int);
int (*stop)(int);
int mode; /* set to SVC_CONSOLE by the *-scm.c code */
int (*init)(int, char **); /* called before main */
int (*main)(int); /* called to run the service */
int (*stop)(int); /* called by scm to tell the service to stop */
};
int SCM_Start(struct SCM_def *);
int SCM_Start(struct SCM_def *, int argc, char **argv);
char *SCM_Install(struct SCM_def *);
int SCM_Remove(struct SCM_def *);
wconsd.c
int wconsd_main(int param1);
int wconsd_stop(int param1);
struct SCM_def sd = {
"wconsd","wconsd - Telnet to Serial server",
wconsd_init, wconsd_main, wconsd_stop
.name = "wconsd",
.desc = "wconsd - Telnet to Serial server",
.init = wconsd_init,
.main = wconsd_main,
.stop = wconsd_stop,
};
/*
* output from OutputDebugStringA can be seen using sysinternals debugview
* http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
* http://live.sysinternals.com/Dbgview.exe
*/
/*
......
WSADATA wsaData;
int err;
if (sd->mode==SVC_CONSOLE) {
if (sd.mode==SVC_CONSOLE) {
/* We are running in a command-line mode */
dprintf_to_stdout=1;
win-scm.c
return;
}
int SCM_Start_Console(const int argc, const char **argv) {
int SCM_Start_Console(int argc, char **argv) {
global_sd->mode=SVC_CONSOLE;
int err = sd->init(argc,argv);
int err = global_sd->init(argc,argv);
if (err!=0) {
printf("SCM_Start_Console: init failed, return code %d\n",err);
return SVC_FAIL;
}
sd->main(0);
global_sd->main(0);
return SVC_OK;
}
int SCM_Start(struct SCM_def *sd, const int argc, const char **argv) {
int SCM_Start(struct SCM_def *sd, int argc, char **argv) {
SERVICE_TABLE_ENTRY ServiceTable[] = {
{ "", ServiceMain },
{ NULL, NULL }
......
/* If we have commandline args, then we cannot have been started
* by the Windows SCM
*/
if (argc<2) {
if (argc>1) {
return SCM_Start_Console(argc,argv);
}

Also available in: Unified diff