X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Ftable.h;h=c29d7e31f0e1a4466be63439d3dcc6bfeb49583e;hb=634408e0c5e9d99b55c40ab4df608f822ef923a7;hp=c24bca2a7aafe4fc0f18c39a369f86486620fbfe;hpb=3a3eb9daef012e58d6604a6fc726a5115b25945f;p=openvswitch diff --git a/lib/table.h b/lib/table.h index c24bca2a..c29d7e31 100644 --- a/lib/table.h +++ b/lib/table.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2009, 2010, 2011, 2012 Nicira Networks. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -32,11 +32,13 @@ struct table { size_t n_rows, allocated_rows; size_t current_column; char *caption; + bool timestamp; }; void table_init(struct table *); void table_destroy(struct table *); void table_set_caption(struct table *, char *caption); +void table_set_timestamp(struct table *, bool timestamp); void table_add_column(struct table *, const char *heading, ...) PRINTF_FORMAT(2, 3); @@ -59,6 +61,7 @@ struct cell *table_add_cell(struct table *); enum table_format { TF_TABLE, /* 2-d table. */ + TF_LIST, /* One cell per line, one row per paragraph. */ TF_HTML, /* HTML table. */ TF_CSV, /* Comma-separated lines. */ TF_JSON /* JSON. */ @@ -66,6 +69,7 @@ enum table_format { enum cell_format { CF_STRING, /* String format. */ + CF_BARE, /* String format without most punctuation. */ CF_JSON /* JSON. */ }; @@ -80,13 +84,15 @@ struct table_style { #define TABLE_OPTION_ENUMS \ OPT_NO_HEADINGS, \ - OPT_PRETTY + OPT_PRETTY, \ + OPT_BARE -#define TABLE_LONG_OPTIONS \ - {"format", required_argument, 0, 'f'}, \ - {"data", required_argument, 0, 'd'}, \ - {"no-headings", no_argument, 0, OPT_NO_HEADINGS}, \ - {"pretty", no_argument, 0, OPT_PRETTY}, +#define TABLE_LONG_OPTIONS \ + {"format", required_argument, NULL, 'f'}, \ + {"data", required_argument, NULL, 'd'}, \ + {"no-headings", no_argument, NULL, OPT_NO_HEADINGS}, \ + {"pretty", no_argument, NULL, OPT_PRETTY}, \ + {"bare", no_argument, NULL, OPT_BARE} #define TABLE_OPTION_HANDLERS(STYLE) \ case 'f': \ @@ -103,6 +109,12 @@ struct table_style { \ case OPT_PRETTY: \ (STYLE)->json_flags |= JSSF_PRETTY; \ + break; \ + \ + case OPT_BARE: \ + (STYLE)->format = TF_LIST; \ + (STYLE)->cell_format = CF_BARE; \ + (STYLE)->headings = false; \ break; void table_parse_format(struct table_style *, const char *format);