|
gimme-alpha 0.1
|
00001 /* 00002 ** read_nextnano_inputfile.h 00003 ** 00004 ** Made by Johnny Q. Hacker 00005 ** Login <solarion@borkborkbork> 00006 ** 00007 00008 00009 Copyright (C) 2008 Joseph Pingenot 00010 00011 This program is free software: you can redistribute it and/or modify 00012 it under the terms of the GNU Affero General Public License as published by 00013 the Free Software Foundation, either version 3 of the License, or 00014 (at your option) any later version. 00015 00016 This program is distributed in the hope that it will be useful, 00017 but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00019 GNU Affero General Public License for more details. 00020 00021 You should have received a copy of the GNU Affero General Public License 00022 along with this program. If not, see <http://www.gnu.org/licenses/>. 00023 00024 ** Started on Mon Sep 29 16:18:03 2008 Johnny Q. Hacker 00025 ** Last update Wed Oct 1 08:14:40 2008 Johnny Q. Hacker 00026 */ 00027 00028 #ifndef READ_NEXTNANO_INPUTFILE_H_ 00029 # define READ_NEXTNANO_INPUTFILE_H_ 00030 00031 #include <glib.h> 00032 #include <gio/gio.h> 00033 #include <libcommon/gimme_alpha_types.h> 00034 00035 #define DOMAIN_READ_NEXTNANO_INPUTFILE 1024 00036 00037 /*!error codes*/ 00038 #define ERR_NO_START_SECTION -1 /*!There was no section start; just keywords*/ 00039 #define ERR_BAD_KEYWORD_LINE -2 /*!This was a bad keyword line*/ 00040 00041 struct nextnano_keyword { 00042 /*!\var the data type for this */ 00043 enum data_types t; 00044 /*!\var 0 if this keyword is optional; 1 otherwise*/ 00045 short int required; 00046 /*!\var sequence number within the section; the first is 1, second 00047 * is 2, etc.*/ 00048 int seqnum; 00049 }; 00050 00051 struct nextnano_keyword_section { 00052 /*!\var GHashTable containing keywords for this section.*/ 00053 GHashTable *keywords; 00054 /*!\var 0 if this section is optional; 1 otherwise*/ 00055 short int required; 00056 }; 00057 00058 struct nextnano_value { 00059 enum data_types t; 00060 union { 00061 int i; 00062 double d; 00063 char *s; 00064 } store; 00065 }; 00066 00067 /*NextNano input files are complicated. See the Notes. 00068 */ 00069 00070 GHashTable* read_nextnano_inputfile(GInputStream *istream, GError **err); 00071 GHashTable* read_nextnano_inputfile2(GFile *basedir, GHashTable *keys, int inputfile, GError **err, char** filename); 00072 GHashTable* read_nextnano_inputfile_stringy(GInputStream *istream, GError **err); 00073 GHashTable* read_nextnano_inputfile_stringy2(GFile *basedir, GHashTable *keys, int inputfile, GError **err); 00074 GHashTable *read_nextnano_dbfile(GInputStream *istream, GError **err); 00075 GHashTable *read_nextnano_dbfile2(GFile *basedir, GError **err); 00076 GHashTable *read_nextnano_keyfile2(GFile *basedir, GError **err); 00077 00078 void print_stringy_inputfile(GHashTable *h); 00079 void print_finalized_inputfile(GHashTable *h); 00080 00081 /*Returns the list for a specific part of the input file. 00082 *ARGS: 00083 * section name of the section you want 00084 * secnum There may be multiple sections that match the name. 00085 * This specifies which one you want (in order of 00086 * occurrance) 00087 * chunknum There may be multiple chunks of key/value lists within 00088 * each section. This specifies which which one you 00089 * want (in order of occurrance) 00090 * key Specifies the key within the section. 00091 *RETURNS: 00092 * The list associated with the requested key. 00093 * NULL if the key wasn't found. 00094 */ 00095 GList* read_nextnano_extract_list_db(GHashTable *input, char* section, int secnum, int chunknum, char* key); 00096 00097 GList* read_nextnano_extract_list(GHashTable *input, char* section, int chunknum, char* key, int *err); 00098 GList* read_nextnano_extract_list_typed(GHashTable *input, char* section, int chunknum, char* key, int *err, enum data_types type); 00099 00100 /*Returns the first value in the key/value list. If there are 00101 * multiple key/value lists, err is set to 1. 00102 *ARGS: 00103 * same as read_nextnano_extract_list 00104 * err pointer to an int to store the error. 00105 *RETURNS 00106 * the item 00107 */ 00108 char* read_nextnano_extract_item(GHashTable *input, char* section, int chunknum, char* key, int* err); 00109 void* read_nextnano_extract_item_typed(GHashTable *input, char* section, int chunknum, char* key, int* err, enum data_types type); 00110 00111 00112 #endif /* !READ_NEXTNANO_INPUTFILE_H_ */