pdf-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[pdf-devel] Error module patches


From: gerel
Subject: [pdf-devel] Error module patches
Date: Sun, 24 Feb 2008 18:32:16 -0300

Well, Here are the modified patches before committed. 

Thanks everyone for your help.


--- pdf-error.h ---
/*
 *
 *       File:         pdf-error.h
 *       Date:         Sun Feb  24 20:22:05 2008
 *
 *       GNU PDF Library - Header file for the Error module
 *
 */

/* Copyright (C) 2007, 2008 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/>.
 */

/* Time-stamp: <2008-02-23 19:07:30 gerel> */

#ifndef PDF_ERROR_H
#define PDF_ERROR_H

#ifdef HAVE_DEBUG_BASE
#define PDF_DEBUG_BASE(message, ...) \
  pdf_error (0, stderr, "***DEBUG BASE***:%s:%d: " message, \
  __FILE__, __LINE__, __VA_ARGS__)
#else
#define PDF_DEBUG_BASE ""
#endif /* HAVE_DEBUG_BASE */

#ifdef HAVE_DEBUG_OBJECT
#define PDF_DEBUG_OBJECT(message, ...) \
  pdf_error (0, stderr, "***DEBUG OBJECT***:%s:%d: " message, \
  __FILE__, __LINE__, __VA_ARGS__)
#else
#define PDF_DEBUG_OBJECT ""
#endif /* HAVE_DEBUG_OBJECT */

#ifdef HAVE_DEBUG_DOCUMENT
#define PDF_DEBUG_DOCUMENT(message, ...) \
  pdf_error (0, stderr, "***DEBUG DOCUMENT***:%s:%d: " message, \
  __FILE__, __LINE__, __VA_ARGS__)
#else
#define PDF_DEBUG_DOCUMENT ""
#endif /* HAVE_DEBUG_DOCUMENT */

#ifdef HAVE_DEBUG_PAGE
#define PDF_DEBUG_PAGE(message, ...) \
  pdf_error (0, stderr, "***DEBUG PAGE***:%s:%d: " message, \
  __FILE__, __LINE__, __VA_ARGS__)
#else
#define PDF_DEBUG_PAGE ""
#endif /* HAVE_DEBUG_PAGE */


/* TODO: add missing status codes */
typedef enum 
{
        PDF_OK = 0,
        PDF_ERROR,
        PDF_EBADDATA,
        PDF_ENOMEM,
        PDF_EEOF,
        PDF_EDIVBYZERO,
        PDF_ENONODE,
        PDF_EINVRANGE,
        PDF_ETEXTENC,
        PDF_ENOMATCH,
        PDF_STATUS_ITEMS
} pdf_status_t;

extern const char * pdf_error_stlist [];

/* Print a message with `fprintf (fd, FORMAT, ...)';
   if status is nonzero, print the corresponding message. */
extern void pdf_error (pdf_status_t status, FILE * fd, const char *format, ...);

/* Print the message corresponding to 'status' to stderr
 * followed by 'str'.
 */
extern void pdf_perror (pdf_status_t status, const char *str);

#endif /* PDF_ERROR_H */

--- EOF pdf-error.h ---


--- pdf-error.c ---
/*
 *
 *       File:         pdf-error.c
 *       Date:         Sun Feb  24 20:22:05 2008
 *
 *       GNU PDF Library - Implementation for the Error module
 *
 */

/* Copyright (C) 2007, 2008 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/>.
 */

/* Time-stamp: <2008-02-23 19:09:59 gerel> */

#include <config.h>

#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>

#include <pdf-global.h>
#include <pdf-error.h>

/* Update this list according to pdf_status_t. */
const char * pdf_error_stlist [] =
  {
          "error",
          "invalid or bad arguments",
          "insufficient memory",
          "end of file",
          "divison by zero",
          "no node found",
          "invalid range",
          "error in text encoding",
          "no matching found"
  };


void
pdf_perror (pdf_status_t status, const char *str)
{ 
  pdf_error ((int) status, stderr, str);
}


