コード例 #1
0
ファイル: cphoto.cpp プロジェクト: sdutz/QPhoto
//----------------------------------------------------
CPhoto::CPhoto( QWidget *parent) :
    QDialog( parent),
    ui( new Ui::CPhoto)
{
    ui->setupUi(this) ;
    setModal( false) ;
    setWindowTitle( QPHOTO);
    m_szFileName    = "" ;
    m_nCurr         = -1 ;
    m_bChanged      = false ;
    m_bFullScreen   = false ;
    m_bShowHelp     = false ;
    m_bShiftPressed = false ;
    m_bCtrlPressed  = false ;
    m_szExt         = ".jpeg.jpg" ;
    m_szFilters     = "Images (*.jpeg *.jpg)" ;
    setMinimumSize( MIN_WIDTH, MIN_HEIGHT) ;
    m_pConf = new ConfMgr() ;
    m_pColl = new CollectionMgr() ;
    m_pConf->SetDbMgr( m_pColl) ;
    InitLang() ;
    SetIds() ;
    CreateActions() ;
    CreateTimers() ;
    BuildContextMenu() ;
    BuildSlideShowMenu() ;
    ui->ImgView->SetConfMgr( m_pConf) ;
    ui->ImgView->PrepareSlideshowItems() ;
    SetBtnIcons() ;
    setAcceptDrops( true) ;
    m_player.setPlaylist( &m_playList) ;
    RetranslateDialog() ;
    InitDialogs() ;
}
コード例 #2
0
ファイル: CROSS.CPP プロジェクト: NOAA-ORR-ERD/PyGnome
void BasicInit()
#ifdef MAC
{
	void InitColors();
#if MACB4CARBON  
	short i;
	Ptr stackTop;
	// JLMextern _DataInit();
	
	stackTop = GetApplLimit();
	
	
	SetApplLimit((void *)(stackTop - (Ptr)30000));
	// SetApplLimit((void *)(*(long *)csb - 30000));
	MaxApplZone();
	for (i = 1 ; i <= 16 ; i++) MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	FlushEvents(everyEvent, 0);
#endif
	InitCursor();
	
	InitColors();
}
コード例 #3
0
int main ()
{
	int ret;
	Rect windRect;
	long start,end,amount;
	
	/* Initialize all the needed managers. */
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();

	//ProfilerInit(collectDetailed, bestTimeBase, 1000, 50);
	//ProfilerSetStatus(true);

	windRect = qd.screenBits.bounds;
	InsetRect(&windRect, 50, 50);
	pWindow = NewCWindow(nil, &windRect, "\pMpeg", true, documentProc, (WindowPtr) -1, false, 0);
    
    start = TickCount();
    main2();
    end = TickCount();
    amount = end - start;
    fprintf(stderr, "Time taken %d memoryAllocator %d \n", amount,counter);

   //	ProfilerDump("\pProfile.out");
     
    do {
	} while (!Button());


}
コード例 #4
0
ファイル: ugView.c プロジェクト: rolk/ug
int main (void)
{
  /* init the Macintosh toolbox */
  InitGraf(&qd.thePort);
  InitFonts();
  FlushEvents(everyEvent,0);
  InitWindows();
  InitMenus();
  TEInit();
  InitDialogs(nil);
  InitCursor();

  /* read the screen's size */
  screenx = ((qd.screenBits).bounds).right;
  screeny = ((qd.screenBits).bounds).bottom;
  SetRect(&dragRect,4,24,((qd.screenBits).bounds).right-4,((qd.screenBits).bounds).bottom-4);


  SetUpMenus ();
  SetState(CLOSED);
  OpenCommand();

  /* handle events till the end */
  while (!quitFlag)
  {
    ProcessEvent();
  }

  return(0);
}
コード例 #5
0
ファイル: Full.cpp プロジェクト: staylo/XCSoar
lua_State *
Lua::NewFullState()
{
  lua_State *L = NewBasicState();

  InitLog(L);
  InitPersistent(L);
  InitTimer(L);
  InitMap(L);
  InitBlackboard(L);
  InitDialogs(L);
  InitLegacy(L);
  InitAirspace(L);
  InitTask(L);
  InitSettings(L);
  InitWind(L);
  InitLogger(L);
  InitTracking(L);
  InitReplay(L);
  InitInputEvent(L);

  {
    SetPackagePath(L,
                   WideToUTF8Converter(LocalPath(_T("lua" DIR_SEPARATOR_S "?.lua")).c_str()));
  }

  return L;
}
コード例 #6
0
/*
=============
InitMacStuff
=============
*/
void InitMacStuff( void ) {
	Handle 		menuBar;
	char		dir[MAX_OSPATH];
	
	// init toolbox
	MaxApplZone();
	MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);
	SetEventMask( -1 );
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();

	// init menu
	menuBar = GetNewMBar(rMenuBar);
	if(!menuBar) {
		Com_Error( ERR_FATAL, "MenuBar not found.");
	}
	
	SetMenuBar(menuBar);
	DisposeHandle(menuBar);
	AppendResMenu(GetMenuHandle(mApple),'DRVR');
	DrawMenuBar();

	Sys_InitConsole();

	SetEventMask( -1 );
}
コード例 #7
0
ファイル: iappmac.c プロジェクト: Feneric/xconq
static int
MacintoshInit()
{
    MaxApplZone();
    MoreMasters();
    MoreMasters();
    MoreMasters();
    MoreMasters();

    tcl_macQdPtr = &qd;

     if (TkMacHaveAppearance()) {
         RegisterAppearanceClient();
     }

    InitGraf(&tcl_macQdPtr->thePort);
    InitFonts();

    if (TkMacHaveAppearance() >= 0x110) {
	InitFloatingWindows();
    } else {
	InitWindows();
    }

    InitMenus();
    InitDialogs((long) NULL);		
    InitCursor();

    FlushEvents(everyEvent, 0);
    SetEventMask(everyEvent);
    Tcl_MacSetEventProc(TkMacConvertEvent);

    return TCL_OK;
}
コード例 #8
0
// --------------------------------------------------------------------------------------
static void initialize(void)
{
	MenuBarHandle menuBar;
	OSErr error;
	
	MoreMasters();				// I doubt we actually need any extra master pointers 
	InitGraf(&qd.thePort);		// but I left the calls here as a reminder for where they 
	InitFonts();				// belong if they are needed
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
	
	InitCursor();
	RegisterAppearanceClient();
	
	menuBar = GetNewMBar(rMenuBar);		// draw the menu bar as soon as possible
	if (menuBar == NULL)
		ExitToShell();
	SetMenuBar(menuBar);
	DrawMenuBar();
	
		// do non time sensitive initialization after we get the application event loop going
	gOpenAppAEHandler = NewAEEventHandlerUPP(openApplicationAEHandler);
	error = AEInstallEventHandler(kCoreEventClass, kAEOpenApplication, gOpenAppAEHandler, 0, 
									false);
	if (error != noErr)
		ExitToShell();
	
		/* If we supported them, we would install open documents and print documents 
		   handlers here and we would do most of the same initialization stuff that we 
		   do in the open application handler. */
	
	FlushEvents(everyEvent, 0);
}
コード例 #9
0
static void InitMacToolbox (void)
{
	InitGraf (&qd.thePort);
	InitFonts ();
	InitWindows ();
	InitMenus ();
	TEInit ();
	InitDialogs (nil);
}
コード例 #10
0
ファイル: shell.c プロジェクト: MaddTheSane/tntbasic
/* ----------- private code */
static void initialize_application(
	void)
{
	Handle menubar;
	StringHandle		userName;

#ifndef OP_PLATFORM_MAC_CARBON_FLAG
	MaxApplZone();
	MoreMasters();
	MoreMasters();
	MoreMasters();
	
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(NULL);
#else
	MoreMasterPointers(192);
#endif // ! OP_PLATFORM_MAC_CARBON_FLAG

	InitCursor();

	FlushEvents(everyEvent, 0);

	menubar= GetNewMBar(rMENU_BAR_ID);
	op_assert(menubar);

	SetMenuBar(menubar);
	DisposeHandle(menubar);
	AppendResMenu(GetMenuHandle(mApple), 'DRVR');
	DrawMenuBar();

	//	Get the user name from the systemÉ
	
	userName = GetString (-16096);
	if (userName == NULL)
		strcpy(gNameString, "OpenPlay Test");
	else
	{
		doCopyP2CStr(*userName,gNameString);
		ReleaseResource ((Handle) userName);
	}

	// ecf - we wanna enable enumeration by default...
	check_menu_item(mSpecial, iActiveEnumeration, active_enumeration);
	
	//install apple event handler for quitting
	AEInstallEventHandler(kCoreEventClass,kAEQuitApplication,NewAEEventHandlerUPP((AEEventHandlerProcPtr)do_quit_apple_event),0L,false);
	
	return;
}
コード例 #11
0
ファイル: ftlint_m.c プロジェクト: anoopadvaitha/lincodelib
static void
init_toolbox()
{
    InitGraf(&qd.thePort);
    InitFonts();
    InitWindows();
    TEInit();
    InitDialogs((long)0);
    InitMenus();
    InitCursor();
    SIOUXSettings.asktosaveonclose = 0;
}
コード例 #12
0
ファイル: viewer.cpp プロジェクト: poppeman/Pictus
	void Viewer::ViewportMode(ScreenMode newMode)
	{
		if (m_screenMode == newMode)
		{
			return;
		}

		m_screenMode = newMode;

		if (newMode == Viewer::SM_Fullscreen)
		{
			m_userInitiatedMove = false;
			wxDisplay mon(DisplayFromPointFallback(PositionScreen()));

			m_statusBar->Show(false);
			m_previousWindowStyle = GetWindowStyle();
			SetWindowStyleFlag(wxBORDER_NONE);
			m_previousWindowRegion = wxToRect(GetRect());
			auto monRegion = wxToRect(mon.GetClientArea());

			SetSize(monRegion.Left(), monRegion.Top(), monRegion.Width(), monRegion.Height());
			m_viewPort.ActiveCursorMode(ViewPort::CursorHideAutomatic);
			Raise();
			m_userInitiatedMove = true;
		}
		else
		{
			m_userInitiatedMove = false;
			SetWindowStyleFlag(m_previousWindowStyle);
			m_statusBar->Show(m_cfg.View.ShowStatusBar);
			SetSize(m_previousWindowRegion.Left(), m_previousWindowRegion.Top(), m_previousWindowRegion.Width(), m_previousWindowRegion.Height());
			m_viewPort.ActiveCursorMode(ViewPort::CursorShow);
			m_userInitiatedMove = true;
		}

		// Make sure that the settings and adjust dialogs are on top (if running)
		InitDialogs();
		if (m_settings->IsVisible())
		{
			ShowSettings();
		}

		if (m_adjust->IsVisible())
		{
			ShowAdjust();
		}

		ImageChanged();
		UpdateImageInformation();
	}
