/*virtual*/
void ServerPeerHalfDuplexSSLIn::OnConnect(PmSockIOChannel *pChannel, PslError errorCode) {
	UTIL_ASSERT_THROW_FATAL(!errorCode, MyName(), Err("PmSockAcceptCrypto failed: ", errorCode).c_str() );

    //10. create a palmsock channel watch for IN
	CreateWatchWithCallback(pChannel, G_IO_IN, &pWatchIn_, (GSourceFunc)PeerBase::StaticChannelWatchOn_G_IO_IN,
			this, MyName() );
}
Ejemplo n.º 2
0
Plugin *abvh::ReadString( const string &params )
    {
    // The abvh aggregate object needs no parameters.
    ParamReader get( params );
    if( get["begin"] && get[MyName()] ) return new abvh();
    return NULL;
    }
Ejemplo n.º 3
0
Plugin *Block::ReadString( const string &params ) // Read params from string.
    {
    ParamReader get( params );
    Vec3 Vmin, Vmax;
    if( get[MyName()] && get[Vmin] && get[Vmax] ) return new Block( Vmin, Vmax );
    return NULL;
    }
Ejemplo n.º 4
0
bool printer::Run( string command, Camera &camera, Scene &scene )
    {
    indent_n = 0;
    cout << "\n----- Scene printed by " << MyName() << " plugin ------" << endl;
    print_it( cout, scene.object );
    cout << "\n" << endl;
    return true;
    }
Ejemplo n.º 5
0
Plugin *Sphere::ReadString( const string &params ) // Reads params from a string.
    {
    Vec3 cent;
    double r;
    ParamReader get( params );
    if( get[MyName()] && get[cent] && get[r] ) return new Sphere( cent, r );
    return NULL;
    }
Ejemplo n.º 6
0
Plugin *printer::ReadString( const string &params )
    {
    ParamReader get( params );
    if( get["preprocess"] && get[MyName()] )
        {
        // See if the optional limit was specified.
        if( get["limit"] && get[limit] ) {}
        return Plugin::Null;
        }
    return NULL;
    }
Plugin *basic_builder::ReadString( const string &params ) 
    {
    ParamReader p( params );
    if( p["builder"] && p[MyName()] ) return new basic_builder();
    return NULL;
    }
	Plugin *hierarchicalAggregate::ReadString( const std::string &params ){
		ParamReader get( params );
		if( get["begin"] && get[MyName()] )
			return new hierarchicalAggregate();
		return NULL;
    }
Ejemplo n.º 9
0
Plugin *blockNew::ReadString( const std::string &params ){
    ParamReader get( params );
    Vec3 Vmin, Vmax;
    if( get[MyName()] && get[Vmin] && get[Vmax] ) return new blockNew( Vmin, Vmax );
    return NULL;
    }
Ejemplo n.º 10
0
BOOL
SplOpenPrinter(
    LPWSTR              pPrinterName,
    LPHANDLE            pPrinterHandle,
    LPPRINTER_DEFAULTS  pDefaults,
    PINISPOOLER         pIniSpooler,
    LPBYTE              pSplClientInfo,
    DWORD               dwLevel
    )

