示例#1
0
wxMacClassicPrinterDC::wxMacClassicPrinterDC(wxPrintData* data)
{
    ::GetPort( &m_macPrintFormerPort ) ;
    m_err = noErr ;
    ::UMAPrOpen() ;
    m_err = PrError() ;
    if ( m_err != noErr )
        return;

    wxMacClassicPrintData *native = (wxMacClassicPrintData*) data->m_nativePrintData ;

    if ( ::PrValidate( native->m_macPrintSettings ) )
    {
        // the driver has changed in the mean time, should we pop up a page setup dialog ?
        if ( !::PrStlDialog( native->m_macPrintSettings ) )
        {
            m_err = -1 ;
            return;
        }
    }
    m_err = PrError() ;

    if ( m_err == noErr )
    {
        m_maxX = (**native->m_macPrintSettings).prInfo.rPage.right - (**native->m_macPrintSettings).prInfo.rPage.left ;
        m_maxY = (**native->m_macPrintSettings).prInfo.rPage.bottom - (**native->m_macPrintSettings).prInfo.rPage.top ;
    }
}
示例#2
0
文件: mprinter.cpp 项目: PNCG/neuron
bool MacPrinterCanvas::setup(bool s){
#if carbon
	return false;
#else
	GetPort(&oldPort);
	PrOpen();
  if (!prRecHdl) {
	prRecHdl = THPrint(NewHandleClear(sizeof(TPrint)));
	if (PrError()  != noErr) {
		return false;
	}
	PrintDefault(prRecHdl);
	if (PrError()  != noErr) {
		return false;
	}
  }else{
	PrValidate(prRecHdl);
  }
    if (s) {
		PrStlDialog(prRecHdl);
	}
	PrClose();
	if (PrError()  != noErr) {
		return false;
	}
	//debugfile("MacPrinterCanvas::setup  width=%d height=%d\n", pwidth(), pheight());
	SetPort(oldPort);
	return true;
#endif
}
示例#3
0
文件: mprinter.cpp 项目: PNCG/neuron
bool MacPrinterCanvas::finish() {
#if carbon
	return false;
#else
	endPaint();
	PrClosePage(gPrinterPort);
	if (PrError()  != noErr) {
		return false;
	}
	PrCloseDoc(gPrinterPort);
	if (PrError()  != noErr) {
		return false;
	}
	if ((**prRecHdl).prJob.bJDocLoop == bSpoolLoop) {
		TPrStatus theStatus;
		PrPicFile(prRecHdl, nil, nil, nil, &theStatus);
		if (PrError()  != noErr) {
			return false;
		}
	}
	PrClose();
	if (PrError()  != noErr) {
		return false;
	}
	SetPort(oldPort);
//debugfile("MacPrinter::finish\n");
	return true;
#endif
}
示例#4
0
文件: mprinter.cpp 项目: PNCG/neuron
bool MacPrinterCanvas::start() {
#if carbon
	return false;
#else
//debugfile("MacPrinter::init\n");
	GetPort(&oldPort);
	PrOpen();
  if (!prRecHdl) {
	prRecHdl = THPrint(NewHandleClear(sizeof(TPrint)));
	if (PrError()  != noErr) {
		return false;
	}
	PrintDefault(prRecHdl);
	if (PrError()  != noErr) {
		return false;
	}
	PrStlDialog(prRecHdl);
  }else{
	PrValidate(prRecHdl);
  }
	gPrinterPort = PrOpenDoc(prRecHdl, nil, nil);
	if (PrError()  != noErr) {
		return false;
	}
	PrOpenPage(gPrinterPort, nil);
	if (PrError()  != noErr) {
		return false;
	}
	damage_all();
	beginPaint();
	return true;
#endif
}
示例#5
0
int ioPrintPostProcessing(PrintingLogicPtr printJob) {                                                                	OSStatus	status = noErr;

     // Close the print job.  This dismisses the progress dialog on Mac OS X.
 	PrCloseDoc(printJob->thePrPort);
 	status = PrError();
    return status;
}    
示例#6
0
int ioPagePreProcessing(PrintingLogicPtr printJob) {                                               
    OSStatus		status = noErr;

	PrOpenPage(printJob->thePrPort, nil);
 	status = PrError();
    return status;
}
示例#7
0
文件: main.c 项目: taysom/tau
int main (int argc, char *argv[])
{
	int i;

	Option.file_size = Local_option.size_big_file;
	Option.dir = ".";
	punyopt(argc, argv, myopt, "b:forsv");
	Local_option.size_big_file = Option.file_size;

	if (Local_option.size_big_file < 40000) {
		PrError("Size of big file, %lld, should be greater than 40K",
			Local_option.size_big_file);
		return 2;
	}
	if (Local_option.size_big_file < (1LL << 32)) {
		fprintf(stderr, "Size of big file only 0x%llx\n",
			Local_option.size_big_file);
	}
	if (argc == optind) {
		all_tests(Option.dir);
	} else for (i = optind; i < argc; i++) {
		all_tests(argv[i]);
	}
	if (Option.print) DumpRecords();
	return 0;
}
示例#8
0
文件: dir.c 项目: taysom/tau
void SeekTest (void)
{
	int num_children = 10;
	dir_s dir = NilDir;
	DIR *d;
	struct dirent *entry;
	int i;

	dir.name = RndName();
	mkdir(dir.name, 0777);
	AddChildren(&dir, num_children);

	d = opendir(dir.name);
	while ((entry = readdir(d)) != NULL) {
		SaveTell(d, entry, &dir);
	}
	for (i = 0; i < 27; i++) {
		int k = urand(num_children);
		file_s *file = &dir.file[k];
		seekdir(d, file->tell);
		entry = readdir(d);
		if (strcmp(entry->d_name, file->name) != 0) {
			PrError("Seekdir failed. Looking for %s found %s",
				entry->d_name, file->name);
		}
	}
	closedir(d);
	DeleteChildren(&dir);
	rmdir(dir.name);
	free(dir.name);
}
示例#9
0
static boolean shellcheckprinterror (boolean flopening) {
	
	/*
	 returns false if there was a print error.
	 
	 1/18/93 dmb: take flopening parameter, & special case this error
	 */
	
	OSErr x;
	bigstring bserror;
	
#	ifdef MACVERSION
	
	//Code change by Timothy Paustian Friday, June 16, 2000 3:50:52 PM
	//Changed to Opaque call for Carbon
	// this is pointless --- explicitly excluded
#		if TARGET_API_MAC_CARBON == 1
	
	x = PMSessionError(shellprintinfo.printhandle);
	
#		else	
	
	x = PrError ();
	
#		endif
	
	if (x == noErr) /*no error, keep going*/
		return (true);
	
	if (x != iPrAbort) {
		
		if (flopening) 
		{
			GetIndString (bserror, interfacelistnumber, trychooserstring);
		}
		else {
			
			getsystemerrorstring (x, bserror);
			
			parsedialogstring (bserror, "\x06" ".Print", nil, nil, nil, bserror);
		}
		
		shellerrormessage (bserror);
	}
	
#	endif
	
#ifdef WIN95VERSION
	x = GetLastError();

	if (x == 0)
		return (true);

	getsystemerrorstring (x, bserror);

	shellerrormessage (bserror);
#endif
	
	return (false); /*there was an error*/
	} /*shellcheckprinterror*/
