From 4d02ecd18b8149583bb8194c5cc94b1a8afdda94 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Mon, 7 Mar 2011 11:54:38 +0000 Subject: [PATCH] 2011-03-07 12:53 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * INSTALL * contrib/hbplist + contrib/hbgs + contrib/hbgs/core.c + contrib/hbgs/hbgs.hbx + contrib/hbgs/hbgs.hbp + contrib/hbgs/hbgs.hbc + contrib/hbgs/tests + contrib/hbgs/tests/testgs.prg + contrib/hbgs/tests/hbmk.hbm + Added basic, high-level Ghostscript wrapper. (only tested on win/win64) --- harbour/ChangeLog | 14 ++++ harbour/INSTALL | 4 + harbour/contrib/hbgs/core.c | 101 ++++++++++++++++++++++++++ harbour/contrib/hbgs/hbgs.hbc | 7 ++ harbour/contrib/hbgs/hbgs.hbp | 23 ++++++ harbour/contrib/hbgs/hbgs.hbx | 34 +++++++++ harbour/contrib/hbgs/tests/hbmk.hbm | 7 ++ harbour/contrib/hbgs/tests/testgs.prg | 19 +++++ harbour/contrib/hbplist | 1 + 9 files changed, 210 insertions(+) create mode 100644 harbour/contrib/hbgs/core.c create mode 100644 harbour/contrib/hbgs/hbgs.hbc create mode 100644 harbour/contrib/hbgs/hbgs.hbp create mode 100644 harbour/contrib/hbgs/hbgs.hbx create mode 100644 harbour/contrib/hbgs/tests/hbmk.hbm create mode 100644 harbour/contrib/hbgs/tests/testgs.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 507c0c7d2f..8aacea5f74 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,20 @@ The license applies to all entries newer than 2009-04-28. */ +2011-03-07 12:53 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) + * INSTALL + * contrib/hbplist + + contrib/hbgs + + contrib/hbgs/core.c + + contrib/hbgs/hbgs.hbx + + contrib/hbgs/hbgs.hbp + + contrib/hbgs/hbgs.hbc + + contrib/hbgs/tests + + contrib/hbgs/tests/testgs.prg + + contrib/hbgs/tests/hbmk.hbm + + Added basic, high-level Ghostscript wrapper. + (only tested on win/win64) + 2011-03-07 12:44 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/src/rtl/valtype.c * modified to work with any HB_IT_STRING flags we may add in the future diff --git a/harbour/INSTALL b/harbour/INSTALL index 0ddaa606eb..58c91d3575 100644 --- a/harbour/INSTALL +++ b/harbour/INSTALL @@ -341,6 +341,8 @@ HARBOUR HB_WITH_FREEIMAGE=C:\FreeImage\Dist HB_WITH_GD=C:\gd\include HB_WITH_GPM= (on Linux only) + HB_WITH_GS=C:\ghostscript-9.01\psi + HB_WITH_GS_BIN=C:\ghostscript-9.01\bin (on Windows) HB_WITH_JPEG=C:\jpeglib (defaults to locally hosted version if not found) HB_WITH_LIBHARU=C:\libharu\include (defaults to locally hosted version) HB_WITH_LIBMAGIC= (currently on *nix systems) @@ -1510,6 +1512,8 @@ HARBOUR http://freeimage.sourceforge.net/ HB_WITH_GD - GD Graphics Library [multiplatform, free, open-source] http://www.boutell.com/gd/ + HB_WITH_GS - Ghostscript [multiplatform, free, open-source] + http://pages.cs.wisc.edu/~ghost/ HB_WITH_JPEG - jpeglib [multiplatform, free, open-source] http://www.ijg.org/ HB_WITH_LIBHARU - libharu (PDF creation) [multiplatform, free, open-source] diff --git a/harbour/contrib/hbgs/core.c b/harbour/contrib/hbgs/core.c new file mode 100644 index 0000000000..1a9f6ba52b --- /dev/null +++ b/harbour/contrib/hbgs/core.c @@ -0,0 +1,101 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Ghostscript high-level API + * + * Copyright 2011 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + * 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, 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 software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ + +#include "hbapi.h" + +#if defined( HB_OS_WIN ) && ! defined( _Windows ) +# define _Windows +# include +# define GSDLLEXPORT __declspec( dllimport ) +#endif + +#include "ierrors.h" +#include "iapi.h" + +HB_FUNC( HB_GS ) +{ + HB_BOOL bResult = HB_FALSE; + PHB_ITEM pParam = hb_param( 1, HB_IT_ARRAY ); + + if( pParam ) + { + void * minst; + int gsargc = ( int ) hb_arrayLen( pParam ) + 1; + int pos; + int code, code1; + char ** gsargv = ( char ** ) hb_xgrab( gsargc * sizeof( const char * ) ); + + gsargv[ 0 ] = "hbgs"; /* actual value doesn't matter */ + + for( pos = 1; pos < gsargc; ++pos ) + { + const char * pszParam = hb_arrayGetCPtr( pParam, pos ); + gsargv[ pos ] = ( char * ) ( pszParam ? pszParam : "" ); + } + + code = gsapi_new_instance( &minst, NULL ); + if( code >= 0 ) + { + code = gsapi_init_with_args( minst, gsargc, gsargv ); + code1 = gsapi_exit( minst ); + + if( ( code == 0 ) || ( code == e_Quit ) ) + code = code1; + + gsapi_delete_instance( minst ); + + bResult = ( code == 0 || code == e_Quit ); + } + } + + hb_retl( bResult ); +} diff --git a/harbour/contrib/hbgs/hbgs.hbc b/harbour/contrib/hbgs/hbgs.hbc new file mode 100644 index 0000000000..8b26bc4d7b --- /dev/null +++ b/harbour/contrib/hbgs/hbgs.hbc @@ -0,0 +1,7 @@ +# +# $Id$ +# + +libs=${_HB_DYNPREF}${hb_name}${_HB_DYNSUFF} + +libs=gs diff --git a/harbour/contrib/hbgs/hbgs.hbp b/harbour/contrib/hbgs/hbgs.hbp new file mode 100644 index 0000000000..7540e5f782 --- /dev/null +++ b/harbour/contrib/hbgs/hbgs.hbp @@ -0,0 +1,23 @@ +# +# $Id$ +# + +-hblib +-inc + +-o${hb_name} + +-w3 -es2 + +-depoptional=gs:yes +-depkeyhead=gs:iapi.h +-depcontrol=gs:${HB_WITH_GS} +-depimplibs=gs:${HB_WITH_GS_BIN}/gsdll32.dll{win&&x86} +-depimplibs=gs:${HB_WITH_GS_BIN}/gsdll64.dll{win&&x86_64} +-depimplibd=gs:gs + +-instfile=inc:hbgs.hbx + +hbgs.hbx + +core.c diff --git a/harbour/contrib/hbgs/hbgs.hbx b/harbour/contrib/hbgs/hbgs.hbx new file mode 100644 index 0000000000..6650c538a7 --- /dev/null +++ b/harbour/contrib/hbgs/hbgs.hbx @@ -0,0 +1,34 @@ +/* + * $Id$ + */ + +/* -------------------------------------------------------------------- */ +/* NOTE: You can add manual override which functions to include or */ +/* exclude from automatically generated EXTERNAL/DYNAMIC list. */ +/* Syntax: // HB_FUNC_INCLUDE */ +/* // HB_FUNC_EXCLUDE */ +/* -------------------------------------------------------------------- */ + +/* -------------------------------------------------------------------- */ +/* WARNING: Automatically generated code below. DO NOT EDIT! */ +/* Regenerate using hbmk2 '-hbx=' option. */ +/* -------------------------------------------------------------------- */ + +#ifndef __HBEXTERN_CH__HBGS__ +#define __HBEXTERN_CH__HBGS__ + +#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBGS__ANNOUNCE ) + ANNOUNCE __HBEXTERN__HBGS__ +#endif + +#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBGS__REQUEST ) + #command DYNAMIC => EXTERNAL +#endif + +DYNAMIC HB_GS + +#if defined( __HBEXTREQ__ ) .OR. defined( __HBEXTERN__HBGS__REQUEST ) + #uncommand DYNAMIC => EXTERNAL +#endif + +#endif diff --git a/harbour/contrib/hbgs/tests/hbmk.hbm b/harbour/contrib/hbgs/tests/hbmk.hbm new file mode 100644 index 0000000000..b3b5e961ea --- /dev/null +++ b/harbour/contrib/hbgs/tests/hbmk.hbm @@ -0,0 +1,7 @@ +# +# $Id$ +# + +../hbgs.hbc + +-w3 -es2 diff --git a/harbour/contrib/hbgs/tests/testgs.prg b/harbour/contrib/hbgs/tests/testgs.prg new file mode 100644 index 0000000000..6232604c64 --- /dev/null +++ b/harbour/contrib/hbgs/tests/testgs.prg @@ -0,0 +1,19 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * + * Copyright 2011 Viktor Szakats (harbour.01 syenar.hu) + * www - http://harbour-project.org + * + */ + +#include "simpleio.ch" + +PROCEDURE Main() + + ? HB_GS( { "--version" } ) + + RETURN diff --git a/harbour/contrib/hbplist b/harbour/contrib/hbplist index dc4c698ff5..6bdba6719c 100644 --- a/harbour/contrib/hbplist +++ b/harbour/contrib/hbplist @@ -21,6 +21,7 @@ hbformat/utils/hbformat.hbp hbfoxpro/hbfoxpro.hbp hbfship/hbfship.hbp hbgd/hbgd.hbp +hbgs/hbgs.hbp hbgt/hbgt.hbp hbhpdf/hbhpdf.hbp # uses: libhpdf (locally hosted) hbhttpd/hbhttpd.hbp