Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Functions | Variables
nclog.cpp File Reference
#include "mozce_internal.h"
#include "winsock.h"
#include <stdarg.h>
#include <stdio.h>

Go to the source code of this file.

Classes

struct  _nclog_module

Defines

#define USE_NC_LOGGING

Functions

static bool wsa_bind (unsigned short port)
static bool wsa_init ()
bool set_nclog_port (unsigned short x)
static void wsa_send (const char *x)
int nclog (const char *fmt,...)
void nclograw (const char *data, long length)

Variables

static SOCKET wsa_socket = INVALID_SOCKET
static unsigned short theLogPort
static _nclog_module module

Define Documentation

Definition at line 47 of file nclog.cpp.


Function Documentation

int nclog ( const char *  fmt,
  ... 
)

Definition at line 125 of file nclog.cpp.

{
  va_list vl;
  va_start(vl,fmt);
  char buf[1024]; // to bad CE hasn't got wvnsprintf
  sprintf(buf,fmt,vl);
  wsa_init();
  wsa_send(buf);
  return 0;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void nclograw ( const char *  data,
long  length 
)

Definition at line 136 of file nclog.cpp.

{
  wsa_init();
  
  SOCKADDR_IN sa;
  sa.sin_family = AF_INET;
  sa.sin_port = htons(theLogPort);
  sa.sin_addr.s_addr = htonl(INADDR_BROADCAST);
  
  sendto(wsa_socket, data, length, 0, (sockaddr*)&sa, sizeof(sa));
}

Here is the call graph for this function:

bool set_nclog_port ( unsigned short  x)

Definition at line 112 of file nclog.cpp.

{ return wsa_bind(x); }

Here is the call graph for this function:

static bool wsa_bind ( unsigned short  port) [static]

Definition at line 62 of file nclog.cpp.

{
  SOCKADDR_IN addr;
  addr.sin_family = AF_INET;
  addr.sin_port = htons(port);
  addr.sin_addr.s_addr = htonl(INADDR_ANY);
  int r=bind(wsa_socket,(sockaddr*)&addr,sizeof(addr));
  if (r==0) theLogPort=port;
  return (r==0);
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

static bool wsa_init ( ) [static]

Definition at line 75 of file nclog.cpp.

{
  if (wsa_socket != INVALID_SOCKET) return true;
  int r;
  WSADATA wd;
  BOOL bc=true;
  
  if (0 != WSAStartup(0x101, &wd)) 
  {
         MessageBox(0, L"WSAStartup failed", L"ERROR", 0);
         goto error;
  }
  wsa_socket=socket(PF_INET, SOCK_DGRAM, 0);
  if (wsa_socket == INVALID_SOCKET)
  {
         MessageBox(0, L"socket failed", L"ERROR", 0);
         goto error;
  }
  r=setsockopt(wsa_socket, SOL_SOCKET, SO_BROADCAST, (char*)&bc,
               sizeof(bc));
  if (r!=0)
  {
       MessageBox(0, L"setsockopt failed", L"ERROR", 0);
       goto error;
  }

  if (wsa_bind(9998)) return true; // bind to default port.

  MessageBox(0, L"Can Not Bind To Port", L"ERROR", 0);

error:
  if (wsa_socket != INVALID_SOCKET) closesocket(wsa_socket);
  return false;

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void wsa_send ( const char *  x) [static]

Definition at line 114 of file nclog.cpp.

{
  SOCKADDR_IN sa;
  sa.sin_family = AF_INET;
  sa.sin_port = htons(theLogPort);
  sa.sin_addr.s_addr = htonl(INADDR_BROADCAST);
  
  sendto(wsa_socket, x, strlen(x), 0, (sockaddr*)&sa, sizeof(sa));
}

Here is the caller graph for this function:


Variable Documentation

Definition at line 163 of file nclog.cpp.

unsigned short theLogPort [static]

Definition at line 59 of file nclog.cpp.

SOCKET wsa_socket = INVALID_SOCKET [static]

Definition at line 56 of file nclog.cpp.