您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ rrd_set_error函数代码示例

51自学网 2021-06-02 11:56:41
  C++
这篇教程C++ rrd_set_error函数代码示例写得很实用,希望能帮到您。

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

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

示例1: return

/* get_path: Return a path name appropriate to be sent to the daemon. * * When talking to a local daemon (thru a UNIX socket), relative path names * are resolved to absolute path names to allow for transparent integration * into existing solutions (as requested by Tobi). Else, absolute path names * are not allowed, since path name translation is done by the server. * * One must hold `lock' when calling this function. */static const char *get_path (const char *path, char *resolved_path) /* {{{ */{  const char *ret = path;  int is_unix = 0;  if ((path == NULL) || (resolved_path == NULL) || (sd_path == NULL))    return (NULL);  if ((*sd_path == '/')      || (strncmp ("unix:", sd_path, strlen ("unix:")) == 0))    is_unix = 1;  if (is_unix)  {    ret = realpath(path, resolved_path);    if (ret == NULL)      rrd_set_error("realpath(%s): %s", path, rrd_strerror(errno));    return ret;  }  else  {    if (*path == '/') /* not absolute path */    {      rrd_set_error ("absolute path names not allowed when talking "          "to a remote daemon");      return NULL;    }  }  return path;} /* }}} char *get_path */
开发者ID:BOBYou,项目名称:ntopng,代码行数:39,


示例2: optparse_init

rrd_info_t *rrd_info(    int argc,    char **argv){    struct optparse_long longopts[] = {        {"daemon", 'd', OPTPARSE_REQUIRED},        {"noflush", 'F', OPTPARSE_NONE},        {0},    };    struct    optparse options;    int       opt;    rrd_info_t *info;    char *opt_daemon = NULL;    int status;    int flushfirst = 1;    optparse_init(&options, argc, argv);    while ((opt = optparse_long(&options, longopts, NULL)) != -1) {        switch (opt) {        case 'd':            if (opt_daemon != NULL)                free (opt_daemon);            opt_daemon = strdup(options.optarg);            if (opt_daemon == NULL)            {                rrd_set_error ("strdup failed.");                return NULL;            }            break;        case 'F':            flushfirst = 0;            break;        case '?':            rrd_set_error("%s", options.errmsg);            return NULL;        }    } /* while (opt != -1) */    if (options.argc - options.optind != 1) {        rrd_set_error ("Usage: rrdtool %s [--daemon |-d <addr> [--noflush|-F]] <file>",                options.argv[0]);        return NULL;    }    if (flushfirst) {        status = rrdc_flush_if_daemon(opt_daemon, options.argv[options.optind]);        if (status) return (NULL);    }    rrdc_connect (opt_daemon);    if (rrdc_is_connected (opt_daemon))        info = rrdc_info(options.argv[options.optind]);    else        info = rrd_info_r(options.argv[options.optind]);    if (opt_daemon) free(opt_daemon);    return (info);} /* rrd_info_t *rrd_info */
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:60,


示例3: request

static int request (const char *buffer, size_t buffer_size, /* {{{ */    rrdc_response_t **ret_response){  int status;  rrdc_response_t *res;  if (sh == NULL)    return (ENOTCONN);  status = (int) fwrite (buffer, buffer_size, /* nmemb = */ 1, sh);  if (status != 1)  {    close_connection ();    rrd_set_error("request: socket error (%d) while talking to rrdcached",                  status);    return (-1);  }  fflush (sh);  res = NULL;  status = response_read (&res);  if (status != 0)  {    if (status < 0)      rrd_set_error("request: internal error while talking to rrdcached");    return (status);  }  *ret_response = res;  return (0);} /* }}} int request */
开发者ID:BOBYou,项目名称:ntopng,代码行数:32,


示例4: set_deltaarg

int set_deltaarg(    rrd_t *rrd,    enum rra_par_en rra_par,    char *arg){    rrd_value_t param;    unsigned long i;    signed short rra_idx = -1;    param = atof(arg);    if (param < 0.1) {        rrd_set_error("Parameter specified is too small");        return -1;    }    /* does the appropriate RRA exist?  */    for (i = 0; i < rrd->stat_head->rra_cnt; ++i) {        if (cf_conv(rrd->rra_def[i].cf_nam) == CF_FAILURES) {            rra_idx = i;            break;        }    }    if (rra_idx == -1) {        rrd_set_error("Failures RRA does not exist in this RRD");        return -1;    }    /* set the value */    rrd->rra_def[rra_idx].par[rra_par].u_val = param;    return 0;}
开发者ID:Sweet-kid,项目名称:rrdtool-1.x,代码行数:30,


