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.
This commit is contained in:
Viktor Szakats
2010-04-23 12:32:44 +00:00
parent 6194ef871d
commit 1fb1a8abc6
3 changed files with 47 additions and 2 deletions

View File

@@ -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.

View File

@@ -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 );
}

View File

@@ -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