示例#10
0
int ioPagePostProcessing(PrintingLogicPtr printJob) {                                               
    OSStatus		status = noErr;
    
    //	Close the page.
	PrClosePage(printJob->thePrPort);
 	status = PrError();
    return status;
}
示例#11
0
void wxMacClassicPrinterDC::EndDoc( wxPrinterDC* dc )
{
    if ( m_err )
        return ;

    PrCloseDoc( m_macPrintingPort ) ;
    m_err = PrError() ;
}
示例#12
0
OSStatus  OpenPrinterAndValidate(void)
{
	OSStatus			err = noErr;

	#if TARGET_API_MAC_CARBON
	/////////////////////////////////////////////////
		err =  PMCreateSession(&gPrintSession);
		if(err) return err;

		// get and validate the page formatting
		if (gPageFormat == kPMNoPageFormat) {   // Set up a valid PageFormat object
			err = PMCreatePageFormat(&gPageFormat);
			//  Note that PMPageFormat is not session-specific, but calling
			//  PMSessionDefaultPageFormat assigns values specific to the printer
			//  associated with the current printing session.
			if ((err == noErr) && (gPageFormat != kPMNoPageFormat))
				err = PMSessionDefaultPageFormat(gPrintSession, gPageFormat);
		}
		else{
			err = PMSessionValidatePageFormat(gPrintSession, gPageFormat, kPMDontWantBoolean);
		}
		if(err) return err;
		/////////////////////////////////////////////////
		// let's also get and validate the print settings
		if (gPrintSettings == kPMNoPrintSettings)
		{
			err = PMCreatePrintSettings(&gPrintSettings);	
			// Note that PMPrintSettings is not session-specific, but calling
			// PMSessionDefaultPrintSettings assigns values specific to the printer
			// associated with the current printing session.
			if ((err == noErr) && (gPrintSettings != kPMNoPrintSettings))
				err = PMSessionDefaultPrintSettings(gPrintSession, gPrintSettings);
		}
		else {
			err = PMSessionValidatePrintSettings(gPrintSession, gPrintSettings, kPMDontWantBoolean);
		}

		return err;
	
	#else //// MACB4CARBON ////////////////////////////////////////
	/////////////////////////////////////////////////
		PrOpen();
		err = PrError();
		if(err) return err;		
	   
		// always use the global
		if(gPrRecHdl == nil){
			gPrRecHdl  = (THPrint)_NewHandleClear(sizeof(TPrint));
			if(!gPrRecHdl)return memFullErr; 
			PrintDefault(gPrRecHdl);
		}
	
		PrValidate(gPrRecHdl); 	
		// We ignore the returned value  
		
		return(noErr);
	#endif
} 
示例#13
0
void wxMacClassicPrinterDC::EndPage( wxPrinterDC* dc )
{
    if ( m_err )
        return ;

    PrClosePage( m_macPrintingPort ) ;
    m_err = PrError() ;
    if ( m_err != noErr )
        ::PrCloseDoc( m_macPrintingPort  ) ;
}
示例#14
0
文件: dir.c 项目: taysom/tau
static void SaveTell (DIR *d, struct dirent *entry, dir_s *dir)
{
	file_s *f;
	if (ignore(entry->d_name)) return;
	if ((f = FindFile(dir, entry->d_name)) == NULL) {
		PrError("Didn't find %s in %s", entry->d_name, dir->name);
		return;
	}
	f->tell = telldir(d);
}
示例#15
0
文件: dir.c 项目: taysom/tau
static bool AuditChild (struct dirent *entry, void *user)
{
	dir_s *dir = user;
	if (ignore(entry->d_name)) return TRUE;
	if (!FindFile(dir, entry->d_name)) {
		PrError("Didn't find %s in %s", entry->d_name, dir->name);
		return FALSE;
	}
	return TRUE;
}
示例#16
0
文件: rw.c 项目: taysom/tau
static void is_zeros (void *buf, u64 n)
{
	u8 *b = buf;
	u8 *end = &b[n];

	for (b = buf; b < end; b++) {
		if (*b) {
			PrError("should be zero but is 0x%2x", *b);
		}
	}
}
示例#17
0
int ioPrintSetup(PrintingLogicPtr *token)
{
    OSStatus		status = noErr;
    PrintingLogicPtr printJob;
   
    printJob = *token = (PrintingLogicPtr) NewPtrClear(sizeof(PrintingLogic));
    printJob->thePrRecHdl = (THPrint)  NewHandle (sizeof (TPrint));
	status = MemError();
    if (status != noErr) 
        return -1;	// pointless to continue if memory allocation fails
    
    //	Initialize the printing manager and create a printing session.
 	PrOpen(); //The PrOpen procedure prepares the current printer driver for use. 
 	status = PrError();
    if (status != noErr) 
    	return status;	
 	
 	PrintDefault(printJob->thePrRecHdl);
	status = PrError();
    if (status != noErr) 
    	return status;	

	PrValidate(printJob->thePrRecHdl);
	status = PrError();
    if (status != noErr) 
    	return status;	

    //	Display the Page Setup dialog.
	if (! PrStlDialog(printJob->thePrRecHdl)) 
  	    goto cleanup; // user cancelled

    
    return status;
    cleanup: 
    	DisposeHandle ((Handle) printJob->thePrRecHdl);
    	printJob->thePrRecHdl = NULL;
    	return -4;
}
示例#18
0
文件: main.c 项目: taysom/tau
/* cleanup deletes the scratch directory and everything under it. */
void cleanup (void)
{
	char *cmd;
	int rc;

	chdir("..");
	cmd = Catstr("rm -fr ", Scratch, NULL);

	rc = system(cmd);
	if (rc == -1) PrError("%s:", cmd);
	free(cmd);
	free(Scratch);
	Scratch = NULL;
}
示例#19
0
文件: dir.c 项目: taysom/tau
static bool DeleteDirEntry (DirEntry_s *direntry)
{
	switch (direntry->type) {
		case T_FILE:
			unlink(direntry->name);
			break;
		case T_DIR:
			rmdir(direntry->name);
			break;
		default:
			PrError("bad type %d", direntry->type);
			break;
	}
	return TRUE;
}
示例#20
0
void wxMacClassicPrinterDC::StartPage( wxPrinterDC* dc )
{
    if ( m_err )
        return ;

    wxMacClassicPrintData *native = (wxMacClassicPrintData*) dc->GetPrintData().m_nativePrintData ;

    PrOpenPage( m_macPrintingPort , NULL ) ;
    dc->m_macLocalOrigin.x =  (**native->m_macPrintSettings).rPaper.left ;
    dc->m_macLocalOrigin.y =  (**native->m_macPrintSettings).rPaper.top ;
    // m_macPrintingPort is now the current port
    Rect clip = { -32000 , -32000 , 32000 , 32000 } ;
    ::ClipRect( &clip ) ;
    m_err = PrError() ;
    if ( m_err != noErr )
        ::PrCloseDoc( m_macPrintingPort ) ;
}
示例#21
0
bool wxMacClassicPrinterDC::StartDoc(  wxPrinterDC* dc , const wxString& WXUNUSED(message)  )
{
    if ( m_err )
        return false ;

    wxMacClassicPrintData *native = (wxMacClassicPrintData*) dc->GetPrintData().m_nativePrintData ;
    m_macPrintingPort = ::PrOpenDoc( native->m_macPrintSettings , NULL , NULL ) ;
    m_err = PrError() ;
    if ( m_err )
        return false ;

    // sets current port
    dc->m_macPort = (GrafPtr ) m_macPrintingPort ;
    m_maxX = (**native->m_macPrintSettings).prInfo.rPage.right - (**native->m_macPrintSettings).prInfo.rPage.left ;
    m_maxY = (**native->m_macPrintSettings).prInfo.rPage.bottom - (**native->m_macPrintSettings).prInfo.rPage.top ;
    return true ;
}
示例#22
0
ACPI_STATUS
PrResolveIntegerExpression (
    char                    *Line,
    UINT64                  *ReturnValue)
{
    UINT64                  Result;
    char                    *ExpandedLine;


    DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
        "**** Resolve #if:  %s\n", Gbl_CurrentLineNumber, Line);

    /* Expand all macros within the expression first */

    ExpandedLine = PrExpandMacros (Line);

    /* Now we can evaluate the expression */

    Result = PrEvaluateExpression (ExpandedLine);
    DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
        "**** Expression Resolved to: %8.8X%8.8X\n",
        Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Result));

    *ReturnValue = Result;
    return (AE_OK);

