libc structures

Idio supports the passing of opaque C pointers as the C/pointer type.

Those C/pointers can be tagged with some type information which can be used for access, setting (if appropriate) and printing.

struct group

Idio supports tagged references to C struct group:

struct group
{
    char   *gr_name;
    char   *gr_passwd;
    gid_t   gr_gid;
    char  **gr_mem;
};

See also getgrgid and getgrnam.

function libc/struct-group-ref group member

in C, group->member

Param group:

struct-group

Type group:

C/pointer

Param member:

member name

Type member:

symbol

Return:

group -> member

Rtype:

varies on member

Accessing gr_mem will return a list of strings.

function libc/struct-group-as-string group
Param group:

struct-group

Type group:

C/pointer

Return:

string

Rtype:

string

struct passwd

Idio supports tagged references to C struct passwd:

struct passwd
{
    char   *pw_name;
    char   *pw_passwd;
    uid_t   pw_uid;
    gid_t   pw_gid;
    char   *pw_gecos;
    char   *pw_dir;
    char   *pw_shell;
};

See also getpwuid and getpwnam.

function libc/struct-passwd-ref passwd member

in C, passwd->member

Param passwd:

struct-passwd

Type passwd:

C/pointer

Param member:

member name

Type member:

symbol

Return:

passwd -> member

Rtype:

varies on member

function libc/struct-passwd-as-string passwd
Param passwd:

struct-passwd

Type passwd:

C/pointer

Return:

string

Rtype:

string

struct rlimit

Idio supports tagged references to C struct rlimit:

struct rlimit
{
  rlim_t               rlim_cur;
  rlim_t               rlim_max;
};

using the structure member names rlim_cur and rlim_max.

See also getrlimit and setrlimit.

function libc/struct-rlimit-ref rlimit member

in C, rlimit->member

Param rlimit:

struct-rlimit

Type rlimit:

C/pointer

Param member:

member name

Type member:

symbol

Return:

rlimit -> member

Rtype:

varies on member

function libc/struct-rlimit-set! rlimit member val

in C, rlimit->member = val

Param rlimit:

struct-rlimit

Type rlimit:

C/pointer

Param member:

member name

Type member:

symbol

Param val:

a C/ type

Type val:

varies on member

Return:

#<unspec>

The C/ types for val are libc/rlim_t.

function libc/struct-rlimit-as-string rlimit
Param rlimit:

struct-rlimit

Type rlimit:

C/pointer

Return:

string

Rtype:

string

struct-rlimit-as-string is set to be the printer for a libc/struct-rlimit.

struct rusage

Idio supports tagged references to C struct rusage:

struct rusage
{
  struct timeval       ru_utime;
  struct timeval       ru_stime;
};

using the structure member names ru_utime and ru_stime for struct-timeval structures. The other member names are not accessible due to portability concerns.

See also getrusage.

function libc/struct-rusage-ref rusage member

in C, rusage->member

Param rusage:

struct-rusage

Type rusage:

C/pointer

Param member:

member name

Type member:

symbol

Return:

rusage -> member

Rtype:

varies on member

function libc/struct-rusage-as-string rusage
Param rusage:

struct-rusage

Type rusage:

C/pointer

Return:

string

Rtype:

string

struct-rusage-as-string is set to be the printer for a libc/struct-rusage.

The code implicitly uses the underlying C code for struct-timeval-as-string.

struct stat

Idio supports tagged references to C struct stat:

struct stat
{
  dev_t                st_dev;
  ino_t                st_ino;
  nlink_t              st_nlink;
  mode_t               st_mode;
  uid_t                st_uid;
  gid_t                st_gid;
  dev_t                st_rdev;
  off_t                st_size;
  blksize_t            st_blksize;
  blkcnt_t             st_blocks;
  struct timespec      st_atim;
  struct timespec      st_mtim;
  struct timespec      st_ctim;
};

using the structure member names st_dev, st_ino etc..

In addition the pseudo-member names st_atime, st_mtime and st_ctime will access the tv_sec member of the corresponding struct-timespec members to maintain the legacy interface.

See also stat and fstat.

function libc/struct-stat-as-string stat
Param stat:

struct-stat

Type stat:

C/pointer

Return:

string

Rtype:

string

struct-stat-as-string is set to be the printer for a libc/struct-stat.

The code implicitly uses the underlying C code for struct-timeval-as-string.

