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

C++ rrd_set_error函数代码示例

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

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



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


示例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,代码来源:rrd_info.c


示例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,代码来源:rrd_client.c


示例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,代码来源:rrd_tune.c


示例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,代码来源:rrd_client.c


示例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,代码来源:rrd_graph_helper.c


示例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,代码来源:rrd_fetch_libdbi.c


示例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,代码来源:rrd_restore.c


示例9: rrd_parse_vdef

int
rrd_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,代码来源:rrd_graph_helper.c


示例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,代码来源:rrd_tune.c


示例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,代码来源:rrd_open.c


示例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,代码来源:rrd_last.c


示例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,代码来源:rrd_restore.c


示例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,代码来源:rrd_hw.c


示例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,代码来源:rrd_restore.c


示例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,代码来源:rrd_fetch_libdbi.c


示例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,代码来源:rrd_first.c


示例18: rrd_parse_find_gf

int
rrd_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,代码来源:rrd_graph_helper.c


示例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,代码来源:rrd_xport.c


示例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,代码来源:rrd_restore.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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