示例5: rrdc_flush_if_daemon

/* convenience function; if there is a daemon specified, or if we can * detect one from the environment, then flush the file.  Otherwise, no-op */int rrdc_flush_if_daemon (const char *opt_daemon, const char *filename) /* {{{ */{  int status = 0;  rrdc_connect(opt_daemon);  if (rrdc_is_connected(opt_daemon))  {    rrd_clear_error();    status = rrdc_flush (filename);    if (status != 0 && !rrd_test_error())    {      if (status > 0)      {        rrd_set_error("rrdc_flush (%s) failed: %s",                      filename, rrd_strerror(status));      }      else if (status < 0)      {        rrd_set_error("rrdc_flush (%s) failed with status %i.",                      filename, status);      }    }  } /* if (rrdc_is_connected(..)) */  return status;} /* }}} int rrdc_flush_if_daemon */
开发者ID:BOBYou,项目名称:ntopng,代码行数:31,


示例6: parse_textalign

int parse_textalign(enum gf_en gf,parsedargs_t* pa,image_desc_t *const im) {  /* get new graph that we fill */  graph_desc_t *gdp=newGraphDescription(im,gf,pa,0);   if (!gdp) { return 1;}  /* get align */  char* align=getKeyValueArgument("align",1,pa);  if (!align) align=getFirstUnusedArgument(1,pa)->value;  if (!align) { rrd_set_error("No alignment given"); return 1; }  /* parse align */  if (strcmp(align, "left") == 0) {    gdp->txtalign = TXA_LEFT;  } else if (strcmp(align, "right") == 0) {    gdp->txtalign = TXA_RIGHT;  } else if (strcmp(align, "justified") == 0) {    gdp->txtalign = TXA_JUSTIFIED;  } else if (strcmp(align, "center") == 0) {    gdp->txtalign = TXA_CENTER;  } else {    rrd_set_error("Unknown alignement type '%s'", align);    return 1;  }  /* debug output */  dprintf("=================================/n");  dprintf("TEXTALIGN : %s/n",pa->arg_orig);  dprintf("ALIGNMENT : %s (%u)/n",align,gdp->txtalign);    dprintf("=================================/n");  /* and return */  return 0;}
开发者ID:Sweet-kid,项目名称:rrdtool-1.x,代码行数:32,


示例7: _inline_unescape

static int _inline_unescape (char* string) {  char *src=string;  char *dst=string;  char c,h1,h2;  while((c= *src)) {    src++;    if (c == '%') {      if (*src == '%') { 	/* increase src pointer by 1 skiping second % */	src+=1;      } else {	/* try to calculate hex value from the next 2 values*/	h1=_hexcharhelper(*src);	if (h1 == (char)-1) {	  rrd_set_error("string escape error at: %s/n",string);	  return(1);	}	h2=_hexcharhelper(*(src+1));	if (h1 == (char)-1) {	  rrd_set_error("string escape error at: %s/n",string);	  return(1);	}	c=h2+(h1<<4);	/* increase src pointer by 2 skiping 2 chars */	src+=2;      }     }    *dst=c;    dst++;  }  *dst=0;  return 0;}
开发者ID:bloopletech,项目名称:rrdtool,代码行数:33,


示例8: rrd_restore

int rrd_restore(    int argc,    char **argv){    rrd_t    *rrd;    /* init rrd clean */    optind = 0;    opterr = 0;         /* initialize getopt */    while (42) {        int       opt;        int       option_index = 0;        static struct option long_options[] = {            {"range-check", no_argument, 0, 'r'},            {"force-overwrite", no_argument, 0, 'f'},            {0, 0, 0, 0}        };        opt = getopt_long(argc, argv, "rf", long_options, &option_index);        if (opt == EOF)            break;        switch (opt) {        case 'r':            opt_range_check = 1;            break;        case 'f':            opt_force_overwrite = 1;            break;        default:            rrd_set_error("usage rrdtool %s [--range-check|-r] "                          "[--force-overwrite/-f]  file.xml file.rrd",                          argv[0]);            return (-1);            break;        }    }                   /* while (42) */    if ((argc - optind) != 2) {        rrd_set_error("usage rrdtool %s [--range-check/-r] "                      "[--force-overwrite/-f] file.xml file.rrd", argv[0]);        return (-1);    }    rrd = parse_file(argv[optind]);    if (rrd == NULL)        return (-1);        if (write_file(argv[optind + 1], rrd) != 0) {        local_rrd_free(rrd);        return (-1);    }    local_rrd_free(rrd);    return (0);}                       /* int rrd_restore */
开发者ID:badphart,项目名称:rrdtool-1.x,代码行数:60,


