[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

'utmp.h' and 'utmp'



Hi !

   While I install a BBS software called PowerBBS. I encounter a problem :
when the system compiler to a file called 'ttysrc.c' ,it told me a message
that it can't find 'utmpx.h' Oh ! My God ! I can't find this file either.

ttysrc.c
-----------------------------------------------------------------------------
#ifndef lint
static char copyright[] =
"@(#) Copyright (c) 1989, 1993\n\
        The Regents of the University of California.  All rights reserved
#endif /* not lint */

#ifndef lint
static char sccsid[] = "@(#)who.c       8.1 (Berkeley) 6/6/93";
#endif /* not lint */

#include <sys/types.h>
#include <sys/file.h>
#include <stdio.h>

#ifndef SYSV
#include <utmp.h>
#else
#include <utmpx.h>
#endif

#ifndef FREEBSD
#ifdef OSF1
#define _PATH_UTMP "/var/adm/utmp"
#define UT_NAMESIZE     32
#define UT_LINESIZE     32
#define UT_HOSTSIZE     64
#else
#ifdef SYSV
#define _PATH_UTMP "/var/adm/utmpx"
[A#define UT_NAMESIZE     32
#define UT_LINESIZE     32
#define UT_HOSTSIZE     257
#else
#define _PATH_UTMP "/etc/utmp"
#define UT_NAMESIZE     8
#define UT_LINESIZE     8
#define UT_HOSTSIZE     16
#endif
#endif
#endif

get_tty_src(site)
        char *site;
{
        register char *p;
#ifndef SYSV
        struct utmp usr;
#else
        struct utmpx usr;
#endif

        FILE *ufp;
        char *t, *rindex(), *strcpy(), *strncpy(), *ttyname();
#ifdef SUN5
        char *index();
#endif

        strcpy(site, "(UNKNOWN???)");
        if( !(ufp = fopen(_PATH_UTMP, "r")) )
          return;


        /* search through the utmp and find an entry for this tty */

        if (p = ttyname(0))
        {
                /* strip any directory component */
#ifdef RS6K
                if (t = index(p, '/'))
                        p = t + 1;
                if (t = index(p, '/'))
                        p = t + 1;
#else
#ifdef HPPA
                if (t = index(p, '/'))
                        p = t + 1;
                if (t = index(p, '/'))
                        p = t + 1;
#else
#ifndef SYSV
                if (t = rindex(p, '/'))
                        p = t + 1;
#else
                if (t = index(p, '/'))
                        p = t + 1;
                if (t = index(p, '/'))
                        p = t + 1;
#endif
#endif
#endif
                sprintf(site, "(%-.10s UNKNOWN???)", p);
                while (fread((char *)&usr, sizeof(usr), 1, ufp) == 1)
                  if (usr.ut_name && !strcmp(usr.ut_line, p))
                  {
                    if (usr.ut_host)
                        sprintf(site, "(%-.*s)", (UT_HOSTSIZE>27)?27:UT_H
                    return;
                  }
        }
        else
          strcpy(site, "(TTY UNKNOWN???)");
} 
/*end of get_tty_src*/



#ifdef SUN5
/*
        Solaris 2.4 implement index in /usr/ucb/cc
        but we don't want to use it
*/
char *index(p, c)
char *p;
char c;
{ 
  int cnt;

  while( *(p+cnt) )
  {
    if( *(p+cnt)==c )
      return(p+cnt);
    cnt++;
  }

  return((char*)NULL);
} 
/*end of index*/
#endif

-----------------------------------------------------------------------------

Can somebody tell me how to manager this problem !!

                                                          Sinerely Yours,
                                                          eddie

--
 ===========================================================================
 NCTU Applied Chemistry             |  * World Wide Web is more fantastic !
 Eddie Wednesday                    |  * JaVa and VRML are the best !
 TEL: (035) 712-121 ext. 79416      |  * Debian GNU/Linux is a good choice ! 
 E-mail: u8425023@cc.nctu.edu.tw    |  * The wonderful feeling is to have  
         eddie@bbs.ac.nctu.edu.tw   |    a SUN Station !                     
 http:// ( still under construction 8-O )     
                                                               


Reply to: