Back to index

lightning-sunbird  0.9+nobinonly
Defines | Functions
mozce_internal.h File Reference
#include <windows.h>
#include <winsock2.h>
#include "mozce_defs.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define charcount(array)   (sizeof(array) / sizeof(array[0]))
#define MOZCE_PRECHECK

Functions

int a2w_buffer (const char *inACPString, int inACPChars, unsigned short *outWideString, int inWideChars)
unsigned short * a2w_malloc (const char *inACPString, int inACPChars, int *outWideChars)
int w2a_buffer (const unsigned short *inWideString, int inWideChars, char *outACPString, int inACPChars)
char * w2a_malloc (unsigned short *inWideString, int inWideChars, int *outACPChars)
void dumpMemoryInfo ()
MOZCE_SHUNT_API int mozce_printf (const char *,...)
int nclog (const char *fmt,...)
void nclograw (const char *data, long length)

Define Documentation

#define charcount (   array)    (sizeof(array) / sizeof(array[0]))

Definition at line 150 of file mozce_internal.h.

Value:
{                                      \
    SetLastError(0);                   \
}

Definition at line 180 of file mozce_internal.h.


Function Documentation

int a2w_buffer ( const char *  inACPString,
int  inACPChars,
unsigned short *  outWideString,
int  inWideChars 
)

Definition at line 43 of file a2w.cpp.

{
    int retval = 0;
    
    /*
    **  Start off by terminating the out argument if appropriate.
    */
    if(NULL != outWideString && 0 != inWideChars)
    {
        *outWideString = L'\0';
    }
    
    /*
    **  Sanity check arguments.
    */
    if(NULL != inACPString && 0 != inACPChars && (0 == inWideChars || NULL != outWideString))
    {
        /*
        **  Attempt the conversion.
        */
        retval = MultiByteToWideChar(
                                     CP_ACP,
                                     0,
                                     inACPString,
                                     inACPChars,
                                     outWideString,
                                     inWideChars
                                     );
    }
    
    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned short* a2w_malloc ( const char *  inACPString,
int  inACPChars,
int outWideChars 
)

Definition at line 77 of file a2w.cpp.

{
    LPWSTR retval = NULL;
    
    /*
    **  Initialize any out arguments.
    */
    if(NULL != outWideChars)
    {
        *outWideChars = 0;
    }
    
    /*
    **  Initialize the acp char length if requested.
    **  We do this here to avoid doing it twice in calls to a2w_buffer.
    */
    if(-1 == inACPChars)
    {
        if(NULL != inACPString)
        {
            /*
            **  Plus one so the terminating character is included.
            */
            inACPChars = (int)strlen(inACPString) + 1;
        }
        else
        {
            inACPChars = 0;
        }
    }
    
    /*
    **  Sanity check arguments.
    */
    if(NULL != inACPString && 0 != inACPChars)
    {
        int charsRequired = 0;
        
        /*
        **  Determine the size of buffer required for the conversion.
        */
        charsRequired = a2w_buffer(inACPString, inACPChars, NULL, 0);
        if(0 != charsRequired)
        {
            LPWSTR heapBuffer = NULL;
            
            heapBuffer = (LPWSTR)malloc((size_t)charsRequired * sizeof(WCHAR));
            if(NULL != heapBuffer)
            {
                int wideChars = 0;
                
                /*
                **  Real thing this time.
                */
                wideChars = a2w_buffer(inACPString, inACPChars, heapBuffer, charsRequired);
                if(0 != wideChars)
                {
                    retval = heapBuffer;
                    if(NULL != outWideChars)
                    {
                        *outWideChars = wideChars;
                    }
                }
                else
                {
                    /*
                    **  Something wrong.
                    **  Clean up.
                    */
                    free(heapBuffer);
                }
            }
        }
    }
    
    return retval;
}

Here is the call graph for this function:

Definition at line 1394 of file win32.cpp.

{
    MEMORYSTATUS ms;
    ms.dwLength = sizeof(MEMORYSTATUS);
    
    
    GlobalMemoryStatus(&ms);
    
    wprintf(L"-> %d %d %d %d %d %d %d\n", 
            ms.dwMemoryLoad, 
            ms.dwTotalPhys, 
            ms.dwAvailPhys, 
            ms.dwTotalPageFile, 
            ms.dwAvailPageFile, 
            ms.dwTotalVirtual, 
            ms.dwAvailVirtual);
}
MOZCE_SHUNT_API int mozce_printf ( const char *  ,
  ... 
)

Definition at line 194 of file stdio.cpp.

{
#ifdef DEBUG
#define MAX_CHARS_IN_VARIABLE_STRING 1024
    
    char buf[MAX_CHARS_IN_VARIABLE_STRING];
    
    TCHAR tBuf[MAX_CHARS_IN_VARIABLE_STRING];
    
    va_list ptr;
    va_start(ptr,format);
    vsprintf(buf,format,ptr);
    
    mbstowcs(tBuf, buf, MAX_CHARS_IN_VARIABLE_STRING);
    
    OutputDebugString(tBuf);
    
    return 1;
#endif
    return 0;
}

Here is the call graph for this function:

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:

int w2a_buffer ( const unsigned short *  inWideString,
int  inWideChars,
char *  outACPString,
int  inACPChars 
)

Definition at line 43 of file w2a.cpp.

{
    int retval = 0;

    /*
    **  Start off by terminating the out argument if appropriate.
    */
    if(NULL != outACPString && 0 != inACPChars)
    {
        *outACPString = '\0';
    }

    /*
    **  Sanity check arguments.
    */
    if(NULL != inWideString && 0 != inWideChars && (0 == inACPChars || NULL != outACPString))
    {
        /*
        **  Attempt the conversion.
        */
        retval = WideCharToMultiByte(
                                     CP_ACP,
                                     0,
                                     inWideString,
                                     inWideChars,
                                     outACPString,
                                     inACPChars,
                                     NULL,
                                     NULL
                                     );
    }

    return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

char* w2a_malloc ( unsigned short *  inWideString,
int  inWideChars,
int outACPChars 
)