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

C++ ProgrammingError函数代码示例

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

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



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

示例1: CopyList

void CopyList(Item **dest, const Item *source)
/* Copy or concat lists */
{
    if (*dest != NULL)
    {
        ProgrammingError("CopyList - list not initialized");
    }

    if (source == NULL)
    {
        return;
    }

    for (const Item *ip = source; ip != NULL; ip = ip->next)
    {
        AppendItem(dest, ip->name, ip->classes);
    }
}
开发者ID:FancsalMelinda,项目名称:core,代码行数:18,代码来源:item_lib.c


示例2: ScopePutMatch

void ScopePutMatch(int index, const char *value)
{
    if (!SCOPE_MATCH)
    {
        SCOPE_MATCH = ScopeNew("match");
    }
    Scope *ptr = SCOPE_MATCH;

    char lval[4] = { 0 };
    snprintf(lval, 3, "%d", index);

    Rval rval = (Rval) { value, RVAL_TYPE_SCALAR };

    CfAssoc *assoc = HashLookupElement(ptr->hashtable, lval);

    if (assoc)
    {
        if (CompareVariableValue(rval, assoc) == 0)
        {
            /* Identical value, keep as is */
        }
        else
        {
            /* Different value, bark and replace */
            if (!UnresolvedVariables(assoc, RVAL_TYPE_SCALAR))
            {
                CfOut(OUTPUT_LEVEL_INFORM, "", " !! Duplicate selection of value for variable \"%s\" in scope %s", lval, ptr->scope);
            }
            RvalDestroy(assoc->rval);
            assoc->rval = RvalCopy(rval);
            assoc->dtype = DATA_TYPE_STRING;
            CfDebug("Stored \"%s\" in context %s\n", lval, "match");
        }
    }
    else
    {
        if (!HashInsertElement(ptr->hashtable, lval, rval, DATA_TYPE_STRING))
        {
            ProgrammingError("Hash table is full");
        }
    }
}
开发者ID:jooooooon,项目名称:core,代码行数:42,代码来源:scope.c


示例3: Hostname2IPString

/**
 * @brief DNS lookup of hostname, store the address as string into dst of size
 * dst_size.
 * @return -1 in case of unresolvable hostname or other error.
 */
int Hostname2IPString(char *dst, const char *hostname, size_t dst_size)
{
    int ret;
    struct addrinfo *response, *ap;
    struct addrinfo query = {
        .ai_family = AF_UNSPEC,
        .ai_socktype = SOCK_STREAM
    };

    if (dst_size < CF_MAX_IP_LEN)
    {
        ProgrammingError("Hostname2IPString got %zu, needs at least"
                         " %d length buffer for IPv6 portability!",
                         dst_size, CF_MAX_IP_LEN);
    }

    ret = getaddrinfo(hostname, NULL, &query, &response);
    if ((ret) != 0)
    {
        Log(LOG_LEVEL_INFO,
            "Unable to lookup hostname '%s' or cfengine service. (getaddrinfo: %s)",
            hostname, gai_strerror(ret));
        return -1;
    }

    for (ap = response; ap != NULL; ap = ap->ai_next)
    {
        /* No lookup, just convert numeric IP to string. */
        int ret2 = getnameinfo(ap->ai_addr, ap->ai_addrlen,
                               dst, dst_size, NULL, 0, NI_NUMERICHOST);
        if (ret2 == 0)
        {
            freeaddrinfo(response);
            return 0;                                           /* Success */
        }
    }
    freeaddrinfo(response);

    Log(LOG_LEVEL_ERR,
        "Hostname2IPString: ERROR even though getaddrinfo returned success!");
    return -1;
}
开发者ID:grimm26,项目名称:core,代码行数:47,代码来源:communication.c


示例4: VariableStateHasMore