void
pdf_error (pdf_status_t status, FILE * fd, const char *format, ...)
{
  va_list args;
  int errnum;

  errnum = (int) status;
  
  fprintf (fd, "%s", program_name);

  if (format != NULL)
    {
      fprintf (fd, ": ");
      va_start (args, format);
      vfprintf (fd, format, args);
      va_end (args);
    }

  if (errnum >  0 && errnum < PDF_STATUS_ITEMS)
    fprintf (fd, ": %s", pdf_error_stlist[errnum-1]);
  
  fprintf (fd, ".\n");
  fflush (fd);

}


--- EOF pdf-error.c ---


--- ChangeLog ---
Index: ChangeLog
===================================================================
RCS file: /sources/pdf/libgnupdf/ChangeLog,v
retrieving revision 1.141
diff -u -r1.141 ChangeLog
--- ChangeLog   24 Feb 2008 17:23:16 -0000      1.141
+++ ChangeLog   24 Feb 2008 21:28:58 -0000
@@ -1,3 +1,7 @@
+2008-02-24  gerel  <address@hidden>
+
+       * src/base/pdf-error.[ch] (Error management): added first 
implementation.
+
 2008-02-24  Jose E. Marchesi  <address@hidden>

        * doc/gnupdf-tsd.texi: New file.

--- EOF ChangeLog ---


--- src/Makefile.am ---
Index: src/Makefile.am
===================================================================
RCS file: /sources/pdf/libgnupdf/src/Makefile.am,v
retrieving revision 1.35
diff -u -r1.35 Makefile.am
--- src/Makefile.am     22 Feb 2008 21:57:52 -0000      1.35
+++ src/Makefile.am     24 Feb 2008 21:31:23 -0000
@@ -27,6 +27,8 @@
 
 TYPES_MODULE_SOURCES = base/pdf-types.c base/pdf-types.h
 
+ERROR_MODULE_SOURCES = base/pdf-error.c base/pdf-error.h
+
 STM_MODULE_SOURCES = base/pdf-stm-f-a85.c base/pdf-stm-f-a85.h \
                      base/pdf-stm-f-ahex.c base/pdf-stm-f-ahex.h \
                      base/pdf-stm-f-fax.c base/pdf-stm-f-fax.h \
@@ -44,8 +46,8 @@
 BASE_LAYER_SOURCES = base/pdf-base.c base/pdf-base.h \
                      $(ALLOC_MODULE_SOURCES) \
                      $(TYPES_MODULE_SOURCES) \
-                     $(STM_MODULE_SOURCES)
-
+                     $(STM_MODULE_SOURCES) \
+                     $(ERROR_MODULE_SOURCES)
 # Library sources
 
 libgnupdf_la_SOURCES = pdf-global.c pdf-global.h
@@ -77,7 +79,8 @@
               base/pdf-stm-f-pred.h \
               base/pdf-stm-f-rl.h \
               base/pdf-stm-file.h \
-              base/pdf-stm.h
+              base/pdf-stm.h \
+              base/pdf-error.h
 
 pdf.h : $(PUBLIC_HDRS)
        chmod +x $(top_srcdir)/src/extract-public-hdr

--- EOF src/Makefile.am ---


--- AUTHORS ---
Index: AUTHORS
===================================================================
RCS file: /sources/pdf/libgnupdf/AUTHORS,v
retrieving revision 1.7
diff -u -r1.7 AUTHORS
--- AUTHORS     16 Nov 2007 16:10:54 -0000      1.7
+++ AUTHORS     24 Feb 2008 21:32:50 -0000
@@ -36,3 +36,5 @@
   torture/test-obj_createdestroy.c torture/test-obj_dict.c
   torture/test-obj_dupequality.c torture/test-rectangle.c
   torture/test-stm_openclose.c
+
+Gerdardo E. Gidoni: src/base/pdf-error.c, src/base/pdf-error.h

--- EOF AUTHORS ---


BTW, I'm not sure about src/Makefile.am, I hope it's ok.

cheers

-gerel




reply via email to

[Prev in Thread] Current Thread [Next in Thread]