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


C++ CfDebug函数代码示例

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


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

示例1: memset

static Averages *GetCurrentAverages(char *timekey)
{
    CF_DB *dbp;
    static Averages entry;

    if (!OpenDB(&dbp, dbid_observations))
    {
        return NULL;
    }

    memset(&entry, 0, sizeof(entry));

    AGE++;
    WAGE = AGE / SECONDS_PER_WEEK * CF_MEASURE_INTERVAL;

    if (ReadDB(dbp, timekey, &entry, sizeof(Averages)))
    {
        int i;

        for (i = 0; i < CF_OBSERVABLES; i++)
        {
            CfDebug("Previous values (%lf,..) for time index %s\n\n", entry.Q[i].expect, timekey);
        }
    }
    else
    {
        CfDebug("No previous value for time index %s\n", timekey);
    }

    CloseDB(dbp);
    return &entry;
}
开发者ID:cyphermaster,项目名称:core,代码行数:32,代码来源:env_monitor.c

示例2: CfDebug

Bundle *AppendBundle(Bundle **start, char *name, char *type, Rlist *args)
{
    Bundle *bp, *lp;

    CfDebug("Appending new bundle %s %s (", type, name);

    if (DEBUG)
    {
        ShowRlist(stdout, args);
    }
    CfDebug(")\n");

    CheckBundle(name, type);

    bp = xcalloc(1, sizeof(Bundle));

    if (*start == NULL)
    {
        *start = bp;
    }
    else
    {
        for (lp = *start; lp->next != NULL; lp = lp->next)
        {
        }

        lp->next = bp;
    }

    bp->name = xstrdup(name);
    bp->type = xstrdup(type);
    bp->args = args;

    return bp;
}
开发者ID:dnaeon,项目名称:core,代码行数:35,代码来源:install.c

示例3: TimeAbs2Int

long TimeAbs2Int(char *s)
{
    time_t cftime;
    int i;
    char mon[4], h[3], m[3];
    long month = 0, day = 0, hour = 0, min = 0, year = 0;
    static long days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };

    if (s == NULL)
    {
        return CF_NOINT;
    }

    year = Str2Int(VYEAR);

    if (year % 4 == 0)          /* leap years */
    {
        days[1] = 29;
    }

    if (strstr(s, ":"))         /* Hr:Min */
    {
        sscanf(s, "%2[^:]:%2[^:]:", h, m);
        month = Month2Int(VMONTH);
        day = Str2Int(VDAY);
        hour = Str2Int(h);
        min = Str2Int(m);
    }
    else                        /* date Month */
    {
        sscanf(s, "%3[a-zA-Z] %ld", mon, &day);

        month = Month2Int(mon);

        if (Month2Int(VMONTH) < month)
        {
            /* Wrapped around */
            year--;
        }
    }

    CfDebug("(%s)\n%ld=%s,%ld=%s,%ld,%ld,%ld\n", s, year, VYEAR, month, VMONTH, day, hour, min);

    cftime = 0;
    cftime += min * 60;
    cftime += hour * 3600;
    cftime += (day - 1) * 24 * 3600;
    cftime += 24 * 3600 * ((year - 1970) / 4);  /* Leap years */

    for (i = 0; i < month - 1; i++)
    {
        cftime += days[i] * 24 * 3600;
    }

    cftime += (year - 1970) * 365 * 24 * 3600;

    CfDebug("Time %s CORRESPONDS %s\n", s, cf_ctime(&cftime));
    return (long) cftime;
}
开发者ID:gsprint,项目名称:core,代码行数:59,代码来源:conversion.c

示例4: IsIPV6Address

int IsIPV6Address(char *name)
{
    char *sp;
    int count, max = 0;

    CfDebug("IsIPV6Address(%s)\n", name);

    if (name == NULL)
    {
        return false;
    }

    count = 0;

    for (sp = name; *sp != '\0'; sp++)
    {
        if (isalnum((int) *sp))
        {
            count++;
        }
        else if ((*sp != ':') && (*sp != '.'))
        {
            return false;
        }

        if (*sp == 'r')
        {
            return false;
        }

        if (count > max)
        {
            max = count;
        }
        else
        {
            count = 0;
        }
    }

    if (max <= 2)
    {
        CfDebug("Looks more like a MAC address");
        return false;
    }

    if (strstr(name, ":") == NULL)
    {
        return false;
    }

    if (strcasestr(name, "scope"))
    {
        return false;
    }

    return true;
}
开发者ID:pombredanne,项目名称:core,代码行数:58,代码来源:communication.c