static bool VariableStateHasMore(const PromiseIterator *iter, size_t index)
{
    CfAssoc *var = SeqAt(iter->vars, index);
    switch (var->rval.type)
    {
    case RVAL_TYPE_LIST:
        {
            const Rlist *state = SeqAt(iter->var_states, index);
            return state && state->next;
        }

    case RVAL_TYPE_CONTAINER:
    case RVAL_TYPE_FNCALL:
    case RVAL_TYPE_NOPROMISEE:
    case RVAL_TYPE_SCALAR:
        ProgrammingError("Unhandled case in switch %d", var->rval.type);
    }

    return false;
}
开发者ID:Kegeruneku,项目名称:core,代码行数:20,代码来源:iteration.c


示例5: FileStateToChar

static char FileStateToChar(FileState status)
{
    switch(status)
    {
    case FILE_STATE_NEW:
        return 'N';

    case FILE_STATE_REMOVED:
        return 'R';

    case FILE_STATE_CONTENT_CHANGED:
        return 'C';

    case FILE_STATE_STATS_CHANGED:
        return 'S';

    default:
        ProgrammingError("Unhandled file status in switch: %d", status);
    }
}
开发者ID:jooooooon,项目名称:core,代码行数:20,代码来源:verify_files_hashes.c


示例6: switch

static const char *SpecialScopeToString(SpecialScope scope)
{
    switch (scope)
    {
    case SPECIAL_SCOPE_CONST:
        return "const";
    case SPECIAL_SCOPE_EDIT:
        return "edit";
    case SPECIAL_SCOPE_MATCH:
        return "match";
    case SPECIAL_SCOPE_MON:
        return "mon";
    case SPECIAL_SCOPE_SYS:
        return "sys";
    case SPECIAL_SCOPE_THIS:
        return "this";
    default:
        ProgrammingError("Unhandled special scope");
    }
}
开发者ID:patuchov,项目名称:core,代码行数:20,代码来源:scope.c


示例7: CompareVersions

VersionCmpResult CompareVersions(EvalContext *ctx, const char *v1, const char *v2, Attributes a, Promise *pp)
{
    switch (a.packages.package_select)
    {
    case PACKAGE_VERSION_COMPARATOR_EQ:
    case PACKAGE_VERSION_COMPARATOR_NONE:
        return CompareVersionsEqual(ctx, v1, v2, a, pp);
    case PACKAGE_VERSION_COMPARATOR_NEQ:
        return InvertResult(CompareVersionsEqual(ctx, v1, v2, a, pp));
    case PACKAGE_VERSION_COMPARATOR_LT:
        return CompareVersionsLess(ctx, v1, v2, a, pp);
    case PACKAGE_VERSION_COMPARATOR_GT:
        return CompareVersionsLess(ctx, v2, v1, a, pp);
    case PACKAGE_VERSION_COMPARATOR_GE:
        return InvertResult(CompareVersionsLess(ctx, v1, v2, a, pp));
    case PACKAGE_VERSION_COMPARATOR_LE:
        return InvertResult(CompareVersionsLess(ctx, v2, v1, a, pp));
    default:
        ProgrammingError("Unexpected comparison value: %d", a.packages.package_select);
    }
}
开发者ID:nperron,项目名称:core,代码行数:21,代码来源:vercmp.c


示例8: PrintList

void PrintList(List *list)
{
    ListIterator *i = NULL;

    i = ListIteratorGet(list);
    if (!i)
    {
        ProgrammingError("Unable to get iterator for hub list");
        return;
    }

    do
    {
        HostProperties *hostprop = (HostProperties *)ListIteratorData(i);

        Log(LOG_LEVEL_NOTICE, "CFEngine Policy Server: hostname '%s', IP address '%s', port %d",
            hostprop->Hostname, hostprop->IPAddress, hostprop->Port);
    } while (ListIteratorNext(i) != -1);

    ListIteratorDestroy(&i);
}
开发者ID:basvandervlies,项目名称:core,代码行数:21,代码来源:findhub.c


