void printDSSMStructure(DSSM* dssm, int dashes) { printf("%d #=%d\n", dssm->id, dssm->nGraphs); for(int i = 0; i < dssm->nVertices; i++) { if (dssm->nextOnes[i] != NULL) { printrep(dashes, " "); printf("%d[%d]=", dssm->id, i); printDSSMStructure(dssm->nextOnes[i], dashes + 1); } } }
int main(int argc, char **argv) { int c; (void) setlocale(LC_ALL, ""); while ((c = getopt(argc, argv, "l:o:")) != EOF) switch (c) { case 'l': replin = optarg; break; case 'o': report = optarg; break; case '?': fprintf(stderr, "usage: %s [-l lineuse] " "[-o reboot]\n", argv[0]); exit(1); } if ((tbuf = (struct tbuf *)calloc(a_tsize, sizeof (struct tbuf))) == NULL) { fprintf(stderr, "acctcon: Cannot allocate memory\n"); exit(3); } /* * XXX - fixme - need a good way of getting the fd that getutxent would * use to access wtmpx, so we can convert this read of stdin to use * the APIs and remove the dependence on the existence of the file. */ while (fread(&wb, sizeof (wb), 1, stdin) == 1) { if (firstime == 0) firstime = wb.ut_xtime; if (valid()) loop(); else fixup(stderr); } wb.ut_name[0] = '\0'; strcpy(wb.ut_line, "acctcon"); wb.ut_type = ACCOUNTING; wb.ut_xtime = lastime; loop(); output(); if (report != NULL) printrep(); if (replin != NULL) printlin(); exit(exitcode); }
static void printobj_r(object *o, int parenttype, int tflag) { int iterating = 0; /* Put parenthesis around concatenations */ if (parenttype != T_GROUP && o->next) { iterating = 1; printf("( "); } while (o) { switch (o->type) { case T_ALTERNATION: if (tflag) printf("{ALTERNATION}"); if (o->next) printf("( "); printobj_r(o->u.alternation.left, o->type, tflag); printf(" / "); printobj_r(o->u.alternation.right, o->type, tflag); if (o->next) printf(" )"); break; case T_RULE: if (tflag) printf("{RULE}"); printrep(&o->u.e.repetition); if (o->u.e.e.rule.rule) { printf("%s", o->u.e.e.rule.rule->name); o->u.e.e.rule.rule->used = 1; } else printf("%s", o->u.e.e.rule.name); break; case T_GROUP: if (tflag) printf("{GROUP}"); if (o->u.e.repetition.lo == 0 && o->u.e.repetition.hi == 1) { if (!NOBRACKET(o->u.e.e.group)) printf("[ "); } else { printrep(&o->u.e.repetition); if (!NOPAREN(o->u.e.e.group)) printf("( "); } printobj_r(o->u.e.e.group, o->type, tflag); if (o->u.e.repetition.lo == 0 && o->u.e.repetition.hi == 1) { if (!NOBRACKET(o->u.e.e.group)) printf(" ]"); } else { if (!NOPAREN(o->u.e.e.group)) printf(" )"); } break; case T_TERMSTR: if (tflag) printf("{TERMSTR}"); printrep(&o->u.e.repetition); if (o->u.e.e.termstr.flags & F_CASESENSITIVE) { unsigned char *p = (unsigned char*)o->u.e.e.termstr.str; char sep; int allprintable = 1; printf("%%"); sep = 'x'; while (*p) { if (!isgraph(*p)) allprintable = 0; printf("%c%02X", sep, *p++); sep = '.'; } if (c2flag && allprintable) printf(" ; %s\n", o->u.e.e.termstr.str); } else { printf("%c%s%c", '"', o->u.e.e.termstr.str, '"'); } break; case T_TERMRANGE: if (tflag) printf("{TERMRANGE}"); printrep(&o->u.e.repetition); printf("%%x%02X-%02X", o->u.e.e.termrange.lo, o->u.e.e.termrange.hi); /* XXX isprint does not handle non-ASCII */ if (c2flag && isprint(o->u.e.e.termrange.lo) && isprint(o->u.e.e.termrange.hi)) { printf(" ; '%c'-'%c'\n", o->u.e.e.termrange.lo, o->u.e.e.termrange.hi); } break; case T_PROSE: if (tflag) printf("{PROSE}"); printrep(&o->u.e.repetition); printf("<%s>", o->u.e.e.proseval); break; default: printf("{UNKNOWN OBJECT TYPE %d}", o->type); break; } if (o->next) printf(" "); o = o->next; } if (iterating) printf(" )"); }