コード例 #1
0
ファイル: main.c プロジェクト: burzumishi/e16
static void
ECheckEprog(const char *name)
{
    char                s[1024];

    Esnprintf(s, sizeof(s), "%s/%s", EDirBin(), name);

    if (!exists(s))
    {
        Alert(_("!!!!!!!! ERROR ERROR ERROR ERROR !!!!!!!!\n" "\n"
                "Enlightenment's utility executable cannot be found at:\n"
                "\n" "%s\n"
                "This is a fatal error and Enlightenment will cease to run.\n"
                "Please rectify this situation and ensure it is installed\n"
                "correctly.\n" "\n"
                "The reason this could be missing is due to badly created\n"
                "packages, someone manually deleting that program or perhaps\n"
                "an error in installing Enlightenment.\n"), s);
        EExit(1);
    }

    if (!canexec(s))
    {
        Alert(_("!!!!!!!! ERROR ERROR ERROR ERROR !!!!!!!!\n" "\n"
                "Enlightenment's utility executable is not able to be executed:\n"
                "\n" "%s\n"
                "This is a fatal error and Enlightenment will cease to run.\n"
                "Please rectify this situation and ensure it is installed\n"
                "correctly.\n"), s);
        EExit(1);
    }
}
コード例 #2
0
ファイル: Appmobile.c プロジェクト: crmne/UDPLoadBalancer
void *scheduler(void *p)
{
	struct timeval timeout; char ch=1; int ris;

	for(;;)
	{
		do {
			rdset=all;
			timeout.tv_sec=0;
			timeout.tv_usec=40000;
			ris=select(1,NULL,NULL,NULL,&timeout);
		} while( (ris<0) && (errno==EINTR) );
		if(ris<0) {
			perror("thread scheduler - select failed: TERMINO ");
			sleep(1);
			EExit(1);
		}
		do {
			ris=send(fds[1],&ch,1, MSG_NOSIGNAL);
		} while( (ris<0)&&(errno==EINTR));
		if(ris<0) {
			perror("thread scheduler - select failed: TERMINO ");
			sleep(1);
			EExit(1);
		}
	}
	pthread_exit(NULL);
	return(NULL);
}
コード例 #3
0
ファイル: main.c プロジェクト: burzumishi/e16
static void
EDirCheck(const char *dir)
{
    if (file_test(dir, EFILE_DIR | EPERM_RWX))
        return;

    Alert(_("%s must be a directory in which you have\n"
            "read, write, and execute permission.\n"), dir);
    EExit(1);
}
コード例 #4
0
ファイル: session.c プロジェクト: Limsik/e17
/* This function is usually exclusively devoted to saving data.
 * However, E sometimes wants to save state and exit immediately afterwards
 * so that the SM will restart it in a different theme. Therefore, we include
 * a suicide clause at the end.
 */
