Changeset 177


Ignore:
Timestamp:
Apr 18, 2009, 12:09:06 PM (16 years ago)
Author:
Herwig Bauernfeind
Message:

Alex Taylors fixes for Tickets #79/#80/#81/#82/#83/#84

Location:
branches/smbpdr-1.0
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • branches/smbpdr-1.0/build.cmd

    r175 r177  
    44RC -r smb.RC smb.RES
    55gcc -Zdll -Zbin-files -Zomf -o smb.pdr smb.o smb.def smb.res
     6ea2 -e DEFAULT_PORT=SMB smb.pdr
    67rem d:
    78rem cd \OS2\DLL
  • branches/smbpdr-1.0/changelog

    r175 r177  
     1Version 1.0-RC5    14-04-2009 (Update by Alex Taylor)
     2  +Added:   The port description (seen on the "Output Port" properties page)
     3            now shows the workgroup\server\printer name.
     4  *Changed: The "install new port" dialog no longer shows up to 64 SMB port
     5            icons (as long as SMB.PDR has its EAs intact.)
     6  *Changed: Removed the "send as binary file" checkbox (it did nothing anyway).
     7  !Fixed:   Population of values in properties dialog sometimes failed if there were empty fields.
     8  !Fixed:   PostScript header no longer forcibly written into the spooled file.
     9  !Fixed:   Default description is now correctly loaded from resources.
     10
    111Version 1.0-RC4    14-03-2009
    2                              +Added: Support for smbspool.exe's copies option
    3                                      (this only makes sense in case there is
    4                                      no other way to print multiple copies of
    5                                      a document using options provided by
    6                                      applications or printer drivers).
     12  +Added: Support for smbspool.exe's copies option (this only makes sense in
     13          case there is no other way to print multiple copies of a document
     14          using options provided by applications or printer drivers).
     15         
    716Version 1.0-RC3    13-03-2009
    8                              +Added: Created an "Abort, Retry" message box
    9                                      with an appropriate loop.
    10                              *Changed: "Save properties" into "OK"
    11                              *Changed: Settings dialogue not system-modal
    12                                        anymore
     17  +Added: Created an "Abort, Retry" message box with an appropriate loop.
     18  *Changed: "Save properties" into "OK"
     19  *Changed: Settings dialogue not system-modal anymore
     20 
    1321Version 1.0-RC2    12-03-2009
    14                              +Added: Show message box in case an error occured.
     22  +Added: Show message box in case an error occured.
     23 
    1524Version 1.0-RC1    11-03-2009
    16                              +Added: Support workgroup
    17                              +Added: Support authentication
    18                              *Changed: Nicer icon
     25  +Added: Support workgroup
     26  +Added: Support authentication
     27  *Changed: Nicer icon
     28
    1929Version 1.0-beta.2 09-03-2009
    20                              !Fixed: Could not print to slow or sleeping
    21                                      devices
     30  !Fixed: Could not print to slow or sleeping devices.
     31
    2232Version 1.0-beta.1 08-03-2009
    23                              Made Pauls code based upon Serge Sterck's
    24                              lpr32.pdr source workable. (Guest hardcoded,
    25                              no authentication, no error checking)
     33  Made Paul Smedleys code based upon Serge Sterck's lpr32.pdr source workable
     34  (Guest hardcoded, no authentication, no error checking).
  • branches/smbpdr-1.0/makefile

    r175 r177  
    1 # Makefile for VAC (doesn't work at the moment)
    21BASE=SMB
     2DEF_PORTNAME=SMB
    33
    44ICCOPTS=-Gd-e- -Sp1 -Ss+ -Ms -C+ -Fo$@ -Dcdecl= -D_cdecl= -Rn -O -Wpro -Q+ -Yp+ -Ss+
     
    1010!ENDIF
    1111
    12 $(BASE).PDR:                    $(BASE).OBJ \
     12$(BASE).PDR:                    $(BASE).DLL
     13        copy $(BASE).DLL $(BASE).PDR
     14        del $(BASE).DLL
     15
     16$(BASE).DLL:                    $(BASE).OBJ \
    1317                                $(BASE).RES
    1418        ILINK $(LINKOPTS) @<<
    1519$(BASE)
    16 $(BASE).PDR
     20$(BASE).DLL
    1721$(BASE)
    1822OS2386
    1923$(BASE)
    2024<<
    21         RC $(BASE).RES $(BASE).PDR
     25        RC $(BASE).RES $(BASE).DLL
     26        ea2 -e DEFAULT_PORT=$(DEF_PORTNAME) $(BASE).DLL
    2227
    2328$(BASE).RES:                    $(BASE).RC \
     
    2833                                $(BASE).H
    2934        ICC $(ICCOPTS) $(BASE).C
     35
     36clean:
     37        if exist $(BASE).PDR del $(BASE).PDR
     38        if exist $(BASE).DLL del $(BASE).DLL
     39        if exist $(BASE).SYM del $(BASE).SYM
     40        if exist $(BASE).MAP del $(BASE).MAP
     41        if exist $(BASE).RES del $(BASE).RES
     42        if exist $(BASE).OBJ del $(BASE).OBJ
  • branches/smbpdr-1.0/readme.smbpdr

    r175 r177  
    1 CIFS/SMB port driver for eCS (OS/2) Version 1.0-RC4-20090314
     1CIFS/SMB port driver for eCS (OS/2) Version 1.0-RC5-20090416
    22============================================================
    33
     
    66able to create a working port driver to access remote printers shared via
    77CIFS/SMB (this is Samba, Windows ...).
     8
     9This release has several problems/omissions/enhancements fixed by Alex Taylor
     10(see changelog).
    811
    912Prerequisites:
     
    5558Have fun!
    5659
    57 Herwig Bauernfeind, March 2009
     60Herwig Bauernfeind, April 2009
  • branches/smbpdr-1.0/smb.c

    r175 r177  
    6666        if ('0' <= c && c <= '9')
    6767        {
    68                  return c - '0';
     68                return c - '0';
    6969        }
    7070       
    7171        if ('A' <= c && c <= 'F')
    7272        {
    73                  return c - 'A' + 0xA;
     73                return c - 'A' + 0xA;
    7474        }
    7575       
    7676        if ('a' <= c && c <= 'f')
    7777        {
    78                  return c - 'a' + 0xA;
     78                return c - 'a' + 0xA;
    7979        }
    8080       
     
    143143} PORTNAMES, *PPORTNAMES;
    144144
     145/* Alex Taylor's new version of lprtok() that can handle missing fields */
    145146char * lprtok (char *string,char *control)
    146147{
    147                 unsigned char *str;
    148                 const unsigned char *ctrl = control;
    149 
    150                 unsigned char map[32];
    151                 int count;
    152 
    153                 static char *nextoken;
    154 
    155                 for (count = 0; count < 32; count++)
    156                                 map[count] = 0;
    157 
    158                 do {
    159                                 map[*ctrl >> 3] |= (1 << (*ctrl & 7));
    160                 } while (*ctrl++);
    161 
    162                 if (string)
    163                                 str = string;
    164                 else
    165                                 str = nextoken;
    166 
    167                 while ( (map[*str >> 3] & (1 << (*str & 7))) && *str )
    168                                 str++;
    169 
    170                 string = str;
    171 
    172                 for ( ; *str ; str++ )
    173                                 if ( map[*str >> 3] & (1 << (*str & 7)) ) {
    174                                                 *str++ = '\0';
    175                                                 break;
    176                                 }
    177 
    178                 nextoken = str;
    179 
    180                 /* Determine if a token has been found. */
    181                 if ( string == str )
    182                                 return NULL;
    183                 else
    184                                 return string;
     148        char *c;
     149        static char *next;
     150
     151        if ( control == NULL ) return string;
     152        if ( string  == NULL ) string = next;
     153        if ( string  == NULL ) return NULL;
     154
     155        if (( c = strpbrk( string, control )) == NULL ) {
     156                next = NULL;
     157        }
     158        else {
     159                next = c+1;
     160                *c = '\0';
     161        }
     162
     163        return ( string );
    185164}
    186165MRESULT EXPENTRY CommDlg( HWND hDlg, USHORT msg, MPARAM mp1, MPARAM mp2 )
     
    188167        PLPRDATA    pLprData;
    189168        ULONG       ulTimeOut = 0 ;
    190         CHAR        szDesc[ STR_LEN_PORTDESC];
     169        CHAR        szDesc[ STR_LEN_PORTDESC ];
     170        CHAR        szShareName[ STR_LEN_PORTDESC ];
    191171        CHAR        szTitle[ STR_LEN_TITLE + 1];
    192172        CHAR        szTemp[ STR_LEN_PORTDESC ];
     
    276256                        {
    277257                                case DID_OK:
     258                                        sprintf(szDesc,"\\");
    278259                                        /* Servername | IP */
    279260                                        WinQueryDlgItemText (hDlg, ID_IP, sizeof(szTemp), szTemp );
    280261                                        sprintf(pLprData->szSaveLprSetting,"%s",szTemp);
     262                                        strncpy(szShareName, szTemp, STR_LEN_PORTDESC - 1);
    281263                                        /* Printername | Queue */
    282264                                        WinQueryDlgItemText (hDlg, ID_SMBQUEUE, sizeof(szTemp), szTemp );
    283265                                        strcat(pLprData->szSaveLprSetting,"#");
    284266                                        strcat(pLprData->szSaveLprSetting,szTemp);
     267                                        if (strlen(szTemp) > 0) {
     268                                                strncat(szShareName, "\\", STR_LEN_PORTDESC - 1);
     269                                                strncat(szShareName, szTemp, STR_LEN_PORTDESC - 1);
     270                                        }
    285271                                        /* Workgroup */
    286272                                        WinQueryDlgItemText (hDlg, ID_WORKGROUP, sizeof(szTemp), szTemp );
    287273                                        strcat(pLprData->szSaveLprSetting,"#");
    288274                                        strcat(pLprData->szSaveLprSetting,szTemp);
     275                                        if (strlen(szTemp) > 0) {
     276                                                strncat(szDesc, "\\", STR_LEN_PORTDESC - 1);
     277                                                strncat(szDesc, szTemp, STR_LEN_PORTDESC - 1);
     278                                        }
     279                                        strncat(szDesc, "\\", STR_LEN_PORTDESC - 1);
     280                                        strncat(szDesc, szShareName, STR_LEN_PORTDESC - 1);
    289281                                        /* Username */
    290282                                        WinQueryDlgItemText (hDlg, ID_USER, sizeof(szTemp), szTemp );
     
    301293                                        encryptPassword(pwBuffer,szTemp);
    302294                                        strcat(pLprData->szSaveLprSetting,szTemp);
    303                                        
     295
    304296                                        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    305297                                                                                                pLprData->pszAppName,
     
    312304                                                                                                pLprData->pszPortName,
    313305                                                                                                pLprData->szSaveLprSetting))
    314                                         WinDismissDlg(hDlg, MBID_CANCEL);
     306                                                WinDismissDlg(hDlg, MBID_CANCEL);
     307
     308                                        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     309                                                                                                pLprData->pszAppName,
     310                                                                                                KEY_DESCRIPTION,
     311                                                                                                szDesc ))
     312                                                WinDismissDlg(hDlg, MBID_CANCEL);
     313
    315314                                        WinDismissDlg(hDlg, TRUE);
    316315                                        break;
     
    321320                        break;
    322321                default:
    323                     return WinDefDlgProc(hDlg, msg, mp1, mp2) ;
    324                     break;
    325      }
    326  return FALSE;
     322                        return WinDefDlgProc(hDlg, msg, mp1, mp2) ;
     323                        break;
     324        }
     325return FALSE;
    327326}
    328327ULONG CalcStructLength ( HAB hab,
    329                                                  HMODULE hModule,
    330                                                  USHORT usID )
    331 {
    332    ULONG cbRequired;
    333    CHAR  chString[STR_LEN_PORTDESC];
    334 
    335    cbRequired = 0;
    336 
    337    WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, chString);
    338    cbRequired += strlen (chString) + 1;
    339    WinLoadString(hab, hModule, (USHORT)(usID + 1), STR_LEN_PORTDESC, chString);
    340    cbRequired += strlen (chString) + 1;
    341    cbRequired += sizeof (PORTNAMES);
    342    return(cbRequired);
     328                                                HMODULE hModule,
     329                                                USHORT usID )
     330{
     331        ULONG cbRequired;
     332        CHAR  chString[STR_LEN_PORTDESC];
     333
     334        cbRequired = 0;
     335
     336        WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, chString);
     337        cbRequired += strlen (chString) + 1;
     338        WinLoadString(hab, hModule, (USHORT)(usID + 1), STR_LEN_PORTDESC, chString);
     339        cbRequired += strlen (chString) + 1;
     340        cbRequired += sizeof (PORTNAMES);
     341        return(cbRequired);
    343342}
    344343
     
    346345                                                HMODULE hModule )
    347346{
    348    ULONG  cbRequired;
    349    USHORT usID;
    350 
    351    cbRequired = 0;
     347        ULONG  cbRequired;
     348        USHORT usID;
     349
     350        cbRequired = 0;
    352351
    353352                /*
    354353                ** calculate length required to fit all the port info.
    355354                */
    356    for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2)
    357    {
     355        for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2)
     356        {
    358357                cbRequired += CalcStructLength (hab, hModule, usID);
    359    }
    360 
    361    return(cbRequired);
     358        }
     359
     360        return(cbRequired);
    362361}
    363362
     
    366365                                                ULONG cbBuf )
    367366{
    368    ULONG  cbRequired;
    369    USHORT usID;
    370    ULONG  ulNumPort;
    371 
    372    cbRequired = 0;
    373    ulNumPort = 0;
     367        ULONG  cbRequired;
     368        USHORT usID;
     369        ULONG  ulNumPort;
     370
     371        cbRequired = 0;
     372        ulNumPort = 0;
    374373
    375374                /*
    376375                ** calculate how many ports we can fit in buf.
    377376                */
    378    for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2)
    379    {
     377        for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2)
     378        {
    380379                cbRequired += CalcStructLength (hab, hModule, usID);
    381380                if (cbRequired > cbBuf)
    382381                {
    383                  return(ulNumPort);
     382                return(ulNumPort);
    384383                }
    385384                ulNumPort++;
    386    }
    387 
    388    return(ulNumPort);
     385        }
     386
     387        return(ulNumPort);
    389388}
    390389VOID CopyStruct ( HAB hab,
    391                                   HMODULE hModule,
    392                                   USHORT usID,
    393                                   PCH pBuf,
    394                                   PULONG pulBeginStruct,
    395                                   PULONG pulBeginText )
    396 {
    397    PPORTNAMES pPortNames;
    398 
    399    pPortNames = (PPORTNAMES)(pBuf + *pulBeginStruct);
    400    *pulBeginStruct += sizeof (PORTNAMES);
     390                                        HMODULE hModule,
     391                                        USHORT usID,
     392                                        PCH pBuf,
     393                                        PULONG pulBeginStruct,
     394                                        PULONG pulBeginText )
     395{
     396        PPORTNAMES pPortNames;
     397
     398        pPortNames = (PPORTNAMES)(pBuf + *pulBeginStruct);
     399        *pulBeginStruct += sizeof (PORTNAMES);
    401400
    402401                /*
    403402                ** copy port name in the structure
    404403                */
    405    pPortNames->pszPortName = pBuf + *pulBeginText;
    406    WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, pPortNames->pszPortName);
    407    *pulBeginText += strlen (pPortNames->pszPortName) + 1;
     404        pPortNames->pszPortName = pBuf + *pulBeginText;
     405        WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, pPortNames->pszPortName);
     406        *pulBeginText += strlen (pPortNames->pszPortName) + 1;
    408407
    409408                /*
    410409                ** copy port description to the structure
    411410                */
    412    pPortNames->pszPortDesc = pBuf + *pulBeginText;
    413    WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, pPortNames->pszPortDesc);
    414    *pulBeginText += strlen (pPortNames->pszPortDesc) + 1;
     411        pPortNames->pszPortDesc = pBuf + *pulBeginText;
     412        WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, pPortNames->pszPortDesc);
     413        *pulBeginText += strlen (pPortNames->pszPortDesc) + 1;
    415414}
    416415VOID  CopyNPorts ( HAB hab,
    417                                    HMODULE hModule,
    418                                    PCH pBuf,
    419                                    ULONG ulReturned )
    420 {
    421    USHORT usID;
    422    ULONG  ulBeginText;
    423    ULONG  ulBeginStruct;
    424 
    425    ulBeginText = ulReturned * sizeof (PORTNAMES);
    426    ulBeginStruct = 0;
    427 
    428    for (usID = PORT_ID_FIRST;
     416                                        HMODULE hModule,
     417                                        PCH pBuf,
     418                                        ULONG ulReturned )
     419{
     420        USHORT usID;
     421        ULONG  ulBeginText;
     422        ULONG  ulBeginStruct;
     423
     424        ulBeginText = ulReturned * sizeof (PORTNAMES);
     425        ulBeginStruct = 0;
     426
     427        for (usID = PORT_ID_FIRST;
    429428                usID <= PORT_ID_LAST && ulReturned;
    430429                usID += 2, --ulReturned)
    431    {
     430        {
    432431                CopyStruct (hab, hModule, usID, pBuf, &ulBeginStruct, &ulBeginText);
    433    }
     432        }
    434433}
    435434
     
    439438                                                PSZ pszAppName )
    440439{
    441    LPRDATA LprData;
    442 
    443    memset (&LprData, 0, sizeof (LPRDATA));
    444    LprData.hAB = hab;
    445    LprData.hModule = hModule;
    446    LprData.pszPortName = pszPortName;
    447    LprData.pszAppName = pszAppName;
    448 
    449    WinDlgBox  (HWND_DESKTOP,
     440        LPRDATA LprData;
     441
     442        memset (&LprData, 0, sizeof (LPRDATA));
     443        LprData.hAB = hab;
     444        LprData.hModule = hModule;
     445        LprData.pszPortName = pszPortName;
     446        LprData.pszAppName = pszAppName;
     447
     448        WinDlgBox  (HWND_DESKTOP,
    450449                                HWND_DESKTOP,
    451450                                (PFNWP)CommDlg,
     
    454453                                &LprData);
    455454
    456    return LprData.lfModified;
     455        return LprData.lfModified;
    457456}
    458457BOOL GetPortDescription ( HAB hab,
    459                                                   HMODULE hModule,
    460                                                   PSZ pszPortName,
    461                                                   PSZ pszPortDesc )
     458                                                        HMODULE hModule,
     459                                                        PSZ pszPortName,
     460                                                        PSZ pszPortDesc )
    462461{
    463462        USHORT usID;
    464         CHAR    chBuf[STR_LEN_PORTDESC];
     463        CHAR   chBuf[STR_LEN_PORTDESC] = {0};
    465464
    466465        for (usID = PORT_ID_FIRST; usID <= PORT_ID_LAST; usID += 2)
    467466        {
    468                 WinLoadString(hab, hModule, usID, STR_LEN_PORTDESC, chBuf);
     467                WinLoadString(hab, hModule, usID, STR_LEN_PORTNAME, chBuf);
    469468                if (!strcmp (pszPortName, chBuf))
    470469                {
     470                if ( WinLoadString(hab, hModule, usID+1, STR_LEN_PORTDESC, chBuf) ) {
    471471                        strcpy (pszPortDesc, chBuf);
    472472                        return(TRUE);
    473473                }
     474                break;
     475                }
    474476        }
    475477        return(FALSE);
     478}
     479BOOL  GenerateUniquePortName( PSZ pszPortName )
     480{
     481        BOOL   fPortExists;
     482        PSZ    pszEndPortName;
     483        USHORT i;
     484        CHAR   chPortData[STR_LEN_PORTNAME];
     485
     486        /*
     487        ** Generate a unique port name by adding numbers to the
     488        **   end of pszPortName
     489        */
     490        pszEndPortName = pszPortName + strlen( pszPortName );
     491        i = 1;
     492        fPortExists = TRUE;
     493        while ( (i < MAX_PORTS) && fPortExists )
     494        {
     495                _itoa( i, pszEndPortName, 4);
     496                fPortExists = PrfQueryProfileString (HINI_SYSTEMPROFILE,
     497                                                                                        APPNAME_PM_SPOOLER_PORT,
     498                                                                                        pszPortName,
     499                                                                                        NULL,
     500                                                                                        chPortData,
     501                                                                                        sizeof(chPortData) - 1);
     502                i++;
     503        }
     504        return(!fPortExists);
    476505}
    477506APIRET APIENTRY SplPdEnumPort ( HAB hab,
     
    484513{
    485514        HMODULE hModule;
    486         ULONG   ulBootDrive;
    487         ULONG   rcLoadMod;
    488         CHAR    szPathName[260];
     515        ULONG   ulBootDrive;
     516        ULONG   rcLoadMod;
     517        CHAR    szPathName[260];
    489518
    490519        if (!pulReturned ||
     
    501530
    502531        DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
    503                                          sizeof (ULONG));
     532                                        sizeof (ULONG));
    504533        szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
    505534
    506535        PrfQueryProfileString (HINI_SYSTEMPROFILE,
    507                                                   "PM_PORT_DRIVER",
    508                                                   "SMB",
    509                                                   szDefaultPortDrvPath,
    510                                                   szPathName,
    511                                                   256 );
     536                                                        "PM_PORT_DRIVER",
     537                                                        "SMB",
     538                                                        szDefaultPortDrvPath,
     539                                                        szPathName,
     540                                                        256 );
    512541
    513542        rcLoadMod = DosLoadModule (NULL, 0, szPathName, &hModule);
     
    517546                *pulReturned = 0;
    518547                *pcbRequired = CalcBufLength (hab, hModule);
    519                 *pulTotal = 64;                         /* Currently support LPRx x = 1 .. 9     */
     548                *pulTotal = MAX_PORTS;
    520549                if (!rcLoadMod)
    521550                DosFreeModule (hModule);
     
    526555                ** check number of ports info we can fit in supplied buffer
    527556                */
    528         *pulTotal    = 64;                              /* Currently support LPRx x= 1 .. 9      */
     557        *pulTotal    = MAX_PORTS;
    529558        *pcbRequired = CalcBufLength (hab, hModule);
    530559        *pulReturned = NumPortsCanFit (hab, hModule, cbBuf);
     
    536565        {
    537566                if (!rcLoadMod)
    538                  DosFreeModule (hModule);
     567                DosFreeModule (hModule);
    539568                return(ERROR_INSUFFICIENT_BUFFER);
    540569        }
     
    549578                */
    550579        if (!rcLoadMod)
    551           DosFreeModule (hModule);
     580                DosFreeModule (hModule);
    552581
    553582                /*
     
    562591}
    563592APIRET APIENTRY SplPdInstallPort ( HAB hab,
    564                                                                    PSZ pszPortName )
    565 {
    566    CHAR    chBuf[STR_LEN_PORTNAME];
    567    CHAR    chPortDesc[STR_LEN_PORTDESC];
    568    ULONG   ulBootDrive;
    569    HMODULE hModule;
    570    CHAR    szPathName[260];    /* will contain full path to this port driver */
    571 
    572    if (!pszPortName)
    573    {
    574                 return(ERROR_INVALID_PARAMETER);
    575    }
    576    strcpy(szDefaultPortDrvPath,PATH_SMB_PDR);
    577    DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
    578                                     sizeof (ULONG));
    579    szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
    580 
    581    PrfWriteProfileString (HINI_SYSTEMPROFILE,
    582                                                   "PM_PORT_DRIVER",
    583                                                   "SMB",
    584                                                   szDefaultPortDrvPath);
    585    hModule = 0L ;                                                    /* Init module handle to null */
    586    DosLoadModule (NULL, 0, szPathName, &hModule);
    587    if (!GetPortDescription (hab, hModule, pszPortName, chPortDesc))
    588    {
     593                                                                        PSZ pszPortName )
     594{
     595        CHAR    chBuf[STR_LEN_PORTNAME];
     596        CHAR    chPortDesc[STR_LEN_PORTDESC];
     597        ULONG   ulBootDrive;
     598        HMODULE hModule;
     599        CHAR    szPathName[260];    /* will contain full path to this port driver */
     600
     601        if (!pszPortName)
     602        {
     603                return(ERROR_INVALID_PARAMETER);
     604        }
     605        strcpy(szDefaultPortDrvPath,PATH_SMB_PDR);
     606        DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
     607                                        sizeof (ULONG));
     608        szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
     609        strcpy( szPathName, szDefaultPortDrvPath );
     610
     611        /* Make sure the port driver itself is installed */
     612        PrfWriteProfileString (HINI_SYSTEMPROFILE,
     613                                                        "PM_PORT_DRIVER",
     614                                                        "SMB",
     615                                                        szDefaultPortDrvPath);
     616
     617        /* Generate appname for "PM_SMBx" */
     618        strcpy (chBuf, APPNAME_LEAD_STR);
     619        strcat (chBuf, pszPortName);
     620
     621        /*
     622        ** Check for this being our default Port Name to install.
     623        ** If so (pszPortName == "SMB") then generate a unique
     624        **   port name so that we can install multiple SMB printers.
     625        */
     626        if (!strcmp(pszPortName, DEF_PORTNAME))
     627        {
     628                /*
     629                ** Use chBuf to store the new portname to install
     630                ** Must first increment past "PM_" in chBuf
     631                */
     632                pszPortName = chBuf + 3;
     633                GenerateUniquePortName( pszPortName );
     634        }
     635
     636        /* Get initial port description (fall back to portname if unavailable) */
     637        hModule = 0L ;                            /* Init module handle to null */
     638        DosLoadModule (NULL, 0, szPathName, &hModule);
     639        if (!GetPortDescription (hab, hModule, pszPortName, chPortDesc))
     640        {
    589641                strcpy( chPortDesc, pszPortName );
    590    }
    591    DosFreeModule (hModule);
    592    strcpy (chBuf, APPNAME_LEAD_STR);
    593    strcat (chBuf, pszPortName);
    594    if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     642        }
     643        DosFreeModule (hModule);
     644
     645        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    595646                                                                chBuf,
    596647                                                                KEY_DESCRIPTION,
    597648                                                                chPortDesc))
    598    {
     649        {
    599650                return (WinGetLastError (hab));
    600    }
    601 
    602    if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     651        }
     652
     653        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    603654                                                                chBuf,
    604655                                                                KEY_INITIALIZATION,
    605656                                                                DEF_INITIALIZATION))
    606    {
     657        {
    607658                return (WinGetLastError (hab));
    608    }
    609 
    610    if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     659        }
     660
     661        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    611662                                                                chBuf,
    612663                                                                KEY_TERMINATION,
    613664                                                                DEF_TERMINATION))
    614    {
     665        {
    615666                return (WinGetLastError (hab));
    616    }
    617 
    618    if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     667        }
     668
     669        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    619670                                                                chBuf,
    620671                                                                KEY_PORTDRIVER,
    621672                                                                DEF_PORTDRIVER))
    622    {
     673        {
    623674                return (WinGetLastError (hab));
    624    }
    625 
    626    if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     675        }
     676
     677        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    627678                                                                chBuf,
    628679                                                                KEY_TIMEOUT,
    629680                                                                DEF_TIMEOUT))
    630    {
     681        {
    631682                return (WinGetLastError (hab));
    632    }
    633    if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
     683        }
     684        if (!PrfWriteProfileString (HINI_SYSTEMPROFILE,
    634685                                                                APPNAME_PM_SPOOLER_PORT,
    635686                                                                pszPortName,
    636687                                                                DEF_INITIALIZATION))
    637    {
     688        {
    638689                return (WinGetLastError (hab));
    639    }
    640    return(NO_ERROR);
     690        }
     691        return(NO_ERROR);
    641692}
    642693BOOL   APIENTRY SplPdGetPortIcon ( HAB hab,
    643                                                                    PULONG idIcon )
    644 {
    645    if (idIcon)
    646    {
     694                                                                        PULONG idIcon )
     695{
     696        if (idIcon)
     697        {
    647698                *idIcon = SMB_ICON;
    648    }
    649    return(TRUE);
     699        }
     700        return(TRUE);
    650701}
    651702APIRET APIENTRY SplPdQueryPort ( HAB hab,
    652                                                                  PSZ pszPortName,
    653                                                                  PVOID pBufIn,
    654                                                                  ULONG cbBuf,
    655                                                                  PULONG cItems )
    656 {
    657    HMODULE hModule;
    658    CHAR    chString[STR_LEN_DESC];
    659    USHORT  usNumLines;
    660    USHORT  usLineID;
    661    USHORT  usStrLength;
    662    ULONG   ulBootDrive;
    663    PCH     pBuf = pBufIn;
    664    CHAR    szPathName[260];    /* will contain full path to this port driver */
    665 
    666    if (!cItems)
    667    {
    668                 return(ERROR_INVALID_PARAMETER);
    669    }
    670 
    671    if (!pBuf || !cbBuf)
    672    {
    673                 return(ERROR_INVALID_PARAMETER);
    674    }
    675 
    676 
    677    DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
    678                                     sizeof (ULONG));
    679    szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
    680 
    681    PrfQueryProfileString (HINI_SYSTEMPROFILE,
    682                                                   "PM_PORT_DRIVER",
    683                                                   "SMB",
    684                                                   szDefaultPortDrvPath,
    685                                                   szPathName,
    686                                                   256 );
    687 
    688    hModule = 0L ;
    689 
    690    DosLoadModule (NULL, 0, szPathName, &hModule);
    691 
    692    chString[0] = '\0' ;
    693 
    694    WinLoadString(hab, hModule, (USHORT)ID_NUMBER_OF_DESC_LINES, STR_LEN_DESC,
    695                                  chString);
    696    usNumLines = (USHORT)atoi (chString);
    697    usLineID = ID_FIRST_DESC_LINES;
    698    for (*cItems = 0; *cItems < usNumLines; *cItems++)
    699    {
     703                                                                PSZ pszPortName,
     704                                                                PVOID pBufIn,
     705                                                                ULONG cbBuf,
     706                                                                PULONG cItems )
     707{
     708        HMODULE hModule;
     709        CHAR    chString[STR_LEN_DESC];
     710        USHORT  usNumLines;
     711        USHORT  usLineID;
     712        USHORT  usStrLength;
     713        ULONG   ulBootDrive;
     714        PCH     pBuf = pBufIn;
     715        CHAR    szPathName[260];    /* will contain full path to this port driver */
     716
     717        if (!cItems)
     718        {
     719                return(ERROR_INVALID_PARAMETER);
     720        }
     721
     722        if (!pBuf || !cbBuf)
     723        {
     724                return(ERROR_INVALID_PARAMETER);
     725        }
     726
     727
     728        DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
     729                                        sizeof (ULONG));
     730        szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
     731
     732        PrfQueryProfileString (HINI_SYSTEMPROFILE,
     733                                                        "PM_PORT_DRIVER",
     734                                                        "SMB",
     735                                                        szDefaultPortDrvPath,
     736                                                        szPathName,
     737                                                        256 );
     738
     739        hModule = 0L ;
     740
     741        DosLoadModule (NULL, 0, szPathName, &hModule);
     742
     743        chString[0] = '\0' ;
     744
     745        WinLoadString(hab, hModule, (USHORT)ID_NUMBER_OF_DESC_LINES, STR_LEN_DESC,
     746                                chString);
     747        usNumLines = (USHORT)atoi (chString);
     748        usLineID = ID_FIRST_DESC_LINES;
     749        for (*cItems = 0; *cItems < usNumLines; *cItems++)
     750        {
    700751                WinLoadString(hab, hModule, usLineID, STR_LEN_DESC, chString);
    701752                if (cbBuf >= (usStrLength = (USHORT)(strlen (chString) + 1)))
    702753                {
    703                  strcpy (pBuf, chString);
    704                  pBuf += usStrLength;
    705                  cbBuf -= usStrLength;
     754                strcpy (pBuf, chString);
     755                pBuf += usStrLength;
     756                cbBuf -= usStrLength;
    706757                }
    707758                else
    708759                {
    709                  DosFreeModule (hModule);
    710                  return(ERROR_INSUFFICIENT_BUFFER);
     760                DosFreeModule (hModule);
     761                return(ERROR_INSUFFICIENT_BUFFER);
    711762                }
    712    }
    713    DosFreeModule (hModule);
    714    return(NO_ERROR);
     763        }
     764        DosFreeModule (hModule);
     765        return(NO_ERROR);
    715766}
    716767APIRET APIENTRY SplPdSetPort ( HAB hab,
     
    718769                                                                PULONG flModified )
    719770{
    720     CHAR    chBuf[STR_LEN_PORTNAME];
    721     CHAR    chPortDriver[STR_LEN_PORTNAME];
    722     ULONG   ulBootDrive;
    723     HMODULE hModule;
    724     CHAR    szPathName[260];   /* will contain full path to this port driver */
    725 
    726    if (!pszPortName || !flModified)
    727    {
    728                 return(ERROR_INVALID_PARAMETER);
    729    }
    730 
    731    strcpy (chBuf, APPNAME_LEAD_STR);
    732    strcat (chBuf, pszPortName);
    733 
    734    if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf,
     771        CHAR    chBuf[STR_LEN_PORTNAME];
     772        CHAR    chPortDriver[STR_LEN_PORTNAME];
     773        ULONG   ulBootDrive;
     774        HMODULE hModule;
     775        CHAR    szPathName[260];   /* will contain full path to this port driver */
     776
     777        if (!pszPortName || !flModified)
     778        {
     779                return(ERROR_INVALID_PARAMETER);
     780        }
     781
     782        strcpy (chBuf, APPNAME_LEAD_STR);
     783        strcat (chBuf, pszPortName);
     784
     785        if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf,
    735786                                                                KEY_PORTDRIVER, NULL, chPortDriver,
    736787                                                                STR_LEN_PORTNAME)))
    737    {
    738                 return(ERROR_INVALID_PARAMETER);
    739    }
    740 
    741    if (strcmp (chPortDriver, DEF_PORTDRIVER))
    742    {
    743                 return(ERROR_INVALID_PARAMETER);
    744    }
    745 
    746    DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
    747                                     sizeof (ULONG));
    748    szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
    749 
    750    PrfQueryProfileString (HINI_SYSTEMPROFILE,
    751                                                   "PM_PORT_DRIVER",
    752                                                   "SMB",
    753                                                   szDefaultPortDrvPath,
    754                                                   szPathName,
    755                                                   256 );
    756 
    757    hModule = 0L ;                                                               /* Init module handle to null */
    758 
    759    DosLoadModule (NULL, 0, szPathName, &hModule);
    760 
    761    *flModified = OpenLprPortDlg (hab, hModule, pszPortName, chBuf);
    762 
    763    DosFreeModule (hModule);
    764    return(NO_ERROR);
     788        {
     789                return(ERROR_INVALID_PARAMETER);
     790        }
     791
     792        if (strcmp (chPortDriver, DEF_PORTDRIVER))
     793        {
     794                return(ERROR_INVALID_PARAMETER);
     795        }
     796
     797        DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
     798                                        sizeof (ULONG));
     799        szDefaultPortDrvPath[0] = (CHAR)(ulBootDrive + 'A' - 1);
     800
     801        PrfQueryProfileString (HINI_SYSTEMPROFILE,
     802                                                        "PM_PORT_DRIVER",
     803                                                        "SMB",
     804                                                        szDefaultPortDrvPath,
     805                                                        szPathName,
     806                                                        256 );
     807
     808        hModule = 0L ;                               /* Init module handle to null */
     809
     810        DosLoadModule (NULL, 0, szPathName, &hModule);
     811
     812        *flModified = OpenLprPortDlg (hab, hModule, pszPortName, chBuf);
     813
     814        DosFreeModule (hModule);
     815        return(NO_ERROR);
    765816}
    766817
    767818
    768819APIRET APIENTRY SplPdRemovePort ( HAB hab,
    769                                                                   PSZ pszPortName )
    770 {
    771     CHAR chBuf[STR_LEN_PORTNAME];
    772     CHAR chPortDriver[STR_LEN_PORTNAME];
    773 
    774    if (!pszPortName)
    775    {
    776                 return(ERROR_INVALID_PARAMETER);
    777    }
    778 
    779    strcpy (chBuf, APPNAME_LEAD_STR);
    780    strcat (chBuf, pszPortName);
    781 
    782    if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf,
     820                                                                        PSZ pszPortName )
     821{
     822        CHAR chBuf[STR_LEN_PORTNAME];
     823        CHAR chPortDriver[STR_LEN_PORTNAME];
     824
     825        if (!pszPortName)
     826        {
     827                return(ERROR_INVALID_PARAMETER);
     828        }
     829
     830        strcpy (chBuf, APPNAME_LEAD_STR);
     831        strcat (chBuf, pszPortName);
     832
     833        if (!(PrfQueryProfileString (HINI_SYSTEMPROFILE, chBuf,
    783834                                                                KEY_PORTDRIVER, NULL, chPortDriver,
    784835                                                                STR_LEN_PORTNAME)))
    785    {
    786                 return(ERROR_INVALID_PARAMETER);
    787    }
    788 
    789    if (strcmp (chPortDriver, DEF_PORTDRIVER))
    790    {
    791                 return(ERROR_INVALID_PARAMETER);
    792    }
    793 
    794    PrfWriteProfileString (HINI_SYSTEMPROFILE, chBuf, NULL, NULL);
    795 
    796    PrfWriteProfileString (HINI_SYSTEMPROFILE,
    797                                                   APPNAME_PM_SPOOLER_PORT,
    798                                                   pszPortName,
    799                                                   NULL);
    800    return(NO_ERROR);
     836        {
     837                return(ERROR_INVALID_PARAMETER);
     838        }
     839
     840        if (strcmp (chPortDriver, DEF_PORTDRIVER))
     841        {
     842                return(ERROR_INVALID_PARAMETER);
     843        }
     844
     845        PrfWriteProfileString (HINI_SYSTEMPROFILE, chBuf, NULL, NULL);
     846
     847        PrfWriteProfileString (HINI_SYSTEMPROFILE,
     848                                                        APPNAME_PM_SPOOLER_PORT,
     849                                                        pszPortName,
     850                                                        NULL);
     851        return(NO_ERROR);
    801852
    802853}
    803854ULONG APIENTRY SplPdOpen( PSZ     pszPortName,
    804                                                   PHFILE  phFile,
    805                                                   PULONG  pDeviceFlags,
    806                                                   PVOID   pPrtOpenStruct)
    807 {
    808    APIRET rc;
    809    ULONG  ulAction       = 0;      /* Action taken by DosOpen */
    810    ULONG  ulBytesRead    = 0;      /* Number of bytes read by DosRead */
    811    ULONG  ulWrote               = 0;      /* Number of bytes written by DosWrite */
    812    ULONG  ulLocal               = 0;      /* File pointer position after DosSetFilePtr */
    813    CHAR   szTemp[ 256];
    814    UCHAR  tmp[256];
    815    ULONG  pcbWritten ;
    816    USHORT  i;
    817    HFILE   control;
    818    UCHAR  filename[256];
    819    DATETIME dt;
    820    UCHAR  spool_dir[256];
    821    PEAOP2 pEABuf = NULL;
    822    UCHAR           pszPSHeader[] = "%!PS-Adobe-3.0\n";
    823    ULONG                   cbHeader;
    824 
    825 
    826   if (!phFile || !pDeviceFlags )
    827   {
    828       return(ERROR_INVALID_PARAMETER);
    829   }
    830   DosGetDateTime(&dt);
    831   rc = PrfQueryProfileString (HINI_SYSTEMPROFILE,
    832                                                       "PM_SPOOLER",
    833                                                       "DIR",
    834                                                       NULL,
    835                                                       (PSZ)spool_dir,
    836                                                       sizeof(spool_dir));
    837   spool_dir[ strlen(spool_dir) - 1] = '\0';
    838   sprintf(tmp,"%s\\SMB",spool_dir);
    839   DosCreateDir( tmp,pEABuf );
    840   sprintf(filename,"%s\\SMB\\%02d_%02d_%02d_%02d_%s",spool_dir,dt.hours,dt.minutes,dt.seconds,dt.hundredths,pszPortName);
    841   rc = DosOpen(filename,
    842                        phFile,                                          /* File handle */
    843                        &ulAction,                                     /* Action taken */
    844                        100L,                                               /* File primary allocation */
    845                        FILE_ARCHIVED | FILE_NORMAL,    /* File attribute */
    846                        OPEN_ACTION_CREATE_IF_NEW |
    847                        OPEN_ACTION_OPEN_IF_EXISTS,     /* Open function type */
    848                        OPEN_FLAGS_NOINHERIT |
    849                        OPEN_SHARE_DENYNONE  |
    850                        OPEN_ACCESS_READWRITE,             /* Open mode of the file */
    851                        0L);                                                 /* No extended attribute */
    852   DosWrite(*phFile,pszPSHeader,strlen(pszPSHeader),&cbHeader);
    853   sprintf(szTemp,"PM_%s",pszPortName);
    854   if (PrfQueryProfileString (HINI_SYSTEMPROFILE,
    855                                                      szTemp,
    856                                                      KEY_INITIALIZATION,
    857                                                      NULL,
    858                                                      szTemp,
    859                                                      sizeof(szTemp)))
    860    {
    861       sprintf(tmp   ,"%s\\SMB\\%d.control",spool_dir,*phFile);
    862       rc = DosOpen( tmp    ,
    863                                    &control,                                            /* File handle */
    864                                    &ulAction,                                 /* Action taken */
    865                                    strlen(szTemp),                              /* File primary allocation */
    866                                    FILE_ARCHIVED | FILE_NORMAL,    /* File attribute */
    867                                    OPEN_ACTION_CREATE_IF_NEW |
    868                                    OPEN_ACTION_OPEN_IF_EXISTS,     /* Open function type */
    869                                    OPEN_FLAGS_NOINHERIT |
    870                                    OPEN_SHARE_DENYNONE  |
    871                                    OPEN_ACCESS_READWRITE,                 /* Open mode of the file */
    872                                    0L);                                             /* No extended attribute */
    873      rc = DosWrite( control,szTemp,strlen(szTemp),&pcbWritten);
    874      rc = DosWrite( control,"#",1,&pcbWritten);
    875      rc = DosWrite( control,filename,strlen(filename),&pcbWritten);
    876      rc = DosWrite( control,"@",1,&pcbWritten);
    877      rc = DosClose(control);
    878    }
    879  return rc;
     855                                                        PHFILE  phFile,
     856                                                        PULONG  pDeviceFlags,
     857                                                        PVOID   pPrtOpenStruct)
     858{
     859        APIRET rc;
     860        ULONG  ulAction       = 0;      /* Action taken by DosOpen */
     861        ULONG  ulBytesRead    = 0;      /* Number of bytes read by DosRead */
     862        ULONG  ulWrote       = 0;      /* Number of bytes written by DosWrite */
     863        ULONG  ulLocal       = 0;      /* File pointer position after DosSetFilePtr */
     864        CHAR   szTemp[ 256];
     865        UCHAR  tmp[256];
     866        ULONG  pcbWritten ;
     867        USHORT  i;
     868        HFILE   control;
     869        UCHAR  filename[256];
     870        DATETIME dt;
     871        UCHAR  spool_dir[256];
     872        PEAOP2 pEABuf = NULL;
     873/*   UCHAR       pszPSHeader[] = "%!PS-Adobe-3.0\n";
     874        ULONG           cbHeader;  */
     875
     876
     877        if (!phFile || !pDeviceFlags )
     878        {
     879                return(ERROR_INVALID_PARAMETER);
     880        }
     881        DosGetDateTime(&dt);
     882        rc = PrfQueryProfileString (HINI_SYSTEMPROFILE,
     883                                                                "PM_SPOOLER",
     884                                                                "DIR",
     885                                                                NULL,
     886                                                                (PSZ)spool_dir,
     887                                                                sizeof(spool_dir));
     888        spool_dir[ strlen(spool_dir) - 1] = '\0';
     889        sprintf(tmp,"%s\\SMB",spool_dir);
     890        DosCreateDir( tmp,pEABuf );
     891        sprintf(filename,"%s\\SMB\\%02d_%02d_%02d_%02d_%s",spool_dir,dt.hours,dt.minutes,dt.seconds,dt.hundredths,pszPortName);
     892        rc = DosOpen(filename,
     893                                phFile,                      /* File handle */
     894                                &ulAction,                     /* Action taken */
     895                                100L,                           /* File primary allocation */
     896                                FILE_ARCHIVED | FILE_NORMAL,    /* File attribute */
     897                                OPEN_ACTION_CREATE_IF_NEW |
     898                                OPEN_ACTION_OPEN_IF_EXISTS,     /* Open function type */
     899                                OPEN_FLAGS_NOINHERIT |
     900                                OPEN_SHARE_DENYNONE  |
     901                                OPEN_ACCESS_READWRITE,         /* Open mode of the file */
     902                                0L);                         /* No extended attribute */
     903/*  DosWrite(*phFile,pszPSHeader,strlen(pszPSHeader),&cbHeader);  */
     904        sprintf(szTemp,"PM_%s",pszPortName);
     905        if (PrfQueryProfileString (HINI_SYSTEMPROFILE,
     906                                                        szTemp,
     907                                                        KEY_INITIALIZATION,
     908                                                        NULL,
     909                                                        szTemp,
     910                                                        sizeof(szTemp)))
     911        {
     912                sprintf(tmp   ,"%s\\SMB\\%d.control",spool_dir,*phFile);
     913                rc = DosOpen( tmp    ,
     914                                        &control,                        /* File handle */
     915                                        &ulAction,                     /* Action taken */
     916                                        strlen(szTemp),              /* File primary allocation */
     917                                        FILE_ARCHIVED | FILE_NORMAL,    /* File attribute */
     918                                        OPEN_ACTION_CREATE_IF_NEW |
     919                                        OPEN_ACTION_OPEN_IF_EXISTS,     /* Open function type */
     920                                        OPEN_FLAGS_NOINHERIT |
     921                                        OPEN_SHARE_DENYNONE  |
     922                                        OPEN_ACCESS_READWRITE,         /* Open mode of the file */
     923                                        0L);                         /* No extended attribute */
     924        rc = DosWrite( control,szTemp,strlen(szTemp),&pcbWritten);
     925        rc = DosWrite( control,"#",1,&pcbWritten);
     926        rc = DosWrite( control,filename,strlen(filename),&pcbWritten);
     927        rc = DosWrite( control,"@",1,&pcbWritten);
     928        rc = DosClose(control);
     929        }
     930return rc;
    880931
    881932}
    882933ULONG  APIENTRY SplPdQuery ( PSZ    pszDeviceName,
    883                                                      ULONG  ulFlags,
    884                                                      ULONG  ulCommand,
    885                                                      PVOID  pInData,
    886                                                      ULONG  cbInData,
    887                                                      PVOID  pOutData,
    888                                                      PULONG pcbOutData )
    889 {
    890 /*      return ERROR_NOT_SUPPORTED; */
     934                                                        ULONG  ulFlags,
     935                                                        ULONG  ulCommand,
     936                                                        PVOID  pInData,
     937                                                        ULONG  cbInData,
     938                                                        PVOID  pOutData,
     939                                                        PULONG pcbOutData )
     940{
     941/*  return ERROR_NOT_SUPPORTED; */
    891942        return NO_ERROR;
    892943}
     
    9961047        szTemp[i] = '\0';
    9971048        strcpy(filename,&szTemp[pos]);
    998        
     1049
    9991050        rc = DosClose( hFile );
    10001051        DosQuerySysInfo (QSV_BOOT_DRIVE, QSV_BOOT_DRIVE, &ulBootDrive,
     
    10021053
    10031054        decryptPassword(password_enc,password_dec);
    1004        
     1055
    10051056// Usage: smbspool [DEVICE_URI] job-id user title copies options [file]
    10061057
     
    10111062        sprintf(j_title,"from %s",getenv("HOSTNAME"));
    10121063        sprintf(j_options,"opt");
    1013         rc = spawnlp(P_WAIT,binfile,binfile,j_url,j_id,j_user,j_title,j_copies,j_options,filename,NULL); 
    1014        
     1064        rc = spawnlp(P_WAIT,binfile,binfile,j_url,j_id,j_user,j_title,j_copies,j_options,filename,NULL);
     1065
    10151066        while (rc != 0)
    10161067        {
    10171068                sprintf(errorstr,"Error during spooling to smb://%s:****@%s/%s/%s",username,workgroup,ip_add,queue_name);
    1018                 resp = WinMessageBox (HWND_DESKTOP, 
    1019                                                         HWND_DESKTOP, 
    1020                                                         errorstr, 
     1069                resp = WinMessageBox (HWND_DESKTOP,
     1070                                                        HWND_DESKTOP,
     1071                                                        errorstr,
    10211072                                                        "CIFS/SMB Port driver error",
    10221073                                                        0L, MB_RETRYCANCEL | MB_WARNING | MB_MOVEABLE);
    1023                 if (resp != MBID_CANCEL ) 
     1074                if (resp != MBID_CANCEL )
    10241075                {
    1025                         rc = spawnlp(P_WAIT,binfile,binfile,j_url,j_id,j_user,j_title,j_copies,j_options,filename,NULL); 
     1076                        rc = spawnlp(P_WAIT,binfile,binfile,j_url,j_id,j_user,j_title,j_copies,j_options,filename,NULL);
    10261077                }
    10271078                else rc = 0;
    10281079        };
    1029        
     1080
    10301081        strcpy(filename,&szTemp[pos]);
    10311082        DosDelete(filename);
     
    10351086        return rc;
    10361087}
    1037 ULONG APIENTRY SplPdWrite( HFILE        hFile,
    1038                                                         PVOID   pchData,
    1039                                                         ULONG   cbData,
     1088ULONG APIENTRY SplPdWrite( HFILE    hFile,
     1089                                                        PVOID   pchData,
     1090                                                        ULONG   cbData,
    10401091                                                        PULONG  pcbWritten )
    10411092{  APIRET rc;
  • branches/smbpdr-1.0/smb.dlg

    r175 r177  
    66DLGTEMPLATE IDD_SMB LOADONCALL MOVEABLE DISCARDABLE
    77BEGIN
    8     DIALOG  "Port Properties - ", IDD_SMB, 15, 37, 258, 179, FS_NOBYTEALIGN |
     8    DIALOG  "Port Properties - ", IDD_SMB, 15, 37, 232, 156, FS_NOBYTEALIGN |
    99            WS_VISIBLE | WS_SYNCPAINT, FCF_SYSMENU | FCF_TITLEBAR |
    1010            FCF_NOBYTEALIGN
    1111            PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans"
    1212    BEGIN
    13         DEFPUSHBUTTON   "OK", DID_OK, 8, 5, 82, 14
     13        DEFPUSHBUTTON   "OK", DID_OK, 5, 5, 76, 14
    1414                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    15         PUSHBUTTON      "Cancel ", DID_CANCEL, 166, 5, 82, 14
     15        PUSHBUTTON      "Cancel ", DID_CANCEL, 149, 5, 76, 14
    1616                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    17         GROUPBOX        "CIFS/SMB Print server properties", GB_SMBCFG, 5, 97,
    18                         244, 76
     17        GROUPBOX        "CIFS/SMB Print server properties", GB_SMBCFG, 5, 96,
     18                        220, 54
    1919                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    2020                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    21         GROUPBOX        "Login as", 1024, 5, 54, 244, 40
     21        GROUPBOX        "Login as", 1024, 5, 53, 220, 40
    2222                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    2323                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    24         LTEXT           "Workgroup:", DT_WORKGROUP, 13, 151, 53, 8
    25         ENTRYFIELD      "", ID_WORKGROUP, 71, 151, 110, 8, ES_MARGIN
    26         LTEXT           "Server:", DT_IP, 13, 135, 53, 8
    27         ENTRYFIELD      "", ID_IP, 71, 135, 110, 8, ES_MARGIN
    28         LTEXT           "Printer:", DT_SMBQUEUE, 13, 119, 53, 8
    29         ENTRYFIELD      "", ID_SMBQUEUE, 71, 119, 110, 8, ES_MARGIN
    30         AUTOCHECKBOX    "Send as binary file", ID_BINARY, 69, 101, 113, 10
    31         LTEXT           "User ID:", DT_USER, 13, 73, 53, 10, DT_BOTTOM
    32         ENTRYFIELD      "", ID_USER, 71, 75, 100, 8, ES_MARGIN
    33         LTEXT           "Password:", DT_PASSWORD, 13, 60, 53, 10, DT_BOTTOM
    34         ENTRYFIELD      "", ID_PASSWORD, 71, 61, 100, 8, ES_MARGIN |
     24        LTEXT           "Workgroup:", DT_WORKGROUP, 13, 130, 53, 8,
     25                        DT_VCENTER
     26        ENTRYFIELD      "", ID_WORKGROUP, 71, 131, 142, 8, ES_MARGIN
     27        LTEXT           "Server:", DT_IP, 13, 116, 53, 8, DT_VCENTER
     28        ENTRYFIELD      "", ID_IP, 71, 117, 142, 8, ES_MARGIN
     29        LTEXT           "Printer:", DT_SMBQUEUE, 13, 102, 53, 8, DT_VCENTER
     30        ENTRYFIELD      "", ID_SMBQUEUE, 71, 103, 142, 8, ES_MARGIN
     31        AUTOCHECKBOX    "Send as binary file", ID_BINARY, 115, 148, 75, 8,
     32                        NOT WS_VISIBLE | WS_DISABLED
     33        LTEXT           "User ID:", DT_USER, 13, 73, 53, 8, DT_VCENTER
     34        ENTRYFIELD      "", ID_USER, 71, 74, 110, 8, ES_MARGIN
     35        LTEXT           "Password:", DT_PASSWORD, 13, 59, 53, 10, DT_VCENTER
     36        ENTRYFIELD      "", ID_PASSWORD, 71, 60, 110, 8, ES_MARGIN |
    3537                        ES_UNREADABLE
    36         GROUPBOX        "Number of copies", GB_COPIES, 5, 25, 244, 26
     38        GROUPBOX        "Number of copies", GB_COPIES, 5, 24, 220, 26
    3739                        PRESPARAMS PP_FOREGROUNDCOLOR, 0x00000000L
    3840                        PRESPARAMS PP_FONTNAMESIZE, "9.WarpSans Bold"
    39         LTEXT           "Spool this job", DT_COPIES, 13, 31, 54, 8
    40         LTEXT           "times to the server", DT_COPIES2, 104, 31, 135, 8
    41         ENTRYFIELD      "", ID_COPIES, 71, 32, 23, 8, ES_MARGIN
     41        LTEXT           "Spool this job", DT_COPIES, 13, 30, 54, 8,
     42                        DT_VCENTER
     43        LTEXT           "times to the server", DT_COPIES2, 104, 30, 83, 8,
     44                        DT_VCENTER
     45        ENTRYFIELD      "", ID_COPIES, 71, 31, 23, 8, ES_MARGIN
    4246    END
    4347END
  • branches/smbpdr-1.0/smb.h

    r175 r177  
    143143#define PORT_ID_FIRST             PORT_ID_1
    144144#define PORT_ID_LAST              PORT_ID_64
     145#define MAX_PORTS                 64
    145146
    146147#define SMB_ICON                7001
     
    158159#define DEF_TERMINATION           ";"
    159160#define DEF_PORTDRIVER            "SMB;"
     161#define DEF_PORTNAME              "SMB"   /* Must update build script if this is changed! */
    160162#define DEF_TIMEOUT               "45;"
    161163
  • branches/smbpdr-1.0/smb.rc

    r175 r177  
    22#include "SMB.h"
    33
     4DEFAULTICON SMB.ICO
    45POINTER SMB_ICON  LOADONCALL MOVEABLE DISCARDABLE  SMB.ICO
    56
     
    78BEGIN
    89    PORT_ID_1               "SMB1"
    9     PORT_DESC_1             "SMB port 1"
     10    PORT_DESC_1             "SMB port"
    1011    PORT_ID_2               "SMB2"
    11     PORT_DESC_2             "SMB port 2"
     12    PORT_DESC_2             "SMB port"
    1213    PORT_ID_3               "SMB3"
    13     PORT_DESC_3             "SMB port 3"
     14    PORT_DESC_3             "SMB port"
    1415    PORT_ID_4               "SMB4"
    15     PORT_DESC_4             "SMB port 4"
     16    PORT_DESC_4             "SMB port"
    1617    PORT_ID_5               "SMB5"
    17     PORT_DESC_5             "SMB port 5"
     18    PORT_DESC_5             "SMB port"
    1819    PORT_ID_6               "SMB6"
    19     PORT_DESC_6             "SMB port 6"
     20    PORT_DESC_6             "SMB port"
    2021    PORT_ID_7               "SMB7"
    21     PORT_DESC_7             "SMB port 7"
     22    PORT_DESC_7             "SMB port"
    2223    PORT_ID_8               "SMB8"
    23     PORT_DESC_8             "SMB port 8"
     24    PORT_DESC_8             "SMB port"
    2425    PORT_ID_9               "SMB9"
    25     PORT_DESC_9             "SMB port 9"
     26    PORT_DESC_9             "SMB port"
    2627    PORT_ID_10              "SMB10"
    27     PORT_DESC_10            "SMB port 10"
     28    PORT_DESC_10            "SMB port"
    2829    PORT_ID_11              "SMB11"
    29     PORT_DESC_11            "SMB port 11"
     30    PORT_DESC_11            "SMB port"
    3031    PORT_ID_12              "SMB12"
    31     PORT_DESC_12            "SMB port 12"
     32    PORT_DESC_12            "SMB port"
    3233    PORT_ID_13              "SMB13"
    33     PORT_DESC_13            "SMB port 13"
     34    PORT_DESC_13            "SMB port"
    3435    PORT_ID_14              "SMB14"
    35     PORT_DESC_14            "SMB port 14"
     36    PORT_DESC_14            "SMB port"
    3637    PORT_ID_15              "SMB15"
    37     PORT_DESC_15            "SMB port 15"
     38    PORT_DESC_15            "SMB port"
    3839    PORT_ID_16              "SMB16"
    39     PORT_DESC_16            "SMB port 16"
     40    PORT_DESC_16            "SMB port"
    4041    PORT_ID_17              "SMB17"
    41     PORT_DESC_17            "SMB port 17"
     42    PORT_DESC_17            "SMB port"
    4243    PORT_ID_18              "SMB18"
    43     PORT_DESC_18            "SMB port 18"
     44    PORT_DESC_18            "SMB port"
    4445    PORT_ID_19              "SMB19"
    45     PORT_DESC_19            "SMB port 19"
     46    PORT_DESC_19            "SMB port"
    4647    PORT_ID_20              "SMB20"
    47     PORT_DESC_20            "SMB port 20"
     48    PORT_DESC_20            "SMB port"
    4849    PORT_ID_21              "SMB21"
    49     PORT_DESC_21            "SMB port 21"
     50    PORT_DESC_21            "SMB port"
    5051    PORT_ID_22              "SMB22"
    51     PORT_DESC_22            "SMB port 22"
     52    PORT_DESC_22            "SMB port"
    5253    PORT_ID_23              "SMB23"
    53     PORT_DESC_23            "SMB port 23"
     54    PORT_DESC_23            "SMB port"
    5455    PORT_ID_24              "SMB24"
    55     PORT_DESC_24            "SMB port 24"
     56    PORT_DESC_24            "SMB port"
    5657    PORT_ID_25              "SMB25"
    57     PORT_DESC_25            "SMB port 25"
     58    PORT_DESC_25            "SMB port"
    5859    PORT_ID_26              "SMB26"
    59     PORT_DESC_26            "SMB port 26"
     60    PORT_DESC_26            "SMB port"
    6061    PORT_ID_27              "SMB27"
    61     PORT_DESC_27            "SMB port 27"
     62    PORT_DESC_27            "SMB port"
    6263    PORT_ID_28              "SMB28"
    63     PORT_DESC_28            "SMB port 28"
     64    PORT_DESC_28            "SMB port"
    6465    PORT_ID_29              "SMB29"
    65     PORT_DESC_29            "SMB port 29"
     66    PORT_DESC_29            "SMB port"
    6667    PORT_ID_30              "SMB30"
    67     PORT_DESC_30            "SMB port 30"
     68    PORT_DESC_30            "SMB port"
    6869    PORT_ID_31              "SMB31"
    69     PORT_DESC_31            "SMB port 31"
     70    PORT_DESC_31            "SMB port"
    7071    PORT_ID_32              "SMB32"
    71     PORT_DESC_32            "SMB port 32"
     72    PORT_DESC_32            "SMB port"
    7273    PORT_ID_33              "SMB33"
    73     PORT_DESC_33            "SMB port 33"
     74    PORT_DESC_33            "SMB port"
    7475    PORT_ID_34              "SMB34"
    75     PORT_DESC_34            "SMB port 34"
     76    PORT_DESC_34            "SMB port"
    7677    PORT_ID_35              "SMB35"
    77     PORT_DESC_35            "SMB port 35"
     78    PORT_DESC_35            "SMB port"
    7879    PORT_ID_36              "SMB36"
    79     PORT_DESC_36            "SMB port 36"
     80    PORT_DESC_36            "SMB port"
    8081    PORT_ID_37              "SMB37"
    81     PORT_DESC_37            "SMB port 37"
     82    PORT_DESC_37            "SMB port"
    8283    PORT_ID_38              "SMB38"
    83     PORT_DESC_38            "SMB port 38"
     84    PORT_DESC_38            "SMB port"
    8485    PORT_ID_39              "SMB39"
    85     PORT_DESC_39            "SMB port 39"
     86    PORT_DESC_39            "SMB port"
    8687    PORT_ID_40              "SMB40"
    87     PORT_DESC_40            "SMB port 40"
     88    PORT_DESC_40            "SMB port"
    8889    PORT_ID_41              "SMB41"
    89     PORT_DESC_41            "SMB port 41"
     90    PORT_DESC_41            "SMB port"
    9091    PORT_ID_42              "SMB42"
    91     PORT_DESC_42            "SMB port 42"
     92    PORT_DESC_42            "SMB port"
    9293    PORT_ID_43              "SMB43"
    93     PORT_DESC_43            "SMB port 43"
     94    PORT_DESC_43            "SMB port"
    9495    PORT_ID_44              "SMB44"
    95     PORT_DESC_44            "SMB port 44"
     96    PORT_DESC_44            "SMB port"
    9697    PORT_ID_45              "SMB45"
    97     PORT_DESC_45            "SMB port 45"
     98    PORT_DESC_45            "SMB port"
    9899    PORT_ID_46              "SMB46"
    99     PORT_DESC_46            "SMB port 46"
     100    PORT_DESC_46            "SMB port"
    100101    PORT_ID_47              "SMB47"
    101     PORT_DESC_47            "SMB port 47"
     102    PORT_DESC_47            "SMB port"
    102103    PORT_ID_48              "SMB48"
    103     PORT_DESC_48            "SMB port 48"
     104    PORT_DESC_48            "SMB port"
    104105    PORT_ID_49              "SMB49"
    105     PORT_DESC_49            "SMB port 49"
     106    PORT_DESC_49            "SMB port"
    106107    PORT_ID_50              "SMB50"
    107     PORT_DESC_50            "SMB port 50"
     108    PORT_DESC_50            "SMB port"
    108109    PORT_ID_51              "SMB51"
    109     PORT_DESC_51            "SMB port 51"
     110    PORT_DESC_51            "SMB port"
    110111    PORT_ID_52              "SMB52"
    111     PORT_DESC_52            "SMB port 52"
     112    PORT_DESC_52            "SMB port"
    112113    PORT_ID_53              "SMB53"
    113     PORT_DESC_53            "SMB port 53"
     114    PORT_DESC_53            "SMB port"
    114115    PORT_ID_54              "SMB54"
    115     PORT_DESC_54            "SMB port 54"
     116    PORT_DESC_54            "SMB port"
    116117    PORT_ID_55              "SMB55"
    117     PORT_DESC_55            "SMB port 55"
     118    PORT_DESC_55            "SMB port"
    118119    PORT_ID_56              "SMB56"
    119     PORT_DESC_56            "SMB port 56"
     120    PORT_DESC_56            "SMB port"
    120121    PORT_ID_57              "SMB57"
    121     PORT_DESC_57            "SMB port 57"
     122    PORT_DESC_57            "SMB port"
    122123    PORT_ID_58              "SMB58"
    123     PORT_DESC_58            "SMB port 58"
     124    PORT_DESC_58            "SMB port"
    124125    PORT_ID_59              "SMB59"
    125     PORT_DESC_59            "SMB port 59"
     126    PORT_DESC_59            "SMB port"
    126127    PORT_ID_60              "SMB60"
    127     PORT_DESC_60            "SMB port 60"
     128    PORT_DESC_60            "SMB port"
    128129    PORT_ID_61              "SMB61"
    129     PORT_DESC_61            "SMB port 61"
     130    PORT_DESC_61            "SMB port"
    130131    PORT_ID_62              "SMB62"
    131     PORT_DESC_62            "SMB port 62"
     132    PORT_DESC_62            "SMB port"
    132133    PORT_ID_63              "SMB63"
    133     PORT_DESC_63            "SMB port 63"
     134    PORT_DESC_63            "SMB port"
    134135    PORT_ID_64              "SMB64"
    135     PORT_DESC_64            "SMB port 64"
     136    PORT_DESC_64            "SMB port"
    136137    PDR_ID_PROPERTIES       "Properties"
    137138    ID_NUMBER_OF_DESC_LINES "1"
Note: See TracChangeset for help on using the changeset viewer.