Esempio n. 1
0
  Gps::~Gps()
  {
    stop_polling();

    if (0 != pthread_mutex_destroy(&m_watch_mutex)) {
      LIBSITU_WARN("Failed to destroy watch mutex\n");
    }

    free(m_host);
    m_host = NULL;
    free(m_port);
    m_port = NULL;
  }
Esempio n. 2
0
void
init_editfns ()
{
  char *user_name;
  register unsigned char *p, *q;
  struct passwd *pw;		/* password entry for the current user */
  Lisp_Object tem;
  extern char *index ();

  /* Turn off polling so the SIGALRM won't bother getpwuid.  */
  stop_polling ();

  /* Set up system_name even when dumping.  */

  Vsystem_name = build_string (get_system_name ());
  p = XSTRING (Vsystem_name)->data;
  while (*p)
    {
      if (*p == ' ' || *p == '\t')
	*p = '-';
      p++;
    }

#ifndef CANNOT_DUMP
  /* Don't bother with this on initial start when just dumping out */
  if (!initialized)
    return;
#endif				/* not CANNOT_DUMP */

  pw = (struct passwd *) getpwuid (getuid ());
#ifndef OS2
  Vuser_real_name = build_string (pw ? pw->pw_name : "unknown");
#endif

  /* Get the effective user name, by consulting environment variables,
     or the effective uid if those are unset.  */
  user_name = (char *) getenv ("USER");
  if (!user_name)
    user_name = (char *) getenv ("LOGNAME"); /* USG equivalent */
  if (!user_name)
    {
      pw = (struct passwd *) getpwuid (geteuid ());
      user_name = pw ? pw->pw_name : "unknown";
    }
  Vuser_name = build_string (user_name);
#ifdef OS2
  Vuser_real_name = build_string (user_name);
#endif

  /* If the user name claimed in the environment vars differs from
     the real uid, use the claimed name to find the full name.  */
  tem = Fstring_equal (Vuser_name, Vuser_real_name);
  if (NULL (tem))
    pw = (struct passwd *) getpwnam (XSTRING (Vuser_name)->data);

  p = (unsigned char *) getenv("USERFULLNAME");
  if (p==0)
    p = (unsigned char *) (pw ? USER_FULL_NAME : "unknown");
  q = (unsigned char *) index (p, ',');
  Vuser_full_name = make_string (p, q ? q - p : strlen (p));

#ifdef AMPERSAND_FULL_NAME
  p = XSTRING (Vuser_full_name)->data;
  q = (unsigned char *) index (p, '&');
  /* Substitute the login name for the &, upcasing the first character.  */
  if (q)
    {
      char *r
	= (char *) alloca (strlen (p) + XSTRING (Vuser_name)->size + 1);
      bcopy (p, r, q - p);
      r[q - p] = 0;
      strcat (r, XSTRING (Vuser_real_name)->data);
      r[q - p] = UPCASE (r[q - p]);
      strcat (r, q + 1);
      Vuser_full_name = build_string (r);
    }
#endif				/* AMPERSAND_FULL_NAME */

  start_polling ();
}