示例5: RvalDestroy

void RvalDestroy(Rval rval)
{
    Rlist *clist, *next = NULL;

    CfDebug("DeleteRvalItem(%c)", rval.type);

    if (DEBUG)
    {
        RvalShow(stdout, rval);
    }

    CfDebug("\n");

    if (rval.item == NULL)
    {
        CfDebug("DeleteRval NULL\n");
        return;
    }

    switch (rval.type)
    {
    case RVAL_TYPE_SCALAR:

        ThreadLock(cft_lock);
        free((char *) rval.item);
        ThreadUnlock(cft_lock);
        break;

    case RVAL_TYPE_LIST:

        /* rval is now a list whose first item is clist->item */

        for (clist = (Rlist *) rval.item; clist != NULL; clist = next)
        {

            next = clist->next;

            if (clist->item)
            {
                RvalDestroy((Rval) {clist->item, clist->type});
            }

            free(clist);
        }

        break;

    case RVAL_TYPE_FNCALL:

        FnCallDestroy((FnCall *) rval.item);
        break;

    default:
        CfDebug("Nothing to do\n");
        return;
    }
}
开发者ID:ouafae31,项目名称:core,代码行数:57,代码来源:rlist.c

示例6: ArchiveToRepository

int ArchiveToRepository(const char *file, Attributes attr, Promise *pp, const ReportContext *report_context)
 /* Returns true if the file was backup up and false if not */
{
    char destination[CF_BUFSIZE];
    struct stat sb, dsb;

    if (!GetRepositoryPath(file, attr, destination))
    {
        return false;
    }

    if (attr.copy.backup == cfa_nobackup)
    {
        return true;
    }

    if (IsItemIn(VREPOSLIST, file))
    {
        CfOut(OUTPUT_LEVEL_INFORM, "",
              "The file %s has already been moved to the repository once. Multiple update will cause loss of backup.",
              file);
        return true;
    }

    ThreadLock(cft_getaddr);
    PrependItemList(&VREPOSLIST, file);
    ThreadUnlock(cft_getaddr);

    CfDebug("Repository(%s)\n", file);
    
    JoinPath(destination, CanonifyName(file));

    if (!MakeParentDirectory(destination, attr.move_obstructions, report_context))
    {
    }

    if (cfstat(file, &sb) == -1)
    {
        CfDebug("File %s promised to archive to the repository but it disappeared!\n", file);
        return true;
    }

    cfstat(destination, &dsb);

    CheckForFileHoles(&sb, pp);

    if (pp && CopyRegularFileDisk(file, destination, pp->makeholes))
    {
        CfOut(OUTPUT_LEVEL_INFORM, "", "Moved %s to repository location %s\n", file, destination);
        return true;
    }
    else
    {
        CfOut(OUTPUT_LEVEL_INFORM, "", "Failed to move %s to repository location %s\n", file, destination);
        return false;
    }
}
开发者ID:FancsalMelinda,项目名称:core,代码行数:57,代码来源:files_repository.c

示例7: CheckParseReal

static void CheckParseReal(char *lval, char *s, const char *range)
{
    Item *split;
    double max = (double) CF_LOWINIT, min = (double) CF_HIGHINIT, val;
    int n;
    char output[CF_BUFSIZE];

    CfDebug("\nCheckParseReal(%s => %s/%s)\n", lval, s, range);

    if (s == NULL)
    {
        return;
    }

    if (strcmp(s, "inf") == 0)
    {
        ReportError("keyword \"inf\" has an integer value, cannot be used as real");
        return;
    }

    if (IsCf3VarString(s))
    {
        CfDebug("Validation: Unable to verify syntax of real %s due to variable expansion at this stage\n", s);
        return;
    }

/* Numeric types are registered by range separated by comma str "min,max" */

    split = SplitString(range, ',');

    if ((n = ListLen(split)) != 2)
    {
        FatalError("INTERN:format specifier for real rvalues is not ok for lval %s - %d items", lval, n);
    }

    sscanf(split->name, "%lf", &min);
    sscanf(split->next->name, "%lf", &max);
    DeleteItemList(split);

    if (min == CF_HIGHINIT || max == CF_LOWINIT)
    {
        FatalError("INTERN:could not parse format specifier for int rvalues for lval %s", lval);
    }

    val = Str2Double(s);

    if (val > max || val < min)
    {
        snprintf(output, CF_BUFSIZE,
                 "Real item on rhs of lval \'%s\' give as {%s => %.3lf} is out of bounds (should be in [%s])", lval, s,
                 val, range);
        ReportError(output);
    }

    CfDebug("CheckParseReal - syntax verified\n\n");
}
开发者ID:dnaeon,项目名称:core,代码行数:56,代码来源:syntax.c

