Exemplo n.º 1
0
        public Utent GetUtLine(string line)
        {
            Utent utent = new Utent();

            utent.ut_line = line;
            return(GetUtLine(utent));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Returns the next Utent from the utmp file
        /// will throw an Exception if there is no more data
        /// </summary>
        public Utent GetUtent()
        {
            if (!this.have_opened_files)
            {
                this.OpenFile();
            }

            Utent utent = new Utent();

            utent.ut_type = (UtType)br.ReadInt16();
            // 4 Byte alignment;
            sf.Seek(2, SeekOrigin.Current);
            utent.ut_pid  = br.ReadInt32();
            utent.ut_line = Utils.CCharsToString(br.ReadChars(32));
            utent.ut_id   = Utils.CCharsToString(br.ReadChars(4));
            utent.ut_user = Utils.CCharsToString(br.ReadChars(32));
            utent.ut_host = Utils.CCharsToString(br.ReadChars(256));

            ExitStatus e = new ExitStatus();

            e.e_termination = br.ReadInt16();
            e.e_exit        = br.ReadInt16();
            utent.ut_exit   = e;

            utent.ut_session = br.ReadInt32();

            TimeVal t = new TimeVal();

            t.tv_sec    = br.ReadInt32();
            t.tv_usec   = br.ReadInt32();
            utent.ut_tv = t;

            this.NextRecord();
            return(utent);
        }
Exemplo n.º 3
0
        ///<summary>
        /// Scan forward from the current position in the utmp file for
        /// entries with ut_type of UserProcess or LoginProcess and
        /// return the first one where ut_line is the same as Ut->ut_line
        /// Will return null if no matching entry is found.
        ///</summary>
        public Utent GetUtLine(Utent Ut)
        {
            Utent utent = (Utent)null;

            while (this.MoreRecords())
            {
                utent = this.GetUtent();
                if (utent.ut_type == UtType.UserProcess ||
                    utent.ut_type == UtType.LoginProcess)
                {
                    if (utent.ut_line == Ut.ut_line)
                    {
                        break;
                    }
                }
            }
            return(utent);
        }