Ok, issues fixed and some improvements added (now a pdf_char_t is returned by pdf_uuid_string to allow inline calls; added a check for the appropriate buffer size; improved pdf_uuid_generate & pdf_uuid_compare code; updated gnupdf.texi)
Albert 2011/3/23 Jose E. Marchesi <jema...@gnu.org>: > > > Please find attached a new patch. I've considered all your comments > and implemented the string issue with the c) option. I've also updated > the documentation. Thank you Jose and Aleksander for your reviews > :-) > > Your patch seems to revert some of the latest changes by Aleks: > > -@deftypefun {const pdf_text_t *} pdf_hash_get_text (pdf_hash_t *@var{table}, > const pdf_char_t *@var{key}) > +@deftypefun {const pdf_text_t} pdf_hash_get_text (pdf_hash_t *@var{table}, > const pdf_char_t *@var{key}) > > It seems that you made a copy of gnupdf.texi, merged and then copied the > file back in the repo. Please check. > > Regarding the second argument of pdf_uuid_string, I would really prefer > to just require a pointer to pdf_char_t (and not char). The requirement > for the pointed buffer shall be to be big enough, not to contain a fixed > number of chars. > > -- > Jose E. Marchesi jema...@gnu.org > GNU Project http://www.gnu.org >
# Bazaar merge directive format 2 (Bazaar 0.90) # revision_id: albert.mer...@est.fib.upc.edu-20110324175836-\ # amiray302v7qycqx # target_branch: bzr://bzr.sv.gnu.org/pdf/libgnupdf/trunk/ # testament_sha1: 47bebb876779164bca8de621156b825f494640f0 # timestamp: 2011-03-24 18:59:11 +0100 # base_revision_id: jema...@gnu.org-20110323205237-cdqcwxt8vaw5ov19 # # Begin patch === modified file 'AUTHORS' --- AUTHORS 2009-12-08 15:45:40 +0000 +++ AUTHORS 2011-03-24 17:58:36 +0000 @@ -3,6 +3,9 @@ appreciation for their public spirit, we list here in alphabetical order a condensed list of their contributions. +Albert Meroño Peñuela: changed configure.ac gnupdf.texi pdf-types-uuid.c + pdf-types-uuid.h + Aleksander Morgado: changed gnupdf.texi pdf-text.c pdf-text-ucd-case.c pdf-text-filter.c pdf-time.c pdf-time-string.c gnupdf-tsd.texi pdf-text-generate-ucd.c pdf-text-host-encoding.c pdf-time.h pdf-types.h === modified file 'ChangeLog' --- ChangeLog 2011-03-23 20:52:37 +0000 +++ ChangeLog 2011-03-24 17:58:36 +0000 @@ -1,3 +1,11 @@ +2011-03-24 Albert Meroño Peñuela <albert.mer...@est.fib.upc.edu> + + base/types: UUID module implementation. + * src/base/pdf-types-uuid.[h|c] + * src/Makefile.am: Compile UUID module within types. + * configure.ac: Added libuuid dependencies. + * doc/gnupdf.texi: Documented changes in UUID API. + 2011-03-23 Jose E. Marchesi <jema...@gnu.org> readme: added note about year intervals in the copyrights. === modified file 'configure.ac' --- configure.ac 2011-01-27 23:21:59 +0000 +++ configure.ac 2011-03-24 17:58:36 +0000 @@ -102,6 +102,9 @@ dnl Some of the libraries are mandatory, and some are optional. See dnl the section "Report errors" below. +dnl libuuid +AC_LIB_HAVE_LINKFLAGS([uuid]) + dnl libpthread AC_LIB_HAVE_LINKFLAGS([pthread]) @@ -394,6 +397,10 @@ missing_libs="$missing_libs libpthread" fi +if test "x$HAVE_LIBUUID" != "xyes"; then + missing_libs="$missing_libs + libuuid" +fi if test "x$HAVE_LIBGPG_ERROR" != "xyes"; then missing_libs="$missing_libs libgpg-error" === modified file 'doc/gnupdf.texi' --- doc/gnupdf.texi 2011-03-23 09:35:50 +0000 +++ doc/gnupdf.texi 2011-03-24 17:58:36 +0000 @@ -1336,25 +1336,31 @@ @end table @end deftypefun -@deftypefun {const char *} pdf_uuid_string (pdf_uuid_t @var{uuid}) +@deftypefun {pdf_char_t *} pdf_uuid_string (pdf_uuid_t @var{uuid}, pdf_char_t * @var{buffer}, pdf_size_t buffer_size) -Return an ASCII string with the printed representation of @var{uuid}. +Set and return an ASCII string with the printed representation of @var{uuid}. @table @strong @item Parameters @table @var @item uuid A previously generated UUID. +@item buffer +A pointer to the output buffer. The given buffer should have at least PDF_UUID_SIZE (46) bytes. +@item buffer_size +Size of @var{buffer}. @end table @item Returns -A null-terminated buffer containing the printed representation of -@var{uuid}. +A null-terminated buffer containing the printed representation of @var{uuid}. @item Usage example +@example pdf_uuid_t uuid; +pdf_char_t uuid_str[PDF_UUID_SIZE]; uuid = pdf_uuid_generate (PDF_UUID_TIME); printf ("The generated UUID: %s\n", - pdf_uuid_string (uuid)); + pdf_uuid_string (uuid, uuid_str, PDF_UUID_SIZE); +@end example @end table @end deftypefun === modified file 'src/Makefile.am' --- src/Makefile.am 2011-03-10 19:41:03 +0000 +++ src/Makefile.am 2011-03-24 17:58:36 +0000 @@ -32,7 +32,8 @@ TYPES_MODULE_SOURCES = base/pdf-types.h \ base/pdf-types-buffer.c base/pdf-types-buffer.h \ - base/pdf-types-pmon.h + base/pdf-types-pmon.h \ + base/pdf-types-uuid.c base/pdf-types-uuid.h ERROR_MODULE_SOURCES = base/pdf-error.c base/pdf-error.h @@ -118,7 +119,7 @@ endif libgnupdf_la_LDFLAGS = $(top_builddir)/lib/libgnu.la \ - $(LTLIBPTHREAD) $(LTLIBM) \ + $(LTLIBUUID) $(LTLIBPTHREAD) $(LTLIBM) \ $(LTLIBJBIG2DEC) $(LTLIBJPEG) $(LTLIBCURL) \ $(LIBGCRYPT_LIBS) $(LTLIBGPG_ERROR) $(LTLIBGCRYPT) \ $(LTLIBCHECK) $(LTLIBICONV) @@ -149,6 +150,7 @@ base/pdf-error.h \ base/pdf-types-buffer.h \ base/pdf-types-pmon.h \ + base/pdf-types-uuid.h \ base/pdf-fp.h \ base/pdf-alloc.h \ base/pdf-list.h \ === added file 'src/base/pdf-types-uuid.c' --- src/base/pdf-types-uuid.c 1970-01-01 00:00:00 +0000 +++ src/base/pdf-types-uuid.c 2011-03-24 17:58:36 +0000 @@ -0,0 +1,70 @@ +/* -*- mode: C -*- + * + * File: pdf-types-uuid.c + * Date: Tue Feb 8 18:38:34 2011 + * + * GNU PDF Library - UUID generation and utilities + * + */ + +/* Copyright (C) 2011 Free Software Foundation, Inc. */ + +/* 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#include <config.h> + +#include <pdf-types-uuid.h> + +pdf_uuid_t +pdf_uuid_generate (enum pdf_uuid_type_e type) +{ + pdf_uuid_t new_uuid; + + switch (type) + { + case PDF_UUID_TIME: + uuid_generate_time (new_uuid.uuid); + break; + case PDF_UUID_RANDOM: + uuid_generate_random (new_uuid.uuid); + break; + default: + uuid_generate (new_uuid.uuid); + } + + return new_uuid; +} + +pdf_char_t * +pdf_uuid_string (pdf_uuid_t uuid, + pdf_char_t * buffer, + pdf_size_t buffer_size) +{ + if (buffer_size < PDF_UUID_SIZE) + return NULL; + + uuid_unparse (uuid.uuid, buffer); + + return buffer; +} + +pdf_bool_t +pdf_uuid_equal_p (pdf_uuid_t uuid1, + pdf_uuid_t uuid2) +{ + return (uuid_compare (uuid1.uuid, uuid2.uuid) == 0 ? PDF_TRUE : PDF_FALSE); +} + +/* End of pdf-types-uuid.c */ === added file 'src/base/pdf-types-uuid.h' --- src/base/pdf-types-uuid.h 1970-01-01 00:00:00 +0000 +++ src/base/pdf-types-uuid.h 2011-03-24 17:58:36 +0000 @@ -0,0 +1,76 @@ +/* -*- mode: C -*- + * + * File: pdf-types-uuid.h + * Date: Tue Feb 8 16:48:00 2011 + * + * GNU PDF Library - UUID generation and utilities + * + */ + +/* Copyright (C) 2011 Free Software Foundation, Inc. */ + +/* 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 3 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, see <http://www.gnu.org/licenses/>. + */ + +#ifndef PDF_TYPES_UUID_H +#define PDF_TYPES_UUID_H + +#include <config.h> + +/* BEGIN PUBLIC */ + +#include <uuid/uuid.h> + +/* END PUBLIC */ + +#include <pdf-types.h> + +#define PDF_UUID_SIZE 46 + +/* BEGIN PUBLIC */ + +/* Types of UUIDs */ +/* Currently only time-based and random-based UUIDs are supported */ +enum pdf_uuid_type_e +{ + /* Time-based */ + PDF_UUID_TIME, + /* Random-based */ + PDF_UUID_RANDOM +}; + +struct pdf_uuid_s +{ + uuid_t uuid; +}; + +typedef struct pdf_uuid_s pdf_uuid_t; + +/* UUID creation */ +pdf_uuid_t pdf_uuid_generate (enum pdf_uuid_type_e type); + +/* Printed ASCII representation of an UUID */ +pdf_char_t * pdf_uuid_string (pdf_uuid_t uuid, + pdf_char_t * buffer, + pdf_size_t buffer_size); + +/* Determine if two UUIDs are equal */ +pdf_bool_t pdf_uuid_equal_p (pdf_uuid_t uuid1, + pdf_uuid_t uuid2); + +/* END PUBLIC */ + +#endif /* !PDF_TYPES_UUID_H */ + +/* End of pdf-types-uuid.h */ # Begin bundle IyBCYXphYXIgcmV2aXNpb24gYnVuZGxlIHY0CiMKQlpoOTFBWSZTWSWc7X0AB5t/jF4zCDB8d/// /+/fvr////4gAAgAYA+c32665oHOYoAAAGwwJzuO20B3d0pAKUmsoBbN4SSVPU8alP0Sfko9qPVP yo/Q1PVNNGnqeU9RoG0ID1B6gZGgABKKFPDQkNqaNNpNA0Mg0ABkAxGgDQGgAOGhoyaNGjTQyMhh AGQAyDTQAAMgZAEiJCNNNI0Jmo01PRk2SI/SZqjIGI8kwIBo0M1MIOGhoyaNGjTQyMhhAGQAyDTQ AAMgZAEkgCBMjIJhAmmjTKp49T0pMZI9TIHqaB+qADT1Mi4SLEdQ53GeNr08Sp1lzRA+CChPwmWm zg7PDwY8D8eO9ejE6VrJ+UYGeq3R0w8eTJSJ44MphyEP3vb2IWlYsXbTiRtL3m0yeL2qTo1aWsQl AGGK/WC8US6Ng0TD6CAgdl4HV2ODWwj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