NAME
makezluname - Make a ZLU name with TTY name suffix
SYNOPSIS
#include <zcom/zcomsys.h>
#include <zcom/zcomcall.h> /* if compiled with ANSI C (recommended) */
char *makezluname (name)
char *name;
DESCRIPTION
Routine makezluname constructs
a ZLU name by merging the user-supplied name with
the TTY suffix. The returned name is 7 characters long plus a terminating '\0'.
This name may be provided in a call to zopen to
open or create a program ZLU with a name that is associated with
the TTY of the calling process. Note that the zopen call assigns
a label (name) to each program ZLU and does allow two program ZLUs
to be created with the same name. This allows a program to be run from
different terminals without referring to the same program ZLU.
This routine calls ttyname to
retrieve the TTY name of the current process. From the returned
TTY name, the prefix "tty" is
stripped and then appended to the user-supplied name to form a ZLU name. Note that part of the user-supplied name and TTY name may
be truncated to ensure that the returned ZLU name fits in an 8-byte
buffer.
For example, if the specified name is "MYZLU",
the following shows the returned ZLU name for different terminals.
TTY Name | Returned Name | Comment |
|---|
tty01 | MYZLU01 | Only TTY suffix is used. |
tty0p1 | MYZL0p1 | "U" is dropped to fix
TTY suffix. |
tty04p12 | MY04p12 | Maximum of 5 characters from TTY suffix. |
tty04p12i | MY4p12i | Only 5 of 6 characters from TTY suffix. |
term | MYZterm | Full TTY name is used. |
console | MYnsole | Trailing part of TTY name is used. |
The libraries libzcom_c.a and libpthread.a must be linked
into the calling program by giving the options "-lzcom_c
-lpthread" to cc(1) or ld(1).
Threads Considerations
This routine may be called from a multi-threaded application
using the POSIX (1003.1c) kernel threads API package. This routine
has the following characteristics when called by a multi-threaded
application:
cancellation
point | Thread cancellation can occur when a
thread calls this routine. |
async-cancel
unsafe | The calling thread's cancelability
type must be PTHREAD_CANCEL_DEFERRED if cancellation is enabled. |
async-signal
unsafe | It cannot be called from a signal handler. |
fork unsafe | It cannot be called by a child process
after fork(2) but before exec(2). |
See the WARNING section below for more information on using
this routine in a multi-threaded application.
PARAMETERS
name | Name to be merged with TTY suffix. |
RETURN VALUE
Routine makezluname returns
a null-terminated character string, which
consists of the user-supplied name parameter
merged with the TTY name suffix.
EXAMPLE
#include <zcom/zcomsys.h>
#include <zcom/zcomcall.h>
char *zluname; /* Returned ZLU name string */
char name[8];
zluname = makezluname (name);
FILES
/opt/acc/include/zcom/zcomsys.h | ZCOM subsystem general include file, containing
data types, data structures, constants, error codes, masks, etc.
Note that this must be the first include file before any other ZCOM
include files. |
/opt/acc/include/zcom/zcomcall.h | ZCOM routine function prototypes (requires
ANSI C compilation). |
SEE ALSO
zopen(3x), ttyname(3c)