当前位置: 首页>>代码示例>>C++>>正文


C++ ProgrammingError函数代码示例

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


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


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