示例8: CheckParseString

static int CheckParseString(char *lval, char *s, const char *range)
{
    char output[CF_BUFSIZE];

    CfDebug("\nCheckParseString(%s => %s/%s)\n", lval, s, range);

    if (s == NULL)
    {
        return true;
    }

    if (strlen(range) == 0)
    {
        return true;
    }

    if (IsNakedVar(s, '@') || IsNakedVar(s, '$'))
    {
        CfDebug("Validation: Unable to verify variable expansion of %s at this stage\n", s);
        return false;
    }

/* Deal with complex strings as special cases */

    if (strcmp(lval, "mode") == 0 || strcmp(lval, "search_mode") == 0)
    {
        mode_t plus, minus;

        if (!ParseModeString(s, &plus, &minus))
        {
            snprintf(output, CF_BUFSIZE, "Error parsing Unix permission string %s)", s);
            ReportError(output);
            return false;
        }
    }

    if (FullTextMatch(range, s))
    {
        return true;
    }

    if (IsCf3VarString(s))
    {
        CfDebug("Validation: Unable to verify syntax of %s due to variable expansion at this stage\n", s);
    }
    else
    {
        snprintf(output, CF_BUFSIZE,
                 "Scalar item in %s => { %s } in rvalue is out of bounds (value should match pattern %s)", lval, s,
                 range);
        ReportError(output);
        return false;
    }

    return true;
}
开发者ID:dnaeon,项目名称:core,代码行数:56,代码来源:syntax.c

示例9: CheckParseInt

static SyntaxTypeMatch CheckParseInt(const char *lval, const char *s, const char *range)
{
    Item *split;
    int n;
    long max = CF_LOWINIT, min = CF_HIGHINIT, val;

/* Numeric types are registered by range separated by comma str "min,max" */
    CfDebug("\nCheckParseInt(%s => %s/%s)\n", lval, s, range);

    split = SplitString(range, ',');

    if ((n = ListLen(split)) != 2)
    {
        ProgrammingError("INTERN: format specifier for int rvalues is not ok for lval %s - got %d items", lval, n);
    }

    sscanf(split->name, "%ld", &min);

    if (strcmp(split->next->name, "inf") == 0)
    {
        max = CF_INFINITY;
    }
    else
    {
        sscanf(split->next->name, "%ld", &max);
    }

    DeleteItemList(split);

    if (min == CF_HIGHINIT || max == CF_LOWINIT)
    {
        ProgrammingError("INTERN: could not parse format specifier for int rvalues for lval %s", lval);
    }

    if (IsCf3VarString(s))
    {
        return SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED;
    }

    val = IntFromString(s);

    if (val == CF_NOINT)
    {
        return SYNTAX_TYPE_MATCH_ERROR_INT_PARSE;
    }

    if (val > max || val < min)
    {
        return SYNTAX_TYPE_MATCH_ERROR_INT_OUT_OF_RANGE;
    }

    CfDebug("CheckParseInt - syntax verified\n\n");

    return SYNTAX_TYPE_MATCH_OK;
}
开发者ID:jooooooon,项目名称:core,代码行数:55,代码来源:syntax.c

示例10: ArgTemplate

void ArgTemplate(FnCall *fp, const FnCallArg *argtemplate, Rlist *realargs)
{
    int argnum, i;
    Rlist *rp = fp->args;
    char id[CF_BUFSIZE], output[CF_BUFSIZE];
    const FnCallType *fn = FnCallTypeGet(fp->name);

    snprintf(id, CF_MAXVARSIZE, "built-in FnCall %s-arg", fp->name);

    for (argnum = 0; rp != NULL && argtemplate[argnum].pattern != NULL; argnum++)
    {
        if (rp->type != RVAL_TYPE_FNCALL)
        {
            /* Nested functions will not match to lval so don't bother checking */
            SyntaxTypeMatch err = CheckConstraintTypeMatch(id, (Rval) {rp->item, rp->type}, argtemplate[argnum].dtype, argtemplate[argnum].pattern, 1);
            if (err != SYNTAX_TYPE_MATCH_OK && err != SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED)
            {
                FatalError("in %s: %s", id, SyntaxTypeMatchToString(err));
            }
        }

        rp = rp->next;
    }

    if (argnum != RlistLen(realargs) && !fn->varargs)
    {
        snprintf(output, CF_BUFSIZE, "Argument template mismatch handling function %s(", fp->name);
        RlistShow(stderr, realargs);
        fprintf(stderr, ")\n");

        for (i = 0, rp = realargs; i < argnum; i++)
        {
            printf("  arg[%d] range %s\t", i, argtemplate[i].pattern);
            if (rp != NULL)
            {
                RvalShow(stdout, (Rval) {rp->item, rp->type});
                rp = rp->next;
            }
            else
            {
                printf(" ? ");
            }
            printf("\n");
        }

        FatalError("Bad arguments");
    }

    for (rp = realargs; rp != NULL; rp = rp->next)
    {
        CfDebug("finalarg: %s\n", (char *) rp->item);
    }

    CfDebug("End ArgTemplate\n");
}
开发者ID:shaunamarie,项目名称:core,代码行数:55,代码来源:args.c

