Back to index

lightning-sunbird  0.9+nobinonly
Functions
nsMacUtils.cpp File Reference
#include <stdlib.h>
#include "nsMacUtils.h"

Go to the source code of this file.

Functions

OSErr MyNewHandle (long length, Handle *outHandle)
void MyDisposeHandle (Handle theHandle)
void MyHLock (Handle theHandle)
void MyHUnlock (Handle theHandle)
OSErr MyNewBlockClear (long length, void **outBlock)
void MyDisposeBlock (void *dataBlock)
void StrCopySafe (char *dst, const char *src, long destLen)
void CopyPascalString (StringPtr to, const StringPtr from)
void CopyCToPascalString (const char *src, StringPtr dest, long maxLen)
void CopyPascalToCString (const StringPtr src, char *dest, long maxLen)
OSErr GetShortVersionString (short rID, StringPtr version)

Function Documentation

void CopyCToPascalString ( const char *  src,
StringPtr  dest,
long  maxLen 
)

Definition at line 128 of file nsMacUtils.cpp.

{
       char          *s = (char *)src;
       char          *d = (char *)(&dest[1]);
       long          count = 0;
              
       while (count < maxLen && *s) {
              *d ++ = *s ++;
              count ++;
       }
       
       dest[0] = (unsigned char)(count);
}
void CopyPascalString ( StringPtr  to,
const StringPtr  from 
)

Definition at line 116 of file nsMacUtils.cpp.

{
       BlockMoveData(from, to, *from+1);
}

Here is the caller graph for this function:

void CopyPascalToCString ( const StringPtr  src,
char *  dest,
long  maxLen 
)

Definition at line 149 of file nsMacUtils.cpp.

{
       short  len = Min(maxLen, src[0]);
       
       BlockMoveData(&src[1], dest, len);
       dest[len] = '\0';
}

Here is the caller graph for this function:

OSErr GetShortVersionString ( short  rID,
StringPtr  version 
)

Definition at line 170 of file nsMacUtils.cpp.

{
       VersRecHndl          versionH;
       OSErr                error = resNotFound;
       
       versionH = (VersRecHndl)Get1Resource('vers', rID);             
       
       if (versionH)
       {
              CopyPascalString(version, (**versionH).shortVersion);
              ReleaseResource((Handle) versionH);
              error = noErr;
       }
       else
              CopyPascalString(version, (StringPtr)"\p<unknown>");

       return error;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MyDisposeBlock ( void dataBlock)

Definition at line 82 of file nsMacUtils.cpp.

{
  if (dataBlock)
    free(dataBlock);
}

Here is the caller graph for this function:

void MyDisposeHandle ( Handle  theHandle)

Definition at line 55 of file nsMacUtils.cpp.

{
  if (theHandle)
    DisposeHandle(theHandle);
}

Here is the caller graph for this function:

void MyHLock ( Handle  theHandle)

Definition at line 62 of file nsMacUtils.cpp.

{
  HLock(theHandle);
}

Here is the caller graph for this function:

void MyHUnlock ( Handle  theHandle)

Definition at line 67 of file nsMacUtils.cpp.

{
  HUnlock(theHandle);
}

Here is the caller graph for this function:

OSErr MyNewBlockClear ( long  length,
void **  outBlock 
)

Definition at line 74 of file nsMacUtils.cpp.

{
  void* newData = calloc(length, 1);
  if (!newData) return memFullErr;
  *outBlock = newData;
  return noErr;
}

Here is the call graph for this function:

Here is the caller graph for this function:

OSErr MyNewHandle ( long  length,
Handle *  outHandle 
)

Definition at line 46 of file nsMacUtils.cpp.

{
  Handle    tempHandle = NewHandle(length);
  if (!tempHandle) return memFullErr;
  *outHandle = tempHandle;
  return noErr;
}

Here is the caller graph for this function:

void StrCopySafe ( char *  dst,
const char *  src,
long  destLen 
)

Definition at line 96 of file nsMacUtils.cpp.

{
       const unsigned char  *p = (unsigned char *) src - 1;
       unsigned char               *q = (unsigned char *) dst - 1;
       unsigned char        *end = (unsigned char *)dst + destLen;
       
       while ( q < end && (*++q = (*++p)) != '\0' ) {;}
       if (q == end)
              *q = '\0';
}