From 1fb1a8abc6c40fd3f5204fb2e8c1c8f10e0e3cc5 Mon Sep 17 00:00:00 2001 From: Viktor Szakats Date: Fri, 23 Apr 2010 12:32:44 +0000 Subject: [PATCH] 2010-04-23 14:29 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbcups/hbcups.c * contrib/hbcups/tests/test.prg + CUPSPRINTFILE(): Added support for addition 'options' parameter. It can be an array of option strings or a hash table with option name/value pairs. --- harbour/ChangeLog | 7 +++++ harbour/contrib/hbcups/hbcups.c | 39 ++++++++++++++++++++++++++- harbour/contrib/hbcups/tests/test.prg | 3 ++- 3 files changed, 47 insertions(+), 2 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a22beedaa1..f440db8011 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,13 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-04-23 14:29 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) + * contrib/hbcups/hbcups.c + * contrib/hbcups/tests/test.prg + + CUPSPRINTFILE(): Added support for addition 'options' + parameter. It can be an array of option strings or + a hash table with option name/value pairs. + 2010-04-23 13:07 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * contrib/hbmysql/readme.txt ! More or less updated this text. diff --git a/harbour/contrib/hbcups/hbcups.c b/harbour/contrib/hbcups/hbcups.c index 40c193e819..f22170effe 100644 --- a/harbour/contrib/hbcups/hbcups.c +++ b/harbour/contrib/hbcups/hbcups.c @@ -82,7 +82,44 @@ HB_FUNC( CUPSGETDESTS ) HB_FUNC( CUPSPRINTFILE ) { + PHB_ITEM pOptions = hb_param( 4, HB_IT_HASH | HB_IT_ARRAY ); + + int num_options = 0; + cups_option_t * options = NULL; + + if( pOptions ) + { + int tmp; + + if( HB_IS_HASH( pOptions ) ) + { + for( tmp = 0; tmp < hb_hashLen( pOptions ); ++tmp ) + { + PHB_ITEM pKey = hb_hashGetKeyAt( pOptions, tmp + 1 ); + PHB_ITEM pVal = hb_hashGetValueAt( pOptions, tmp + 1 ); + + if( pKey && HB_IS_STRING( pKey ) && + pVal && HB_IS_STRING( pVal ) ) + num_options = cupsAddOption( hb_itemGetCPtr( pKey ), hb_itemGetCPtr( pVal ), num_options, &options ); + } + } + else if( HB_IS_ARRAY( pOptions ) ) + { + for( tmp = 0; tmp < hb_arrayLen( pOptions ); ++tmp ) + { + const char * pszOption = hb_arrayGetCPtr( pOptions, tmp + 1 ); + + if( pszOption ) + num_options = cupsParseOptions( pszOption, num_options, &options ); + } + } + } + hb_retni( cupsPrintFile( hb_parcx( 1 ) /* printername */, hb_parcx( 2 ) /* filename */, - hb_parcx( 3 ) /* title */, 0, NULL ) ); + hb_parcx( 3 ) /* title */, + num_options, + options ) ); + + cupsFreeOptions( num_options, options ); } diff --git a/harbour/contrib/hbcups/tests/test.prg b/harbour/contrib/hbcups/tests/test.prg index 975be0b8d7..69256b3112 100644 --- a/harbour/contrib/hbcups/tests/test.prg +++ b/harbour/contrib/hbcups/tests/test.prg @@ -11,6 +11,7 @@ PROCEDURE Main() ? i:__enumIndex(), i NEXT - ? "Printing... Job ID:", cupsPrintFile( cupsGetDefault(), "test.prg", "Harbour CUPS Printing" ) + ? "Printing... Job ID:", cupsPrintFile( cupsGetDefault(), "test.prg", "Harbour CUPS Printing", { "sides=one-sided" } ) +/* ? "Printing... Job ID:", cupsPrintFile( cupsGetDefault(), "test.prg", "Harbour CUPS Printing", { "sides" => "one-sided" } ) */ RETURN