コード例 #13
0
ファイル: MacInstallWizard.c プロジェクト: rn10950/RetroZilla
void InitManagers(void)
{
	MaxApplZone();	
	MoreMasters(); MoreMasters(); MoreMasters();
	
	InitGraf(&qd.thePort);  
	InitFonts();			
	InitWindows();
	InitMenus();
	TEInit();				
	InitDialogs(NULL);
	
	InitCursor();		
	FlushEvents(everyEvent, 0);	
}
コード例 #14
0
static void
init_toolbox()
{
#ifndef USING_CARBON
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	TEInit();
	InitDialogs((long)0);
	InitMenus();
	InitCursor();
#endif

	SIOUXSettings.asktosaveonclose = 0;
}
コード例 #15
0
ファイル: Retro68Test.c プロジェクト: clehner/Retro68Test
void Initialize(void)
{
	InitGraf((Ptr) &qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);

	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(nil);
	InitCursor();
	
	SetUpMenus();

}
コード例 #16
0
ファイル: CRSVMAC.C プロジェクト: marcinch18/nasa-cosmic
InitMacInterface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheWindow = NULL;
   
   /*=========================*/
   /* Initialize the windows. */
   /*=========================*/
      
   InitDisplayWindow();
   InitFileListWindow();
  }
コード例 #17
0
    virtual HRESULT DeviceCreated(ID3D11Device* pDevice)
    {
        TwInit(TW_DIRECT3D11, pDevice);
        TwDefine("GLOBAL fontstyle=fixed contained=true");
        InitDialogs();

        static bool s_bFirstTime = true;
        if (s_bFirstTime)
        {
            s_bFirstTime = false;
            D3DXVECTOR3 eyePt = D3DXVECTOR3(1200.0f, -350.0f, 0.0f);
            D3DXVECTOR3 lookAtPt = D3DXVECTOR3(0.0f, -500.0f, 0.0f);
            this->camera->SetViewParams(&eyePt, &lookAtPt);
            this->camera->SetScalers(0.005f, 500.0f);
            this->camera->SetRotateButtons(true, false, true, false);
        }

        return S_OK;
    }