/*++

Routine Description:

    OpenPrinter can open any of the following by specifying a string
    in pPrinterName:-

        Server
            \\MachineName
            NULL

        Job
            PrinterName, Job xxxx

        Port
            PortName, Port

        Printer
            PrinterName
            ShareName
            \\MachineName\PrinterName
            \\MachineName\ShareName
            PrinterName, UpgradeToken
            ShareName, UpgradeToken

        Note for Printer there are two Types
            1 - Regular LocalPrinter
            2 - DownLevel Connection Printer

        For type 2 a LocalPrinter exists ( pIniPrinter ) but its port
        does not have a monitor associated with it.   In this case
        we also open the port ( typically \\share\printer of a remote
        machine ) before we return success.

    GUI Applications usually use Server and Printer

    Type Job and Port are used by Print Processors:-

        A print processor will Open a Job then read the job using
        ReadPrinter.  A print processor will output to a Port by opening
        the PortName, Port and using WritePrinter.  Usually these strings
        "PrinterName, Job xxx" "PortName, Port" are passed to the print
        processor by the spooler and are currently not documented.   We
        do know that some OEMs have figured out the extentions and we
        might break someone if we change them.

    Type UpgradeToken is used by a Printer Driver:-

        Used when we need to upgrade a printer's settings from an older
        version of the driver to a newer one (see drvupgrd.c for details).
        This was added in NT 3.51.

Arguments:

    pPrinterName   - PrinterName ( see above for different types of
                     PrinterName )
    pPrinterHandle - Address to put hPrinter on Success
    pDefaults      - Optional, allows user to specify Datatype,
                     DevMode, DesiredAccess.
    pIniSpooler    - handle of spooler on which the open should occur.

    ( see SDK Online Help for full explanation )


Return Value:

    TRUE    - *pPrinterHandle will have a PrinterHandle
    FALSE   - use GetLastError

--*/