示例11: SelectOwnerMatch

static int SelectOwnerMatch(char *path, struct stat *lstatptr, Rlist *crit)
{
    AlphaList leafattrib;
    Rlist *rp;
    char ownerName[CF_BUFSIZE];
    int gotOwner;

    InitAlphaList(&leafattrib);

#ifndef MINGW                   // no uids on Windows
    char buffer[CF_SMALLBUF];
    sprintf(buffer, "%jd", (uintmax_t) lstatptr->st_uid);
    PrependAlphaList(&leafattrib, buffer);
#endif /* MINGW */

    gotOwner = GetOwnerName(path, lstatptr, ownerName, sizeof(ownerName));

    if (gotOwner)
    {
        PrependAlphaList(&leafattrib, ownerName);
    }
    else
    {
        PrependAlphaList(&leafattrib, "none");
    }

    for (rp = crit; rp != NULL; rp = rp->next)
    {
        if (EvalFileResult((char *) rp->item, &leafattrib))
        {
            CfDebug(" - ? Select owner match\n");
            DeleteAlphaList(&leafattrib);
            return true;
        }

        if (gotOwner && FullTextMatch((char *) rp->item, ownerName))
        {
            CfDebug(" - ? Select owner match\n");
            DeleteAlphaList(&leafattrib);
            return true;
        }

#ifndef MINGW
        if (FullTextMatch((char *) rp->item, buffer))
        {
            CfDebug(" - ? Select owner match\n");
            DeleteAlphaList(&leafattrib);
            return true;
        }
#endif /* NOT MINGW */
    }

    DeleteAlphaList(&leafattrib);
    return false;
}
开发者ID:xrg,项目名称:cfengine-core,代码行数:55,代码来源:files_select.c

示例12: SelectOwnerMatch

static int SelectOwnerMatch(char *path, struct stat *lstatptr, Rlist *crit)
{
    Rlist *rp;
    char ownerName[CF_BUFSIZE];
    int gotOwner;

    StringSet *leafattrib = StringSetNew();

#ifndef __MINGW32__                   // no uids on Windows
    char buffer[CF_SMALLBUF];
    snprintf(buffer, CF_SMALLBUF, "%jd", (uintmax_t) lstatptr->st_uid);
    StringSetAdd(leafattrib, xstrdup(buffer));
#endif /* __MINGW32__ */

    gotOwner = GetOwnerName(path, lstatptr, ownerName, sizeof(ownerName));

    if (gotOwner)
    {
        StringSetAdd(leafattrib, xstrdup(ownerName));
    }
    else
    {
        StringSetAdd(leafattrib, xstrdup("none"));
    }

    for (rp = crit; rp != NULL; rp = rp->next)
    {
        if (EvalFileResult((char *) rp->item, leafattrib))
        {
            CfDebug(" - ? Select owner match\n");
            StringSetDestroy(leafattrib);
            return true;
        }

        if (gotOwner && (FullTextMatch((char *) rp->item, ownerName)))
        {
            CfDebug(" - ? Select owner match\n");
            StringSetDestroy(leafattrib);
            return true;
        }

#ifndef __MINGW32__
        if (FullTextMatch((char *) rp->item, buffer))
        {
            CfDebug(" - ? Select owner match\n");
            StringSetDestroy(leafattrib);
            return true;
        }
#endif /* !__MINGW32__ */
    }

    StringSetDestroy(leafattrib);
    return false;
}
开发者ID:jooooooon,项目名称:core,代码行数:54,代码来源:files_select.c

示例13: NotePerformance