#if 0
InvalidExpression:

    ACPI_FREE (EvalBuffer);
    PrError (ASL_ERROR, ASL_MSG_INVALID_EXPRESSION, 0);
    return (AE_ERROR);


NormalExit:

    DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
        "**** Expression Resolved to: %8.8X%8.8X\n",
        Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value1));

    *ReturnValue = Value1;
    return (AE_OK);
#endif
}
示例#23
0
文件: dir.c 项目: taysom/tau
static DirEntry_s *CreateDirEntry (int type)
{
	int fd;
	DirEntry_s *direntry;
	direntry = ezalloc(sizeof(*direntry));
	direntry->name = RndName();
	direntry->type = type;
	switch (type) {
		case T_FILE:
			fd = creat(direntry->name, 0700);
			close(fd);
			break;
		case T_DIR:
			mkdir(direntry->name, 0700);
			break;
		default:
			PrError("bad type %d", type);
			break;
	}
	return direntry;
}
示例#24
0
int ioPrintPreProcessing(PrintingLogicPtr printJob,int numberOfPages) {
    OSStatus		status = noErr;
    UInt32	realNumberOfPagesinDoc;
        
    if (printJob->thePrRecHdl == NULL) 
        return -1;
        
    printJob->numberOfPages = numberOfPages;
    printJob->allowPostscript = false;
    
    if (!PrJobDialog(printJob->thePrRecHdl))
    	return -2;
    
    if (status == noErr) {
        //	Get the user's Print dialog selection for first and last pages to print.
        if (status == noErr)
            { 
            TPPrint foo = *printJob->thePrRecHdl;
            printJob->firstPage = foo->prJob.iFstPage;
            printJob->lastPage =  foo->prJob.iLstPage;
            }
    
        //	Check that the selected page range does not exceed the actual number of
        //	pages in the document.
        if (status == noErr)
            {
            realNumberOfPagesinDoc = printJob->numberOfPages;
            if (realNumberOfPagesinDoc < printJob->lastPage)
                printJob->lastPage = realNumberOfPagesinDoc;
            }
        
        //	Begin a new print job.
		printJob->thePrPort = PrOpenDoc(printJob->thePrRecHdl, nil, nil);
		status = PrError();
        }

    return status;
}
示例#25
0
void
PrAddMacro (
    char                    *Name,
    char                    **Next)
{
    char                    *Token = NULL;
    ACPI_SIZE               TokenOffset;
    ACPI_SIZE               MacroBodyOffset;
    PR_DEFINE_INFO          *DefineInfo;
    PR_MACRO_ARG            *Args;
    char                    *Body;
    char                    *BodyInSource;
    UINT32                  i;
    UINT16                  UseCount = 0;
    UINT16                  ArgCount = 0;
    UINT32                  Depth = 1;
    UINT32                  EndOfArgList;
    char                    BufferChar;


    /* Find the end of the arguments list */

    TokenOffset = Name - Gbl_MainTokenBuffer + strlen (Name) + 1;
    while (1)
    {
        BufferChar = Gbl_CurrentLineBuffer[TokenOffset];
        if (BufferChar == '(')
        {
            Depth++;
        }
        else if (BufferChar == ')')
        {
            Depth--;
        }
        else if (BufferChar == 0)
        {
            PrError (ASL_ERROR, ASL_MSG_MACRO_SYNTAX, TokenOffset);
            return;
        }

        if (Depth == 0)
        {
            /* Found arg list end */

            EndOfArgList = TokenOffset;
            break;
        }

        TokenOffset++;
    }

    /* At this point, we know that we have a reasonable argument list */

    Args = UtLocalCalloc (sizeof (PR_MACRO_ARG) * PR_MAX_MACRO_ARGS);

    /* Get the macro argument names */

    for (i = 0; i < PR_MAX_MACRO_ARGS; i++)
    {
        Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next);
        if (!Token)
        {
            /* This is the case for a NULL macro body */

            BodyInSource = "";
            goto AddMacroToList;
        }

        /* Don't go beyond the argument list */

        TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token);
        if (TokenOffset > EndOfArgList)
        {
            break;
        }

        DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
            "Macro arg: %s \n",
            Gbl_CurrentLineNumber, Token);

        Args[i].Name = UtLocalCalloc (strlen (Token) + 1);
        strcpy (Args[i].Name, Token);

        Args[i].UseCount = 0;

        ArgCount++;
        if (ArgCount >= PR_MAX_MACRO_ARGS)
        {
            PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS, TokenOffset);
            goto ErrorExit;
        }
    }

    /* Get the macro body. Token now points to start of body */

    MacroBodyOffset = Token - Gbl_MainTokenBuffer;

    /* Match each method arg in the macro body for later use */

    Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next);
    while (Token)
    {
        /* Search the macro arg list for matching arg */

        for (i = 0; Args[i].Name && (i < PR_MAX_MACRO_ARGS); i++)
        {
            /*
             * Save argument offset within macro body. This is the mechanism
             * used to expand the macro upon invocation.
             *
             * Handles multiple instances of the same argument
             */
            if (!strcmp (Token, Args[i].Name))
            {
                UseCount = Args[i].UseCount;

                Args[i].Offset[UseCount] =
                    (Token - Gbl_MainTokenBuffer) - MacroBodyOffset;

                DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
                    "Macro Arg #%u: %s UseCount %u Offset %u \n",
                    Gbl_CurrentLineNumber, i, Token,
                    UseCount+1, Args[i].Offset[UseCount]);

                Args[i].UseCount++;
                if (Args[i].UseCount >= PR_MAX_ARG_INSTANCES)
                {
                    PrError (ASL_ERROR, ASL_MSG_TOO_MANY_ARGUMENTS,
                        THIS_TOKEN_OFFSET (Token));

                    goto ErrorExit;
                }
                break;
            }
        }

        Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next);
    }

    BodyInSource = &Gbl_CurrentLineBuffer[MacroBodyOffset];


