コード例 #1
0
ファイル: cpr_darwin_ipc.c プロジェクト: hibrium/Pale-Moon
/**
 * Creates a message queue
 *
 * @param name  - name of the message queue
 * @param depth - the message queue depth, optional field which will
 *                default if set to zero(0)
 *
 * @return Msg queue handle or NULL if init failed, errno provided
 *
 * @note the actual message queue depth will be bounded by the
 *       standard system message queue depth and CPR_MAX_MSG_Q_DEPTH.
 *       If 'depth' is outside of the bounds, the value will be
 *       reset automatically.
 */
cprMsgQueue_t
cprCreateMessageQueue (const char *name, uint16_t depth)
{
    static const char fname[] = "cprCreateMessageQueue";
    cpr_msg_queue_t *msgq;
    static int key_id = 100; /* arbitrary starting number */

    msgq = cpr_calloc(1, sizeof(cpr_msg_queue_t));
    if (msgq == NULL) {
        printf("%s: Malloc failed: %s\n", fname,
               name ? name : unnamed_string);
        errno = ENOMEM;
        return NULL;
    }

    msgq->name = name ? name : unnamed_string;
    msgq->queueId = key_id++;

    pthread_cond_t _cond = PTHREAD_COND_INITIALIZER;
    msgq->cond = _cond;
    pthread_mutex_t _lock = PTHREAD_MUTEX_INITIALIZER;
    msgq->mutex = _lock;

    /*
     * Add message queue to list for statistics reporting
     */
    pthread_mutex_lock(&msgQueueListMutex);
    msgq->next = msgQueueList;
    msgQueueList = msgq;
    pthread_mutex_unlock(&msgQueueListMutex);

    return msgq;
}
コード例 #2
0
ファイル: fsm.c プロジェクト: AshishNamdev/mozilla-central
void
fsm_init (void)
{
    fsm_fcb_t *fcb;

    fsmdef_init_dcb(&fsm_dcb, 0, FSMDEF_CALL_TYPE_NONE, NULL, LSM_NO_LINE,
                    NULL);

    fsmdef_init();
    fsmb2bcnf_init();
    fsmcnf_init();
    fsmxfr_init();

    fsm_cac_init();

    /*
     * Initialize the fcbs.
     */
    fsm_fcbs = (fsm_fcb_t *) cpr_calloc(FSM_MAX_FCBS, sizeof(fsm_fcb_t));
    if (fsm_fcbs == NULL) {
        GSM_ERR_MSG(GSM_F_PREFIX"Failed to allcoate FSM FCBs.\n", "fsm_init");
        return;
    }

    FSM_FOR_ALL_CBS(fcb, fsm_fcbs, FSM_MAX_FCBS) {
        fsm_init_fcb(fcb, CC_NO_CALL_ID, FSMDEF_NO_DCB, FSM_TYPE_NONE);
    }
コード例 #3
0
ファイル: misc.c プロジェクト: AshishNamdev/mozilla-central
/**
 * @brief Given a msg buffer, returns a pointer to the buffer's header
 *
 * The cprGetSysHeader function retrieves the system header buffer for the
 * passed in message buffer.
 *
 * @param[in] buffer  pointer to the buffer whose sysHdr to return
 *
 * @return        Abstract pointer to the msg buffer's system header
 *                or #NULL if failure
 */
void *
cprGetSysHeader (void *buffer)
{
    phn_syshdr_t *syshdr;

    /*
     * Stinks that an external structure is necessary,
     * but this is a side-effect of porting from IRX.
     */
    syshdr = cpr_calloc(1, sizeof(phn_syshdr_t));
    if (syshdr) {
        syshdr->Data = buffer;
    }
    return (void *)syshdr;
}
コード例 #4
0
ファイル: ccsip_callinfo.c プロジェクト: Andrel322/gecko-dev
/*
 * ccsip_process_call_info_header
 *
 * Description:
 *
 * Checks if there is a call info header in the provided SIP message. If there is,
 * the call info in the CCB is cleared and the new call info is parsed into the
 * CCB call info structure.
 */
void
ccsip_process_call_info_header (sipMessage_t *request_p, ccsipCCB_t *ccb)
{
    char       *call_info_hdrs[MAX_CALL_INFO_HEADERS];
    uint16_t    num_call_info_headers;
    int         i = 0;

    if (!ccb) {
        return;
    }

    if (ccb->in_call_info) {
        ccsip_free_call_info_header(ccb->in_call_info);
        ccb->in_call_info = NULL;
    }

    if (!request_p) {
        return;
    }

    memset(call_info_hdrs, 0, MAX_CALL_INFO_HEADERS * sizeof(char *));

    num_call_info_headers = sippmh_get_num_particular_headers(request_p,
                                                              SIP_HEADER_CALL_INFO,
                                                              SIP_HEADER_CALL_INFO,
                                                              call_info_hdrs,
                                                              MAX_CALL_INFO_HEADERS);

    if (num_call_info_headers > 0) {
        ccb->in_call_info = (cc_call_info_t *)
            cpr_calloc(1, sizeof(cc_call_info_t));
        if (ccb->in_call_info) {

            ccb->in_call_info->data.call_info_feat_data.feature_flag = 0;

            // Parse each Call-Info header
            for (i = 0; i < MAX_CALL_INFO_HEADERS; i++) {
                if (call_info_hdrs[i]) {
                    ccsip_decode_call_info_hdr(call_info_hdrs[i], ccb->in_call_info);
                }
            }

        } else {
            ccb->in_call_info = NULL;
        }
    }

}