Example #1
0
static int
MacintoshInit()
{
    THz theZone = GetZone();
    SysEnvRec   sys;

    
    /*
     * There is a bug in systems earlier that 7.5.5, where a second BOA will
     * get a corrupted heap.  This is the fix from TechNote 1070
     */
     
    SysEnvirons(1, &sys);

    if (sys.systemVersion < 0x0755)
    {
        if ( LMGetHeapEnd() != theZone->bkLim) {
            LMSetHeapEnd(theZone->bkLim);
        }
    }
    
#if GENERATING68K && !GENERATINGCFM
    SetApplLimit(GetApplLimit() - (TCL_MAC_68K_STACK_GROWTH));
#endif
    MaxApplZone();

    InitGraf((Ptr)&qd.thePort);
    		    
    /* No problems with initialization */
    Tcl_MacSetEventProc(HandleHighLevelEvents);

    return TCL_OK;
}
Example #2
0
int inithtk(int argc, char *argv[],const char * app_version, bool noGraphics)
{
	InitThreads(HT_MSGMON);   // enable msg driven monitoring
	if(InitShell(argc,argv,app_version)<SUCCESS) return FAIL;
	// CommonInit() expanded with incompatible things commented out: 
		InitMem();   InitLabel();
		InitMath();  InitSigP(); InitUtil();
		InitWave();  /*InitAudio();*/ InitModel();
		if(InitParm()<SUCCESS) return FAIL;
		InitGraf((Boolean)noGraphics);
		InitDict();  InitNet();   InitLM();
		InitRec();  InitLat();  /*InitAdapt();*/
		
		EnableBTrees();   /* allows unseen triphones to be synthesised */
		/*
		Register(abuffer_version);
		Register(acode_version);
		Register(acomponent_version);
		Register(adict_version);
		Register(agram_version);
		Register(angram_version);
		Register(ahmms_version);
		Register(ahtk_version);
		Register(amonitor_version);
		Register(apacket_version);
		Register(arec_version);
		Register(aresource_version);
		Register(arman_version);
		Register(asource_version);
		*/
		InfoPrinted();
		return SUCCESS;
}
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());


}
Example #4
0
File: ugView.c Project: 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);
}
Example #5
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 );
}
// --------------------------------------------------------------------------------------
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);
}
Example #7
0
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;
}
Example #8
0
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();
}
static void InitMacToolbox (void)
{
	InitGraf (&qd.thePort);
	InitFonts ();
	InitWindows ();
	InitMenus ();
	TEInit ();
	InitDialogs (nil);
}
Example #10
0
/* ----------- 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;
}
Example #11
0
static void
init_toolbox()
{
    InitGraf(&qd.thePort);
    InitFonts();
    InitWindows();
    TEInit();
    InitDialogs((long)0);
    InitMenus();
    InitCursor();
    SIOUXSettings.asktosaveonclose = 0;
}
Example #12
0
void InitManagers(void)
{
	MaxApplZone();	
	MoreMasters(); MoreMasters(); MoreMasters();
	
	InitGraf(&qd.thePort);  
	InitFonts();			
	InitWindows();
	InitMenus();
	TEInit();				
	InitDialogs(NULL);
	
	InitCursor();		
	FlushEvents(everyEvent, 0);	
}
static void
init_toolbox()
{
#ifndef USING_CARBON
	InitGraf(&qd.thePort);
	InitFonts();
	InitWindows();
	TEInit();
	InitDialogs((long)0);
	InitMenus();
	InitCursor();
#endif

	SIOUXSettings.asktosaveonclose = 0;
}
Example #14
0
void Initialize(void)
{
	InitGraf((Ptr) &qd.thePort);
	InitFonts();
	FlushEvents(everyEvent, 0);

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

}
Example #15
0
void Initialise(int argc, char *argv[])
{
   InitThreads(HT_MSGMON);
	if(InitShell(argc,argv,hnettest_version)<SUCCESS)
		HError(999,"Initialise: couldnt init HShell");
	InitMem();   InitLabel();
	InitMath();  InitSigP();
	InitWave();  InitAudio();
	if(InitParm()<SUCCESS)
		HError(999,"Initialise: couldnt init HParm");
	InitGraf(FALSE);  InitModel();
	InitDict();  InitNet();
	EnableBTrees();   /* allows unseen triphones to be synthesised */
	if (!InfoPrinted() && NumArgs() == 0)
		ReportUsage();
}
Example #16
0
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();
  }