static void NotePerformance(char *eventname, time_t t, double value)
{
    CF_DB *dbp;
    Event e, newe;
    double lastseen;
    int lsea = SECONDS_PER_WEEK;
    time_t now = time(NULL);

    CfDebug("PerformanceEvent(%s,%.1f s)\n", eventname, value);

    if (!OpenDB(&dbp, dbid_performance))
    {
        return;
    }

    if (ReadDB(dbp, eventname, &e, sizeof(e)))
    {
        lastseen = now - e.t;
        newe.t = t;

        newe.Q = QAverage(e.Q, value, 0.3);

        /* Have to kickstart variance computation, assume 1% to start  */

        if (newe.Q.var <= 0.0009)
        {
            newe.Q.var = newe.Q.expect / 100.0;
        }
    }
    else
    {
        lastseen = 0.0;
        newe.t = t;
        newe.Q.q = value;
        newe.Q.dq = 0;
        newe.Q.expect = value;
        newe.Q.var = 0.001;
    }

    if (lastseen > (double) lsea)
    {
        CfDebug("Performance record %s expired\n", eventname);
        DeleteDB(dbp, eventname);
    }
    else
    {
        CfOut(cf_verbose, "", "Performance(%s): time=%.4lf secs, av=%.4lf +/- %.4lf\n", eventname, value, newe.Q.expect,
              sqrt(newe.Q.var));
        WriteDB(dbp, eventname, &newe, sizeof(newe));
    }

    CloseDB(dbp);
}
开发者ID:pombredanne,项目名称:core,代码行数:53,代码来源:instrumentation.c

示例14: ArgTemplate

void ArgTemplate(FnCall *fp, const FnCallArg *argtemplate, Rlist *realargs)
{
    int argnum, i;
    Rlist *rp = fp->args;
    char id[CF_BUFSIZE], output[CF_BUFSIZE];
    const FnCallType *fn = FindFunction(fp->name);

    snprintf(id, CF_MAXVARSIZE, "built-in FnCall %s-arg", fp->name);

    for (argnum = 0; rp != NULL && argtemplate[argnum].pattern != NULL; argnum++)
    {
        if (rp->type != CF_FNCALL)
        {
            /* Nested functions will not match to lval so don't bother checking */
            CheckConstraintTypeMatch(id, (Rval) {rp->item, rp->type}, argtemplate[argnum].dtype, argtemplate[argnum].pattern, 1);
        }

        rp = rp->next;
    }

    if (argnum != RlistLen(realargs) && !fn->varargs)
    {
        snprintf(output, CF_BUFSIZE, "Argument template mismatch handling function %s(", fp->name);
        ReportError(output);
        ShowRlist(stderr, realargs);
        fprintf(stderr, ")\n");

        for (i = 0, rp = realargs; i < argnum; i++)
        {
            printf("  arg[%d] range %s\t", i, argtemplate[i].pattern);
            if (rp != NULL)
            {
                ShowRval(stdout, (Rval) {rp->item, rp->type});
                rp = rp->next;
            }
            else
            {
                printf(" ? ");
            }
            printf("\n");
        }

        FatalError("Bad arguments");
    }

    for (rp = realargs; rp != NULL; rp = rp->next)
    {
        CfDebug("finalarg: %s\n", (char *) rp->item);
    }

    CfDebug("End ArgTemplate\n");
}
开发者ID:fbettag,项目名称:core,代码行数:52,代码来源:args.c

示例15: GetProcessColumnNames

void GetProcessColumnNames(char *proc, char **names, int *start, int *end)
{
    char *sp, title[16];
    int col, offset = 0;

    for (col = 0; col < CF_PROCCOLS; col++)
    {
        start[col] = end[col] = -1;
        names[col] = NULL;
    }

    col = 0;

    for (sp = proc; *sp != '\0'; sp++)
    {
        offset = sp - proc;

        if (isspace((int) *sp))
        {
            if (start[col] != -1)
            {
                CfDebug("End of %s is %d\n", title, offset - 1);
                end[col++] = offset - 1;
                if (col > CF_PROCCOLS - 1)
                {
                    CfOut(cf_error, "", "Column overflow in process table");
                    break;
                }
            }
            continue;
        }

        else if (start[col] == -1)
        {
            start[col] = offset;
            sscanf(sp, "%15s", title);
            CfDebug("Start of %s is %d\n", title, offset);
            names[col] = xstrdup(title);
            CfDebug("Col[%d]=%s\n", col, names[col]);
        }
    }

    if (end[col] == -1)
    {
        CfDebug("End of %s is %d\n", title, offset);
        end[col] = offset;
    }
}
开发者ID:joegen,项目名称:sipx-externals,代码行数:48,代码来源:verify_processes.c


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