From fe9fc9b3ddf3a2edd5103aebe6a1e2895ff709b7 Mon Sep 17 00:00:00 2001 From: Joni Kokko Date: Fri, 23 May 2008 06:34:36 +0000 Subject: [PATCH] IrrecoFileContainer added --- irreco/trunk/src/util/Makefile.am | 6 +- irreco/trunk/src/util/irreco_file_container.c | 96 +++++++++++++++++++++++++++ irreco/trunk/src/util/irreco_file_container.h | 75 +++++++++++++++++++++ 3 files changed, 175 insertions(+), 2 deletions(-) create mode 100644 irreco/trunk/src/util/irreco_file_container.c create mode 100644 irreco/trunk/src/util/irreco_file_container.h diff --git a/irreco/trunk/src/util/Makefile.am b/irreco/trunk/src/util/Makefile.am index f63eec1f..a9037a21 100644 --- a/irreco/trunk/src/util/Makefile.am +++ b/irreco/trunk/src/util/Makefile.am @@ -7,6 +7,8 @@ lib_irreco_util_la_CFLAGS = $(IRRECO_CFLAGS) -DIRRECO_UTIL_BUILD lib_irreco_util_la_SOURCES = \ irreco_debug.c \ irreco_debug.h \ + irreco_file_container.c \ + irreco_file_container.h \ irreco_keyfile.c \ irreco_keyfile.h \ irreco_misc.c \ @@ -15,9 +17,9 @@ lib_irreco_util_la_SOURCES = \ irreco_retry_loop.h \ irreco_string_table.c \ irreco_string_table.h \ - irreco_util.h \ irreco_sha1.c \ - irreco_sha1.h + irreco_sha1.h \ + irreco_util.h # diff --git a/irreco/trunk/src/util/irreco_file_container.c b/irreco/trunk/src/util/irreco_file_container.c new file mode 100644 index 00000000..8514c062 --- /dev/null +++ b/irreco/trunk/src/util/irreco_file_container.c @@ -0,0 +1,96 @@ +/* + * irreco - Ir Remote Control + * Copyright (C) 2008 Joni Kokko (t5kojo01@students.oamk.fi) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + +#include "irreco_file_container.h" + +/* + * PURPOCE OF FILE. TODO TODO TODO + */ + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Prototypes */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Construction & Destruction */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +IrrecoFileContainer *irreco_file_container_new() +{ + IrrecoFileContainer *self; + IRRECO_ENTER + + self = g_slice_new0(IrrecoFileContainer); + + self->hash = g_string_new(""); + self->name = g_string_new(""); + self->data = g_string_new(""); + + IRRECO_RETURN_PTR(self); +} + +void irreco_file_container_free(IrrecoFileContainer *self) +{ + IRRECO_ENTER + + g_assert(self != NULL); + + g_string_free(self->hash, TRUE); + g_string_free(self->name, TRUE); + g_string_free(self->data, TRUE); + + g_slice_free(IrrecoFileContainer, self); + + self->hash = NULL; + self->name = NULL; + self->data = NULL; + self = NULL; + + IRRECO_RETURN +} + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Private Functions */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Functions */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + +void irreco_file_container_set(IrrecoFileContainer *self, + const char *file_name, + const char *file_data) +{ + const char *file_hash; + IRRECO_ENTER + + file_hash = sha_compute_checksum_for_string(G_CHECKSUM_SHA1, + file_data, + strlen(file_data)); + + g_string_printf(self->hash,"%s", file_hash); + g_string_printf(self->name,"%s", file_name); + g_string_printf(self->data,"%s", file_data); + + IRRECO_RETURN +} + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Events and Callbacks */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + diff --git a/irreco/trunk/src/util/irreco_file_container.h b/irreco/trunk/src/util/irreco_file_container.h new file mode 100644 index 00000000..8f1b2d81 --- /dev/null +++ b/irreco/trunk/src/util/irreco_file_container.h @@ -0,0 +1,75 @@ +/* + * irreco - Ir Remote Control + * Copyright (C) 2008 Joni Kokko (t5kojo01@students.oamk.fi) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ + + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Typedef */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* + * Make sure that typedefs are available before we include anything elese. + * + * This makes sure that whatever other structures that depend on structures + * defined in this file will compile OK recardles of header inclusion order. + */ +#ifndef __FILE_CONTAINER_H_TYPEDEF__ +#define __FILE_CONTAINER_H_TYPEDEF__ +typedef struct _IrrecoFileContainer IrrecoFileContainer; +#endif /* __FILE_CONTAINER_H_TYPEDEF__ */ + + + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Include */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +#ifndef __FILE_CONTAINER_H__ +#define __FILE_CONTAINER_H__ +#include "irreco_sha1.h" +#include "irreco_util.h" + + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Datatypes */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + +struct _IrrecoFileContainer +{ + GString *hash; + GString *name; + GString *data; +}; + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Macro */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + + + +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ +/* Prototypes */ +/*=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-*/ + +IrrecoFileContainer *irreco_file_container_new(); +void irreco_file_container_free(IrrecoFileContainer *self); + +void irreco_file_container_set(IrrecoFileContainer *self, + const char *file_name, + const char *file_data); +#endif /* __FILE_CONTAINER_H__ */ + + -- 2.11.4.GIT