Lines Matching defs:sf

38 statfoo_setfmt(struct statfoo *sf, const char *fmt0)
48 for (i = 0; i < sf->nstats; i++)
49 if (strcasecmp(tok, sf->stats[i].name) == 0)
51 if (i >= sf->nstats) {
53 "skipped\n", sf->name, tok);
56 if (j+3 > sizeof(sf->fmts)) {
58 "stopped at %s\n", sf->name, tok);
63 "stopped at %s\n", sf->name, tok);
67 sf->fmts[j++] = ' ';
68 sf->fmts[j++] = 0x80 | field;
69 sf->fields[field++] = i;
71 sf->fmts[j] = '\0';
76 statfoo_collect(struct statfoo *sf)
78 fprintf(stderr, "%s: don't know how to collect data\n", sf->name);
82 statfoo_update_tot(struct statfoo *sf)
84 fprintf(stderr, "%s: don't know how to update total data\n", sf->name);
88 statfoo_get(struct statfoo *sf, int s, char b[], size_t bs)
90 fprintf(stderr, "%s: don't know how to get stat #%u\n", sf->name, s);
95 statfoo_print_header(struct statfoo *sf, FILE *fd)
99 for (cp = sf->fmts; *cp != '\0'; cp++) {
101 int six = sf->fields[*cp &~ 0x80];
102 const struct fmt *f = &sf->stats[six];
111 statfoo_print_current(struct statfoo *sf, FILE *fd)
116 for (cp = sf->fmts; *cp != '\0'; cp++) {
118 int six = sf->fields[*cp &~ 0x80];
119 const struct fmt *f = &sf->stats[six];
120 if (sf->get_curstat(sf, six, buf, sizeof(buf)))
129 statfoo_print_total(struct statfoo *sf, FILE *fd)
134 for (cp = sf->fmts; *cp != '\0'; cp++) {
136 int six = sf->fields[*cp &~ 0x80];
137 const struct fmt *f = &sf->stats[six];
138 if (sf->get_totstat(sf, six, buf, sizeof(buf)))
147 statfoo_print_verbose(struct statfoo *sf, FILE *fd)
154 for (i = 0; i < sf->nstats; i++) {
155 f = &sf->stats[i];
159 for (i = 0; i < sf->nstats; i++) {
160 f = &sf->stats[i];
161 if (sf->get_totstat(sf, i, s, sizeof(s)) && strcmp(s, "0"))
167 statfoo_print_fields(struct statfoo *sf, FILE *fd)
172 for (i = 0; i < sf->nstats; i++) {
173 w = strlen(sf->stats[i].name);
177 for (i = 0; i < sf->nstats; i++) {
178 const struct fmt *f = &sf->stats[i];
185 statfoo_init(struct statfoo *sf, const char *name, const struct fmt *stats, int nstats)
187 sf->name = name;
188 sf->stats = stats;
189 sf->nstats = nstats;
190 sf->setfmt = statfoo_setfmt;
191 sf->collect_cur = statfoo_collect;
192 sf->collect_tot = statfoo_collect;
193 sf->update_tot = statfoo_update_tot;
194 sf->get_curstat = statfoo_get;
195 sf->get_totstat = statfoo_get;
196 sf->print_header = statfoo_print_header;
197 sf->print_current = statfoo_print_current;
198 sf->print_total = statfoo_print_total;
199 sf->print_verbose = statfoo_print_verbose;
200 sf->print_fields = statfoo_print_fields;