Changeset 1928


Ignore:
Timestamp:
Apr 26, 2005, 5:08:23 AM (20 years ago)
Author:
bird
Message:

Added R3 part from libc.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/emx/src/lib/misc/sysctl.c

    • Property cvs2svn:cvs-rev changed from 1.4 to 1.5
    r1927 r1928  
    4747#include <string.h>
    4848#include <stdio.h>
     49#include <limits.h>
     50#include <paths.h>
     51#include <stdio.h>
     52#include <unistd.h>
     53#include <string.h>
    4954#define _KERNEL
    5055#include <sys/sysctl.h>
     
    16051610 *
    16061611 */
    1607 int _STD(sysctl)(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
     1612static int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
    16081613{
    16091614    int     error;
     
    16481653}
    16491654
     1655int _STD(sysctl)(int *name, u_int namelen, void *oldp, size_t *oldlenp, void *newp, size_t newlen)
     1656{
     1657        if (name[0] != CTL_USER)
     1658                return (__sysctl(name, namelen, oldp, oldlenp, newp, newlen));
     1659
     1660        if (newp != NULL) {
     1661                errno = EPERM;
     1662                return (-1);
     1663        }
     1664        if (namelen != 2) {
     1665                errno = EINVAL;
     1666                return (-1);
     1667        }
     1668
     1669        switch (name[1]) {
     1670        case USER_CS_PATH:
     1671                if (oldp && *oldlenp < sizeof(_PATH_STDPATH)) {
     1672                        errno = ENOMEM;
     1673                        return -1;
     1674                }
     1675                *oldlenp = sizeof(_PATH_STDPATH);
     1676                if (oldp != NULL)
     1677                        memmove(oldp, _PATH_STDPATH, sizeof(_PATH_STDPATH));
     1678                return (0);
     1679        }
     1680
     1681        if (oldp && *oldlenp < sizeof(int)) {
     1682                errno = ENOMEM;
     1683                return (-1);
     1684        }
     1685        *oldlenp = sizeof(int);
     1686        if (oldp == NULL)
     1687                return (0);
     1688
     1689        switch (name[1]) {
     1690        case USER_BC_BASE_MAX:
     1691                *(int *)oldp = BC_BASE_MAX;
     1692                return (0);
     1693        case USER_BC_DIM_MAX:
     1694                *(int *)oldp = BC_DIM_MAX;
     1695                return (0);
     1696        case USER_BC_SCALE_MAX:
     1697                *(int *)oldp = BC_SCALE_MAX;
     1698                return (0);
     1699        case USER_BC_STRING_MAX:
     1700                *(int *)oldp = BC_STRING_MAX;
     1701                return (0);
     1702        case USER_COLL_WEIGHTS_MAX:
     1703                *(int *)oldp = COLL_WEIGHTS_MAX;
     1704                return (0);
     1705        case USER_EXPR_NEST_MAX:
     1706                *(int *)oldp = EXPR_NEST_MAX;
     1707                return (0);
     1708        case USER_LINE_MAX:
     1709                *(int *)oldp = LINE_MAX;
     1710                return (0);
     1711        case USER_RE_DUP_MAX:
     1712                *(int *)oldp = RE_DUP_MAX;
     1713                return (0);
     1714        case USER_POSIX2_VERSION:
     1715                *(int *)oldp = _POSIX2_VERSION;
     1716                return (0);
     1717        case USER_POSIX2_C_BIND:
     1718#ifdef POSIX2_C_BIND
     1719                *(int *)oldp = 1;
     1720#else
     1721                *(int *)oldp = 0;
     1722#endif
     1723                return (0);
     1724        case USER_POSIX2_C_DEV:
     1725#ifdef  POSIX2_C_DEV
     1726                *(int *)oldp = 1;
     1727#else
     1728                *(int *)oldp = 0;
     1729#endif
     1730                return (0);
     1731        case USER_POSIX2_CHAR_TERM:
     1732#ifdef  POSIX2_CHAR_TERM
     1733                *(int *)oldp = 1;
     1734#else
     1735                *(int *)oldp = 0;
     1736#endif
     1737                return (0);
     1738        case USER_POSIX2_FORT_DEV:
     1739#ifdef  POSIX2_FORT_DEV
     1740                *(int *)oldp = 1;
     1741#else
     1742                *(int *)oldp = 0;
     1743#endif
     1744                return (0);
     1745        case USER_POSIX2_FORT_RUN:
     1746#ifdef  POSIX2_FORT_RUN
     1747                *(int *)oldp = 1;
     1748#else
     1749                *(int *)oldp = 0;
     1750#endif
     1751                return (0);
     1752        case USER_POSIX2_LOCALEDEF:
     1753#ifdef  POSIX2_LOCALEDEF
     1754                *(int *)oldp = 1;
     1755#else
     1756                *(int *)oldp = 0;
     1757#endif
     1758                return (0);
     1759        case USER_POSIX2_SW_DEV:
     1760#ifdef  POSIX2_SW_DEV
     1761                *(int *)oldp = 1;
     1762#else
     1763                *(int *)oldp = 0;
     1764#endif
     1765                return (0);
     1766        case USER_POSIX2_UPE:
     1767#ifdef  POSIX2_UPE
     1768                *(int *)oldp = 1;
     1769#else
     1770                *(int *)oldp = 0;
     1771#endif
     1772                return (0);
     1773        case USER_STREAM_MAX:
     1774                *(int *)oldp = FOPEN_MAX;
     1775                return (0);
     1776        case USER_TZNAME_MAX:
     1777                *(int *)oldp = NAME_MAX;
     1778                return (0);
     1779        default:
     1780                errno = EINVAL;
     1781                return (-1);
     1782        }
     1783        /* NOTREACHED */
     1784}
Note: See TracChangeset for help on using the changeset viewer.