示例9: sockaddr_AddrCompare

int sockaddr_AddrCompare(const void *sa1, const void *sa2)
{
    int sa1_family = ((struct sockaddr *) sa1)->sa_family;
    int sa2_family = ((struct sockaddr *) sa2)->sa_family;

    if ((sa1_family != AF_INET && sa1_family != AF_INET6) ||
        (sa2_family != AF_INET && sa2_family != AF_INET6))
    {
        ProgrammingError("sockaddr_AddrCompare: Unknown address families %d %d",
                         sa1_family, sa2_family);
    }

    if (sa1_family != sa2_family)
    {
        /* We consider any IPv4 address smaller than any IPv6 one. */
        return (sa1_family == AF_INET) ? -1 : 1;
    }

    int result;
    switch (sa1_family)
    {
    case AF_INET:
    {
        struct in_addr *addr1 = & ((struct sockaddr_in *) sa1)->sin_addr;
        struct in_addr *addr2 = & ((struct sockaddr_in *) sa2)->sin_addr;
        result = memcmp(addr1, addr2, sizeof(*addr1));
    }
    case AF_INET6:
    {
        struct in6_addr *addr1 = & ((struct sockaddr_in6 *) sa1)->sin6_addr;
        struct in6_addr *addr2 = & ((struct sockaddr_in6 *) sa2)->sin6_addr;
        result = memcmp(addr1, addr2, sizeof(*addr1));
    }
    default:
        assert(0);
        result = 0;
    }

    return result;
}
开发者ID:bahamat,项目名称:cfengine-core,代码行数:40,代码来源:misc.c


示例10: RlistFlatten

void RlistFlatten(EvalContext *ctx, Rlist **list)
{
    for (Rlist *rp = *list; rp != NULL;)
    {
        if (rp->type != RVAL_TYPE_SCALAR)
        {
            rp = rp->next;
            continue;
        }

        char naked[CF_BUFSIZE] = "";
        if (IsNakedVar(rp->item, '@'))
        {
            GetNaked(naked, rp->item);

            Rval rv;
            if (EvalContextVariableGet(ctx, (VarRef) { NULL, ScopeGetCurrent()->scope, naked }, &rv, NULL))
            {
                switch (rv.type)
                {
                case RVAL_TYPE_LIST:
                    for (const Rlist *srp = rv.item; srp != NULL; srp = srp->next)
                    {
                        RlistAppend(list, srp->item, srp->type);
                    }
                    Rlist *next = rp->next;
                    RlistDestroyEntry(list, rp);
                    rp = next;
                    continue;

                default:
                    ProgrammingError("List variable does not resolve to a list");
                    RlistAppend(list, rp->item, rp->type);
                    break;
                }
            }
        }
        rp = rp->next;
    }
}
开发者ID:arcimboldo,项目名称:cfengine,代码行数:40,代码来源:rlist.c


示例11: switch

const char *LogLevelToString(LogLevel level)
{
    switch (level)
    {
    case LOG_LEVEL_CRIT:
        return "critical";
    case LOG_LEVEL_ERR:
        return "error";
    case LOG_LEVEL_WARNING:
        return "warning";
    case LOG_LEVEL_NOTICE:
        return "notice";
    case LOG_LEVEL_INFO:
        return "info";
    case LOG_LEVEL_VERBOSE:
        return "verbose";
    case LOG_LEVEL_DEBUG:
        return "debug";
    default:
        ProgrammingError("Unknown log level passed to LogLevelToString: %d", level);
    }
}
开发者ID:arcimboldo,项目名称:cfengine,代码行数:22,代码来源:logging.c


示例12: defined

