Back to index

glibc  2.9
Functions | Variables
utmpname.c File Reference
#include <bits/libc-lock.h>
#include <stdlib.h>
#include <string.h>
#include <utmp.h>
#include "utmp-private.h"

Go to the source code of this file.

Functions

 __libc_lock_define (extern, __libc_utmp_lock attribute_hidden) int __utmpname(const char *file)

Variables

static const char default_file_name [] = _PATH_UTMP
const char * __libc_utmp_file_name = (const char *) default_file_name

Function Documentation

__libc_lock_define ( extern  ,
__libc_utmp_lock  attribute_hidden 
) const

Definition at line 35 of file utmpname.c.

{
  int result = -1;

  __libc_lock_lock (__libc_utmp_lock);

  /* Close the old file.  */
  (*__libc_utmp_jump_table->endutent) ();
  __libc_utmp_jump_table = &__libc_utmp_unknown_functions;

  if (strcmp (file, __libc_utmp_file_name) != 0)
    {
      if (strcmp (file, default_file_name) == 0)
       {
         free ((char *) __libc_utmp_file_name);

         __libc_utmp_file_name = default_file_name;
       }
      else
       {
         char *file_name = __strdup (file);
         if (file_name == NULL)
           /* Out of memory.  */
           goto done;

         if (__libc_utmp_file_name != default_file_name)
           free ((char *) __libc_utmp_file_name);

         __libc_utmp_file_name = file_name;
       }
    }

  result = 0;

done:
  __libc_lock_unlock (__libc_utmp_lock);
  return result;
}

Here is the call graph for this function:


Variable Documentation

Definition at line 32 of file utmpname.c.

const char default_file_name[] = _PATH_UTMP [static]

Definition at line 29 of file utmpname.c.