static void
callback_save_yourself2(SmcConn smc_conn, SmPointer client_data __UNUSED__)
{
   if (EDebug(EDBUG_TYPE_SESSION))
      Eprintf("callback_save_yourself2\n");

   set_save_props(smc_conn, Mode.wm.master);
   SmcSaveYourselfDone(smc_conn, True);
   if (restarting)
      EExit(0);
}
コード例 #5
0
ファイル: events.c プロジェクト: Limsik/e17
static void
ExtInitShape(int available)
{
   if (available)
      return;

   AlertX(_("X server setup error"), _("OK"), NULL, NULL,
	  _("FATAL ERROR:\n" "\n"
	    "This Xserver does not support the Shape extension.\n"
	    "This is required for Enlightenment to run.\n" "\n"
	    "Your Xserver probably is too old or mis-configured.\n" "\n"
	    "Exiting.\n"));
   EExit(1);
}
コード例 #6
0
ファイル: Appfixed.c プロジェクト: wilk/VOWLAN
int main(int argc, char *argv[])
{
	uint16_t portLBfixed;
	int ris, LBfixedfd;
	pthread_t th;
	int primoricevuto=0;
	int tipogenerazionepkt;

	if(argc==1) { 
		printf ("uso i parametri di default \n%s\n", PARAMETRIDEFAULT );
		portLBfixed = 11001;
		tipogenerazionepkt=2;
	}
	else if(argc!=3) { printf ("necessari 2 parametri\n"); usage(); exit(1);  }
	else { /* leggo parametri da linea di comando */
		portLBfixed = atoi(argv[1]);
		tipogenerazionepkt=atoi(argv[2]);
	}

	if ((signal (SIGHUP, sig_close)) == SIG_ERR) { perror("signal (SIGHUP) failed: "); EExit(2); }
	if ((signal (SIGINT, sig_close)) == SIG_ERR) { perror("signal (SIGINT) failed: "); EExit(2); }
	if ((signal (SIGTERM, sig_close)) == SIG_ERR) { perror("signal (SIGTERM) failed: "); EExit(2); }

	init_random();
	ris=socketpair(AF_UNIX,SOCK_STREAM,0,fds);
	if (ris < 0) {	perror("socketpair fds0 failed: ");	EExit(1); }
	/*
	ris=SetsockoptTCPNODELAY(fds[0],1); if (!ris)  EExit(5);
	ris=SetsockoptTCPNODELAY(fds[1],1); if (!ris)  EExit(5);
	*/

	/* mi connetto al LBfixed */
	ris=TCP_setup_connection(&LBfixedfd, "127.0.0.1", portLBfixed,  300000, 300000, 1);
	if(!ris) {	printf ("TCP_setup_connection() failed\n"); EExit(1); }
	f=fopen("delayfixed.txt","wt");
	if(f==NULL) { perror("fopen failed"); EExit(1); }

	/* inizializzo il sistema di controllo dei pkt ricevuti e/o duplicati */ 
	init_checkrecvFixed();
	init_checkrecvFixedDelay();

	FD_ZERO(&all);
	FD_SET(LBfixedfd,&all);
	maxfd=LBfixedfd;
	FD_SET(fds[0],&all);
	if(maxfd<fds[0]) maxfd=fds[0];

	for(;;)
	{
		struct timeval timeout;
		long int msecdelay;

		do {
			rdset=all;
			timeout.tv_sec=10;
			timeout.tv_usec=0;
			ris=select(maxfd+1,&rdset,NULL,NULL,&timeout);
			/* ris=select(maxfd+1,&rdset,NULL,NULL,&timeout); */
		} while( (ris<0) && (errno==EINTR) );
		if(ris<0) {
			perror("select failed: ");
			EExit(1);
		}

		/* se arriva qualcosa dalla connessione TCP con LBfixed, leggo!!!! */
		if( FD_ISSET(LBfixedfd,&rdset) )
		{
			uint32_t buf[PKTSIZE], idletto; int ris;

#ifdef VICDEBUG
			fprintf(stderr,"in arrivo qualcosa dalla connessione TCP del LBfixed:\n");
#endif
			/* ris=recv(LBfixedfd,(char*)buf,PKTSIZE,MSG_DONTWAIT); */
			/* ris=Readn(LBfixedfd,(char*)buf,PKTSIZE); */
			ris=Readn(LBfixedfd,(char*)buf,sizeof(buf));
			/*if(ris!=PKTSIZE) { fprintf(stderr,"recv from LBfixed failed, received %d: ", ris); EExit(9); }*/
			if(ris!=sizeof(buf)) { fprintf(stderr,"recv from LBfixed failed, received %d: ", ris); EExit(9); }
			idletto=buf[0];
			/* printf("ricevuto pkt id %u\n",idletto); */
			msecdelay=compute_delay(buf);
			if( check_pkt_recv_at_Fixed(idletto) == 1 ) /* pacchetto duplicato */
			{
				printf("ricevuto pkt duplicato id %d delay %ld msec \n",idletto, msecdelay);
				numduplicati++;
			}
			else
			{
				/* memorizzo di avere ricevuto il pkt */
				set_pkt_recv_at_Fixed(idletto);
				SetpktrecvFixedDelay(idletto,msecdelay);
#ifdef OUTPUT_MEDIO
				printf("ricevuto pkt id %lu delay %ld msec \n",idletto, msecdelay);
#endif
				if(primoricevuto==0) {
					pkt_generator_parameters params;
					primoricevuto=1;
					idlastrecv=idletto;
					/* faccio partire il pthread pkt_generator per attivare la generazione di pacchetti */
					params.tipogenerazionepkt=tipogenerazionepkt;
					params.fd=fds[1];
					ris = pthread_create (&th, NULL, pkt_generator, (void*)&params );
					if (ris){
						printf("ERROR; return code from pthread_create() is %d\n",ris);
						EExit(-1);
					}
				}
				else if(idletto>idlastrecv) {
					idlastrecv=idletto;
				}
				if(msecdelay>150) {
					numritardi++;
					printf("%d : delay msec %ld  TEMPO SUPERATO\n", idletto, msecdelay);
				}
				else {
					numok++;
					printf("%d : delay msec %ld\n", idletto, msecdelay);
				}
				/* save_delay(f,buf); */
			}
		}
		else
		{
			if( FD_ISSET(fds[0],&rdset) )
			{
				char ch;
				/* IL BUG E' QUI: E' STATO USATO UN VETTORE DI UINT32 PER CREARE IL PACCHETTO QUANDO SI SAREBBE DOVUTO USARE UN */
				/* VETTORE DI CARATTERI (char buf[PKTSIZE]) DATO CHE : */
				/* sizeof(buf) = 400 , con uint32_t buf[PKTSIZE] */
				/* sizeof(buf) = 100 , con char buf[PKTSIZE] */
				/* ERGO LA RICEZIONE E L'INVIO DEI PACCHETTI VA FATTA CON 400 DI DIMENSIONE E NON PKTSIZE, CIOÈ 100 */
				uint32_t buf[PKTSIZE];
				struct timeval sent;

				do {
					ris=recv(fds[0],&ch,1,0);
				} while( (ris<0) && (errno==EINTR) );
				if(ris<0) {
					perror("Appfixed - recv from scheduler failed: ");
					sleep(1);
					EExit(1);
				}
				/* spedisco i pkt */
				/*memset((char*)buf,0,PKTSIZE);*/
				memset((char*)buf,0,sizeof(buf));
				buf[0]=idmsg;
				gettimeofday(&sent,NULL);
				memcpy( (char*)&(buf[1]), (char*)&sent, sizeof(struct timeval) );

				/*
					fprintf(stderr,"pkt %u sent %ld sec %ld usec\n", idmsg, sent.tv_sec, sent.tv_usec );
				*/

				/*ris=Sendn(LBfixedfd, (char*)buf, PKTSIZE  );*/
				ris=Sendn(LBfixedfd, (char*)buf, sizeof(buf) );
				/*if(ris!=PKTSIZE) {*/
				if(ris!=sizeof(buf)) {
					fprintf(stderr,"Appfixed - Sendn failed   ris %d  TERMINO\n", ris);
					sleep(1);
					EExit(1);
				}
#ifdef OUTPUT_MEDIO
				fprintf(stderr,"pkt %u sent %dB\n", idmsg, ris);
#endif
				idmsg++;

			}
		}

	} /* fine for ;; */
	return(0);
}
コード例 #7
0
ファイル: setup.c プロジェクト: burzumishi/e16
/*
 * This function sets up all of our connections to X
 */