コード例 #18
0
ファイル: tclMacAppInit.c プロジェクト: AsvAgent/ASV
static int
MacintoshInit()
{
#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();

#if defined(THINK_C)

    /* Set options for Think C console package */
    /* The console package calls the Mac init calls */
    console_options.pause_atexit = 0;
    console_options.title = "\pTcl Interpreter";
		
#elif defined(__MWERKS__)

    /* Set options for CodeWarrior SIOUX package */
    SIOUXSettings.autocloseonquit = true;
    SIOUXSettings.showstatusline = true;
    SIOUXSettings.asktosaveonclose = false;
    SIOUXSettings.wasteusetempmemory = true;    
    InstallConsole(0);
    SIOUXSetTitle("\pTcl Interpreter");
		
#elif defined(applec)

    /* Init packages used by MPW SIOW package */
    InitGraf((Ptr)&qd.thePort);
    InitFonts();
    InitWindows();
    InitMenus();
    TEInit();
    InitDialogs(nil);
    InitCursor();
		
#endif

    Tcl_MacSetEventProc((Tcl_MacConvertEventPtr) SIOUXHandleOneEvent);
    
    /* No problems with initialization */
    return TCL_OK;
}
コード例 #19
0
ファイル: main.cpp プロジェクト: 151706061/D3DSamples
	virtual HRESULT DeviceCreated(ID3D11Device* pDevice) 
	{ 
		TwInit(TW_DIRECT3D11, pDevice);        
		TwDefine("GLOBAL fontstyle=fixed contained=true");
		InitDialogs();

		static bool s_bFirstTime = true;
		if (s_bFirstTime)
		{
			s_bFirstTime = false;
			D3DXVECTOR3 eyePt = D3DXVECTOR3(0.0f, 10.0f, -20.0f);
			D3DXVECTOR3 lookAtPt = D3DXVECTOR3(0.0f, 10.0f, 0.0f);
			this->camera->SetViewParams(&eyePt, &lookAtPt);
			this->camera->SetModelCenter(lookAtPt);
			this->camera->SetButtonMasks(MOUSE_LEFT_BUTTON, MOUSE_WHEEL, MOUSE_RIGHT_BUTTON);
		}

		return S_OK;
	}
コード例 #20
0
ファイル: np2.cpp プロジェクト: perabuss/np2wii
static void InitToolBox(void) {

#if !TARGET_CARBON
	MaxApplZone();
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(0);
#endif
	FlushEvents(everyEvent, 0);
	InitCursor();

#ifdef TARGET_API_MAC_CARBON
	AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
						AEProc(handleQuitApp), 0L, false);
#endif
}
コード例 #21
0
ToolBox::ToolBox(void)
{
	short i;
	/* if you have stack requirements that differ from the default, 
		then you counld use SetApplLimit to increase StackSpace at
		this point, before calling MaxApplZone */
		
	MaxApplZone();
	for(i = 0; i < 50; i++)
		MoreMasters();

	//notice the following order is important
	InitGraf(&(qd.thePort));
	InitFonts();
	InitWindows();
	InitMenus();
	TEInit();
	InitDialogs(0L);
	InitCursor();
	FlushEvents( everyEvent, REMOVE_EVENTS);
}
コード例 #22
0
ファイル: main.c プロジェクト: cosyverif/deb-greatspn
void	InitOther()
{
   edit_file[0] = '\0';
   
/*    puts("    ...  start init_net"); fflush(stdout);*/
   if (init_net() == 0)
      exit(1);
   
   {
      register int    i;
      for (i = 0; i < MAX_BKUP; bkup_netobj[i++] = NULL);
   }
   
   ISQRT2 = (double) 1 / sqrt((double) 2.0);
/*    puts("    ...  start reset_net_object"); fflush(stdout);*/
   reset_net_object(&selected);
/*    puts("    ...  start InitMouseHelpDialog"); fflush(stdout);*/
   InitMouseHelpDialog();
/*    puts("    ...  start init_panel"); fflush(stdout);*/
   init_panel(); 
/*    puts("    ...  start InitDialogs"); fflush(stdout);*/
   InitDialogs();
  /*
    puts("    ...  start setup_initialstate"); fflush(stdout);
   setup_initialstate();
  */
/*    puts("    ...  start InitOptions"); fflush(stdout);*/
   InitOptions();

/*    puts("    ...  start init_animation"); fflush(stdout);*/
   init_animation();
   
/*    puts("    ...  start clear_proc_f"); fflush(stdout);*/
   clear_proc_f();	
   
  /* ?????????????? */
/*    puts("    ...  start init_setup_initialstate"); fflush(stdout);*/
   setup_initialstate();
  /* ?????????????? */
}
コード例 #23
0
ファイル: main.c プロジェクト: dvincent/frontier
static void initmacintosh (void) {

	/*
	the magic stuff that every Macintosh application needs to do 
	before doing anything else.
	*/

	short i;
		
	MaxApplZone ();
	
	for (i = 0; i < 10; i++) 
		MoreMasters ();
	
	InitGraf (&qd.thePort);
	
	InitFonts ();
	
	FlushEvents (everyEvent, 0);
	
	InitWindows ();
	
	InitMenus ();
	
	TEInit ();
	
	InitDialogs (0L);
	
	InitCursor ();
	
	for (i = 0; i < 5; i++) { /*register with Multifinder*/
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/
		} /*for*/
	} /*initmacintosh*/
コード例 #24
0
ファイル: macpgen.c プロジェクト: LapsedAcademicsInc/putty
static void mac_startup(void) {
    Handle menuBar;
    TECInfoHandle ti;

#if !TARGET_API_MAC_CARBON
    /* Init Memory Manager */
    MaxApplZone();
    /* Init QuickDraw */
    InitGraf(&qd.thePort);
    /* Init Font Manager */
    InitFonts();
    /* Init Window Manager */
    InitWindows();
    /* Init Menu Manager */
    InitMenus();
    /* Init TextEdit */
    TEInit();
    /* Init Dialog Manager */
    InitDialogs(NULL);
#endif
    
    /* Get base system version (only used if there's no better selector) */
    if (Gestalt(gestaltSystemVersion, &mac_gestalts.sysvers) != noErr ||
	(mac_gestalts.sysvers &= 0xffff) < 0x700)
	fatalbox("PuTTYgen requires System 7 or newer");
    /* Find out if we've got Color Quickdraw */
    if (Gestalt(gestaltQuickdrawVersion, &mac_gestalts.qdvers) != noErr)
    	mac_gestalts.qdvers = gestaltOriginalQD;
    /* ... and the Appearance Manager? */
    if (Gestalt(gestaltAppearanceVersion, &mac_gestalts.apprvers) != noErr)
	if (Gestalt(gestaltAppearanceAttr, NULL) == noErr)
	    mac_gestalts.apprvers = 0x0100;
	else
	    mac_gestalts.apprvers = 0;
#if TARGET_RT_MAC_CFM
    /* Paranoia: Did we manage to pull in AppearanceLib? */
    if (&RegisterAppearanceClient == kUnresolvedCFragSymbolAddress)
	mac_gestalts.apprvers = 0;
#endif
#if TARGET_CPU_68K
    mac_gestalts.cntlattr = 0;
    mac_gestalts.windattr = 0;
#else
    /* Mac OS 8.5 Control Manager (proportional scrollbars)? */
    if (Gestalt(gestaltControlMgrAttr, &mac_gestalts.cntlattr) != noErr ||
	&SetControlViewSize == kUnresolvedCFragSymbolAddress)
	mac_gestalts.cntlattr = 0;
    /* Mac OS 8.5 Window Manager? */
    if (Gestalt(gestaltWindowMgrAttr, &mac_gestalts.windattr) != noErr ||
	&SetWindowContentColor == kUnresolvedCFragSymbolAddress)
	mac_gestalts.windattr = 0;
#endif
    /* Text Encoding Conversion Manager? */
    if (
#if TARGET_RT_MAC_CFM
	&TECGetInfo == kUnresolvedCFragSymbolAddress ||
#else
	InitializeUnicodeConverter(NULL) != noErr ||
#endif
	TECGetInfo(&ti) != noErr)
	mac_gestalts.encvvers = 0;
    else {
	mac_gestalts.encvvers = (*ti)->tecVersion;
	mac_gestalts.uncvattr = (*ti)->tecUnicodeConverterFeatures;
	DisposeHandle((Handle)ti);
    }
    /* Navigation Services? */
    if (NavServicesAvailable())
	mac_gestalts.navsvers = NavLibraryVersion();
    else
	mac_gestalts.navsvers = 0;

    /* We've been tested with the Appearance Manager */
    if (mac_gestalts.apprvers != 0)
	RegisterAppearanceClient();

    menuBar = GetNewMBar(128);
    if (menuBar == NULL)
	fatalbox("Unable to create menu bar.");
    SetMenuBar(menuBar);
    AppendResMenu(GetMenuHandle(mApple), 'DRVR');
    mac_adjustmenus();
    DrawMenuBar();
    InitCursor();
    windows.about = NULL;
    windows.licence = NULL;

    flags = FLAG_INTERACTIVE;

    /* Install Apple Event handlers. */
#if 0
    AEInstallEventHandler(kCoreEventClass, kAEOpenApplication,
			  NewAEEventHandlerUPP(&mac_aevt_oapp), 0, FALSE);
    AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments,
			  NewAEEventHandlerUPP(&mac_aevt_odoc), 0, FALSE);
    AEInstallEventHandler(kCoreEventClass, kAEPrintDocuments,
			  NewAEEventHandlerUPP(&mac_aevt_pdoc), 0, FALSE);
