exif-mnote-data.c

Go to the documentation of this file.
00001 /* exif-mnote-data.c
00002  *
00003  * Copyright (C) 2003 Lutz Mueller <lutz@users.sourceforge.net>
00004  *
00005  * This library is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU Lesser General Public
00007  * License as published by the Free Software Foundation; either
00008  * version 2.1 of the License, or (at your option) any later version.
00009  *
00010  * This library 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 GNU
00013  * Lesser General Public License for more details. 
00014  *
00015  * You should have received a copy of the GNU Lesser General Public
00016  * License along with this library; if not, write to the
00017  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00018  * Boston, MA  02110-1301  USA.
00019  */
00020 
00021 #include <config.h>
00022 
00023 #include <libexif/exif-mnote-data.h>
00024 #include <libexif/exif-mnote-data-priv.h>
00025 
00026 #include <stdlib.h>
00027 #include <string.h>
00028 
00029 struct _ExifMnoteDataPriv
00030 {
00031         unsigned int ref_count;
00032 };
00033 
00034 void
00035 exif_mnote_data_construct (ExifMnoteData *d, ExifMem *mem)
00036 {
00037         if (!d || !mem) return;
00038         if (d->priv) return;
00039         d->priv = exif_mem_alloc (mem, sizeof (ExifMnoteDataPriv));
00040         if (!d->priv) return;
00041 
00042         d->priv->ref_count = 1;
00043 
00044         d->mem = mem;
00045         exif_mem_ref (mem);
00046 }
00047 
00048 void
00049 exif_mnote_data_ref (ExifMnoteData *d)
00050 {
00051         if (d && d->priv) d->priv->ref_count++;
00052 }
00053 
00054 static void
00055 exif_mnote_data_free (ExifMnoteData *d)
00056 {
00057         ExifMem *mem = d ? d->mem : NULL;
00058 
00059         if (!d) return;
00060         if (d->priv) {
00061                 if (d->methods.free) d->methods.free (d);
00062                 exif_mem_free (mem, d->priv);
00063                 d->priv = NULL;
00064         }
00065         exif_log_unref (d->log);
00066         exif_mem_free (mem, d);
00067         exif_mem_unref (mem);
00068 }
00069 
00070 void
00071 exif_mnote_data_unref (ExifMnoteData *d)
00072 {
00073         if (!d || !d->priv) return;
00074         if (d->priv->ref_count > 0) d->priv->ref_count--;
00075         if (!d->priv->ref_count)
00076                 exif_mnote_data_free (d);
00077 }
00078 
00079 void
00080 exif_mnote_data_load (ExifMnoteData *d, const unsigned char *buf,
00081                       unsigned int buf_size)
00082 {
00083         if (!d || !d->methods.load) return;
00084         d->methods.load (d, buf, buf_size);
00085 }
00086 
00087 void
00088 exif_mnote_data_save (ExifMnoteData *d, unsigned char **buf,
00089                       unsigned int *buf_size)
00090 {
00091         if (!d || !d->methods.save) return;
00092         d->methods.save (d, buf, buf_size);
00093 }
00094 
00095 void
00096 exif_mnote_data_set_byte_order (ExifMnoteData *d, ExifByteOrder o)
00097 {
00098         if (!d || !d->methods.set_byte_order) return;
00099         d->methods.set_byte_order (d, o);
00100 }
00101 
00102 void
00103 exif_mnote_data_set_offset (ExifMnoteData *d, unsigned int o)
00104 {
00105         if (!d || !d->methods.set_offset) return;
00106         d->methods.set_offset (d, o);
00107 }
00108 
00109 unsigned int
00110 exif_mnote_data_count (ExifMnoteData *d)
00111 {
00112         if (!d || !d->methods.count) return 0;
00113         return d->methods.count (d);
00114 }
00115 
00116 unsigned int
00117 exif_mnote_data_get_id (ExifMnoteData *d, unsigned int n)
00118 {
00119         if (!d || !d->methods.get_id) return 0;
00120         return d->methods.get_id (d, n);
00121 }
00122 
00123 const char *
00124 exif_mnote_data_get_name (ExifMnoteData *d, unsigned int n)
00125 {
00126         if (!d || !d->methods.get_name) return NULL;
00127         return d->methods.get_name (d, n);
00128 }
00129 
00130 const char *
00131 exif_mnote_data_get_title (ExifMnoteData *d, unsigned int n)
00132 {
00133         if (!d || !d->methods.get_title) return NULL;
00134         return d->methods.get_title (d, n);
00135 }
00136         
00137 const char *
00138 exif_mnote_data_get_description (ExifMnoteData *d, unsigned int n)
00139 {
00140         if (!d || !d->methods.get_description) return NULL;
00141         return d->methods.get_description (d, n);
00142 }
00143         
00144 char *
00145 exif_mnote_data_get_value (ExifMnoteData *d, unsigned int n, char *val, unsigned int maxlen)
00146 {
00147         if (!d || !d->methods.get_value) return NULL;
00148         return d->methods.get_value (d, n, val, maxlen);
00149 }
00150 
00151 void
00152 exif_mnote_data_log (ExifMnoteData *d, ExifLog *log)
00153 {
00154         if (!d) return;
00155         exif_log_unref (d->log);
00156         d->log = log;
00157         exif_log_ref (log);
00158 }

SourceForge.net Logo Generated by doxygen