function libc/struct-stat-ref stat member

in C, stat->member

Param stat:

struct-stat

Type stat:

C/pointer

Param member:

member name

Type member:

symbol

Return:

stat -> member

Rtype:

varies on member

struct statvfs

Idio supports tagged references to C struct statvfs:

struct statvfs
{
    unsigned long  f_bsize;
    unsigned long  f_frsize;
    fsblkcnt_t     f_blocks;
    fsblkcnt_t     f_bfree;
    fsblkcnt_t     f_bavail;
    fsfilcnt_t     f_files;
    fsfilcnt_t     f_ffree;
    fsfilcnt_t     f_favail;
    unsigned long  f_fsid;
    unsigned long  f_flag;
    unsigned long  f_namemax;
};

using the structure member names f_bsize, f_frsize etc..

See also statvfs and fstatvfs.

function libc/struct-statvfs-as-string statvfs
Param statvfs:

struct-statvfs

Type statvfs:

C/pointer

Return:

string

Rtype:

string

struct-statvfs-as-string is set to be the printer for a libc/struct-statvfs.

function libc/struct-statvfs-ref statvfs member

in C, statvfs->member

Param statvfs:

struct-statvfs

Type statvfs:

C/pointer

Param member:

member name

Type member:

symbol

Return:

statvfs -> member

Rtype:

varies on member

struct termios

Idio supports tagged references to C struct termios:

struct termios
{
  tcflag_t             c_iflag;
  tcflag_t             c_oflag;
  tcflag_t             c_cflag;
  tcflag_t             c_lflag;
  cc_t[]               c_cc;
  speed_t              c_ispeed;
  speed_t              c_ospeed;
};

using the structure member names c_iflag, c_oflag etc..

Note that SunOS does not define either of c_ispeed or c_ospeed and OpenBSD defines speed_t as an int.

Linux’s c_line is not supported.

See also tcgetattr and tcsetattr.

function libc/struct-termios-ref termios member

in C, termios->member

Param termios:

struct-termios

Type termios:

C/pointer

Param member:

member name

Type member:

symbol

Return:

termios -> member

Rtype:

varies on member

function libc/struct-termios-set! termios member val

in C, termios->member = val

Param termios:

struct-termios

Type termios:

C/pointer

Param member:

member name

Type member:

symbol

Param val:

a C/ type

Type val:

varies on member

Return:

#<unspec>

The C/ types for val are libc/tcflag_t, libc/speed_t and C/pointer for c_cc.

function libc/struct-termios-as-string termios
Param termios:

struct-termios

Type termios:

C/pointer

Return:

string

Rtype:

string

struct-termios-as-string is set to be the printer for a libc/struct-termios.

The c_cc member is not printed.

struct timespec

Idio supports tagged references to C struct timespec:

struct timespec
{
  time_t               tv_sec;
  long                 tv_nsec;
};

using the structure member names tv_sec and tv_nsec.

Note that tv_nsec is defined as a long due to portability issues.

function libc/struct-timespec-ref timespec member

in C, timespec->member

Param timespec:

struct-timespec

Type timespec:

C/pointer

Param member:

member name

Type member:

symbol

Return:

timespec -> member

Rtype:

varies on member

function libc/struct-timespec-set! timespec member val

in C, timespec->member = val

Param timespec:

struct-timespec

Type timespec:

C/pointer

Param member:

member name

Type member:

symbol

Param val:

a C/ type

Type val:

varies on member

Return:

#<unspec>

The C/ types for val are libc/time_t, C/long.

function libc/struct-timespec-as-string timespec
Param timespec:

struct-timespec

Type timespec:

C/pointer

Return:

string

Rtype:

string

struct-timespec-as-string is set to be the printer for a libc/struct-timespec.

The code prints the structure in a pseudo-floating point format: tv_sec.tv_nsec with the tv_nsec part formatted to 9 digits with leading 0 (zero) padding.

struct timeval

Idio supports tagged references to C struct timeval:

struct timeval
{
  time_t             tv_sec;
  suseconds_t        tv_usec;
};

using the structure member names tv_sec and tv_usec.

Note that on some systems suseconds_t may be typedef’d to a long.

See also gettimeofday.

function libc/struct-timeval-ref timeval member

in C, timeval->member

Param timeval:

struct-timeval

Type timeval:

C/pointer

Param member:

member name

Type member:

symbol

Return:

timeval -> member

