00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00051 #ifndef _QOF_MAIN_H
00052 #define _QOF_MAIN_H
00053
00070 void qof_main_wrap_line (FILE * fp, gint indent,
00071 const gchar * template_str, ...)
00072 __attribute__ ((format (printf, 3, 4)));
00073
00075 #define ERR_INDENT strlen(PACKAGE) + 2
00076
00093 GSList*
00094 qof_main_get_param_list(QofIdTypeConst object_type, QofType param_type);
00095
00100 #define QOF_DATE_STRING_LENGTH MAX_DATE_LENGTH
00101
00103 #define QOF_MAIN_CLI "QOF-mod-command-line"
00104
00118 #define CATEGORY_NAME "category"
00119
00127 #define QSF_COMPRESS "compression_level"
00128
00130 #define QSF_ENCODING "encoding_string"
00131
00133 #define QSF_DATE_CONVERT "convert_date_to_time"
00134
00159 #define QOF_SQL_SUPPORTED "^SELECT|INSERT"
00160
00170 gchar *
00171 qof_main_make_utf8 (gchar * string);
00172
00190 glong
00191 qof_mod_get_local_offset (void);
00192
00203 void qof_main_show_error (QofSession * session);
00204
00210 typedef struct QofMain_s
00211 {
00213 gchar *filename;
00215 gchar *write_file;
00217 gchar *input_file;
00219 gchar *sql_file;
00222 gchar *sql_str;
00224 gchar *database;
00226 gchar *exclude;
00228 gchar *category;
00231 QofTime *min_qt;
00234 QofTime *max_qt;
00236 QofSession *input_session;
00238 QofSession *export_session;
00240 gboolean error;
00242 QofQuery *query;
00244 GList *sql_list;
00246 gint64 gz_level;
00248 const gchar *encoding;
00251 gint64 convert;
00253 QofType param_type;
00254 } QofMainContext;
00255
00257 void qof_main_free (QofMainContext * context);
00258
00260 void qof_cmd_xmlfile (QofMainContext * context);
00261
00267 void qof_cmd_list (void);
00268
00275 void
00276 qof_mod_category (const gchar * category, QofMainContext * data);
00277
00284 void
00285 qof_mod_database (const gchar * database, QofMainContext * data);
00286
00314 void
00315 qof_mod_time (const gchar * date_time, QofMainContext * data);
00316
00321 void
00322 qof_mod_exclude (const gchar * exclude, QofMainContext * data);
00323
00363 void
00364 qof_mod_sql (const gchar * sql_query, QofMainContext * data);
00365
00374 void
00375 qof_mod_sql_file (const gchar * sql_file, QofMainContext * data);
00376
00381 void
00382 qof_mod_write (const gchar * write_file, QofMainContext * data);
00383
00390 void
00391 qof_mod_compression (gint64 gz_level, QofMainContext * context);
00392
00394 void
00395 qof_mod_encoding (const gchar * encoding, QofMainContext * context);
00396
00398 void
00399 qof_mod_convert_deprecated (gint64 convert, QofMainContext * context);
00400
00410 void qof_main_moderate_query (QofMainContext * context);
00411
00417 void qof_cmd_explain (QofMainContext * context);
00418
00419 void qof_main_select (QofMainContext * context);
00420
00430
00431
00432
00433 #define QOF_CLI_OPTIONS POPT_AUTOHELP \
00434 {"list", 'l', POPT_ARG_NONE, NULL, qof_op_list, \
00435 _("List all databases supported by the current QOF framework " \
00436 "and exit."), NULL}, \
00437 {"explain", 0, POPT_ARG_NONE, NULL, qof_op_explain, \
00438 _("List the fields within the specified database and " \
00439 "exit, requires -d."), NULL}, \
00440 {"xml-file", 'x', POPT_ARG_STRING, &filename, qof_op_offline, \
00441 _("Query the QSF XML data in <filename>"), \
00442 "filename"}, \
00443 {"date", 't', POPT_ARG_STRING, &date_time, qof_op_time, \
00444 _("Shorthand to only query objects that contain the " \
00445 "specified date."), "string"}, \
00446 {"database", 'd', POPT_ARG_STRING, &database, qof_op_database, \
00447 _("Shorthand to only query objects within a specific " \
00448 "supported database. "), "string"}, \
00449 {"exclude", 'e', POPT_ARG_STRING, &exclude, qof_op_exclude, \
00450 _("Shorthand to exclude a supported database from the query."), \
00451 "string"}, \
00452 {"sql", 's', POPT_ARG_STRING, &sql_query, qof_op_sql, \
00453 _("Specify a SQL query on the command line."), "string"}, \
00454 {"sql-file", 'f', POPT_ARG_STRING, &sql_file, qof_op_sql_file, \
00455 _("Specify one or more SQL queries contained in a file."), \
00456 "filename"}, \
00457 {"write", 'w', POPT_ARG_STRING, &write_file, qof_op_write, \
00458 _("Write the results of any query to the file"), "filename"}, \
00459 {"compress", 0, POPT_ARG_INT, &gz_level, qof_op_compress, \
00460 _("Compress output files, 0 for none, 9 for maximum"), "integer"}, \
00461 {"debug", 0, POPT_ARG_NONE, NULL, qof_op_debug, \
00462 _("Print debugging information to a temporary file."), NULL}, \
00463 {"version", 0, POPT_ARG_NONE, NULL, qof_op_vers, \
00464 _("Display version information"), NULL}, \
00465 {"category", 'c', POPT_ARG_STRING, &category, qof_op_category, \
00466 _("Shorthand to only query objects that are set to the specified category."), \
00467 "string"},
00468
00470 #define QOF_MAIN_OP \
00471 _(qof_op_noop, = 0) \
00472 _(qof_op_list,) \
00473 _(qof_op_xmlfile,) \
00474 _(qof_op_category,) \
00475 _(qof_op_database,) \
00476 _(qof_op_time,) \
00477 _(qof_op_exclude,) \
00478 _(qof_op_sql,) \
00479 _(qof_op_sql_file,) \
00480 _(qof_op_write, ) \
00481 _(qof_op_explain,) \
00482 _(qof_op_vers,) \
00483 _(qof_op_compress,) \
00484 _(qof_op_debug,)
00485
00491 #define QOF_OP_VARS \
00492 const gchar *exclude, *date_time, *category, *database; \
00493 const gchar *sql_file, *write_file, *sql_query, *filename;
00494
00499 #define QOF_OP_INIT \
00500 exclude = NULL; \
00501 category = NULL; \
00502 database = NULL; \
00503 sql_file = NULL; \
00504 write_file = NULL; \
00505 sql_query = NULL; \
00506 filename = NULL;
00507
00511 #endif