Ignore:
Timestamp:
Jan 24, 2013, 2:25:43 AM (13 years ago)
Author:
Alex Taylor
Message:

Auto-port numbers now generated in base 10 instead of base 4.
Implemented SplPdQuery/SplPdSet entrypoints, which are required for programs to create/configure ports.
Added sample program which demonstrates this (smbport.c). Added BLDLEVEL signature (uses MAKEDESC.CMD).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/smbpdr-1.0/smb.c

    r422 r758  
    5959#include    <process.h>
    6060#include    "SMB.h"
     61
     62#define BIDI_SET_PORTDRV    0x00000019
     63#define BIDI_Q_PORTDRV      0x00008019
     64
    6165
    6266/* Password encryption/decryption routines from ndpsmb.c */
     
    493497        while ( (i < MAX_PORTS) && fPortExists )
    494498        {
    495                 _itoa( i, pszEndPortName, 4);
     499                _itoa( i, pszEndPortName, 10);
    496500                fPortExists = PrfQueryProfileString (HINI_SYSTEMPROFILE,
    497501                                                                                        APPNAME_PM_SPOOLER_PORT,
     
    931935
    932936}
     937#if 1
     938ULONG  APIENTRY SplPdQuery ( PSZ    pszPortName,
     939                             ULONG  ulFlags,
     940                             ULONG  ulCommand,
     941                             PVOID  pInData,
     942                             ULONG  cbInData,
     943                             PVOID  pOutData,
     944                             PULONG pcbOutData )
     945{
     946    PPORTSETTINGS pSettings;
     947    CHAR          szAppName[ STR_LEN_PORTNAME ];
     948    ULONG         rc;
     949
     950    // Generate appname for "PM_SMBx"
     951    strcpy( szAppName, APPNAME_LEAD_STR);
     952    strncat( szAppName, pszPortName, STR_LEN_PORTNAME-1 );
     953
     954    switch ( ulCommand ) {
     955
     956        case BIDI_Q_PORTDRV:
     957            // Make sure the data is valid
     958            if ( !pOutData || *pcbOutData < sizeof( PORTSETTINGS ))
     959                return( ERROR_INVALID_PARAMETER );
     960            pSettings = (PPORTSETTINGS) pOutData;
     961
     962            PrfQueryProfileString( HINI_SYSTEMPROFILE, szAppName,
     963                                   KEY_INITIALIZATION, NULL,
     964                                   pSettings->szPortData, STR_LEN_PORTDESC );
     965            *pcbOutData = sizeof( PORTSETTINGS );
     966            rc = NO_ERROR;
     967            break;
     968
     969        default:
     970            rc = ERROR_NOT_SUPPORTED;
     971            //rc = NO_ERROR;
     972            break;
     973    }
     974
     975   return ( rc );
     976}
     977ULONG  APIENTRY SplPdSet   ( PSZ    pszPortName,
     978                             ULONG  ulFlags,
     979                             ULONG  ulCommand,
     980                             PVOID  pInData,
     981                             ULONG  cbInData )
     982{
     983    PPORTSETTINGS pSettings;
     984    CHAR          szIniStr[ STR_LEN_PORTDESC ] = {0};
     985    CHAR          szAppName[ STR_LEN_PORTNAME ];
     986    PSZ           token;
     987    ULONG         rc;
     988
     989    // Generate appname for "PM_CUPSx"
     990    strcpy( szAppName, APPNAME_LEAD_STR);
     991    strncat( szAppName, pszPortName, STR_LEN_PORTNAME-1 );
     992
     993    switch ( ulCommand ) {
     994
     995        case BIDI_SET_PORTDRV:
     996            // Validate the data
     997            if ( !pInData || cbInData < sizeof( PORTSETTINGS ))
     998                return( ERROR_INVALID_PARAMETER );
     999            pSettings = (PPORTSETTINGS) pInData;
     1000            // Update the INITIALIZATION string
     1001            PrfWriteProfileString( HINI_SYSTEMPROFILE, szAppName,
     1002                                   KEY_INITIALIZATION, pSettings->szPortData );
     1003            PrfWriteProfileString( HINI_SYSTEMPROFILE, APPNAME_PM_SPOOLER_PORT,
     1004                                   pszPortName, pSettings->szPortData );
     1005            // Update the DESCRIPTION string
     1006            if (( token = lprtok( pSettings->szPortData, "#")) != NULL ) {
     1007                strncpy( szIniStr, token, STR_LEN_PORTDESC-1 );
     1008                if (( token = lprtok( NULL, "#")) != NULL ) {
     1009                    if ( token[ strlen(token) - 1 ] == ';')
     1010                        token[ strlen(token) - 1 ] = '\0';
     1011                    strncat( szIniStr, ":", STR_LEN_PORTDESC-1 );
     1012                    strncat( szIniStr, token, STR_LEN_PORTDESC-1 );
     1013                }
     1014            }
     1015            PrfWriteProfileString( HINI_SYSTEMPROFILE,
     1016                                   szAppName, KEY_DESCRIPTION, szIniStr );
     1017            rc = NO_ERROR;
     1018            break;
     1019
     1020        default:
     1021            //rc = ERROR_NOT_SUPPORTED;
     1022            rc = NO_ERROR;
     1023            break;
     1024    }
     1025    return ( rc );
     1026
     1027}
     1028#else
    9331029ULONG  APIENTRY SplPdQuery ( PSZ    pszDeviceName,
    9341030                                                        ULONG  ulFlags,
     
    9511047        return NO_ERROR;
    9521048}
     1049#endif
    9531050ULONG  APIENTRY SplPdNewPage ( HFILE  hFile, ULONG ulPageNumber )
    9541051{
Note: See TracChangeset for help on using the changeset viewer.