mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-07-06 03:08:31 +00:00
Add finger demo to redbean and fix regression
This change fixes a regression in unix.connect() caused by the recent addition of UNIX domain sockets. The BSD finger command has been added to third_party for fun and profit. A new demo has been added to redbean showing how a protocol as simple as finger can be implemented.
This commit is contained in:
parent
2415afab0e
commit
17cbe73411
34 changed files with 2454 additions and 29 deletions
28
libc/runtime/__utmpxname.S
Normal file
28
libc/runtime/__utmpxname.S
Normal file
|
@ -0,0 +1,28 @@
|
|||
/*-*- mode:unix-assembly; indent-tabs-mode:t; tab-width:8; coding:utf-8 -*-│
|
||||
│vi: set et ft=asm ts=8 tw=8 fenc=utf-8 :vi│
|
||||
╞══════════════════════════════════════════════════════════════════════════════╡
|
||||
│ Copyright 2022 Justine Alexandra Roberts Tunney │
|
||||
│ │
|
||||
│ Permission to use, copy, modify, and/or distribute this software for │
|
||||
│ any purpose with or without fee is hereby granted, provided that the │
|
||||
│ above copyright notice and this permission notice appear in all copies. │
|
||||
│ │
|
||||
│ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL │
|
||||
│ WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED │
|
||||
│ WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE │
|
||||
│ AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL │
|
||||
│ DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR │
|
||||
│ PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER │
|
||||
│ TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR │
|
||||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/macros.internal.h"
|
||||
|
||||
__utmpxname:
|
||||
.errno
|
||||
mov ENOTSUP(%rip),%edx
|
||||
mov %edx,(%rax)
|
||||
ret
|
||||
.endfn __utmpxname,globl
|
||||
.alias __utmpxname,utmpname
|
||||
.alias __utmpxname,utmpxname
|
47
libc/runtime/utmp.h
Normal file
47
libc/runtime/utmp.h
Normal file
|
@ -0,0 +1,47 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_UTMP_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_UTMP_H_
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#include "libc/runtime/utmpx.h"
|
||||
|
||||
#define ACCOUNTING 9
|
||||
#define UT_NAMESIZE 32
|
||||
#define UT_HOSTSIZE 256
|
||||
#define UT_LINESIZE 32
|
||||
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct lastlog {
|
||||
time_t ll_time;
|
||||
char ll_line[UT_LINESIZE];
|
||||
char ll_host[UT_HOSTSIZE];
|
||||
};
|
||||
|
||||
#define ut_time ut_tv.tv_sec
|
||||
#define ut_name ut_user
|
||||
#define ut_addr ut_addr_v6[0]
|
||||
#define utmp utmpx
|
||||
#define e_exit __e_exit
|
||||
#define e_termination __e_termination
|
||||
|
||||
int login_tty(int);
|
||||
int utmpname(const char *);
|
||||
struct utmp *getutent(void);
|
||||
struct utmp *getutid(const struct utmp *);
|
||||
struct utmp *getutline(const struct utmp *);
|
||||
struct utmp *pututline(const struct utmp *);
|
||||
void endutent(void);
|
||||
void setutent(void);
|
||||
void updwtmp(const char *, const struct utmp *);
|
||||
|
||||
#define _PATH_UTMP "/dev/null/utmp"
|
||||
#define _PATH_WTMP "/dev/null/wtmp"
|
||||
|
||||
#define UTMP_FILE _PATH_UTMP
|
||||
#define WTMP_FILE _PATH_WTMP
|
||||
#define UTMP_FILENAME _PATH_UTMP
|
||||
#define WTMP_FILENAME _PATH_WTMP
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_RUNTIME_UTMP_H_ */
|
51
libc/runtime/utmpx.h
Normal file
51
libc/runtime/utmpx.h
Normal file
|
@ -0,0 +1,51 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_UTMPX_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_UTMPX_H_
|
||||
#include "libc/calls/struct/timeval.h"
|
||||
#include "libc/calls/weirdtypes.h"
|
||||
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
||||
COSMOPOLITAN_C_START_
|
||||
|
||||
struct utmpx {
|
||||
short ut_type;
|
||||
pid_t ut_pid;
|
||||
char ut_line[32];
|
||||
char ut_id[4];
|
||||
char ut_user[32];
|
||||
char ut_host[256];
|
||||
struct {
|
||||
short __e_termination;
|
||||
short __e_exit;
|
||||
} ut_exit;
|
||||
long ut_session;
|
||||
struct timeval ut_tv;
|
||||
unsigned ut_addr_v6[4];
|
||||
char __unused[20];
|
||||
};
|
||||
|
||||
void endutxent(void);
|
||||
struct utmpx *getutxent(void);
|
||||
struct utmpx *getutxid(const struct utmpx *);
|
||||
struct utmpx *getutxline(const struct utmpx *);
|
||||
struct utmpx *pututxline(const struct utmpx *);
|
||||
void setutxent(void);
|
||||
|
||||
#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE)
|
||||
#define e_exit __e_exit
|
||||
#define e_termination __e_termination
|
||||
void updwtmpx(const char *, const struct utmpx *);
|
||||
int utmpxname(const char *);
|
||||
#endif
|
||||
|
||||
#define EMPTY 0
|
||||
#define RUN_LVL 1
|
||||
#define BOOT_TIME 2
|
||||
#define NEW_TIME 3
|
||||
#define OLD_TIME 4
|
||||
#define INIT_PROCESS 5
|
||||
#define LOGIN_PROCESS 6
|
||||
#define USER_PROCESS 7
|
||||
#define DEAD_PROCESS 8
|
||||
|
||||
COSMOPOLITAN_C_END_
|
||||
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
||||
#endif /* COSMOPOLITAN_LIBC_RUNTIME_UTMPX_H_ */
|
Loading…
Add table
Add a link
Reference in a new issue