Example #17
0
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;
}
Example #18
0
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
}
Example #19
0
int main(int argc, char *argv[])
{
	int n,a1,a2,a3,a4;

	InitThreads(sMon);
	if(InitShell(argc,argv,hthreadtest_version)<SUCCESS)
		HError(1100,"HThreadTest: InitShell failed");
	if (NumArgs() < 1) ReportUsage();
	InitMem();   InitLabel();
	InitMath();  InitSigP();
	InitWave();  InitAudio();
	InitVQ();
	if(InitParm()<SUCCESS)
		HError(3200,"HThreadTest: InitParm failed");
	InitGraf(FALSE);
   if (sMon==HT_MSGMON) HCreateMonitor(tmon4,(void *)0);
	if (NextArg() == INTARG){
		n = GetIntArg();
		switch(n){
		case 1:
			a1 = GetIntArg(); a2 = GetIntArg();
			ParallelForkAndJoin(a1,a2); break;
		case 2:
			a1 = GetIntArg(); a2 = GetIntArg();
			SimpleMutex(a1,a2); break;
		case 3:
			SimpleSignal(); break;
		case 4:
			a1 = GetIntArg(); a2 = GetIntArg();
			a3 = GetIntArg(); a4 = GetIntArg();
			BufferTest(a1,a2,a3,a4,GetStrArg()); break;
		default:
			printf("Bad test number %d\n",n); ReportUsage();
		}
	}
	if (sMon>0){
		AccessStatus();
		PrintThreadStatus("Final");
		ReleaseStatusAccess();
		if (sMon==HT_MSGMON)HJoinMonitor();
	}
}
Example #20
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);
}
Example #21
0
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*/
Example #22
0
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);
}
Example #23
0
File: jam.c Project: PPNav/GPSTk
int
main( int argc, char **argv, char **arg_environ )
{
	int		n, num_targets;
	const char	*s;
	struct option	optv[N_OPTS];
	char*       targets[N_TARGETS];
	const char	*all = "all";
	int		anyhow = 0;
	int		status;

# ifdef OS_MAC
	InitGraf(&qd.thePort);
# endif

	argc--, argv++;

	if( ( num_targets = getoptions( argc, argv, "d:j:f:gs:t:ano:qv", optv, targets ) ) < 0 )
	{
	    printf( "\nusage: jam [ options ] targets...\n\n" );

            printf( "-a      Build all targets, even if they are current.\n" );
            printf( "-dx     Display (a)actions (c)causes (d)dependencies\n" );
	    printf( "        (m)make tree (x)commands (0-9) debug levels.\n" );
            printf( "-fx     Read x instead of Jambase.\n" );
	    printf( "-g      Build from newest sources first.\n" );
            printf( "-jx     Run up to x shell commands concurrently.\n" );
            printf( "-n      Don't actually execute the updating actions.\n" );
            printf( "-ox     Write the updating actions to file x.\n" );
            printf( "-q      Quit quickly as soon as a target fails.\n" );
	    printf( "-sx=y   Set variable x=y, overriding environment.\n" );
            printf( "-tx     Rebuild x, even if it is up-to-date.\n" );
            printf( "-v      Print the version of jam and exit.\n\n" );

	    exit( EXITBAD );
	}

	/* Version info. */

	if( ( s = getoptval( optv, 'v', 0 ) ) )
	{
	    printf( "FT-Jam %s. %s. ", VERSION, OSMINOR );
	    printf( "(C) 1993-2003 Christopher Seiwald, see www.freetype.org/jam/\n" );

	    return EXITOK;
	}

	/* Pick up interesting options */

	if( ( s = getoptval( optv, 'n', 0 ) ) )
	    globs.noexec++, DEBUG_MAKE = DEBUG_MAKEQ = DEBUG_EXEC = 1; 

	if( ( s = getoptval( optv, 'q', 0 ) ) )
	    globs.quitquick = 1;

	if( ( s = getoptval( optv, 'a', 0 ) ) )
	    anyhow++;

	if( ( s = getoptval( optv, 'j', 0 ) ) )
	    globs.jobs = atoi( s );

	if( ( s = getoptval( optv, 'g', 0 ) ) )
	    globs.newestfirst = 1;

	/* Turn on/off debugging */

	for( n = 0; (s = getoptval( optv, 'd', n )) != 0; n++ )
	{
	    int i = atoi( s );

	    /* First -d, turn off defaults. */

	    if( !n )
		DEBUG_MAKE = DEBUG_MAKEQ = DEBUG_EXEC = 0;

	    /* n turns on levels 1-n */
	    /* +n turns on level n */
	    /* c turns on named display c */

	    if( i < 0 || i >= DEBUG_MAX )
	    {
		printf( "Invalid debug level '%s'.\n", s );
	    }
	    else if( *s == '+' )
	    {
		globs.debug[i] = 1;
	    }
	    else if( i ) while( i )
	    {
		globs.debug[i--] = 1;
	}
	    else while( *s ) switch( *s++ )
	    {
	    case 'a': DEBUG_MAKE = DEBUG_MAKEQ = 1; break;
	    case 'c': DEBUG_CAUSES = 1; break;
	    case 'd': DEBUG_DEPENDS = 1; break;
	    case 'm': DEBUG_MAKEPROG = 1; break;
	    case 'x': DEBUG_EXEC = 1; break;
	    case '0': break;
	    default: printf( "Invalid debug flag '%c'.\n", s[-1] );
	    }
	}

	/* Set JAMDATE first */

	{
	    char buf[ 128 ];
	    time_t clock;
	    time( &clock );
	    strcpy( buf, ctime( &clock ) );

	    /* Trim newline from date */

	    if( strlen( buf ) == 25 )
		buf[ 24 ] = 0;

	    var_set( "JAMDATE", list_new( L0, buf, 0 ), VAR_SET );
	}

	/* And JAMUNAME */
# ifdef unix
	{
	    struct utsname u;

	    if( uname( &u ) >= 0 )
	    {
		LIST *l = L0;
		l = list_new( l, u.machine, 0 );
		l = list_new( l, u.version, 0 );
		l = list_new( l, u.release, 0 );
		l = list_new( l, u.nodename, 0 );
		l = list_new( l, u.sysname, 0 );
		var_set( "JAMUNAME", l, VAR_SET );
	    }
	}
# endif /* unix */

	/*
	 * Jam defined variables OS, OSPLAT
	 */

	var_defines( othersyms );

	/* load up environment variables */

	var_defines( (const char **)use_environ );

	/* Load up variables set on command line. */

	for( n = 0; (s = getoptval( optv, 's', n )) != 0; n++ )
	{
	    const char *symv[2];
	    symv[0] = s;
	    symv[1] = 0;
	    var_defines( symv );
	}

	/* Initialize built-in rules */

	load_builtins();

	/* Parse ruleset */

	for( n = 0; (s = getoptval( optv, 'f', n )) != 0; n++ )
	    parse_file( s );

	if( !n )
	    parse_file( "+" );

	status = yyanyerrors();

	/* Manually touch -t targets */

	for( n = 0; (s = getoptval( optv, 't', n )) != 0; n++ )
	    touchtarget( s );

	/* If an output file is specified, set globs.cmdout to that */

	if( (s = getoptval( optv, 'o', 0 )) != 0 )
	{
	    if( !( globs.cmdout = fopen( s, "w" ) ) )
	    {
		printf( "Failed to write to '%s'\n", s );
		exit( EXITBAD );
	    }
	    globs.noexec++;
	}

    /* Add JAMCMDARGS
     */
     {
        LIST*  l = L0;

        for ( n = 0; n < num_targets; n++ )
          l = list_new( l, targets[n], 0 );

        var_set( "JAMCMDARGS", l, VAR_SET );
     }

	/* Now make target */

	if( !num_targets )
	    status |= make( 1, &all, anyhow );
	else
	    status |= make( num_targets, (const char**)targets, anyhow );

	/* Widely scattered cleanup */

	var_done();
	donerules();
	donestamps();
	donestr();

	/* close cmdout */

	if( globs.cmdout )
	    fclose( globs.cmdout );

	return status ? EXITBAD : EXITOK;
}
Example #24
0
int main( int argc, char * * argv, char * * arg_environ )
{
    int                     n;
    char                  * s;
    struct bjam_option      optv[N_OPTS];
    char            const * all = "all";
    int                     status;
    int                     arg_c = argc;
    char          *       * arg_v = argv;
    char            const * progname = argv[0];
    module_t              * environ_module;

#if defined(unix) || defined(__unix)
    sigset_t sigmask;
    struct sigaction sa;

    sigemptyset(&sigmask);
    sigaddset(&sigmask, SIGCHLD);
    sigprocmask(SIG_BLOCK, &sigmask, NULL);
    sa.sa_flags = 0;
    sa.sa_handler = child_sig_handler;
    sigemptyset(&sa.sa_mask);
    sigaction(SIGCHLD, &sa, NULL);
    sigemptyset(&empty_sigmask);
#endif

    saved_argv0 = argv[0];

    BJAM_MEM_INIT();

# ifdef OS_MAC
    InitGraf(&qd.thePort);
# endif

    --argc;
    ++argv;

    if ( getoptions( argc, argv, "-:l:m:d:j:p:f:gs:t:ano:qv", optv ) < 0 )
    {
        printf( "\nusage: %s [ options ] targets...\n\n", progname );

        printf( "-a      Build all targets, even if they are current.\n" );
        printf( "-dx     Set the debug level to x (0-9).\n" );
        printf( "-fx     Read x instead of Jambase.\n" );
        /* printf( "-g      Build from newest sources first.\n" ); */
        printf( "-jx     Run up to x shell commands concurrently.\n" );
        printf( "-lx     Limit actions to x number of seconds after which they are stopped.\n" );
        printf( "-mx     Limit action output buffer to x kb's of data, after which action output is read and ignored.\n" );
        printf( "-n      Don't actually execute the updating actions.\n" );
        printf( "-ox     Write the updating actions to file x.\n" );
        printf( "-px     x=0, pipes action stdout and stderr merged into action output.\n" );
        printf( "-q      Quit quickly as soon as a target fails.\n" );
        printf( "-sx=y   Set variable x=y, overriding environment.\n" );
        printf( "-tx     Rebuild x, even if it is up-to-date.\n" );
        printf( "-v      Print the version of jam and exit.\n" );
        printf( "--x     Option is ignored.\n\n" );

        exit( EXITBAD );
    }

    /* Version info. */
    if ( ( s = getoptval( optv, 'v', 0 ) ) )
    {
        printf( "Boost.Jam  " );
        printf( "Version %s. %s.\n", VERSION, OSMINOR );
        printf( "   Copyright 1993-2002 Christopher Seiwald and Perforce Software, Inc.  \n" );
        printf( "   Copyright 2001 David Turner.\n" );
        printf( "   Copyright 2001-2004 David Abrahams.\n" );
        printf( "   Copyright 2002-2008 Rene Rivera.\n" );
        printf( "   Copyright 2003-2008 Vladimir Prus.\n" );

        return EXITOK;
    }

    /* Pick up interesting options. */
    if ( ( s = getoptval( optv, 'n', 0 ) ) )
        globs.noexec++, globs.debug[2] = 1;

    if ( ( s = getoptval( optv, 'p', 0 ) ) )
    {
        /* Undocumented -p3 (acts like both -p1 -p2) means separate pipe action
         * stdout and stderr.
         */
        globs.pipe_action = atoi( s );
        if ( ( 3 < globs.pipe_action ) || ( globs.pipe_action < 0 ) )
        {
            printf(
                "Invalid pipe descriptor '%d', valid values are -p[0..3].\n",
                globs.pipe_action );
            exit( EXITBAD );
        }
    }

    if ( ( s = getoptval( optv, 'q', 0 ) ) )
        globs.quitquick = 1;

    if ( ( s = getoptval( optv, 'a', 0 ) ) )
        anyhow++;

    if ( ( s = getoptval( optv, 'j', 0 ) ) )
    {
        globs.jobs = atoi( s );
        if (globs.jobs == 0)
        {
            printf("Invalid value for the '-j' option.\n");
            exit(EXITBAD);
        }
    }

    if ( ( s = getoptval( optv, 'g', 0 ) ) )
        globs.newestfirst = 1;

    if ( ( s = getoptval( optv, 'l', 0 ) ) )
        globs.timeout = atoi( s );

    if ( ( s = getoptval( optv, 'm', 0 ) ) )
        globs.maxbuf = atoi( s ) * 1024;

    /* Turn on/off debugging */
    for ( n = 0; ( s = getoptval( optv, 'd', n ) ); ++n )
    {
        int i;

        /* First -d, turn off defaults. */
        if ( !n )
            for ( i = 0; i < DEBUG_MAX; ++i )
                globs.debug[i] = 0;

        i = atoi( s );

        if ( ( i < 0 ) || ( i >= DEBUG_MAX ) )
        {
            printf( "Invalid debug level '%s'.\n", s );
            continue;
        }

        /* n turns on levels 1-n. */
        /* +n turns on level n. */
        if ( *s == '+' )
            globs.debug[i] = 1;
        else while ( i )
            globs.debug[i--] = 1;
    }

    constants_init();

    {
        PROFILE_ENTER( MAIN );

#ifdef HAVE_PYTHON
        {
            PROFILE_ENTER( MAIN_PYTHON );
            Py_Initialize();
            {
                static PyMethodDef BjamMethods[] = {
                    {"call", bjam_call, METH_VARARGS,
                     "Call the specified bjam rule."},
                    {"import_rule", bjam_import_rule, METH_VARARGS,
                     "Imports Python callable to bjam."},
                    {"define_action", bjam_define_action, METH_VARARGS,
                     "Defines a command line action."},
                    {"variable", bjam_variable, METH_VARARGS,
                     "Obtains a variable from bjam's global module."},
                    {"backtrace", bjam_backtrace, METH_VARARGS,
                     "Returns bjam backtrace from the last call into Python."},
                    {"caller", bjam_caller, METH_VARARGS,
                     "Returns the module from which the last call into Python is made."},
                    {NULL, NULL, 0, NULL}
                };

                Py_InitModule( "bjam", BjamMethods );
            }
            PROFILE_EXIT( MAIN_PYTHON );
        }
#endif

#ifndef NDEBUG
        run_unit_tests();
#endif
#if YYDEBUG != 0
        if ( DEBUG_PARSE )
            yydebug = 1;
#endif

        /* Set JAMDATE. */
        var_set( root_module(), constant_JAMDATE, list_new( L0, outf_time(time(0)) ), VAR_SET );

        /* Set JAM_VERSION. */
        var_set( root_module(), constant_JAM_VERSION,
                 list_new( list_new( list_new( L0,
                   object_new( VERSION_MAJOR_SYM ) ),
                   object_new( VERSION_MINOR_SYM ) ),
                   object_new( VERSION_PATCH_SYM ) ),
                   VAR_SET );

        /* Set JAMUNAME. */
#if defined(unix) || defined(__unix)
        {
            struct utsname u;

            if ( uname( &u ) >= 0 )
            {
                var_set( root_module(), constant_JAMUNAME,
                         list_new(
                             list_new(
                                 list_new(
                                     list_new(
                                         list_new( L0,
                                            object_new( u.sysname ) ),
                                         object_new( u.nodename ) ),
                                     object_new( u.release ) ),
                                 object_new( u.version ) ),
                             object_new( u.machine ) ), VAR_SET );
            }
        }
#endif /* unix */

        /* Load up environment variables. */

        /* First into the global module, with splitting, for backward
         * compatibility.
         */
        var_defines( root_module(), use_environ, 1 );

        environ_module = bindmodule( constant_ENVIRON );
        /* Then into .ENVIRON, without splitting. */
        var_defines( environ_module, use_environ, 0 );

        /*
         * Jam defined variables OS & OSPLAT. We load them after environment, so
         * that setting OS in environment does not change Jam's notion of the
         * current platform.
         */
        var_defines( root_module(), othersyms, 1 );

        /* Load up variables set on command line. */
        for ( n = 0; ( s = getoptval( optv, 's', n ) ); ++n )
        {
            char *symv[2];
            symv[ 0 ] = s;
            symv[ 1 ] = 0;
            var_defines( root_module(), symv, 1 );
            var_defines( environ_module, symv, 0 );
        }

        /* Set the ARGV to reflect the complete list of arguments of invocation.
         */
        for ( n = 0; n < arg_c; ++n )
        {
            var_set( root_module(), constant_ARGV, list_new( L0, object_new( arg_v[n] ) ), VAR_APPEND );
        }

        /* Initialize built-in rules. */
        load_builtins();

        /* Add the targets in the command line to the update list. */
        for ( n = 1; n < arg_c; ++n )
        {
            if ( arg_v[ n ][ 0 ] == '-' )
            {
                char * f = "-:l:d:j:f:gs:t:ano:qv";
                for ( ; *f; ++f ) if ( *f == arg_v[ n ][ 1 ] ) break;
                if ( ( f[ 1 ] == ':' ) && ( arg_v[ n ][ 2 ] == '\0' ) ) ++n;
            }
            else
            {
                OBJECT * target = object_new( arg_v[ n ] );
                mark_target_for_updating( target );
                object_free( target );
            }
        }

        if (!targets_to_update())
        {
            mark_target_for_updating( constant_all );
        }

        /* Parse ruleset. */
        {
            FRAME frame[ 1 ];
            frame_init( frame );
            for ( n = 0; ( s = getoptval( optv, 'f', n ) ); ++n )
            {
                OBJECT * filename = object_new( s );
                parse_file( filename, frame );
                object_free( filename );
            }

            if ( !n )
            {
                parse_file( constant_plus, frame );
            }
        }

        status = yyanyerrors();

        /* Manually touch -t targets. */
        for ( n = 0; ( s = getoptval( optv, 't', n ) ); ++n )
        {
            OBJECT * target = object_new( s );
            touch_target( target );
            object_free( target );
        }

        /* If an output file is specified, set globs.cmdout to that. */
        if ( ( s = getoptval( optv, 'o', 0 ) ) )
        {
            if ( !( globs.cmdout = fopen( s, "w" ) ) )
            {
                printf( "Failed to write to '%s'\n", s );
                exit( EXITBAD );
            }
            ++globs.noexec;
        }

        /* The build system may set the PARALLELISM variable to override -j
           options.  */
        {
            LIST *p = L0;
            p = var_get ( root_module(), constant_PARALLELISM );
            if ( p )
            {
                int j = atoi( object_str( p->value ) );
                if ( j == -1 )
                {
                    printf( "Invalid value of PARALLELISM: %s\n", object_str( p->value ) );
                }
                else
                {
                    globs.jobs = j;
                }
            }
        }

        /* KEEP_GOING overrides -q option. */
        {
            LIST *p = L0;
            p = var_get( root_module(), constant_KEEP_GOING );
            if ( p )
            {
                int v = atoi( object_str( p->value ) );
                if ( v == 0 )
                    globs.quitquick = 1;
                else
                    globs.quitquick = 0;
            }
        }

        /* Now make target. */
        {
            PROFILE_ENTER( MAIN_MAKE );

            LIST * targets = targets_to_update();
            if (targets)
            {
                int targets_count = list_length( targets );
                OBJECT * * targets2 = (OBJECT * *)
                    BJAM_MALLOC( targets_count * sizeof( OBJECT * ) );
                int n = 0;
                for ( ; targets; targets = list_next( targets ) )
                    targets2[ n++ ] = targets->value;
                status |= make( targets_count, targets2, anyhow );
                BJAM_FREE( (void *)targets2 );
            }
            else
            {
                status = last_update_now_status;
            }

            PROFILE_EXIT( MAIN_MAKE );
        }

        PROFILE_EXIT( MAIN );
    }

    if ( DEBUG_PROFILE )
        profile_dump();

    
#ifdef OPT_HEADER_CACHE_EXT
    hcache_done();
#endif

    clear_targets_to_update();

    /* Widely scattered cleanup. */
    file_done();
    rules_done();
    stamps_done();
    search_done();
    class_done();
    modules_done();
    regex_done();
    exec_done();
    pwd_done();
    path_done();
    function_done();
    list_done();
    constants_done();
    object_done();

    /* Close cmdout. */
    if ( globs.cmdout )
        fclose( globs.cmdout );

#ifdef HAVE_PYTHON
    Py_Finalize();
#endif

    BJAM_MEM_CLOSE();

    return status ? EXITBAD : EXITOK;
}
Example #25
0
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*/
Example #26
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;
}
Example #27
0
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);
  }