示例9: rrd_parse_vdef

intrrd_parse_vdef(char *line, unsigned int *eaten, graph_desc_t *gdp, image_desc_t *im) {    char tmpstr[MAX_VNAME_LEN+1];	/* vname/0 */    int i=0;    dprintf("- parsing '%s'/n",&line[*eaten]);    if (rrd_parse_vname(line,eaten,gdp,im)) return 1;    sscanf(&line[*eaten], DEF_NAM_FMT ",%n", tmpstr,&i);    if (!i) {	rrd_set_error("Cannot parse line '%s'",line);	return 1;    }    if ((gdp->vidx=find_var(im,tmpstr))<0) {	rrd_set_error("Not a valid vname: %s in line %s",tmpstr,line);	return 1;    }    if (   im->gdes[gdp->vidx].gf != GF_DEF	&& im->gdes[gdp->vidx].gf != GF_CDEF) {	rrd_set_error("variable '%s' not DEF nor "			"CDEF in VDEF '%s'", tmpstr,gdp->vname);	return 1;    }    dprintf("- found vname: '%s' vidx %li/n",tmpstr,gdp->vidx);    (*eaten)+=i;    dprintf("- calling vdef_parse with param '%s'/n",&line[*eaten]);    vdef_parse(gdp,&line[*eaten]);    while (line[*eaten]!='/0'&&line[*eaten]!=':')	(*eaten)++;    return 0;}
开发者ID:OPSF,项目名称:uClinux,代码行数:33,


示例10: set_hwsmootharg

int set_hwsmootharg(    rrd_t *rrd,    enum cf_en cf,    enum rra_par_en rra_par,    char *arg){    double    param;    unsigned long i;    signed short rra_idx = -1;    /* read the value */    param = atof(arg);    /* in order to avoid smoothing of SEASONAL or DEVSEASONAL, we need to      * the 0.0 value*/    if (param < 0.0 || param > 1.0) {        rrd_set_error("Holt-Winters parameter must be between 0 and 1");        return -1;    }    /* does the appropriate RRA exist?  */    for (i = 0; i < rrd->stat_head->rra_cnt; ++i) {        if (cf_conv(rrd->rra_def[i].cf_nam) == cf) {            rra_idx = i;            break;        }    }    if (rra_idx == -1) {        rrd_set_error("Holt-Winters RRA does not exist in this RRD");        return -1;    }    /* set the value */    rrd->rra_def[rra_idx].par[rra_par].u_val = param;    return 0;}
开发者ID:Sweet-kid,项目名称:rrdtool-1.x,代码行数:34,


示例11: rrd_close

