Quellcodebibliothek Statistik Leitseite products/sources/formale Sprachen/C/Linux/tools/perf/util/   (Open Source Betriebssystem Version 6.17.9©)  Datei vom 24.10.2025 mit Größe 1 kB image not shown  

Quelle  parse-sublevel-options.c   Sprache: C

 
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include <stdio.h>

#include "util/debug.h"
#include "util/parse-sublevel-options.h"

static int parse_one_sublevel_option(const char *str,
         struct sublevel_option *opts)
{
 struct sublevel_option *opt = opts;
 char *vstr, *s = strdup(str);
 int v = 1;

 if (!s) {
  pr_err("no memory\n");
  return -1;
 }

 vstr = strchr(s, '=');
 if (vstr)
  *vstr++ = 0;

 while (opt->name) {
  if (!strcmp(s, opt->name))
   break;
  opt++;
 }

 if (!opt->name) {
  pr_err("Unknown option name '%s'\n", s);
  free(s);
  return -1;
 }

 if (vstr)
  v = atoi(vstr);

 *opt->value_ptr = v;
 free(s);
 return 0;
}

/* parse options like --foo a=<n>,b,c... */
int perf_parse_sublevel_options(const char *str, struct sublevel_option *opts)
{
 char *s = strdup(str);
 char *p = NULL;
 int ret;

 if (!s) {
  pr_err("no memory\n");
  return -1;
 }

 p = strtok(s, ",");
 while (p) {
  ret = parse_one_sublevel_option(p, opts);
  if (ret) {
   free(s);
   return ret;
  }

  p = strtok(NULL, ",");
 }

 free(s);
 return 0;
}

Messung V0.5
C=95 H=90 G=92

¤ Dauer der Verarbeitung: 0.3 Sekunden  ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

Beweissystem der NASA

Beweissystem Isabelle

NIST Cobol Testsuite

Cephes Mathematical Library

Wiener Entwicklungsmethode

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.