#endif
    AEInstallEventHandler(kCoreEventClass, kAEQuitApplication,
			  NewAEEventHandlerUPP(&mac_aevt_quit), 0, FALSE);
}
コード例 #25
0
ファイル: viewer.cpp プロジェクト: poppeman/Pictus
	void Viewer::ShowSettings()
	{
		InitDialogs();
		m_settings->Show(true);
		m_settings->Raise();
	}
コード例 #26
0
ファイル: HTLine.c プロジェクト: svagionitis/libwww
int main (int argc, char ** argv)
{
    int		status = 0;	
    int		arg;
    int		tokencount = 0;
    BOOL	formdata = NO;
    HTChunk *	keywords = NULL;			/* From command line */
    HTAssocList*formfields = NULL;
    HTMethod	method = METHOD_GET;			    /* Default value */
    ComLine *	cl = ComLine_new();
    BOOL	cache = NO;			     /* Use persistent cache */
    BOOL	flush = NO;		       /* flush the persistent cache */
    char *	cache_root = NULL;

    /* Starts Mac GUSI socket library */
#ifdef GUSI
    GUSISetup(GUSIwithSIOUXSockets);
    GUSISetup(GUSIwithInternetSockets);
#endif

#ifdef __MWERKS__ /* STR */
    InitGraf((Ptr) &qd.thePort); 
    InitFonts(); 
    InitWindows(); 
    InitMenus(); TEInit(); 
    InitDialogs(nil); 
    InitCursor();
    SIOUXSettings.asktosaveonclose = false;
    argc=ccommand(&argv);
#endif

    /* Initiate W3C Reference Library with a client profile */
    HTProfile_newNoCacheClient(APP_NAME, APP_VERSION);

    /* Need our own trace and print functions */
    HTPrint_setCallback(printer);
    HTTrace_setCallback(tracer);

    /*
    ** Delete the default Username/password handler so that we can handle
    ** parameters handed to us from the command line. The default is set
    ** by the profile.
    */
    HTAlert_deleteOpcode(HT_A_USER_PW);
    HTAlert_add(PromptUsernameAndPassword, HT_A_USER_PW);

    /*
    ** Add default content decoder. We insert a through line as it doesn't
    ** matter that we get an encoding that we don't know.
    */
    HTFormat_addCoding("*", HTIdentityCoding, HTIdentityCoding, 0.3);

    /* Scan command Line for parameters */
    for (arg=1; arg<argc; arg++) {
	if (*argv[arg] == '-') {
	    
	    /* - alone => filter */
	    if (argv[arg][1] == '\0') {
		cl->flags |= CL_FILTER;	   
	    
	    /* -? or -help: show the command line help page */
	    } else if (!strcmp(argv[arg],"-?") || !strcmp(argv[arg],"-help")) {
		cl->anchor = (HTParentAnchor *) HTAnchor_findAddress(W3C_HELP);
		tokencount = 1;

	    /* non-interactive */
	    } else if (!strcmp(argv[arg], "-n")) {
		HTAlert_setInteractive(NO);

	    /* Treat the keywords as form data with a <name> "=" <value> */
	    } else if (!strcmp(argv[arg], "-form")) {
		formdata = YES;

	    /* from -- Initial represntation (only with filter) */
	    } else if (!strcmp(argv[arg], "-from")) {
		cl->format = (arg+1 < argc && *argv[arg+1] != '-') ?
		    HTAtom_for(argv[++arg]) : WWW_HTML;

	    /* to -- Final representation */
	    } else if (!strcmp(argv[arg], "-to")) {
		HTFormat format = (arg+1 < argc && *argv[arg+1] != '-') ?
		    HTAtom_for(argv[++arg]) : DEFAULT_FORMAT;
		HTRequest_setOutputFormat(cl->request, format);

	    /* destination for PUT, POST etc. */
	    } else if (!strcmp(argv[arg], "-dest")) {
		if (arg+1 < argc && *argv[arg+1] != '-') {
		    char * dest = HTParse(argv[++arg], cl->cwd, PARSE_ALL);
		    cl->dest = (HTParentAnchor *) HTAnchor_findAddress(dest);
		    HT_FREE(dest);
		}

	    /* source please */
	    } else if (!strcmp(argv[arg], "-source")) {
		HTRequest_setOutputFormat(cl->request, WWW_RAW);

	    /* log file */
	    } else if (!strcmp(argv[arg], "-l")) {
		cl->logfile = (arg+1 < argc && *argv[arg+1] != '-') ?
		    argv[++arg] : DEFAULT_LOG_FILE;

	    /* Max forward hops in case of TRACE request */
	    } else if (!strcmp(argv[arg], "-hops") ||
		       !strcmp(argv[arg], "-maxforwards")) {
		int hops = (arg+1 < argc && *argv[arg+1] != '-') ?
		    atoi(argv[++arg]) : DEFAULT_HOPS;
		if (hops >= 0) HTRequest_setMaxForwards(cl->request, hops);

	    /* automated authentication of format user:password@realm */
	    } else if (!strncmp(argv[arg], "-auth", 5)) {
		char * credentials = (arg+1 < argc && *argv[arg+1] != '-') ?
		    argv[++arg] : NULL;
		if (credentials) ParseCredentials(cl, credentials);

	    /* rule file */
	    } else if (!strcmp(argv[arg], "-r")) {
		cl->rules = (arg+1 < argc && *argv[arg+1] != '-') ?
		    argv[++arg] : DEFAULT_RULE_FILE;

	    /* output filename */
	    } else if (!strcmp(argv[arg], "-o")) { 
		cl->outputfile = (arg+1 < argc && *argv[arg+1] != '-') ?
		    argv[++arg] : DEFAULT_OUTPUT_FILE;

	    /* timeout -- Change the default request timeout */
	    } else if (!strcmp(argv[arg], "-timeout")) {
		int timeout = (arg+1 < argc && *argv[arg+1] != '-') ?
		    atoi(argv[++arg]) : DEFAULT_TIMEOUT;
		if (timeout >= 1) cl->timer = timeout*MILLIES;

	    /* preemptive or non-preemptive access */
	    } else if (!strcmp(argv[arg], "-single")) {
		HTRequest_setPreemptive(cl->request, YES);

	    /* content Length Counter */
	    } else if (!strcmp(argv[arg], "-cl")) { 
		cl->flags |= CL_COUNT;

	    /* print version and exit */
	    } else if (!strcmp(argv[arg], "-version")) { 
		VersionInfo(argv[0]);
		Cleanup(cl, 0);

	    /* run in quiet mode */
	    } else if (!strcmp(argv[arg], "-q")) { 
		cl->flags |= CL_QUIET;

	    /* Start the persistent cache */
	    } else if (!strcmp(argv[arg], "-cache")) {
		cache = YES;

	    /* Determine the cache root */
	    } else if (!strcmp(argv[arg], "-cacheroot")) { 
		cache_root = (arg+1 < argc && *argv[arg+1] != '-') ?
		    argv[++arg] : NULL;

	    /* Persistent cache flush */
	    } else if (!strcmp(argv[arg], "-flush")) {
		flush = YES;

	    /* Do a cache validation */
	    } else if (!strcmp(argv[arg], "-validate")) {
		cl->flags |= CL_VALIDATE;

	    /* Do an end-to-end cache-validation */
	    } else if (!strcmp(argv[arg], "-endvalidate")) {
		cl->flags |= CL_END_VALIDATE;

	    /* Force complete reload */
	    } else if (!strcmp(argv[arg], "-nocache")) {
		cl->flags |= CL_CACHE_FLUSH;

#ifdef WWWTRACE
	    /* trace flags */
	    } else if (!strncmp(argv[arg], "-v", 2)) {
		HTSetTraceMessageMask(argv[arg]+2);
#endif

	    /* GET method */
	    } else if (!strcasecomp(argv[arg], "-get")) {
		method = METHOD_GET;

	    /* HEAD method */
	    } else if (!strcasecomp(argv[arg], "-head")) {
		method = METHOD_HEAD;

	    /* DELETE method */
	    } else if (!strcasecomp(argv[arg], "-delete")) {
		method = METHOD_DELETE;

	    /* POST Method */
	    } else if (!strcasecomp(argv[arg], "-post")) {
		method = METHOD_POST;

	    /* PUT Method */
	    } else if (!strcasecomp(argv[arg], "-put")) {
		method = METHOD_PUT;

	    /* OPTIONS Method */
	    } else if (!strcasecomp(argv[arg], "-options")) {
		method = METHOD_OPTIONS;

	    /* TRACE Method */
	    } else if (!strcasecomp(argv[arg], "-trace")) {
		method = METHOD_TRACE;

	    } else {
		if (SHOW_MSG) HTPrint("Bad Argument (%s)\n", argv[arg]);
	    }
	} else {	 /* If no leading `-' then check for URL or keywords */
    	    if (!tokencount) {
		char * ref = HTParse(argv[arg], cl->cwd, PARSE_ALL);
		cl->anchor = (HTParentAnchor *) HTAnchor_findAddress(ref);
		tokencount = 1;
		HT_FREE(ref);
	    } else if (formdata) {		   /* Keywords are form data */
		char * string = argv[arg];
		if (tokencount++ <= 1) formfields = HTAssocList_new();
		HTParseFormInput(formfields, string);
	    } else {		   	       /* keywords are search tokens */
		char * escaped = HTEscape(argv[arg], URL_XALPHAS);
		if (tokencount++ <= 1)
		    keywords = HTChunk_new(128);
		else
		    HTChunk_putc(keywords, ' ');
		HTChunk_puts(keywords, HTStrip(escaped));
		HT_FREE(escaped);
	    }
	}
    }

    if (!tokencount && !cl->flags & CL_FILTER) {
	VersionInfo(argv[0]);
	Cleanup(cl, 0);
    }

    /* Should we use persistent cache? */
    if (cache) {
	HTCacheInit(cache_root, 20);

	/* Should we start by flushing? */
	if (flush) HTCache_flushAll();
    }

    /*
    ** Check whether we should do some kind of cache validation on
    ** the load
    */
    if (cl->flags & CL_VALIDATE)
	HTRequest_setReloadMode(cl->request, HT_CACHE_VALIDATE);
    else if (cl->flags & CL_END_VALIDATE)
	HTRequest_setReloadMode(cl->request, HT_CACHE_END_VALIDATE);
    else if (cl->flags & CL_CACHE_FLUSH)
	HTRequest_setReloadMode(cl->request, HT_CACHE_FLUSH);

    /* Add progress notification */
    if (cl->flags & CL_QUIET) HTAlert_deleteOpcode(HT_A_PROGRESS);

    /* Output file specified? */
    if (cl->outputfile) {
	if ((cl->output = fopen(cl->outputfile, "wb")) == NULL) {
	    if (SHOW_MSG) HTPrint("Can't open `%s'\\n",cl->outputfile);
	    cl->output = OUTPUT;
	}
    }

    /*
    ** Set up the output. Even though we don't use this explicit, it is
    ** required in order to show the stream stack that we know that we are
    ** getting raw data output on the output stream of the request object.
    */
    HTRequest_setOutputStream(cl->request,
			      HTFWriter_new(cl->request, cl->output, YES));

    /* Setting event timeout */
    HTHost_setEventTimeout(cl->timer);

    /*
    ** Make sure that the first request is flushed immediately and not
    ** buffered in the output buffer
    */
    HTRequest_setFlush(cl->request, YES);

    /* Log file specifed? */
    if (cl->logfile) {
	cl->log = HTLog_open(cl->logfile, YES, YES);
        if (cl->log) HTNet_addAfter(HTLogFilter, NULL, cl->log, HT_ALL, HT_FILTER_LATE);
    }

    /* Just convert formats */
    if (cl->flags & CL_FILTER) {
#ifdef STDIN_FILENO
	HTRequest_setAnchor(cl->request, (HTAnchor *) cl->anchor);
	HTRequest_setPreemptive(cl->request, YES);
	HTLoadSocket(STDIN_FILENO, cl->request);
#endif
	Cleanup(cl, 0);
    }
    
    /* Content Length Counter */
    if (cl->flags & CL_COUNT) {
	HTRequest_setOutputStream(cl->request,
				  HTContentCounter(HTBlackHole(),
						   cl->request, 0x2000));
    }

    /* Rule file specified? */
    if (cl->rules) {
	char * rules = HTParse(cl->rules, cl->cwd, PARSE_ALL);
	if (!HTLoadRulesAutomatically(rules))
	    if (SHOW_MSG) HTPrint("Can't access rules\n");
	HT_FREE(rules);
    }

    /* Add our own filter to update the history list */
    HTNet_addAfter(terminate_handler, NULL, NULL, HT_ALL, HT_FILTER_LAST);

    /* Start the request */
    switch (method) {
    case METHOD_GET:

	if (formdata)
	    status = HTGetFormAnchor(formfields, (HTAnchor *) cl->anchor,
				     cl->request);
	else if (keywords)
	    status = HTSearchAnchor(keywords, (HTAnchor *) cl->anchor,
				    cl->request);
	else
	    status = HTLoadAnchor((HTAnchor *) cl->anchor, cl->request);
	break;

    case METHOD_HEAD:
	if (formdata) {
	    HTRequest_setMethod(cl->request, METHOD_HEAD);
	    status = HTGetFormAnchor(formfields, (HTAnchor *) cl->anchor,
				     cl->request);
	} else if (keywords) {
	    HTRequest_setMethod(cl->request, METHOD_HEAD);
	    status = HTSearchAnchor(keywords, (HTAnchor *) cl->anchor,
				    cl->request);
	} else
	    status = HTHeadAnchor((HTAnchor *) cl->anchor, cl->request);
	break;

    case METHOD_DELETE:
	status = HTDeleteAnchor((HTAnchor *) cl->anchor, cl->request);
	break;

    case METHOD_POST:
	if (formdata) {
	    HTParentAnchor * posted = NULL;
#if 1
	    posted = HTPostFormAnchor(formfields, (HTAnchor *) cl->anchor,
				      cl->request);
	    status = posted ? YES : NO;
#else
	    /* If we want output to a chunk instead */
	    post_result = HTPostFormAnchorToChunk(formfields, (HTAnchor *) cl->anchor,
						  cl->request);
	    status = post_result ? YES : NO;
#endif
	} else {
	    if (SHOW_MSG) HTPrint("Nothing to post to this address\n");
	    status = NO;	    
	}
	break;

    case METHOD_PUT:
	status = HTPutDocumentAnchor(cl->anchor, (HTAnchor *) cl->dest,
				     cl->request);
	break;

    case METHOD_OPTIONS:
	status = HTOptionsAnchor((HTAnchor *) cl->anchor, cl->request);
	break;	

    case METHOD_TRACE:
	status = HTTraceAnchor((HTAnchor *) cl->anchor, cl->request);
	break;	

    default:
	if (SHOW_MSG) HTPrint("Don't know this method\n");
	break;
    }

    if (keywords) HTChunk_delete(keywords);
    if (formfields) HTAssocList_delete(formfields);
    if (status != YES) {
	if (SHOW_MSG) HTPrint("Sorry, can't access resource\n");
	Cleanup(cl, -1);
    }

    /* Go into the event loop... */
    HTEventList_loop(cl->request);

    /* Only gets here if event loop fails */
    Cleanup(cl, 0);
    return 0;
}
コード例 #27
0
ファイル: mac.c プロジェクト: pombredanne/Frontier
boolean initmacintosh (void) {
	
	/*
	the magic stuff that every Macintosh application needs to do 
	before doing anything else.
	
	4/24/91 dmb: added memory config resource stuff
	
	3.0.4 dmb: use LMGetCurStackBase, not CurStackBase global
	
	3.0.4 dmb: pass 0L to InitDialogs
	*/
	
	register short i;
	register hdlmemoryconfig h;
	register long ctbytes;
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:45:13 PM
	//
	#if TARGET_API_MAC_CARBON == 0
	long ctstack;
	#endif
	long ctheap, ctcode;
	short ctmasters;
	
	h = (hdlmemoryconfig) Get1Resource ('MCFG', 1);
	
	if (h == nil)
		clearbytes (&macmemoryconfig, sizeof (macmemoryconfig));
	else
		macmemoryconfig = **h;
	
	//Code change by Timothy Paustian Saturday, June 3, 2000 10:13:20 PM
	//Changed to Opaque call for Carbon
	//we don't need this in carbon.
	#if TARGET_API_MAC_CARBON == 0
	if (h != nil) { /*first check stack size*/
		
		ctbytes = (**h).minstacksize;
		
		ctstack = LMGetCurStackBase () - GetApplLimit (); /*current stack size*/
		
		if (ctbytes > ctstack)
			SetApplLimit (LMGetCurStackBase () - ctbytes);
		}
	MaxApplZone ();
	
	#endif

	
	
	if (h != nil) { /*check heap size and master pointers*/
		
		ctbytes = (**h).minheapsize;
		
		//Code change by Timothy Paustian Thursday, June 8, 2000 3:04:31 PM
		//Changed to Opaque call for Carbon
		//This is meaningless for OS X since it has unlimited memory.
		
		#if TARGET_API_MAC_CARBON == 1
		//we need to do somethings else. FreeMem is going to return some large value
		//of all the available system memory
		//This whole thing is pointless. We can get as much memory as we need.

			#pragma unused (ctmasters)
			#pragma unused (ctcode)
			#pragma unused (ctheap)
		
		#else

		ctheap = FreeMem ();
		
		if (ctbytes > ctheap) {
			
			return (false);
			}
		
		ctbytes = (**h).avghandlesize;
		
		ctcode = (**h).reserveforcode;
		
		if ((ctbytes > 0) && (ctheap > ctcode)) {
			
			ctmasters = ((ctheap - ctcode) / ctbytes) / kNumberOfMasters;
			
			ctmasters = min (ctmasters, 1024);  /*7.1b37 PBS: You'd think 1024 calls would be enough. With large memory alottments on Mac
			  						  			Classic, we're calling MoreMasters in excess of 20,000 times. That makes the app take
			  						  			a minute or so to start up! So instead I've chosen an arbitrary limit.*/
			  						  
			for (i = 1; i < ctmasters; i++) 
				MoreMasters ();
			}
		#endif

		ReleaseResource ((Handle) h); /*we're done with it*/
		}
	
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:21:06 PM
	//Changed to Opaque call for Carbon
	//we don't need this initialization in carbon
	#if TARGET_API_MAC_CARBON == 0
	InitGraf (&qd.thePort);
	
	InitFonts ();
	
	FlushEvents (everyEvent, 0);
	
	InitWindows ();
	
	InitMenus ();
	
	TEInit ();
	
	InitDialogs (0L);
	#endif

	
	InitCursor ();
	//Code change by Timothy Paustian Thursday, June 8, 2000 3:22:57 PM
	//Changed to Opaque call for Carbon
	//this is obsolete, we should be using gestalt for this.
	
	{	
		long quickDrawFeatures;
		OSErr theErr = Gestalt(gestaltSystemVersion, &gSystemVersion);
		if(oserror(theErr))
			ExitToShell();

		theErr = Gestalt(gestaltQuickdrawFeatures, &quickDrawFeatures);
		
		if(oserror(theErr))
			ExitToShell();
		gHasColorQD = (quickDrawFeatures & (1 << gestaltHasColor));
		//Nav services has to be present and we want the 1.1 or greater version.
		gCanUseNavServ = (NavServicesAvailable() && (NavLibraryVersion() >= 0x01108000));
	}
	
	
	//SysEnvirons (1, &macworld);
	
	//gee I bet this isn't required anymore either.
	for (i = 1; i <= 5; i++) { /*register with Multifinder*/
		
		EventRecord ev;
		
		EventAvail (everyEvent, &ev); /*see TN180 -- splash screen*/
		} /*for*/
	
	#if TARGET_API_MAC_CARBON == 1
	
		RegisterAppearanceClient ();
		
	#endif
	
	return (true);
	} /*initmacintosh*/