Rtype:

varies on member

function libc/struct-timeval-set! timeval member val

in C, timeval->member = val

Param timeval:

struct-timeval

Type timeval:

C/pointer

Param member:

member name

Type member:

symbol

Param val:

a C/ type

Type val:

varies on member

Return:

#<unspec>

The C/ types for val are libc/time_t or libc/suseconds_t (or C/long on OpenBSD).

function libc/subtract-struct-timeval tv1 tv2

A simple function to calculate the difference between two C struct timevals

tv1 - tv2

Param tv1:

struct-timeval

Type tv1:

C/pointer

Param tv2:

struct-timeval

Type tv2:

C/pointer

Return:

struct-timeval

Rtype:

C/pointer

Raises ^system-error:

function libc/add-struct-timeval tv1 tv2

A simple function to calculate the sum of two C struct timevals

tv1 + tv2

Param tv1:

struct-timeval

Type tv1:

C/pointer

Param tv2:

struct-timeval

Type tv2:

C/pointer

Return:

struct-timeval

Rtype:

C/pointer

Raises ^system-error:

function libc/struct-timeval-as-string timeval
Param timeval:

struct-timeval

Type timeval:

C/pointer

Return:

string

Rtype:

string

struct-timeval-as-string is set to be the printer for a libc/struct-timeval.

The code prints the structure in a pseudo-floating point format: tv_sec.tv_usec with the tv_usec part formatted to 6 digits with leading 0 (zero) padding.

struct tm

Idio supports tagged references to C struct tm:

struct tm
{
  int                  tm_sec;
  int                  tm_min;
  int                  tm_hour;
  int                  tm_mday;
  int                  tm_mon;
  int                  tm_year;
  int                  tm_wday;
  int                  tm_yday;
  int                  tm_isdst;
  long int             tm_gmtoff;
  char*                tm_zone;
};

using the structure member names tm_sec, tm_min etc..

Note that SunOS does not define tm_gmtoff or tm_zone.

See also asctime, localtime, gmtime, mktime, strftime, strptime.

function libc/struct-tm-ref tm member

in C, tm->member

Param tm:

struct-tm

Type tm:

C/pointer

Param member:

member name

Type member:

symbol

Return:

tm -> member

Rtype:

varies on member

function libc/struct-tm-set! tm member val

in C, tm->member = val

Param tm:

struct-tm

Type tm:

C/pointer

Param member:

member name

Type member:

symbol

Param val:

a C/ type

Type val:

varies on member

Return:

#<unspec>

The C/ types for val are C/int, C/long and C/pointer for tm_zone.

function libc/struct-tm-as-string tm
Param tm:

struct-tm

Type tm:

C/pointer

Return:

string

Rtype:

string

struct-tm-as-string is set to be the printer for a libc/struct-tm.

struct tms

Idio supports tagged references to C struct tms:

struct tms
{
  clock_t              tms_utime;
  clock_t              tms_stime;
  clock_t              tms_cutime;
  clock_t              tms_cstime;
};

using the structure member names tms_utime, tms_stime etc..

See also times.

function libc/struct-tms-ref tms member

in C, tms->member

Param tms:

struct-tms

Type tms:

C/pointer

Param member:

member name

Type member:

symbol

Return:

tms -> member

Rtype:

varies on member

function libc/struct-tms-as-string tms
Param tms:

struct-tms

Type tms:

C/pointer

Return:

string

Rtype:

string

struct-tms-as-string is set to be the printer for a libc/struct-tms.

struct utsname

Idio supports tagged references to C struct utsname:

struct utsname
{
  char[]               sysname;
  char[]               nodename;
  char[]               release;
  char[]               version;
  char[]               machine;
  char[]               domainname;
};

using the structure member names sysname, nodename etc..

Note that domainname is only available on Linux.

See also uname and idio-uname.

function libc/struct-utsname-ref utsname member

in C, utsname->member

Param utsname:

struct-utsname

Type utsname:

C/pointer

Param member:

member name

Type member:

symbol

Return:

utsname -> member

Rtype:

varies on member

function libc/struct-utsname-as-string utsname
Param utsname:

struct-utsname

Type utsname:

C/pointer

Return:

string

Rtype:

string

struct-utsname-as-string is set to be the printer for a libc/struct-utsname.

Last built at 2024-12-21T07:10:41Z+0000 from 62cca4c (dev) for Idio 0.3.b.6