Changeset 14


Ignore:
Timestamp:
May 3, 2013, 7:18:10 PM (12 years ago)
Author:
Alex Taylor
Message:

Added RPUPortInfo function.

Location:
rxprtutl/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified rxprtutl/trunk/notes

    r13 r14  
    1818      To convert <number> to USHORT:  ushort = REVERSE( X2C( D2X( number, 4 )))
    1919      To convert <number> to ULONG:   ulong  = REVERSE( X2C( D2X( number, 8 )))
     20
     21      Fixed-length string (character array) fields MUST append a 0 byte to
     22      the end of the string value, and SHOULD pad the rest of the array (up
     23      to the defined length) with 0 bytes as well.
    2024
    2125
     
    183187  END
    184188
     189(At least version 1.03 of SMB.PDR is required.)
     190
  • TabularUnified rxprtutl/trunk/rxprtutl.c

    r13 r14  
    132132    "RPUPortDelete",
    133133    "RPUPortDialog",
     134    "RPUPortInfo",
    134135    "RPUPortInstall",
    135136    "RPUPortQuery",
     
    155156RexxFunctionHandler RPUPortDelete;
    156157RexxFunctionHandler RPUPortDialog;
     158RexxFunctionHandler RPUPortInfo;
    157159RexxFunctionHandler RPUPortInstall;
    158160RexxFunctionHandler RPUPortQuery;
     
    770772
    771773/* ------------------------------------------------------------------------- *
     774 * RPUPortInfo                                                               *
     775 *                                                                           *
     776 * Queries basic information about a local port.  This is different from     *
     777 * RPUPortQuery() in that the latter returns port configuration information  *
     778 * from the port driver itself, whereas this function only returns what the  *
     779 * spooler itself knows about the port.                                      *
     780 *                                                                           *
     781 * REXX ARGUMENTS:                                                           *
     782 *   1. The name of the port.                                     (REQUIRED) *
     783 *   2. The name of the stem in which to return the results:      (REQUIRED) *
     784 *      (stem).!name       The name of the port                              *
     785 *      (stem).!driver     The name of the port driver                       *
     786 *      (stem).!converter  The name of the protocol converter used           *
     787 *                                                                           *
     788 * REXX RETURN VALUE:                                                        *
     789 *   1 on success, or 0 if an error occurred.                                *
     790 * ------------------------------------------------------------------------- */
     791ULONG APIENTRY RPUPortInfo( PSZ pszName, ULONG argc, RXSTRING argv[], PSZ pszQueue, PRXSTRING prsResult )
     792{
     793    PPRPORTINFO2 pInfo      = NULL;
     794    PVOID        pbuf       = NULL;
     795    ULONG        cbBuf      = 0,
     796                 cbNeeded   = 0;
     797    CHAR         szStem[ US_STEM_MAXZ ];   // compound variable stem name
     798    PSZ          pszPortName;
     799    SPLERR       rc;
     800
     801
     802    // Reset the error indicator
     803    WriteErrorCode( 0, NULL );
     804
     805    // Validate the REXX arguments
     806    if (( argc != 2 ) ||
     807        ( ! RXVALIDSTRING( argv[0] )) || ( ! RXVALIDSTRING( argv[1] )))
     808        return ( 40 );
     809
     810    pszPortName = argv[0].strptr;
     811
     812    // Initialize the result stem name
     813    if ( RXSTRLEN(argv[1]) > US_STEM_MAXZ ) return ( 40 );
     814    if ( argv[1].strptr[ argv[1].strlength-1 ] == '.') argv[1].strlength--;
     815    strncpy( szStem, argv[1].strptr, RXSTRLEN( argv[1] ));
     816    szStem[ RXSTRLEN( argv[1] ) ] = '\0';
     817
     818
     819    // Query the amount of available data
     820    rc = SplQueryPort( NULL, pszPortName, 2L, NULL, 0L, &cbNeeded );
     821    if (( rc != ERROR_MORE_DATA ) && ( rc != NERR_BufTooSmall ))
     822    {
     823        WriteErrorCode( rc, "SplQueryPort");
     824        MAKERXSTRING( *prsResult, "0", 1 );
     825        return ( 0 );
     826    }
     827
     828    // Now get the actual data
     829    pbuf = malloc( cbNeeded );
     830    if ( !pbuf ) {
     831        WriteErrorCode( ERROR_NOT_ENOUGH_MEMORY, "malloc");
     832        MAKERXSTRING( *prsResult, "0", 1 );
     833        return ( 0 );
     834    }
     835    cbBuf = cbNeeded;
     836    rc = SplQueryPort( NULL, pszPortName, 2L, pbuf, cbBuf, &cbNeeded );
     837    if ( rc == NO_ERROR ) {
     838        pInfo = (PPRPORTINFO2) pbuf;
     839        WriteCompoundVariable( szStem, "!name",      pInfo->pszPortName );
     840        WriteCompoundVariable( szStem, "!driver",    pInfo->pszPortDriver );
     841        WriteCompoundVariable( szStem, "!converter", pInfo->pszProtocolConverter );
     842        MAKERXSTRING( *prsResult, "1", 1 );
     843    }
     844    else {
     845        WriteErrorCode( rc, "SplQueryPort");
     846        MAKERXSTRING( *prsResult, "0", 1 );
     847    }
     848
     849    free( pbuf );
     850    return ( 0 );
     851}
     852
     853
     854/* ------------------------------------------------------------------------- *
    772855 * RPUPortInstall                                                            *
    773856 *                                                                           *
     
    14221505
    14231506    pszDeviceName = argv[0].strptr;
    1424 //printf("Device: \"%s\"\n", pszDeviceName );
    14251507
    14261508    // Initialize the result stem name
  • TabularUnified rxprtutl/trunk/rxprtutl.def

    r13 r14  
    11LIBRARY     RXPRTUTL INITINSTANCE TERMINSTANCE
    22DATA        MULTIPLE NONSHARED
    3 DESCRIPTION '@#Alex Taylor:0.2.2#@##1## 1 May 2013 18:18:54      REINFORCE::::::@@REXX Printer Management Utilities'
     3DESCRIPTION '@#Alex Taylor:0.2.2#@##1## 3 May 2013 12:46:17      REINFORCE::::::@@REXX Printer Management Utilities'
    44
    55EXPORTS     RPULoadFuncs
     
    1212RPUPortDelete
    1313RPUPortDialog
     14RPUPortInfo
    1415RPUPortInstall
    1516RPUPortQuery
Note: See TracChangeset for help on using the changeset viewer.