AddMacroToList:

    /* Check if name is already defined first */

    DefineInfo = PrMatchDefine (Name);
    if (DefineInfo)
    {
        DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
            "#define: macro name already exists: %s\n",
            Gbl_CurrentLineNumber, Name);

        /* Error only if not exactly the same macro */

        if (strcmp (DefineInfo->Body, BodyInSource) ||
            (DefineInfo->ArgCount != ArgCount))
        {
            PrError (ASL_ERROR, ASL_MSG_EXISTING_NAME,
                THIS_TOKEN_OFFSET (Name));
        }

        goto ErrorExit;
    }

    DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
        "Macro body: %s \n",
        Gbl_CurrentLineNumber, BodyInSource);

    /* Add macro to the #define list */

    DefineInfo = PrAddDefine (Name, BodyInSource, FALSE);
    if (DefineInfo)
    {
        Body = UtLocalCalloc (strlen (BodyInSource) + 1);
        strcpy (Body, BodyInSource);

        DefineInfo->Body = Body;
        DefineInfo->Args = Args;
        DefineInfo->ArgCount = ArgCount;
    }

    return;


ErrorExit:
    ACPI_FREE (Args);
    return;
}
示例#26
0
文件: prscan.c 项目: 9elements/fwts
static void
PrDoDirective (
    char                    *DirectiveToken,
    char                    **Next)
{
    char                    *Token = Gbl_MainTokenBuffer;
    char                    *Token2 = NULL;
    char                    *End;
    UINT64                  Value;
    ACPI_SIZE               TokenOffset;
    int                     Directive;
    ACPI_STATUS             Status;


    if (!DirectiveToken)
    {
        goto SyntaxError;
    }

    Directive = PrMatchDirective (DirectiveToken);
    if (Directive == ASL_DIRECTIVE_NOT_FOUND)
    {
        PrError (ASL_ERROR, ASL_MSG_UNKNOWN_DIRECTIVE,
            THIS_TOKEN_OFFSET (DirectiveToken));

        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "#%s: Unknown directive\n",
            Gbl_CurrentLineNumber, DirectiveToken);
        return;
    }

    /*
     * Emit a line directive into the preprocessor file (.pre) after
     * every matched directive. This is passed through to the compiler
     * so that error/warning messages are kept in sync with the
     * original source file.
     */
    FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\" // #%s\n",
        Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename,
        Gbl_DirectiveInfo[Directive].Name);

    /*
     * If we are currently ignoring this block and we encounter a #else or
     * #elif, we must ignore their blocks also if the parent block is also
     * being ignored.
     */
    if (Gbl_IgnoringThisCodeBlock)
    {
        switch (Directive)
        {
        case PR_DIRECTIVE_ELSE:
        case PR_DIRECTIVE_ELIF:

            if (Gbl_DirectiveStack &&
                Gbl_DirectiveStack->IgnoringThisCodeBlock)
            {
                PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
                return;
            }
            break;

        default:
            break;
        }
    }

    /*
     * Need to always check for #else, #elif, #endif regardless of
     * whether we are ignoring the current code block, since these
     * are conditional code block terminators.
     */
    switch (Directive)
    {
    case PR_DIRECTIVE_ELSE:

        Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
        PrDbgPrint ("Executing", "else block");
        return;

    case PR_DIRECTIVE_ELIF:

        Gbl_IgnoringThisCodeBlock = !(Gbl_IgnoringThisCodeBlock);
        Directive = PR_DIRECTIVE_IF;

        if (Gbl_IgnoringThisCodeBlock == TRUE)
        {
            /* Not executing the ELSE part -- all done here */
            PrDbgPrint ("Ignoring", "elif block");
            return;
        }

        /*
         * After this, we will execute the IF part further below.
         * First, however, pop off the original #if directive.
         */
        if (ACPI_FAILURE (PrPopDirective ()))
        {
            PrError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
                THIS_TOKEN_OFFSET (DirectiveToken));
        }

        PrDbgPrint ("Executing", "elif block");
        break;

    case PR_DIRECTIVE_ENDIF:

        PrDbgPrint ("Executing", "endif");

        /* Pop the owning #if/#ifdef/#ifndef */

        if (ACPI_FAILURE (PrPopDirective ()))
        {
            PrError (ASL_ERROR, ASL_MSG_ENDIF_MISMATCH,
                THIS_TOKEN_OFFSET (DirectiveToken));
        }
        return;

    default:
        break;
    }

    /* Most directives have at least one argument */

    if (Gbl_DirectiveInfo[Directive].ArgCount >= 1)
    {
        Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
        if (!Token)
        {
            goto SyntaxError;
        }
    }

    if (Gbl_DirectiveInfo[Directive].ArgCount >= 2)
    {
        Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
        if (!Token2)
        {
            goto SyntaxError;
        }
    }

    /*
     * At this point, if we are ignoring the current code block,
     * do not process any more directives (i.e., ignore them also.)
     * For "if" style directives, open/push a new block anyway. We
     * must do this to keep track of #endif directives
     */
    if (Gbl_IgnoringThisCodeBlock)
    {
        switch (Directive)
        {
        case PR_DIRECTIVE_IF:
        case PR_DIRECTIVE_IFDEF:
        case PR_DIRECTIVE_IFNDEF:

            PrPushDirective (Directive, Token);
            PrDbgPrint ("Ignoring", Gbl_DirectiveInfo[Directive].Name);
            break;

        default:
            break;
        }

        return;
    }

    /*
     * Execute the directive
     */
    PrDbgPrint ("Begin execution", Gbl_DirectiveInfo[Directive].Name);

    switch (Directive)
    {
    case PR_DIRECTIVE_IF:

        TokenOffset = Token - Gbl_MainTokenBuffer;

        /* Need to expand #define macros in the expression string first */

        Status = PrResolveIntegerExpression (
            &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
        if (ACPI_FAILURE (Status))
        {
            return;
        }

        PrPushDirective (Directive, Token);
        if (!Value)
        {
            Gbl_IgnoringThisCodeBlock = TRUE;
        }

        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "Resolved #if: %8.8X%8.8X %s\n",
            Gbl_CurrentLineNumber, ACPI_FORMAT_UINT64 (Value),
            Gbl_IgnoringThisCodeBlock ? "<Skipping Block>" : "<Executing Block>");
        break;

    case PR_DIRECTIVE_IFDEF:

        PrPushDirective (Directive, Token);
        if (!PrMatchDefine (Token))
        {
            Gbl_IgnoringThisCodeBlock = TRUE;
        }

        PrDbgPrint ("Evaluated", "ifdef");
        break;

    case PR_DIRECTIVE_IFNDEF:

        PrPushDirective (Directive, Token);
        if (PrMatchDefine (Token))
        {
            Gbl_IgnoringThisCodeBlock = TRUE;
        }

        PrDbgPrint ("Evaluated", "ifndef");
        break;

    case PR_DIRECTIVE_DEFINE:
        /*
         * By definition, if first char after the name is a paren,
         * this is a function macro.
         */
        TokenOffset = Token - Gbl_MainTokenBuffer + strlen (Token);
        if (*(&Gbl_CurrentLineBuffer[TokenOffset]) == '(')
        {
#ifndef MACROS_SUPPORTED
            AcpiOsPrintf (
                "%s ERROR - line %u: #define macros are not supported yet\n",
                Gbl_CurrentLineBuffer, Gbl_LogicalLineNumber);
            exit(1);
#else
            PrAddMacro (Token, Next);
#endif
        }
        else
        {
            /* Use the remainder of the line for the #define */

            Token2 = *Next;
            if (Token2)
            {
                while ((*Token2 == ' ') || (*Token2 == '\t'))
                {
                    Token2++;
                }

                End = Token2;
                while (*End != '\n')
                {
                    End++;
                }

                *End = 0;
            }
            else
            {
                Token2 = "";
            }
#if 0
            Token2 = PrGetNextToken (NULL, "\n", /*PR_TOKEN_SEPARATORS,*/ Next);
            if (!Token2)
            {
                Token2 = "";
            }
#endif
            DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
                "New #define: %s->%s\n",
                Gbl_LogicalLineNumber, Token, Token2);

            PrAddDefine (Token, Token2, FALSE);
        }
        break;

    case PR_DIRECTIVE_ERROR:

        /* Note: No macro expansion */

        PrError (ASL_ERROR, ASL_MSG_ERROR_DIRECTIVE,
            THIS_TOKEN_OFFSET (Token));

        Gbl_SourceLine = 0;
        Gbl_NextError = Gbl_ErrorLog;
        CmCleanupAndExit ();
        exit(1);

    case PR_DIRECTIVE_INCLUDE:

        Token = PrGetNextToken (NULL, " \"<>", Next);
        if (!Token)
        {
            goto SyntaxError;
        }

        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "Start #include file \"%s\"\n", Gbl_CurrentLineNumber,
            Token, Gbl_CurrentLineNumber);

        PrDoIncludeFile (Token);
        break;

    case PR_DIRECTIVE_INCLUDEBUFFER:

        Token = PrGetNextToken (NULL, " \"<>", Next);
        if (!Token)
        {
            goto SyntaxError;
        }

        Token2 = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
        if (!Token2)
        {
            goto SyntaxError;
        }

        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "Start #includebuffer input from file \"%s\", buffer name %s\n",
            Gbl_CurrentLineNumber, Token, Token2);

        PrDoIncludeBuffer (Token, Token2);
        break;

    case PR_DIRECTIVE_LINE:

        TokenOffset = Token - Gbl_MainTokenBuffer;

        Status = PrResolveIntegerExpression (
            &Gbl_CurrentLineBuffer[TokenOffset-1], &Value);
        if (ACPI_FAILURE (Status))
        {
            return;
        }

        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "User #line invocation %s\n", Gbl_CurrentLineNumber,
            Token);

        Gbl_CurrentLineNumber = (UINT32) Value;

        /* Emit #line into the preprocessor file */

        FlPrintFile (ASL_FILE_PREPROCESSOR, "#line %u \"%s\"\n",
            Gbl_CurrentLineNumber, Gbl_Files[ASL_FILE_INPUT].Filename);
        break;

    case PR_DIRECTIVE_PRAGMA:

        if (!strcmp (Token, "disable"))
        {
            Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
            if (!Token)
            {
                goto SyntaxError;
            }

            TokenOffset = Token - Gbl_MainTokenBuffer;
            AslDisableException (&Gbl_CurrentLineBuffer[TokenOffset]);
        }
        else if (!strcmp (Token, "message"))
        {
            Token = PrGetNextToken (NULL, PR_TOKEN_SEPARATORS, Next);
            if (!Token)
            {
                goto SyntaxError;
            }

            TokenOffset = Token - Gbl_MainTokenBuffer;
            AcpiOsPrintf ("%s\n", &Gbl_CurrentLineBuffer[TokenOffset]);
        }
        else
        {
            PrError (ASL_ERROR, ASL_MSG_UNKNOWN_PRAGMA,
                THIS_TOKEN_OFFSET (Token));
            return;
        }

        break;

    case PR_DIRECTIVE_UNDEF:

        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "#undef: %s\n", Gbl_CurrentLineNumber, Token);

        PrRemoveDefine (Token);
        break;

    case PR_DIRECTIVE_WARNING:

        PrError (ASL_WARNING, ASL_MSG_WARNING_DIRECTIVE,
            THIS_TOKEN_OFFSET (Token));

        Gbl_SourceLine = 0;
        Gbl_NextError = Gbl_ErrorLog;
        break;

    default:

        /* Should never get here */
        DbgPrint (ASL_PARSE_OUTPUT, PR_PREFIX_ID
            "Unrecognized directive: %u\n",
            Gbl_CurrentLineNumber, Directive);
        break;
    }

    return;

