AST(3ast) AST(3ast)

# [NAME](#NAME)

ast - miscellaneous libast support

# [SYNOPSIS](#SYNOPSIS)

```
#include <ast.h>
char*          astconf(const char* name, const char* path, const char* value);
long           astconf_long(arg);
unsigned long  astconf_ulong(arg);
Ast_confdisc_t astconfdisc(Ast_confdisc_t new_notify);
void           astconflist(Sfio_t* stream, const char* path, int flags);
off_t          astcopy(int rfd, int wfd, off_t n);
int            astquery(int fd, const char* format , ...);
```

# [DESCRIPTION](#DESCRIPTION)

astconf is a string interface to the [*confstr*(3)](/man/os/ksh/confstr.3), [*pathconf*(2)](/man/os/ksh/pathconf.2), and [*sysconf*(3)](/man/os/ksh/sysconf.3) calls. If *value* is 0 then the configuration parameter value for *name* is returned. Some *name* configuration parameters may consult the *path* argument. In this case if *path* is 0 then **"/"** is used. Otherwise if *path* is not 0 then it must exist. The string return value for *name* remains unchanged until the next astconf call on *name*. If *value* is 0 then a valid string is always returned; **""** is returned if *name* has no configuration value. This simplifies the programming interface:

```
if (!strcmp(astconf("PATH_RESOLVE", NULL, NULL), "logical"))
	/* the logical way ... */
```

If *value* is not 0 then the configuration parameter value for *name* is set to *value*. 0 is returned if the value cannot be set. The paradigm is:

```
universe = astconf("UNIVERSE", 0, "att");
...
astconf("UNIVERSE", 0, universe);
```

The settable configuration names are:

PATH\_RESOLVE

logical if symbolic links are followed during file tree traversal, physical if symbolic links are not followed during file tree traversal, and metaphysical if symbolic links are followed at the top level during file tree traversal. These correspond to the generic -L, -P, and -H command options.

UNIVERSE

ucb for *Berkeley* style and att otherwise. This configuration parameter controls the *universe* setting on machines that support it (e.g., Pyramid). UNIVERSE also controls the behavior of some commands like [*cat*(1)](/man/os/ksh/cat.1) and [*echo*(1)](/man/os/ksh/echo.1).

User defined *name* values may also be set and queried, but these should probably have some form of vendor prefix to avoid being stomped by future standards.

astconf\_long and astconf\_ulong are macros that call either *sysconf* or astconf, preferring *sysconf* if it's available. astconf\_long returns a signed long value while astconf\_ulong returns an unsigned long value. The argument passed to these macros may be one of the following:

```
CONF_ARG_MAX
CONF_CHILD_MAX
CONF_CLK_TCK
CONF_NGROUPS_MAX
CONF_OPEN_MAX
CONF_PAGESIZE
```

astconfdisc registers a discipline function

```
int (*notify)(const char* name, const char* path, const char* value);
```

that is called just before the configuration parameter *name* is set to *value* relative to *path*. If *notify* returns 0 then the configuration parameter value is not changed.

astconflist lists the current configuration names and values of *stream*. If *path* is 0 then **"/"** is used where appropriate. If *flags* is 0 or R\_OK|W\_OK then all configuration parameters are listed. R\_OK lists the readonly configuration parameters and W\_OK lists the settable configuration parameters. X\_OK lists the settable configuration parameters in a form that can be snarfed for input to the [*getconf*(1)](/man/os/ksh/getconf.1) command.

astcopy efficiently copies up to *n* bytes from the file descriptor *rfd* to the file descriptor *wfd*. The actual number of bytes copied is returned; -1 is returned on error. If *n* is 0 then an optimal number of bytes (with respect to both *rfd* and *wfd*) is copied.

If possible [*mmap*(2)](/man/os/ksh/mmap.2) is used to do the transfer. Some implementations may bypass user buffer copies usually required by the [*read*(2)](/man/os/ksh/read.2)-[*write*(2)](/man/os/ksh/write.2) paradigm.

astquery outputs an [*sfprintf*(3)](/man/os/ksh/sfprintf.3) prompt specified by *format, ...* to the controlling terminal and reads a response from the controlling terminal. Affirmative response returns 0, EOF or quit response returns -1, otherwise 1 is returned. If *quit* is greater than 0 then *exit(quit)* is called on a quit response. The responses will eventually be locale specific.

astwinsize returns the number of rows in *\*rows* and the number of columns *\*col* for the terminal file descriptor *fd*. If the number of rows or columns cannot be determined or if *fd* is not a terminal then *\*rows* and *\*cols* are set to 0. If [*ioctl*(2)](/man/os/ksh/ioctl.2) methods fail then the environment variable LINES is used to set *\*rows* and the environment variable COLUMNS is used to set *\*cols*.

# [SEE ALSO](#SEE_ALSO)

[getconf(1)](/man/os/ksh/getconf.1), [confstr(3)](/man/os/ksh/confstr.3), [mmap(2)](/man/os/ksh/mmap.2), [pathconf(2)](/man/os/ksh/pathconf.2), [read(2)](/man/os/ksh/read.2), [sysconf(3)](/man/os/ksh/sysconf.3), [write(2)](/man/os/ksh/write.2)

---

Document: ast(3ast) from ksh 1.0.10-r37 (Chainguard OS)
Source: https://github.com/ksh93/ksh
