2
* Copyright (C) 2000 S�bastien LECACHEUR
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20
#include <string.h> /* strcmp */
21
#include "gwsupport.h"
22
#include "gwdbcatalog.h"
25
typedef struct gw_db_catalog_s {
30
gchar* program_builder;
37
GWDBCatalog * gw_db_catalog_new ( void) {
38
GWDBCatalog *catalog = NULL;
41
if ( (catalog = (GWDBCatalog*)g_malloc0 ( sizeof ( GWDBCatalog))) != NULL ) {
43
catalog->short_db_name = NULL;
44
catalog->db_name = NULL;
45
catalog->version = NULL;
46
catalog->program_builder = NULL;
47
catalog->description = NULL;
48
catalog->is_modified = FALSE;
56
gint gw_db_catalog_set_name ( GWDBCatalog *catalog, gchar *name) {
57
if ( catalog != NULL ) {
58
if ( catalog->name != NULL ) {
59
g_free ( catalog->name);
71
gint gw_db_catalog_set_short_db_name ( GWDBCatalog *catalog, gchar *short_db_name) {
72
if ( catalog != NULL ) {
73
if ( catalog->short_db_name != NULL ) {
74
g_free ( catalog->short_db_name);
77
catalog->short_db_name = short_db_name;
86
gint gw_db_catalog_set_db_name ( GWDBCatalog *catalog, gchar *db_name) {
87
if ( catalog != NULL ) {
88
if ( catalog->db_name != NULL ) {
89
g_free ( catalog->db_name);
92
catalog->db_name = db_name;
101
gint gw_db_catalog_set_version ( GWDBCatalog *catalog, gchar *version) {
102
if ( catalog != NULL ) {
103
if ( catalog->version != NULL ) {
104
g_free ( catalog->version);
107
catalog->version = version;
116
gint gw_db_catalog_set_program_builder ( GWDBCatalog *catalog, gchar *program_builder) {
117
if ( catalog != NULL ) {
118
if ( catalog->program_builder != NULL ) {
119
g_free ( catalog->program_builder);
122
catalog->program_builder = program_builder;
131
gint gw_db_catalog_set_description ( GWDBCatalog *catalog, gchar *description) {
132
if ( catalog != NULL ) {
133
if ( catalog->description != NULL ) {
134
g_free ( catalog->description);
137
catalog->description = description;
146
gint gw_db_catalog_set_size ( GWDBCatalog *catalog, gulong size) {
147
if ( catalog != NULL ) {
148
catalog->size = size;
157
gint gw_db_catalog_set_ismodified ( GWDBCatalog *catalog, gboolean modified) {
158
if ( catalog != NULL ) {
159
catalog->is_modified = modified;
168
gchar * gw_db_catalog_get_name ( GWDBCatalog *catalog) {
169
if ( catalog != NULL ) {
170
return catalog->name;
177
gchar * gw_db_catalog_get_short_db_name ( GWDBCatalog *catalog) {
178
if ( catalog != NULL ) {
179
return catalog->short_db_name;
186
gchar * gw_db_catalog_get_db_name ( GWDBCatalog *catalog) {
187
if ( catalog != NULL ) {
188
return catalog->db_name;
195
gchar * gw_db_catalog_get_version ( GWDBCatalog *catalog) {
196
if ( catalog != NULL ) {
197
return catalog->version;
204
gchar * gw_db_catalog_get_program_builder ( GWDBCatalog *catalog) {
205
if ( catalog != NULL ) {
206
return catalog->program_builder;
213
gchar * gw_db_catalog_get_description ( GWDBCatalog *catalog) {
214
if ( catalog != NULL ) {
215
return catalog->description;
222
gulong gw_db_catalog_get_size ( GWDBCatalog *catalog) {
223
if ( catalog != NULL ) {
224
return catalog->size;
231
gboolean gw_db_catalog_is_modified ( GWDBCatalog *catalog) {
232
if ( catalog != NULL ) {
233
return catalog->is_modified;
236
/* If catalog doesn't exist, it may not be modified. */
241
GWDBCatalog * gw_db_catalog_dup ( GWDBCatalog *catalog, GWDBCatalog **dup) {
242
GWDBCatalog *dup_catalog = NULL;
245
if ( catalog != NULL ) {
247
if ( dup_catalog == NULL ) {
248
/* Don't check if gw_db_catalog_new return NULL because all following functions check it too. */
249
(*dup) = dup_catalog = gw_db_catalog_new ( );
252
if ( gw_db_catalog_get_name ( catalog) != NULL ) {
253
gw_db_catalog_set_name ( dup_catalog, g_strdup ( gw_db_catalog_get_name ( catalog)));
255
gw_db_catalog_set_name ( dup_catalog, NULL);
257
if ( gw_db_catalog_get_short_db_name ( catalog) != NULL ) {
258
gw_db_catalog_set_short_db_name ( dup_catalog, g_strdup ( gw_db_catalog_get_short_db_name ( catalog)));
260
gw_db_catalog_set_short_db_name ( dup_catalog, NULL);
262
if ( gw_db_catalog_get_db_name ( catalog) != NULL ) {
263
gw_db_catalog_set_db_name ( dup_catalog, g_strdup ( gw_db_catalog_get_db_name ( catalog)));
265
gw_db_catalog_set_db_name ( dup_catalog, NULL);
267
if ( gw_db_catalog_get_version ( catalog) != NULL ) {
268
gw_db_catalog_set_version ( dup_catalog, g_strdup ( gw_db_catalog_get_version ( catalog)));
270
gw_db_catalog_set_version ( dup_catalog, NULL);
272
if ( gw_db_catalog_get_program_builder ( catalog) != NULL ) {
273
gw_db_catalog_set_program_builder ( dup_catalog, g_strdup ( gw_db_catalog_get_program_builder ( catalog)));
275
gw_db_catalog_set_program_builder ( dup_catalog, NULL);
277
if ( gw_db_catalog_get_description ( catalog) != NULL ) {
278
gw_db_catalog_set_description ( dup_catalog, g_strdup ( gw_db_catalog_get_description ( catalog)));
280
gw_db_catalog_set_description ( dup_catalog, NULL);
282
gw_db_catalog_set_size ( dup_catalog, gw_db_catalog_get_size ( catalog));
283
gw_db_catalog_set_ismodified ( dup_catalog, gw_db_catalog_is_modified ( catalog));
290
gint gw_db_catalog_free ( GWDBCatalog *catalog) {
291
if ( catalog != NULL ) {
292
gw_db_catalog_set_name ( catalog, NULL);
293
gw_db_catalog_set_short_db_name ( catalog, NULL);
294
gw_db_catalog_set_db_name ( catalog, NULL);
295
gw_db_catalog_set_version ( catalog, NULL);
296
gw_db_catalog_set_program_builder ( catalog, NULL);
297
gw_db_catalog_set_description ( catalog, NULL);
308
gboolean gw_db_catalog_equals ( GWDBCatalog *catalog, GWDBCatalog *to) {
309
gboolean equals = FALSE;
312
if ( catalog != NULL && to != NULL) {
313
if ( str_equals ( gw_db_catalog_get_name ( catalog), gw_db_catalog_get_name ( to))
314
&& str_equals ( gw_db_catalog_get_short_db_name ( catalog), gw_db_catalog_get_short_db_name ( to))
315
&& str_equals ( gw_db_catalog_get_db_name ( catalog), gw_db_catalog_get_db_name ( to))
316
&& str_equals ( gw_db_catalog_get_version ( catalog), gw_db_catalog_get_version ( to))
317
&& str_equals ( gw_db_catalog_get_program_builder ( catalog), gw_db_catalog_get_program_builder ( to))
318
&& str_equals ( gw_db_catalog_get_description ( catalog), gw_db_catalog_get_description ( to))
319
&& gw_db_catalog_is_modified ( catalog) == gw_db_catalog_is_modified ( to)
320
&& gw_db_catalog_get_size ( catalog) == gw_db_catalog_get_size ( to) ) {