Example #28
0
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;
}
Example #29
0
void main()
{
	Action action = Draw;
	SetGraphicsColor(color, 1);


	InitGraf();

	int menu_it = 0;
	polygon.n = 0;

	InitGraphics();

	menu_item = 0;
	CheckMenuItem(menu_action, 1, MF_CHECKED);
	CheckMenuItem(menu_draw, 20, MF_CHECKED);

	while (key_input != ESC)						// ESC exits the program
	{
		CheckGraphicsMsg();

		if (menu_it != menu_item)
		{
			switch (menu_item){
			case 20:
				CheckMenuItem(menu_draw, 20, MF_CHECKED);
				CheckMenuItem(menu_draw, 21, MF_UNCHECKED);
				CheckMenuItem(menu_draw, 22, MF_UNCHECKED);
				menu_it = menu_item;
				shape = Line;
				break;
			case 21:
				CheckMenuItem(menu_draw, 20, MF_UNCHECKED);
				CheckMenuItem(menu_draw, 21, MF_CHECKED);
				CheckMenuItem(menu_draw, 22, MF_UNCHECKED);

				menu_it = menu_item;
				shape = Poly;
				break;
			case 22:
				CheckMenuItem(menu_draw, 20, MF_UNCHECKED);
				CheckMenuItem(menu_draw, 21, MF_UNCHECKED);
				CheckMenuItem(menu_draw, 22, MF_CHECKED);
				menu_it = menu_item;
				shape = Circle;
				break;
			default:
				int i;
				for (i = 1; i <= 16; i++)
					CheckMenuItem(menu_action, i, MF_UNCHECKED);
				CheckMenuItem(menu_action, menu_item, MF_CHECKED);
				if (menu_item >= 1 && menu_item <= 16){
					switch (menu_item) {
					case 1:
						action = Draw;
						break;
					case 2:
						action = Pick;
						break;
					case 3:
						action = Zoom;
						break;
					}
					mouse_action = NO_ACTION;
				}
				menu_it = menu_item;

			}

		}

		if (mouse_action == L_MOUSE_DOWN)
		{
			switch (action) {
			case Draw:
				MouseDownDraw();
				break;
			case Pick:
				MouseDownPick();
				break;
			case Zoom:
				MouseDownZoom();
				break;
			}
		}
		if (mouse_action == L_MOUSE_MOVE_DOWN)
		{
			switch (action) {
			case Draw:
				MouseMoveDraw();
				break;
			case Pick:
				MouseMovePick();
				break;
			case Zoom:
				MouseMoveZoom();
				break;
			}
		}
		else  if (mouse_action == L_MOUSE_UP)
		{
			switch (action) {
			case Draw:
				MouseUpDraw();
				break;
			case Pick:
				MouseUpPick();
				break;
			case Zoom:
				MouseUpZoom();
				break;
			}
		}
		else  if (mouse_action == R_MOUSE_DOWN)
		{
			switch (action) {
			case Draw:
				RMouseDownDraw();
				break;
			case Pick:
				RMouseDownPick();
				break;
			case Zoom:
				RMouseDownZoom();
				break;
			}
		}
	}

	CloseGraphics();
}
Example #30
0
// 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);

}