nswin32.c File Reference

#include "nsd.h"

Defines

#define SysErrMsg()   (NsWin32ErrMsg(GetLastError()))

Functions

BOOL APIENTRY DllMain (HANDLE hModule, DWORD why, LPVOID lpReserved)
char * NsWin32ErrMsg (int err)
int NsConnectService (void)
int NsRemoveService (char *server)
int NsInstallService (char *server)
void NsHandleSignals (void)
void NsSendSignal (int sig)
int ns_socknbclose (SOCKET sock)
SOCKET ns_sockdup (SOCKET sock)
int link (char *from, char *to)
int symlink (char *from, char *to)
int kill (int pid, int sig)
int truncate (char *file, off_t size)

Define Documentation

 
#define SysErrMsg (  )     (NsWin32ErrMsg(GetLastError()))


Function Documentation

BOOL APIENTRY DllMain ( HANDLE  hModule,
DWORD  why,
LPVOID  lpReserved 
)

----------------------------------------------------------------------

DllMain --

Init routine for the nsd.dll which setups TLS for Win32 errors disables thread attach/detach calls.

Results: TRUE or FALSE.

Side effects: None.

----------------------------------------------------------------------

int kill ( int  pid,
int  sig 
)

int link ( char *  from,
char *  to 
)

----------------------------------------------------------------------

link, symlink, kill --

Stubs for missing Unix routines. This is done simply to avoid more ifdef's in the code.

Results: -1.

Side effects: Sets errno to EINVAL.

----------------------------------------------------------------------

SOCKET ns_sockdup ( SOCKET  sock  ) 

----------------------------------------------------------------------

ns_sockdup --

Duplicate a socket. This is used in the old ns_sock Tcl cmds.

Results: New handle to underlying socket.

Side effects: None.

----------------------------------------------------------------------

int ns_socknbclose ( SOCKET  sock  ) 

----------------------------------------------------------------------

ns_socknbclose --

Perform a non-blocking socket close via the socket callback thread. This is only called by a timeout in Ns_SockTimedConnect.

Results: 0 or SOCKET_ERROR.

Side effects: Socket will be closed when writable.

----------------------------------------------------------------------

int NsConnectService ( void   ) 

----------------------------------------------------------------------

NsConnectService --

Attach to the service control manager at startup.

Results: None.

Side effects: Service control manager will create a new thread running ServiceMain().

----------------------------------------------------------------------

Open a temporary log, ensuring it's opened on fd 2 for later dup2 in NsLogOpen().

void NsHandleSignals ( void   ) 

----------------------------------------------------------------------

NsHandleSignals --

Loop endlessly, processing HUP signals until a TERM signal arrives.

Results: None.

Side effects: None.

----------------------------------------------------------------------

If running as a service, stop the ticker thread and report startup complete. Otherwise, register a handler which will initiate an orderly shutdown on Ctrl-C.

If running as a service, startup the ticker thread again to keep updating status until shutdown is complete.

int NsInstallService ( char *  server  ) 

----------------------------------------------------------------------

NsInstallService --

Install as an NT service.

Results: None.

Side effects: Service should appear in the list in the services control panel.

----------------------------------------------------------------------

int NsRemoveService ( char *  server  ) 

----------------------------------------------------------------------

NsRemoveService --

Remove a previously installed service.

Results: None.

Side effects: Service should stop and then disappear from the list in the services control panel.

----------------------------------------------------------------------

void NsSendSignal ( int  sig  ) 

----------------------------------------------------------------------

NsSendSignal --

Send a signal to wakeup NsHandleSignals. As on Unix, a signal sent multiple times is only received once.

Results: None.

Side effects: Main thread will wakeup.

----------------------------------------------------------------------

char* NsWin32ErrMsg ( int  err  ) 

----------------------------------------------------------------------

NsWin32ErrMsg --

Get a string message for an error code in either the kernel or wsock dll's.

Results: Pointer to per-thread LocalAlloc'ed memory.

Side effects: None.

----------------------------------------------------------------------

int symlink ( char *  from,
char *  to 
)

int truncate ( char *  file,
off_t  size 
)

----------------------------------------------------------------------

truncate --

Implement Unix truncate.

Results: 0 if ok or -1 on error.

Side effects: File is opened, truncated, and closed.

----------------------------------------------------------------------


Generated on Tue Sep 4 19:58:56 2007 by  doxygen 1.5.1