int rrd_close(    rrd_file_t *rrd_file){    rrd_simple_file_t *rrd_simple_file;    rrd_simple_file = (rrd_simple_file_t *)rrd_file->pvt;    int       ret;#ifdef HAVE_MMAP    ret = munmap(rrd_simple_file->file_start, rrd_file->file_len);    if (ret != 0)        rrd_set_error("munmap rrd_file: %s", rrd_strerror(errno));#endif#ifdef HAVE_LIBRADOS    if (rrd_file->rados)        ret = rrd_rados_close(rrd_file->rados);    else#endif    ret = close(rrd_simple_file->fd);    if (ret != 0)        rrd_set_error("closing file: %s", rrd_strerror(errno));    free(rrd_file->pvt);    free(rrd_file);    rrd_file = NULL;    return ret;}
开发者ID:JoakimSoderberg,项目名称:rrdtool-1.x,代码行数:26,


示例12: rrd_last

time_t rrd_last(    int argc,    char **argv){    char *opt_daemon = NULL;    time_t lastupdate;    optind = 0;    opterr = 0;         /* initialize getopt */    while (42) {        int       opt;        int       option_index = 0;        static struct option long_options[] = {            {"daemon", required_argument, 0, 'd'},            {0, 0, 0, 0}        };        opt = getopt_long(argc, argv, "d:", long_options, &option_index);        if (opt == EOF)            break;        switch (opt) {        case 'd':            if (opt_daemon != NULL)                    free (opt_daemon);            opt_daemon = strdup (optarg);            if (opt_daemon == NULL)            {                rrd_set_error ("strdup failed.");                return (-1);            }            break;        default:            rrd_set_error ("Usage: rrdtool %s [--daemon <addr>] <file>",                    argv[0]);            return (-1);            break;        }    }                   /* while (42) */    if ((argc - optind) != 1) {        rrd_set_error ("Usage: rrdtool %s [--daemon <addr>] <file>",                argv[0]);        return (-1);    }    rrdc_connect (opt_daemon);    if (rrdc_is_connected (opt_daemon))        lastupdate = rrdc_last (argv[optind]);    else        lastupdate = rrd_last_r(argv[optind]);    if (opt_daemon) free(opt_daemon);    return (lastupdate);}
开发者ID:JoakimSoderberg,项目名称:rrdtool-1.x,代码行数:59,


示例13: write_file

int write_file(    const char *file_name,    rrd_t *rrd){    FILE     *fh;#ifdef HAVE_LIBRADOS    if (strncmp("ceph//", file_name, 6) == 0) {      return rrd_rados_create(file_name + 6, rrd);    }#endif    if (strcmp("-", file_name) == 0)        fh = stdout;    else {        int       fd_flags = O_WRONLY | O_CREAT;        int       fd;#if defined(_WIN32) && !defined(__CYGWIN__) && !defined(__CYGWIN32__)        fd_flags |= O_BINARY;#endif        if (opt_force_overwrite == 0)            fd_flags |= O_EXCL;        fd = open(file_name, fd_flags, 0666);        if (fd == -1) {            rrd_set_error("creating '%s': %s", file_name,                          rrd_strerror(errno));            return (-1);        }        fh = fdopen(fd, "wb");        if (fh == NULL) {            rrd_set_error("fdopen failed: %s", rrd_strerror(errno));            close(fd);            return (-1);        }    }    int rc = write_fh(fh, rrd);    /* lets see if we had an error */    if (ferror(fh)) {        rrd_set_error("a file error occurred while creating '%s': %s", file_name,            rrd_strerror(errno));        fclose(fh);        if (strcmp("-", file_name) != 0)            unlink(file_name);        return (-1);    }    fclose(fh);        return rc;}
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:56,


示例14: lookup_seasonal

int lookup_seasonal(    rrd_t *rrd,    unsigned long rra_idx,    unsigned long rra_start,    rrd_file_t *rrd_file,    unsigned long offset,    rrd_value_t **seasonal_coef){    unsigned long pos_tmp;    /* rra_ptr[].cur_row points to the rra row to be written; this function     * reads cur_row + offset */    unsigned long row_idx = rrd->rra_ptr[rra_idx].cur_row + offset;    /* handle wrap around */    if (row_idx >= rrd->rra_def[rra_idx].row_cnt)        row_idx = row_idx % (rrd->rra_def[rra_idx].row_cnt);    /* rra_start points to the appropriate rra block in the file */    /* compute the pointer to the appropriate location in the file */    pos_tmp =        rra_start +        (row_idx) * (rrd->stat_head->ds_cnt) * sizeof(rrd_value_t);    /* allocate memory if need be */    if (*seasonal_coef == NULL)        *seasonal_coef =            (rrd_value_t *) malloc((rrd->stat_head->ds_cnt) *                                   sizeof(rrd_value_t));    if (*seasonal_coef == NULL) {        rrd_set_error("memory allocation failure: seasonal coef");        return -1;    }    if (!rrd_seek(rrd_file, pos_tmp, SEEK_SET)) {        if (rrd_read            (rrd_file, *seasonal_coef,             sizeof(rrd_value_t) * rrd->stat_head->ds_cnt)            == (ssize_t) (sizeof(rrd_value_t) * rrd->stat_head->ds_cnt)) {            /* success! */            /* we can safely ignore the rule requiring a seek operation between read             * and write, because this read moves the file pointer to somewhere             * in the file other than the next write location.             * */            return 0;        } else {            rrd_set_error("read operation failed in lookup_seasonal(): %lu/n",                          pos_tmp);        }    } else {        rrd_set_error("seek operation failed in lookup_seasonal(): %lu/n",                      pos_tmp);    }    return -1;}
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:56,


示例15: get_xml_text

static xmlChar* get_xml_text (    xmlTextReaderPtr reader    ){    while(xmlTextReaderRead(reader)){        xmlChar  *ret;            xmlChar  *text;        xmlChar  *begin_ptr;        xmlChar  *end_ptr;        int type;                type = xmlTextReaderNodeType(reader);        if (type == XML_READER_TYPE_ELEMENT){            xmlChar *name;            name = xmlTextReaderName(reader);            rrd_set_error("line %d: expected a value but found a <%s> element",                          xmlTextReaderGetParserLineNumber(reader),                          name);            xmlFree(name);                        return NULL;                    }        /* trying to read text from <a></a> we end up here           lets return an empty string instead. This is a tad optimistic           since we do not check if it is actually </a> and not </b>           we got, but first we do not know if we expect </a> and second           we the whole implementation is on the optimistic side. */        if (type == XML_READER_TYPE_END_ELEMENT){            return  xmlStrdup(BAD_CAST "");        }                /* skip all other non-text */        if (type != XML_READER_TYPE_TEXT)            continue;                text = xmlTextReaderValue(reader);        begin_ptr = text;        while ((begin_ptr[0] != 0) && (isspace(begin_ptr[0])))            begin_ptr++;        if (begin_ptr[0] == 0) {            xmlFree(text);            return xmlStrdup(BAD_CAST "");        }                end_ptr = begin_ptr;        while ((end_ptr[0] != 0) && (!isspace(end_ptr[0])))            end_ptr++;        end_ptr[0] = 0;                ret = xmlStrdup(begin_ptr);        xmlFree(text);        return ret;    }    rrd_set_error("file ended while looking for text");    return NULL;}  /* get_xml_text */ 
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:55,


示例16: _sql_setparam

static int _sql_setparam(struct sql_table_helper* th,char* key, char* value) {    char* dbi_errstr=NULL;    dbi_driver driver;    /* if not connected */    if (! th->conn) {        /* initialize some stuff */        th->table_next=th->table_start;        th->result=NULL;        th->connected=0;        /* initialize db */        if (getenv("RRDDEBUGSQL")) {            fprintf(stderr,"RRDDEBUGSQL: %li: initialize libDBI/n",time(NULL) );        }        dbi_initialize(NULL);        /* load the driver */        driver=dbi_driver_open(th->dbdriver);        if (! driver) {            rrd_set_error( "libdbi - no such driver: %s (possibly a dynamic link problem of the driver being linked without -ldbi)",th->dbdriver);            return -1;        }        /* and connect to driver */        th->conn=dbi_conn_open(driver);        /* and handle errors */        if (! th->conn) {            rrd_set_error( "libdbi - could not open connection to driver %s",th->dbdriver);            dbi_shutdown();            return -1;        }    }    if (th->connected) {        rrd_set_error( "we are already connected - can not set parameter %s=%s",key,value);        _sql_close(th);        return -1;    }    if (getenv("RRDDEBUGSQL")) {        fprintf(stderr,"RRDDEBUGSQL: %li: setting option %s to %s/n",time(NULL),key,value );    }    if (strcmp(key, "port") == 0) {        if (dbi_conn_set_option_numeric(th->conn,key,atoi(value))) {            dbi_conn_error(th->conn,(const char**)&dbi_errstr);            rrd_set_error( "libdbi: problems setting %s to %d - %s",key,value,dbi_errstr);            _sql_close(th);            return -1;        }    } else {        if (dbi_conn_set_option(th->conn,key,value)) {            dbi_conn_error(th->conn,(const char**)&dbi_errstr);            rrd_set_error( "libdbi: problems setting %s to %s - %s",key,value,dbi_errstr);            _sql_close(th);            return -1;        }    }    return 0;}
开发者ID:oetiker,项目名称:rrdtool-1.x,代码行数:54,


示例17: rrd_first

time_t rrd_first(    int argc,    char **argv){    struct optparse_long longopts[] = {        {"rraindex", 129, OPTPARSE_REQUIRED},        {"daemon", 'd', OPTPARSE_REQUIRED},        {0},    };    struct    optparse options;    int       opt;    int       target_rraindex = 0;    char     *endptr;    char *opt_daemon = NULL;    optparse_init(&options, argc, argv);    while ((opt = optparse_long(&options, longopts, NULL)) != -1) {        switch (opt) {        case 129:            target_rraindex = strtol(options.optarg, &endptr, 0);            if (target_rraindex < 0) {                rrd_set_error("invalid rraindex number");                return (-1);            }            break;        case 'd':            if (opt_daemon != NULL)                    free (opt_daemon);            opt_daemon = strdup(options.optarg);            if (opt_daemon == NULL)            {                rrd_set_error ("strdup failed.");                return -1;            }            break;        case '?':            rrd_set_error("%s", options.errmsg);            return -1;        }    }    if (options.optind >= options.argc) {        rrd_set_error("usage rrdtool %s [--rraindex number] [--daemon|-d <addr>] file.rrd",                      options.argv[0]);        return -1;    }    rrdc_connect (opt_daemon);    if (rrdc_is_connected (opt_daemon)) {      return rrdc_first(options.argv[options.optind], target_rraindex);    } else {      return rrd_first_r(options.argv[options.optind], target_rraindex);	}}
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:54,


示例18: rrd_parse_find_gf

intrrd_parse_find_gf(char *line, unsigned int *eaten, graph_desc_t *gdp) {    char funcname[11],c1=0;    int i=0;    /* start an argument with DEBUG to be able to see how it is parsed */    sscanf(&line[*eaten], "DEBUG%n", &i);    if (i) {	gdp->debug=1;	(*eaten)+=i;	i=0;	dprintf("Scanning line '%s'/n",&line[*eaten]);    }    sscanf(&line[*eaten], "%10[A-Z]%n%c", funcname, &i, &c1);    if (!i) {	rrd_set_error("Could not make sense out of '%s'",line);	return 1;    }    if ((int)(gdp->gf=gf_conv(funcname)) == -1) {	rrd_set_error("'%s' is not a valid function name", funcname);	return 1;    } else {	dprintf("- found function name '%s'/n",funcname);    }    if (gdp->gf == GF_LINE) {	if (c1 == ':') {	    gdp->linewidth=1;	    dprintf("- - using default width of 1/n");	} else {	    double width;	    (*eaten)+=i;	    if (sscanf(&line[*eaten],"%lf%n:",&width,&i)) {		if (width < 0 || isnan(width) || isinf(width) ) {		    rrd_set_error("LINE width is %lf. It must be finite and >= 0 though",width);		    return 1;		}		gdp->linewidth=width;		dprintf("- - using width %f/n",width);	    } else {		rrd_set_error("LINE width: %s",line);		return 1;	    }	}    } else {	if (c1 != ':') {	    rrd_set_error("Malformed %s command: %s",funcname,line);	    return 1;	}    }    (*eaten)+=++i;    return 0;}
开发者ID:OPSF,项目名称:uClinux,代码行数:53,


示例19: addToBuffer

int addToBuffer(stringbuffer_t * sb,char* data,size_t len) {    /* if len <= 0  we assume a string and calculate the length ourself */    if (len<=0) {        len=strlen(data);    }    /* if we have got a file, then take the shortcut */    if (sb->file) {        sb->len+=len;        fwrite(data,len,1,sb->file);        return 0;    }    /* if buffer is 0, then initialize */    if (! sb->data) {        /* make buffer a multiple of 8192 */        sb->allocated+=8192;        sb->allocated-=(sb->allocated%8192);        /* and allocate it */        sb->data = (unsigned char *) malloc(sb->allocated);        if (! sb->data) {            rrd_set_error("malloc issue");            return 1;        }        /* and initialize the buffer */        sb->len=0;        sb->data[0]=0;    }    /* and figure out if we need to extend the buffer */    if (sb->len+len+1>=sb->allocated) {        /* add so many pages until we have a buffer big enough */        while(sb->len+len+1>=sb->allocated) {            sb->allocated+=8192;        }        /* try to resize it */        unsigned char* resized=(unsigned char*)realloc(sb->data,sb->allocated);        if (resized) {            sb->data=resized;        } else {            free(sb->data);            sb->data=NULL;            sb->allocated=0;            rrd_set_error("realloc issue");            return -1;        }    }    /* and finally add to the buffer */    memcpy(sb->data+sb->len,data,len);    sb->len+=len;    /* and 0 terminate it */    sb->data[sb->len]=0;    /* and return */    return 0;}
开发者ID:hidebay,项目名称:rrdtool-1.x,代码行数:52,


示例20: rrd_restore

int rrd_restore(    int argc,    char **argv){    struct optparse_long longopts[] = {        {"range-check", 'r', OPTPARSE_NONE},        {"force-overwrite", 'f', OPTPARSE_NONE},        {0},    };    struct    optparse options;    int       opt;    rrd_t    *rrd;    optparse_init(&options, argc, argv);    while ((opt = optparse_long(&options, longopts, NULL)) != -1) {        switch (opt) {        case 'r':            opt_range_check = 1;            break;        case 'f':            opt_force_overwrite = 1;            break;        case '?':            rrd_set_error("%s", options.errmsg);            return -1;        }    } /* while (opt != -1) */    if (options.argc - options.optind != 2) {        rrd_set_error("usage rrdtool %s [--range-check|-r] "                      "[--force-overwrite|-f] file.xml file.rrd",                      options.argv[0]);        return -1;    }    rrd = parse_file(options.argv[options.optind]);    if (rrd == NULL)        return (-1);        if (write_file(options.argv[options.optind + 1], rrd) != 0) {        local_rrd_free(rrd);        return (-1);    }    local_rrd_free(rrd);    return (0);}                       /* int rrd_restore */
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:51,


示例21: printstrftime

char* printstrftime(long argc, const char **args){	struct	rrd_time_value start_tv, end_tv;	char    *parsetime_error = NULL;	char	formatted[MAX_STRFTIME_SIZE];	struct tm *the_tm;	time_t	start_tmp, end_tmp;	/* Make sure that we were given the right number of args */	if( argc != 4) {		rrd_set_error( "wrong number of args %d", argc);		return stralloc("");	}	/* Init start and end time */	parsetime("end-24h", &start_tv);	parsetime("now", &end_tv);	/* Parse the start and end times we were given */	if( (parsetime_error = parsetime( args[1], &start_tv))) {		rrd_set_error( "start time: %s", parsetime_error);		return stralloc("");	}	if( (parsetime_error = parsetime( args[2], &end_tv))) {		rrd_set_error( "end time: %s", parsetime_error);		return stralloc("");	}	if( proc_start_end( &start_tv, &end_tv, &start_tmp, &end_tmp) == -1) {		return stralloc("");	}	/* Do we do the start or end */	if( strcasecmp( args[0], "START") == 0) {		the_tm = localtime( &start_tmp);	}	else if( strcasecmp( args[0], "END") == 0) {		the_tm = localtime( &end_tmp);	}	else {		rrd_set_error( "start/end not found in '%s'", args[0]);		return stralloc("");	}	/* now format it */	if( strftime( formatted, MAX_STRFTIME_SIZE, args[3], the_tm)) {		return( stralloc( formatted));	}	else {		rrd_set_error( "strftime failed");		return stralloc("");	}}
开发者ID:nickmbailey,项目名称:python26-rrdtool-rpm,代码行数:51,


示例22: calloc

rpnp_t   *rpn_expand(    rpn_cdefds_t *rpnc){    short     i;    rpnp_t   *rpnp;    /* DS_CDEF_MAX_RPN_NODES is small, so at the expense of some wasted     * memory we avoid any reallocs */    rpnp = (rpnp_t *) calloc(DS_CDEF_MAX_RPN_NODES, sizeof(rpnp_t));    if (rpnp == NULL) {        rrd_set_error("failed allocating rpnp array");        return NULL;    }    for (i = 0; rpnc[i].op != OP_END; ++i) {        rpnp[i].op = (enum op_en)rpnc[i].op;	rpnp[i].extra = NULL;	rpnp[i].free_extra = NULL;        if (rpnp[i].op == OP_NUMBER) {            rpnp[i].val = (double) rpnc[i].val;        } else if (rpnp[i].op == OP_VARIABLE || rpnp[i].op == OP_PREV_OTHER) {            rpnp[i].ptr = (long) rpnc[i].val;        }    }    /* terminate the sequence */    rpnp[i].op = OP_END;    return rpnp;}
开发者ID:Brainiarc7,项目名称:rrdtool-1.x,代码行数:27,


示例23: get_xml_time_t

static int get_xml_time_t(    xmlTextReaderPtr reader,    time_t *value){        xmlChar *text;    time_t temp;        if ((text = get_xml_text(reader)) != NULL){        errno = 0;        #if SIZEOF_TIME_T == 4        temp = strtol((char *)text,NULL, 0);#elif SIZEOF_TIME_T == 8        temp = strtoll((char *)text,NULL, 0);        #else#error "Don't know how to deal with TIME_T other than 4 or 8 bytes"#endif            if (errno>0){            rrd_set_error("ling %d: get_xml_time_t from '%s' %s",                          xmlTextReaderGetParserLineNumber(reader),                          text,rrd_strerror(errno));            xmlFree(text);                        return -1;        }        xmlFree(text);                    *value = temp;        return 0;    }    return -1;} /* get_xml_time_t */
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:28,


示例24: expect_element_end

static int expect_element_end (    xmlTextReaderPtr reader,    char *exp_name){    xmlChar *name;    /* maybe we are already on the end element ... lets see */    if (xmlTextReaderNodeType(reader) == XML_READER_TYPE_END_ELEMENT){         xmlChar *temp;         xmlChar *temp2;                     temp = xmlTextReaderName(reader);         temp2 = (xmlChar*)sprintf_alloc("/%s", temp);         name = xmlStrdup(temp2);         xmlFree(temp);         free(temp2);                } else {              name = get_xml_element(reader);    }    if (name == NULL)        return -1;        if (xmlStrcasecmp(name+1,(xmlChar *)exp_name) != 0 || name[0] != '/'){        rrd_set_error("line %d: expected </%s> end element but found <%s>",                      xmlTextReaderGetParserLineNumber(reader),exp_name,name);        xmlFree(name);                    return -1;                }    xmlFree(name);        return 0;    } /* expect_element_end */
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:29,


示例25: rrd_dump_opt_r

int rrd_dump_opt_r(    const char *filename,    char *outname,    int opt_noheader){    FILE     *out_file;    int       res;    out_file = NULL;    if (outname) {        if (!(out_file = fopen(outname, "w"))) {            return (-1);        }    } else {        out_file = stdout;    }    res = rrd_dump_cb_r(filename, opt_noheader, rrd_dump_opt_cb_fileout, (void *)out_file);    if (fflush(out_file) != 0) {        rrd_set_error("error flushing output: %s", rrd_strerror(errno));        res = -1;    }    if (out_file != stdout) {        fclose(out_file);        if (res != 0)            unlink(outname);    }    return res;}
开发者ID:nirgal,项目名称:rrdtool-1.x,代码行数:31,


示例26: va_start

/* allocate memory for string */char     *sprintf_alloc(    char *fmt,    ...){    char     *str = NULL;    va_list   argp;#ifdef HAVE_VASPRINTF    va_start( argp, fmt );    if (vasprintf( &str, fmt, argp ) == -1){        va_end(argp);        rrd_set_error ("vasprintf failed.");        return(NULL);    }#else    int       maxlen = 1024 + strlen(fmt);    str = (char*)malloc(sizeof(char) * (maxlen + 1));    if (str != NULL) {        va_start(argp, fmt);#ifdef HAVE_VSNPRINTF        vsnprintf(str, maxlen, fmt, argp);#else        vsprintf(str, fmt, argp);#endif    }#endif /* HAVE_VASPRINTF */    va_end(argp);    return str;}
开发者ID:DigiTempReader,项目名称:rrdtool-1.x,代码行数:29,


示例27: rrd_write

ssize_t rrd_write(    rrd_file_t *rrd_file,    const void *buf,    size_t count){    rrd_simple_file_t *rrd_simple_file = (rrd_simple_file_t *)rrd_file->pvt;#ifdef HAVE_MMAP    size_t old_size = rrd_file->file_len;    if (count == 0)        return 0;    if (buf == NULL)        return -1;      /* EINVAL */        if((rrd_file->pos + count) > old_size)    {        rrd_set_error("attempting to write beyond end of file (%ld + %ld > %ld)",rrd_file->pos, count, old_size);        return -1;    }    memcpy(rrd_simple_file->file_start + rrd_file->pos, buf, count);    rrd_file->pos += count;    return count;       /* mimmic write() semantics */#else    ssize_t   _sz = write(rrd_simple_file->fd, buf, count);    if (_sz > 0)        rrd_file->pos += _sz;    return _sz;#endif}
开发者ID:baiyunping333,项目名称:rrdtool-1.x,代码行数:29,


示例28: rrd_seek

off_t rrd_seek(    rrd_file_t *rrd_file,    off_t off,    int whence){    off_t     ret = 0;#ifndef HAVE_MMAP    rrd_simple_file_t *rrd_simple_file;    rrd_simple_file = (rrd_simple_file_t *)rrd_file->pvt;#endif #ifdef HAVE_MMAP    if (whence == SEEK_SET)        rrd_file->pos = off;    else if (whence == SEEK_CUR)        rrd_file->pos += off;    else if (whence == SEEK_END)        rrd_file->pos = rrd_file->file_len + off;#else    ret = lseek(rrd_simple_file->fd, off, whence);    if (ret < 0)        rrd_set_error("lseek: %s", rrd_strerror(errno));    rrd_file->pos = ret;#endif    /* mimic fseek, which returns 0 upon success */    return ret < 0;     /*XXX: or just ret to mimic lseek */}
开发者ID:baiyunping333,项目名称:rrdtool-1.x,代码行数:27,



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


C++ rs函数代码示例
C++ rrd_get_error函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。