コード例 #28
0
static int
MacintoshInit()
{
    int i;
    long result, mask = 0x0700; 		/* mask = system 7.x */

#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TK_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();
    for (i = 0; i < 4; i++) {
	(void) MoreMasters();
    }

    /*
     * Tk needs us to set the qd pointer it uses.  This is needed
     * so Tk doesn't have to assume the availablity of the qd global
     * variable.  Which in turn allows Tk to be used in code resources.
     */
    tcl_macQdPtr = &qd;

    /*
     * If appearance is present, then register Tk as an Appearance client
     * This means that the mapping from non-Appearance to Appearance cdefs
     * will be done for Tk regardless of the setting in the Appearance
     * control panel.  
     */
     
     if (TkMacHaveAppearance()) {
         RegisterAppearanceClient();
     }

    InitGraf(&tcl_macQdPtr->thePort);
    InitFonts();
    if (TkMacHaveAppearance() >= 0x110) {
        InitFloatingWindows();
    } else {
    InitWindows();
    }
    InitMenus();
    InitDialogs((long) NULL);		
    InitCursor();

    /*
     * Make sure we are running on system 7 or higher
     */
     
    if ((NGetTrapAddress(_Gestalt, ToolTrap) == 
    	    NGetTrapAddress(_Unimplemented, ToolTrap))
    	    || (((Gestalt(gestaltSystemVersion, &result) != noErr)
	    || (result < mask)))) {
	panic("Tcl/Tk requires System 7 or higher.");
    }

    /*
     * Make sure we have color quick draw 
     * (this means we can't run on 68000 macs)
     */
     
    if (((Gestalt(gestaltQuickdrawVersion, &result) != noErr)
	    || (result < gestalt32BitQD13))) {
	panic("Tk requires Color QuickDraw.");
    }

    
    FlushEvents(everyEvent, 0);
    SetEventMask(everyEvent);


    Tcl_MacSetEventProc(TkMacConvertEvent);
    return TCL_OK;
}
コード例 #29
0
ファイル: MACINIT.C プロジェクト: marcinch18/nasa-cosmic
init_mac_interface() 
  {
   int myRsrc, i;
   int MainEvent();
    
   /*=====================================================*/
   /* Macintosh Incantation for initializing application. */
   /*=====================================================*/
	
   InitGraf(&thePort);
   InitFonts();
   InitWindows();
   InitMenus();
   TEInit();
   InitDialogs(0L);
	
   MaxApplZone();
   FlushEvents(everyEvent,0);
	  
   /*==================================*/
   /* Get the screen width and height. */
   /*==================================*/
   
   ScreenHeight = screenBits.bounds.bottom - screenBits.bounds.top;
   ScreenWidth = screenBits.bounds.right - screenBits.bounds.left;
   
   /*===============================*/
   /* Set up the menus and cursors. */
   /*===============================*/
   
   SetUpMenus();
   SetUpCursors();
   
   /*=====================================*/
   /* Initialize global window variables. */
   /*=====================================*/
   
   TheText = NULL;
   TheWindow = NULL;
   TheVScrollBar = NULL;
   TheHScrollBar = NULL;
   
   /*======================================*/
   /* Place any selected files in buffers. */
   /*======================================*/
   
   DoStartup();
   
   /*=======================*/
   /* Initialize the Scrap. */
   /*=======================*/
   
   InitializeScrap();
   
   /*=========================*/
   /* Set up for MultiFinder. */
   /*=========================*/
   
   MultiFinderSetup();
   
   /*===================================*/
   /* Set up routers for the interface. */
   /*===================================*/
   
   SetUpRouters();
   
   /*==================================================================*/
   /* Set up hook between CLIPS command loop and interface event loop. */
   /*==================================================================*/
   
   set_event_function(MainEvent);
   
   /*==================================================================*/
   /* Add execution function to update interface between rule firings. */
   /*==================================================================*/
   
   add_exec_function("macint",mac_exec_function);
  }
