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);
62 sf->fmts[j++] = ' ';
63 sf->fmts[j++] = 0x80 | i;
65 sf->fmts[j] = '\0';
70 statfoo_collect(struct statfoo *sf)
72 fprintf(stderr, "%s: don't know how to collect data\n", sf->name);
76 statfoo_update_tot(struct statfoo *sf)
78 fprintf(stderr, "%s: don't know how to update total data\n", sf->name);
82 statfoo_get(struct statfoo *sf, int s, char b[], size_t bs)
84 fprintf(stderr, "%s: don't know how to get stat #%u\n", sf->name, s);
89 statfoo_print_header(struct statfoo *sf, FILE *fd)
93 for (cp = sf->fmts; *cp != '\0'; cp++) {
95 const struct fmt *f = &sf->stats[*cp &~ 0x80];
104 statfoo_print_current(struct statfoo *sf, FILE *fd)
109 for (cp = sf->fmts; *cp != '\0'; cp++) {
111 const struct fmt *f = &sf->stats[*cp &~ 0x80];
112 if (sf->get_curstat(sf, *cp &~ 0x80, buf, sizeof(buf)))
121 statfoo_print_total(struct statfoo *sf, FILE *fd)
126 for (cp = sf->fmts; *cp != '\0'; cp++) {
128 const struct fmt *f = &sf->stats[*cp &~ 0x80];
129 if (sf->get_totstat(sf, *cp &~ 0x80, buf, sizeof(buf)))
138 statfoo_print_verbose(struct statfoo *sf, FILE *fd)
143 for (i = 0; i < sf->nstats; i++) {
144 if (sf->get_totstat(sf, i, s, sizeof(s)) && strcmp(s, "0"))
145 fprintf(fd, "%s %s\n", s, sf->stats[i].desc);
150 statfoo_print_fields(struct statfoo *sf, FILE *fd)
155 for (i = 0; i < sf->nstats; i++) {
156 w = strlen(sf->stats[i].name);
160 for (i = 0; i < sf->nstats; i++) {
161 const struct fmt *f = &sf->stats[i];
168 statfoo_init(struct statfoo *sf, const char *name, const struct fmt *stats, int nstats)
170 sf->name = name;
171 sf->stats = stats;
172 sf->nstats = nstats;
173 sf->setfmt = statfoo_setfmt;
174 sf->collect_cur = statfoo_collect;
175 sf->collect_tot = statfoo_collect;
176 sf->update_tot = statfoo_update_tot;
177 sf->get_curstat = statfoo_get;
178 sf->get_totstat = statfoo_get;
179 sf->print_header = statfoo_print_header;
180 sf->print_current = statfoo_print_current;
181 sf->print_total = statfoo_print_total;
182 sf->print_verbose = statfoo_print_verbose;
183 sf->print_fields = statfoo_print_fields;