char *sockaddr_ntop(struct sockaddr *sa)
{
#if defined(HAVE_GETADDRINFO)
    static char addrbuf[INET6_ADDRSTRLEN];
    void *addr;
#else
    static char addrbuf[20];
#endif

    switch (sa->sa_family)
    {
    case AF_INET:
        CfDebug("IPV4 address\n");
        snprintf(addrbuf, 20, "%.19s", inet_ntoa(((struct sockaddr_in *) sa)->sin_addr));
        break;

#ifdef AF_LOCAL
    case AF_LOCAL:
        CfDebug("Local socket\n");
        strcpy(addrbuf, "127.0.0.1");
        break;
#endif

#if defined(HAVE_GETADDRINFO)
    case AF_INET6:
        CfDebug("IPV6 address\n");
        addr = &((struct sockaddr_in6 *) sa)->sin6_addr;
        inet_ntop(sa->sa_family, addr, addrbuf, sizeof(addrbuf));
        break;
#endif
    default:
        CfDebug("Address family was %d\n", sa->sa_family);
        ProgrammingError("Software failure in sockaddr_ntop\n");
    }

    CfDebug("sockaddr_ntop(%s)\n", addrbuf);
    return addrbuf;
}
开发者ID:FraserMCampbell,项目名称:core,代码行数:38,代码来源:sockaddr.c


示例13: sockaddr_port

/* Return the port number in host byte order. */
uint16_t sockaddr_port(const void *sa)
{
    int family = ((struct sockaddr *) sa)->sa_family;
    uint16_t port;

    switch (family)
    {
    case AF_INET:
        port = ((struct sockaddr_in *) sa)->sin_port;
        break;

#ifdef HAVE_GETADDRINFO
    case AF_INET6:
        addr = ((struct sockaddr_in6 *) sa)->sin6_port;
        break;
#endif

    default:
        ProgrammingError("sockaddr_port: address family was %d", family);
    }

    return ntohs(port);
}
开发者ID:bahamat,项目名称:cfengine-core,代码行数:24,代码来源:misc.c


示例14: LastStackFrame

static StackFrame *LastStackFrameBundle(const EvalContext *ctx)
{
    StackFrame *last_frame = LastStackFrame(ctx, 0);

    switch (last_frame->type)
    {
    case STACK_FRAME_TYPE_BUNDLE:
        return last_frame;

    case STACK_FRAME_TYPE_BODY:
        {
            assert(LastStackFrame(ctx, 1));
            assert(LastStackFrame(ctx, 1)->type == STACK_FRAME_TYPE_PROMISE);
            StackFrame *previous_frame = LastStackFrame(ctx, 2);
            if (previous_frame)
            {
                assert(previous_frame->type == STACK_FRAME_TYPE_BUNDLE);
                return previous_frame;
            }
            else
            {
                return NULL;
            }
        }

    case STACK_FRAME_TYPE_PROMISE:
        {
            StackFrame *previous_frame = LastStackFrame(ctx, 1);
            assert(previous_frame);
            assert("Promise stack frame does not follow bundle stack frame" && previous_frame->type == STACK_FRAME_TYPE_BUNDLE);
            return previous_frame;
        }

    default:
        ProgrammingError("Unhandled stack frame type");
    }
}
开发者ID:shaunamarie,项目名称:core,代码行数:37,代码来源:env_context.c


示例15: ScopePopThis

void ScopePopThis()
{
    Scope *op = NULL;

    if (RlistLen(CF_STCK) > 0)
    {
        ScopeClear("this");
        {
            Rlist *rp = CF_STCK;

            if (CF_STCK == NULL)
            {
                ProgrammingError("Attempt to pop from empty stack");
            }

            op = rp->item;

            if (rp->next == NULL)       /* only one left */
            {
                CF_STCK = (void *) NULL;
            }
            else
            {
                CF_STCK = rp->next;
            }

            free((char *) rp);
        }
        if (op == NULL)
        {
            return;
        }

        free(op->scope);
        op->scope = xstrdup("this");
    }
}
开发者ID:jooooooon,项目名称:core,代码行数:37,代码来源:scope.c


