Back to index

glibc  2.9
Functions
logout.c File Reference
#include <errno.h>
#include <string.h>
#include <utmp.h>
#include <sys/time.h>

Go to the source code of this file.

Functions

int logout (const char *line)

Function Documentation

int logout ( const char *  line)

Definition at line 26 of file logout.c.

{
  struct utmp tmp, utbuf;
  struct utmp *ut;
  int result = 0;

  /* Tell that we want to use the UTMP file.  */
  if (utmpname (_PATH_UTMP) == -1)
    return 0;

  /* Open UTMP file.  */
  setutent ();

  /* Fill in search information.  */
#if _HAVE_UT_TYPE - 0
  tmp.ut_type = USER_PROCESS;
#endif
  strncpy (tmp.ut_line, line, sizeof tmp.ut_line);

  /* Read the record.  */
  if (getutline_r (&tmp, &utbuf, &ut) >= 0)
    {
      /* Clear information about who & from where.  */
      bzero (ut->ut_name, sizeof ut->ut_name);
#if _HAVE_UT_HOST - 0
      bzero (ut->ut_host, sizeof ut->ut_host);
#endif
#if _HAVE_UT_TV - 0
      struct timeval tv;
      __gettimeofday (&tv, NULL);
      ut->ut_tv.tv_sec = tv.tv_sec;
      ut->ut_tv.tv_usec = tv.tv_usec;
#else
      ut->ut_time = time (NULL);
#endif
#if _HAVE_UT_TYPE - 0
      ut->ut_type = DEAD_PROCESS;
#endif

      if (pututline (ut) != NULL)
       result = 1;
    }

  /* Close UTMP file.  */
  endutent ();

  return result;
}

Here is the call graph for this function: