• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ dbg_err_if函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中dbg_err_if函数的典型用法代码示例。如果您正苦于以下问题:C++ dbg_err_if函数的具体用法?C++ dbg_err_if怎么用?C++ dbg_err_if使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了dbg_err_if函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: push_code_block

static int push_code_block(lang_c_ctx_t *ctx, parser_t *p,
                           const char *buf, size_t sz)
{
    code_block_t *node;

    dbg_return_if (p == NULL, ~0);
    dbg_return_if (ctx == NULL, ~0);

    node = (code_block_t*)u_zalloc(sizeof(code_block_t));
    dbg_err_if(node == NULL);

    node->sz = sz;
    node->buf = (char*)u_malloc(sz);
    dbg_err_if(node->buf == NULL);

    node->code_line = p->code_line;
    node->file_in = ctx->ti->file_in;

    memcpy(node->buf, buf, sz);

    TAILQ_INSERT_TAIL(&ctx->code_blocks, node, np);

    return 0;
err:
    if(node)
        free_code_block(node);
    return ~0;
}
开发者ID:nawawi,项目名称:klone,代码行数:28,代码来源:trans_c.c


示例2: u_buf_load

/**
 *  \brief  Fill a buffer object with the content of a file
 *
 *  Open \p filename and copy its whole content into the given buffer \p ubuf
 *
 *  \param  ubuf        an already allocated ::u_buf_t object
 *  \param  filename    path of the source file
 *
 *  \retval  0  on success
 *  \retval ~0  on failure
 */
int u_buf_load (u_buf_t *ubuf, const char *filename)
{
    struct stat st;
    FILE *fp = NULL;

    dbg_return_if (ubuf == NULL, ~0);
    dbg_return_if (filename == NULL, ~0);

    dbg_err_sif (stat(filename, &st) == -1);

    /* clear the current data */
    dbg_err_if (u_buf_clear(ubuf));

    /* be sure to have a big enough buffer */
    dbg_err_if (u_buf_reserve(ubuf, st.st_size));

    dbg_err_sifm ((fp = fopen(filename, "r")) == NULL, "%s", filename);

    /* fill the buffer with the whole file content */
    dbg_err_if (fread(ubuf->data, st.st_size, 1, fp) != 1);
    ubuf->len = st.st_size;

    (void) fclose(fp);

    return 0;
err:
    U_FCLOSE(fp);
    return ~0;
}
开发者ID:fdotli,项目名称:libu,代码行数:40,代码来源:buf.c


示例3: u_asctime_to_tt

/**
 * \brief   Convert an asctime(3) string to \c time_t
 *
 * Convert the asctime(3) string \p str to its \c time_t representation \p tp.
 *
 * \param   str     the string to be converted
 * \param   tp      the \c time_t conversion of \p str as a value-result
 *                  argument
 * \return
 * - \c 0   successful
 * - \c ~0  failure
 */
int u_asctime_to_tt(const char *str, time_t *tp)
{
    enum { BUFSZ = 64 };
    char wday[BUFSZ], mon[BUFSZ];
    unsigned int day, year, hour, min, sec;
    struct tm tm;
    int i;

    dbg_return_if (str == NULL, ~0);
    dbg_return_if (tp == NULL, ~0);
    dbg_return_if (strlen(str) >= BUFSZ, ~0);

    dbg_err_if((i = sscanf(str, "%s %s %u %u:%u:%u %u", wday,
                           mon, &day, &hour, &min, &sec, &year)) != 7);

    memset(&tm, 0, sizeof(struct tm));

    /* time */
    tm.tm_sec = sec;
    tm.tm_min = min;
    tm.tm_hour = hour;

    /* date */
    tm.tm_mday = day;
    tm.tm_mon = month_idx(mon);
    tm.tm_year = year - 1900;

    dbg_err_if(tm.tm_mon < 0);

    *tp = timegm(&tm);

    return 0;
err:
    return ~0;
}
开发者ID:nawawi,项目名称:klone,代码行数:47,代码来源:date.c


示例4: server_reap_child