void
SetupX(const char *dstr)
{
   int                 err;
   char                buf[128];
   unsigned int        mask;

   if (!dstr)
      dstr = getenv("DISPLAY");
   if (!dstr)
      dstr = ":0.0";

   /* Open a connection to the diplay nominated by the DISPLAY variable */
   err = EDisplayOpen(dstr, Dpy.screen);
   if (err)
     {
	Alert(_("Enlightenment cannot connect to the display nominated by\n"
		"your shell's DISPLAY environment variable. You may set this\n"
		"variable to indicate which display name Enlightenment is to\n"
		"connect to. It may be that you do not have an Xserver already\n"
		"running to serve that Display connection, or that you do not\n"
		"have permission to connect to that display. Please make sure\n"
		"all is correct before trying again. Run an Xserver by running\n"
		"xdm or startx first, or contact your local system\n"
		"administrator, or Xserver vendor, or read the X, xdm and\n"
		"startx manual pages before proceeding.\n"));
	EExit(1);
     }

   if (getenv("ESYNCHRONIZE"))
      XSynchronize(disp, True);

   Dpy.screens = ScreenCount(disp);
   Dpy.screen = DefaultScreen(disp);

   if (Mode.wm.master ||
       Mode.wm.master_screen < 0 || Mode.wm.master_screen >= Dpy.screens)
      Mode.wm.master_screen = Dpy.screen;

   /* Start up on multiple heads, if appropriate */
   if (Dpy.screens > 1 && !Mode.wm.single && !Mode.wm.restart)
     {
	int                 i;

	for (i = 0; i < Dpy.screens; i++)
	  {
	     pid_t               pid;

	     if (i == Dpy.screen)
		continue;

	     pid = fork();
	     if (pid)
	       {
		  /* We are the master */
		  Mode.wm.child_count++;
		  Mode.wm.children =
		     EREALLOC(pid_t, Mode.wm.children, Mode.wm.child_count);
		  Mode.wm.children[Mode.wm.child_count - 1] = pid;
	       }
	     else
	       {
		  /* We are a slave */
		  EDisplayDisconnect();
		  Mode.wm.master = 0;
		  Mode.wm.pid = getpid();
		  Dpy.screen = i;
		  ExtInitWinSet(NoXID);
#ifdef SIGSTOP
		  kill(getpid(), SIGSTOP);
#endif
		  EDisplayOpen(dstr, i);
		  /* Terminate the loop as I am the child process... */
		  break;
	       }
	  }
     }

   Dpy.name = Estrdup(DisplayString(disp));
   Esetenv("DISPLAY", Dpy.name);

   Dpy.pixel_black = BlackPixel(disp, Dpy.screen);
   Dpy.pixel_white = WhitePixel(disp, Dpy.screen);

   EDisplaySetErrorHandlers(EventShowError, HandleXIOError);

   /* Root defaults */
   RROOT = ERegisterWindow(DefaultRootWindow(disp), NULL);

   if (Mode.wm.window)
     {
	VROOT = ECreateWindow(RROOT, 0, 0, Mode.wm.win_w, Mode.wm.win_h, 0);

	/* Enable eesh and edox to pick up the virtual root */
	Esnprintf(buf, sizeof(buf), "%#x", WinGetXwin(VROOT));
	Esetenv("ENL_WM_ROOT", buf);
     }
   else
     {
	/* Running E normally on the root window */
	VROOT = RROOT;
     }

   Dpy.root_gc = EXCreateGC(WinGetXwin(VROOT), 0, NULL);

   /* Initialise event handling */
   EventsInit();

   /* select all the root window events to start managing */
   Dpy.last_error_code = 0;
   mask =
      StructureNotifyMask | SubstructureNotifyMask | SubstructureRedirectMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Another Window Manager is already running"),
	       _("OK"), NULL, NULL,
	       _("Another Window Manager is already running.\n" "\n"
		 "You will have to quit your current Window Manager first before\n"
		 "you can successfully run Enlightenment.\n"));
	EExit(1);
     }

   mask |= ButtonPressMask | ButtonReleaseMask;
   ESelectInput(VROOT, mask);
   ESync(0);
   if (Dpy.last_error_code)
     {
	AlertX(_("Cannot select root window button press events"),
	       _("OK"), NULL, NULL,
	       _("Root window button actions will not work.\n"));
     }

   /* warn, if necessary about X version problems */
   if (ProtocolVersion(disp) != 11)
     {
	AlertX(_("X server version error"), _("Ignore this error"), "",
	       _("Quit Enlightenment"),
	       _("WARNING:\n"
		 "This is not an X11 Xserver. It in fact talks the X%i protocol.\n"
		 "This may mean Enlightenment will either not function, or\n"
		 "function incorrectly. If it is later than X11, then your\n"
		 "server is one the author of Enlightenment neither have\n"
		 "access to, nor have heard of.\n"), ProtocolVersion(disp));
     }

   /* damn that bloody numlock stuff - ok I'd rather XFree got fixed to not */
   /* have it as a modifier and everyone have to write specific code to mask */
   /* it out - but well.... */
   /* ok under Xfree Numlock and Scollock are lock modifiers and we need */
   /* to hunt them down to mask them out - EVIL EVIL EVIL hack but needed */
   {
      XModifierKeymap    *mod;
      EX_KeyCode          nl, sl;
      unsigned int        numlock, scrollock;
      int                 i;

      int                 masks[8] = {
	 ShiftMask, LockMask, ControlMask, Mod1Mask, Mod2Mask, Mod3Mask,
	 Mod4Mask, Mod5Mask
      };

      numlock = scrollock = 0;
      mod = XGetModifierMapping(disp);
      nl = EKeysymToKeycode(XK_Num_Lock);
      sl = EKeysymToKeycode(XK_Scroll_Lock);
      if ((mod) && (mod->max_keypermod > 0))
	{
	   for (i = 0; i < (8 * mod->max_keypermod); i++)
	     {
		if ((nl) && (mod->modifiermap[i] == nl))
		   numlock = masks[i / mod->max_keypermod];
		else if ((sl) && (mod->modifiermap[i] == sl))
		   scrollock = masks[i / mod->max_keypermod];
	     }
	}
      Mode.masks.mod_combos[0] = 0;
      Mode.masks.mod_combos[1] = LockMask;
      if (numlock)
	{
	   Mode.masks.mod_combos[2] = numlock;
	   Mode.masks.mod_combos[5] = LockMask | numlock;
	}
      if (scrollock)
	{
	   Mode.masks.mod_combos[3] = scrollock;
	   Mode.masks.mod_combos[6] = LockMask | scrollock;
	}
      if (numlock && scrollock)
	{
	   Mode.masks.mod_combos[4] = numlock | scrollock;
	   Mode.masks.mod_combos[7] = LockMask | numlock | scrollock;
	}

      Mode.masks.mod_key_mask =
	 (ShiftMask | ControlMask | Mod1Mask | Mod2Mask | Mod3Mask | Mod4Mask |
	  Mod5Mask) & (~(numlock | scrollock | LockMask));

      if (mod)
	 XFreeModifiermap(mod);
   }

   ScreenInit();
}
コード例 #8
0
ファイル: Appmobile.c プロジェクト: crmne/UDPLoadBalancer
int main(int argc, char *argv[])
{
	uint16_t portLBmobile;
	int ris, LBmobilefd;
	pthread_t th;
	int primoricevuto=0;

	printf ("uso i parametri di default \n%s\n", PARAMETRIDEFAULT );
	portLBmobile = 6001;

	if ((signal (SIGHUP, sig_close)) == SIG_ERR) { perror("signal (SIGHUP) failed: "); EExit(2); }
	if ((signal (SIGINT, sig_close)) == SIG_ERR) { perror("signal (SIGINT) failed: "); EExit(2); }
	if ((signal (SIGTERM, sig_close)) == SIG_ERR) { perror("signal (SIGTERM) failed: "); EExit(2); }

	init_random();
	ris=socketpair(AF_UNIX,SOCK_STREAM,0,fds);
	if (ris < 0) {	perror("socketpair fds0 failed: ");	EExit(1); }

	/* mi connetto al LBmobile */
	ris=TCP_setup_connection(&LBmobilefd, "127.0.0.1", portLBmobile,  300000, 300000, 1);
	if(!ris) {	printf ("TCP_setup_connection() failed\n"); EExit(1); }
	f=fopen("delaymobile.txt","wt");
	if(f==NULL) { perror("fopen failed"); EExit(1); }

	FD_ZERO(&all);
	FD_SET(LBmobilefd,&all);
	maxfd=LBmobilefd;
	FD_SET(fds[0],&all);
	if(maxfd<fds[0]) maxfd=fds[0];

	ris = pthread_create (&th, NULL, scheduler, NULL );
	if (ris){
		printf("ERROR; return code from pthread_create() is %d\n",ris);
		EExit(-1);
	}

	for(;;)
	{
		struct timeval timeout;

		do {
			rdset=all;
			timeout.tv_sec=10;
			timeout.tv_usec=0;
			ris=select(maxfd+1,&rdset,NULL,NULL,&timeout);
			/* ris=select(maxfd+1,&rdset,NULL,NULL,&timeout); */
		} while( (ris<0) && (errno==EINTR) );
		if(ris<0) {
			perror("select failed: ");
			EExit(1);
		}

		/* se arriva qualcosa dalla connessione TCP con LBmobile, leggo!!!! */
		if( FD_ISSET(LBmobilefd,&rdset) )
		{
			uint32_t buf[PKTSIZE], idletto; int ris;

#ifdef VICDEBUG
			fprintf(stderr,"in arrivo qualcosa dalla connessione TCP del LBmobile:\n");
#endif
			/* ris=recv(LBmobilefd,(char*)buf,PKTSIZE,MSG_DONTWAIT); */
			ris=Readn(LBmobilefd,(char*)buf,PKTSIZE);
			if(ris!=PKTSIZE) { fprintf(stderr,"recv from LBmobile failed, received %d: ", ris); EExit(9); }
			idletto=buf[0];
			printf("ricevuto pkt id %u\n",idletto);

			if(primoricevuto==0) {
				primoricevuto=1;
				idlastrecv=idletto;
				numricevuti=1;
			} 
			else if(idletto<=idlastrecv) {
				fprintf(stderr,"ERRORE, RICEVUTO PKT FUORI ORDINE: letto %u precedente %u  - TERMINO\n",idletto, idlastrecv);
				EExit(999);
			} 
			else {
				if(idlastrecv+1 < idletto) {
					numpersi += (idletto-(idlastrecv+1));
					fprintf(stderr,"PERSO \n");
				} 
				idlastrecv=idletto;
				numricevuti++;
			}
			/* salvo delay pkt */
			save_delay(f,buf);
		}
		else
		{
			if( FD_ISSET(fds[0],&rdset) )
			{
				char ch;
				uint32_t buf[PKTSIZE];
				struct timeval sent;

				do {
					ris=recv(fds[0],&ch,1,0);
				} while( (ris<0) && (errno==EINTR) );
				if(ris<0) {
					perror("Appmobile - recv from scheduler failed: ");
					sleep(1);
					EExit(1);
				}
				/* spedisco i pkt */
				memset((char*)buf,0,PKTSIZE);
				buf[0]=idmsg;
				gettimeofday(&sent,NULL);
				memcpy( (char*)&(buf[1]), (char*)&sent, sizeof(struct timeval) );

				ris=Sendn(LBmobilefd, (char*)buf, PKTSIZE  );
				if(ris!=PKTSIZE) {
					fprintf(stderr,"Appmobile - Sendn failed   ris %d  TERMINO\n", ris);
					sleep(1);
					EExit(1);
				}
				fprintf(stderr,"pkt %u sent %dB\n", idmsg, ris);
				idmsg++;
			}
		}

	} /* fine for ;; */
	return(0);
}