SyntaxError:

    PrError (ASL_ERROR, ASL_MSG_DIRECTIVE_SYNTAX,
        THIS_TOKEN_OFFSET (DirectiveToken));
    return;
}
示例#27
0
文件: prutils.c 项目: 99corps/runtime
void
PrOpenIncludeFile (
    char                    *Filename)
{
    FILE                    *IncludeFile;
    ASL_INCLUDE_DIR         *NextDir;


    /* Start the actual include file on the next line */

    Gbl_CurrentLineOffset++;

    /* Attempt to open the include file */
    /* If the file specifies an absolute path, just open it */

    if ((Filename[0] == '/')  ||
        (Filename[0] == '\\') ||
        (Filename[1] == ':'))
    {
        IncludeFile = PrOpenIncludeWithPrefix ("", Filename);
        if (!IncludeFile)
        {
            goto ErrorExit;
        }
        return;
    }

    /*
     * The include filename is not an absolute path.
     *
     * First, search for the file within the "local" directory -- meaning
     * the same directory that contains the source file.
     *
     * Construct the file pathname from the global directory name.
     */
    IncludeFile = PrOpenIncludeWithPrefix (Gbl_DirectoryPath, Filename);
    if (IncludeFile)
    {
        return;
    }

    /*
     * Second, search for the file within the (possibly multiple)
     * directories specified by the -I option on the command line.
     */
    NextDir = Gbl_IncludeDirList;
    while (NextDir)
    {
        IncludeFile = PrOpenIncludeWithPrefix (NextDir->Dir, Filename);
        if (IncludeFile)
        {
            return;
        }

        NextDir = NextDir->Next;
    }

    /* We could not open the include file after trying very hard */

ErrorExit:
    sprintf (Gbl_MainTokenBuffer, "%s, %s", Filename, strerror (errno));
    PrError (ASL_ERROR, ASL_MSG_INCLUDE_FILE_OPEN, 0);
}
示例#28
0
boolean shellprint (WindowPtr w, boolean fldialog) {

	/*
	9/5/90 dmb:  open and close print resources each time we're called.  also, 
	make sure we close each page opened, even when errors occur
	
	9/28/91 dmb: for exit of edit mode before printing
	
	4/24/92 dmb: make sure bJDocLoop is bSpoolLoop before calling PrPicFile, as 
	per IM II-155.  otherwise, we can get bogus PrErrors
	*/

	// classic mac
	TPPrPort printport;
	TPrStatus printstatus;
	THPrint hp = shellprintinfo.printhandle;

	SInt32	firstPage = 1;
	SInt32	lastPage = 9999;

	short i;
	boolean fl = false;
	
	if (w == nil) /*defensive driving*/
		return (false);

	PrOpen ();
	if (!shellcheckprinterror (true))
		return (false);

	fl = false; /*until sucessfull print, this is return value*/

	if (fldialog) {
		if (!PrJobDialog (hp))
			goto exit;
	}
	else
		PrValidate (hp);

	setcursortype (cursoriswatch);

	shellupdateallnow (); /*update all windows that were dirtied by the print dialog*/

	shellpushglobals (w);

	(*shellglobals.settextmoderoutine) (false); /*make sure editing changes are accepted*/

	pushport (nil); /*save current port on stack*/

	shellprintinfo.printport = printport = PrOpenDoc (hp, nil, nil);
	currentprintport = w;

	/*prepares for printing*/
	(*shellglobals.beginprintroutine) ();

	/*fills in fields of printinfo record*/
	(*shellglobals.setprintinfoproutine) ();
	//this only counts the number of pages.

	// wird in classic lastPage gesetzt?
	if(lastPage > shellprintinfo.ctpages)
		lastPage = shellprintinfo.ctpages;

	for (i = 1; i <= lastPage; i++) { /*print one page*/

		if (PrError () != noErr)
			break;

		PrOpenPage (printport, nil);

		if (PrError () == noErr) {

			SetFractEnable (true);

			fl = (*shellglobals.printroutine) (i);

			SetFractEnable (false);
		}

		PrClosePage (printport);

		if (!fl)
			break;

		if (keyboardescape ()) {

			PrSetError (iPrAbort);

		}
	} /*for*/

	PrCloseDoc (printport);

	if (fl) {

		if (	(PrError () == noErr)
			&& ((**hp).prJob.bJDocLoop == bSpoolLoop))
		{
			PrPicFile (hp, nil, nil, nil, &printstatus);
		}

		fl = shellcheckprinterror (false);
	}

	popport ();
	
	(*shellglobals.endprintroutine) ();

	shellpopglobals ();

exit:

	PrClose ();

	currentprintport = NULL;

	return (fl);

	} /*shellprint*/