/* remove a child process whose pid is 'pid' to children list */
static int server_reap_child(server_t *s, pid_t pid)
{
    child_t *child;
    backend_t *be;

    dbg_err_if (s == NULL);
    
    /* get the child object */
    dbg_err_if(children_get_by_pid(s->children, pid, &child));

    /* remove the child from the list */
    dbg_err_if(children_del(s->children, child));
    be = child->be;

    /* check that the minimum number of process are active */
    be->nchild--;
    if(be->nchild < be->start_child)
        be->fork_child = be->start_child - be->nchild;

    U_FREE(child);

    return 0;
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:26,代码来源:server.c


示例5: u_tt_to_rfc822

/**
 * \brief   Convert a \c time_t value to a rfc822 time string
 *
 * Convert the \c time_t value \p ts to a rfc822 time string
 *
 * \param   dst     placeholder for the rfc822 time string.  The buffer,
 *                  of at least RFC822_DATE_BUFSZ bytes, must be preallocated
 *                  by the caller.
 * \param   ts      the \c time_t value to be converted
 *
 * \return
 * - \c 0   successful
 * - \c ~0  failure
 */
int u_tt_to_rfc822(char dst[RFC822_DATE_BUFSZ], time_t ts)
{
    char buf[RFC822_DATE_BUFSZ];
    struct tm tm;

    dbg_return_if (dst == NULL, ~0);

#ifdef OS_WIN
    memcpy(&tm, gmtime(&ts), sizeof(tm));
#else
    dbg_err_if(gmtime_r(&ts, &tm) == NULL);
#endif

    dbg_err_if(tm.tm_wday > 6 || tm.tm_wday < 0);
    dbg_err_if(tm.tm_mon > 11 || tm.tm_mon < 0);

    dbg_err_if(u_snprintf(buf, sizeof buf,
                          "%s, %02u %s %02u %02u:%02u:%02u GMT",
                          days3[tm.tm_wday],
                          tm.tm_mday, months[tm.tm_mon], tm.tm_year + 1900,
                          tm.tm_hour, tm.tm_min, tm.tm_sec));

    /* copy out */
    u_strlcpy(dst, buf, RFC822_DATE_BUFSZ);

    return 0;
err:
    return ~0;
}
开发者ID:nawawi,项目名称:klone,代码行数:43,代码来源:date.c


示例6: u_uri_crumble

/** 
 *  \brief Parse an URI string and create the corresponding ::u_uri_t object 
 *
 *  Parse the NUL-terminated string \p uri and create an ::u_uri_t object at 
 *  \p *pu 
 *
 *  \param  uri     the NUL-terminated string that must be parsed
 *  \param  opts    bitmask of or'ed ::u_uri_opts_t values
 *  \param  pu      the newly created ::u_uri_t object containing the b
 *
 *  \retval  0  on success
 *  \retval ~0  on error
 */
int u_uri_crumble (const char *uri, u_uri_opts_t opts, u_uri_t **pu)
{
    u_uri_t *u = NULL;
    int rc = 0;
    char es[1024];
    regex_t re;
    regmatch_t pmatch[10];

    dbg_return_if (uri == NULL, ~0);
    dbg_return_if (pu == NULL, ~0);

    dbg_err_if ((rc = regcomp(&re, uri_pat, REG_EXTENDED)));
    dbg_err_if ((rc = regexec(&re, uri, 10, pmatch, 0)));

    dbg_err_if (u_uri_new(opts, &u));
    dbg_err_if (u_uri_fill(u, uri, pmatch));

    regfree(&re);

    *pu = u;

    return 0;
err:
    if (rc)
    {
        regerror(rc, &re, es, sizeof es);
        u_dbg("%s: %s", uri, es);
    }
    regfree(&re);

    if (u)
        u_uri_free(u);

    return ~0;
}
开发者ID:sharpglasses,项目名称:ServerSkeleton,代码行数:48,代码来源:uri.c


示例7: so_atom_delete_oldest

static int so_atom_delete_oldest(session_opt_t *so)
{
    atom_t *atom, *oldest;
    size_t count, i;

    dbg_err_if (so == NULL);

    count = atoms_count(so->atoms);
    nop_err_if(count == 0);

    dbg_err_if(atoms_getn(so->atoms, 0, &oldest));
    for(i = 1; i < count; ++i)
    {
        dbg_err_if(atoms_getn(so->atoms, i, &atom));

        /* save if older */
        if(atom->arg <= oldest->arg)
            oldest = atom;
    }

    dbg_err_if(atoms_remove(so->atoms, oldest));

    return 0;
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:26,代码来源:ses_mem.c


示例8: var_set_bin_value

/**
 * \ingroup vars
 * \brief   Set binary value of a variable
 *
 * Set binary value of variable \p v.
 *
 * \param v      variable object
 * \param data   value data
 * \param size   value size
 *
 * \return \c 0 if successful, non-zero on error
 */
int var_set_bin_value(var_t *v, const unsigned char *data, size_t size)
{
    dbg_err_if (v == NULL);
    dbg_err_if (data == NULL);
    
    U_FREE(v->data);

    if(data && size)
    {
        v->size = size;
        v->data = u_malloc(size+1);
        dbg_err_if(v->data == NULL);

        memcpy(v->data, data, size);
        v->data[size] = 0; /* zero-term v->data so it can be used as a string */
    } else {
        v->size = 0;
        v->data = NULL;
    }

    if(v->svalue)
        dbg_err_if(u_string_set(v->svalue, v->data, v->size));

    return 0; 
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:39,代码来源:var.c


示例9: RemoveService

/* uninstall this service from the system */
int RemoveService(void) 
{
    SC_HANDLE hSCM, hService;
    int rc;

    hSCM = OpenSCManager(NULL, NULL, SC_MANAGER_CONNECT);

    dbg_err_if(hSCM == NULL);

    /* Open this service for DELETE access */
    hService = OpenService(hSCM, ss_name, DELETE);

    dbg_err_if(hService == NULL);

    /* Remove this service from the SCM's database */
    rc = DeleteService(hService);

    dbg_err_if(rc == 0);

    /* success */
    MessageBox(NULL, "Uninstall succeeded", ss_name, MB_OK);
    return 0;
err:
    /* common error handling */
    warn_strerror(GetLastError());
    MessageBox(NULL, "Uninstall failed", ss_name, MB_OK);
    return ~0;
}
开发者ID:SuperPeanut,项目名称:klone,代码行数:29,代码来源:entry.c


示例10: io_mem_create

int io_mem_create(char *buf, size_t size, int flags, io_t **pio)
{
    io_mem_t *im = NULL;

    dbg_err_if (buf == NULL);
    dbg_err_if (pio == NULL);
    
    dbg_err_if(io_create(io_mem_t, (io_t**)&im));

    im->io.type = IO_TYPE_MEM;

    im->buf = buf;
    im->size = size;
    im->flags = flags;
    im->off = 0;
    im->io.read = (io_read_op) io_mem_read;
    im->io.write = (io_write_op) io_mem_write;
    im->io.seek = (io_seek_op) io_mem_seek;
    im->io.tell = (io_tell_op) io_mem_tell;
    im->io.close = (io_close_op) io_mem_close; 
    im->io.free = (io_free_op) io_mem_free; 

    *pio = (io_t*)im;

    return 0;
err:
    if(im)
        io_free((io_t *)im);
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:30,代码来源:iomem.c


示例11: dbg_err_if

ec_pdu_t *kache_get_evcoap_response(kache_evcoap_t *ke, 
        ec_client_t *cli, 
        char *uri)
{
    kache_obj_t *obj;
    dbg_err_if((obj = kache_get(ke->kache,uri))==NULL);
    ec_pdu_t *pdu;
    dbg_err_if((pdu = malloc(sizeof(ec_pdu_t))) == NULL);
    ec_opts_init(&pdu->opts);
    ec_pdu_t *req = &cli->req;

    ev_uint16_t ct;

    ec_opts_get_content_type(
                &req->opts, 
                &ct);

    kache_content_type_t *mt;
    dbg_err_if((mt = malloc(sizeof(kache_content_type_t)))==NULL);
    kache_ct_from_ecct(mt,&ct);
    kache_rep_t *rep;
    rep = kache_get_rep_by_media_type(obj,mt);

    //Translation
    dbg_err_if(kache_rep_to_evcoap_pdu_(rep, pdu));
    
    return pdu;
err:
    return NULL;
    

}
开发者ID:koanlogic,项目名称:webthings,代码行数:32,代码来源:kache_evcoap.c


示例12: klog_open_from_config

/**
 * \brief   create a \c klog_t object reading configuration parameters from
 *          a configuration "log" record
 *
 * \param ls        a log configuration record
 * \param pkl       the corresponding \c klog_args_t object as a value-result 
 *                  argument
 * \return
 * - \c 0  success
 * - \c ~0 on failure (\p pka MUST not be referenced)
 */
int klog_open_from_config(u_config_t *ls, klog_t **pkl)
{
    klog_t *kl = NULL;
    klog_args_t *kargs = NULL;

    /* parse config parameters */
    dbg_err_if(klog_args(ls, &kargs));

    /* create a klog object */
    dbg_err_if(klog_open(kargs, &kl));

    klog_args_free(kargs);
    kargs = NULL;

    /* stick it */
    *pkl = kl;

    return 0;
err:
    if(kargs)
        klog_args_free(kargs);
    if(kl)
        klog_close(kl);
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:36,代码来源:klog.c


示例13: session_mem_remove

static int session_mem_remove(session_t *ss)
{
    ppc_t *ppc;

    dbg_err_if (ss == NULL);
    
    if(ctx->pipc)
    {   /* children context */
        ppc = server_get_ppc(ctx->server);
        dbg_err_if(ppc == NULL);

        dbg_err_if(ppc_write(ppc, ctx->pipc, PPC_CMD_MSES_REMOVE, ss->filename, 
            strlen(ss->filename) + 1) < 0);

        /* remove the session-atom from the (local copy) atom list */
        dbg_err_if(so_atom_remove(ss->so, ss->filename));
    } else {
        /* parent context */
        dbg_err_if(so_atom_remove(ss->so, ss->filename));
    }

    return 0;
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:25,代码来源:ses_mem.c


示例14: session_client_module_init

/* this function will be called once by the server during startup */
int session_client_module_init(u_config_t *config, session_opt_t *so)
{
    u_config_t *c;
    const char *v;

    /* config may be NULL */
    dbg_err_if (so == NULL);
    
    /* default */
    so->hash = EVP_sha1(); 

    /* always enable encryption for client-side sessions */
    if(!so->encrypt)
        warn("encryption is required for client side session");
    so->encrypt = 1;

    if(config && !u_config_get_subkey(config, "client", &c))
    {
        if((v = u_config_get_subkey_value(c, "hash_function")) != NULL)
        {
            if(!strcasecmp(v, "md5"))
                so->hash = EVP_md5();
            else if(!strcasecmp(v, "sha1"))
                so->hash = EVP_sha1();
#ifdef SSL_OPENSSL
            else if(!strcasecmp(v, "ripemd160"))
                so->hash = EVP_ripemd160();
#endif
            else
                warn_err("config error: bad hash_function");
        } 
    }

#ifdef SSL_OPENSSL
    /* initialize OpenSSL HMAC stuff */
    HMAC_CTX_init(&so->hmac_ctx);

    /* gen HMAC key */
    dbg_err_if(!RAND_bytes(so->hmac_key, HMAC_KEY_LEN));

    /* init HMAC with our key and chose hash algorithm */
    HMAC_Init_ex(&so->hmac_ctx, so->hmac_key, HMAC_KEY_LEN, so->hash, NULL);
#endif

#ifdef SSL_CYASSL
    /* gen HMAC key */
    dbg_err_if(!RAND_bytes(so->hmac_key, HMAC_KEY_LEN));

    if(strcmp(so->hash, "MD5") == 0)
        HmacSetKey(&so->hmac_ctx, MD5, so->hmac_key, HMAC_KEY_LEN);
    else if(strcmp(so->hash, "SHA") == 0)
        HmacSetKey(&so->hmac_ctx, SHA, so->hmac_key, HMAC_KEY_LEN);
#endif

    return 0;
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:59,代码来源:ses_client.c


示例15: u_buf_shrink

/**
 *  \brief  Removes bytes from the tail of the buffer
 *
 *  Set the new length of the buffer; \p newlen must be less or equal to the
 *  current buffer length.
 *
 *  \param  ubuf    a previously allocated buffer object
 *  \param  newlen     new length of the buffer
 *
 *  \return 
 *  \retval  0  on success
 *  \retval ~0  on error
 */
int u_buf_shrink(u_buf_t *ubuf, size_t newlen)
{
    dbg_err_if (ubuf == NULL);
    dbg_err_if (newlen > ubuf->len);

    ubuf->len = newlen;

    return 0;
err:
    return ~0;
}
开发者ID:fdotli,项目名称:libu,代码行数:24,代码来源:buf.c


示例16: dbg_err_if

char *io_mem_get_buf(io_t *io)
{
    io_mem_t *im = (io_mem_t*)io;

    dbg_err_if(io == NULL);
    dbg_err_if(im->io.type != IO_TYPE_MEM);

    return im->buf;
err:
    return NULL;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:11,代码来源:iomem.c


示例17: var_set_name

/**
 * \ingroup vars
 * \brief   Set the name of a variable
 *
 * Set the name of variable \p v
 *
 * \param v     variable object
 * \param name  variable name (null-terminated)
 *
 * \return \c 0 if successful, non-zero on error
 */
int var_set_name(var_t *v, const char *name)
{
    dbg_err_if (v == NULL);
    dbg_err_if (name == NULL);

    dbg_err_if(u_string_set(v->sname, name, strlen(name)));

    return 0; 
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:22,代码来源:var.c


示例18: io_mem_get_bufsz

size_t io_mem_get_bufsz(io_t *io)
{
    io_mem_t *im = (io_mem_t*)io;

    dbg_err_if(io == NULL);
    dbg_err_if(im->io.type != IO_TYPE_MEM);

    return im->size;
err:
    return 0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:11,代码来源:iomem.c


示例19: var_set

/** 
 * \ingroup vars
 * \brief   Set the name and value of a variable
 *  
 * Set variable \p var to \p name and \p value.
 *
 * \param var   variable object
 * \param name  string name (null-terminated)
 * \param value string value (null-terminated)
 *  
 * \return \c 0 if successful, non-zero on error
 */ 
int var_set(var_t *var, const char *name, const char *value)
{
    dbg_err_if (var == NULL);
    dbg_err_if (name == NULL);
    dbg_err_if (value == NULL);
    
    dbg_err_if(var_set_name(var, name));
    dbg_err_if(var_set_value(var, value));

    return 0;
err:
    return ~0;
}
开发者ID:DanielTillett,项目名称:klone,代码行数:25,代码来源:var.c


示例20: u_buf_set

/**
 *  \brief  Set the value of a buffer
 *
 *  Explicitly set the value of \a ubuf to \a data.  If needed the buffer
 *  object will call ::u_buf_append to enlarge the storage needed to copy-in
 *  the \a data value.
 *
 *  \param  ubuf    a previously allocated ::u_buf_t object
 *  \param  data    a reference to the memory block that will be copied into
 *                  the buffer
 *  \param  size    size of \a data in bytes
 *
 *  \retval  0  on success
 *  \retval ~0  on error
 */
int u_buf_set (u_buf_t *ubuf, const void *data, size_t size)
{
    dbg_return_if (ubuf == NULL, ~0);
    dbg_return_if (data == NULL, ~0);
    dbg_return_if (size == 0, ~0);

    dbg_err_if (u_buf_clear(ubuf));
    dbg_err_if (u_buf_append(ubuf, data, size));

    return 0;
err:
    return ~0;
}
开发者ID:fdotli,项目名称:libu,代码行数:28,代码来源:buf.c



注:本文中的dbg_err_if函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ dbg_func_in函数代码示例发布时间:2022-05-30
下一篇:
C++ dbg_err函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap