Beispiel #1
0
void
init_simple(void)
{
    screenInfo.numScreens = 1;
    screenInfo.screens[0] = &screen;

    screen.myNum = 0;
    screen.id = 100;
    screen.width = 640;
    screen.height = 480;
    screen.DeviceCursorInitialize = device_cursor_init;
    screen.DeviceCursorCleanup = device_cursor_cleanup;
    screen.SetCursorPosition = set_cursor_pos;
    screen.root = &root;

    dixResetPrivates();
    InitAtoms();
    XkbInitPrivates();
    dixRegisterPrivateKey(&XIClientPrivateKeyRec, PRIVATE_CLIENT,
                          sizeof(XIClientRec));
    dixRegisterPrivateKey(&miPointerScreenKeyRec, PRIVATE_SCREEN, 0);
    dixRegisterPrivateKey(&miPointerPrivKeyRec, PRIVATE_DEVICE, 0);
    XInputExtensionInit();

    init_window(&root, NULL, ROOT_WINDOW_ID);
    init_window(&window, &root, CLIENT_WINDOW_ID);

    serverClient = &server_client;
    InitClient(serverClient, 0, (void *) NULL);
    if (!InitClientResources(serverClient)) /* for root resources */
        FatalError("couldn't init server resources");
    SyncExtensionInit();

    devices = init_devices();
}
static void xtest_init_devices(void)
{
    ScreenRec screen;

    /* random stuff that needs initialization */
    memset(&screen, 0, sizeof(screen));
    screenInfo.numScreens = 1;
    screenInfo.screens[0] = &screen;
    screen.myNum = 0;
    screen.id = 100;
    screen.width = 640;
    screen.height = 480;
    screen.DeviceCursorInitialize = device_cursor_init;
    dixResetPrivates();
    InitAtoms();

    /* this also inits the xtest devices */
    InitCoreDevices();

    g_assert(xtestpointer);
    g_assert(xtestkeyboard);
    g_assert(IsXTestDevice(xtestpointer, NULL));
    g_assert(IsXTestDevice(xtestkeyboard, NULL));
    g_assert(IsXTestDevice(xtestpointer, inputInfo.pointer));
    g_assert(IsXTestDevice(xtestkeyboard, inputInfo.keyboard));
    g_assert(GetXTestDevice(inputInfo.pointer) == xtestpointer);
    g_assert(GetXTestDevice(inputInfo.keyboard) == xtestkeyboard);
}
Beispiel #3
0
int
_DndIndexToTargets(Display * display,
       int index,
       Atom ** targets)
{
    DndTargetsTable  targets_table;
    int i ;

    /* again, slow: no caching here, alloc/free each time */

    InitAtoms(display) ;

    printf("index %d\n", index);

    if (!(targets_table = TargetsTable (display)) ||
  (index >= targets_table->num_entries)) {
        return -1;
    }

    /* transfer the correct target list index */
    *targets = (Atom*)malloc(sizeof(Atom)*targets_table->
          entries[index].num_targets);
    memcpy((char*)*targets,
     (char*)targets_table->entries[index].targets,
     sizeof(Atom)*targets_table->entries[index].num_targets);

    /* free the target table and its guts */
    for (i=0 ; i < targets_table->num_entries; i++) 
  XFree((char*)targets_table->entries[i].targets);
    XFree((char*)targets_table);

    return targets_table->entries[index].num_targets;
}
Beispiel #4
0
XCBEventFilter::XCBEventFilter(LSession *sessionhandle) : QAbstractNativeEventFilter(){
  session = sessionhandle; //save this for interaction with the session later
  TrayDmgFlag = 0;
  stopping = false;
  session->XCB->SelectInput(QX11Info::appRootWindow()); //make sure we get root window events
  InitAtoms();
}
Beispiel #5
0
extern int
_DndTargetsToIndex(Display * display,
       Atom * targets, int num_targets)
{
    int    i, j;
    Atom    *sorted_targets;
    DndTargetsTable  targets_table;
    int index = -1 ;

    InitAtoms(display) ;

    if (!(targets_table = TargetsTable (display))||
  (index >= targets_table->num_entries)) {
#ifdef ENABLE_MOTIF_WARNINGS
  printf("_DndTargetsToIndex: cannot find the target table data\n");
#endif
        return -1 ;
    }

    /* sort the given target list */
    sorted_targets = (Atom *) malloc(sizeof(Atom) * num_targets);
    memcpy (sorted_targets, targets, sizeof(Atom) * num_targets);
    qsort ((void *)sorted_targets, (size_t)num_targets, (size_t)sizeof(Atom),
           AtomCompare);

    /* look for a match */

    for (i = 0; i < targets_table->num_entries; i++) {
  if (num_targets == targets_table->entries[i].num_targets) {
            for (j = 0; j < num_targets; j++) {
          if (sorted_targets[j] != 
        targets_table->entries[i].targets[j]) {
              break;
    }
      }
      if (j == num_targets) {
          index = i ;
    break ;
      }
  }
    }
    
    XFree ((char *)sorted_targets);
    /* free the target table and its guts */
    for (i=0 ; i < targets_table->num_entries; i++) 
  XFree((char*)targets_table->entries[i].targets);
    XFree((char*)targets_table);

#ifdef ENABLE_MOTIF_WARNINGS
    if (index == -1 )
  printf("DndTargetsToIndex: non existing target list: unsupported\n");
#endif
        /* to support: need to grab the server, add our target list
     to the property, return index = num_entries++, and ungrab */
    return index ;
}
Beispiel #6
0
void init_simple(void)
{
    screenInfo.arraySize = MAXSCREENS;
    screenInfo.numScreens = 1;
    screenInfo.screens[0] = &screen;

    screen.myNum = 0;
    screen.id = 100;
    screen.width = 640;
    screen.height = 480;
    screen.DeviceCursorInitialize = device_cursor_init;
    screen.SetCursorPosition = set_cursor_pos;

    dixResetPrivates();
    InitAtoms();
    XInputExtensionInit();
    init_window(&root, NULL, ROOT_WINDOW_ID);
    init_window(&window, &root, CLIENT_WINDOW_ID);

    devices = init_devices();
}
int
main(int argc, char *argv[])
{
    int         i, oldumask;

    argcGlobal = argc;
    argvGlobal = argv;

    configfilename = NULL;

    /* init stuff */
    ProcessCmdLine(argc, argv);

    /*
     * Do this first thing, to get any options that only take effect at
     * startup time.  It is read again each time the server resets.
     */
    if (ReadConfigFile(configfilename) != FSSuccess) {
	FatalError("couldn't read config file\n");
    }
    InitErrors();

    /* make sure at least world write access is disabled */
    if (((oldumask = umask(022)) & 002) == 002)
	(void)umask(oldumask);

    SetDaemonState();
    SetUserId();

    while (1) {
	serverGeneration++;
	OsInit();
	if (serverGeneration == 1) {
	    /* do first time init */
	    CreateSockets(OldListenCount, OldListen);
	    InitProcVectors();
	    clients = (ClientPtr *) fsalloc(MAXCLIENTS * sizeof(ClientPtr));
	    if (!clients)
		FatalError("couldn't create client array\n");
	    for (i = MINCLIENT; i < MAXCLIENTS; i++)
		clients[i] = NullClient;
	    /* make serverClient */
	    serverClient = (ClientPtr) fsalloc(sizeof(ClientRec));
	    if (!serverClient)
		FatalError("couldn't create server client\n");
	}
	ResetSockets();

	/* init per-cycle stuff */
	InitClient(serverClient, SERVER_CLIENT, (pointer) 0);

	clients[SERVER_CLIENT] = serverClient;
	currentMaxClients = MINCLIENT;
	currentClient = serverClient;

	if (!InitClientResources(serverClient))
	    FatalError("couldn't init server resources\n");

	InitAtoms();
	InitFonts();
	SetConfigValues();
	if (!create_connection_block())
	    FatalError("couldn't create connection block\n");

#ifdef DEBUG
	fprintf(stderr, "Entering Dispatch loop\n");
#endif

	Dispatch();

#ifdef DEBUG
	fprintf(stderr, "Leaving Dispatch loop\n");
#endif

	/* clean up per-cycle stuff */
	if ((dispatchException & DE_TERMINATE) || drone_server)
	    break;
	fsfree(ConnectionInfo);
	/* note that we're parsing it again, for each time the server resets */
	if (ReadConfigFile(configfilename) != FSSuccess)
	    FatalError("couldn't read config file\n");
    }

    CloseSockets();
    CloseErrors();
    exit(0);
}
Beispiel #8
0
int
main(int argc, char *argv[], char *envp[])
#endif
{
    int i;
    HWEventQueueType alwaysCheckForInput[2];

    display = "0";

    InitRegions();

    CheckUserParameters(argc, argv, envp);

    CheckUserAuthorization();

    InitConnectionLimits();

    ProcessCommandLine(argc, argv);

    alwaysCheckForInput[0] = 0;
    alwaysCheckForInput[1] = 1;
    while (1) {
        serverGeneration++;
        ScreenSaverTime = defaultScreenSaverTime;
        ScreenSaverInterval = defaultScreenSaverInterval;
        ScreenSaverBlanking = defaultScreenSaverBlanking;
        ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
#ifdef DPMSExtension
        DPMSStandbyTime = DPMSSuspendTime = DPMSOffTime = ScreenSaverTime;
        DPMSEnabled = TRUE;
        DPMSPowerLevel = 0;
#endif
        InitBlockAndWakeupHandlers();
        /* Perform any operating system dependent initializations you'd like */
        OsInit();
        if (serverGeneration == 1) {
            CreateWellKnownSockets();
            for (i = 1; i < MAXCLIENTS; i++)
                clients[i] = NullClient;
            serverClient = calloc(sizeof(ClientRec), 1);
            if (!serverClient)
                FatalError("couldn't create server client");
            InitClient(serverClient, 0, (pointer) NULL);
        }
        else
            ResetWellKnownSockets();
        clients[0] = serverClient;
        currentMaxClients = 1;

        /* Initialize privates before first allocation */
        dixResetPrivates();

        /* Initialize server client devPrivates, to be reallocated as
         * more client privates are registered
         */
        if (!dixAllocatePrivates(&serverClient->devPrivates, PRIVATE_CLIENT))
            FatalError("failed to create server client privates");

        if (!InitClientResources(serverClient)) /* for root resources */
            FatalError("couldn't init server resources");

        SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]);
        screenInfo.numScreens = 0;

        InitAtoms();
        InitEvents();
        InitSelections();
        InitGlyphCaching();
        dixResetRegistry();
        ResetFontPrivateIndex();
        InitCallbackManager();
        InitOutput(&screenInfo, argc, argv);

        if (screenInfo.numScreens < 1)
            FatalError("no screens found");
        InitExtensions(argc, argv);

        for (i = 0; i < screenInfo.numGPUScreens; i++) {
            ScreenPtr pScreen = screenInfo.gpuscreens[i];
            if (!CreateScratchPixmapsForScreen(pScreen))
                FatalError("failed to create scratch pixmaps");
        }

        for (i = 0; i < screenInfo.numScreens; i++) {
            ScreenPtr pScreen = screenInfo.screens[i];

            if (!CreateScratchPixmapsForScreen(pScreen))
                FatalError("failed to create scratch pixmaps");
            if (pScreen->CreateScreenResources &&
                !(*pScreen->CreateScreenResources) (pScreen))
                FatalError("failed to create screen resources");
            if (!CreateGCperDepth(i))
                FatalError("failed to create scratch GCs");
            if (!CreateDefaultStipple(i))
                FatalError("failed to create default stipple");
            if (!CreateRootWindow(pScreen))
                FatalError("failed to create root window");
        }

        InitFonts();
        if (SetDefaultFontPath(defaultFontPath) != Success) {
            ErrorF("[dix] failed to set default font path '%s'",
                   defaultFontPath);
        }
        if (!SetDefaultFont(defaultTextFont)) {
            FatalError("could not open default font '%s'", defaultTextFont);
        }

        if (!(rootCursor = CreateRootCursor(NULL, 0))) {
            FatalError("could not open default cursor font '%s'",
                       defaultCursorFont);
        }

#ifdef DPMSExtension
        /* check all screens, looking for DPMS Capabilities */
        DPMSCapableFlag = DPMSSupported();
        if (!DPMSCapableFlag)
            DPMSEnabled = FALSE;
#endif

#ifdef PANORAMIX
        /*
         * Consolidate window and colourmap information for each screen
         */
        if (!noPanoramiXExtension)
            PanoramiXConsolidate();
#endif

        for (i = 0; i < screenInfo.numScreens; i++)
            InitRootWindow(screenInfo.screens[i]->root);

        InitCoreDevices();
        InitInput(argc, argv);
        InitAndStartDevices();
        ReserveClientIds(serverClient);

        dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);

#ifdef PANORAMIX
        if (!noPanoramiXExtension) {
            if (!PanoramiXCreateConnectionBlock()) {
                FatalError("could not create connection block info");
            }
        }
        else
#endif
        {
            if (!CreateConnectionBlock()) {
                FatalError("could not create connection block info");
            }
        }

#ifdef XQUARTZ
        /* Let the other threads know the server is done with its init */
        pthread_mutex_lock(&serverRunningMutex);
        serverRunning = TRUE;
        pthread_cond_broadcast(&serverRunningCond);
        pthread_mutex_unlock(&serverRunningMutex);
#endif

        NotifyParentProcess();

        Dispatch();

#ifdef XQUARTZ
        /* Let the other threads know the server is no longer running */
        pthread_mutex_lock(&serverRunningMutex);
        serverRunning = FALSE;
        pthread_mutex_unlock(&serverRunningMutex);
#endif

        UndisplayDevices();
        DisableAllDevices();

        /* Now free up whatever must be freed */
        if (screenIsSaved == SCREEN_SAVER_ON)
            dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
        FreeScreenSaverTimer();
        CloseDownExtensions();

#ifdef PANORAMIX
        {
            Bool remember_it = noPanoramiXExtension;

            noPanoramiXExtension = TRUE;
            FreeAllResources();
            noPanoramiXExtension = remember_it;
        }
#else
        FreeAllResources();
#endif

        CloseInput();

        for (i = 0; i < screenInfo.numScreens; i++)
            screenInfo.screens[i]->root = NullWindow;

        CloseDownDevices();

        CloseDownEvents();

        for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
            ScreenPtr pScreen = screenInfo.gpuscreens[i];
            FreeScratchPixmapsForScreen(pScreen);
            (*pScreen->CloseScreen) (pScreen);
            dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
            free(pScreen);
            screenInfo.numGPUScreens = i;
        }

        for (i = screenInfo.numScreens - 1; i >= 0; i--) {
            FreeScratchPixmapsForScreen(screenInfo.screens[i]);
            FreeGCperDepth(i);
            FreeDefaultStipple(i);
            dixFreeScreenSpecificPrivates(screenInfo.screens[i]);
            (*screenInfo.screens[i]->CloseScreen) (screenInfo.screens[i]);
            dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN);
            free(screenInfo.screens[i]);
            screenInfo.numScreens = i;
        }

        ReleaseClientIds(serverClient);
        dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
        serverClient->devPrivates = NULL;

        FreeFonts();

        FreeAuditTimer();

        if (dispatchException & DE_TERMINATE) {
            CloseWellKnownConnections();
        }

        OsCleanup((dispatchException & DE_TERMINATE) != 0);

        if (dispatchException & DE_TERMINATE) {
            ddxGiveUp(EXIT_NO_ERROR);
            break;
        }

        free(ConnectionInfo);
        ConnectionInfo = NULL;
    }
    return 0;
}
Beispiel #9
0
void WindowManager::init_internals(void)
{
	ELOG("Starting window manager");
	wm_conf = new WindowManagerConfig;

	app_starting = false;

	// defaults, in case world goes down
	wm_conf->title_active_color = fl_rgb(0,0,128);
	wm_conf->title_active_color_text = fl_rgb(255,255,255);
	wm_conf->title_normal_color = fl_rgb(192,192,192);
	wm_conf->title_normal_color_text = fl_rgb(0,0,128);
	wm_conf->title_label_align = FL_ALIGN_LEFT;
	wm_conf->title_height = 20;
	wm_conf->title_box_type = 0;
	wm_conf->frame_do_opaque = false;
	wm_conf->frame_animate = true;
	wm_conf->frame_animate_speed = 15;

	fl_open_display();
	XSetErrorHandler(xerror_handler);
	wm_area.set(0, 0, Fl::w(), Fl::h());

	read_configuration();
	read_xset_configuration();

	//register_protocols();
#ifdef _DEBUG
	InitAtoms(fl_display, atom_map);
	register_events();
#else
	InitAtoms(fl_display);
#endif

	//cur = XCreateFontCursor(fl_display, XC_left_ptr);
	//XDefineCursor(fl_display, RootWindow(fl_display, fl_screen), cur);
	// load cursor
	cur = new CursorHandler;
	cur->load(X_CURSORS);
	cur->set_root_cursor();

	sound_system = new SoundSystem();
	sound_system->init();

	sound_system->add(SOUND_MINIMIZE, "sounds/minimize.ogg");
	sound_system->add(SOUND_MAXIMIZE, "sounds/maximize.ogg");
	sound_system->add(SOUND_CLOSE,    "sounds/close.ogg");
	sound_system->add(SOUND_RESTORE,  "sounds/restore.ogg");
	sound_system->add(SOUND_SHADE,    "sounds/shade.ogg");

	// the world is starting here
	show();
	register_protocols();

	hint_stuff = new Hints;
	hint_stuff->icccm_set_iconsizes(this);

	init_clients();
	Fl::add_handler(wm_event_handler);
	XSync(fl_display, 0);

	is_running = true;
}
Beispiel #10
0
XCBEventFilter::XCBEventFilter(LSession *sessionhandle) : QAbstractNativeEventFilter(){
  session = sessionhandle; //save this for interaction with the session later
  TrayDmgFlag = 0;
  stopping = false;
  InitAtoms();
}
Beispiel #11
0
int main(int argc, char **argv, char **env)
	{
	int i;
	int save_flag=0;
	char *save_file=NULL;


	
	if(sizeof(Term)!=4)
		{
		puts("Compilation error");
		return -1;
		}

	if(argc>1 && strcmp(argv[1],"-exv")==0)
		{
		exv(argc-1,argv+1);
		return 0;
		}

	InitAtoms();
	InitFuncs();
	AlwaysBracets = 0;
	WideWriting = 0;
	signal(SIGINT, stop);
	signal(SIGSEGV, sigsegv);
	signal(SIGUSR1, sigdmp);
	

	for(i=1; i<argc; i++)
		{
		if(strcmp(argv[i],"-v")==0)
			{
			VerbMode=1;
			continue;
			}
		if(strcmp(argv[i],"-vv")==0)
			{
			VerbMode=2;
			continue;
			}
		if(strcmp(argv[i],"-vvv")==0)
			{
			VerbMode=3;
			continue;
			}
		if(strcmp(argv[i],"-c4")==0)
			{
			ChepVersion=4;
			continue;
			}	
		if(strcmp(argv[i],"-c3")==0)
			{
			ChepVersion=3;
			continue;
			}	
		if(strcmp(argv[i],"-mOmega")==0)
			{
			ChepVersion=4;
			MicroOmega=1;
			continue;
			}	
		if(strcmp(argv[i],"-OutDir")==0)
			{
			OutputDirectory=argv[++i];
			continue;
			}
		if(strcmp(argv[i],"-InDir")==0)
			{
			InputDirectory=argv[++i];
			continue;
			}
		if(strcmp(argv[i],"-allvrt")==0)
			{
			write_all_vertices=1;
			continue;
			}
		if(strcmp(argv[i],"-rc")==0)
			{
			InitFile=argv[++i];
			continue;
			}
		if(strcmp(argv[i],"-tex")==0)
			{
			TexOutput=1;
			opSplitCol1=0;
			continue;
			}
		if(strcmp(argv[i],"-feynarts")==0 || strcmp(argv[i],"-FeynArts")==0)
			{
			FAOutput=1;
			opSplitCol1=0;
			opSplitCol2=0;
			continue;
			}
		if(strcmp(argv[i],"-feynarts6")==0 || strcmp(argv[i],"-FeynArts6")==0 ||
				strcmp(argv[i],"-fa6")==0)
			{
			FAOutput=1;
			FAver=6;
			opSplitCol1=0;
			opSplitCol2=0;
			continue;
			}
		if(strcmp(argv[i],"-uf")==0 || strcmp(argv[i],"-UF")==0)
			{
			UFOutput=1;
			opSplitCol1=0;
			opSplitCol2=0;
			continue;
			}
		if(strcmp(argv[i],"-save")==0)
			{
			save_flag=1;
			save_file=argv[++i];
			printf("Feynman rules will be saved in '%s' file.\n",save_file);
			continue;
			}
		if(strcmp(argv[i],"-eval-prm")==0)
			{
			EvalPrm=1;
			continue;
			}
		if(strcmp(argv[i],"-eval-vrt")==0)
			{
			EvalVrt=1;
			continue;
			}
		if(strcmp(argv[i],"-frc")==0)
			{
			ForsedRedCol=1;
			continue;
			}
		if(strcmp(argv[i],"-nocolor")==0)
			{
			NoColors=1;
			continue;
			}
		if(strcmp(argv[i],"-colors")==0)
			{
			WriteColors=1;
			continue;
			}
        if(strcmp(argv[i],"-no4color")==0)
			{
            No4Color=1;
			continue;
            }
		if(strcmp(argv[i],"-nocdot")==0)
			{
			TEX_set_dot=0;
			continue;
			}
		if(strcmp(argv[i],"-v-charges")==0)
			{
			verb_charge=1;
			continue;
			}
		if(strcmp(argv[i],"-v-herm")==0)
			{
			verb_herm=1;
			continue;
			}
		if(strcmp(argv[i],"-v-imprt")==0)
			{
			verb_imprt=1;
			continue;
			}
		if(strcmp(argv[i],"-off-srefine")==0)
			{
			off_srefine=1;
			continue;
			}
		if(strcmp(argv[i],"-chep-srefine")==0)
			{
			ch_sign=1;
			continue;
			}
		if(strcmp(argv[i],"-texLines")==0)
			{
			sscanf(argv[++i],"%d",&TEX_lines);
			continue;
			}
		if(strcmp(argv[i],"-texLineLength")==0)
			{
			sscanf(argv[++i],"%d",&TEX_spec_in_line);
			continue;
			}
		if(strcmp(argv[i],"-texMaxPrtNo")==0)
			{
			sscanf(argv[++i],"%d",&TEX_max_pno);
			continue;
			}
		if(strncmp(argv[i],"-abbr",5)==0)
			{
			if(eval_vrt_len)
				{
				puts("Error: -evl and -abbr options are not compatible");
				continue;
				}
			opAbbrVrt=1;
			opAbbArr=1;
			opEvalVrt=0;
			opTriHeu=0;
			if(argv[i][5]>'1' && argv[i][5]<'9')
				opAbbrVrt=argv[i][5]-'1'+1;
			if(argv[i][5]=='A')
				opAbbArr=0;
			opNoDummies=1;
			continue;
			}
		if(strcmp(argv[i],"-evl")==0)
			{
			if(opAbbrVrt)
			{
				puts("Error: -evl and -abbr options are not compatible");
				i++;
				continue;
			}
			sscanf(argv[++i],"%d",&eval_vrt_len);
			if(eval_vrt_len==2)
			{
				opNoDummies=1;
				eval_vrt_more=1;
				/*kill_gamma_pm=1;*/
			}
			continue;
			}
		if(strcmp(argv[i],"-sleep")==0)
			{
			int sec;
			sscanf(argv[++i],"%d",&sec);
			sleep(sec*60);
			continue;
			}
		if(strcmp(argv[i],"-key")==0)
			{
			SetKeyFromArg(argv[++i]);
			continue;
			}
		if(strcmp(argv[i],"-edbg")==0)
			{
			end_with_tty=1;
			continue;
			}
		if(strcmp(argv[i],"-norc")==0)
			{
			remove_rc=1;
			continue;
			}
		if(argv[i][0]=='-')
			{
			ErrorInfo(0);
			printf(": unknown option %s.\n",argv[i]);
			continue;
			}
		if(InputFile)
			{
			ErrorInfo(0);
			printf(": unknown option %s.\n",argv[i]);
			continue;
			}
		InputFile=argv[i];
		}

	if(!write_all_vertices && !TexOutput)
	{
		if(FAOutput)
			opMaxiLegs=4;
		else
			opMaxiLegs=4;
	}

	if(UFOutput)
	{
		FAOutput=1;
		opAbbrVrt=1;
		opAbbArr=0;
		opEvalVrt=0;
		opTriHeu=0;
		opNoDummies=1;
	}
		
	if(MicroOmega)
		SetKeyFromArg("MicrOmega=1");
	else
		SetKeyFromArg("MicrOmega=0");
	
	if(FAOutput)
		SetKeyFromArg("FeynArts=1");
	else
		SetKeyFromArg("FeynArts=0");
		
	if(InputDirectory==NULL)
		{
		InputDirectory=find_path(argv[0],env);
		if(VerbMode)
			printf("Input directory is '%s'\n",InputDirectory);
		}
	doinitfile=1;	
    ReadFile(InitFile);
	doinitfile=0;
	if(InputFile!=NULL)
		ReadFile(InputFile);
	else
		{
		printf(
"Welcome to LanHEP                                Version 3.1.1  (Nov 08 2010)\n");
		/*
		log_file=fopen("lhep.log","w");
		if(log_file==NULL)
			printf("Warning: can not open file lhep.log for writing.\n");
		*/
		ReadFile(NULL);
		if(log_file!=NULL)
			{
			fclose(log_file);
			log_file=0;
			}
		}

puts("");

/*	AtomStatistics();
	ListStatistics();
*/
	if(save_flag)
		{
		Term t;
		SaveRules(save_file);
		if(itrSetIn("q.sav")==0)
			return 0;

		while((t=itrIn())!=0)
			{
			WriteTerm(t);
			puts("");
			}

		itrCloseIn();

		return 0;
		}

	if(ModelNumber!=0 || InputFile!=NULL)
		{
		if(MicroOmega)
			ModelNumber=1;
		RegisterLine("MAIN: writing lagrangian.");
		WriteLagrFile(ModelNumber,ModelName);
		UnregisterLine();
		RegisterLine("MAIN: writing parameters and particles.");
		WriteParameters(ModelNumber,ModelName);
		WriteParticles(ModelNumber,ModelName);
		if(MicroOmega)
		{
			ModelNumber=2;
			SecondVaFu=1;
			WriteParameters(ModelNumber,ModelName);
		}
		UnregisterLine();
		WriteExtlib(ModelNumber,ModelName);
		WriteCpart(ModelNumber,ModelName);
		
		if(!TexOutput && !FAOutput && C_F_WIDTH<longest_cfline)
		{
			printf("Error: 'Common Factor' field longer than maximum of %d symbols.\n",
					C_F_WIDTH);
			printf("Use the statement 'option chepCFWidth=%d.'\n",longest_cfline+1);
		}
		if(!TexOutput && !FAOutput && L_P_WIDTH<longest_lpline)
		{
			printf("Error: 'Lorentz part' field longer than maximum of %d symbols.\n",
					L_P_WIDTH);
			printf("Use the statement 'option chepLPWidth=%d.'\n",longest_lpline+1);
		}
		if(!TexOutput && !FAOutput && P_D_WIDTH<longest_pdline)
		{
			if(P_D_WIDTH)
			{
			printf("Error: 'Parameter expression' field for '%s' is longer than maximum of %d symbols.\n",
					AtomValue(llparam),P_D_WIDTH);
			printf("Use the statement 'option chepPDWidth=%d.'\n",longest_pdline+1);
			}
			else if(longest_pdline>100)
				printf("Longest parameter expression is %d symbols for '%s'.\n",longest_pdline,
					AtomValue(llparam));
		}
		
		if(!TexOutput && !FAOutput && VerbMode)
			{
			printf("Longest Common factor line is %d symbols (max %d)\n",
											longest_cfline,C_F_WIDTH);
			printf("Longest Lorentz part  line is %d symbols (max %d)\n",
											longest_lpline,L_P_WIDTH);
			printf("Longest Parameter dep line is %d symbols (max %d)\n\n",
											longest_pdline,P_D_WIDTH);
			}
		}
/*
	else
		puts("Model # is zero");
*/
	if(VerbMode)
		{
		int i;
		printf("%5.1fMB of memory used.\n",
			(ListMemory()+TermMemory())*0.001);
		abbr_stat();
		/*AtomStatistics();
		ListStatistics();
		for(i=0;i<10;i++)
			if(inf_removed[i]) printf("%d pwr of inf: %d\n",i,inf_removed[i]);*/
		}

	if(err_cnt)
		puts("!!!!!!!!!!!!! THERE WERE ERRORS DURING PROCESSING !!!!!!!!");
		
		if(end_with_tty)
		{
			ReadFile(NULL);
			puts("");
		}
		
	return 0;
	}
Beispiel #12
0
int
dix_main(int argc, char *argv[], char *envp[])
{
    int i;
    HWEventQueueType alwaysCheckForInput[2];
    #ifdef _DEBUG
    //int TmpFlag=_CrtSetDbgFlag( _CRTDBG_REPORT_FLAG);
    
    //TmpFlag|=_CRTDBG_ALLOC_MEM_DF;
    //TmpFlag|=_CRTDBG_DELAY_FREE_MEM_DF;
    //TmpFlag|=_CRTDBG_CHECK_ALWAYS_DF;
    //TmpFlag|=_CRTDBG_CHECK_CRT_DF;
    //TmpFlag|=_CRTDBG_LEAK_CHECK_DF;
    
    //_CrtSetDbgFlag(TmpFlag);
    #endif

    ptw32_processInitialize();
    display = "0";

    #ifdef WIN32

    if (InitWSA()<0)
    {
      printf("Error initialising WSA\n");
      return -1;
    }
    /* In Win32 we have different threads call Xlib functions (depending
       on the commandline options given).
       XInitThreads has to be called before
       any xlib function is called (aoccording to the man page) */
    XInitThreads();
    /* change the current directory to the directory where the vcxsrv.exe executable is installed.
       This is needed because the font directories are relative to the current directory.
     */
     {
       char ModuleFilename[MAX_PATH];
       char *pSlash;
       GetModuleFileName(NULL,ModuleFilename,sizeof(ModuleFilename));
       pSlash=strrchr(ModuleFilename,'\\');
       if (pSlash)
       {
         *pSlash='\0';
         chdir(ModuleFilename);
       }
     }
    OsVendorPreInit(argc, argv);
    #endif

    InitRegions();

    CheckUserParameters(argc, argv, envp);

    CheckUserAuthorization();

    InitConnectionLimits();

    ProcessCommandLine(argc, argv);

    alwaysCheckForInput[0] = 0;
    alwaysCheckForInput[1] = 1;
    while (1) {
        serverGeneration++;
        ScreenSaverTime = defaultScreenSaverTime;
        ScreenSaverInterval = defaultScreenSaverInterval;
        ScreenSaverBlanking = defaultScreenSaverBlanking;
        ScreenSaverAllowExposures = defaultScreenSaverAllowExposures;
#ifdef DPMSExtension
        DPMSStandbyTime = DPMSSuspendTime = DPMSOffTime = ScreenSaverTime;
        DPMSEnabled = TRUE;
        DPMSPowerLevel = 0;
#endif
        InitBlockAndWakeupHandlers();
        /* Perform any operating system dependent initializations you'd like */
        if (serverGeneration == 1) {
            CreateWellKnownSockets();
            for (i = 1; i < MAXCLIENTS; i++)
                clients[i] = NullClient;
            serverClient = calloc(sizeof(ClientRec), 1);
            if (!serverClient)
                FatalError("couldn't create server client");
            InitClient(serverClient, 0, (void *) NULL);
        }
        else
            ResetWellKnownSockets();
        clients[0] = serverClient;
        currentMaxClients = 1;
        OsInit();

        /* clear any existing selections */
        InitSelections();

        /* Initialize privates before first allocation */
        dixResetPrivates();

        /* Initialize server client devPrivates, to be reallocated as
         * more client privates are registered
         */
        if (!dixAllocatePrivates(&serverClient->devPrivates, PRIVATE_CLIENT))
            FatalError("failed to create server client privates");

        if (!InitClientResources(serverClient)) /* for root resources */
            FatalError("couldn't init server resources");

        SetInputCheck(&alwaysCheckForInput[0], &alwaysCheckForInput[1]);
        screenInfo.numScreens = 0;

        InitAtoms();
        InitEvents();
        InitGlyphCaching();
        dixResetRegistry();
        ResetFontPrivateIndex();
        InitCallbackManager();
        InitOutput(&screenInfo, argc, argv);

        if (screenInfo.numScreens < 1)
            FatalError("no screens found");
        InitExtensions(argc, argv);

        for (i = 0; i < screenInfo.numGPUScreens; i++) {
            ScreenPtr pScreen = screenInfo.gpuscreens[i];
            if (!CreateScratchPixmapsForScreen(pScreen))
                FatalError("failed to create scratch pixmaps");
            if (pScreen->CreateScreenResources &&
                !(*pScreen->CreateScreenResources) (pScreen))
                FatalError("failed to create screen resources");
        }

        for (i = 0; i < screenInfo.numScreens; i++) {
            ScreenPtr pScreen = screenInfo.screens[i];

            if (!CreateScratchPixmapsForScreen(pScreen))
                FatalError("failed to create scratch pixmaps");
            if (pScreen->CreateScreenResources &&
                !(*pScreen->CreateScreenResources) (pScreen))
                FatalError("failed to create screen resources");
            if (!CreateGCperDepth(i))
                FatalError("failed to create scratch GCs");
            if (!CreateDefaultStipple(i))
                FatalError("failed to create default stipple");
            if (!CreateRootWindow(pScreen))
                FatalError("failed to create root window");
        }

        InitFonts();
        if (SetDefaultFontPath(defaultFontPath) != Success) {
            ErrorF("[dix] failed to set default font path '%s'",
                   defaultFontPath);
        }
        if (!SetDefaultFont(defaultTextFont)) {
            FatalError("could not open default font '%s'", defaultTextFont);
        }

        if (!(rootCursor = CreateRootCursor(NULL, 0))) {
            FatalError("could not open default cursor font '%s'",
                       defaultCursorFont);
        }

#ifdef DPMSExtension
        /* check all screens, looking for DPMS Capabilities */
        DPMSCapableFlag = DPMSSupported();
        if (!DPMSCapableFlag)
            DPMSEnabled = FALSE;
#endif

#ifdef PANORAMIX
        /*
         * Consolidate window and colourmap information for each screen
         */
        if (!noPanoramiXExtension)
            PanoramiXConsolidate();
#endif

        for (i = 0; i < screenInfo.numScreens; i++)
            InitRootWindow(screenInfo.screens[i]->root);

        InitCoreDevices();
        InitInput(argc, argv);
        InitAndStartDevices();
        ReserveClientIds(serverClient);

        dixSaveScreens(serverClient, SCREEN_SAVER_FORCER, ScreenSaverReset);

        dixCloseRegistry();

#ifdef PANORAMIX
        if (!noPanoramiXExtension) {
            if (!PanoramiXCreateConnectionBlock()) {
                FatalError("could not create connection block info");
            }
        }
        else
#endif
        {
            if (!CreateConnectionBlock()) {
                FatalError("could not create connection block info");
            }
        }

#ifdef XQUARTZ
        /* Let the other threads know the server is done with its init */
        pthread_mutex_lock(&serverRunningMutex);
        serverRunning = TRUE;
        pthread_cond_broadcast(&serverRunningCond);
        pthread_mutex_unlock(&serverRunningMutex);
#endif

        NotifyParentProcess();

        #ifdef _MSC_VER
        // initialise here because doing it in InitInput failes because keyboard device is not started yet then
        winInitializeModeKeyStates ();
        #endif

        Dispatch();

#ifdef XQUARTZ
        /* Let the other threads know the server is no longer running */
        pthread_mutex_lock(&serverRunningMutex);
        serverRunning = FALSE;
        pthread_mutex_unlock(&serverRunningMutex);
#endif

        UndisplayDevices();
        DisableAllDevices();

        /* Now free up whatever must be freed */
        if (screenIsSaved == SCREEN_SAVER_ON)
            dixSaveScreens(serverClient, SCREEN_SAVER_OFF, ScreenSaverReset);
        FreeScreenSaverTimer();
        CloseDownExtensions();

#ifdef PANORAMIX
        {
            Bool remember_it = noPanoramiXExtension;

            noPanoramiXExtension = TRUE;
            FreeAllResources();
            noPanoramiXExtension = remember_it;
        }
#else
        FreeAllResources();
#endif

        CloseInput();

        for (i = 0; i < screenInfo.numScreens; i++)
            screenInfo.screens[i]->root = NullWindow;

        CloseDownDevices();

        CloseDownEvents();

        for (i = screenInfo.numGPUScreens - 1; i >= 0; i--) {
            ScreenPtr pScreen = screenInfo.gpuscreens[i];
            FreeScratchPixmapsForScreen(pScreen);
            (*pScreen->CloseScreen) (pScreen);
            dixFreePrivates(pScreen->devPrivates, PRIVATE_SCREEN);
            free(pScreen);
            screenInfo.numGPUScreens = i;
        }

        for (i = screenInfo.numScreens - 1; i >= 0; i--) {
            FreeScratchPixmapsForScreen(screenInfo.screens[i]);
            FreeGCperDepth(i);
            FreeDefaultStipple(i);
            dixFreeScreenSpecificPrivates(screenInfo.screens[i]);
            (*screenInfo.screens[i]->CloseScreen) (screenInfo.screens[i]);
            dixFreePrivates(screenInfo.screens[i]->devPrivates, PRIVATE_SCREEN);
            free(screenInfo.screens[i]);
            screenInfo.numScreens = i;
        }

        ReleaseClientIds(serverClient);
        dixFreePrivates(serverClient->devPrivates, PRIVATE_CLIENT);
        serverClient->devPrivates = NULL;

	dixFreeRegistry();

        FreeFonts();

        FreeAllAtoms();

        FreeAuditTimer();

        DeleteCallbackManager();

        if (dispatchException & DE_TERMINATE) {
            CloseWellKnownConnections();
        }

        OsCleanup((dispatchException & DE_TERMINATE) != 0);

        if (dispatchException & DE_TERMINATE) {
            ddxGiveUp(EXIT_NO_ERROR);
            break;
        }

        free(ConnectionInfo);
        ConnectionInfo = NULL;
    }
    return 0;
}