static void print_sys_drive(struct conf_config *conf, int drvno) { struct mlx_sys_drv *drv = &conf->cc_cfg.cc_sys_drives[drvno]; int i; printf("drive%02d ", drvno); switch(drv->sd_raidlevel & 0xf) { case MLX_SYS_DRV_RAID0: printf("RAID0"); break; case MLX_SYS_DRV_RAID1: printf("RAID1"); break; case MLX_SYS_DRV_RAID3: printf("RAID3"); break; case MLX_SYS_DRV_RAID5: printf("RAID5"); break; case MLX_SYS_DRV_RAID6: printf("RAID6"); break; case MLX_SYS_DRV_JBOD: printf("JBOD"); break; default: printf("RAID?"); } printf(" write%s\n", drv->sd_raidlevel & MLX_SYS_DRV_WRITEBACK ? "back" : "through"); for (i = 0; i < drv->sd_valid_spans; i++) { printf(" span%d ", i); print_span(&drv->sd_span[i], drv->sd_valid_arms); } }
static void print_mdoc(const struct roff_node *n, int indent) { const char *p, *t; int i, j; size_t argc; struct mdoc_argv *argv; if (n == NULL) return; argv = NULL; argc = 0; t = p = NULL; switch (n->type) { case ROFFT_ROOT: t = "root"; break; case ROFFT_BLOCK: t = "block"; break; case ROFFT_HEAD: t = "head"; break; case ROFFT_BODY: if (n->end) t = "body-end"; else t = "body"; break; case ROFFT_TAIL: t = "tail"; break; case ROFFT_ELEM: t = "elem"; break; case ROFFT_TEXT: t = "text"; break; case ROFFT_TBL: break; case ROFFT_EQN: t = "eqn"; break; default: abort(); } switch (n->type) { case ROFFT_TEXT: p = n->string; break; case ROFFT_BODY: p = mdoc_macronames[n->tok]; break; case ROFFT_HEAD: p = mdoc_macronames[n->tok]; break; case ROFFT_TAIL: p = mdoc_macronames[n->tok]; break; case ROFFT_ELEM: p = mdoc_macronames[n->tok]; if (n->args) { argv = n->args->argv; argc = n->args->argc; } break; case ROFFT_BLOCK: p = mdoc_macronames[n->tok]; if (n->args) { argv = n->args->argv; argc = n->args->argc; } break; case ROFFT_TBL: break; case ROFFT_EQN: p = "EQ"; break; case ROFFT_ROOT: p = "root"; break; default: abort(); } if (n->span) { assert(NULL == p && NULL == t); print_span(n->span, indent); } else { for (i = 0; i < indent; i++) putchar(' '); printf("%s (%s)", p, t); for (i = 0; i < (int)argc; i++) { printf(" -%s", mdoc_argnames[argv[i].arg]); if (argv[i].sz > 0) printf(" ["); for (j = 0; j < (int)argv[i].sz; j++) printf(" [%s]", argv[i].value[j]); if (argv[i].sz > 0) printf(" ]"); } putchar(' '); if (NODE_DELIMO & n->flags) putchar('('); if (NODE_LINE & n->flags) putchar('*'); printf("%d:%d", n->line, n->pos + 1); if (NODE_DELIMC & n->flags) putchar(')'); if (NODE_EOS & n->flags) putchar('.'); if (NODE_BROKEN & n->flags) printf(" BROKEN"); if (NODE_NOSRC & n->flags) printf(" NOSRC"); if (NODE_NOPRT & n->flags) printf(" NOPRT"); putchar('\n'); } if (n->eqn) print_box(n->eqn->root->first, indent + 4); if (n->child) print_mdoc(n->child, indent + (n->type == ROFFT_BLOCK ? 2 : 4)); if (n->next) print_mdoc(n->next, indent); }
static void print_man(const struct roff_node *n, int indent) { const char *p, *t; int i; if (n == NULL) return; t = p = NULL; switch (n->type) { case ROFFT_ROOT: t = "root"; break; case ROFFT_ELEM: t = "elem"; break; case ROFFT_TEXT: t = "text"; break; case ROFFT_BLOCK: t = "block"; break; case ROFFT_HEAD: t = "head"; break; case ROFFT_BODY: t = "body"; break; case ROFFT_TBL: break; case ROFFT_EQN: t = "eqn"; break; default: abort(); } switch (n->type) { case ROFFT_TEXT: p = n->string; break; case ROFFT_ELEM: case ROFFT_BLOCK: case ROFFT_HEAD: case ROFFT_BODY: p = man_macronames[n->tok]; break; case ROFFT_ROOT: p = "root"; break; case ROFFT_TBL: break; case ROFFT_EQN: p = "EQ"; break; default: abort(); } if (n->span) { assert(NULL == p && NULL == t); print_span(n->span, indent); } else { for (i = 0; i < indent; i++) putchar(' '); printf("%s (%s) ", p, t); if (NODE_LINE & n->flags) putchar('*'); printf("%d:%d", n->line, n->pos + 1); if (NODE_EOS & n->flags) putchar('.'); putchar('\n'); } if (n->eqn) print_box(n->eqn->root->first, indent + 4); if (n->child) print_man(n->child, indent + (n->type == ROFFT_BLOCK ? 2 : 4)); if (n->next) print_man(n->next, indent); }
static void print_mdoc(const struct mdoc_node *n, int indent) { const char *p, *t; int i, j; size_t argc, sz; char **params; struct mdoc_argv *argv; argv = NULL; argc = sz = 0; params = NULL; t = p = NULL; switch (n->type) { case (MDOC_ROOT): t = "root"; break; case (MDOC_BLOCK): t = "block"; break; case (MDOC_HEAD): t = "block-head"; break; case (MDOC_BODY): if (n->end) t = "body-end"; else t = "block-body"; break; case (MDOC_TAIL): t = "block-tail"; break; case (MDOC_ELEM): t = "elem"; break; case (MDOC_TEXT): t = "text"; break; case (MDOC_TBL): /* FALLTHROUGH */ case (MDOC_EQN): break; default: abort(); /* NOTREACHED */ } switch (n->type) { case (MDOC_TEXT): p = n->string; break; case (MDOC_BODY): p = mdoc_macronames[n->tok]; break; case (MDOC_HEAD): p = mdoc_macronames[n->tok]; break; case (MDOC_TAIL): p = mdoc_macronames[n->tok]; break; case (MDOC_ELEM): p = mdoc_macronames[n->tok]; if (n->args) { argv = n->args->argv; argc = n->args->argc; } break; case (MDOC_BLOCK): p = mdoc_macronames[n->tok]; if (n->args) { argv = n->args->argv; argc = n->args->argc; } break; case (MDOC_TBL): /* FALLTHROUGH */ case (MDOC_EQN): break; case (MDOC_ROOT): p = "root"; break; default: abort(); /* NOTREACHED */ } if (n->span) { assert(NULL == p && NULL == t); print_span(n->span, indent); } else if (n->eqn) { assert(NULL == p && NULL == t); print_box(n->eqn->root, indent); } else { for (i = 0; i < indent; i++) putchar('\t'); printf("%s (%s)", p, t); for (i = 0; i < (int)argc; i++) { printf(" -%s", mdoc_argnames[argv[i].arg]); if (argv[i].sz > 0) printf(" ["); for (j = 0; j < (int)argv[i].sz; j++) printf(" [%s]", argv[i].value[j]); if (argv[i].sz > 0) printf(" ]"); } for (i = 0; i < (int)sz; i++) printf(" [%s]", params[i]); printf(" %d:%d\n", n->line, n->pos); } if (n->child) print_mdoc(n->child, indent + 1); if (n->next) print_mdoc(n->next, indent); }
static void print_man(const struct man_node *n, int indent) { const char *p, *t; int i; t = p = NULL; switch (n->type) { case (MAN_ROOT): t = "root"; break; case (MAN_ELEM): t = "elem"; break; case (MAN_TEXT): t = "text"; break; case (MAN_BLOCK): t = "block"; break; case (MAN_HEAD): t = "block-head"; break; case (MAN_BODY): t = "block-body"; break; case (MAN_TAIL): t = "block-tail"; break; case (MAN_TBL): /* FALLTHROUGH */ case (MAN_EQN): break; default: abort(); /* NOTREACHED */ } switch (n->type) { case (MAN_TEXT): p = n->string; break; case (MAN_ELEM): /* FALLTHROUGH */ case (MAN_BLOCK): /* FALLTHROUGH */ case (MAN_HEAD): /* FALLTHROUGH */ case (MAN_TAIL): /* FALLTHROUGH */ case (MAN_BODY): p = man_macronames[n->tok]; break; case (MAN_ROOT): p = "root"; break; case (MAN_TBL): /* FALLTHROUGH */ case (MAN_EQN): break; default: abort(); /* NOTREACHED */ } if (n->span) { assert(NULL == p && NULL == t); print_span(n->span, indent); } else if (n->eqn) { assert(NULL == p && NULL == t); print_box(n->eqn->root, indent); } else { for (i = 0; i < indent; i++) putchar('\t'); printf("%s (%s) %d:%d\n", p, t, n->line, n->pos); } if (n->child) print_man(n->child, indent + 1); if (n->next) print_man(n->next, indent); }
/** Test icalcomponent_get_span() * */ void test_icalcomponent_get_span() { time_t tm1 = 973378800; /*Sat Nov 4 23:00:00 UTC 2000, Sat Nov 4 15:00:00 PST 2000 */ time_t tm2 = 973382400; /*Sat Nov 5 00:00:00 UTC 2000 Sat Nov 4 16:00:00 PST 2000 */ struct icaldurationtype dur; struct icaltime_span span; icalcomponent *c; icaltimezone *azone, *bzone; int tnum = 0; /** test 0 * Direct assigning time_t means they will be interpreted as UTC */ span.start = tm1; span.end = tm2; if (VERBOSE) print_span(tnum++,span); /** test 1 * We specify times in a timezone, the returned span is in UTC */ azone = icaltimezone_get_builtin_timezone("America/Los_Angeles"); c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_vanew_dtstart( icaltime_from_timet_with_zone(tm1,0,azone), icalparameter_new_tzid("America/Los_Angeles"),0), icalproperty_vanew_dtend( icaltime_from_timet_with_zone(tm2,0,azone), icalparameter_new_tzid("America/Los_Angeles"),0), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("America/Los_Angeles", span.start, 973407600); icalcomponent_free(c); /** test 2 * We specify times as floating, the returned span is in UTC * with no conversion applied - so result should be as test 0 */ c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_vanew_dtstart(icaltime_from_timet(tm1,0),0), icalproperty_vanew_dtend(icaltime_from_timet(tm2,0),0), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("floating time", span.start, tm1); icalcomponent_free(c); /** test 3 * We specify times in a timezone, the returned span is in UTC */ azone = icaltimezone_get_builtin_timezone("America/New_York"); c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_vanew_dtstart( icaltime_from_timet_with_zone(tm1,0,azone), icalparameter_new_tzid("America/New_York"),0), icalproperty_vanew_dtend( icaltime_from_timet_with_zone(tm2,0,azone), icalparameter_new_tzid("America/New_York"),0), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("America/New_York", span.start, 973396800); icalcomponent_free(c); /** test 4 * We specify times in two different timezones, the returned span * is in UTC */ azone = icaltimezone_get_builtin_timezone("America/New_York"); bzone = icaltimezone_get_builtin_timezone("America/Los_Angeles"); c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_vanew_dtstart( icaltime_from_timet_with_zone(tm1,0,azone), icalparameter_new_tzid("America/New_York"),0), icalproperty_vanew_dtend( icaltime_from_timet_with_zone(tm2,0,bzone), icalparameter_new_tzid("America/Los_Angeles"),0), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("America/New_York", span.start, 973396800); icalcomponent_free(c); /** test 5 * We specify start time in a timezone and a duration, the returned span * is in UTC */ azone = icaltimezone_get_builtin_timezone("America/Los_Angeles"); memset(&dur,0,sizeof(dur)); dur.minutes = 30; c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_vanew_dtstart( icaltime_from_timet_with_zone(tm1,0,azone), icalparameter_new_tzid("America/Los_Angeles"),0), icalproperty_new_duration(dur), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("America/Los_Angeles w/ duration", span.end, 973409400); icalcomponent_free(c); icalerror_errors_are_fatal = 0; /** test 6 * We specify only start time, should return a null span with no error */ c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_new_dtstart(icaltime_from_timet(tm1,0)), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("null span", span.start, 0); icalcomponent_free(c); /** test 7 * We specify start and end date */ c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_new_dtstart(icaltime_from_timet(tm1,1)), icalproperty_new_dtend(icaltime_from_timet(tm1,1)), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("UTC", span.start, 973296000); icalcomponent_free(c); /** test 8 * We specify start and end date */ c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_new_dtstart(icaltime_from_timet(tm1,1)), icalproperty_new_dtend(icaltime_from_timet(tm2,1)), 0 ); span = icalcomponent_get_span(c); int_is("UTC #2", span.start, 973296000); if (VERBOSE) print_span(tnum++,span); icalcomponent_free(c); /** test 9 * We specify start date */ c = icalcomponent_vanew( ICAL_VEVENT_COMPONENT, icalproperty_new_dtstart(icaltime_from_timet(tm1,1)), 0 ); span = icalcomponent_get_span(c); if (VERBOSE) print_span(tnum++,span); int_is("start date only", span.end, 973382399); icalcomponent_free(c); /* assert(icalerrno == ICAL_MALFORMEDDATA_ERROR); */ icalerror_errors_are_fatal = 1; }
static void print_mdoc(const struct mdoc_node *n, int indent) { const char *p, *t; int i, j; size_t argc; struct mdoc_argv *argv; argv = NULL; argc = 0; t = p = NULL; switch (n->type) { case MDOC_ROOT: t = "root"; break; case MDOC_BLOCK: t = "block"; break; case MDOC_HEAD: t = "block-head"; break; case MDOC_BODY: if (n->end) t = "body-end"; else t = "block-body"; break; case MDOC_TAIL: t = "block-tail"; break; case MDOC_ELEM: t = "elem"; break; case MDOC_TEXT: t = "text"; break; case MDOC_TBL: break; case MDOC_EQN: t = "eqn"; break; default: abort(); /* NOTREACHED */ } switch (n->type) { case MDOC_TEXT: p = n->string; break; case MDOC_BODY: p = mdoc_macronames[n->tok]; break; case MDOC_HEAD: p = mdoc_macronames[n->tok]; break; case MDOC_TAIL: p = mdoc_macronames[n->tok]; break; case MDOC_ELEM: p = mdoc_macronames[n->tok]; if (n->args) { argv = n->args->argv; argc = n->args->argc; } break; case MDOC_BLOCK: p = mdoc_macronames[n->tok]; if (n->args) { argv = n->args->argv; argc = n->args->argc; } break; case MDOC_TBL: break; case MDOC_EQN: p = "EQ"; break; case MDOC_ROOT: p = "root"; break; default: abort(); /* NOTREACHED */ } if (n->span) { assert(NULL == p && NULL == t); print_span(n->span, indent); } else { for (i = 0; i < indent; i++) putchar('\t'); printf("%s (%s)", p, t); for (i = 0; i < (int)argc; i++) { printf(" -%s", mdoc_argnames[argv[i].arg]); if (argv[i].sz > 0) printf(" ["); for (j = 0; j < (int)argv[i].sz; j++) printf(" [%s]", argv[i].value[j]); if (argv[i].sz > 0) printf(" ]"); } putchar(' '); if (MDOC_LINE & n->flags) putchar('*'); printf("%d:%d", n->line, n->pos + 1); if (n->lastline != n->line) printf("-%d", n->lastline); putchar('\n'); } if (n->eqn) print_box(n->eqn->root->first, indent + 1); if (n->child) print_mdoc(n->child, indent + 1); if (n->next) print_mdoc(n->next, indent); }
static void print_man(const struct man_node *n, int indent) { const char *p, *t; int i; t = p = NULL; switch (n->type) { case MAN_ROOT: t = "root"; break; case MAN_ELEM: t = "elem"; break; case MAN_TEXT: t = "text"; break; case MAN_BLOCK: t = "block"; break; case MAN_HEAD: t = "block-head"; break; case MAN_BODY: t = "block-body"; break; case MAN_TBL: break; case MAN_EQN: t = "eqn"; break; default: abort(); /* NOTREACHED */ } switch (n->type) { case MAN_TEXT: p = n->string; break; case MAN_ELEM: /* FALLTHROUGH */ case MAN_BLOCK: /* FALLTHROUGH */ case MAN_HEAD: /* FALLTHROUGH */ case MAN_BODY: p = man_macronames[n->tok]; break; case MAN_ROOT: p = "root"; break; case MAN_TBL: break; case MAN_EQN: p = "EQ"; break; default: abort(); /* NOTREACHED */ } if (n->span) { assert(NULL == p && NULL == t); print_span(n->span, indent); } else { for (i = 0; i < indent; i++) putchar('\t'); printf("%s (%s) ", p, t); if (MAN_LINE & n->flags) putchar('*'); printf("%d:%d\n", n->line, n->pos + 1); } if (n->eqn) print_box(n->eqn->root->first, indent + 1); if (n->child) print_man(n->child, indent + 1); if (n->next) print_man(n->next, indent); }