Back to index

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

Go to the source code of this file.

Functions

static PRUint8 get_opcode (const PRUint8 *buf)
static PRUint8 get_flags (const PRUint8 *buf)
static const char * get_key (const PRUint8 *buf)
PRUint8IPC_FlattenLockMsg (const ipcLockMsg *msg, PRUint32 *bufLen)
void IPC_UnflattenLockMsg (const PRUint8 *buf, PRUint32 bufLen, ipcLockMsg *msg)

Function Documentation

static PRUint8 get_flags ( const PRUint8 buf) [inline, static]

Definition at line 50 of file ipcLockProtocol.cpp.

{
    return (buf[0] & 0xf0) >> 4;
}

Here is the caller graph for this function:

static const char* get_key ( const PRUint8 buf) [inline, static]

Definition at line 55 of file ipcLockProtocol.cpp.

{
    return ((const char *) buf) + 1;
}

Here is the caller graph for this function:

static PRUint8 get_opcode ( const PRUint8 buf) [inline, static]

Definition at line 45 of file ipcLockProtocol.cpp.

{
    return (buf[0] & 0x0f);
}

Here is the caller graph for this function:

PRUint8* IPC_FlattenLockMsg ( const ipcLockMsg msg,
PRUint32 bufLen 
)

Definition at line 63 of file ipcLockProtocol.cpp.

{
    PRUint32 len = 1                 // header byte
                 + strlen(msg->key)  // key
                 + 1;                // null terminator

    PRUint8 *buf = (PRUint8 *) ::operator new(len);
    if (!buf)
        return NULL;

    buf[0] = (msg->opcode | (msg->flags << 4));

    memcpy(&buf[1], msg->key, len - 1);
    *bufLen = len;
    return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void IPC_UnflattenLockMsg ( const PRUint8 buf,
PRUint32  bufLen,
ipcLockMsg msg 
)

Definition at line 81 of file ipcLockProtocol.cpp.

{
    PR_ASSERT(bufLen > 2); // malformed buffer otherwise
    msg->opcode = get_opcode(buf);
    msg->flags = get_flags(buf);
    msg->key = get_key(buf);
}

Here is the call graph for this function:

Here is the caller graph for this function: