Files
mcde/lib/McdeSys/private.h
T
lotherk cbf1edf406 MCDE dtsystemsettings: Sharing, name at the top and services beside
their details (t0158)

The pane follows the reference's shape: "Computer Name:" with the field and
Edit..., the line "Computers on your local network can access this computer
at NAME.local", then the services at the left and the chosen one at the
right -- its switch, its state and the address others use (ssh,
smb://ADDR/, ADDR:/folder, afp://ADDR/ from mcde_sys_interfaces).  The
folders shared by SMB, NFS and AFP appear under the file sharing services
(Add.../Remove), and Unlock... is unchanged.

mcde_sys_hostname_set was declared and never written; it is now: the name
must be letters, digits, '.' and '-' (checked in common.c), NetBSD writes
/etc/myname and runs hostname(1), Linux /etc/hostname and hostnamectl (else
hostname(1)).  "Edit..." runs it as root (dtsystemsettings -set-hostname
NAME in the su terminal, like the time zone and the clock).

Measured under Xvfb: the pane shows the name (kitt), the .local line, the
five services, and for "File Sharing by SMB" its state "On -- others reach
it at smb://192.168.1.116/" and the Shared Folders list with Add.../Remove
(docs/screenshots/leopard/System-Preferences-Sharing-mcde.png); selecting
another service switches the page and hides the folders (Remote Login).

Open: the reference's On column as check marks (the switch is on the detail
page), per-user rights for a folder (Samba valid users/read list/write list
and the netatalk counterpart -- McdeSys would need a struct instead of the
path list), Printer, Screen and Internet Sharing entries, AppleTalk options
under "Options...", and the change of the host name was not run as root
here (no root; it writes /etc/myname and the running name).
2026-11-14 08:37:26 +00:00

96 lines
4.7 KiB
C

/*
* private.h -- MCDE: what common.c and the backends of McdeSys share
*
* Copyright (c) 2026 The Makronix project. GNU LGPL 2.0 or later, as CDE.
*/
#ifndef _McdeSys_private_h
#define _McdeSys_private_h
#include <stddef.h>
#include <sys/types.h>
#include <Mcde/McdeSys.h>
/* the failure STATUS with its sentence for the user; returns STATUS */
int mcde_sys_fail(int status, const char *fmt, ...);
/* run ARGV (an absolute path first) and wait; MCDE_SYS_OK on exit status 0 */
int mcde_sys_run(char *const argv[]);
/* run ARGV and put what it prints (stdout, at most LEN-1 bytes) into BUF */
int mcde_sys_capture(char *const argv[], char *buf, size_t len);
/* the first of PATHS (NULL-terminated) that is an executable file, or NULL */
const char *mcde_sys_which(const char *const *paths);
/* the same, ending the child after SECONDS (tools that ask the network) */
int mcde_sys_capture_limited(char *const argv[], char *buf, size_t len,
int seconds);
/* run ARGV and write INPUT to its standard input (for chpasswd(8)) */
int mcde_sys_run_input(char *const argv[], const char *input);
/* the value after KEY on the first line of FILE that starts with it */
int mcde_sys_file_value(const char *file, const char *key, char *buf,
size_t len);
/* the backend: the fields of INFO that only the system can tell (common.c
* has filled in what POSIX gives, the backend may replace it) */
void mcde_sys_info_backend(McdeSysInfo *info);
/* the backend: Wi-Fi or not, and the network joined (net.c asks) */
McdeSysNetKind mcde_sys_if_kind(const char *name, char *ssid, size_t len);
/* net.c: an interface name that may go on a command line; the prefix
* length of a dotted netmask (-1: none) and the netmask of a prefix */
int mcde_sys_net_ifname_ok(const char *name);
int mcde_sys_net_prefix(const char *netmask);
void mcde_sys_net_mask(int prefix, char *buf, size_t len);
/* the backend: the configured settings of IFNAME, its router, Ethernet ID
* and media into CONFIG (net.c has filled in the current addresses, the MTU
* and the DNS servers in use); and writing the configured part, checked */
int mcde_sys_net_config_backend(const char *ifname,
McdeSysNetConfig *config);
int mcde_sys_net_configure_backend(const char *ifname,
const McdeSysNetConfig *config);
/* users.c: is LOGIN a member of the administrators' group */
int mcde_sys_user_is_admin(const char *login);
/* the backend: the group whose members administer the computer */
const char *mcde_sys_admin_group(void);
/* the backend: the shell a new user gets */
const char *mcde_sys_default_shell(void);
/* the backend: the arguments of process PID, each ended by a NUL, into BUF;
* how many bytes, or -1 */
int mcde_sys_process_args(pid_t pid, char *buf, size_t len);
/* the backend: 1 when PID is stopped or a zombie, 0 when it runs, -1 when
* it cannot be asked (no such process, no permission) */
int mcde_sys_process_stopped_backend(pid_t pid);
/* the backend: a file's comment (extended attribute) and its lock (the
* immutable flag); MCDE_SYS_ENOTSUP when the file system cannot */
int mcde_sys_file_comment_get_backend(const char *path, char *buf,
size_t len);
int mcde_sys_file_comment_set_backend(const char *path, const char *text);
int mcde_sys_file_locked_get_backend(const char *path, int *locked);
int mcde_sys_file_locked_set_backend(const char *path, int locked);
/* the backend: is the system's time service on, and which server; then
* switch it on or off (needs root) */
int mcde_sys_ntp_get_backend(int *on, char *server, size_t len);
int mcde_sys_ntp_set_backend(int on, const char *server);
/* the backend: the computer's name, now and at boot (rc.conf/myname on
* NetBSD, /etc/hostname and hostnamectl on Linux) */
int mcde_sys_hostname_set_backend(const char *name);
/* the backend, for share.c: where the servers keep their configuration
* (NULL: not on this system), and how an exports(5) line reads */
const char *mcde_sys_exports_file(void);
const char *mcde_sys_smb_conf(void);
const char *mcde_sys_afp_conf(void);
void mcde_sys_export_line(const char *path, char *buf, size_t len);
/* the backend: make running servers read their configuration again */
void mcde_sys_shares_reload(void);
/* netmount.c: a service of KIND found on HOST (NAME as it calls itself)
* into HOSTS, merged by host; the new count */
int mcde_sys_net_add(McdeSysNetHost *hosts, int n, size_t max,
const char *name, const char *host, int kind);
/* the backend: the mixer when no sound server runs (sound.c asks) */
int mcde_sys_mixer_get(int *percent, int *muted);
int mcde_sys_mixer_set(int percent);
int mcde_sys_mixer_mute(int muted);
/* the backend: the player of the system's own sound device, for a WAV file
* when no sound server runs (audioplay(1) on NetBSD), or NULL */
const char *mcde_sys_player(void);
#endif /* _McdeSys_private_h */