コード例 #30
0
ファイル: mktyplib.c プロジェクト: mingpen/OpenNT
// MkTypLib entry point
VOID main
(
#ifndef NO_MPW
    int argc,        /* Number of strings in array argv          */
    CHAR *argv[]     /* Array of command-line argument strings   */
#endif	// NO_MPW
)
{

#ifdef USE_DIMALLOC
    IMalloc FAR *pmalloc;
#endif //USE_DIMALLOC
#ifdef NO_MPW
#define MAX_ARGS 21
    int argc;        /* Number of strings in array argv          */
    CHAR *argv[MAX_ARGS];  /* Array of command-line argument strings   */
    FILE * hFileArgs;
#endif	// NO_MPW

    int fArgErr;
    HRESULT res;
#ifndef MAC
    OPENFILENAME ofn;
#endif

#ifdef NODEBUGALERTS
    WINDEBUGINFO debuginfo;

    GetWinDebugInfo(&debuginfo, WDI_OPTIONS);
    Olddebuginfo = debuginfo;		// save for restoration
    debuginfo.dwOptions |= DBO_SILENT;
    SetWinDebugInfo(&debuginfo);
#endif	//NODEBUGALERTS

    // init key fields in the main 'typlib' structure before we use them
    typlib.pEntry = NULL;	// no entries seen so far
    typlib.pImpLib = NULL;	// no imported libraries initially

#ifdef MAC
#ifdef NO_MPW
    // Do mysterious MAC init stuff
    MaxApplZone();
#endif //NO_MPW

    InitGraf((Ptr) &qd.thePort);
#ifdef NO_MPW
    InitFonts();
    InitWindows();
    InitMenus();
    InitDialogs(nil);
    InitCursor();
#endif //NO_MPW

    PPCInit();		// required by OleInitialize

    // init the OLE Applet
    if ((res = InitOleManager(0)) != NOERROR)
	ParseError(ERR_OM);		// UNDONE: correct error?
    fAppletInitialized = TRUE;

#ifdef NO_MPW
    // If a file exists called "MKTYPLIB.ARG", load up argc, argv[] to satisfy
    // our command line parser.
    if (hFileArgs = fopen("mktyplib.arg", "r"))
	{
	    argc = 1;
	    while (argc < MAX_ARGS)
		{
		argv[argc] = malloc(50);
		if (fscanf(hFileArgs, " %s ", argv[argc]) == EOF)
		    break;
		argc++;
		}
	    fclose(hFileArgs);

	}
   else
	{
	    // activate to output to file instead of using lame MAC MessageBox's
	    // szOutputFile  = "m.log";		// redirected output
	    szInputFile   = "m.odl";		// input file
	    fHFile = TRUE;			// want a .H file

	    fArgErr = FALSE;			// no arg error
	    goto ArgsParsed;
	}
#endif //NO_MPW
#endif //MAC

    InitLeadByteTable();

    fArgErr = FParseCl(argc, argv);	// parse the command line

#ifdef MAC
#ifdef NO_MPW
ArgsParsed:
#endif //NO_MPW
#endif //MAC

    if (szOutputFile)
	{
#ifdef WIN16
            // perform in-place conversion to OEM char set
            AnsiToOem(szOutputFile, szOutputFile);

            // (don't bother converting back - this string is not used again)
#endif // WIN16

	    hFileOutput = fopen(szOutputFile, "w");
	    // if problem opening output file, then just revert to normal
	    // MessageBox output.
	    // CONSIDER: give an error, too?
	}

    if (!fNologo)
	{
	    DisplayLine(szBanner);		// display the copyright banner
	    // add a blank line in some cases to make it look better
	    if (hFileOutput)
		fputs("\n", hFileOutput);
#ifndef WIN16
#ifndef NO_MPW
	    else
		printf("\n");
#endif	//NO_MPW
#endif //!WIN16
	}

    if (fArgErr || fGiveUsage)
	{
GiveUsage:
	    DisplayLine(szUsage);
	    ErrorExit();	// clean up and exit(1)
	}

#ifndef	MAC
    // use common dialog to get input filename if user didn't specify one
    if (szInputFile == NULL)
	{
	    szInputFile = malloc(CB_MAX_PATHNAME+1);
            
	    memset(&ofn, 0, sizeof(OPENFILENAME));
	    ofn.lStructSize = sizeof(OPENFILENAME);
//	    ofn.hwndOwner = g_hwndMain;
	    ofn.hwndOwner = NULL;
	    ofn.lpstrFile = szInputFile;
	    ofn.nMaxFile = CB_MAX_PATHNAME+1;
	    *szInputFile = '\0';
	    ofn.lpstrFilter = "Object Description Lang.\0*.odl\0\0";
	    ofn.nFilterIndex = 1; 
	    ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;

	    // if anything went wrong -- just give the usage message
	    if (GetOpenFileName(&ofn) == 0)
		goto GiveUsage;
	}
#endif	//!MAC

    Assert(szInputFile);

// now compute filenames based off the input filename

    if (szTypeLibFile == NULL)	// if output file not specified
    	{   // use input filename with ".tlb" extension
	    szTypeLibFile = CloneNameAddExt(szInputFile, ".tlb");
    	}

    if (fHFile && szHFile == NULL)	// if header filename not specified
    	{   // use input filename with ".h" extension
	    szHFile = CloneNameAddExt(szInputFile, ".h");
    	}


    // If output file ends up with the same name as the input file, then
    // the user is screwed. Just give the usage message.
    if (!strcmp(szInputFile, szTypeLibFile))
	goto GiveUsage;

    // If .h file ends up with the same name as either the input file or output
    // file, then the user is screwed. Just give the usage message.
    if (szHFile && (!strcmp(szInputFile, szHFile) || !strcmp(szTypeLibFile, szHFile)))
	goto GiveUsage;

#ifdef USE_DIMALLOC

    // Use the dimalloc implementation, since the default implementation
    // doesn't work yet in mac ole.
    if (!GetDebIMalloc(&pmalloc))
      ParseError(ERR_OM);		// UNDONE: correct error?

    res = OLEINITIALIZE(pmalloc);
    pmalloc->lpVtbl->Release(pmalloc);
#else
    // must init OLE
    res = OLEINITIALIZE(NULL);
#endif

    if (FAILED(res))
	ParseError(ERR_OM);		// UNDONE: correct error?
    fOLEInitialized = TRUE;

#ifndef MAC
     hcrsWait = LoadCursor(NULL, (LPSTR)IDC_WAIT);
     SetCursor(hcrsWait);		// turn on the hourglass cursor
     // UNDONE: this doesn't always stay on in WIN16, nor does it seem to
     // UNDONE: have any affect in WIN32.
#endif //!MAC

#if FV_CPP
    if (fCPP)			// if we're to pre-process input file
	DoPreProcess();
#endif	//FV_CPP

    strcpy(szFileCur, szInputFile);	// init current file name (for
					// error reporting)

#if FV_CPP
    ParseOdlFile(fCPP ? szTempFile : szInputFile);	// parse the input file
#else
    ParseOdlFile(szInputFile);		// parse the input file
#endif

#if FV_CPP
    if (szTempFile)
	{
	    SideAssert(MyRemove(szTempFile) == 0);	// delete tmp file created above
	    szTempFile = NULL;
	}
#endif	//FV_CPP

    if (fHFile)				// output .H file if desired
	OutputHFile(szHFile);

    // Now emit the type library
    OutputTyplib(szTypeLibFile);

#ifdef NO_MPW
    // Now dump the type library
    DumpTypeLib(szTypeLibFile);
#endif

    CleanupImportedTypeLibs();		// release any imported typelibs

    OLEUNINITIALIZE();			// terminate OLE

#ifdef MAC
    UninitOleManager();			// clean up applet
#endif //MAC

    DisplaySuccess(szTypeLibFile);	// holy *&*%&^%, it worked!!!

    if (hFileOutput)			// close redirected output file
	fclose(hFileOutput);

#ifdef NODEBUGALERTS
    SetWinDebugInfo(&Olddebuginfo);
#endif	//NODEBUGALERTS
    exit(0);

}