Пример #1
0
void         got_login (player * p, char *str)
{
   char        *fault;
   player      *scan;

   str = trim_end (str);


   if ((fault = bad_name (str)))
   {
      writep (p, fault);
      login_prompt (p);
      return;
   }
   lower_case (str);
   sprintf (p->lower_name, str);
   if (player_load (p))
   {
      if (system_flags & TEMP_CLOSED)
	 if (!(p->residency & SU))
	 {
	    writep (p, " Sorry, we're currently closed to connections.  Try again later.\n\n");
	    p->flags |= P_LOGOUT;
	    return;
	 }
      promptp (p, "password: "******"quit"))
   {
      p->flags |= P_LOGOUT;
      return;
   }

   if (p->flags & P_RECON)
   {
      enter_arena (p, 0);
      return;
   }
   if (system_flags & NO_NEWBIES)
   {
      writep (p, " Sorry, but we're currently closed to newbies.  Try again later.\n\n");
      p->flags |= P_LOGOUT;
      return;
   }
   for (scan = p_top; scan; scan = scan->p_next)
   {
      if (!strcasecmp (str, scan->name))
      {
	 writep (p, " There is already someone on the program with that name.\n\n");
	 login_prompt (p);
	 return;
      }
   }
   strncpy (p->name, str, P_NAME_LEN);
   strncpy (p->lower_name, p->name, P_NAME_LEN);
   lower_case (p->lower_name);
   writep (p, "\n");
   writep (p, screen_one_msg.data);
   promptp (p, "[Hit <RETURN> to continue] ");

   p->func = screen_two;
   return;
}
Пример #2
0
static int  inotify_test(void)
{
	int inotify_fd;
	DIR *director_watch;
	struct dirent *de;


	inotify_fd = open_inotify_fd();
	if (inotify_fd > 0) {
		/* We will need a place to enqueue inotify events,
		   this is needed because if you do not read events
		   fast enough, you will miss them. This queue is
		   probably too small if you are monitoring something
		   like a directory with a lot of files and the directory
		   is deleted.
		*/
		queue_t q;
		q = queue_create(128);

		/* This is the watch descriptor returned for each item we are
	           watching. A real application might keep these for some use
	           in the application. This sample only makes sure that none of
	           the watch descriptors is less than 0.
	        */


		/* Watch all events (IN_ALL_EVENTS) for the directories and
	           files passed in as arguments.
	           Read the article for why you might want to alter this for
	           more efficient inotify use in your app.
	        */
		int index;
		wd = 0;
		printf("\n");
		/* for (index = 1; (index < argc) && wd >= 0); index++) { */
		/* 	wd = watch_dir(inotify_fd, argv[index], IN_ALL_EVENTS); */
		/* } */

		director_watch = opendir(WATCH_PATH);
		if (director_watch == 0)
			return;
		while((de = readdir(director_watch)) != 0) {
			if(bad_name(de->d_name))
				   continue;
			snprintf(busname, sizeof busname, "%s/%s", WATCH_PATH, de->d_name);		  

			int wd = watch_dir(inotify_fd, busname, IN_DELETE | IN_CREATE);
			if (wd > 0){
				LOG("chiplua add %s", busname);
			}
			process_inotify_events(q, inotify_fd);
		}	     
		return 0;
	}
	
	/* wd = watch_dir(inotify_fd, WATCH_PATH, IN_DELETE | IN_CREATE); */
	/* if (wd > 0) { */
	/* 	/\* Wait for events and process them until a */
	/* 	   temination condition is detected. */
	/* 	*\/ */
	/* 	process_inotify_events(q, inotify_fd); */
	/* } */
	/* printf("\nTerminating\n"); */

	/* /\* Finish up by closing the fd, destroying the queue, */
	/*    and returning a proper code. */
	/* *\/ */
	/* close_inotify_fd(inotify_fd); */
	/*queue_destroy(q); */
	
}