示例#29
0
void
PrDoMacroInvocation (
    char                    *TokenBuffer,
    char                    *MacroStart,
    PR_DEFINE_INFO          *DefineInfo,
    char                    **Next)
{
    PR_MACRO_ARG            *Args;
    char                    *Token = NULL;
    UINT32                  TokenOffset;
    UINT32                  Length;
    UINT32                  i;


    /* Take a copy of the macro body for expansion */

    strcpy (Gbl_MacroTokenBuffer, DefineInfo->Body);

    /* Replace each argument within the prototype body */

    Args = DefineInfo->Args;
    if (!Args->Name)
    {
        /* This macro has no arguments */

        Token = PrGetNextToken (NULL, PR_MACRO_ARGUMENTS, Next);
        if (!Token)
        {
            goto BadInvocation;
        }

        TokenOffset = (MacroStart - TokenBuffer);
        Length = Token - MacroStart + strlen (Token) + 1;

        PrReplaceData (
            &Gbl_CurrentLineBuffer[TokenOffset], Length,
            Gbl_MacroTokenBuffer, strlen (Gbl_MacroTokenBuffer));
        return;
    }

    while (Args->Name)
    {
        /* Get the next argument from macro invocation */

        Token = PrGetNextToken (NULL, PR_MACRO_SEPARATORS, Next);
        if (!Token)
        {
            goto BadInvocation;
        }

        /* Replace all instances of this argument */

        for (i = 0; i < Args->UseCount; i++)
        {
            /* Offset zero indicates "arg not used" */
            /* TBD: Not really needed now, with UseCount available */

            if (Args->Offset[i] == 0)
            {
                break;
            }

            PrReplaceData (
                &Gbl_MacroTokenBuffer[Args->Offset[i]], strlen (Args->Name),
                Token, strlen (Token));

            DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
                "ExpandArg: %s \n",
                Gbl_CurrentLineNumber, Gbl_MacroTokenBuffer);
        }

        Args++;
    }

    /* TBD: need to make sure macro was not invoked with too many arguments */

    if (!Token)
    {
        return;
    }

    /* Replace the entire macro invocation with the expanded macro */

    TokenOffset = (MacroStart - TokenBuffer);
    Length = Token - MacroStart + strlen (Token) + 1;

    PrReplaceData (
        &Gbl_CurrentLineBuffer[TokenOffset], Length,
        Gbl_MacroTokenBuffer, strlen (Gbl_MacroTokenBuffer));

    return;