示例16: UpdatePromiseCounters

void UpdatePromiseCounters(PromiseResult status)
{
    switch (status)
    {
    case PROMISE_RESULT_CHANGE:
        PR_REPAIRED++;
        break;

    case PROMISE_RESULT_NOOP:
        PR_KEPT++;
        break;

    case PROMISE_RESULT_WARN:
    case PROMISE_RESULT_TIMEOUT:
    case PROMISE_RESULT_FAIL:
    case PROMISE_RESULT_DENIED:
    case PROMISE_RESULT_INTERRUPTED:
        PR_NOTKEPT++;
        break;

    default:
        ProgrammingError("Unexpected status '%c' has been passed to UpdatePromiseCounters", status);
    }
}
开发者ID:maciejmrowiec,项目名称:core,代码行数:24,代码来源:audit.c


示例17: VariableStateReset

static bool VariableStateReset(PromiseIterator *iter, size_t index)
{
    assert(index < SeqLength(iter->var_states));

    CfAssoc *var = SeqAt(iter->vars, index);

    switch (var->rval.type)
    {
    case RVAL_TYPE_LIST:
        {
            Rlist *state = RvalRlistValue(var->rval);
            // find the first valid value, return false if there is none
            state = FirstRealEntry(state);
            SeqSet(iter->var_states, index, state);
            return state != NULL;
        }
        break;

    default:
        ProgrammingError("Unhandled case in switch");
    }

    return false;
}
开发者ID:Kegeruneku,项目名称:core,代码行数:24,代码来源:iteration.c


示例18: sockaddr_pton

bool sockaddr_pton(int af, const void *src, void *genaddr)
{
    switch (af)
    {
    case AF_INET:
    {
        struct sockaddr_in *addr = (struct sockaddr_in *) genaddr;

        memset(addr, 0, sizeof(struct sockaddr_in));
        addr->sin_family = AF_INET;
        addr->sin_addr.s_addr = inet_addr(src);

        CfDebug("Coded ipv4 %s\n", sockaddr_ntop((struct sockaddr *) genaddr));

        return addr->sin_addr.s_addr != INADDR_NONE;
    }
#if defined(HAVE_GETADDRINFO)
    case AF_INET6:
    {
        int err;
        struct sockaddr_in6 *addr = (struct sockaddr_in6 *) genaddr;

        memset(addr, 0, sizeof(struct sockaddr_in6));
        addr->sin6_family = AF_INET6;
        err = inet_pton(AF_INET6, src, &addr->sin6_addr);

        CfDebug("Coded ipv6 %s\n", sockaddr_ntop((struct sockaddr *) genaddr));

        return err > 0;
    }
#endif
    default:
        CfDebug("Address family was %d\n", af);
        ProgrammingError("Software failure in sockaddr_pton\n");
    }
}
开发者ID:FraserMCampbell,项目名称:core,代码行数:36,代码来源:sockaddr.c


示例19: ExpandDanglers

Rval ExpandDanglers(EvalContext *ctx,
                    const char *ns, const char *scope,
                    Rval rval, const Promise *pp)
{
    assert(ctx);
    assert(pp);

    switch (rval.type)
    {
    case RVAL_TYPE_SCALAR:
        if (IsCf3VarString(RvalScalarValue(rval)))
        {
            return EvaluateFinalRval(ctx, PromiseGetPolicy(pp), ns, scope, rval, false, pp);
        }
        else
        {
            return RvalCopy(rval);
        }
        break;

    case RVAL_TYPE_LIST:
        {
            Rlist *result_list = RlistCopy(RvalRlistValue(rval));
            RlistFlatten(ctx, &result_list);
            return (Rval) { result_list, RVAL_TYPE_LIST };
        }
        break;

    case RVAL_TYPE_CONTAINER:
    case RVAL_TYPE_FNCALL:
    case RVAL_TYPE_NOPROMISEE:
        return RvalCopy(rval);
    }

    ProgrammingError("Unhandled Rval type");
}
开发者ID:rcorrieri,项目名称:core,代码行数:36,代码来源:expand.c


