CPU_INT32U  HTTP_Dict_KeyGet (const  HTTP_DICT    *p_dict_tbl,
                                     CPU_INT32U    dict_size,
                              const  CPU_CHAR     *p_str_cmp,
                                     CPU_BOOLEAN   case_sensitive,
                                     CPU_INT32U    str_len)
{
    CPU_INT32U   nbr_entry;
    CPU_INT32U   ix;
    CPU_INT32U   len;
    CPU_INT16S   cmp;
    HTTP_DICT   *p_srch;


    nbr_entry =  dict_size / sizeof(HTTP_DICT);
    p_srch    = (HTTP_DICT *)p_dict_tbl;
    for (ix = 0; ix < nbr_entry; ix++) {
        len = DEF_MIN(str_len, p_srch->StrLen);
        if (case_sensitive == DEF_YES) {
            cmp = Str_Cmp_N(p_str_cmp, p_srch->StrPtr, len);
            if (cmp == 0) {
                return (p_srch->Key);
            }
        } else {
            cmp = Str_CmpIgnoreCase_N(p_str_cmp, p_srch->StrPtr, len);
            if (cmp == 0) {
                return (p_srch->Key);
            }
        }

        p_srch++;
    }

    return (HTTP_DICT_KEY_INVALID);
}
Пример #2
0
CPU_SIZE_T  SerialBuf_Rd (SERIAL_BUF  *pbuf,
                          CPU_INT08U  *pdest,
                          CPU_SIZE_T   len)
{
    CPU_SIZE_T   buf_avail;
    CPU_SIZE_T   buf_copy_start;
    CPU_SIZE_T   buf_copy_end;
    CPU_SIZE_T   buf_copy_tot;
    CPU_SIZE_T   ix_rd;
    CPU_SIZE_T   ix_rd_new;
    CPU_SIZE_T   buf_len;
    CPU_INT08U  *pdest_08;
    CPU_SR_ALLOC();


    CPU_CRITICAL_ENTER();
    buf_len   = pbuf->Len;
    buf_avail = buf_len - pbuf->EmptyCnt;                       /* Calc nbr data octets in buf.                         */
    pdest_08  = (CPU_INT08U *)pdest;



    if (buf_avail == 0) {                                       /* ------------------ HANDLE EMPTY BUF ---------------- */
        CPU_CRITICAL_EXIT();
        return ((CPU_SIZE_T)0);
    }



                                                                /* ------------- CALC BUF IX & LEN TO COPY ------------ */
    ix_rd          = pbuf->IxRd;
    buf_copy_tot   = DEF_MIN(buf_avail,    len);                /* Calc nbr data octets tot to copy.                    */
    buf_copy_end   = DEF_MIN(buf_copy_tot, buf_len - ix_rd);    /* Calc nbr data octets to copy from buf end.           */
    buf_copy_start = buf_copy_tot - buf_copy_end;               /* Calc nbr data octets to copy from buf start.         */
    if (buf_copy_start > 0) {                                   /* Update buf ix rd.                                    */
        pbuf->IxRd = buf_copy_start;
    } else {
        ix_rd_new = ix_rd + buf_copy_tot;
        if (ix_rd_new == buf_len) {
            pbuf->IxRd = 0;
        } else {
            pbuf->IxRd = ix_rd_new;
        }
    }
    CPU_CRITICAL_EXIT();

                                                                /* --------------- COPY DATA AT BUF END --------------- */
                                                                /* Copy data.                                           */
    Mem_Copy((void *)pdest_08, (void *)&pbuf->DataPtr[ix_rd], buf_copy_end);
                                                                /* -------------- COPY DATA AT BUF START -------------- */
    pdest_08 += buf_copy_end;                                   /* Adj buf ptr.                                         */
                                                                /* Copy data.                                           */
    Mem_Copy((void *)pdest_08, (void *)&pbuf->DataPtr[0], buf_copy_start);



    CPU_CRITICAL_ENTER();
    pbuf->EmptyCnt += buf_copy_tot;                             /* Update buf empty octets rem.                         */
    CPU_CRITICAL_EXIT();

    return (buf_copy_tot);
}