BadInvocation:
    PrError (ASL_ERROR, ASL_MSG_INVALID_INVOCATION,
        THIS_TOKEN_OFFSET (MacroStart));

    DbgPrint (ASL_DEBUG_OUTPUT, PR_PREFIX_ID
        "Bad macro invocation: %s \n",
        Gbl_CurrentLineNumber, Gbl_MacroTokenBuffer);
    return;
}
示例#30
0
boolean shellinitprint (void) {
	
	/*
	 9/5/90 dmb: close print resources after initializing stuff
	 
	 10/21/91 dmb: added margins field to print info; structure is now here to 
	 have user-settable margins.
	 
	 12/31/91 dmb: initialize shellprintinfo.paperrect to standard 72dpi values in 
	 case no printer is chosen and shellcopyprintinfo never gets called
	 
	 1/18/93 dmb: don't call shellcheckprinterror the first time; if PrOpen fails 
	 here, we don't want to raise an alert.
	 */
	
#if MACVERSION && !TARGET_API_MAC_CARBON
	
	Handle h;
	
#endif
	
	currentprintport = NULL;
	
	clearbytes (&shellprintinfo, longsizeof (shellprintinfo));
	
	setrect (&shellprintinfo.margins, 36, 36, 36, 36);
	
	setrect (&shellprintinfo.paperrect, 5, 6, 725, 546); /*defaults in case PrOpen fails*/
	
	shellprintinfo.scaleMult = 1;
	shellprintinfo.scaleDiv = 1;
	
#ifdef MACVERSION
	
#	if TARGET_API_MAC_CARBON == 1
	
	//I realized this is only called once during the startup of the app.
	//Carbon printing really doesn't need any global structures. Better to 
	//allocate them as we use them.
	
	// Nope.
	// We need a global var for calling page setup
	
	shellprintinfo.printport = nil;
	shellprintinfo.printhandle = nil;
	shellprintinfo.pageformat = nil;
	shellprintinfo.printsettings = nil;
	// shellprintinfo.pagerect = {0,0,0,0};
	
#	else		
	
	if (!newclearhandle (longsizeof (TPrint), &h))
		return (false);
	
	shellprintinfo.printhandle = (THPrint) h; /*copy into print record*/
	
	PrOpen (); /*initialize the Mac print manager*/
	
	if (PrError () != noErr)
		goto error;
	
	PrintDefault (shellprintinfo.printhandle); /*set default print record*/
	
	PrClose (); /*shouldn't leave print resources open all the time*/
	
	if (!shellcheckprinterror (false)) 
		goto error;
#	endif
	
#endif
	
#ifdef WIN95VERSION
	
	ZeroMemory (&shellprintinfo.pagesetupinfo, sizeof (PAGESETUPDLG));
	
	shellprintinfo.pagesetupinfo.lStructSize = sizeof (PAGESETUPDLG);
	
	shellprintinfo.pagesetupinfo.hwndOwner = NULL;
	
	shellprintinfo.pagesetupinfo.Flags = PSD_RETURNDEFAULT | PSD_NOWARNING;
	
	if (! PageSetupDlg (&shellprintinfo.pagesetupinfo)) {
		
		if (CommDlgExtendedError() != 0)
			goto error;
	}
	
#endif
	
	//#if !TARGET_API_MAC_CARBON
	
	shellcopyprintinfo (); /*copies fields from handle into record*/
	
	//#endif
	
	return (true);
	
#if !defined(MACVERSION) || !TARGET_API_MAC_CARBON
	
error:
		
#endif
		
		/*
		 shelldisposeprintinfo ();
		 */
		
		return (false);
} /*shellinitprint*/