示例20: xcalloc

Promise *DeRefCopyPromise(EvalContext *ctx, const Promise *pp)
{
    Promise *pcopy;
    Rval returnval;

    pcopy = xcalloc(1, sizeof(Promise));

    if (pp->promiser)
    {
        pcopy->promiser = xstrdup(pp->promiser);
    }

    if (pp->promisee.item)
    {
        pcopy->promisee = RvalCopy(pp->promisee);
        if (pcopy->promisee.type == RVAL_TYPE_LIST)
        {
            Rlist *rval_list = RvalRlistValue(pcopy->promisee);
            RlistFlatten(ctx, &rval_list);
            pcopy->promisee.item = rval_list;
        }
    }

    if (pp->classes)
    {
        pcopy->classes = xstrdup(pp->classes);
    }

/* FIXME: may it happen? */
    if ((pp->promisee.item != NULL && pcopy->promisee.item == NULL))
    {
        ProgrammingError("Unable to copy promise");
    }

    pcopy->parent_promise_type = pp->parent_promise_type;
    pcopy->offset.line = pp->offset.line;
    pcopy->comment = pp->comment ? xstrdup(pp->comment) : NULL;
    pcopy->has_subbundles = pp->has_subbundles;
    pcopy->conlist = SeqNew(10, ConstraintDestroy);
    pcopy->org_pp = pp->org_pp;
    pcopy->offset = pp->offset;

/* No further type checking should be necessary here, already done by CheckConstraintTypeMatch */

    for (size_t i = 0; i < SeqLength(pp->conlist); i++)
    {
        Constraint *cp = SeqAt(pp->conlist, i);

        Body *bp = NULL;
        FnCall *fp = NULL;

        /* A body template reference could look like a scalar or fn to the parser w/w () */
        const Policy *policy = PolicyFromPromise(pp);
        Seq *bodies = policy ? policy->bodies : NULL;

        char body_ns[CF_MAXVARSIZE] = "";
        char body_name[CF_MAXVARSIZE] = "";

        switch (cp->rval.type)
        {
        case RVAL_TYPE_SCALAR:
            if (cp->references_body)
            {
                SplitScopeName(RvalScalarValue(cp->rval), body_ns, body_name);
                if (EmptyString(body_ns))
                {
                    strncpy(body_ns, PromiseGetNamespace(pp), CF_MAXVARSIZE);
                }
                bp = IsBody(bodies, body_ns, body_name);
            }
            fp = NULL;
            break;
        case RVAL_TYPE_FNCALL:
            fp = RvalFnCallValue(cp->rval);
            SplitScopeName(fp->name, body_ns, body_name);
            if (EmptyString(body_ns))
            {
                strncpy(body_ns, PromiseGetNamespace(pp), CF_MAXVARSIZE);
            }
            bp = IsBody(bodies, body_ns, body_name);
            break;
        default:
            bp = NULL;
            fp = NULL;
            break;
        }

        /* First case is: we have a body template to expand lval = body(args), .. */

        if (bp)
        {
            EvalContextStackPushBodyFrame(ctx, pcopy, bp, fp ? fp->args : NULL);

            if (strcmp(bp->type, cp->lval) != 0)
            {
                Log(LOG_LEVEL_ERR,
                    "Body type mismatch for body reference '%s' in promise at line %zu of file '%s', '%s' does not equal '%s'",
                      body_name, pp->offset.line, PromiseGetBundle(pp)->source_path, bp->type, cp->lval);
            }

//.........这里部分代码省略.........
开发者ID:embedian,项目名称:core,代码行数:101,代码来源:promises.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ Progress函数代码示例发布时间:2022-05-30
下一篇:
C++ ProgramFail函数代码示例发布时间: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