{
    PINIPRINTER pIniPrinter = NULL;
    PINIPORT    pIniPort = NULL;
    PINIPORT    pIniNetPort = NULL;
    DWORD       LastError = 0;
    LPWSTR      pName = pPrinterName+2;
    WCHAR       string[MAX_UNC_PRINTER_NAME + PRINTER_NAME_SUFFIX_MAX];
    PINIJOB pIniJob = NULL;
    HANDLE  hReadFile = INVALID_HANDLE_VALUE;
    DWORD       TypeofHandle = 0;
    LPWSTR      pSecondPart = NULL;
    HANDLE      hPort = INVALID_PORT_HANDLE;
    DWORD       OpenPortError = NO_ERROR;
    BOOL        bRemoteUserPrinterNotShared = FALSE;
    DWORD       MachineNameLength;
    DWORD       RouterReturnValue = ROUTER_UNKNOWN;
    DWORD       AccessRequested;

#if DBG
    //
    // On DBG builds, force last error to zero so we can catch people
    // that don't set it when they should.
    //
    SetLastError( ERROR_SUCCESS );
#endif

    //
    // Reject "" - pointer to a NULL string.
    //
    if ( pPrinterName && !pPrinterName[0] ) {
        SetLastError(ERROR_INVALID_NAME);
        return ROUTER_UNKNOWN;
    }

    //
    // Check for SERVER Opens.
    //
    // If the printer name was NULL or our own MachineName, then
    // the caller wants a handle to the server.
    //
    if( MyName( pPrinterName, pIniSpooler )){

        return CreateServerHandle( pPrinterName,
                                   pPrinterHandle,
                                   pDefaults,
                                   pIniSpooler );
    }

    DBGMSG( DBG_TRACE, ( "OpenPrinter(%ws)\n", pPrinterName ));

    EnterSplSem();

    //
    // For the Mars folks who will come in with the same printer
    // connection, do a DeletePrinterCheck; this will allow
    // Mars connections that have been deleted to be proceed
    // to the Mars print providor
    //
    if (( pIniPrinter = FindPrinter( pPrinterName )) ||
        ( pIniPrinter = FindPrinterShare( pPrinterName, pIniSpooler ))) {

        DeletePrinterCheck( pIniPrinter );
        pIniPrinter = NULL;
    }

    //
    // The strategy for the rest of this code is to walk through each
    // different printer handle type, searching for a match.
    //
    // RouterReturnValue will be set to the current state of routing.
    // If a section recognizes and "owns" a printer and successfully
    // opens it, it sets RouterReturnValue to ROUTER_SUCCESS and
    // jumps to DoneRouting which allocs the handle.
    //
    // If it recoginzes the printer but fails to open it, and
    // guarentees that no one else (localspl code or other providers)
    // will recognize it, it should set RouterReturnValue to
    // ROUTER_STOP_ROUTING.  We will quit at this point.
    //
    // If it doesn't recognize the printer, set RouterReturnValue
    // to ROUTER_UNKNOWN and we will keep looking.
    //

    //
    // Try regular printer name: "My Printer" "TestPrinter."
    //

    RouterReturnValue = OpenLocalPrinterName( pPrinterName,
                                              pIniSpooler,
                                              &TypeofHandle,
                                              &pIniPrinter,
                                              &pIniPort,
                                              &pIniNetPort,
                                              &hPort,
                                              &OpenPortError,
                                              pDefaults );

    //
    // Note: Don't check for interactive users, since anyone using the
    // name without the server prefix must be local anyway.
    // The server does this and must not be marked as remote, since
    // its AddJob calls will fail.
    //

    if( RouterReturnValue != ROUTER_UNKNOWN ){
        goto DoneRouting;
    }

    SPLASSERT( !TypeofHandle && !pIniPrinter && !pIniPort &&
               !pIniNetPort && !pIniJob && !hPort );

    //
    // Try LocalPrinter with an extention e.g.
    //
    // PortName, Port
    // PrinterName, Job xxxx
    // PrinterName, UpgradeToken
    //
    // See if the name includes a comma.  Look for qualifiers:
    //    Port Job LocalOnly UpgradeToken
    //

    wcscpy( string, pPrinterName );

    if( pSecondPart = wcschr( string, L',' )){

        //
        // Turn into 2 strings
        // First PrintName
        // pSecondPart points to the rest.
        //
        *pSecondPart++ = 0;

        //
        // Get rid of Leading Spaces
        //
        while ( *pSecondPart == L' ' && *pSecondPart != 0 ) {
            pSecondPart++;
        }

        SPLASSERT( *pSecondPart );

        //
        //  PrintName, UpgradeToken
        //
        RouterReturnValue = CheckPrinterUpgradeToken( string,
                                                      pSecondPart,
                                                      &TypeofHandle,
                                                      &pIniPrinter,
                                                      pIniSpooler );

        if( RouterReturnValue != ROUTER_UNKNOWN ){
            goto DoneRouting;
        }

        SPLASSERT( !TypeofHandle && !pIniPrinter && !pIniPort &&
                   !pIniNetPort && !pIniJob && !hPort );

        //
        //  PortName, Port
        //
        RouterReturnValue = CheckPrinterPortToken( string,
                                                   pSecondPart,
                                                   &TypeofHandle,
                                                   &pIniPrinter,
                                                   &pIniPort,
                                                   &pIniJob,
                                                   pDefaults,
                                                   pIniSpooler );

        if( RouterReturnValue != ROUTER_UNKNOWN ){
            goto DoneRouting;
        }

        SPLASSERT( !TypeofHandle && !pIniPrinter && !pIniPort &&
                   !pIniNetPort && !pIniJob && !hPort );

        //
        //  PrinterName, Job ###
        //
        RouterReturnValue = CheckPrinterJobToken( string,
                                                  pSecondPart,
                                                  &TypeofHandle,
                                                  &pIniPrinter,
                          &pIniJob,
                          &hReadFile,
                                                  pIniSpooler );

        if( RouterReturnValue != ROUTER_UNKNOWN ){
            goto DoneRouting;
        }

        SPLASSERT( !TypeofHandle && !pIniPrinter && !pIniPort &&
                   !pIniNetPort && !pIniJob && !hPort );

    }

    //
    // Try local printer qualified by \\ServerName:
    // "\\ServerName\PrinterName" "\\ServerName\ShareName."
    //

    wcscpy( string, pPrinterName );

    if( string[0] == L'\\' &&
        string[1] == L'\\' &&
        ( pName = wcschr( &string[2], L'\\')) ) {

        *pName = L'\0';
        pName++;

        if ( MyName(string, pIniSpooler) ) {

            //
            // Check local printer.
            //
            RouterReturnValue = OpenLocalPrinterName( pName,
                                                      pIniSpooler,
                                                      &TypeofHandle,
                                                      &pIniPrinter,
                                                      &pIniPort,
                                                      &pIniNetPort,
                                                      &hPort,
                                                      &OpenPortError,
                                                      pDefaults );

            if( RouterReturnValue == ROUTER_SUCCESS ){

                //
                // On success, determine whether the user is remote or local.
                // Note: we only do this for fully qualified names
                // (\\server\share), since using just the share or printer
                // name can only succeed locally.
                //

                if( ( pIniSpooler->SpoolerFlags & SPL_REMOTE_HANDLE_CHECK ) &&
                     !IsInteractiveUser() ) {

                    TypeofHandle |= PRINTER_HANDLE_REMOTE;
                }

                //
                // This is a remote open.
                //
                // If the printer is not shared, ensure the caller
                // has Administer access to the printer.
                //
                // bugbug!
                //
                // The following seems to belong to the inside of the above "if" clause. As it is, if
                // an interactive user calls in with UNC name, we require him to have ADMIN access if the 
                // printer is not shared; but if he uses the printer friendly name, we let him go.
                //
                if( !( pIniPrinter->Attributes & PRINTER_ATTRIBUTE_SHARED )){
                    bRemoteUserPrinterNotShared = TRUE;
                }

            } else {

                //
                // Since we matched the server but didn't find the printer,
                // we should stop routing.
                //
                RouterReturnValue = ROUTER_STOP_ROUTING;
                SetLastError( ERROR_INVALID_PRINTER_NAME );
            }

            //
            // Both cases we are done routing since we found our
            // server name prefix.
            //
            goto DoneRouting;
        }
    }

    //
    // We have completed all routing.  Anything other than success
    // should exit now.
    //

DoneRouting:

    if( RouterReturnValue == ROUTER_SUCCESS) {

        //
        // It's an error if the printer is pending deletion or pending creation.
        //
        SPLASSERT( pIniPrinter );

        if ( (( pIniPrinter->Status & PRINTER_PENDING_DELETION )                      &&
              ( pIniSpooler->SpoolerFlags & SPL_FAIL_OPEN_PRINTERS_PENDING_DELETION ) &&
              ( pIniPrinter->cJobs == 0 )) ||

             ( pIniPrinter->Status & PRINTER_PENDING_CREATION ) ) {

            RouterReturnValue = ROUTER_STOP_ROUTING;
            SetLastError( ERROR_INVALID_PRINTER_NAME );
            goto DoneRouting;
        }

        //
        // When the printer is opened, access type may be specified in
        // pDefaults.  If no defaults are supplied (or request access
        // is unspecified), we use PRINTER_ACCESS_USE.
        //
        // Future calls with the handle will check against both the
        // current user privileges on this printer but also this initial
        // access.  (Even if the user is an admin of the printer, unless
        // they open the printer with PRINTER_ALL_ACCESS, they can't
        // administer it.
        //
        // If the user requires more access, the printer must be reopened.
        //

        AccessRequested = ( !pDefaults || !pDefaults->DesiredAccess ) ?
            PRINTER_READ :
            pDefaults->DesiredAccess;

        //
        // If the user is remote and the printer is not shared, only allow
        // administrators succeed.
        //
        // This allows administrators to admin printers even if they
        // are not shared, and prevents non-admins from opening non-shared
        // printers.
        //

        if( bRemoteUserPrinterNotShared &&
            !(AccessRequested & PRINTER_ACCESS_ADMINISTER )) {

            PSPOOL pSpool;

            // Get a quick and dirty pSpool to pass in
            pSpool = (PSPOOL)AllocSplMem( SPOOL_SIZE );
            if( pSpool == NULL ) {
                DBGMSG( DBG_WARNING, ("SplOpenPrinter failed to allocate memory %d\n", GetLastError() ));
                RouterReturnValue = ROUTER_STOP_ROUTING;
                goto WrapUp;                 
            }
            pSpool->signature = SJ_SIGNATURE;
            pSpool->pIniPrinter = pIniPrinter;


            // Add admin request, and see if user has the right.
            AccessRequested |= PRINTER_ACCESS_ADMINISTER;
            if( !ValidateObjectAccess( SPOOLER_OBJECT_PRINTER, AccessRequested, pSpool, pIniSpooler )) {
                SetLastError(ERROR_ACCESS_DENIED);
                RouterReturnValue = ROUTER_STOP_ROUTING;                
            }
            AccessRequested &= ~PRINTER_ACCESS_ADMINISTER;

            // clean up
            FreeSplMem( pSpool );

            // If the user had no ADMIN privilege, fail the open call.
            if( RouterReturnValue == ROUTER_STOP_ROUTING )
                goto WrapUp;
        }

        //
        // Create the printer handle that we will return to the user.
        //

        *pPrinterHandle = CreatePrinterHandle( pPrinterName,
                                               pIniPrinter,
                                               pIniPort,
                                               pIniNetPort,
                                               pIniJob,
                                               TypeofHandle,
                                               hPort,
                                               pDefaults,
                                               pIniSpooler,
                                               AccessRequested,
                                               pSplClientInfo,
                                               dwLevel,
                                               hReadFile );

        if( *pPrinterHandle ){

            //
            // Update the OpenPortError.
            //
            ((PSPOOL)*pPrinterHandle)->OpenPortError = OpenPortError;

        } else {
            SPLASSERT( GetLastError( ));
            RouterReturnValue = ROUTER_STOP_ROUTING;
        }
    }
    
WrapUp:
    
    LeaveSplSem();
    //
    // Don't have an SplOutSem as we could be called recursively.
    //

    switch( RouterReturnValue ){
    case ROUTER_SUCCESS:

        DBGMSG( DBG_TRACE, ("OpenPrinter returned handle %x\n", *pPrinterHandle));
        SPLASSERT( *pPrinterHandle );
        break;

    case ROUTER_UNKNOWN:

        SPLASSERT( !TypeofHandle && !pIniPrinter && !pIniPort &&
                   !pIniNetPort && !pIniJob && !hPort );

        //
        // hPort should not be valid.  If it is, we have leaked a handle.
        //
    SPLASSERT( !hPort );
    SPLASSERT( hReadFile == INVALID_HANDLE_VALUE );
        DBGMSG( DBG_TRACE, ( "OpenPrinter failed, invalid name %s\n",
                             pPrinterName ));
        SetLastError( ERROR_INVALID_NAME );
        break;

    case ROUTER_STOP_ROUTING:

        LastError = GetLastError();
        SPLASSERT( LastError );

        //
        // On failure, we may have opened a port or file handle. We need
        // to close it since we won't return a valid handle, and
        // so ClosePrinter will never get called.
        //

        if( hPort != INVALID_PORT_HANDLE ) {
            ClosePrinter( hPort );
        }

        if ( hReadFile != INVALID_HANDLE_VALUE ) {
            CloseHandle( hReadFile );
        }

        DBGMSG( DBG_TRACE, ("OpenPrinter %s failed: Error %d\n",
                            pPrinterName, GetLastError()));

        SetLastError( LastError );
        break;
    }

    return RouterReturnValue;
}
Plugin *basic_shader::ReadString( const string &params ) 
    {
    ParamReader get( params );
    if( get["shader"] && get[MyName()] ) return new basic_shader();
    return NULL;
    }
Ejemplo n.º 12
0
Plugin *ppm_writer::ReadString( const string &params ) 
    {
    ParamReader get( params );
    if( get["writer"] && get[MyName()] ) return new ppm_writer();
    return NULL;
    }