GnuCash 2.4.99
sixtp-utils.h
00001 /********************************************************************
00002  * sixtp-utils.h                                                    *
00003  * Copyright 2001 Gnumatic, Inc.                                    *
00004  *                                                                  *
00005  * This program is free software; you can redistribute it and/or    *
00006  * modify it under the terms of the GNU General Public License as   *
00007  * published by the Free Software Foundation; either version 2 of   *
00008  * the License, or (at your option) any later version.              *
00009  *                                                                  *
00010  * This program is distributed in the hope that it will be useful,  *
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
00013  * GNU General Public License for more details.                     *
00014  *                                                                  *
00015  * You should have received a copy of the GNU General Public License*
00016  * along with this program; if not, contact:                        *
00017  *                                                                  *
00018  * Free Software Foundation           Voice:  +1-617-542-5942       *
00019  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
00020  * Boston, MA  02110-1301,  USA       gnu@gnu.org                   *
00021  *                                                                  *
00022  ********************************************************************/
00023 
00024 #ifndef SIXTP_UTILS_H
00025 #define SIXTP_UTILS_H
00026 
00027 #include "qof.h"
00028 
00029 #include "sixtp.h"
00030 
00031 typedef struct
00032 {
00033     Timespec ts;
00034     guint s_block_count;
00035     guint ns_block_count;
00036 } TimespecParseInfo;
00037 
00038 #define TIMESPEC_TIME_FORMAT  "%Y-%m-%d %H:%M:%S"
00039 #define TIMESPEC_PARSE_TIME_FORMAT  "%Y-%m-%d %H:%M:%S"
00040 #define TIMESPEC_SEC_FORMAT_MAX 256
00041 
00042 gboolean isspace_str(const gchar *str, int nomorethan);
00043 
00044 gboolean allow_and_ignore_only_whitespace(GSList *sibling_data,
00045         gpointer parent_data,
00046         gpointer global_data,
00047         gpointer *result,
00048         const char *text,
00049         int length);
00050 
00051 gboolean generic_accumulate_chars(GSList *sibling_data,
00052                                   gpointer parent_data,
00053                                   gpointer global_data,
00054                                   gpointer *result,
00055                                   const char *text,
00056                                   int length);
00057 
00058 
00059 void generic_free_data_for_children(gpointer data_for_children,
00060                                     GSList* data_from_children,
00061                                     GSList* sibling_data,
00062                                     gpointer parent_data,
00063                                     gpointer global_data,
00064                                     gpointer *result,
00065                                     const gchar *tag);
00066 
00067 gchar * concatenate_child_result_chars(GSList *data_from_children);
00068 
00069 gboolean string_to_double(const char *str, double *result);
00070 
00071 gboolean string_to_gint64(const gchar *str, gint64 *v);
00072 
00073 gboolean string_to_gint32(const gchar *str, gint32 *v);
00074 
00075 gboolean hex_string_to_binary(const gchar *str,  void **v, guint64 *data_len);
00076 
00077 gboolean generic_return_chars_end_handler(gpointer data_for_children,
00078         GSList* data_from_children,
00079         GSList* sibling_data,
00080         gpointer parent_data,
00081         gpointer global_data,
00082         gpointer *result,
00083         const gchar *tag);
00084 
00085 sixtp* simple_chars_only_parser_new(sixtp_end_handler end_handler);
00086 
00087 gboolean string_to_timespec_secs(const gchar *str, Timespec *ts);
00088 gboolean string_to_timespec_nsecs(const gchar *str, Timespec *ts);
00089 
00090 /* str must have length of at least TIMESPEC_SEC_FORMAT_MAX */
00091 gboolean timespec_secs_to_given_string (const Timespec *ts, gchar *str);
00092 
00093 
00094 gboolean generic_timespec_start_handler(GSList* sibling_data,
00095                                         gpointer parent_data,
00096                                         gpointer global_data,
00097                                         gpointer *data_for_children,
00098                                         gpointer *result,
00099                                         const gchar *tag, gchar **attrs);
00100 
00101 gboolean timespec_parse_ok(TimespecParseInfo *info);
00102 
00103 gboolean generic_timespec_secs_end_handler(
00104     gpointer data_for_children,
00105     GSList  *data_from_children, GSList *sibling_data,
00106     gpointer parent_data, gpointer global_data,
00107     gpointer *result, const gchar *tag);
00108 
00109 gboolean generic_timespec_nsecs_end_handler(
00110     gpointer data_for_children,
00111     GSList  *data_from_children, GSList *sibling_data,
00112     gpointer parent_data, gpointer global_data,
00113     gpointer *result, const gchar *tag);
00114 
00115 
00116 sixtp* generic_timespec_parser_new(sixtp_end_handler end_handler);
00117 
00118 gboolean generic_guid_end_handler(
00119     gpointer data_for_children,
00120     GSList  *data_from_children, GSList *sibling_data,
00121     gpointer parent_data, gpointer global_data,
00122     gpointer *result, const gchar *tag);
00123 
00124 sixtp* generic_guid_parser_new(void);
00125 
00126 gboolean generic_gnc_numeric_end_handler(
00127     gpointer data_for_children,
00128     GSList  *data_from_children, GSList *sibling_data,
00129     gpointer parent_data, gpointer global_data,
00130     gpointer *result, const gchar *tag);
00131 
00132 sixtp* generic_gnc_numeric_parser_new(void);
00133 
00134 sixtp* restore_char_generator(sixtp_end_handler ender);
00135 
00136 
00137 
00138 #endif /* _SIXTP_UTILS_H_ */
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines