di-4.47/0000755000175000017500000000000013334050206010144 5ustar bllblldi-4.47/D/0000755000175000017500000000000013334050206010327 5ustar bllblldi-4.47/D/dispopts.d0000644000175000017500000000107313334050206012342 0ustar bllbll// written in the D programming language module dispopts; import std.stdio; import std.string; import config; enum real size1000 = 1000.0, size1024 = 1024.0; enum int idx1000 = 0, idx1024 = 1; struct DisplayOpts { bool posixCompat = false; real dispBlockSize = 0; real baseDispSize = size1024; int baseDispIdx = idx1024; short precision = 0; short width = 0; short inodeWidth = 0; string dbsstr = "H"; string dispBlockLabel; }; di-4.47/D/options.d0000644000175000017500000003554713334050206012205 0ustar bllbll// written in the D programming language module options; import std.string; import std.ascii : isDigit; import std.utf; import std.conv : to; private import std.process : getenv; debug (1) { import std.stdio; } version (unittest) { import std.stdio; private import std.process : setenv, unsetenv; } import config; import dihelp; import digetoptn; import dispopts; private immutable string DI_ALL_FORMAT = "MTS\n\tO\n\tbuf13\n\tbcvpa\n\tBuv2\n\tiUFP"; private immutable string DI_POSIX_FORMAT = "SbuvpM"; private immutable string DI_DEFAULT_SORT = "m"; struct Options { bool csvOutput = false; bool displayAll = false; bool localOnly = false; bool includeLoopback = false; bool printHeader = true; bool quotaCheck = true; bool displayTotal = false; bool debugHeader = false; bool unknown = false; short debugLevel = 0; string formatString = DI_DEFAULT_FORMAT; string sortType = DI_DEFAULT_SORT; string zoneDisplay; bool[string] includeList; bool[string] excludeList; } int getDIOptions (string[] args, ref Options opts, ref DisplayOpts dispOpts) { int idx; string s; if ((s = getenv ("DIFMT")) != null) { opts.formatString = s; } // gnu df if ((s = getenv ("POSIXLY_CORRECT")) != null) { dispOpts.dbsstr = "512"; opts.formatString = DI_POSIX_FORMAT; dispOpts.posixCompat = true; } // bsd df if ((s = getenv ("BLOCKSIZE")) != null) { dispOpts.dbsstr = s; } // gnu df if ((s = getenv ("DF_BLOCK_SIZE")) != null) { dispOpts.dbsstr = s; } if ((s = getenv ("DI_ARGS")) != null) { processOpts (s, opts, dispOpts); } idx = processOpts (args, opts, dispOpts); return idx; } unittest { bool fail; int failures; int tcount; Options opts; DisplayOpts dispOpts; unsetenv ("DI_ARGS"); unsetenv ("BLOCKSIZE"); unsetenv ("DF_BLOCK_SIZE"); unsetenv ("POSIXLY_CORRECT"); ++tcount; fail = false; opts = opts.init; setenv ("DIFMT", "SMT", true); getDIOptions ([""], opts, dispOpts); if (opts.formatString != "SMT") { fail = true; } if (fail) { ++failures; writefln ("# %s: fail: %s", "getDIOptions:", "Env: DIFMT"); writefln (" expected: %s got %s", "SMT", opts.formatString); } unsetenv ("DIFMT"); ++tcount; fail = false; opts = opts.init; setenv ("POSIXLY_CORRECT", " ", true); getDIOptions ([""], opts, dispOpts); if (dispOpts.dbsstr != "512") { fail = true; } if (opts.formatString != DI_POSIX_FORMAT) { fail = true; } if (dispOpts.posixCompat != true) { fail = true; } if (fail) { ++failures; writefln ("# %s: fail: %s", "getDIOptions:", "Env: POSIXLY_CORRECT"); writefln (" expected: %s got %s", "512", dispOpts.dbsstr); writefln (" expected: %s got %s", DI_POSIX_FORMAT, opts.formatString); writefln (" expected: %s got %s", true, dispOpts.posixCompat); } unsetenv ("POSIXLY_CORRECT"); ++tcount; fail = false; opts = opts.init; setenv ("DF_BLOCK_SIZE", "kB", true); getDIOptions ([""], opts, dispOpts); if (dispOpts.dbsstr != "kB") { fail = true; } if (fail) { ++failures; writefln ("# %s: fail: %s", "getDIOptions:", "Env: DF_BLOCK_SIZE"); writefln (" expected: %s got %s", "kB", dispOpts.dbsstr); } unsetenv ("DF_BLOCK_SIZE"); ++tcount; fail = false; opts = opts.init; setenv ("BLOCKSIZE", "kB", true); getDIOptions ([""], opts, dispOpts); if (dispOpts.dbsstr != "kB") { fail = true; } if (fail) { ++failures; writefln ("# %s: fail: %s", "getDIOptions:", "Env: BLOCKSIZE"); writefln (" expected: %s got %s", "kB", dispOpts.dbsstr); } unsetenv ("BLOCKSIZE"); if (failures > 0) { write ("unittest: options: getDIOptions: "); writefln ("failed: %d of %d", failures, tcount); } } private: int processOpts (string str, ref Options opts, ref DisplayOpts dispOpts) { return processOpts (["dummy"] ~ split(strip(str)), opts, dispOpts); } int processOpts (string[] args, ref Options opts, ref DisplayOpts dispOpts) { int idx; OptInfo[string] options; with (opts) { auto delA = delegate (string arg, string val) { formatString = DI_ALL_FORMAT; }; auto delB = delegate (string arg, string val) { processBaseSize (val, dispOpts); }; auto delg = delegate (string arg, string val) { dispOpts.dbsstr = "g"; }; auto delh = delegate (string arg, string val) { dispOpts.dbsstr = "h"; }; auto delH = delegate (string arg, string val) { dispOpts.dbsstr = "H"; }; auto delhelp = delegate (string arg, string val) { usage(); exit (0); }; auto delI = delegate (string arg, string val) { processIncludeList (val, opts); }; auto delk = delegate (string arg, string val) { dispOpts.dbsstr = "k"; }; auto delm = delegate (string arg, string val) { dispOpts.dbsstr = "m"; }; auto delP = delegate (string arg, string val) { if (dispOpts.dbsstr != "k") { dispOpts.dbsstr = "512"; } formatString = DI_POSIX_FORMAT; dispOpts.posixCompat = true; }; auto dels = delegate (string arg, string val) { sortType = processSort (val); }; auto delsi = delegate (string arg, string val) { dispOpts.baseDispSize = size1000; dispOpts.baseDispIdx = idx1000; dispOpts.dbsstr = "H"; }; auto delversion = delegate (string arg, string val) { dispVersion(); exit (0); }; auto delx = delegate (string arg, string val) { processExcludeList (val, opts); }; auto delZ = delegate (string arg, string val) { zoneDisplay = "all"; }; goinit (options, "-A", GETOPTN_FUNC_NOARG, cast(void *) null, delA); goinit (options, "-a", GETOPTN_BOOL, cast(void *) &displayAll, null); goinit (options, "--all", GETOPTN_ALIAS, cast(void *) &"-a", null); goinit (options, "-b", GETOPTN_ALIAS, cast(void *) &"-B", null ); goinit (options, "--block-size", GETOPTN_ALIAS, cast(void *) &"-B", null ); goinit (options, "-B", GETOPTN_FUNC_ARG, cast(void *) null, delB ); goinit (options, "-c", GETOPTN_BOOL, cast(void *) &csvOutput, null ); goinit (options, "--csv-output", GETOPTN_ALIAS, cast(void *) &"-c", null ); goinit (options, "-d", GETOPTN_STRING, cast(void *) &dispOpts.dbsstr, null ); goinit (options, "-f", GETOPTN_STRING, cast(void *) &formatString, null ); goinit (options, "--format-string", GETOPTN_ALIAS, cast(void *) &"-f", null ); goinit (options, "-F", GETOPTN_ALIAS, cast(void *) &"-I", null ); goinit (options, "-g", GETOPTN_FUNC_NOARG, cast(void *) null, delg ); goinit (options, "-h", GETOPTN_FUNC_NOARG, cast(void *) null, delh ); goinit (options, "-H", GETOPTN_FUNC_NOARG, cast(void *) null, delH ); goinit (options, "--help", GETOPTN_FUNC_NOARG, cast(void *) null, delhelp ); goinit (options, "--human-readable", GETOPTN_ALIAS, cast(void *) &"-H", null ); goinit (options, "-?", GETOPTN_ALIAS, cast(void *) &"--help", null ); goinit (options, "-i", GETOPTN_ALIAS, cast(void *) &"-x", null ); goinit (options, "-I", GETOPTN_FUNC_ARG, cast(void *) null, delI ); goinit (options, "--inodes", GETOPTN_IGNORE, cast(void *) null, null ); goinit (options, "-k", GETOPTN_FUNC_NOARG, cast(void *) null, delk ); goinit (options, "-l", GETOPTN_BOOL, cast(void *) &localOnly, null ); goinit (options, "--local", GETOPTN_ALIAS, cast(void *) &"-l", null ); goinit (options, "-L", GETOPTN_BOOL, cast(void *) &includeLoopback, null ); goinit (options, "-m", GETOPTN_FUNC_NOARG, cast(void *) null, delm ); goinit (options, "-n", GETOPTN_BOOL, cast(void *) &printHeader, null ); goinit (options, "--no-sync", GETOPTN_IGNORE, cast(void *) null, null ); goinit (options, "-P", GETOPTN_FUNC_NOARG, cast(void *) null, delP ); goinit (options, "--portability", GETOPTN_ALIAS, cast(void *) &"-P", null ); goinit (options, "--print-type", GETOPTN_IGNORE, cast(void *) null, null ); goinit (options, "-q", GETOPTN_BOOL, cast(void *) "aCheck, null ); goinit (options, "-s", GETOPTN_FUNC_ARG, cast(void *) null, dels ); goinit (options, "--si", GETOPTN_FUNC_NOARG, cast(void *) null, delsi ); goinit (options, "--sync", GETOPTN_IGNORE, cast(void *) null, null ); goinit (options, "-t", GETOPTN_BOOL, cast(void *) &displayTotal, null ); goinit (options, "--total", GETOPTN_ALIAS, cast(void *) &"-t", null ); goinit (options, "--type", GETOPTN_ALIAS, cast(void *) &"-I", null ); goinit (options, "-v", GETOPTN_IGNORE, cast(void *) null, null ); goinit (options, "--version", GETOPTN_FUNC_NOARG, cast(void *) null, delversion ); goinit (options, "-w", GETOPTN_SHORT, cast(void *) &dispOpts.width, null ); goinit (options, "-W", GETOPTN_SHORT, cast(void *) &dispOpts.inodeWidth, null ); goinit (options, "-x", GETOPTN_FUNC_ARG, cast(void *) null, delx ); goinit (options, "--exclude-type", GETOPTN_ALIAS, cast(void *) &"-x", null ); goinit (options, "-X", GETOPTN_SHORT, cast(void *) &debugLevel, null ); goinit (options, "-z", GETOPTN_STRING, cast(void *) &zoneDisplay, null ); goinit (options, "-Z", GETOPTN_FUNC_NOARG, cast(void *) null, delZ ); idx = getoptn (GETOPTN_LEGACY, args, options); } return idx; } version (unittest) { mixin template MoptionsTest(T) { void test (string l, bool expected, string o, ref T var, T rv, int ri) { int i; bool fail; ++tcount; opts = opts.init; i = processOpts (o, opts, dispOpts); //writeln ("### OA:i:", i, ":ri:", ri); //writeln ("### OA:var:", var, ":rv:", rv); if (var != rv) { fail = true; } if (i != ri) { fail = true; } if (fail) { ++failures; writefln ("# %s: fail: %s", "processOpts:", l); writefln (" expected: %s got %s", rv, var); writefln (" expected: %s got %s", ri, i); } } } } unittest { int failures; int tcount; Options opts; DisplayOpts dispOpts; string s; mixin MoptionsTest!bool tbool; mixin MoptionsTest!string tstr; mixin MoptionsTest!real treal; mixin MoptionsTest!short tshort; mixin MoptionsTest!(bool[string]) tbaa; with (opts) { tbool.test ("-a: displayAll", true, "-a", displayAll, true, 2); tstr.test ("-d k: dispOpts.dbsstr", true, "-d k", dispOpts.dbsstr, "k", 3); tstr.test ("-k: dispOpts.dbsstr", true, "-k", dispOpts.dbsstr, "k", 2); tstr.test ("-d g: dispOpts.dbsstr", true, "-d g", dispOpts.dbsstr, "g", 3); tstr.test ("-g: dispOpts.dbsstr", true, "-g", dispOpts.dbsstr, "g", 2); tstr.test ("-d m: dispOpts.dbsstr", true, "-d m", dispOpts.dbsstr, "m", 3); tstr.test ("-m: dispOpts.dbsstr", true, "-m", dispOpts.dbsstr, "m", 2); tstr.test ("-d h: dispOpts.dbsstr", true, "-d h", dispOpts.dbsstr, "h", 3); tstr.test ("-h: dispOpts.dbsstr", true, "-h", dispOpts.dbsstr, "h", 2); tstr.test ("-d H: dispOpts.dbsstr", true, "-d H", dispOpts.dbsstr, "H", 3); tstr.test ("-H: dispOpts.dbsstr", true, "-H", dispOpts.dbsstr, "H", 2); tstr.test ("-A: formatString", true, "-A", formatString, DI_ALL_FORMAT, 2); treal.test ("-b 1000: dispOpts.baseDispSize", true, "-b 1000", dispOpts.baseDispSize, 1000.0, 3); treal.test ("-b 1024: dispOpts.baseDispSize", true, "-b 1024", dispOpts.baseDispSize, 1024.0, 3); treal.test ("-b d: dispOpts.baseDispSize", true, "-b d", dispOpts.baseDispSize, 1000.0, 3); treal.test ("-b k: dispOpts.baseDispSize", true, "-b k", dispOpts.baseDispSize, 1024.0, 3); tstr.test ("-f: formatString", true, "-f SMbuvpT", formatString, "SMbuvpT", 3); tbaa.test ("-I nfs: includeList", true, "-I nfs", includeList, ["nfs":true], 3); tbaa.test ("-I nfs,jfs: includeList", true, "-I nfs,jfs", includeList, ["nfs":true,"jfs":true], 3); tbaa.test ("-I nfs -I jfs: includeList", true, "-I nfs -I jfs", includeList, ["nfs":true,"jfs":true], 5); tbool.test ("-l: localOnly", true, "-l", localOnly, true, 2); tbool.test ("-L: includeLoopback", true, "-L", includeLoopback, true, 2); tbool.test ("-n: printHeader", true, "-n", printHeader, false, 2); tstr.test ("-P: dispOpts.dbsstr", true, "-P", dispOpts.dbsstr, "512", 2); tbool.test ("-P: dispOpts.posixCompat", true, "-P", dispOpts.posixCompat, true, 2); tstr.test ("-P: formatString", true, "-P", formatString, DI_POSIX_FORMAT, 2); tstr.test ("-P -k: dispOpts.dbsstr", true, "-P -k", dispOpts.dbsstr, "k", 3); tstr.test ("-k -P: dispOpts.dbsstr", true, "-k -P", dispOpts.dbsstr, "k", 3); tbool.test ("-q: quotaCheck", true, "-q", quotaCheck, false, 2); tstr.test ("-s r: sortType", true, "-s r", sortType, "rm", 3); tstr.test ("-s t: sortType", true, "-s t", sortType, "tm", 3); tstr.test ("-s trsrm: sortType", true, "-s trsrm", sortType, "trsrm", 3); tbool.test ("-t: displayTotal", true, "-t", displayTotal, true, 2); tshort.test ("-w 12: dispOpts.width", true, "-w 12", dispOpts.width, 12, 3); tshort.test ("-W 12: dispOpts.inodeWidth", true, "-W 12", dispOpts.width, 12, 3); tbaa.test ("-x nfs: excludeList", true, "-x nfs", excludeList, ["nfs":true], 3); tbaa.test ("-x nfs,jfs: excludeList", true, "-x nfs,jfs", excludeList, ["nfs":true,"jfs":true], 3); tbaa.test ("-x nfs -x jfs: excludeList", true, "-x nfs -x jfs", excludeList, ["nfs":true,"jfs":true], 5); tstr.test ("-z some: zoneDisplay", true, "-z some", zoneDisplay, "some", 3); tstr.test ("-Z: zoneDisplay", true, "-Z", zoneDisplay, "all", 2); tshort.test ("-X 4: debugLevel", true, "-X 4", debugLevel, 4, 3); } if (failures > 0) { write ("unittest: options: processOpts: "); writefln ("failed: %d of %d", failures, tcount); } } void processBaseSize (string arg, ref DisplayOpts dispOpts) { size_t i = 0; dchar c; with (dispOpts) { c = decode (arg, i); if (isDigit (c)) { baseDispSize = to!(typeof(baseDispSize))(arg); baseDispIdx = idx1000; // unknown, really if (baseDispSize == 1024.0) { baseDispIdx = idx1024; } } else if (arg == "k") { baseDispSize = size1024; baseDispIdx = idx1024; } else if (arg == "d" || arg == "si") { baseDispSize = size1000; baseDispIdx = idx1000; } } } string processSort (string arg) { string sortType; sortType = arg; if (arg == "r") { // backwards compatibility sortType = "rm"; } if (arg == "t") { // add some additional sorting... sortType = "tm"; } return sortType; } void processIncludeList (string arg, ref Options opts) { foreach (str; split (arg, ",")) { opts.includeList[str] = true; } } void processExcludeList (string arg, ref Options opts) { foreach (str; split (arg, ",")) { opts.excludeList[str] = true; } } di-4.47/D/diquota.d0000644000175000017500000003702613334050206012152 0ustar bllbll// written in the D programming language module diquota; import std.stdio; import std.string; private import std.process : geteuid, getegid; private import core.stdc.errno; import config; import options; import diskpart; struct diQuota_t { string special; string name; string fsType; Uid_t uid; Gid_t gid; real limit; real used; real ilimit; real iused; } static if (_cdefine_BLOCK_SIZE) { alias BLOCK_SIZE DI_QUOT_BLOCK_SIZE; /* linux */ } else static if (_cdefine_DQBSIZE) { alias DQBSIZE DI_QUOT_BLOCK_SIZE; /* aix */ } else static if (_cdefine_DEV_BSIZE) { alias DEV_BSIZE DI_QUOT_BLOCK_SIZE; /* tru64, et. al. */ } else { enum size_t DI_QUOT_BLOCK_SIZE = 512; } /* rename certain structure members for portability */ static if (_cmem_dqblk_dqb_fsoftlimit) { alias dqb_fsoftlimit dqb_isoftlimit; } static if (_cmem_dqblk_dqb_fhardlimit) { alias dqb_fhardlimit dqb_ihardlimit; } static if (_cmem_dqblk_dqb_curfiles) { alias dqb_curfiles dqb_curinodes; } void checkDiskQuotas (ref DiskPartitions dps, Options opts) { int i; Uid_t uid; Gid_t gid; diQuota_t diqinfo; real tsize; uid = 0; gid = 0; static if (_has_std_quotas) { uid = geteuid (); gid = getegid (); } foreach (ref dp; dps.diskPartitions) { // if (! dp.doPrint) { // continue; // } diqinfo.uid = uid; diqinfo.gid = gid; diqinfo.name = dp.name; diqinfo.special = dp.special; diqinfo.fsType = dp.fsType; diquota (&diqinfo, opts); if (opts.debugLevel > 2) { writefln ("quota: %s limit: %f", dp.name, diqinfo.limit); writefln ("quota: tot: %f", dp.totalBlocks); writefln ("quota: %s used: %f", dp.name, diqinfo.used); writefln ("quota: avail: %f", dp.availBlocks); } if (diqinfo.limit != 0 && diqinfo.limit < dp.totalBlocks) { dp.totalBlocks = diqinfo.limit; tsize = diqinfo.limit - diqinfo.used; if (tsize < 0) { tsize = 0; } if (tsize < dp.availBlocks) { dp.availBlocks = tsize; dp.freeBlocks = tsize; if (opts.debugLevel > 2) { writefln ("quota: using quota for: total free avail"); } } else if (tsize > dp.availBlocks && tsize < dp.freeBlocks) { dp.freeBlocks = tsize; if (opts.debugLevel > 2) { writefln ("quota: using quota for: total free"); } } else { if (opts.debugLevel > 2) { writefln ("quota: using quota for: total"); } } } if (diqinfo.ilimit != 0 && diqinfo.ilimit < dp.totalInodes) { dp.totalInodes = diqinfo.ilimit; tsize = diqinfo.ilimit - diqinfo.iused; if (tsize < 0) { tsize = 0; } if (tsize < dp.availInodes) { dp.availInodes = tsize; dp.freeInodes = tsize; if (opts.debugLevel > 2) { writefln ("quota: using quota for inodes: total free avail"); } } else if (tsize > dp.availInodes && tsize < dp.freeInodes) { dp.freeInodes = tsize; if (opts.debugLevel > 2) { writefln ("quota: using quota for inodes: total free"); } } else { if (opts.debugLevel > 2) { writefln ("quota: using quota for inodes: total"); } } } } return; } void diquota (diQuota_t *diqinfo, Options opts) { int rc; int xfsflag; static if (_cstruct_dqblk) { C_ST_dqblk qinfo; char *qiptr; } static if (_cstruct_fs_disk_quota) { C_ST_fs_disk_quota xfsqinfo; } static if (_has_std_quotas) { int ucmd; int gcmd; } if (opts.debugLevel > 5) { writefln ("quota: diquota %s %s ", diqinfo.name, diqinfo.fsType); } rc = -1; xfsflag = FALSE; diqinfo.limit = 0; diqinfo.used = 0; diqinfo.ilimit = 0; diqinfo.iused = 0; if (diqinfo.fsType.length >= 3 && diqinfo.fsType[0..3] == "nfs" && diqinfo.fsType != "nfsd") { if (opts.debugLevel > 5) { writefln ("quota: diquota: nfs"); } static if (_has_std_nfs_quotas) { diquota_nfs (diqinfo, opts); } return; } if (diqinfo.fsType == "xfs") { if (opts.debugLevel > 5) { writefln ("quota: diquota: xfs"); } static if (_hdr_linux_dqblk_xfs) { ucmd = C_MACRO_QCMD (Q_XGETQUOTA, USRQUOTA); gcmd = C_MACRO_QCMD (Q_XGETQUOTA, GRPQUOTA); qiptr = cast(char *) &xfsqinfo; xfsflag = TRUE; } ; } else { static if (_has_std_quotas) { /* hp-ux doesn't have QCMD */ ucmd = Q_GETQUOTA; gcmd = Q_GETQUOTA; } static if (_cmacro_QCMD) { ucmd = C_MACRO_QCMD (Q_GETQUOTA, USRQUOTA); gcmd = C_MACRO_QCMD (Q_GETQUOTA, GRPQUOTA); } static if (_cstruct_dqblk) { qiptr = cast(char *) &qinfo; } } static if (_cdefine___FreeBSD__ && _t_FreeBSD__ == 5) { /* quotactl on devfs fs panics the system (FreeBSD 5.1) */ if (strcmp (diqinfo.fsType, "ufs") != 0) { return; } } if (opts.debugLevel > 5) { writefln ("quota: quotactl on %s (%s)", diqinfo.name, _c_arg_1_quotactl); } static if (_clib_quotactl && _c_arg_1_quotactl == "char *") { rc = quotactl (toStringz(diqinfo.name), ucmd, cast(int) diqinfo.uid, cast(caddr_t) qiptr); } static if (_clib_quotactl && _c_arg_2_quotactl == "char *") { /* AIX has linux compatibility routine, but still need name */ static if (_cdefine__AIX) { rc = quotactl (ucmd, toStringz(diqinfo.name), cast(int) diqinfo.uid, cast(caddr_t) qiptr); } else { rc = quotactl (ucmd, toStringz(diqinfo.special), cast(int) diqinfo.uid, cast(caddr_t) qiptr); } } static if (_sys_fs_ufs_quota) { /* Solaris */ { int fd; C_ST_quotctl qop; char tname [DI_NAME_LEN]; qop.op = Q_GETQUOTA; qop.uid = diqinfo.uid; qop.addr = cast(caddr_t) qiptr; strcpy (tname, diqinfo.name); strcat (tname, "/quotas"); fd = open (tname, O_RDONLY | O_NOCTTY); if (fd >= 0) { rc = ioctl (fd, Q_QUOTACTL, &qop); close (fd); } else { rc = fd; } } } /* _sys_fs_ufs_quota */ if (opts.debugLevel > 5) { writefln ("quota: quotactl on %s : rc %d : errno %d", diqinfo.name, rc, errno); } static if (_has_std_quotas) { di_process_quotas ("usr", diqinfo, rc, xfsflag, qiptr, opts); static if (_cdefine_GRPQUOTA) { if (rc == 0 || errno != ESRCH) { static if (_clib_quotactl && _c_arg_1_quotactl == "char *") { rc = quotactl (toStringz(diqinfo.name), gcmd, cast(int) diqinfo.gid, cast(caddr_t) qiptr); } static if (_clib_quotactl && _c_arg_1_quotactl != "char *") { rc = quotactl (gcmd, toStringz(diqinfo.special), cast(int) diqinfo.gid, cast(caddr_t) qiptr); } di_process_quotas ("grp", diqinfo, rc, xfsflag, qiptr, opts); } } /* _cdefine_GRPQUOTA */ } /* _has_std_quotas */ } static if (_has_std_nfs_quotas) { static if (_cdefine_RQ_PATHLEN) { alias RQ_PATHLEN DI_RQ_PATHLEN; } else { enum int DI_RQ_PATHLEN = 1024; } extern (C) { static C_TYP_bool_t xdr_quota_get (XDR *xp, C_ST_getquota_args *args) { if (! xdr_string (xp, &args.gqa_pathp, DI_RQ_PATHLEN)) { return 0; } if (! xdr_gqa_uid (xp, &args.gqa_uid)) { return 0; } return 1; } static C_TYP_bool_t xdr_quota_rslt (XDR *xp, C_ST_getquota_rslt *rslt) { C_ENUM_gqr_status quotastat; int intquotastat; C_ST_rquota *rptr; if (! xdr_int (xp, &intquotastat)) { return 0; } quotastat = cast(C_ENUM_gqr_status) intquotastat; static if (_cmem_getquota_rslt_gqr_status) { rslt.gqr_status = quotastat; } else { rslt.status = quotastat; } rptr = &rslt.gqr_rquota; if (! xdr_int (xp, &rptr.rq_bsize)) { return 0; } if (! xdr_bool (xp, &rptr.rq_active)) { return 0; } if (! xdr_rq_bhardlimit (xp, &rptr.rq_bhardlimit)) { return 0; } if (! xdr_rq_bsoftlimit (xp, &rptr.rq_bsoftlimit)) { return 0; } if (! xdr_rq_curblocks (xp, &rptr.rq_curblocks)) { return 0; } if (! xdr_rq_fhardlimit (xp, &rptr.rq_fhardlimit)) { return 0; } if (! xdr_rq_fsoftlimit (xp, &rptr.rq_fsoftlimit)) { return 0; } if (! xdr_rq_curfiles (xp, &rptr.rq_curfiles)) { return 0; } return (1); } } /* extern (C) */ static void diquota_nfs (diQuota_t *diqinfo, Options opts) { C_ST_CLIENT *rqclnt; C_ENUM_clnt_stat clnt_stat; C_ST_timeval timeout; string host; string path; char[] hostz; char[] pathz; C_ST_getquota_args args; C_ST_getquota_rslt result; C_ST_rquota *rptr; int quotastat; real tsize; if (opts.debugLevel > 5) { writefln ("quota: diquota_nfs"); } timeout.tv_sec = 2; timeout.tv_usec = 0; host = diqinfo.special; path = host; hostz = host.dup; auto idx = indexOf (host, ':'); if (idx != -1) { hostz[idx] = '\0'; ++idx; path = host[idx..$]; } pathz = path.dup; pathz ~= '\0'; if (opts.debugLevel > 5) { writefln ("quota: nfs: host: %s path: %s", host, path); writefln ("quota: nfs: hostz: %s pathz: %s", hostz, pathz); } args.gqa_pathp = pathz.ptr; args.gqa_uid = cast(C_TYP_gqa_uid) diqinfo.uid; rqclnt = clnt_create (hostz.ptr, cast(C_TYP_u_long) RQUOTAPROG, cast(C_TYP_u_long) RQUOTAVERS, toStringz("udp")); if (rqclnt == cast(CLIENT *) null) { if (opts.debugLevel > 2) { writefln ("quota: nfs: create failed %d", errno); } return; } rqclnt.cl_auth = authunix_create_default(); clnt_stat = C_MACRO_clnt_call (rqclnt, cast(C_TYP_u_long) RQUOTAPROC_GETQUOTA, cast(xdrproc_t) &xdr_quota_get, cast(caddr_t) &args, cast(xdrproc_t) &xdr_quota_rslt, cast(caddr_t) &result, timeout); if (clnt_stat != C_ENUM_clnt_stat.RPC_SUCCESS) { if (opts.debugLevel > 2) { writefln ("quota: nfs: not success: %d", cast(int) clnt_stat); } if (rqclnt.cl_auth) { C_MACRO_auth_destroy (rqclnt.cl_auth); } C_MACRO_clnt_destroy (rqclnt); return; } static if (_cmem_getquota_rslt_gqr_status) { quotastat = result.gqr_status; } else { quotastat = result.status; } if (quotastat == 1) { rptr = &result.gqr_rquota; if (opts.debugLevel > 2) { writefln ("quota: nfs: status 1"); writefln ("quota: nfs: rq_bsize: %d", rptr.rq_bsize); writefln ("quota: nfs: rq_active: %d", rptr.rq_active); } diqinfo.limit = rptr.rq_bhardlimit * rptr.rq_bsize; tsize = rptr.rq_bsoftlimit * rptr.rq_bsize; if (tsize != 0 && tsize < diqinfo.limit) { diqinfo.limit = tsize; } if (diqinfo.limit != 0) { diqinfo.used = rptr.rq_curblocks * rptr.rq_bsize; } diqinfo.ilimit = rptr.rq_fhardlimit; tsize = rptr.rq_fsoftlimit; if (tsize != 0 && tsize < diqinfo.ilimit) { diqinfo.ilimit = tsize; } if (diqinfo.ilimit != 0) { diqinfo.iused = rptr.rq_curfiles; } } if (rqclnt.cl_auth) { C_MACRO_auth_destroy (rqclnt.cl_auth); } C_MACRO_clnt_destroy (rqclnt); } } /* have rpc headers */ static if (_has_std_quotas) { static void di_process_quotas (string tag, diQuota_t *diqinfo, int rc, int xfsflag, char *cqinfo, Options opts) { real quotBlockSize = DI_QUOT_BLOCK_SIZE; real tsize; real tlimit; C_ST_dqblk *qinfo; static if (_cstruct_fs_disk_quota) { C_ST_fs_disk_quota *xfsqinfo; } if (opts.debugLevel > 5) { writefln ("quota: di_process_quotas"); } qinfo = cast(C_ST_dqblk *) cqinfo; if (xfsflag) { static if (_cstruct_fs_disk_quota) { xfsqinfo = cast(C_ST_fs_disk_quota *) cqinfo; } quotBlockSize = 512; } if (rc == 0) { tlimit = 0; if (xfsflag) { static if (_cstruct_fs_disk_quota) { tsize = xfsqinfo.d_blk_hardlimit; } ; } else { tsize = qinfo.dqb_bhardlimit; } if (opts.debugLevel > 2) { writefln ("quota: %s %s orig hard: %f", tag, diqinfo.name, tsize); } // OLD: tsize = tsize * quotBlockSize / diqinfo.blockSize; if (tsize != 0 && (tsize < diqinfo.limit || diqinfo.limit == 0)) { diqinfo.limit = tsize; tlimit = tsize; } if (xfsflag) { static if (_cstruct_fs_disk_quota) { tsize = xfsqinfo.d_blk_softlimit; } ; } else { tsize = qinfo.dqb_bsoftlimit; } if (opts.debugLevel > 2) { writefln ("quota: %s %s orig soft: %f", tag, diqinfo.name, tsize); } // OLD: tsize = tsize * quotBlockSize / diqinfo.blockSize; if (tsize != 0 && (tsize < diqinfo.limit || diqinfo.limit == 0)) { if (opts.debugLevel > 2) { writefln ("quota: using soft: %f", tsize); } diqinfo.limit = tsize; tlimit = tsize; } /* any quota set? */ if (tlimit == 0) { if (opts.debugLevel > 2) { writefln ("quota: %s %s no quota", tag, diqinfo.name); } return; } static if (_cmem_dqblk_dqb_curspace) { // OLD: tsize = qinfo.dqb_curspace / diqinfo.blockSize; if (tsize > diqinfo.used || diqinfo.used == 0) { diqinfo.used = tsize; } } static if (_cmem_dqblk_dqb_curblocks) { if (xfsflag) { static if (_cstruct_fs_disk_quota) { tsize = xfsqinfo.d_bcount; } ; } else { tsize = qinfo.dqb_curblocks; } // OLD: tsize = tsize * quotBlockSize / diqinfo.blockSize; if (tsize > diqinfo.used || diqinfo.used == 0) { diqinfo.used = tsize; } } if (opts.debugLevel > 2) { writefln ("quota: %s %s used: %f limit: %f", tag, diqinfo.name, diqinfo.used, diqinfo.limit); } if (xfsflag) { static if (_cstruct_fs_disk_quota) { tsize = xfsqinfo.d_ino_hardlimit; } ; } else { tsize = qinfo.dqb_ihardlimit; } if (tsize != 0 && (tsize < diqinfo.ilimit || diqinfo.ilimit == 0)) { diqinfo.ilimit = tsize; tlimit = tsize; } if (opts.debugLevel > 2) { writefln ("quota: %s %s i hard: %f", tag, diqinfo.name, tsize); } if (xfsflag) { static if (_cstruct_fs_disk_quota) { tsize = xfsqinfo.d_ino_softlimit; } ; } else { tsize = qinfo.dqb_isoftlimit; } if (tsize != 0 && (tsize < diqinfo.ilimit || diqinfo.ilimit == 0)) { diqinfo.ilimit = tsize; tlimit = tsize; } if (opts.debugLevel > 2) { writefln ("quota: %s %s i soft: %f", tag, diqinfo.name, tsize); } /* any quota set? */ if (tlimit == 0) { if (opts.debugLevel > 2) { writefln ("quota: %s %s no inode quota", tag, diqinfo.name); } return; } if (xfsflag) { static if (_cstruct_fs_disk_quota) { tsize = xfsqinfo.d_icount; } ; } else { tsize = qinfo.dqb_curinodes; } if (tsize > diqinfo.iused || diqinfo.iused == 0) { diqinfo.iused = tsize; } if (opts.debugLevel > 2) { writefln ("quota: %s %s i used: %f", tag, diqinfo.name, tsize); } } else { if (opts.debugLevel > 2) { writefln ("quota: %s %s errno %d", tag, diqinfo.name, errno); } } } } /* _has_std_quotas */ di-4.47/D/diskpart.d0000644000175000017500000003141213334050206012316 0ustar bllbll// written in the D programming language module diskpart; import std.stdio; import std.string; import std.conv : to; private import core.memory : GC; private import core.stdc.stdio; private import core.stdc.errno; import config; class DiskPartitions { public: struct DiskPartition { bool isRemote; bool isReadOnly; bool doPrint; bool isPooledFS; bool isLoopback; byte printFlag; ushort index; uint st_dev; // disk device number uint sp_dev; // special device number uint sp_rdev; // special rdev # real totalBlocks; real freeBlocks; real availBlocks; real blockSize; real totalInodes; real freeInodes; real availInodes; string name; // mount point string special; // special device name string fsType; // type of file system string mountOptions; string mountTime; void checkPartSizes () { if (this.freeBlocks < 0.0) { this.freeBlocks = 0.0; } if (this.availBlocks < 0.0) { this.availBlocks = 0.0; } if (this.totalInodes < 0.0) { this.freeInodes = 0.0; this.availInodes = 0.0; } } void initDiskPartition () { this.totalBlocks = 0.0; this.freeBlocks = 0.0; this.availBlocks = 0.0; this.totalInodes = 0.0; this.freeInodes = 0.0; this.availInodes = 0.0; } // for .st_dev enum DI_UNKNOWN_DEV = 0xFFFFFFFF; // for .printFlag enum byte DI_PRINT_OK = 0, DI_PRINT_IGNORE = 1, DI_PRINT_BAD = 2, DI_PRINT_OUTOFZONE = 3, DI_PRINT_EXCLUDE = 4, DI_PRINT_FORCE = 5, DI_PRINT_SKIP = 6; }; // struct DiskPartition public: DiskPartition[] diskPartitions; DiskPartition tot; this () {} this (int dbg) { this.debugLevel = dbg; } void setDebugLevel (int dbg) { debugLevel = dbg; } void getEntries () { static if (_clib_getmntent && _clib_setmntent && _clib_endmntent && ! _clib_getfsstat) { FILE * f; C_ST_mntent * mntEntry; static if (_c_args_setmntent == 1) { f = setmntent (toStringz(DI_MOUNT_FILE)); } else static if (_c_args_setmntent == 2) { f = setmntent (toStringz(DI_MOUNT_FILE), toStringz("r")); } if (f == cast(FILE *) null) { string s = format ("Unable to open %s errno %d", DI_MOUNT_FILE, errno()); throw new Exception (s); } scope (exit) { endmntent (f); } while ((mntEntry = getmntent (f)) != cast (C_ST_mntent *) null) { DiskPartition dp; dp.initDiskPartition; dp.special = to!(typeof(dp.special))(mntEntry.mnt_fsname); dp.name = to!(typeof(dp.special))(mntEntry.mnt_dir); dp.fsType = to!(typeof(dp.special))(mntEntry.mnt_type); if (dp.special == "none") { dp.printFlag = dp.DI_PRINT_IGNORE; } if (dp.fsType == "rootfs") { dp.printFlag = dp.DI_PRINT_IGNORE; } if (dp.fsType == MNTTYPE_IGNORE) { dp.printFlag = dp.DI_PRINT_IGNORE; } if (dp.fsType[0..2] == "nfs") { dp.isRemote = true; } /+ if ((devp = strstr (mntEntry->mnt_opts, "dev=")) != (char *) NULL) { if (devp != mntEntry->mnt_opts) { --devp; } *devp = 0; /* point to preceeding comma and cut off */ } if (chkMountOptions (mntEntry->mnt_opts, DI_MNTOPT_RO) != (char *) NULL) { diptr->isReadOnly = TRUE; } +/ dp.mountOptions = to!(typeof(dp.mountOptions))(mntEntry.mnt_opts); if (debugLevel > 5) { writefln ("mnt:%s - %s:%s: %d %d", dp.name, dp.special, dp.fsType, dp.printFlag, dp.isReadOnly); writefln (" %s", dp.mountOptions); } dp.index = indexCount++; diskPartitions ~= dp; } // while there are mount entries } // _clib_get/set/endmntent static if (_clib_getfsstat) { C_ST_statfs *mntbufp; // if (debug > 0) { printf ("# getDiskEntries: getfsstat\n"); } auto count = getfsstat (cast(C_ST_statfs *) null, cast(_c_arg_2_getfsstat_alias) 0, MNT_NOWAIT); if (count < 1) { // fprintf (stderr, "Unable to do getfsstat () errno %d\n", errno); return; } auto bufsize = C_ST_statfs.sizeof * cast(size_t)count; mntbufp = cast(C_ST_statfs*) GC.calloc (bufsize); count = getfsstat (mntbufp, cast(_c_arg_2_getfsstat_alias)bufsize, MNT_NOWAIT); for (auto idx = 0; idx < count; idx++) { DiskPartition dp; dp.initDiskPartition; auto sp = mntbufp + idx; copyCstring (dp.special, sp.f_mntfromname); copyCstring (dp.name, sp.f_mntonname); static if (_cmem_statfs_f_fstypename) { copyCstring (dp.fsType, sp.f_fstypename); // } else static if (_lib_sysfs && _cmem_statfs_f_type) { // char fbuff [DI_TYPE_LEN]; // sysfs (GETFSTYP, sp.f_type, fbuff); // copyCstring (dp.fsType, fbuff); // } else static if (_dcl_mnt_names && _cmem_statfs_f_type) { // ; } if (dp.fsType.length > 2 && dp.fsType[0..2] == "nfs") { dp.isRemote = true; } static if (_cdefine_MNT_RDONLY) { if ((sp.f_flags & MNT_RDONLY) == MNT_RDONLY) { dp.isReadOnly = TRUE; } } static if (_cdefine_MNT_LOCAL) { if ((sp.f_flags & MNT_LOCAL) != MNT_LOCAL) { dp.isRemote = TRUE; } } static if (_cmem_statfs_f_fsize) { dp.blockSize = sp.f_fsize; } else static if (_cmem_statfs_f_bsize) { dp.blockSize = sp.f_bsize; } dp.totalBlocks = cast(typeof(dp.totalBlocks)) sp.f_blocks * dp.blockSize; dp.freeBlocks = cast(typeof(dp.freeBlocks)) sp.f_bfree * dp.blockSize; dp.availBlocks = cast(typeof(dp.availBlocks)) sp.f_bavail * dp.blockSize; dp.totalInodes = sp.f_files; dp.freeInodes = sp.f_ffree; dp.availInodes = sp.f_ffree; dp.index = indexCount++; diskPartitions ~= dp; } GC.free (mntbufp); return; } /+ # if _dcl_mnt_names # if ! defined (MNT_NUMTYPES) # define MNT_NUMTYPES (sizeof(mnt_names)/sizeof(char *)) # endif # endif # define DI_UNKNOWN_FSTYPE "(%.2d)?" convertMountOptions ((long) sp->f_flags, diptr); # if _mem_struct_statfs_f_type # if defined (MOUNT_NFS3) if (sp->f_type == MOUNT_NFS3) { strncat (diptr->options, "v3,", DI_OPT_LEN - strlen (diptr->options) - 1); } # endif # endif # if _mem_struct_statfs_mount_info && \ defined (MOUNT_NFS) && \ (_mem_struct_statfs_f_type || _mem_struct_statfs_f_fstypename) # if _mem_struct_statfs_f_type if (sp->f_type == MOUNT_NFS # endif # if _mem_struct_statfs_f_fstypename if (strcmp (sp->f_fstypename, MOUNT_NFS) == 0 # endif # if _mem_struct_statfs_f_fstypename && defined (MOUNT_NFS3) || strcmp (sp->f_fstypename, MOUNT_NFS3) == 0 # endif # if _mem_struct_statfs_f_type && defined (MOUNT_NFS3) || sp->f_type == MOUNT_NFS3 # endif ) { struct nfs_args *na; na = &sp->mount_info.nfs_args; convertNFSMountOptions (na->flags, na->wsize, na->rsize, diptr); } # endif trimChar (diptr->options, ','); # if _dcl_mnt_names && _mem_struct_statfs_f_type fstype = sp->f_type; if ((fstype >= 0) && (fstype < MNT_NUMTYPES)) { strncpy (diptr->fsType, mnt_names [fstype], DI_TYPE_LEN); } else { Snprintf1 (diptr->fsType, sizeof (diptr->fsType), DI_UNKNOWN_FSTYPE, fstype); } # endif } +/ } void getPartitionInfo () { static if (_clib_statvfs && ! _clib_getfsstat) { C_ST_statvfs statBuf; foreach (ref dp; diskPartitions) { if (dp.printFlag == dp.DI_PRINT_OK || dp.printFlag == dp.DI_PRINT_SKIP || dp.printFlag == dp.DI_PRINT_FORCE) { if (statvfs (toStringz(dp.name), &statBuf) != 0) { string s = format ("statvfs: %s errno %d", dp.name, errno()); throw new Exception (s); } if (statBuf.f_frsize == 0 && statBuf.f_bsize != 0) { dp.blockSize = statBuf.f_bsize; } else { dp.blockSize = statBuf.f_frsize; } /* Linux! statvfs() returns values in f_bsize rather f_frsize. Bleah.*/ /* Non-POSIX! Linux manual pages are incorrect. */ static if (SYSTYPE == "Linux") { dp.blockSize = statBuf.f_bsize; } dp.totalBlocks = cast(typeof(dp.totalBlocks)) statBuf.f_blocks * dp.blockSize; dp.freeBlocks = cast(typeof(dp.freeBlocks)) statBuf.f_bfree * dp.blockSize; dp.availBlocks = cast(typeof(dp.availBlocks)) statBuf.f_bavail * dp.blockSize; dp.totalInodes = statBuf.f_files; dp.freeInodes = statBuf.f_ffree; dp.availInodes = statBuf.f_favail; static if (_cmem_statvfs_f_basetype) { if (dp.fsType.length == 0) { copyCstring (dp.fsType, statBuf.f_basetype); } } if (debugLevel > 5) { writefln ("part:%s: %.0f : %.0f %.0f %.0f", dp.name, dp.blockSize, dp.totalBlocks, dp.freeBlocks, dp.availBlocks); } } } } return; } void sortPartitions (ref size_t[] sortIndex, string sortType) { int gap; auto count = this.diskPartitions.length; if (count <= 1) { return; } gap = 1; while (gap < count) { gap = 3 * gap + 1; } for (gap /= 3; gap > 0; gap /= 3) { for (int i = gap; i < count; ++i) { auto tempIndex = sortIndex[i]; auto j = i - gap; while (j >= 0 && dpCompare (this.diskPartitions, sortType, sortIndex[j], tempIndex) > 0) { sortIndex[j+gap] = sortIndex[j]; j = j - gap; } j += gap; if (j != i) { sortIndex[j] = tempIndex; } } // insertion sort by gap size } // for gap size } // sortPartitions private: int dpCompare (ref DiskPartitions.DiskPartition[] dps, string sortType, size_t i, size_t j) { int rc; int sortOrder; /* reset sort order to the default start value */ sortOrder = DI_SORT_ASCENDING; rc = 0; foreach (char st; sortType) { switch (st) { case DI_SORT_NONE: { break; } case DI_SORT_MOUNT: { rc = strcoll (toStringz(dps[i].name), toStringz(dps[j].name)); rc *= sortOrder; break; } case DI_SORT_REVERSE: { sortOrder *= -1; break; } case DI_SORT_SPECIAL: { rc = strcoll (toStringz(dps[i].special), toStringz(dps[j].special)); rc *= sortOrder; break; } case DI_SORT_TYPE: { rc = strcoll (toStringz(dps[i].fsType), toStringz(dps[j].fsType)); rc *= sortOrder; break; } case DI_SORT_AVAIL: { auto v = dps[i].availBlocks - dps[j].availBlocks; rc = v < 0.00001 ? 0 : v > 0.0 ? 1 : -1; rc *= sortOrder; break; } default: { break; } } /* switch on sort type */ if (rc != 0) { return rc; } } return rc; } private: int debugLevel; short indexCount; static if (_cdefine__PATH_MOUNTED) { alias _PATH_MOUNTED DI_MOUNT_FILE; } else static if (_cdefine__PATH_MNTTAB) { alias _PATH_MNTTAB DI_MOUNT_FILE; } else static if (_cdefine_MOUNTED) { alias MOUNTED DI_MOUNT_FILE; } else static if (_cdefine_MNTTAB) { alias MNTTAB DI_MOUNT_FILE; } else { enum string DI_MOUNT_FILE = "/etc/mnttab"; } static if (! _cdefine_MNTTYPE_IGNORE) { enum string MNTTYPE_IGNORE = "ignore"; } void copyCstring (ref string a, char[] b) { auto l = strlen (b.ptr); a = to!(string)(b[0..l]); } enum char DI_SORT_NONE = 'n', DI_SORT_MOUNT = 'm', DI_SORT_SPECIAL = 's', DI_SORT_AVAIL = 'a', DI_SORT_REVERSE = 'r', DI_SORT_TYPE = 't', DI_SORT_ASCENDING = 1; }; // class DiskPartitions di-4.47/D/dilocale.d0000644000175000017500000000131413334050206012247 0ustar bllbll// written in the D programming language import std.string; import std.conv : to; private import std.process : getenv; import config; enum string DI_LOCALE_DIR = DI_PREFIX ~ "/share/locale"; static if (_enable_nls) { auto DI_GT (string txt) { return (to!string(gettext(toStringz(txt)))); } } else { auto DI_GT (string txt) { return (txt); } } void initLocale () { string localeptr = null; static if (_clib_setlocale) { setlocale (LC_ALL, ""); } static if (_enable_nls) { if ((localeptr = getenv ("DI_LOCALE_DIR")) == cast(string) null) { localeptr = DI_LOCALE_DIR; } bindtextdomain (toStringz(DI_PROG), toStringz(localeptr)); textdomain (toStringz(DI_PROG)); } } di-4.47/D/display.d0000644000175000017500000006360713334050206012155 0ustar bllbll// written in the D programming language module display; import std.stdio; import std.string; import std.ascii : isDigit; import std.uni : toLower; import std.conv : to; private import std.utf : count; private import std.math : floor; import config; import options; import dispopts; import diskpart; import dilocale; private: enum dchar FMT_MOUNT = 'm', FMT_MOUNT_FULL = 'M', FMT_SPECIAL = 's', FMT_SPECIAL_FULL = 'S', FMT_TYPE = 't', FMT_TYPE_FULL = 'T', FMT_BLOCKS_TOT = 'b', FMT_BLOCKS_TOT_AVAIL = 'B', FMT_BLOCKS_USED = 'u', FMT_BLOCKS_CALC_USED = 'c', FMT_BLOCKS_FREE = 'f', FMT_BLOCKS_AVAIL = 'v', FMT_BLOCKS_PERC_NOT_AVAIL = 'p', FMT_BLOCKS_PERC_USED = '1', FMT_BLOCKS_PERC_USED_AVAIL = '2', FMT_BLOCKS_PERC_AVAIL = 'a', FMT_BLOCKS_PERC_FREE = '3', FMT_INODES_TOT = 'i', FMT_INODES_USED = 'U', FMT_INODES_FREE = 'F', FMT_INODES_PERC = 'P', FMT_MOUNT_TIME = 'I', FMT_MOUNT_OPTIONS = 'O'; enum int FTYPE_STRING = 1, FTYPE_SPACE = 2, FTYPE_PERC_SPACE = 3, FTYPE_INODE = 4, FTYPE_PERC_INODE = 5; struct FormatInfo { dchar key; int ftype; long width; string title; }; FormatInfo[] formatTypes = [ { key: FMT_MOUNT, ftype: FTYPE_STRING, width: 15, title: "Mount" }, { key: FMT_MOUNT_FULL, ftype: FTYPE_STRING, width: 15, title: "Mount" }, { key: FMT_SPECIAL, ftype: FTYPE_STRING, width: 18, title: "Filesystem" }, { key: FMT_SPECIAL_FULL, ftype: FTYPE_STRING, width: 18, title: "Filesystem" }, { key: FMT_TYPE, ftype: FTYPE_STRING, width: 7, title: "fsType" }, { key: FMT_TYPE_FULL, ftype: FTYPE_STRING, width: 7, title: "fs Type" }, { key: FMT_BLOCKS_TOT, ftype: FTYPE_SPACE, width: 8, title: "" }, { key: FMT_BLOCKS_TOT_AVAIL, ftype: FTYPE_SPACE, width: 8, title: "" }, { key: FMT_BLOCKS_USED, ftype: FTYPE_SPACE, width: 8, title: "Used" }, { key: FMT_BLOCKS_CALC_USED, ftype: FTYPE_SPACE, width: 8, title: "Used" }, { key: FMT_BLOCKS_FREE, ftype: FTYPE_SPACE, width: 8, title: "Free" }, { key: FMT_BLOCKS_AVAIL, ftype: FTYPE_SPACE, width: 8, title: "Avail" }, { key: FMT_BLOCKS_PERC_NOT_AVAIL, ftype: FTYPE_PERC_SPACE, width: 6, title: "%Used" }, { key: FMT_BLOCKS_PERC_USED, ftype: FTYPE_PERC_SPACE, width: 6, title: "%Used" }, { key: FMT_BLOCKS_PERC_USED_AVAIL, ftype: FTYPE_PERC_SPACE, width: 6, title: "%Used" }, { key: FMT_BLOCKS_PERC_AVAIL, ftype: FTYPE_PERC_SPACE, width: 5, title: "%Free" }, { key: FMT_BLOCKS_PERC_FREE, ftype: FTYPE_PERC_SPACE, width: 5, title: "%Free" }, { key: FMT_INODES_TOT, ftype: FTYPE_INODE, width: 9, title: "Inodes" }, { key: FMT_INODES_USED, ftype: FTYPE_INODE, width: 9, title: "IUsed" }, { key: FMT_INODES_FREE, ftype: FTYPE_INODE, width: 9, title: "IFree" }, { key: FMT_INODES_PERC, ftype: FTYPE_PERC_INODE, width: 6, title: "%IUsed" }, { key: FMT_MOUNT_TIME, ftype: FTYPE_STRING, width: 0, title: "" }, { key: FMT_MOUNT_OPTIONS, ftype: FTYPE_STRING, width: 15, title: "Options" } ]; size_t[dchar] formatTypesIdxs; bool fmtInfoIdxsInitialized; struct DisplayData { Options opts; DisplayOpts dispOpts; DiskPartitions dps; string titleString; string[dchar] dispFmtString; }; struct DisplayTable { real size; real low; real high; short precision; char key; string suffix; string disp[2]; }; DisplayTable[] displayTable = [ // size == low except for bytes { size: 0, low: 0, high: 0, precision: 0, key: 'b', suffix: " ", disp: [ "Bytes", "Bytes" ] }, { size: 0, low: 0, high: 0, precision: 0, key: 'k', suffix: "K", disp: [ "KBytes", "KBytes" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'm', suffix: "M", disp: [ "Megs", "Mebis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'g', suffix: "G", disp: [ "Gigs", "Gibis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 't', suffix: "T", disp: [ "Teras", "Tebis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'p', suffix: "P", disp: [ "Petas", "Pebis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'e', suffix: "E", disp: [ "Exas", "Exbis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'z', suffix: "Z", disp: [ "Zettas", "Zebis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'y', suffix: "Y", disp: [ "Yottas", "Yobis" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'h', suffix: "h", disp: [ "Size", "Size" ] }, { size: 0, low: 0, high: 0, precision: 1, key: 'H', suffix: "H", disp: [ "Size", "Size" ] } ]; size_t[char] displayIdxs; bool dispIdxsInitialized; public: void doDisplay (Options opts, ref DisplayOpts dispOpts, DiskPartitions dps, bool hasPooled) { DisplayData dispData; initializeIdxs (); initializeTitles (dispOpts); initializeDisplayTable (dispOpts); setDispBlockSize (dispOpts); if (opts.debugLevel > 30) { dumpDispTable (); } dispData.opts = opts; dispData.dispOpts = dispOpts; dispData.dps = dps; buildDisplayList (dispData); displayTitle (dispData); displayPartitions (dispData, hasPooled); } private: void dumpDispTable () { foreach (disp; displayTable) { writefln ("%s %s %-6s sz:%25.0f\n low:%25.0f high:%25.0f", disp.key, disp.suffix, disp.disp[0], disp.size, disp.low, disp.high); } } void buildDisplayList (ref DisplayData dispData) { int[dchar] dpMax; bool first = true; foreach (dchar c; dispData.opts.formatString) { if (c in formatTypesIdxs && formatTypes[formatTypesIdxs[c]].ftype == FTYPE_STRING) { dpMax[c] = 0; } } foreach (dp; dispData.dps.diskPartitions) { if (! dp.doPrint) { continue; } if (FMT_SPECIAL_FULL in dpMax) { setMaxLen (dp.special, dpMax[FMT_SPECIAL_FULL]); } if (FMT_MOUNT_FULL in dpMax) { setMaxLen (dp.name, dpMax[FMT_MOUNT_FULL]); } if (FMT_TYPE_FULL in dpMax) { setMaxLen (dp.fsType, dpMax[FMT_TYPE_FULL]); } if (FMT_MOUNT_OPTIONS in dpMax) { setMaxLen (dp.mountOptions, dpMax[FMT_MOUNT_OPTIONS]); } } foreach (dchar c; dispData.opts.formatString) { if (c in formatTypesIdxs) { string fmt; auto title = DI_GT (formatTypes[formatTypesIdxs[c]].title); auto ftype = formatTypes[formatTypesIdxs[c]].ftype; auto width = formatTypes[formatTypesIdxs[c]].width; switch (c) { case FMT_MOUNT_FULL: case FMT_SPECIAL_FULL: case FMT_TYPE_FULL: case FMT_MOUNT_TIME: case FMT_MOUNT_OPTIONS: { width = dpMax[c]; break; } case FMT_BLOCKS_TOT: case FMT_BLOCKS_TOT_AVAIL: { title = DI_GT (dispData.dispOpts.dispBlockLabel); break; } default: { break; } } if (dispData.opts.csvOutput) { title = to!string(c); } auto utflen = std.utf.count (title); if (utflen > width) { width = utflen; } switch (ftype) { case FTYPE_STRING: { fmt = format ("%%-%d.%ds ", width, width); if (dispData.opts.csvOutput) { fmt = "\"%s\""; } dispData.dispFmtString[c] = fmt; break; } case FTYPE_SPACE: { if (dispData.dispOpts.width != 0) { width = dispData.dispOpts.width; } auto twidth = width; if (dispData.dispOpts.dbsstr == "h" || dispData.dispOpts.dbsstr == "H") { --twidth; } fmt = format ("%%%d.%df", twidth, dispData.dispOpts.precision); if (dispData.opts.csvOutput) { fmt = format ("%%.%df", dispData.dispOpts.precision); } dispData.dispFmtString[c] = fmt; break; } case FTYPE_PERC_SPACE: { auto twidth = width - 2; if (twidth < 1) { twidth = 1; } fmt = format ("%%%d.0f%%%% ", twidth); if (dispData.opts.csvOutput) { fmt = "%.0f%%"; } dispData.dispFmtString[c] = fmt; break; } case FTYPE_INODE: { if (dispData.dispOpts.inodeWidth != 0) { width = dispData.dispOpts.inodeWidth; } fmt = format ("%%%d.0f ", width); if (dispData.opts.csvOutput) { fmt = "%.0f"; } dispData.dispFmtString[c] = fmt; break; } case FTYPE_PERC_INODE: { fmt = format ("%%%d.0f%%%% ", width); if (dispData.opts.csvOutput) { fmt = "%.0f%%"; } dispData.dispFmtString[c] = fmt; break; } default: { break; } } // switch on format type auto twid = width + title.length - utflen; if (dispData.opts.csvOutput) { fmt = "%s"; } else { if (ftype == FTYPE_STRING) { fmt = format ("%%-%d.%ds ", twid, twid); } else { fmt = format ("%%%d.%ds ", twid, twid); } } if (dispData.opts.csvOutput && ! first) { dispData.titleString ~= ","; } dispData.titleString ~= format (fmt, title); } else { dispData.titleString ~= format ("%s", c); } first = false; } // for each format string char } void displayTitle (ref DisplayData dispData) { if (! dispData.opts.printHeader) { return; } writeln (dispData.titleString); } void displayPartitions (ref DisplayData dispData, bool hasPooled) { size_t[] sortIndex; sortIndex.length = dispData.dps.diskPartitions.length; for (int i = 0; i < sortIndex.length; ++i) { sortIndex[i] = i; } if (dispData.opts.displayTotal) { bool inpool; string lastpool; dispData.dps.tot.initDiskPartition; dispData.dps.tot.name = DI_GT("Total"); if (hasPooled) { dispData.dps.sortPartitions (sortIndex, "s"); } foreach (size_t i, size_t v; sortIndex) { bool startpool; auto dp = dispData.dps.diskPartitions[v]; startpool = false; if (hasPooled && dp.isPooledFS) { if (lastpool.length == 0 || (dp.special.length >= lastpool.length && lastpool != dp.special[0..lastpool.length])) { lastpool = dp.special; auto si = indexOf (lastpool, "#"); /* for advfs */ if (si >= 0) { lastpool.length = si; } si = indexOf (lastpool, "/"); /* for zfs */ if (si >= 0) { lastpool.length = si; } inpool = false; startpool = true; } } else { inpool = false; } if (dp.doPrint) { /* only add in a pooled filesystem if it's the first in the list */ /* belonging to that pool */ if (! inpool) { dispData.dps.tot.totalBlocks += dp.totalBlocks; dispData.dps.tot.freeBlocks += dp.freeBlocks; dispData.dps.tot.availBlocks += dp.availBlocks; dispData.dps.tot.totalInodes += dp.totalInodes; dispData.dps.tot.freeInodes += dp.freeInodes; dispData.dps.tot.availInodes += dp.availInodes; } else { /* if in a pool of disks, add the total used to the totals */ dispData.dps.tot.totalBlocks += dp.totalBlocks - dp.freeBlocks; dispData.dps.tot.totalInodes += dp.totalInodes - dp.freeInodes; } } if (startpool) { inpool = true; } } } dispData.dps.sortPartitions (sortIndex, dispData.opts.sortType); foreach (size_t i, size_t v; sortIndex) { auto dp = dispData.dps.diskPartitions[v]; if (! dp.doPrint) { continue; } printPartition (dispData, dp); } // for each disk partition if (dispData.opts.displayTotal) { printPartition (dispData, dispData.dps.tot); } } void printPartition (ref DisplayData dispData, DiskPartitions.DiskPartition dp) { string outString; string sval; real rval; real uval; size_t dHidx; bool first = true; if (dispData.dispOpts.dbsstr == "H") { real mval = 0.0; foreach (dchar c; dispData.opts.formatString) { if (c in formatTypesIdxs) { auto ftype = formatTypes[formatTypesIdxs[c]].ftype; if (ftype == FTYPE_SPACE) { switch (c) { case FMT_BLOCKS_TOT: { rval = dp.totalBlocks; break; } case FMT_BLOCKS_TOT_AVAIL: { rval = dp.totalBlocks - (dp.freeBlocks - dp.availBlocks); break; } case FMT_BLOCKS_USED: { rval = dp.totalBlocks - dp.freeBlocks; break; } case FMT_BLOCKS_CALC_USED: { rval = dp.totalBlocks - dp.availBlocks; break; } case FMT_BLOCKS_FREE: { rval = dp.freeBlocks; break; } case FMT_BLOCKS_AVAIL: { rval = dp.availBlocks; break; } default: { break; } } // switch on format character if (rval > mval) { mval = rval; } } // is FTYPE_SPACE } // valid format character } // for each character in format string dHidx = findDispSize (mval); } // if -d H foreach (dchar c; dispData.opts.formatString) { if (c in formatTypesIdxs) { auto ftype = formatTypes[formatTypesIdxs[c]].ftype; switch (c) { case FMT_MOUNT: case FMT_MOUNT_FULL: { sval = dp.name; break; } case FMT_SPECIAL: case FMT_SPECIAL_FULL: { sval = dp.special; break; } case FMT_TYPE: case FMT_TYPE_FULL: { sval = dp.fsType; break; } case FMT_BLOCKS_TOT: { rval = dp.totalBlocks; break; } case FMT_BLOCKS_TOT_AVAIL: { rval = dp.totalBlocks - (dp.freeBlocks - dp.availBlocks); break; } case FMT_BLOCKS_USED: { rval = dp.totalBlocks - dp.freeBlocks; break; } case FMT_BLOCKS_CALC_USED: { rval = dp.totalBlocks - dp.availBlocks; break; } case FMT_BLOCKS_FREE: { rval = dp.freeBlocks; break; } case FMT_BLOCKS_AVAIL: { rval = dp.availBlocks; break; } case FMT_BLOCKS_PERC_NOT_AVAIL: { rval = dp.totalBlocks; uval = dp.totalBlocks - dp.availBlocks; break; } case FMT_BLOCKS_PERC_USED: { rval = dp.totalBlocks; uval = dp.totalBlocks - dp.freeBlocks; break; } case FMT_BLOCKS_PERC_USED_AVAIL: { rval = dp.totalBlocks - (dp.freeBlocks - dp.availBlocks); uval = dp.totalBlocks - dp.freeBlocks; break; } case FMT_BLOCKS_PERC_AVAIL: { rval = dp.totalBlocks; uval = dp.availBlocks; break; } case FMT_BLOCKS_PERC_FREE: { rval = dp.totalBlocks; uval = dp.freeBlocks; break; } case FMT_INODES_TOT: { rval = dp.totalInodes; break; } case FMT_INODES_USED: { rval = dp.totalInodes - dp.freeInodes; break; } case FMT_INODES_FREE: { rval = dp.freeInodes; break; } case FMT_INODES_PERC: { rval = dp.totalInodes; uval = dp.totalInodes - dp.availInodes; break; } case FMT_MOUNT_TIME: { break; } case FMT_MOUNT_OPTIONS: { sval = dp.mountOptions; break; } default: { break; } } // switch on format character switch (ftype) { case FTYPE_STRING: { if (dispData.opts.csvOutput && ! first) { outString ~= ","; } outString ~= format (dispData.dispFmtString[c], sval); break; } case FTYPE_SPACE: { if (dispData.opts.csvOutput && ! first) { outString ~= ","; } outString ~= blockDisplay (dispData, c, rval, dHidx, dispData.opts.csvOutput); break; } case FTYPE_PERC_SPACE: case FTYPE_PERC_INODE: { if (dispData.opts.csvOutput && ! first) { outString ~= ","; } outString ~= percDisplay (dispData, c, rval, uval); break; } case FTYPE_INODE: { if (dispData.opts.csvOutput && ! first) { outString ~= ","; } outString ~= inodeDisplay (dispData, c, rval); break; } default: { break; } } } else { outString ~= c; } first = false; } // for each format character writeln (outString); } auto findDispSize (real val) { foreach (i, dt; displayTable) { if (val >= dt.low && val < dt.high) { return i; } } return displayIdxs['m']; } string blockDisplay (const DisplayData dispData, const dchar c, const real val, const size_t dHidx, bool csvOutput) { size_t idx; real dbs = dispData.dispOpts.dispBlockSize; string suffix = ""; if (dispData.dispOpts.dbsstr == "h") { idx = findDispSize (val); } if (dispData.dispOpts.dbsstr == "H") { idx = dHidx; } if (dispData.dispOpts.dbsstr == "h" || dispData.dispOpts.dbsstr == "H") { dbs = displayTable[idx].size; suffix = displayTable[idx].suffix; } auto nval = val / dbs; auto fmt = dispData.dispFmtString[c] ~ suffix; if (! csvOutput) { fmt ~= " "; } else { fmt = "\"" ~ fmt ~ "\""; } return format (fmt, nval); } string inodeDisplay (const DisplayData dispData, const dchar c, const real val) { size_t idx; string suffix = ""; auto fmt = dispData.dispFmtString[c]; return format (fmt, val); } string percDisplay (const DisplayData dispData, const dchar c, const real tval, const real uval) { real perc; if (tval > 0.0) { perc = uval / tval; perc *= 100; } else { perc = 0.0; } auto fmt = dispData.dispFmtString[c]; return format (fmt, perc); } void setDispBlockSize (ref DisplayOpts dispOpts) { real val; char c; val = 1024.0 * 1024.0; c = dispOpts.dbsstr[0]; if (isDigit (c)) { val = to!(typeof(val))(dispOpts.dbsstr); val = floor (val); // make sure it's an integer value //writefln ("digit:%s:val=%25.0f", dispOpts.dbsstr, val); foreach (disp; displayTable) { if (val == disp.size) { c = disp.key; //writefln ("digit:%s", c); break; } } } else { if (c != 'H') { c = cast(char) toLower (c); } if (dispOpts.dbsstr == "HUMAN") { c = 'h'; } //writefln ("non-digit:%s:%s", dispOpts.dbsstr, c); if (dispOpts.dbsstr.length > 1 && dispOpts.dbsstr[1] == 'B' && dispOpts.baseDispSize != size1000) { //writefln ("non-digit:1000:%s", c); dispOpts.baseDispSize = size1000; dispOpts.baseDispIdx = idx1000; initializeDisplayTable (dispOpts); } if (dispOpts.dbsstr.length > 1 && dispOpts.dbsstr[1] == 'b' && dispOpts.baseDispSize != size1024) { //writefln ("non-digit:1024:%s", c); dispOpts.baseDispSize = size1024; dispOpts.baseDispIdx = idx1024; initializeDisplayTable (dispOpts); } } if (c in displayIdxs) { auto idx = displayIdxs [c]; dispOpts.dispBlockLabel = displayTable [idx].disp [dispOpts.baseDispIdx]; val = displayTable [idx].size; dispOpts.precision = displayTable [idx].precision; } else { foreach (idx, disp; displayTable) { if (disp.key == 'h') { break; } auto tval = val / disp.size; if (floor (tval) == tval) { auto s = disp.suffix; if (idx == 0) { s = "b"; } dispOpts.dispBlockLabel = format ("%.0f%s", tval, s); } } } if (dispOpts.posixCompat && val == 512.0) { dispOpts.dispBlockLabel = "512-blocks"; } if (dispOpts.posixCompat && val == 1024.0) { dispOpts.dispBlockLabel = "1024-blocks"; } //writefln ("block label:%s", dispOpts.dispBlockLabel); dispOpts.dispBlockSize = val; //writefln ("block size:%.0f", val); } unittest { DisplayOpts dispOpts; int tcount; int failures; void test (string l, bool posix, string dbsstr, real bds, int bdi, string rdbl, real rdbs) { bool fail; ++tcount; dispOpts = dispOpts.init; dispOpts.dbsstr = dbsstr; dispOpts.baseDispSize = bds; dispOpts.baseDispIdx = bdi; dispOpts.posixCompat = posix; setDispBlockSize (dispOpts); if (dispOpts.dispBlockLabel != rdbl) { fail = true; } if (dispOpts.dispBlockSize != rdbs) { fail = true; } if (fail) { ++failures; writefln ("# setDispBlockSize-fail: %s", l); writefln (" using:dbsstr:%s: bds:%.0f: bdi:%d: rdbl:%s: rdbs:%.0f:", dbsstr, bds, bdi, rdbl, rdbs); writefln (" expected: %s got %s", rdbl, dispOpts.dispBlockLabel); writefln (" expected: %.0f got %.0f", rdbs, dispOpts.dispBlockSize); } } initializeIdxs (); dispOpts.baseDispSize = size1024; dispOpts.baseDispIdx = idx1024; initializeDisplayTable (dispOpts); for (auto i = 0; i < displayTable.length; ++i) { test (format("%.0f", displayTable[i].size), false, format ("%.0f", displayTable[i].size), size1024, idx1024, displayTable[i].disp[1], displayTable[i].size); test (to!string(displayTable[i].key), false, to!string(displayTable[i].key), size1024, idx1024, displayTable[i].disp[1], displayTable[i].size); } test ("HUMAN", false, "HUMAN", size1024, idx1024, "Size", 0); dispOpts.baseDispSize = size1000; dispOpts.baseDispIdx = idx1000; initializeDisplayTable (dispOpts); for (auto i = 0; i < displayTable.length; ++i) { test (format("%.0f", displayTable[i].size), false, format ("%.0f", displayTable[i].size), size1000, idx1000, displayTable[i].disp[0], displayTable[i].size); test (to!string(displayTable[i].key), false, to!string(displayTable[i].key), size1000, idx1000, displayTable[i].disp[0], displayTable[i].size); } test ("HUMAN", false, "HUMAN", size1000, idx1000, "Size", 0); dispOpts.baseDispSize = size1000; dispOpts.baseDispIdx = idx1000; initializeDisplayTable (dispOpts); for (auto i = 0; i < displayTable.length; ++i) { test (format ("%sB", displayTable[i].key), false, format ("%sB", displayTable[i].key), size1024, idx1024, displayTable[i].disp[0], displayTable[i].size); } test ("2.5", false, "2.5", size1000, idx1000, "2b", 2); test ("2", false, "2", size1000, idx1000, "2b", 2); test ("2048", false, "2048", size1000, idx1000, "2048b", 2048); test ("2000", false, "2000", size1000, idx1000, "2K", 2000); dispOpts.baseDispSize = size1024; dispOpts.baseDispIdx = idx1024; initializeDisplayTable (dispOpts); for (auto i = 0; i < displayTable.length; ++i) { test (format ("%sb", displayTable[i].key), false, format ("%sb", displayTable[i].key), size1000, idx1000, displayTable[i].disp[1], displayTable[i].size); } test ("2.5", false, "2.5", size1024, idx1024, "2b", 2.0); test ("2", false, "2", size1024, idx1024, "2b", 2.0); test ("2048", false, "2048", size1024, idx1024, "2K", 2048.0); test ("2000", false, "2000", size1024, idx1024, "2000b", 2000.0); test ("Posix-1024", true, "k", size1024, idx1024, "1024-blocks", 1024.0); test ("Posix-512", true, "512", size1024, idx1024, "512-blocks", 512.0); if (failures > 0) { write ("unittest: display: setDispBlockSize: "); writefln ("failed: %d of %d", failures, tcount); } } void initializeDisplayTable (ref DisplayOpts dispOpts) { displayTable [0].size = 1; displayTable [0].low = 1; // temporary, reset below displayTable [0].high = dispOpts.baseDispSize; for (auto i = 1; i < displayTable.length; ++i) { if (displayTable [i].key == 'h') { break; } if (displayTable [i].key == 'H') { break; } displayTable [i].size = displayTable [i - 1].size * dispOpts.baseDispSize; displayTable [i].low = displayTable [i - 1].low * dispOpts.baseDispSize; displayTable [i].high = displayTable [i - 1].high * dispOpts.baseDispSize; } displayTable [0].low = 0; } void initializeIdxs () { if (! dispIdxsInitialized) { foreach (idx, dt; displayTable) { displayIdxs[dt.key] = idx; } dispIdxsInitialized = true; } if (! fmtInfoIdxsInitialized) { foreach (idx, fi; formatTypes) { formatTypesIdxs[fi.key] = idx; } fmtInfoIdxsInitialized = true; } } void setMaxLen (string val, ref int max) { int len = cast(int) val.length; if (len > max) { max = len; } } void initializeTitles (DisplayOpts dispOpts) { if (dispOpts.posixCompat) { formatTypes[formatTypesIdxs[FMT_MOUNT_FULL]].title = "Mounted On"; formatTypes[formatTypesIdxs[FMT_BLOCKS_AVAIL]].title = "Available"; formatTypes[formatTypesIdxs[FMT_BLOCKS_PERC_NOT_AVAIL]].title = "Capacity"; formatTypes[formatTypesIdxs[FMT_BLOCKS_PERC_USED]].title = "Capacity"; formatTypes[formatTypesIdxs[FMT_BLOCKS_PERC_USED_AVAIL]].title = "Capacity"; } } di-4.47/D/Makefile0000644000175000017500000001116513334050206011773 0ustar bllbll# # di makefile - D # # Copyright 2011 Brad Lanam Walnut Creek CA, USA # OBJ_EXT = .o EXE_EXT = CC = cc DC = gdc # # common programs # CAT = cat CHGRP = chgrp CHMOD = chmod CHOWN = chown CP = cp LN = ln MKDIR = mkdir MV = mv RM = rm ### # mkconfig variables MKC_DIR = ../mkconfig MKCONFIG_TYPE = sh MKC_REQLIB = di.reqlibs # set to -e to echo command lines. MKCECHO = ### # main # have to get various environment variables set up. # DTESTFLAGS="$$DC_OPT $$DC_RELEASE $$DC_INLINE" di-programs # compiling w/o the unittest flag doesn't work w/incremental linking .PHONY: all all: di.env . ./di.env; \ $(MAKE) -e MKCONFIG_TYPE=sh \ DTESTFLAGS="$$DC_UNITTEST" di-programs # DTESTFLAGS="$$DC_UNITTEST $$DC_COV $$DC_DEBUG" \ .PHONY: all-test all-test: di.env . ./di.env; \ $(MAKE) -e MKCONFIG_TYPE=sh \ DTESTFLAGS="$$DC_UNITTEST $$DC_COV " \ LIBS="$(LIBS) $$DC_LIBS" di-programs ### # environment #### possibly merge features/env.dat w/C version??? di.env: features/env.dat ../dioptions.dat @-$(RM) -f di.env tests.done CFLAGS="-I`pwd`/../C" $(_MKCONFIG_SHELL) \ $(MKC_DIR)/mkconfig.sh features/env.dat ### # cleaning # leaves: # config.d, di.env, di.reqlibs .PHONY: clean clean: @-rm -f di di.exe mi mi.exe \ *.o *.obj *.lst *.gcno *.gcda *.gcov \ mkconfig.log mkconfig.cache mkc*.vars *~ \ > /dev/null 2>&1 # leaves: # _mkconfig_runtests, _tmp_mkconfig .PHONY: realclean realclean: @$(MAKE) clean > /dev/null 2>&1 @-$(RM) -rf config.d di.env $(MKC_REQLIB) \ >/dev/null 2>&1 # leaves: .PHONY: distclean distclean: @$(MAKE) realclean > /dev/null 2>&1 @-$(RM) -rf _mkconfig_runtests _tmp_mkconfig test_di \ >/dev/null 2>&1 ### # installation .PHONY: install install: di-programs di.env . ./di.env;cd ..;$(MAKE) -e prefix=$(prefix) LOCALEDIR=$(LOCALEDIR) FROMDIR=D install ### # programs .PHONY: di-programs di-programs: di$(EXE_EXT) ### # configuration file ../dioptions.dat: ../features/dioptions.dat cd ../;$(MAKE) dioptions.dat config.d: di.env ../dioptions.dat features/mkconfig.dat @-$(RM) -f config.d tests.done @if [ "$(DI_NO_NLS)" != "" ]; then \ echo "*** User requested no NLS"; \ $(MKC_DIR)/mkcsetopt.sh -o ../dioptions.dat NLS F; fi @. ./di.env;$(_MKCONFIG_SHELL) \ $(MKC_DIR)/mkconfig.sh \ features/mkconfig.dat; fi $(MKC_REQLIB): di.env config.d $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -reqlib -o \ $(MKC_REQLIB) config.d ### # executables OBJECTS = config$(OBJ_EXT) di$(OBJ_EXT) \ dihelp$(OBJ_EXT) dilocale$(OBJ_EXT) \ diquota$(OBJ_EXT) diskpart$(OBJ_EXT) display$(OBJ_EXT) \ dispopts$(OBJ_EXT) digetoptn$(OBJ_EXT) options$(OBJ_EXT) di$(EXE_EXT): $(OBJECTS) $(MKC_REQLIB) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -link $(MKCECHO) -c $(DC) \ -o di$(EXE_EXT) -r $(MKC_REQLIB) -- $(LDFLAGS) $(OBJECTS) $(LIBS) ### # objects config$(OBJ_EXT): config.d $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) config.d di$(OBJ_EXT): di.d config$(OBJ_EXT) \ diskpart$(OBJ_EXT) dihelp$(OBJ_EXT) \ dilocale$(OBJ_EXT) diquota$(OBJ_EXT) \ display$(OBJ_EXT) dispopts$(OBJ_EXT) \ digetoptn$(OBJ_EXT) options$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) di.d digetoptn$(OBJ_EXT): digetoptn.d config$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) digetoptn.d dihelp$(OBJ_EXT): dihelp.d config$(OBJ_EXT) dilocale$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) dihelp.d dilocale$(OBJ_EXT): dilocale.d config$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) dilocale.d diquota$(OBJ_EXT): diquota.d config$(OBJ_EXT) diskpart$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) diquota.d diskpart$(OBJ_EXT): diskpart.d config$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) diskpart.d display$(OBJ_EXT): display.d config$(OBJ_EXT) dilocale$(OBJ_EXT) \ diskpart$(OBJ_EXT) dispopts$(OBJ_EXT) \ options$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) display.d dispopts$(OBJ_EXT): dispopts.d config$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) dispopts.d options$(OBJ_EXT): options.d config$(OBJ_EXT) \ dispopts$(OBJ_EXT) dihelp$(OBJ_EXT) digetoptn$(OBJ_EXT) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -comp $(MKCECHO) -c $(DC) -o $@ \ -- $(DFLAGS) $(DTESTFLAGS) options.d di-4.47/D/features/0000755000175000017500000000000013334050206012145 5ustar bllblldi-4.47/D/features/mkconfig.dat0000644000175000017500000001745013334050206014443 0ustar bllbll# # Copyright 2011 Brad Lanam, Walnut Creek, California USA # # option-file ../dioptions.dat loadunit d-main output config.d standard csizes # di.d: for version chdr version.h # stat() csys stat.h # O_RDONLY chdr fcntl.h # NLS support: # libintl.h has dcls for gettext(), et. al. chdr libintl.h # locale.h has LC_ALL chdr locale.h # unistd.h has geteuid, et. al. chdr unistd.h # diskpart.d: # All: chdr string.h # Linux: # _PATH_MOUNTED MNTTYPE_IGNORE chdr mntent.h # Linux: # for struct statvfs, statvfs() csys statvfs.h # FreeBSD: # for getfsstat(); MNT_NOWAIT; struct statfs csys mount.h # diquota.d: # Linux: # XGETQUOTA chdr linux/dqblk_xfs.h # Solaris: csys fs/ufs_quota.h # Linux: # quotas: QCMD, SUBCMD*, struct dqblk, USRQUOTA, GRPQUOTA csys quota.h # quotas: uid_t, gid_t csys types.h # FreeBSD: # quotas: QCMD, SUBCMD*, struct dqblk, USRQUOTA, GRPQUOTA chdr ufs/ufs/quota.h # NFS quotas chdr rpc/types.h # FreeBSD has broken rpc headers chdr rpc/auth.h rpc/types.h chdr rpc/clnt.h rpc/types.h rpc/auth.h chdr rpc/rpc.h chdr rpcsvc/rquota.h ### Other C library routines clib exit cdcl exit ### For NLS support clib bindtextdomain -lintl, -lintl -liconv clib gettext -lintl, -lintl -liconv clib setlocale clib textdomain -lintl, -lintl -liconv cdefine hex LC_ALL cdcl bindtextdomain cdcl gettext cdcl setlocale cdcl textdomain command msgfmt gmsgfmt ### diskpart.d: # All: clib strlen cdcl strlen clib strcoll cdcl strcoll clib strcmp cdcl strcmp # FreeBSD: for struct statfs from mount.h ctype int uid_t ctype int int32_t ctype int int64_t ctype int uint32_t ctype int uint64_t cstruct fsid # FreeBSD: for struct statvfs from statvfs.h ctype int fsblkcnt_t ctype int fsfilcnt_t # FreeBSD: # getfsstat clib getfsstat cdcl args noconst getfsstat # Linux: # get/set/endmntent clib endmntent cdcl endmntent # some unixware needs -lgen clib getmntent -lgen cdcl getmntent clib setmntent cdcl args noconst setmntent # Linux: from mntent.h cdefine string _PATH_MOUNTED cdefine string _PATH_MNTTAB cdefine string MOUNTED cdefine string MNTTAB # Linux: from mntent.h cdefine string MNTTYPE_IGNORE # Linux: from mntent.h cstruct mntent # Linux: for struct statvfs from statvfs.h ctype int __fsblkcnt_t ctype int __fsfilcnt_t # Linux: 64-bit: for struct statvfs from statvfs.h ctype int __fsblkcnt64_t ctype int __fsfilcnt64_t # Linux: statvfs clib statvfs cdcl statvfs # Linux: from statvfs.h cstruct statvfs # FreeBSD: from mount.h cstruct statfs # FreeBSD: from mount.h cdefine int MNT_NOWAIT cdefine hex MNT_RDONLY cdefine hex MNT_LOCAL # Linux: from statvfs.h cmember statvfs f_basetype # FreeBSD: struct statfs from mount.h cmember statfs f_fstypename cmember statfs f_ftype cmember statfs f_fsize cmember statfs f_bsize ### diquota.d # uid/gid; geteuid, getegid ctype int gid_t ctype int __gid_t # done above #ctype int uid_t ctype int __uid_t clib getegid clib geteuid cdcl getegid cdcl geteuid # from sys/quota.h cdefine hex SUBCMDSHIFT cdefine hex SUBCMDMASK if sysquota _sys_quota cmacro QCMD sys/quota.h int int int endif if ufsufsquota _hdr_ufs_ufs_quota cmacro QCMD ufs/ufs/quota.h int int int endif cdefine hex Q_GETQUOTA cdefine hex Q_XGETQUOTA cdefine hex USRQUOTA cdefine hex GRPQUOTA # from rpcsvc/rquota.h cdefine int RQUOTAPROG cdefine int RQUOTAVERS cdefine int RQUOTAPROC_GETQUOTA # from sys/quota.h # linux clib quotactl cdcl args noconst quotactl cstruct dqblk cmember dqblk dqb_curspace cmember dqblk dqb_curblocks cmember dqblk dqb_fhardlimit cmember dqblk dqb_fsoftlimit cmember dqblk dqb_curfiles # from linux/dqblk_xfs.h # linux ctype int __s8 ctype int __s16 ctype int __s32 ctype int __u16 ctype int __u32 ctype int __u64 # Linux: cdefine hex BLOCK_SIZE # Linux: xfs quotas cstruct fs_disk_quota # Tru64, et. al. cdefine hex DEV_BSIZE # FreeBSD: cdefine int __FreeBSD__ # AIX: cdefine hex DQBSIZE cdefine int _AIX # from rpcsvc/rquota.h # linux cdefine int TRUE cdefine int FALSE ctype int u_int64_t ctype int u_int32_t ctypedef __caddr_t ctypedef caddr_t # from rpc/auth.h clib authunix_create_default cdcl authunix_create_default cmacro auth_destroy rpc/auth.h void 'AUTH *' # from rpc/clnt.h cmacro clnt_call rpc/clnt.h clnt_stat 'CLIENT *' u_long xdrproc_t caddr_t xdrproc_t caddr_t 'struct timeval' cmacro clnt_destroy rpc/clnt.h void 'CLIENT *' clib clnt_create cdcl clnt_create # NFS quotas clib xdr_quota_get cdcl xdr_quota_get clib xdr_quota_rslt cdcl xdr_quota_rslt clib xdr_string cdcl xdr_string clib xdr_int cdcl xdr_int clib xdr_u_int cdcl xdr_u_int clib xdr_bool cdcl xdr_bool cdefine int RQ_PATHLEN # from rpcsvc/rquota.h ctype int bool_t ctype int enum_t ctype int u_int ctype int u_long # done above #ctype int int32_t cstruct rquota ctypedef rquota cmemberxdr rquota rq_bhardlimit cmemberxdr rquota rq_bsoftlimit cmemberxdr rquota rq_curblocks cmemberxdr rquota rq_fhardlimit cmemberxdr rquota rq_fsoftlimit cmemberxdr rquota rq_curfiles cenum gqr_status ctypedef gqr_status cstruct getquota_rslt cmember getquota_rslt gqr_status cmember getquota_rslt gqr_rquota cenum xdr_op cenum clnt_stat cenum auth_stat ctypedef xdrproc_t # Linux: ctype int __time_t ctype int __suseconds_t # FreeBSD: ctype int time_t ctype int suseconds_t ctype int rpcproc_t ctype int rpcprog_t ctype int rpcvers_t # cstruct timeval cstruct rpc_err cstruct getquota_args cmembertype getquota_args gqa_uid cmemberxdr getquota_args gqa_uid cstruct opaque_auth cunion des_block cstruct AUTH ctypedef AUTH cstruct CLIENT ctypedef CLIENT cstruct XDR ctypedef XDR ### di.d cdefine string DI_VERSION # for struct stat cstruct timespec ctype int __dev_t ctype int fflags_t ctype int ino_t ctype int __ino_t ctype int __ino64_t ctype int mode_t ctype int __mode_t ctype int nlink_t ctype int __nlink_t ctype int off_t ctype int __off_t ctype int __off64_t ctype int blksize_t ctype int __blksize_t ctype int blkcnt_t ctype int __blkcnt_t ctype int __blkcnt64_t #ctype int __uid_t #ctype int __gid_t #ctype int __time_t ctype int __int32_t #ctype int int32_t ctype int __uint32_t #ctype int uint32_t cstruct stat clib stat cdcl stat clib fstat cdcl fstat cdefine int O_RDONLY cdefine int O_NOCTTY clib open cdcl open clib close cdcl close ### options # see dioptions.dat to change these option DI_DEFAULT_FORMAT smbuvpT option DI_DEFAULT_DISP_SIZE H ifnotoption NLS set _lib_bindtextdomain 0 set _lib_gettext 0 set _lib_setlocale 0 set _lib_textdomain 0 set _hdr_libintl 0 set _hdr_locale 0 set _command_msgfmt 0 endif if hasnls _clib_bindtextdomain && _clib_gettext && _clib_setlocale && \ _clib_textdomain && _hdr_libintl && _hdr_locale && \ _command_msgfmt setint _enable_nls 1 else set _clib_bindtextdomain 0 set _clib_gettext 0 set _clib_setlocale 0 set _clib_textdomain 0 set _hdr_libintl 0 set _hdr_locale 0 set _command_msgfmt 0 setint _enable_nls 0 endif if stdquotas _hdr_linux_quota || _hdr_ufs_quota || _hdr_ufs_ufs_quota || \ _sys_fs_ufs_quota || _sys_quota || _clib_quotactl setint _has_std_quotas 1 else setint _has_std_quotas 0 endif if stdnfsquotas _hdr_rpc_rpc && _hdr_rpcsvc_rquota && _clib_xdr_int && \ _cmemberxdr_rquota_rq_bhardlimit && _cmemberxdr_getquota_args_gqa_uid setint _has_std_nfs_quotas 1 else setint _has_std_nfs_quotas 0 endif include static if (_ctype_uid_t > 0) { alias C_TYP_uid_t Uid_t; } else { alias int Uid_t; } static if (_ctype_gid_t > 0) { alias C_TYP_gid_t Gid_t; } else { alias int Gid_t; } static if (! _clib_strcoll) { alias strcoll strcmp; } enum string DI_PROG = "di"; enum string DI_PREFIX = "/home/bll/DI/di/C/test_di"; // needed for getmntent() import core.stdc.stdio; // for FILE endinclude di-4.47/D/features/env.dat0000644000175000017500000000042613334050206013431 0ustar bllblloption-file ../dioptions.dat loadunit env-main loadunit env-systype loadunit env-dc loadunit env-cc loadunit env-msgfmt loadunit env-extension output di.env system type system rev system arch dc using_gdc dflags cc cflags ldflags libs extension obj extension exe cmd_msgfmt di-4.47/D/dihelp.d0000644000175000017500000000412513334050206011743 0ustar bllbll// written in the D programming language module dihelp; import std.stdio; import config; import dilocale; void dispVersion () { writefln (DI_GT("di version %s Default Format: %s"), DI_VERSION, DI_DEFAULT_FORMAT); } void usage () { dispVersion (); /* 12345678901234567890123456789012345678901234567890123456789012345678901234567890 */ writeln (DI_GT("Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]")); writeln (DI_GT(" [-I include-fstyp-list] [file [...]]")); writeln (DI_GT(" -a : print all mounted devices")); writeln (DI_GT(" -d x : size to print blocks in (512 - POSIX, k - kbytes,")); writeln (DI_GT(" m - megabytes, g - gigabytes, t - terabytes, h - human readable).")); writeln (DI_GT(" -f x : use format string ")); writeln (DI_GT(" -I x : include only file system types in ")); writeln (DI_GT(" -x x : exclude file system types in ")); writeln (DI_GT(" -l : display local filesystems only")); writeln (DI_GT(" -n : don't print header")); writeln (DI_GT(" -t : print totals")); writeln (DI_GT(" Format string values:")); writeln (DI_GT(" m - mount point M - mount point, full length")); writeln (DI_GT(" b - total kbytes B - kbytes available for use")); writeln (DI_GT(" u - used kbytes c - calculated kbytes in use")); writeln (DI_GT(" f - kbytes free v - kbytes available")); writeln (DI_GT(" p - percentage not avail. for use 1 - percentage used")); writeln (DI_GT(" 2 - percentage of user-available space in use.")); writeln (DI_GT(" i - total file slots (i-nodes) U - used file slots")); writeln (DI_GT(" F - free file slots P - percentage file slots used")); writeln (DI_GT(" s - filesystem name S - filesystem name, full length")); writeln (DI_GT(" t - disk partition type T - partition type, full length")); writeln (DI_GT("See manual page for more options.")); } di-4.47/D/d.README0000644000175000017500000000251413334050206011433 0ustar bllblldi - disk information utility (version 4.32) This code is out of date and has not been updated to work with the latest D compiler. This code is out of date and has not been updated to match the current version of the C code. This code is in development. It is only included here as an example on how to use 'mkconfig' with the D language. 2012-10-19: gdc not tested. paths are not canonacalized. 2011-11-18: the code will not link without the second set of unittest blocks in options.d. No idea why. Apparently some sort of bug due to ???. 2012-1-17: Debian gdc-4.6.2-4 : same issue. 2012-1-26: FreeBSD : loss of precision somewhere and the values for zottas (and hence yobis) gets messed up. Got: 999999999999999983222784 Instead of: 1000000000000000000000000 This occurs with gcc-4.2.1 also, so it is a gcc bug on FreeBSD. Zones are not working; don't have a D compiler on Solaris. CHANGES 4.32 [18 Oct 2012] Change getErrno to errno. Rearranged diskpart.d class def. Cleanup. 4.31 [20 Nov 2011] Most command line arguments are working. Updated build system to mkconfig-1.19 COPYRIGHT Copyright 2011 Brad Lanam, Walnut Creek, CA, USA di-4.47/D/digetoptn.d0000644000175000017500000007045013334050206012477 0ustar bllbll// written in the D programming language module digetoptn; import std.variant; import std.string; import std.conv : to; debug (1) { import std.stdio; } version (unittest) { import std.stdio; import std.math; } import config; enum string endArgs = "--", longOptStart = "--"; enum char shortOptStart = '-', argAssign = '='; // enum getoptType {} doesn't seem to work. enum ubyte GETOPTN_LEGACY = 0, GETOPTN_MODERN = 1; alias ubyte getoptType; enum ubyte GETOPTN_BOOL = 1, GETOPTN_STRING = 2, GETOPTN_BYTE = 3, GETOPTN_SHORT = 4, GETOPTN_INT = 5, GETOPTN_LONG = 6, GETOPTN_DOUBLE = 7, GETOPTN_REAL = 8, GETOPTN_ALIAS = 9, GETOPTN_FUNC_NOARG = 10, GETOPTN_FUNC_ARG = 11, GETOPTN_IGNORE = 12; private struct ArgInfo { string arg; string argval; int asidx; // for short options; current position in arg str int avidx; // for short options; start of arg val size_t alen; bool longOptFlag; bool attachedArg; bool haveArg; }; struct OptInfo { getoptType otype; void * optval; void delegate (string option, string argval) odg; }; void goinit (ref OptInfo[string] oiaa, string option, getoptType otype, void *optval, void delegate (string option, string argval) odg) { OptInfo oi = { otype: otype, optval: optval, odg: odg }; oiaa[option] = oi; } int getoptn (getoptType gtype, string[] allargs, OptInfo[string] opts) { ArgInfo ainfo; int rv; debug (1) { foreach (k, arg; allargs) { writefln ("getoptn:args:%d:%s:", k, arg); } } with (ainfo) { outerfor: for (auto aidx = 1; aidx < allargs.length; ++aidx) { arg = allargs[aidx]; argval = null; attachedArg = false; haveArg = false; if (allargs.length > aidx + 1) { argval = allargs[aidx + 1]; } asidx = 1; avidx = 2; if (arg[0] != shortOptStart || arg == endArgs) { if (arg == endArgs) { ++aidx; } debug (1) { writefln ("getoptn:nomore:aidx:%d:", aidx); } rv = aidx - 1; // end of loop adds one break outerfor; } int rc = 0; longOptFlag = false; if (arg[0..2] == longOptStart) { longOptFlag = true; } alen = arg.length; // check if there's an = assignment... auto ival = indexOf (arg, argAssign); if (ival >= 0) { alen = ival; } debug (1) { writefln ("getoptn:%d:%s:%s:", aidx, arg, arg[0..alen]); } innerwhile: while (asidx < arg.length && arg[asidx] != '\0') { debug (1) { writefln ("getoptn:aidx:%d:asidx:%d:alen:%d:avidx:%d:arg:%s:", aidx, asidx, arg.length, avidx, arg); } rc = checkOption (gtype, ainfo, arg[0..alen], opts); debug (1) { writefln ("getoptn:co:rc:%d", rc); } rv = aidx; // end of loop adds one // if the option had an argument, process the next arg // otherwise, it was a boolean, and asidx is used. if (rc != 0) { aidx += rc - 1; // increment by rc less one, for loop will inc again rv = aidx; // end of loop adds one if (haveArg) { break innerwhile; } } // handles boolean --arg if (longOptFlag || gtype == GETOPTN_MODERN) { debug (1) { writefln ("getoptn:break inner:"); } break innerwhile; } ++asidx; ++avidx; } // while } // for } // with debug (1) { writefln ("getoptn:exit:%d:rv:%d", allargs.length, rv + 1); } return rv + 1; } private: version (unittest) { mixin template MgetoptTest(T) { void test (getoptType gtype, string l, bool expok, T[] res, T init, T[] expected, OptInfo[string] opts, string[] a, int wantrc) { for (auto i = 0; i < 4; ++i) { res[i] = init; } int idx; int fail = 0; ++tcount; a = ["dummy"] ~ a; try { idx = getoptn (gtype, a, opts); for (auto i = 0; i < 4; ++i) { if (expected[i] != res[i]) { fail = 1; debug (1) { writefln (" getoptn: %d: exp:%s:res:%s:", i, expected[i], res[i]); } } } if (idx != wantrc) { fail = 2; debug (1) { writefln (" getoptn:idx:%d:want:%d:", idx, wantrc); } } if (! expok) { fail = 3; debug (1) { writefln (" getoptn: expected failure"); } } } catch (Exception e) { if (expok) { writefln (" getoptn: expected success; got: %s", e.msg); fail = 4; } } if (fail) { ++failures; writefln ("# %s: fail: %s", testname, l); } } } } // for getopt(); unittest { int failures; int tcount; bool[4] rb; int[4] ri; long[4] rl; double[4] rd; real[4] rr; string testname = "getopt"; mixin MgetoptTest!bool tbool; mixin MgetoptTest!int tint; mixin MgetoptTest!double tdouble; OptInfo[string] opta; goinit (opta, "-a", GETOPTN_BOOL, cast(void *) &rb[0], null); goinit (opta, "-b", GETOPTN_BOOL, cast(void *) &rb[1], null); goinit (opta, "-c", GETOPTN_BOOL, cast(void *) &rb[2], null); goinit (opta, "-d", GETOPTN_BOOL, cast(void *) &rb[3], null); tbool.test (GETOPTN_LEGACY, "boolean bundled, no args", true, rb, false, [false,false,false,false], opta, [], 1); tbool.test (GETOPTN_LEGACY, "boolean bundled, all", true, rb, false, [true,true,true,true], opta, ["-abcd"], 2); tbool.test (GETOPTN_LEGACY, "boolean separate, all", true, rb, false, [true,true,true,true], opta, ["-a", "-b", "-c", "-d"], 5); tbool.test (GETOPTN_LEGACY, "boolean separate, bc", true, rb, false, [false,true,true,false], opta, ["-b", "-c"], 3); tbool.test (GETOPTN_LEGACY, "boolean separate, ad", true, rb, false, [true,false,false,true], opta, ["-a", "-d"], 3); tbool.test (GETOPTN_LEGACY, "boolean unrecognized option: bundled", false, rb, false, [true,true,true,true], opta, ["-abxd"], 0); OptInfo[string] optb; goinit (optb, "--testa", GETOPTN_BOOL, cast(void *) &rb[0], null); goinit (optb, "--testb", GETOPTN_BOOL, cast(void *) &rb[1], null); goinit (optb, "--testc", GETOPTN_BOOL, cast(void *) &rb[2], null); goinit (optb, "--testd", GETOPTN_BOOL, cast(void *) &rb[3], null); tbool.test (GETOPTN_LEGACY, "boolean long option", true, rb, false, [true,false,false,true], optb, ["--testa", "--testd"], 3); tbool.test (GETOPTN_LEGACY, "boolean check return idx", true, rb, false, [true,true,true,true], opta, ["-abcd"], 2); OptInfo[string] opte; goinit (opte, "-a", GETOPTN_INT, cast(void *) &ri[0], null); goinit (opte, "-b", GETOPTN_INT, cast(void *) &ri[1], null); goinit (opte, "-c", GETOPTN_INT, cast(void *) &ri[2], null); goinit (opte, "-d", GETOPTN_INT, cast(void *) &ri[3], null); tint.test (GETOPTN_LEGACY, "int separate, ad", true, ri, 0, [1,0,0,2], opte, ["-a", "1", "-d", "2"], 5); tint.test (GETOPTN_LEGACY, "int attached, ad", true, ri, 0, [1,0,0,2], opte, ["-a1", "-d2"], 3); tint.test (GETOPTN_LEGACY, "int non option stop arg", true, ri, 0, [1,0,0,0], opte, ["-a", "1", "3", "-d", "2"], 3); tint.test (GETOPTN_LEGACY, "int -- stop arg", true, ri, 0, [1,0,0,0], opte, ["-a", "1", "--", "-d", "2"], 4); tint.test (GETOPTN_LEGACY, "int attached non option stop arg", true, ri, 0, [1,0,0,0], opte, ["-a1", "3", "-d", "2"], 2); tint.test (GETOPTN_LEGACY, "int attached separate", true, ri, 0, [1,0,0,2], opte, ["-a1", "-d", "2"], 4); tint.test (GETOPTN_LEGACY, "int missing", false, ri, 0, [1,0,0,9], opte, ["-a1", "-d"], 0); OptInfo[string] optf; goinit (optf, "--testa", GETOPTN_INT, cast(void *) &ri[0], null); goinit (optf, "--testb", GETOPTN_INT, cast(void *) &ri[1], null); goinit (optf, "--testc", GETOPTN_INT, cast(void *) &ri[2], null); goinit (optf, "--testd", GETOPTN_INT, cast(void *) &ri[3], null); tint.test (GETOPTN_LEGACY, "int long options", true, ri, 0, [1,0,0,2], optf, ["--testa", "1", "--testd", "2"], 5); tint.test (GETOPTN_LEGACY, "int unrecognized long option", false, ri, 0, [999,0,0,999], optf, ["--testz", "1", "--testd", "2"], 0); tint.test (GETOPTN_LEGACY, "int unrecognized short option", false, ri, 0, [998,0,0,998], optf, ["-x", "1", "--testd", "2"], 0); if (failures > 0) { write ("unittest: digetopt: getoptn: "); writefln ("failed: %d of %d", failures, tcount); } } int checkOption (getoptType gtype, ref ArgInfo ainfo, string chkarg, OptInfo[string] opts) { string tchk = to!string(shortOptStart) ~ to!string(chkarg[ainfo.asidx]); debug (1) { writefln ("chk:%s:%s:%d", chkarg, tchk, opts.length); foreach (k, v; opts) { writefln (" chk:%s:", k); } } if (chkarg in opts || tchk in opts) { OptInfo opt; if (chkarg in opts) { opt = opts[chkarg]; debug (1) { writefln ("chk:found:%s:", chkarg); } } if (tchk in opts) { debug (1) { writefln ("chk:found:%s:", tchk); } opt = opts[tchk]; } if (opt.otype == GETOPTN_IGNORE) { debug (1) { writefln ("chk:ignore"); } return 1; } else if (opt.otype == GETOPTN_ALIAS) { debug (1) { writefln ("chk:alias:%s:", *(cast(string*)opt.optval)); } ainfo.asidx = 1; return checkOption (gtype, ainfo, *(cast(string*)opt.optval), opts); } else { debug (1) { writefln ("chk:do process"); writefln ("chk:proc:%s:%s:%d", ainfo.arg, chkarg, ainfo.asidx); } return processOption (gtype, ainfo, opt); } } string s = "Unrecognized option: " ~ ainfo.arg; throw new Exception(s); return 0; } version (unittest) { int docoTest (T) (getoptType gtype, string[] a, OptInfo[string] opts, bool expok, T init, ref T res, T expres, int expret, ref int rv) { int rc; int fail; ArgInfo ainfo; res = init; with (ainfo) { arg = a[0]; argval = null; attachedArg = false; haveArg = false; if (a.length > 1) { argval = a[1]; } asidx = 1; avidx = 2; alen = arg.length; auto ival = indexOf (arg, argAssign); if (ival >= 0) { alen = ival; } longOptFlag = false; if (arg[0..2] == longOptStart) { longOptFlag = true; } } try { rc = checkOption (gtype, ainfo, ainfo.arg[0..ainfo.alen], opts); rv = rc; if (rc != expret) { fail = 2; } if (expres != res) { fail = 1; } if (! expok) { fail = 3; } } catch (Exception e) { if (expok) { writefln (" getoptn: expected success; got: %s", e.msg); fail = 4; } } return fail; } mixin template MCOTest (T) { void test (T) (getoptType gtype, string label, string[] a, OptInfo[string] opts, bool expok, T init, ref T res, T expres, int expret) { int rv; ++tcount; auto fail = docoTest!(T) (gtype, a, opts, expok, init, res, expres, expret, rv); if (fail > 0) { ++failures; writefln ("# %s: fail: %s", testname, label); writefln (" expected ok : %d", expok); writefln (" fail return : %d", fail); writefln (" expected return: %s got %s", expret, rv); writefln (" expected value : %s got %s", expres, res); } } } } unittest { string testname = "chk"; int failures; int tcount; bool rb; mixin MCOTest!bool tbool; string rs; mixin MCOTest!string tstr; OptInfo[string] opta; goinit (opta, "-a", GETOPTN_BOOL, cast(void *) &rb, null); goinit (opta, "-b", GETOPTN_ALIAS, cast(void *) &"-a", null); tbool.test (GETOPTN_LEGACY, "co: alias: single", ["-b"], opta, true, false, rb, true, 1); OptInfo[string] optb; goinit (optb, "-a", GETOPTN_BOOL, cast(void *) &rb, null); goinit (optb, "-b", GETOPTN_ALIAS, cast(void *) &"-a", null); goinit (optb, "-c", GETOPTN_ALIAS, cast(void *) &"-b", null); tbool.test (GETOPTN_LEGACY, "co: alias: double", ["-c"], optb, true, false, rb, true, 1); OptInfo[string] optc; goinit (optc, "-a", GETOPTN_BOOL, cast(void *) &rb, null); goinit (optc, "-b", GETOPTN_ALIAS, cast(void *) &"-a", null); goinit (optc, "--clong", GETOPTN_ALIAS, cast(void *) &"-b", null); tbool.test (GETOPTN_LEGACY, "co: alias: long", ["--clong"], optc, true, false, rb, true, 1); OptInfo[string] optd; goinit (optd, "-a", GETOPTN_STRING, cast(void *) &rs, null); goinit (optd, "-b", GETOPTN_ALIAS, cast(void *) &"-a", null); tstr.test (GETOPTN_LEGACY, "co: alias: arg,=", ["-b=def"], optd, true, "abc", rs, "def", 1); OptInfo[string] opte; goinit (opte, "-a", GETOPTN_STRING, cast(void *) &rs, null); goinit (opte, "--blong", GETOPTN_ALIAS, cast(void *) &"-a", null); tstr.test (GETOPTN_LEGACY, "co: alias: long,arg,=", ["--blong=def"], opte, true, "abc", rs, "def", 1); OptInfo[string] optf; goinit (optf, "--along", GETOPTN_STRING, cast(void *) &rs, null); goinit (optf, "-b", GETOPTN_ALIAS, cast(void *) &"--along", null); tstr.test (GETOPTN_LEGACY, "co: alias: short,arg,=", ["-b=def"], optf, true, "abc", rs, "def", 1); OptInfo[string] optg; goinit (optg, "-a", GETOPTN_STRING, cast(void *) &rs, null); goinit (optg, "-b", GETOPTN_ALIAS, cast(void *) &"-a", null); tstr.test (GETOPTN_LEGACY, "co: alias: arg,sep", ["-b", "def"], optg, true, "abc", rs, "def", 2); OptInfo[string] opth; goinit (opth, "-a", GETOPTN_STRING, cast(void *) &rs, null); goinit (opth, "--blong", GETOPTN_ALIAS, cast(void *) &"-a", null); tstr.test (GETOPTN_LEGACY, "co: alias: long,arg,sep", ["--blong", "def"], opth, true, "abc", rs, "def", 2); OptInfo[string] opti; goinit (opti, "--along", GETOPTN_STRING, cast(void *) &rs, null); goinit (opti, "-b", GETOPTN_ALIAS, cast(void *) &"--along", null); tstr.test (GETOPTN_LEGACY, "co: alias: short,arg,sep", ["-b", "def"], opti, true, "abc", rs, "def", 2); if (failures > 0) { write ("unittest: digetopt: checkOption: "); writefln ("failed: %d of %d", failures, tcount); } } void checkHaveArg (in bool haveArg, in string oa) { if (! haveArg) { string s = "Missing argument for -" ~ oa; debug (1) { writefln ("** throwing %s", s); } throw new Exception(s); } } int processOption (getoptType gtype, ref ArgInfo ainfo, OptInfo opt) { int rc = 0; with (ainfo) { debug (1) { writefln ("## proc:arg:%s:", arg); } // if length != alen there is a =argval // if LEGACY && there's more string and not a boolean, then is argval debug (1) { writefln (" :otype:%d:alen:%d:len:%d:asidx:%d:avidx:%d:arg:%s:", opt.otype, alen, arg.length, asidx, avidx, arg); } if (opt.otype != GETOPTN_BOOL && arg.length != alen) { argval = arg[alen + 1..$]; // -...=val attachedArg = true; haveArg = true; debug (1) { writefln (" :att:=:%s:", argval); } } else if (gtype == GETOPTN_LEGACY && opt.otype != GETOPTN_BOOL && ! longOptFlag && arg.length > avidx) { argval = arg[avidx..$]; // short option -fval attachedArg = true; haveArg = true; debug (1) { writefln (" :att:legacy:%s:", argval); } } else if (opt.otype != GETOPTN_BOOL && argval != null) { haveArg = true; debug (1) { writefln (" :sep:%s:", argval); } } debug (1) { writefln (" :arg:%s:asidx:%d:avidx:%d:att:%d:have:%d:argval:%s:", arg, asidx, avidx, attachedArg, haveArg, argval); } if (opt.otype == GETOPTN_IGNORE) { ++rc; } else if (opt.otype == GETOPTN_BOOL) { *(cast(bool*)opt.optval) = 1 - *(cast(bool*)opt.optval); ++rc; } else if (opt.otype == GETOPTN_ALIAS) { return 1; } else if (opt.otype == GETOPTN_BYTE) { checkHaveArg (haveArg, arg); *(cast(byte*)opt.optval) = to!(byte)(argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_SHORT) { checkHaveArg (haveArg, arg); *(cast(short*)opt.optval) = to!(short)(argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_INT) { checkHaveArg (haveArg, arg); *(cast(int*)opt.optval) = to!(int)(argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_LONG) { checkHaveArg (haveArg, arg); *(cast(long*)opt.optval) = to!(long)(argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_DOUBLE) { checkHaveArg (haveArg, arg); *(cast(double*)opt.optval) = to!(double)(argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_REAL) { checkHaveArg (haveArg, arg); *(cast(real*)opt.optval) = to!(real)(argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_STRING) { checkHaveArg (haveArg, arg); *(cast(string*)opt.optval) = cast(string) argval; if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_FUNC_ARG) { opt.odg (arg, argval); if (! attachedArg) { ++rc; } ++rc; } else if (opt.otype == GETOPTN_FUNC_NOARG) { opt.odg (arg, argval); ++rc; } else { throw new Exception("Unhandled type passed to getopt()"); } } debug (1) { writefln (" :rc:%d:", rc); } return rc; } version (unittest) { int dopoTest (T) (getoptType gtype, string[] a, OptInfo opt, bool expok, T init, ref T res, T expres, int expret, ref int rv) { int rc; int fail; ArgInfo ainfo; res = init; with (ainfo) { arg = a[0]; argval = null; attachedArg = false; haveArg = false; if (a.length > 1) { argval = a[1]; } asidx = 1; avidx = 2; alen = arg.length; auto ival = indexOf (arg, argAssign); if (ival >= 0) { alen = ival; } longOptFlag = false; if (arg[0..2] == longOptStart) { longOptFlag = true; } } try { rc = processOption (gtype, ainfo, opt); rv = rc; if (rc != expret) { fail = 2; } if (expres != res) { fail = 1; } if (! expok) { fail = 3; } } catch (Exception e) { if (expok) { writefln (" getoptn: expected success; got: %s", e.msg); fail = 4; } } return fail; } mixin template MPOTest (T) { void test (T) (getoptType gtype, string label, string[] a, OptInfo opt, bool expok, T init, ref T res, T expres, int expret) { int rv; ++tcount; auto fail = dopoTest!(T) (gtype, a, opt, expok, init, res, expres, expret, rv); if (fail > 0) { ++failures; writefln ("# %s: fail: %s", testname, label); writefln (" expected ok : %d", expok); writefln (" fail return : %d", fail); writefln (" expected return: %s got %s", expret, rv); writefln (" expected value : %s got %s", expres, res); } } } mixin template MPOIntegerTest (T) { void test (string lab, getoptType otype) { T v; void tester (T) (getoptType gtype, string label, string[] a, OptInfo opt, bool expok, T init, ref T res, T expres, int expret) { int rv; ++tcount; auto fail = dopoTest!(T) (gtype, a, opt, expok, init, res, expres, expret, rv); if (fail > 0) { ++failures; writefln ("# %s: fail: %s", testname, label); writefln (" expected ok : %d", expok); writefln (" fail return : %d", fail); writefln (" expected return: %s got %s", expret, rv); writefln (" expected value : %s got %s", expres, res); } } OptInfo opt1 = { otype, cast(void *) &v, null }; tester (GETOPTN_LEGACY, lab ~ " leg,sopt,sep", ["-a", "1"], opt1, true, cast(T) 0, v, cast(T) 1, 2); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,att", ["-a1"], opt1, true, cast(T) 0, v, cast(T) 1, 1); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,=", ["-a=1"], opt1, true, cast(T) 0, v, cast(T) 1, 1); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,miss", ["-a"], opt1, false, cast(T) 0, v, cast(T) 0, 0); tester (GETOPTN_MODERN, lab ~ " mod,sopt,att", ["-a1"], opt1, false, cast(T) 0, v, cast(T) 0, 1); tester (GETOPTN_MODERN, lab ~ " mod,sopt,=", ["-a=1"], opt1, true, cast(T) 0, v, cast(T) 1, 1); OptInfo opt2 = { otype, cast(void *) &v, null }; tester (GETOPTN_MODERN, lab ~ " mod,lopt,=", ["--a=1"], opt2, true, cast(T) 0, v, cast(T) 1, 1); tester (GETOPTN_MODERN, lab ~ " mod,lopt,sep", ["--a", "1"], opt2, true, cast(T) 0, v, cast(T) 1, 2); tester (GETOPTN_MODERN, lab ~ " mod,lopt,miss", ["--a"], opt2, false, cast(T) 0, v, cast(T) 0, 1); tester (GETOPTN_MODERN, lab ~ " mod,lopt,att", ["--a1"], opt2, false, cast(T) 0, v, cast(T) 0, 1); tester (GETOPTN_LEGACY, lab ~ " mod,lopt,att", ["--a1"], opt2, false, cast(T) 0, v, cast(T) 0, 1); } } mixin template MPORealTest (T) { void test (string lab, getoptType otype) { T v; void tester (T) (getoptType gtype, string label, string[] a, OptInfo opt, bool expok, T init, ref T res, T expres, int expret) { int rv; ++tcount; auto fail = dopoTest!(T) (gtype, a, opt, expok, init, res, expres, expret, rv); if (fail > 0) { if (fail == 1 && fabs(expres - res) > 0.000001) { ++failures; writefln ("# %s: fail: %s", testname, label); writefln (" expected ok : %d", expok); writefln (" fail return : %d", fail); writefln (" expected return: %s got %s", expret, rv); } } } OptInfo opt1 = { otype, cast(void *) &v, null }; tester (GETOPTN_LEGACY, lab ~ " leg,sopt,sep", ["-a", "1.25"], opt1, true, cast(T) 0, v, cast(T) 1.25, 2); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,att", ["-a1.25"], opt1, true, cast(T) 0, v, cast(T) 1.25, 1); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,=", ["-a=1.25"], opt1, true, cast(T) 0, v, cast(T) 1.25, 1); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,miss", ["-a"], opt1, false, cast(T) 0, v, cast(T) 0, 0); tester (GETOPTN_MODERN, lab ~ " mod,sopt,att", ["-a1.25"], opt1, false, cast(T) 0, v, cast(T) 0, 1); tester (GETOPTN_MODERN, lab ~ " mod,sopt,=", ["-a=1.25"], opt1, true, cast(T) 0, v, cast(T) 1.25, 1); OptInfo opt2 = { otype, cast(void *) &v, null }; tester (GETOPTN_MODERN, lab ~ " mod,lopt,=", ["--a=1.25"], opt2, true, cast(T) 0, v, cast(T) 1.25, 1); tester (GETOPTN_MODERN, lab ~ " mod,lopt,sep", ["--a", "1.25"], opt2, true, cast(T) 0, v, cast(T) 1.25, 2); tester (GETOPTN_MODERN, lab ~ " mod,lopt,miss", ["--a"], opt2, false, cast(T) 0, v, cast(T) 0, 1); tester (GETOPTN_MODERN, lab ~ " mod,lopt,att", ["--a1.25"], opt2, false, cast(T) 0, v, cast(T) 0, 1); tester (GETOPTN_LEGACY, lab ~ " mod,lopt,att", ["--a1.25"], opt2, false, cast(T) 0, v, cast(T) 0, 1); } } mixin template MPOStringTest (T) { void test (string lab, getoptType otype) { T v; void tester (T) (getoptType gtype, string label, string[] a, OptInfo opt, bool expok, T init, ref T res, T expres, int expret) { int rv; ++tcount; auto fail = dopoTest!(T) (gtype, a, opt, expok, init, res, expres, expret, rv); if (fail > 0) { ++failures; writefln ("# %s: fail: %s", testname, label); writefln (" expected ok : %d", expok); writefln (" fail return : %d", fail); writefln (" expected return: %s got %s", expret, rv); writefln (" expected value : %s got %s", expres, res); } } OptInfo opt1 = { otype, cast(void *) &v, null }; tester (GETOPTN_LEGACY, lab ~ " leg,sopt,sep", ["-a", "abc"], opt1, true, cast(T) "def", v, cast(T) "abc", 2); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,att", ["-aabc"], opt1, true, cast(T) "def", v, cast(T) "abc", 1); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,=", ["-a=abc"], opt1, true, cast(T) "def", v, cast(T) "abc", 1); tester (GETOPTN_LEGACY, lab ~ " leg,sopt,miss", ["-a"], opt1, false, cast(T) "def", v, cast(T) "def", 0); tester (GETOPTN_MODERN, lab ~ " mod,sopt,att", ["-aabc"], opt1, false, cast(T) "def", v, cast(T) "def", 1); tester (GETOPTN_MODERN, lab ~ " mod,sopt,=", ["-a=abc"], opt1, true, cast(T) "def", v, cast(T) "abc", 1); OptInfo opt2 = { otype, cast(void *) &v, null }; tester (GETOPTN_MODERN, lab ~ " mod,lopt,=", ["--a=abc"], opt2, true, cast(T) "def", v, cast(T) "abc", 1); tester (GETOPTN_MODERN, lab ~ " mod,lopt,sep", ["--a", "abc"], opt2, true, cast(T) "def", v, cast(T) "abc", 2); tester (GETOPTN_MODERN, lab ~ " mod,lopt,miss", ["--a"], opt2, false, cast(T) "def", v, cast(T) "def", 1); tester (GETOPTN_MODERN, lab ~ " mod,lopt,att", ["--aabc"], opt2, false, cast(T) "def", v, cast(T) "def", 1); tester (GETOPTN_LEGACY, lab ~ " mod,lopt,att", ["--aabc"], opt2, false, cast(T) "def", v, cast(T) "def", 1); } } mixin template MPOFuncTest (T) { void test (getoptType gtype, string label, string[] a, OptInfo opt, bool expok, ref string res, string expres, int expret) { int rv; ++tcount; auto fail = dopoTest!string (gtype, a, opt, expok, null, res, expres, expret, rv); if (fail > 0) { ++failures; writefln ("# %s: fail: %s", testname, label); writefln (" expected ok : %d", expok); writefln (" fail return : %d", fail); writefln (" expected return: %s got %s", expret, rv); writefln (" expected value : %s got %s", expres, res); } } } } // for processOption() unittest { string testname = "proc"; int failures; int tcount; bool rb; mixin MPOTest!bool tbool; string rs; mixin MPOFuncTest!string tfunc; mixin MPOIntegerTest!byte tibyte; mixin MPOIntegerTest!short tishort; mixin MPOIntegerTest!int tiint; mixin MPOIntegerTest!long tilong; mixin MPORealTest!double trdouble; mixin MPORealTest!real trreal; mixin MPOStringTest!string tsstring; mixin MPOStringTest!(char[]) tschar; OptInfo opta = { GETOPTN_BOOL, cast(void *) &rb, null }; tbool.test (GETOPTN_LEGACY, "bool: leg,sopt,f->t", ["-a"], opta, true, false, rb, true, 1); tbool.test (GETOPTN_LEGACY, "bool: leg,sopt,t->f", ["-a"], opta, true, true, rb, false, 1); OptInfo optb = { GETOPTN_BOOL, cast(void *) &rb, null }; tbool.test (GETOPTN_MODERN, "bool: mod,lopt,t->f", ["--a"], optb, true, false, rb, true, 1); tbool.test (GETOPTN_MODERN, "bool: mod,lopt,f->t", ["--a"], optb, true, true, rb, false, 1); OptInfo optc = { GETOPTN_IGNORE, cast(void *) null, null }; tbool.test (GETOPTN_MODERN, "ingore: mod,lopt,f->t", ["--a"], optc, true, true, rb, true, 1); tibyte.test ("byte", GETOPTN_BYTE); tishort.test ("short", GETOPTN_SHORT); tiint.test ("int", GETOPTN_INT); tilong.test ("long", GETOPTN_LONG); trdouble.test ("double", GETOPTN_DOUBLE); trreal.test ("real", GETOPTN_REAL); tsstring.test ("string", GETOPTN_STRING); tschar.test ("char", GETOPTN_STRING); auto d1 = delegate (string arg, string val) { rs = arg; }; OptInfo optd = { GETOPTN_FUNC_NOARG, cast(void *) rs, d1 }; tfunc.test (GETOPTN_MODERN, "func: mod,noarg", ["-a", "def"], optd, true, rs, "-a", 1); auto d2 = delegate (string arg, string val) { rs = val; }; OptInfo opte = { GETOPTN_FUNC_ARG, cast(void *) rs, d2 }; tfunc.test (GETOPTN_MODERN, "func: mod,arg", ["-a", "def"] , opte, true, rs, "def", 2); if (failures > 0) { write ("unittest: digetopt: processOption: "); writefln ("failed: %d of %d", failures, tcount); } } di-4.47/D/di.d0000644000175000017500000001332413334050206011073 0ustar bllbll// written in the D programming language import std.stdio; import std.string; import config; import options; import dispopts; import diskpart; import display; import dilocale; import diquota; enum string FUSE_FS = "fuse"; void main (string[] args) { Options opts; DisplayOpts dispOpts; bool hasLoopback; initLocale (); auto optidx = getDIOptions (args, opts, dispOpts); auto dps = new DiskPartitions (opts.debugLevel); dps.getEntries (); auto hasPooled = preCheckDiskPartitions (dps, opts); if (optidx < args.length || opts.includeLoopback == false) { getDiskStatInfo (dps); hasLoopback = getDiskSpecialInfo (dps); } if (optidx < args.length) { auto rc = checkFileInfo (dps, opts, hasPooled, args, optidx); } dps.getPartitionInfo (); checkDiskPartitions (dps, opts, hasLoopback); if (opts.quotaCheck) { checkDiskQuotas (dps, opts); } doDisplay (opts, dispOpts, dps, hasPooled); } bool preCheckDiskPartitions (ref DiskPartitions dps, Options opts) { bool hasPooled; foreach (ref dp; dps.diskPartitions) { if (dp.fsType == "zfs" || dp.fsType == "advfs") { dp.isPooledFS = true; hasPooled = true; } if (! dp.isRemote && dp.fsType[0..2] == "nfs") { dp.isRemote = true; } if (opts.localOnly && dp.isRemote) { dp.printFlag = dp.DI_PRINT_IGNORE; } checkIncludeList (dp, opts); if (opts.excludeList.length > 0) { if (opts.excludeList.get (dp.fsType, false) || (dp.fsType[0..3] == FUSE_FS && opts.excludeList.get (FUSE_FS, false))) { dp.printFlag = dp.DI_PRINT_EXCLUDE; } } } return hasPooled; } void checkIncludeList (ref DiskPartitions.DiskPartition dp, Options opts) { if (opts.includeList.length > 0) { if (dp.printFlag != dp.DI_PRINT_BAD && dp.printFlag != dp.DI_PRINT_OUTOFZONE && opts.includeList.get (dp.fsType, false) || (dp.fsType[0..3] == FUSE_FS && opts.includeList.get (FUSE_FS, false))) { dp.doPrint = true; } else { dp.doPrint = false; } } } void checkDiskPartitions (ref DiskPartitions dps, Options opts, bool hasLoopback) { foreach (ref dp; dps.diskPartitions) { dp.doPrint = true; if (dp.printFlag == dp.DI_PRINT_EXCLUDE || dp.printFlag == dp.DI_PRINT_BAD || dp.printFlag == dp.DI_PRINT_OUTOFZONE) { dp.doPrint = false; /* -a flag does not affect these */ continue; } if (dp.printFlag == dp.DI_PRINT_IGNORE || dp.printFlag == dp.DI_PRINT_SKIP) { dp.doPrint = opts.displayAll; continue; } dp.checkPartSizes; if (dp.printFlag == dp.DI_PRINT_OK) { if (dp.totalBlocks <= 0.0) { dp.printFlag = dp.DI_PRINT_IGNORE; dp.doPrint = opts.displayAll; } } if (hasLoopback && opts.includeLoopback == false) { if (dp.isLoopback) { dp.printFlag = dp.DI_PRINT_IGNORE; dp.doPrint = opts.displayAll; } } checkIncludeList (dp, opts); } } void getDiskStatInfo (ref DiskPartitions dps) { C_ST_stat statBuf; foreach (ref dp; dps.diskPartitions) { if (dp.printFlag == dp.DI_PRINT_EXCLUDE || dp.printFlag == dp.DI_PRINT_BAD || dp.printFlag == dp.DI_PRINT_OUTOFZONE) { continue; } dp.st_dev = dp.DI_UNKNOWN_DEV; if (stat (toStringz (dp.name), &statBuf) == 0) { dp.st_dev = cast(uint) statBuf.st_dev; } } } bool getDiskSpecialInfo (ref DiskPartitions dps) { C_ST_stat statBuf; bool hasLoopback; foreach (ref dp; dps.diskPartitions) { if (dp.name[0] == '/' && stat (toStringz(dp.special), &statBuf) == 0) { dp.sp_dev = cast(uint) statBuf.st_dev; dp.sp_rdev = cast(uint) statBuf.st_rdev; /* Solaris's loopback device is "lofs" */ /* linux loopback device is "none" */ /* linux has rdev = 0 */ /* DragonFlyBSD's loopback device is "null" */ /* DragonFlyBSD has rdev = -1 */ /* solaris is more consistent; rdev != 0 for lofs */ /* solaris makes sense. */ if ((dp.fsType == "lofs" && dp.sp_rdev != 0) || dp.fsType == "null" || dp.fsType == "none") { dp.isLoopback = true; hasLoopback = true; } else { dp.sp_dev = 0; dp.sp_rdev = 0; } } } return hasLoopback; } bool checkFileInfo (ref DiskPartitions dps, Options opts, bool hasPooled, string[] args, int optidx) { C_ST_stat statBuf; foreach (ref dp; dps.diskPartitions) { if (dp.printFlag == dp.DI_PRINT_OK) { dp.printFlag = dp.DI_PRINT_IGNORE; } } if (hasPooled) { size_t[] sortIndex; sortIndex.length = dps.diskPartitions.length; for (int i = 0; i < sortIndex.length; ++i) { sortIndex[i] = i; } dps.sortPartitions (sortIndex, "s"); } for (auto i = optidx; i < args.length; ++i) { auto fd = open (toStringz(args[i]), O_RDONLY | O_NOCTTY); C_NATIVE_int rc; if (fd < 0) { rc = stat (toStringz(args[i]), &statBuf); } else { rc = fstat (fd, &statBuf); close (fd); } if (rc == 0) { foreach (ref dp; dps.diskPartitions) { if (opts.debugLevel > 5) { writefln ("check %s against %s: %d %d", args[i], dp.name, cast(uint) statBuf.st_dev, dp.st_dev); } if (dp.st_dev != dp.DI_UNKNOWN_DEV && cast(uint) statBuf.st_dev == dp.st_dev && ! dp.isLoopback) { dp.printFlag = dp.DI_PRINT_FORCE; break; } } // for each partition } // if stat of file worked } // for each command line argument return true; } di-4.47/di.spec0000755000175000017500000000316213334050206011421 0ustar bllbllName: di Version: 4.46 Release: 1%{?dist} Summary: 'di' is a disk information utility, displaying everything (and more) that your 'df' command does. Group: System Environment/Base License: zlib/libpng URL: https://gentoo.com/di/ Source0: https://sourceforge.net/projects/diskinfo-di/files/di-%{version}.tar.gz/download Source1: https://gentoo.com/di/di-%{version}.tar.gz Source2: http://www.fossies.org/unix/misc/di-%{version}.tar.gz BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) # Build requires: cat cp grep ln msgfmt mv rm sed sort test uname tr wc #BuildRequires: #Requires: %description 'di' is a disk information utility, displaying everything (and more) that your 'df' command does. It features the ability to display your disk usage in whatever format you prefer. It also checks the user and group quotas, so that the user sees the space available for their use, not the system wide disk space. It is designed to be portable across many platforms and is great for heterogenous networks. %prep %setup -q %build make -e LOCALEDIR=/usr/share/locale %install test -d $RPM_BUILD_ROOT || mkdir $RPM_BUILD_ROOT test -d $RPM_BUILD_ROOT/usr || mkdir $RPM_BUILD_ROOT/usr make -e prefix=$RPM_BUILD_ROOT/usr install %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root,-) %doc README LICENSE MANIFEST /usr/bin/di /usr/bin/mi /usr/share/locale/de/LC_MESSAGES/di.mo /usr/share/locale/en/LC_MESSAGES/di.mo /usr/share/locale/es/LC_MESSAGES/di.mo /usr/share/man/man1/di.1.gz # For Mandriva 2011, change di.1.gz to di.1.xv %changelog di-4.47/README0000644000175000017500000010110013334050206011015 0ustar bllblldi - disk information utility (version 4.47) Website: https://gentoo.com/di/ SourceForge: https://sourceforge.net/projects/diskinfo-di/ CONTENTS Description Installation Tcl Perl Bugs and Known Issues Requirements Porting Information Changes Acknowledgements Copyright DESCRIPTION 'di' is a disk information utility, displaying everything (and more) that your 'df' command does. It features the ability to display your disk usage in whatever format you prefer. It is designed to be highly portable. Great for heterogenous networks. INSTALLATION To build: make -e dioptions.dat # Edit dioptions.dat and change it # to set your preferences. # Add your CC, CFLAGS and LDFLAGS settings. # This file will not be removed and can be reused # for the next release. make -e make -e install Example to change compiler and prefix: CC=gcc prefix=/opt/bin make -e If you don't have a bourne shell compatible shell, Try building with perl: make -e all-perl The CC, CFLAGS, CPPFLAGS, prefix, LDFLAGS, and LIBS environment variables may be set and exported prior to running make. This will override any settings in 'dioptions.dat'. The LOCALEDIR environment variable defaults to ${prefix}/share/locale. The installation uses the INSTALL_DIR (default ${prefix}), INSTALL_BIN_DIR ($INSTALL_DIR/bin), and INST_LOCALEDIR ($INSTALL_DIR/share/locale) environment variables for installation. The internationalization files are automatically built and installed if your system supports internationalization. Windows installation: Alternative 1 - uses pre-built config.win or config.mingw Cygwin gcc: make -e windows-gcc (uses cygwin API) MinGW: mingw32-make -e MAKE=mingw32-make CC=gcc windows-mingw (uses windows API) Msys2: make WINAPI=T NO_PIE=yes Alternative 2 - builds a new config.h file (Cygwin). make -e NO_PIE=yes CC=gcc make -e NO_PIE=yes CC=gcc WINAPI=T # windows API Alternative 3 - builds a new config.h file (MSys) # make sure your PATH is set properly make -e _MKCONFIG_SHELL=bash WINAPI=T NO_PIE=yes CC=gcc You may need to change _lib_GetDiskFreeSpaceEX to 0 in the config.h file for older windows systems. HP-UX: Some versions of gcc on HP-UX break the include files. If you see: header: rpc/rpc.h ... no try: env CC=gcc CFLAGS="-D_LABEL_T" make -e On some HP-UX systems, quotactl isn't declared. If you want quota support, make sure config.h has: #define _lib_quotactl 1 #define _args_quotactl 4 #define _c_arg_1__quotactl int #define _c_arg_2__quotactl char * #define _c_arg_3__quotactl int #define _c_arg_4__quotactl caddr_t #define _quotactl_pos_1 0 #define _quotactl_pos_2 1 64-bit: env CFLAGS="-z +Z +DD64" LDFLAGS="+DD64" make -e 64-bit gcc: env CC=gcc CFLAGS="-fPIC -mlp64 -D_LABEL_T" \ LDFLAGS="-mlp64 -L/usr/lib/hpux64" make -e 32-bit: env CFLAGS="-z +Z +DD32" LDFLAGS="+DD32" make -e 32-bit gcc: env CC=gcc CFLAGS="-fPIC -milp32 -D_LABEL_T" \ LDFLAGS="-milp32 -L/usr/lib/hpux32" make -e Bundled cc: cd C;make hpux-cc Tru64: export BIN_SH=svr4 beforehand. DragonFlyBSD: If quotas are not turned on in the kernel (/boot/loader.conf), the vquotactl interface will not be configured into di. The default build available from DragonFly dports does not have the vquotactl interface turned on. Installation Permissions: Some old systems (Sys V variants) only allow root to read the mount table. In SysV.4 and Solaris, the mount command would reset the permissions to be root readable only (fixed in Solaris 7). If this is needed on your system, do: make installperms TCL The Tcl extension provides access to the di utility via the [diskspace] command. To build: cd C; make -e tcl-sh Windows Cygwin: cd C; make CC=gcc NO_PIE=yes tcl-sh Windows Msys: cd C; make WINAPI=T NO_PIE=yes tcl-sh See C/di-example.tcl for a usage example. PERL The Perl extension provides access to the di utility via the [Filesys::di::diskspace] command. To build: # perl-perl can be substituted for perl-sh to use the # perl configuration script instead of the shell # configuration scripts. cd C; make -e perl-sh; cd Perl; make PREFIX=your-prefix install Windows Cygwin: # I had to install libcrypt-devel for 'crypt.h'. # No idea why perl would require that. # perl-perl is faster than perl-sh. cd C; make CC=gcc NO_PIE=yes perl-perl Windows Msys: # untested; I don't have mingw perl. cd C; make -e WINAPI=T NO_PIE=yes CC=gcc perl-sh See C/Perl/ex/perl-example.pl for a usage example. BUGS AND KNOWN ISSUES What's Not Tested: - pooled filesystems on Tru64. - I have access to a Tru64 system w/quotas, but there's only one filesystem per pool. - quotas: - MacOSX - No access to users with quotas. - MS VC++ has not been tested in a *very* long while. - A/UX, Cray, UNICOS, Next, Pyramid, SCO Unix, Sequent have not been tested in a *very* long while. Known Issues - quotas: - Solaris ufs requires the quotas file to be readable, or make the di program setuid. Neither recommended. - Linux 2.4 - not working - HP-UX - quotactl() isn't declared. See HP-UX section above. - NetBSD 6 - group quotas can't be fetched by ordinary users (EPERM). If the account is limited by a group quota, it won't be reported. - AIX 7 - Unlike AIX 5, AIX 7 gives a permission denied error when a user tries to get their quota. Could make di suid, but that's not a good idea. - pooled filesystems: - hammer: the usage reported for pseudo-filesystems is the usage for the main pool. Therefore the total used and size will be wrong. - btrfs: there's no way to identify the pools. - cygwin with clang does not work. - the pre-configured builds have not been tested in a while. Send bug reports along with the output from 'di -A -a -X 5', output from your standard df command (as verbose as possible), mkconfig.log, mkconfig_env.log, di.env, and config.h to: brad.lanam.di_at_gmail.com If the 'config.h' doesn't get set up correctly, please let me know. E-mail me the incorrect (and corrected if possible) config.h file, and any other information as appropriate. REQUIREMENTS bourne/ksh/bash shell C compiler awk (mawk/nawk/gawk) make cat chmod ln mkdir mv rm sed test mkconfig.sh: a bourne compatible shell that supports shell functions, standard output from 'set'. cat egrep expr grep rm sed sort test mkconfig.pl: cat perl rm mksetopt.sh: mv rm sed test NLS: msgfmt sed runtests.sh (not a requirement for building or installing): ar cat cp dc diff env expr egrep mv rm sed sort test tr PORTING di 4.47 has been tested on the following platforms: Linux RedHat 7.3 (gcc) CentOS 3.9 (gcc) Fedora 7 (gcc) Fedora 27 (gcc) MX Linux 17.1 (gcc, clang) BSD DragonflyBSD 4.4 (gcc) FreeBSD 7.0 (cc) FreeBSD 11.0 (clang) NetBSD 1.62 (cc) NetBSD 2.0 (cc) NetBSD 7.0.1 (gcc) OpenBSD 4.4 (gcc) Windows Msys2 (gcc) Cygwin (gcc) Other AIX 7.1 (gcc) Mac OS X 10.12.6 (clang) QNX 6.5 (cc) SCO SV 6.0.0 (cc) Solaris 11/x86 (cc12.3) Solaris 10/sparc (cc12.3) Solaris 9/x86 (gcc3) Tru64 5.1B (cc) UnixWare 7.1.4 (cc) di has been ported to the following systems in the past: A/UX, AIX, BeOS, BSD, BSDI, Convex, Cray UNICOS, Cray UNICOS/mk, DragonflyBSD, FreeBSD, Haiku, HP/UX, Linux, MacOSX, MirOS, NetBSD, Next, OpenBSD, OS/2, OSF/1, Pyramid, SCO OpenServer, SCO Unix, Sequent Dynix and PT/x, SGI Irix, Solaris, SunOS, Syllable, System V.3, System V.4, Tru64, ULTRIX, UnixWare, VMS, Windows, Xenix CHANGES 4.47 [2018-8-12] Fixed bugs located by scan.coverity.com. This should fix a numeric sort bug. Update mkconfig to version 2.0.0 and make changes to support it. Get perl extension build working again. 4.46 [2018-4-11] Tcl: Fix bad allocation. Tcl: Raise errors rather than exiting. Exit program when incorrect options are specified. Update mkconfig to version 1.31. Add missing mkconfig/runtests.sh. 4.45 [2018-4-10] Update mkconfig to version 1.30 to fix modern libintl.h/printf tests. 4.44 [2017-5-23] Fixed check of exabyte sized filesystems. The signed check now only checks for -1 and -2; there could still be situations where the overflow exactly matches these values. Added faster method for windows check for missing removable filesystems. 4.43 [2016-8-9] Cleaned up some compiler warnings. Fixed memory allocation problem. Tcl interface fixes 4.42 [2016-2-22] Fixed a parsing bug in the Tcl interface. Added a Perl interface. 4.41 [2016-1-24] Fixed bug specifying more than one filesystem on the command line. Added sort by free space, total space. Updated manual page: missing, new sort options. 4.40 [2016-1-22] Updated the Tcl interface to return the 'display' key as a list. 4.39 [2016-1-22] Added a Tcl interface. Fixed CSV header to honor -n flag. Added -C, --csv-tabs to output CSV with tabs. Fixes for mingw (build, long double can't be printf'd). Update mkconfig to version 1.27 4.38 [2016-1-6] Honor FreeBSD NO_PIE environment variable. Update mkconfig to version 1.26 4.37 [2015-10-18] Fixed a problem when processing the DI_ARGS environment variable. Hardened compiler options: reference: http://wiki.debian.org/Hardening Code cleanup to fix compiler warnings. 4.36 [2015-5-18] Updated test for NFS remote filesystems. 4.35 [2014-2-15] Updates for Irix. Fixed a bug when -I/-x were specified in addition to a filespec. Updated build system to mkconfig-1.24 4.34 [2013-1-19] When a filename is specified on the command line, attempt to choose the best filesystem to display when there are multiple choices. Error check realpath() return value. Only canonicalize device names if it has a trailing uuid. Add -R (--dont-resolve-symlink) option to turn off canonicalization. Clean up code to fix clang warnings. Minor updates to support Xenix. 4.33 [2012-11-15] Recoded quota handling as information was improperly losing precision. Added support for dragonflybsd's vquotactl(). Added support for hammer-pfs (pooled filesystems). Exclude rootfs, devfs, procfs, kernfs, ptyfs and devtmpfs by default. Minor updates to main makefile. Minor directory rearrangement for os-specific config files. Fixed possible case of systems with a memcpy macro and no library function. Make sure D tests are not run. HP-UX bcc seems to support long long after all. This is on 11.11. Maybe the older versions did not? No access to 10.20. Updated build system to mkconfig-1.22. 4.32 [2012-10-21] Exclude rootfs by default. Canonacalize the special device name. Updated quota code for NetBSD 6 (quota_open() et.al.). Fixed AIX group quota check. Fixed AIX 7 support. Unlike AIX 5, AIX 7 gives a permission denied error when a user tries to get their quota. Updated build system to mkconfig-1.21. 4.31 [2011-11-20] Filesystems that would return a 'Permission Denied' are not displayed at all, even with -a. Fixed totals with pooled filesystems (when main pool not mounted). Fixed a very rare divide by 0 condition. Code cleanup. Updated build system to mkconfig-1.19. 4.30 [2011-10-8] Added support for long options. GNU df compatible long options have been added and are processed appropriately. Removed program name settings from Makefile and di.c. Minor code cleanup. Added hp-ux bundled cc static target. Updated build system to mkconfig-1.18. 4.29 [2011-9-30] Added the -c option to output in CSV format (request by H.Merijn Brand). Fixed bB format titles. Added checks to make sure required programs for build/install are present. Various fixes for HP-UX, ULTRIX, SCO OpenServer, UnixWare. Added pre-generated config.h files for ULTRIX. Updated build system to mkconfig-1.17. 4.28 [2011-9-11] Fixed compiler warnings for 64-bit. Added support for DragonFlyBSD. Updated build system to mkconfig-1.15 (Solaris 2.6 fixes; pdksh allowed) 4.27 [2010-12-29] Rearranged directory structure. Added support for long double to hold zettas and yottas. Added support for the windows digital mars c compiler. Added a fix for windows removable drives. Rewrote snprintf macros as they didn't work on MacOSX. Fixed quotactl argument for systems w/o QCMD macro. Check for type of structure members and call the correct xdr function. Many minor fixes for compiler warnings. Fixed Makefiles to redirect 'cd' output (CDPATH). Updated build system to mkconfig 1.11. 4.26 [2010-7-25] Fix FreeBSD 5 panic when trying to get quotas on devfs. Updated build system to mkconfig-1.10. 4.25 [2010-7-4] Added support for quotas. Fix for Tru64 advfs pools. Fixed loopback filesystem (lofs/none) exclusion; enabled for all systems. Added an optional DI_LOCALE_DIR environment variable to point to the locale directory where di's messages are installed. Changed the sort to use strcoll() rather than strcmp(). Updated build system to mkconfig-1.6. Removed turnoffwinapi.sh, hasnls.sh & turnoffnls.sh and updated to use new build system tools. Added dioptions.dat to control options. More fixes for totals in a pooled/non-pooled mix when pooled filesystems are not displayed. 4.24 [2010-5-14] Added spanish translation (David Sastre). Update some column widths to help support spanish. Check mbrlen() return code. Fix turnoffnls.sh (broken during rewrite). Add missing defines in static configurations. Added turnoffwinapi.sh for cygwin. 4.23 [2010-5-10] Fix internationalized strings to line up properly. Changed default block size output to -dH (scaled format 2). Brought up to date for AIX, Tru64. Added support for MinGW on Windows. Added support for QNX. Solaris 8 x86 w/gcc3 currently fails. 4.22 [2010-5-2] Updated to use mkconfig 1.3. Fixes problem with linking in unneeded libraries. Replaced hasnls program with a shell script. 4.21 [2010-4-11] Fixed features/turnoffnls.sh. Makefile cleanup (Mike Frysinger). 4.20 [2010-3-7] Added VMS. Fixed totals for pooled filesystems, again (incorrect sort, skipped fs, pooled fs on command line). Remove initial build script and use new mkconfig. Rewrite makefile. Moved mkconfig to its own package. Move regression tests into tests.d directory. Minor updates to manual page. 4.19 [2010-2-1] Fix totals to add up when using small block sizes. Fix totals for mixed pooled and non-pooled filesystems. Add fix for automounted directories: https://bugzilla.redhat.com/show_bug.cgi?id=497830 (df) Builds on BSD 4.3. Changed format of config.h file. Code cleanup. 4.18 [2009-11-29] Code cleanup. The default configuration method has been changed to use a shell script. The perl configuration script is still available (./Build -mkpl). 4.17 [2009-11-22] Totals have been changed to add up whatever filesystems are displayed. This is more intuitive for the user. It is up to the user to exclude read-only filesystems (cdfs, iso9660), memory-based filesystems (memfs, mfs, tmpfs) and user filesystems (fuse*). Excluding the 'fuse' type will exclude all fuse* filesystems. As before, only the main pool of a pooled filesystem is totaled. The build now works on unixware (getmntent is in libgen). The build now works on syllable. The default configuration method has been changed to use the perl script. Removed iffe, as it doesn't support class testing. 4.16 [2009-9-20] Fixed a nested macro issue on Mac OS X 10.6. Fixed bugs with filename arguments. 4.15 [2009-9-17] Fixed filename argument w/non-printing filesystem. Build now works on Haiku. 4.14 [2009-9-10] Code cleanup. Change size labels to match SI standards (1024 vs 1000). Build now works on Debian GNU-kFreeBSD. 4.13 [2008-5-25] Fixed totals to correctly account for pooled filesystems. 4.12 [19 Jan 2008] Change of e-mail addresses. 4.11 [29 May 2007] Fixed minor bug for 'di -sn -t' introduced in 4.10. Code cleanup -- move global variables into local structures. Recoded sorting, added sort by filesystem type. 4.10 [24 Feb 2007] Handle pooled filesystems so that the total space doesn't get added more than once. Compaq Tru64 advfs is untested. 4.9 [2 Nov 2006] Fixed an uninitialized variable used for Solaris zones. Minor fixes to mkconfig.pl. 4.8 [5 Oct 2006] Linux's statvfs() is not POSIX compliant and does not use f_frsize. The correct value is returned in f_bsize. Since there's no way to tell which type of statvfs() is in use, we have to hard-code the logic for linux. This sucks. More minor improvements to mkconfig.pl. Add logic to find the correct msgfmt program to use. 4.7 [23 Sep 2006] Changed the operation of the -a, -x and -I flags so that it is possible to specify -a and still exclude filesystems from the list. Added the -L flag to not check for duplicate filesystems. 4.6 [3 Sep 2006] Improve mkconfig.pl configuration to be more robust, find needed libraries. Improve mkconfig.pl portability. 4.5 [29 Mar 2006] Fix uninitialized variable. Fix manual page formatting. 4.4 [21 Nov 2005] Add zone support for Solaris (-z). Update mkconfig.pl for compatibility w/perl 5.005. 4.3 [29 Oct 2005] Change -P option and POSIXLY_CORRECT environment variable to display POSIX standard output. Add 'a' and '3' format options to display %avail and %free space (request by Bill Poser). Add check and routine to use getvfsstat() for NetBSD 3.x. Add processing of DI_ARGS environment variable. 4.2 [12 Oct 2005] Added -nonls argument to 'Build' to turn off all NLS. Add +DAportable for HP-UX 10.x. Add -qmaxmem=-1 for AIX. Fix compile warning in dilib.c for AIX. Improve tests for libintl.sl for HP-UX. Check /usr/local for libintl.sl also. Version number was inadverdently left as 4.1. 4.1 [6 Aug 2005] Created a perl script as an alternative to iffe to create the config.h file. Internationalization configuration now works for Cygwin, FreeBSD, NetBSD and HP/UX. 4.0 [26 Jul 2005] Metadist is no longer supported; Only the iffe configuration method is now available. Removed -h help flag, changed it to be scaled alternative 1 display to match other 'df' programs. Alias -x to -i to match other 'df' programs. -x will be preferred. Old -x (debug) changed to -X. POSIX -dp flag was broken. Removed. Added -P option. Alias -F to -I for compatibility. Updates to manual page. Internationalization files are now automatically installed if the NLS routines are detected. 3.11 [11 mar 2004] Fixed bug: checking mount options to see if partition was read-only (bsd style get/set/endmntent). 3.10 [26 feb 2004] Added German .po file (Many thanks to Hartmut Haase). Added -64 to Build for 64 bit binaries. Added missing internationalization calls in di.c. 3.9 [25 may 2003] Fixed bug with uninitialized 'dbsstr' variable. iffe: upgraded to 2002-03-06. Don't need to include stdio.h in most di.iffe tests. lib test fixed for cygwin. 3.8 [12 jan 2003] Rewrote block size display processing. It did not match the *BSD implementation of the BLOCKSIZE environment variable. Latest metaconfig (Configure) Add -k alias for -dk. 3.7 [4 sep 2002] Check for initial '/' character in special device name before doing stat(). Otherwise we pick up normal files. Update iffe. Add exa, zetta, yotta support (-de, -dz, -dy). Add support for 1000 byte base block size (and others) (-b option). Add alternative scaled format (-dH, -H). 3.6 [30 jul 2002] Change to use mntctl() in preference to set/get/endmntent() for AIX. AIX: fix to display hostname in special device name for remote mounts. README updated for cygwin Configure/configure problem. Workaround in di.h for cygwin/Configure getopt() problem. Converted all strcpy() to strncpy(). 3.5 [17 jul 2002] Change 'memfs' to 'mfs' for memory file system (FreeBSD). Not added to totals. Added License. Update to use snprintf if available. Update 'Configure' to match 'iffe' build as closely as possible. Fix C code to compile w/non-ansi compiler (HP-UX bundled). Many configuration fixes (hp-ux, aix, et.al.). 3.4 [20 apr 2002] Fix bugs in include/ignore list generation. Rewrite ignore/include lists to allow multiple command line specification of ignore/include lists. Change so -f overrides DIFMT environment variable. Fix bugs in -s command line option. Make more friendly. Add -H (-dh) scaled display format. nfs mounts are always remote. 3.3 [1 apr 2002] Bug fixes for AIX, HP/UX installation. 3.2 [27 feb 2002] Add internationalization code. Update windows code. cleanup. 3.1 [15 nov 2001] Bug fixes for SunOS 4. 3.0 [7 aug 2001] Added getfsstat() for Compaq Tru-64 (and FreeBSD, etc.) systems. Compaq Tru-64 code cleaned up. Thanks to Compaq for their test drive program! More cleanup. Added iffe configuration. 2.4 [12 feb 2001] Fixed so di doesn't statfs() the disks it doesn't need to. Removed fs basetype stuff. Split out disk routines into separate module. Lots of cleanup. Totals: fix to take into account block size of partition. Totals: ignore read-only, partitions not normally printed. Totals: ignore memory filesystems (tmpfs, memfs). 2.3 [24 feb 2000] Modified hints for solaris to do 64 bit compilation. Removed extra libc setting for linux. Added support for BeOS. This required ansi function headers. 2.2 [24 dec 1999] Hints for dec_osf added. Changed HAS_GETMNTINFOFSIZE to be preferred over HAS_GETMNTINFOBSIZE; modified bsdos hints appropriately. Look for include file. 2.1 [24 dec 1999] Added +DAportable for HP-UX. Hints for openbsd added. Made installperm as separate target in makefile. Modified duplicate checking slightly. Changed MNT_NOWAIT to MNT_WAIT. This will work better on FreeBSD. Hopefully will work w/nfs mounts. 2.0 [15 apr 1999] Now uses dist 3.0PL70 for configuration. Duplicate filesystems (automounted) are not displayed. This probably does not work for Digital's advfs. 1.24 [never released] Added Windows w/gcc. The Solaris 2.6 statvfs() bug has a patch out for it. Patch #105572-05 (?). 1.23 [6 jul 1998] Improved Windows. 1.22 [1 jul 1998] Added Windows. Don't know the routines to get the number of file slots or the file system type (FAT12/16/32). Changed default to display megabytes. 1.21 [8 sep 1997] Fixed AIX typo. Linux 2.x 1.20 Added Solaris large file system support. Note that ver 2.6 Beta_Update has a bug in the statvfs() routine, and the non-root available disk space is improperly reported. 1.19 [4 feb 1996] Added mount time, mount options. Link di to the mi command. 1.18 [21 aug 1995] Fixed some ignore/include list problems. Fixed local mount flag for OSF/1. 1.17 [10 aug 1995] Changed block values from unsigned long to doubles so that we can display using different block sizes (-d flag). Added -l flag for local filesystems only. 1.16 [8 aug 1995] Added A/UX [ blemoine@-NOSPAM-atheist.tamu.edu (Brett G. Lemoine) ] Added convex [ "Schilperoort J.W." ] 1.15 [1 aug 1995] Fixed bsdi 1.x and bsdi 2.x. Fragments weren't supported. Fixed FreeBSD 1.x and 2.x; same problem. Changed sco_sl makefile entry. 1.14 [22 jul 1995] Fixed problem with display widths in conjunction with ignore/include lists. 1.13 [17 mar 1995] changed default length of filesystem type field to 7. new debug 'all' format. check for 0 fragment size; replace w/block size if we have it. 1.12 [28 jan 1995] sco nfs 'nothing' fix. freebsd 2.x; better freebsd filesystem types. 1.11 [3 dec 1994] bsdi 1.10 [24 nov 1994] added freebsd. 1.9 [30 aug 1994] makefile fixes. 1.8 [28 may 1994] removed mount option junk. added AIX. 1.7 [2 may 1994] cleaned up sgi in the makefile. changed linux to be w/o need_statfs_defs. solaris cdrom returning all sorts of negative values. T format option. mount options. SunOs filesystem type info. 1.6 [never released] ultrix bug fixes. add dynix to makefile. 1.5 [26 mar 1994] sun had f_bfree instead of f_bavail! xenix, linux, sco -w, -W, -B. fixed width for -f M, -f S. usage. Allow other characters in format string. 1.51 (local, pat@rwing) SunOS *does* support filesystem type info. Its all in the mntent structure, but requires a small bit of work (see source). 1.4 [4 mar 1994] -f B bcopy. solaris cdrom reports -2 for free blocks. 1.3 [3 mar 1994] Command line specification of filenames. sort output. osf/1, ultrix. -F, -f M, -F S. 1.2 [2 mar 1994] # of inodes can be -1L return code for getDiskInfo shouldn't be checked. name of mount point must be maxpathlen. error conditions. pyramid. 1.1 [27 feb 1994] initial release ACKNOWLEDGEMENTS And for their comments/source/manual pages and/or bug fixes, thanks! jjb@NOSPAM-jagware.bcc.com (J.J.Bailey) vogelke@NOSPAM-c-17igp.wpafb.af.mil (Contr Karl Vogel) [pyramid] costales@NOSPAM-ICSI.Berkeley.EDU (Bryan Costales) Mark Neale Pat Myrto [sunOS filesystem type stuff] henrikar@NOSPAM-utctu1.ct.utwente.nl (Henri Karrenbeld) [sgi] Peter Bray gsipe@NOSPAM-pyramid.com (George M. Sipe) [manual page] Jeffrey Mogul [ultrix, osf/1, manual page, new format options] thomas@NOSPAM-idx.kodak.com (Th. Bullinger) [help usage] Seth Theriault [next, tru64] steve@NOSPAM-nshore.org (Stephen J. Walick) [SCO] Gerald Rinske [sgi] Mike Grupenhoff [linux] R.K.Lloyd@NOSPAM-csc.liv.ac.uk [hpux] "William Gibbs" [xenix] Randy Thompson [sequent] eriko@NOSPAM-risc.austin.ibm.com (O'Shaughnessy Erik) [aix] Bill Davidsen [linux, SCO, etc., new format options] fredex@NOSPAM-fcshome.stoneham.ma.us (fred smith) [coherent 4.2.05] bag@NOSPAM-clipper.cs.kiev.ua (Andrey Blochintsev) [bsdi] ginsbach@NOSPAM-spacestar.net (Brian Ginsbach) [netbsd, irix, unicos] et. al. COPYRIGHT Copyright 1994-2018 Brad Lanam, Walnut Creek, CA, USA brad.lanam.di_at_gmail.com https://gentoo.com/di/ di-4.47/tests.d/0000755000175000017500000000000013334050206011530 5ustar bllblldi-4.47/tests.d/disort.sh0000755000175000017500000000564213334050206013402 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'di sort' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ LC_ALL="C" export LC_ALL unset DI_ARGS unset DIFMT dotest () { chkdiff s1 s2 rc=$? if [ $rc -ne 0 ]; then echo "=== s1" cat s1 echo "=== s2" cat s2 fi if [ $rc -ne 0 ]; then grc=$rc fi } for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi tdir=$_MKCONFIG_RUNTOPDIR/$d ( cd $tdir if [ $? -eq 0 ]; then instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 fi ) if [ -x $tdir/di ]; then putsnonl " ${d}" >&5 puts "## regular sort first, then di sort" puts "by special" ${tdir}/di -n -a -f S | sort > s1 ${tdir}/di -n -a -f S -ss > s2 dotest puts "by special reverse" ${tdir}/di -n -a -f S | sort -r > s1 ${tdir}/di -n -a -f S -srs > s2 dotest puts "by special w/total" ${tdir}/di -n -a -f S | sort -t'~' > s1 ${tdir}/di -n -a -f S -ss -t | sed '$d' > s2 dotest puts "by special and mount w/total" ${tdir}/di -n -a -f 'S~M' | sort -t'~' > s1 ${tdir}/di -n -a -f 'S~M' -ssm -t | sed '$d' > s2 dotest puts "by mount" ${tdir}/di -n -a -f M | sort -t'~' > s1 ${tdir}/di -n -a -f M -sm > s2 dotest puts "by mount reverse" ${tdir}/di -n -a -f M | sort -r > s1 ${tdir}/di -n -a -f M -srm > s2 dotest puts "by mount w/total" ${tdir}/di -n -a -f M | sort -t'~' > s1 ${tdir}/di -n -a -f M -sm -t | sed '$d' > s2 dotest puts "by mount and special w/total" ${tdir}/di -n -a -f 'M~S' | sort -t'~' > s1 ${tdir}/di -n -a -f 'M~S' -sms -t | sed '$d' > s2 dotest puts "by type" ${tdir}/di -n -a -f T | sort > s1 ${tdir}/di -n -a -f T -st > s2 dotest puts "by type reverse" ${tdir}/di -n -a -f T | sort -r > s1 ${tdir}/di -n -a -f T -srt > s2 dotest puts "by type w/total" ${tdir}/di -n -a -f T | sort -t'~' > s1 ${tdir}/di -n -a -f T -st -t | sed '$d' > s2 dotest puts "by type and special and mount w/total" ${tdir}/di -n -a -f 'T~S~M' | sort -t'~' > s1 ${tdir}/di -n -a -f 'T~S~M' -stsm -t | sed '$d' > s2 dotest sort -k1 > /dev/null < /dev/null if [ $? = 0 ]; then puts "by type and special and mount reversed 2 and 3" ${tdir}/di -n -a -f 'T~S~M' | sort -t'~' -k1,1 -k2,2r -k3,3r > s1 ${tdir}/di -n -a -f 'T~S~M' -strsm > s2 dotest puts "by type and special and mount reversed 2 " ${tdir}/di -n -a -f 'T~S~M' | sort -t'~' -k1,1 -k2,2r -k3,3 > s1 ${tdir}/di -n -a -f 'T~S~M' -strsrm > s2 dotest fi rm -f s1 s2 if [ $grc -ne 0 ]; then putsnonl "*" >&5 fi else if [ $d = C ]; then puts "## no di executable found for dir $d" putsnonl "*" >&5 grc=1 fi fi done exit $grc di-4.47/tests.d/diarg.sh0000755000175000017500000000710013334050206013153 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'run di w/arguments' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ testArgument () { as=$a a=`echo $a | sed 's/_/ /g'` of="out.${d}.${as}" ofc="out.C.${as}" cmd="${tdir}/di ${a} > ${of}" o=`eval $cmd 2>&1` rc=$? if [ $rc -ne 0 ]; then lrc=$rc; fi if [ "$o" != "" ]; then puts "## $cmd failed with output:" puts $o lrc=1 else puts "## $cmd ok" fi case $a in "-d"*) cmd="${tdir}/di -n $a" eval "$cmd | egrep '(inf|nan)'" rc=$? if [ $rc -eq 0 ]; then lrc=1 fi ;; esac } testargs="-A -a --all -bk -bsi -b1024 -b1000 -b512 \ -Bk -Bsi -B1024 -B1000 -B512 \ --block-size=k --block-size=si --block-size=1024 --block-size=1000 \ --block-size=512 -c --csv-output -C --csv-tabs \ -d1 -d512 -dk -dm -dg -dt -dp -de -dz -dy -dh -dH -d1024 -d1000 \ --dont-resolve-symlink \ -fmtsMTSObuf13bcvpaBuv2iUFP \ -fM -fS -fT --format-string=M --format-string=S \ --format-string=T -g -Ftmpfs -h -H --help --human-readable -itmpfs \ --inodes -k -l --local -m -n --no-sync -P --portability --print-type \ -q -R \ -sm -ss -st -srm -srs -srt -t -sa -sra -sT -srT -sf -srf \ --total --type=tmpfs -v --version \ -w20 -W20 -xtmpfs --exclude-type=tmpfs -X1 -zall -Z \ -b_k -b_si -b_1024 -b_1000 -b_512 -B_k -B_si -B_1024 \ -B_1000 -B_512 \ -d_1 -d_512 -d_k -d_m -d_g -d_t -d_p -d_e \ -d_z -d_y -d_h -d_H -d_1024 -d_1000 -f_M -f_S \ -f_T -F_tmpfs \ -i_tmpfs -a_-i_tmpfs \ -s_m -s_s -s_t -s_rm -s_rs -s_rt -w_20 -W_20 \ -x_tmpfs -a_-x_tmpfs -X_1 \ -z_all " unset DI_ARGS unset DIFMT for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi lrc=0 tdir=$_MKCONFIG_RUNTOPDIR/$d ( cd $tdir if [ $? -eq 0 ]; then instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 fi ) # just allocate disk space first time through if [ -x ${tdir}/di ]; then for a in $testargs; do testArgument done fi done # disk space should be allocated now; rerun for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi lrc=0 tdir=$_MKCONFIG_RUNTOPDIR/$d if [ -x ${tdir}/di ]; then putsnonl " ${d}" >&5 # most all unix ${tdir}/di -n -f M / 2>/dev/null | grep '^/[ ]*$' > /dev/null 2>&1 rc=$? if [ $rc -ne 0 ]; then # cygwin ${tdir}/di -n -f M / 2>/dev/null | grep '/usr/bin$' > /dev/null 2>&1 rc=$? if [ $rc -ne 0 ]; then # cygwin ${tdir}/di -n -f M / 2>/dev/null | grep '^C:\\[ ]*$' > /dev/null 2>&1 rc=$? if [ $rc -ne 0 ]; then # other machines w/odd setup ${tdir}/di -n -f M /boot 2>/dev/null | grep '^/boot[ ]*$' > /dev/null 2>&1 rc=$? fi fi fi lrc=$rc puts "## di -n -f M / : $rc" for a in $testargs; do testArgument if [ $grc -eq 0 -a $d = D ]; then case ${a} in "-d"*1|"-d"*512|"-d"*1000|"-d"*1024|"-d"*k|"-d"*m) ;; "-k"|"-m"|"-P"|"--portability"|"-X"*) ;; *) chkdiff ${ofc} ${of} if [ $grc -ne 0 ]; then lrc=1 fi grc=0 # reset this... ;; esac fi done if [ $lrc -ne 0 ]; then putsnonl "*" >&5 grc=1 fi else if [ $d = C ]; then puts "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.47/tests.d/buildsh.sh0000755000175000017500000001133013334050206013517 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'build w/mkconfig.sh' maindoquery $1 $_MKC_SH getsname $0 dosetup $@ . $_MKCONFIG_DIR/bin/shellfuncs.sh testshcapability for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi tdir=$_MKCONFIG_RUNTOPDIR/$d if [ -d ${tdir} ]; then cd $tdir instdir="`pwd`/test_di" unset MAKEFLAGS if [ $d = D -a "$DC" != "" ]; then ${MAKE:-make} ${TMAKEFLAGS} realclean ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} di.env > env.make.log 2>&1 rc=$? if [ $rc -ne 0 -o ! -f ./di.env ]; then test -f env.make.log && rm -f env.make.log continue; fi ( . ./di.env if [ "${DVERSION}" = "" -o "${DVERSION}" = "1" ]; then exit 1 fi exit 0 ) rc=$? if [ $rc -ne 0 ]; then test -f env.make.log && rm -f env.make.log continue fi fi putsnonl " ${d}" >&5 ${MAKE:-make} ${TMAKEFLAGS} realclean ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all > make.log 2>&1 rc=$? if [ $rc != 0 ]; then grc=$rc; fi if [ $grc -eq 0 ]; then systype=`uname -s` # haiku has too many warnings to deal with if [ "$systype" != "Haiku" ]; then # C: # openbsd: malloc.h, always misused, in file included, in function # openbsd: unfortunately, some output is on separate lines. # openbsd: warning: strcat() is almost always misused, please use strlcat() # solaris: tokens ignored... (dollar sign) # solaris: Function has no return statement : main # freebsd 4.9: from xxx.c:66: (separate line) # freebsd 4.9: /usr/include....function declaration isn't a prototype # AIX: extra msg from make: Target is up to date # Tru64: complains about long long being a new feature. # Tru64: extra ----^ lines # Tru64:(null command) - not sure where that's coming from # SCO_SV: # SCO_SV: warning: `/*' within comment # clang: 'warning: unknown warning option' # clang: X warnings? generated. # many: unrecognized #pragma ignored # miros:gcc: someone does not honour COPTS correctly # gcc:fstack-protector not supported for this target # D: # FLAGS= (makefile) # -- (makefile) cat make.log | grep -v 'dioptions.dat' | grep -v '^load\-unit:' | grep -v '^output\-file:' | grep -v '^option\-file:' | grep -v ' \.\.\. ' | grep -vi mkconfig | grep -v reqlibs | grep -v 'Leaving directory' | grep -v 'Entering directory' | grep -v 'cc \-[co]' | grep -v 'cc32 \-[co]' | grep -v 'cc64 \-[co]' | grep -v 'clang \-[co]' | grep -v 'xlc \-[co]' | grep -v digetentries.o | grep -v '\*\*\* ' | grep -v 'di\.env' | grep -v '^CC=' | grep -v '#warning' | grep -v 'strcpy.*always misused' | grep -v 'strcat.*always misused' | grep -v '^In file included' | grep -v ': In function' | grep -v 'tokens ignored at end of directive line' | grep -v 'Function has no return statement : main' | grep -v '^ *from [^ ]*.[ch]:[0-9]*[:,]$' | grep -v '/usr/include.*function declaration.*a prototype' | grep -v '^Target.*is up to date' | grep -v '^------' | grep -v 'is a new feature' | grep -v '^ *typedef.* long long ' | grep -v 'warning: .... within comment' | grep -v 'Unknown option.*-Wextra.*ignored.' | grep -v 'Unknown option.*-Wno-unused-but-set-variable.*ignored' | grep -v 'warning: unknown warning option' | grep -v 'warning.*generated\.' | grep -v 'Unknown option.*-Wno-unused-parameter.*ignored' | grep -v 'unrecognized #pragma ignored' | grep -v 'someone does not honour COPTS correctly' | grep -v 'fstack-protector not supported for this target' | grep -v FLAGS= | grep -v '(null command)' | grep -v -- '--' | cat > make_extra.log extra=`cat make_extra.log | wc -l | sed -e 's/^ *//'` if [ $extra -ne 0 ]; then puts "## extra output" grc=1 fi fi # not Haiku fi # if the build worked fi mkdir -p $_MKCONFIG_TSTRUNTMPDIR/buildsh_${d}${stag} set +f for f in mkconfig.log mkconfig.cache mkc*.vars di.env di.reqlibs \ env.make.log make.log make_extra.log; do if [ -f $f ]; then mv $f $_MKCONFIG_TSTRUNTMPDIR/buildsh_${d}${stag} fi done set -f done exit $grc di-4.47/tests.d/ditot.sh0000755000175000017500000000235613334050206013220 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'di totals' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ unset DI_ARGS unset DIFMT FORMATS="b B u c f v i U F" grc=0 for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi tdir=$_MKCONFIG_RUNTOPDIR/$d ( cd $tdir if [ $? -eq 0 ]; then instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all \ > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 fi ) if [ -x ${tdir}/di ]; then putsnonl " ${d}" >&5 for format in $FORMATS; do puts "Checking format: $format" # have to exclude zfs, null (dragonflybsd) # otherwise this test won't work. # include the normally excluded to get some data. # ctfs,objfs,sharefs have weird used inode counts (U) didata=`${tdir}/di -n -d1 -f $format -t -a -x null,zfs,ctfs,objfs,sharefs 2>/dev/null ` summtot=`(echo "0 ";echo $didata | sed 's/ */ + /g'; echo " - p") | dc` if [ $summtot -ne 0 ]; then putsnonl "*" >&5 puts "## format: $format failed" grc=1 fi done else if [ $d = C ]; then puts "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.47/tests.d/test_order0000644000175000017500000000007513334050206013627 0ustar bllbll1 buildsh 2 diexec 3 diarg 3 disort 3 ditot 4 diinst 5 dinls di-4.47/tests.d/dinls.sh0000755000175000017500000000366713334050206013214 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'di nls' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ unset DI_ARGS unset DIFMT set -x for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi tdir=$_MKCONFIG_RUNTOPDIR/$d ( cd $tdir if [ $? -eq 0 ]; then instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} install >> ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 fi ) if [ -x ${tdir}/di ]; then putsnonl " ${d}" >&5 if [ $d = C ]; then grep '^#define _enable_nls 1' ${tdir}/config.h hasnls=$? fi if [ $d = D ]; then grep '^enum int _enable_nls = 1;' ${tdir}/config.d hasnls=$? fi if [ ${hasnls} -ne 0 ];then putsnonl " skipped" >&5 exit 0 fi testdir=${tdir}/test_di DI_LOCALE_DIR=${testdir}/share/locale export DI_LOCALE_DIR grc=1 for l in "de" "de_DE" "de_DE.utf-8" "de_DE.UTF-8" \ "de_DE.ISO8859-1" "de_DE.ISO8859-15" ; do LC_ALL="${l}" ${testdir}/bin/di -A | grep Benutzt >/dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then grc=0 break # only need to know that one works... fi done if [ $grc -ne 0 ]; then for l in "es" "es_ES" "es_ES.utf-8" "es_ES.UTF-8" \ "es_ES.ISO8859-1" "es_ES.ISO8859-15" ; do LC_ALL="${l}" ${testdir}/bin/di -A | grep Disponible >/dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then grc=0 break # only need to know that one works... fi done fi # cannot depend on german or spanish being installed... if [ $grc -ne 0 ]; then putsnonl " de/es not installed?" >&5 grc=0 fi else if [ $d = C ]; then puts "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.47/tests.d/diinst.sh0000755000175000017500000000213513334050206013362 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 install maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi tdir=$_MKCONFIG_RUNTOPDIR/$d ( cd $tdir if [ $? -eq 0 ]; then instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 fi ) if [ -x ${tdir}/di ]; then putsnonl " ${d}" >&5 cd ${tdir} grc=0 instdir="`pwd`/test_di" unset MAKEFLAGS ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} install rc=$? # leave a copy laying around...make realclean will clean it up set +f cp mkconfig.log mkconfig.cache mkc*.vars di.env di.reqlibs \ $_MKCONFIG_TSTRUNTMPDIR set -f if [ $rc -ne 0 ]; then grc=$rc; fi ${instdir}/bin/di rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi if [ $grc -ne 0 ]; then putsnonl "*" >&5 fi else if [ $d = C ]; then puts "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.47/tests.d/diexec.sh0000755000175000017500000000162513334050206013334 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'execute di' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ unset DI_ARGS unset DIFMT for d in C D; do if [ $d = D -a \( "$DC" = "" -o "$DC" = "skip" \) ]; then continue fi tdir=$_MKCONFIG_RUNTOPDIR/$d ( cd $tdir if [ $? -eq 0 ]; then instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 fi ) if [ -x ${tdir}/di ]; then putsnonl " ${d}" >&5 ${tdir}/di grc=$? if [ $grc -ne 0 ]; then putsnonl "*" >&5 else # look for invalid floating point numbers ${tdir}/di -n | egrep '(inf|nan)' rc=$? if [ $rc -eq 0 ]; then putsnonl "*" >&5 grc=1 fi fi else if [ $d = C ]; then puts "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.47/MANIFEST0000644000175000017500000000662313334050206011304 0ustar bllbllC/ C di source C/Makefile C Makefile C/configs/ stand-alone configuration files. C/configs/config.bsd43.cc config.h for BSD43 C/configs/config.bsd43.gcc config.h for BSD43 C/configs/config.hpux.bcc config.h for HP-UX (bundled cc) C/configs/config.mingw config.h for Windows (MinGW) C/configs/config.ultrix.cc config.h for ULTRIX C/configs/config.ultrix.gcc config.h for ULTRIX C/configs/config.vms config.h for VMS C/configs/config.vms.b alternate config.h for VMS C/configs/config.cygwin.gcc config.h for Windows cygwin-gcc C/configs/conf.xenix.cc config.h for XENIX C/di-example.tcl example tcl script C/di.c di source C/di.h di source C/dimain.c di source C/dimain.h di source C/didiskutil.c di source C/digetentries.c di source C/digetinfo.c di source C/dimntopt.h di source C/diquota.c di source C/display.c di source C/display.h di source C/features/ di configuration C/features/env.dat environment configuration C/features/shenv.dat tcl environment configuration C/features/getoptn.dat getoptn test configuration C/features/mkconfig.dat mkconfig configuration C/features/mkconfig-tcl.dat additional tcl configuration C/getoptn.c di source C/getoptn.h di source C/options.c di source C/options.h di source C/realloc.c di source C/strdup.c di source C/strstr.c di source C/tcldiskspace.c tcl interface script C/Perl/ perl interface C/Perl/Changes C/Perl/README C/Perl/ex/ C/Perl/ex/perl-example.pl C/Perl/t/ C/Perl/t/diskspace.t C/Perl/MANIFEST C/Perl/di.xs C/Perl/Makefile.PL C/Perl/lib/ C/Perl/lib/Filesys/ C/Perl/lib/Filesys/di.pm C/Perl/ppport.h C/tests.d/ regression tests for di C/tests.d/buildpl.sh C/tests.d/compshpl.sh C/tests.d/env.sh C/tests.d/getoptn.sh C/tests.d/getoptn.txt C/tests.d/rpmbuild.sh C/tests.d/test_order C/trimchar.c di source C/version.h di source D/ D di source D/Makefile D Makefile D/d.README D source README D/di.d di source D/digetoptn.d di source D/dihelp.d di source D/dilocale.d di source D/diquota.d di source D/diskpart.d di source D/display.d di source D/dispopts.d di source D/features/ di configuration D/features/env.dat environment configuration D/features/mkconfig.dat mkconfig configuration D/options.d di source LICENSE License MANIFEST This file Makefile Top Level Makefile README Read This di.1 di Manual Page di.spec rpmspec file features/ features/checkbuild.dat features/checkinstall.dat features/checkperlbuild.dat features/dioptions.dat di options mktar.sh Creates the tar file po/ internationalization po/de.po po/en.po po/es.po tests.d/ regression tests for di tests.d/buildsh.sh tests.d/diarg.sh tests.d/diexec.sh tests.d/diinst.sh tests.d/dinls.sh tests.d/disort.sh tests.d/ditot.sh tests.d/test_order di-4.47/Makefile0000644000175000017500000001334713334050206011614 0ustar bllbll# # di makefile - top level # # Copyright 2001-2011 Brad Lanam Walnut Creek CA, USA # SHELL = /bin/sh MAKE = make FROMDIR = C ### # mkconfig variables MKCONFIGPATH = mkconfig ### # common programs # CAT = cat CHGRP = chgrp CHMOD = chmod CHOWN = chown CP = cp LN = ln MKDIR = mkdir MV = mv RM = rm RPMBUILD = rpmbuild SED = sed TEST = test MKC_DIR = ./mkconfig ### # installation options # prefix = /usr/local LOCALEDIR = $(prefix)/share/locale PROG = di MPROG = mi # INSTALL_DIR = $(prefix) INSTALL_BIN_DIR = $(INSTALL_DIR)/bin INST_LOCALEDIR = $(INSTALL_DIR)/share/locale TARGET = $(INSTALL_BIN_DIR)/$(PROG)$(EXE_EXT) MTARGET = $(INSTALL_BIN_DIR)/$(MPROG)$(EXE_EXT) # if you need permissions other than the default, # edit these, and do a "make installperm". USER = root GROUP = bin INSTPERM = 4111 # install suid if your system has a mount table only root # can read. For SysV.4 and Solaris, the mount command may # reset the permissions of /etc/mnttab. # # simple man page installation # DI_MANINSTDIR = $(INSTALL_DIR)/share/man DI_MANDIR = $(DI_MANINSTDIR)/man1 MAN_TARGET = $(PROG).1 MANPERM = 644 ### # all .PHONY: all all: $(MAKE) checkbuild cd C >/dev/null && $(MAKE) CC=$(CC) -e all .PHONY: all-c all-c: $(MAKE) checkbuild cd C >/dev/null && $(MAKE) CC=$(CC) -e all .PHONY: tcl-sh tcl-sh: $(MAKE) checkbuild cd C >/dev/null && $(MAKE) CC=$(CC) -e tcl-sh .PHONY: all-d all-d: $(MAKE) checkbuild cd D >/dev/null && $(MAKE) -e all .PHONY: all-perl all-perl: $(MAKE) checkperlbuild cd C >/dev/null && $(MAKE) CC=$(CC) -e all-perl .PHONY: windows-gcc windows-gcc: cd C >/dev/null && $(MAKE) -e windows-gcc .PHONY: windows-clang windows-clang: cd C >/dev/null && $(MAKE) -e windows-clang .PHONY: windows-msys windows-msys: cd C >/dev/null && $(MAKE) -e windows-msys .PHONY: windows-mingw windows-mingw: cd C >/dev/null && $(MAKE) -e windows-mingw .PHONY: test test: cd C >/dev/null && $(MAKE) -e test $(MAKE) -e tests.done tests.done: $(MKC_DIR)/runtests.sh @echo "## running tests" CC=$(CC) DC="skip" $(_MKCONFIG_SHELL) \ $(MKC_DIR)/runtests.sh ./tests.d touch tests.done ### ### # installation .PHONY: install install: $(MAKE) all-c $(MAKE) checkinstall . ./C/di.env; $(MAKE) -e FROMDIR=$(FROMDIR) install-prog install-man .PHONY: build.po build-po: -. ./C/di.env; \ (cd po >/dev/null && for i in *.po; do \ j=`echo $$i | $(SED) 's,\\.po$$,,'`; \ $${XMSGFMT} -o $$j.mo $$i; \ done) .PHONY: install-po install-po: build-po -$(TEST) -d $(INST_LOCALEDIR) || $(MKDIR) -p $(INST_LOCALEDIR) -(cd po >/dev/null && for i in *.po; do \ j=`echo $$i | $(SED) 's,\\.po$$,,'`; \ $(TEST) -d $(INST_LOCALEDIR)/$$j || \ $(MKDIR) $(INST_LOCALEDIR)/$$j; \ $(TEST) -d $(INST_LOCALEDIR)/$$j/LC_MESSAGES || \ $(MKDIR) $(INST_LOCALEDIR)/$$j/LC_MESSAGES; \ $(CP) -f $$j.mo $(INST_LOCALEDIR)/$$j/LC_MESSAGES/di.mo; \ $(RM) -f $$j.mo; \ done) .PHONY: install-prog install-prog: $(TEST) -d $(INSTALL_DIR) || $(MKDIR) -p $(INSTALL_DIR) $(TEST) -d $(INSTALL_BIN_DIR) || $(MKDIR) $(INSTALL_BIN_DIR) $(CP) -f ./$(FROMDIR)/$(PROG)$(EXE_EXT) $(TARGET) -$(RM) -f $(MTARGET) > /dev/null 2>&1 -$(LN) -s $(PROG)$(EXE_EXT) $(MTARGET) @-test -f $(FROMDIR)/config.h && \ grep '^#define _enable_nls 1' $(FROMDIR)/config.h >/dev/null 2>&1 && \ (. ./$(FROMDIR)/di.env; $(MAKE) -e INST_LOCALEDIR="$(INST_LOCALEDIR)" \ install-po) @-test -f $(FROMDIR)/config.d && \ grep '^enum int _enable_nls = 1;' $(FROMDIR)/config.d >/dev/null 2>&1 && \ (. ./$(FROMDIR)/di.env; $(MAKE) -e INST_LOCALEDIR="$(INST_LOCALEDIR)" \ install-po) .PHONY: install-man install-man: -$(TEST) -d $(DI_MANINSTDIR) || $(MKDIR) -p $(DI_MANINSTDIR) -$(TEST) -d $(DI_MANDIR) || $(MKDIR) -p $(DI_MANDIR) $(CP) -f di.1 $(DI_MANDIR)/$(MAN_TARGET) $(CHMOD) $(MANPERM) $(DI_MANDIR)/$(MAN_TARGET) .PHONY: installperms installperms: $(CHOWN) $(USER) $(TARGET) $(CHGRP) $(GROUP) $(TARGET) $(CHMOD) $(INSTPERM) $(TARGET) ### # packaging .PHONY: tar tar: @-rm -f di-[0-9].[0-9][0-9][a-z].tar.gz > /dev/null 2>&1 ./mktar.sh ### # cleaning # Leaves: # _tmp_mkconfig/, _mkconfig_runtests/ .PHONY: clean clean: @-rm -rf mkconfig.cache mkc*.vars mkconfig.log \ checkbuild checkperlbuild checkinstall \ tests.done > /dev/null 2>&1; exit 0 @-find . -name '*~' -print | xargs rm >/dev/null 2>&1; exit 0 @-(cd C >/dev/null && $(MAKE) clean > /dev/null 2>&1); exit 0 @-(cd D >/dev/null && $(MAKE) clean > /dev/null 2>&1); exit 0 # Leaves: # _tmp_mkconfig/, _mkconfig_runtests/ .PHONY: realclean realclean: @-rm -rf mkconfig.cache mkc*.vars mkconfig.log \ checkbuild checkperlbuild checkinstall \ tests.done *~ */*~ */*/*~ > /dev/null 2>&1; exit 0 @-(cd C >/dev/null && $(MAKE) realclean > /dev/null 2>&1); exit 0 @-(cd D >/dev/null && $(MAKE) realclean > /dev/null 2>&1); exit 0 # leaves: # dioptions.dat .PHONY: distclean distclean: @-rm -rf mkconfig.cache mkc*.vars mkconfig.log \ _mkconfig_runtests checkbuild checkperlbuild checkinstall \ tests.done _tmp_mkconfig *~ */*~ \ */*/*~ *.orig > /dev/null 2>&1; exit 0 @-(cd C >/dev/null && $(MAKE) distclean > /dev/null 2>&1); exit 0 @-(cd D >/dev/null && $(MAKE) distclean > /dev/null 2>&1); exit 0 ### # dioptions.dat dioptions.dat: features/dioptions.dat @$(CP) features/dioptions.dat dioptions.dat @$(CHMOD) u+w dioptions.dat @touch dioptions.dat # to get mod date current ### # pre-checks checkbuild: features/checkbuild.dat $(_MKCONFIG_SHELL) \ $(MKCONFIGPATH)/mkconfig.sh features/checkbuild.dat touch checkbuild checkperlbuild: features/checkperlbuild.dat $(_MKCONFIG_SHELL) \ $(MKCONFIGPATH)/mkconfig.sh features/checkperlbuild.dat touch checkperlbuild checkinstall: features/checkinstall.dat $(_MKCONFIG_SHELL) \ $(MKCONFIGPATH)/mkconfig.sh features/checkinstall.dat touch checkinstall di-4.47/features/0000755000175000017500000000000013334050206011762 5ustar bllblldi-4.47/features/checkbuild.dat0000644000175000017500000000126513334050206014555 0ustar bllblloutput none command awk nawk mawk gawk command cat command date command egrep command grep command mkdir command rm command sed command sort command touch command tr command uname command wc setint build_commands 0 if build_cmds _command_awk && _command_cat && _command_date && \ _command_egrep && _command_grep && _command_mkdir && \ _command_rm && _command_sed && \ _command_sort && _command_touch && \ _command_tr && _command_uname && _command_wc setint build_commands 1 endif if chk_build_cmds ! _setint_build_commands echo echo ** ERROR: The build requires the following commands: echo ** awk, cat, egrep, grep, mkdir, rm, sed, sort, tr and wc echo exit endif di-4.47/features/checkinstall.dat0000644000175000017500000000100013334050206015107 0ustar bllblloutput none command chmod command cp command grep command ln command mkdir command mv command rm command sed setint install_commands 0 if install_cmds _command_chmod && _command_cp && _command_grep && \ _command_ln && _command_mkdir && _command_mv && _command_rm && \ _command_sed setint install_commands 1 endif if chk_install_cmds ! _setint_install_commands echo echo ** ERROR: The install requires the following commands: echo ** chmod, cp, grep, ln, mkdir, mv, rm and sed echo exit endif di-4.47/features/dioptions.dat0000644000175000017500000000155413334050206014471 0ustar bllbll# This is the 'di' options file. # It will not be removed when the directory # is cleaned, so your settings will be saved. # # Once you have it set up, you can reuse it # to rebuild 'di' with your preferences. # # When a new version of 'di' is released, you # can copy this file over and rebuild. # # enable NLS? NLS=T # use windows API? WINAPI=F # # The default output format # # default: # DI_DEFAULT_FORMAT=smbuvpT # alternatives: # DI_DEFAULT_FORMAT=MbuvpT # # The default display size # k - kbytes # m - mbytes # g - gbytes # h - scaled alternative 1 (human readable) # H - scaled alternative 2 (human readable) # # default: # DI_DEFAULT_DISP_SIZE=H # # The environment variables: # CC, CFLAGS, LDFLAGS, LIBS, SHCFLAGS, SHLDFLAGS, # DC and DFLAGS # may be set here. If these variables are set in # the environment, they will override any settings # here. # di-4.47/features/checkperlbuild.dat0000644000175000017500000000126713334050206015442 0ustar bllblloutput none command awk nawk mawk gawk command cat command date command egrep command grep command mkdir command perl command pwd command rm command sed command sort command tr command uname setint build_commands 0 if build_cmds _command_awk && _command_cat && _command_egrep && \ _command_grep && _command_mkdir && _command_perl && \ _command_pwd && _command_rm && _command_sed && \ _command_sort && _command_tr && _command_uname setint build_commands 1 endif if chk_build_cmds ! _setint_build_commands echo echo ** ERROR: The build requires the following commands: echo ** awk, cat, date, egrep, grep, mkdir, perl, pwd, rm, echo ** sed, sort, and tr echo exit endif di-4.47/po/0000755000175000017500000000000013334050206010562 5ustar bllblldi-4.47/po/es.po0000644000175000017500000001160013334050206011527 0ustar bllbll# msgid "" msgstr "" "Project-Id-Version: di $Revision$\n" "POT-Creation-Date: 2010-03-08 00:05-0800\n" "PO-Revision-Date: 2010-03-08 00:05-0800\n" "Last-Translator: David Sastre Medina \n" "Language-Team: Español \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=utf-8\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" # domain "di" msgid " m - megabytes, g - gigabytes, t - terabytes, h - human readable).\n" msgstr " m - megabytes, g - gigabytes, t - terabytes, h - legible).\n" msgid " [-I include-fstyp-list] [file [...]]\n" msgstr " [-I incluir-lista-tipos-de-sf] [fichero [...]]\n" msgid " 2 - percentage of user-available space in use.\n" msgstr " 2 - porcentaje de espacio disponible de usuario en uso.\n" msgid " F - free file slots P - percentage file slots used\n" msgstr " F - inodos libres P - porcentaje de inodos usados\n" msgid "See manual page for more options.\n" msgstr "Vea página de manual para más opciones.\n" msgid " b - total kbytes B - kbytes available for use\n" msgstr " b - kbytes totales B - kbytes disponibles para uso\n" msgid " f - kbytes free v - kbytes available\n" msgstr " f - kbytes libres v - kbytes disponibles\n" msgid " i - total file slots (i-nodes) U - used file slots\n" msgstr " i - total inodos (i-nodes) U - inodos usados\n" msgid " m - mount point M - mount point, full length\n" msgstr " m - punto de montaje M - punto de montaje, nombre largo\n" msgid " p - percentage not avail. for use 1 - percentage used\n" msgstr " p - porcentaje no disponible 1 - porcentaje usado\n" msgid " s - filesystem name S - filesystem name, full length\n" msgstr " s - nombre de sistema de ficheros S - nombre de sistemas de ficheros, nombre largo\n" msgid " t - disk partition type T - partition type, full length\n" msgstr " t - tipo de partición en disco T - tipo de partición, nombre completo\n" msgid " u - used kbytes c - calculated kbytes in use\n" msgstr " u - kbytes usados c - cálculo de kbytes en uso\n" msgid " -I x : include only file system types in \n" msgstr " -I x : incluir sólo los tipos de sistemas de ficheros en \n" msgid " -a : print all mounted devices\n" msgstr " -a : mostrar todos los dispositivos montados\n" msgid " -d x : size to print blocks in (512 - POSIX, k - kbytes,\n" msgstr " -d x : tamaño de bloque a mostrar (512 - POSIX, k - kbytes,\n" msgid " -f x : use format string \n" msgstr " -f x : usar formato \n" msgid " -x x : exclude file system types in \n" msgstr " -x x : excluir tipos de sistemas de ficheros en \n" msgid " -l : display local filesystems only\n" msgstr " -l : mostrar sistemas de ficheros locales\n" msgid " -n : don't print header\n" msgstr " -n : no mostrar cabecera\n" msgid " -t : print totals\n" msgstr " -t : mostrar totales\n" msgid " Format string values:\n" msgstr " Valores de formato de cadena:\n" #, no-c-format msgid "%IFree" msgstr "%ILibre" #, no-c-format msgid "%IUsed" msgstr "%IUsado" #, no-c-format msgid "%Used" msgstr "%Usado" msgid "Capacity" msgstr "Capacidad" #, no-c-format msgid "%Free" msgstr "%Libre" msgid "Avail" msgstr "Dispon" msgid "Available" msgstr "Disponible" msgid "Exas" msgstr "Exas" msgid "Exbis" msgstr "Exbis" msgid "Filesystem" msgstr "Sistema de ficheros" msgid "Free" msgstr "Libre" msgid "Gigs" msgstr "Gigs" msgid "Inodes" msgstr "Inodos" msgid "IUsed" msgstr "IUsado" msgid "512-blocks" msgstr "512-bloques" msgid "KBytes" msgstr "KBytes" msgid "1024-blocks" msgstr "1024-bloques" msgid "Megs" msgstr "Megs" msgid "Mebis" msgstr "Mebis" msgid "Mount" msgstr "Mountado" msgid "Mounted On" msgstr "Montado En" msgid "Mount Time" msgstr "Momento de Montaje" msgid "Options" msgstr "Opciones" msgid "Petas" msgstr "Petas" msgid "Pebis" msgstr "Pebis" msgid "Size" msgstr "Tamaño" msgid "Teras" msgstr "Teras" msgid "Tebis" msgstr "Tebis" msgid "Total" msgstr "Total" msgid "Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]\n" msgstr "Uso: di [-ant] [-d tamaño-display] [-f formato] [-x excluir-lista-tipos-de-sf]\n" msgid "Used" msgstr "Usado" msgid "Yottas" msgstr "Yottas" msgid "Yobis" msgstr "Yobis" msgid "Zettas" msgstr "Zettas" msgid "Zebis" msgstr "Zebis" #, c-format msgid "di version %s Default Format: %s\n" msgstr "di version %s Formato por Defecto: %s\n" #, c-format msgid "di version %s Default Format: %s\n" msgstr "di version %s Formato por Defecto: %s\n" #, no-c-format msgid "fs Type" msgstr "Tipo de sf" msgid "fsType" msgstr "Tipo de sf" di-4.47/po/en.po0000644000175000017500000001130413334050206011523 0ustar bllbll# msgid "" msgstr "" "Project-Id-Version: di $Revision$\n" "POT-Creation-Date: 2007-01-17 14:23-0800\n" "PO-Revision-Date: 2007-01-17 14:23-0800\n" "Last-Translator: Brad Lanam \n" "Language-Team: English \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" # domain "di" msgid " m - megabytes, g - gigabytes, t - terabytes, h - human readable).\n" msgstr " m - megabytes, g - gigabytes, t - terabytes, h - human readable).\n" msgid " [-I include-fstyp-list] [file [...]]\n" msgstr " [-I include-fstyp-list] [file [...]]\n" msgid " 2 - percentage of user-available space in use.\n" msgstr " 2 - percentage of user-available space in use.\n" msgid " F - free file slots P - percentage file slots used\n" msgstr " F - free file slots P - percentage file slots used\n" msgid "See manual page for more options.\n" msgstr "See manual page for more options.\n" msgid " b - total kbytes B - kbytes available for use\n" msgstr " b - total kbytes B - kbytes available for use\n" msgid " f - kbytes free v - kbytes available\n" msgstr " f - kbytes free v - kbytes available\n" msgid " i - total file slots (i-nodes) U - used file slots\n" msgstr " i - total file slots (i-nodes) U - used file slots\n" msgid " m - mount point M - mount point, full length\n" msgstr " m - mount point M - mount point, full length\n" msgid " p - percentage not avail. for use 1 - percentage used\n" msgstr " p - percentage not avail. for use 1 - percentage used\n" msgid " s - filesystem name S - filesystem name, full length\n" msgstr " s - filesystem name S - filesystem name, full length\n" msgid " t - disk partition type T - partition type, full length\n" msgstr " t - disk partition type T - partition type, full length\n" msgid " u - used kbytes c - calculated kbytes in use\n" msgstr " u - used kbytes c - calculated kbytes in use\n" msgid " -I x : include only file system types in \n" msgstr " -I x : include only file system types in \n" msgid " -a : print all mounted devices\n" msgstr " -a : print all mounted devices\n" msgid " -d x : size to print blocks in (512 - POSIX, k - kbytes,\n" msgstr " -d x : size to print blocks in (512 - POSIX, k - kbytes,\n" msgid " -f x : use format string \n" msgstr " -f x : use format string \n" msgid " -x x : exclude file system types in \n" msgstr " -x x : exclude file system types in \n" msgid " -l : display local filesystems only\n" msgstr " -l : display local filesystems only\n" msgid " -n : don't print header\n" msgstr " -n : don't print header\n" msgid " -t : print totals\n" msgstr " -t : print totals\n" msgid " Format string values:\n" msgstr " Format string values:\n" #, no-c-format msgid "%IFree" msgstr "%IFree" #, no-c-format msgid "%IUsed" msgstr "%IUsed" #, no-c-format msgid "%Used" msgstr "%Used" msgid "Capacity" msgstr "Capacity" #, no-c-format msgid "%Free" msgstr "%Free" msgid "Avail" msgstr "Avail" msgid "Available" msgstr "Available" msgid "Exas" msgstr "Exas" msgid "Exbis" msgstr "Exbis" msgid "Filesystem" msgstr "Filesystem" msgid "Free" msgstr "Free" msgid "Gigs" msgstr "Gigs" msgid "Inodes" msgstr "Inodes" msgid "IUsed" msgstr "IUsed" msgid "512-blocks" msgstr "512-blocks" msgid "KBytes" msgstr "KBytes" msgid "1024-blocks" msgstr "1024-blocks" msgid "Megs" msgstr "Megs" msgid "Mebis" msgstr "Mebis" msgid "Mount" msgstr "Mount" msgid "Mounted On" msgstr "Mounted On" msgid "Mount Time" msgstr "Mount Time" msgid "Options" msgstr "Options" msgid "Petas" msgstr "Petas" msgid "Pebis" msgstr "Pebis" msgid "Size" msgstr "Size" msgid "Teras" msgstr "Teras" msgid "Tebis" msgstr "Tebis" msgid "Total" msgstr "Total" msgid "Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]\n" msgstr "Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]\n" msgid "Used" msgstr "Used" msgid "Yottas" msgstr "Yottas" msgid "Yobis" msgstr "Yobis" msgid "Zettas" msgstr "Zettas" msgid "Zebis" msgstr "Zebis" #, c-format msgid "di version %s Default Format: %s\n" msgstr "di version %s Default Format: %s\n" #, c-format msgid "di version %s Default Format: %s\n" msgstr "di version %s Default Format: %s\n" #, no-c-format msgid "fs Type" msgstr "fs Type" msgid "fsType" msgstr "fsType" di-4.47/po/de.po0000644000175000017500000001140013334050206011506 0ustar bllbll# msgid "" msgstr "" "Project-Id-Version: di $Revision$\n" "POT-Creation-Date: 2007-01-17 14:23-0800\n" "PO-Revision-Date: 2007-01-17 14:23-0800\n" "Last-Translator: Hartmut Haase \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=iso-8859-1\n" "Content-Transfer-Encoding: 8bit\n" "Plural-Forms: nplurals=2; plural=n != 1;\n" # domain "di" msgid " m - megabytes, g - gigabytes, t - terabytes, h - human readable).\n" msgstr " m - Megabyte, g - Gigabyte, t - Terabyte, h - lesbar).\n" msgid " [-I include-fstyp-list] [file [...]]\n" msgstr " [-I include-fstyp-list] [Datei [...]]\n" msgid " 2 - percentage of user-available space in use.\n" msgstr " 2 - Prozent des benutzten verfügbaren Platzes.\n" msgid " F - free file slots P - percentage file slots used\n" msgstr " F - Dateislots freigeben P - Prozent der benutzten Dateislots\n" msgid "See manual page for more options.\n" msgstr "Siehe man-Seite für weitere Optionen.\n" msgid " b - total kbytes B - kbytes available for use\n" msgstr " b - KB gesamt B - verfügbare KB\n" msgid " f - kbytes free v - kbytes available\n" msgstr " f - KB frei v - verfügbare KB\n" msgid " i - total file slots (i-nodes) U - used file slots\n" msgstr " i - Dateislots gesamt (i-nodes) U - benutzte Dateislots\n" msgid " m - mount point M - mount point, full length\n" msgstr " m - Mountpunkt M - Mountpunkt, volle Länge\n" msgid " p - percentage not avail. for use 1 - percentage used\n" msgstr " p - Prozent nicht benutzbar 1 - Prozent benutzt\n" msgid " s - filesystem name S - filesystem name, full length\n" msgstr " s - Dateisystemname S - Dateisystemname, volle Länge\n" msgid " t - disk partition type T - partition type, full length\n" msgstr " t - Plattenpartitionstyp T - Partitionstyp, volle Länge\n" msgid " u - used kbytes c - calculated kbytes in use\n" msgstr " u - benutzte KB c - benutzte KB (berechnet)\n" msgid " -I x : include only file system types in \n" msgstr " -I x : nur Dateisystemtypen in einfügen\n" msgid " -a : print all mounted devices\n" msgstr " -a : alle eingehängten Geräte auflisten\n" msgid " -d x : size to print blocks in (512 - POSIX, k - kbytes,\n" msgstr " -d x : Größe der angezeigten Blöcke (512 - POSIX, k - KB,\n" msgid " -f x : use format string \n" msgstr " -f x : benutze Formatzeichen \n" msgid " -x x : exclude file system types in \n" msgstr " -x x : Dateisystemtyp in ignorieren\n" msgid " -l : display local filesystems only\n" msgstr " -l : nur lokale Dateisysteme anzeigen\n" msgid " -n : don't print header\n" msgstr " -n : keine Kopf drucken\n" msgid " -t : print totals\n" msgstr " -t : Summen drucken\n" msgid " Format string values:\n" msgstr " Formatzeichenkette:\n" #, no-c-format msgid "%IFree" msgstr "%IFrei" #, no-c-format msgid "%IUsed" msgstr "%IBen." #, no-c-format msgid "%Used" msgstr "%Ben." #, no-c-format msgid "Capacity" msgstr "Benutzt%" #, no-c-format msgid "%Free" msgstr "%Frei" msgid "Avail" msgstr "Verfügb." msgid "Available" msgstr "Verfügbar" msgid "Exas" msgstr "Exas" msgid "Exbis" msgstr "Exbis" msgid "Filesystem" msgstr "Dateisystem" msgid "Free" msgstr "Frei" msgid "Gigs" msgstr "GB" msgid "Gibis" msgstr "GB" msgid "Inodes" msgstr "Inodes" msgid "IUsed" msgstr "IBenutzt" msgid "512-blocks" msgstr "512-Blöcke" msgid "KBytes" msgstr "KB" msgid "1024-blocks" msgstr "1024-Blöcke" msgid "Megs" msgstr "MB" msgid "Mebis" msgstr "MB" msgid "Mount" msgstr "Mountpunkt" msgid "Mounted On" msgstr "Eingehängt auf" msgid "Mount Time" msgstr "Mountzeit" msgid "Options" msgstr "Optionen" msgid "Petas" msgstr "Petas" msgid "Pebis" msgstr "Pebis" msgid "Size" msgstr "Größe" msgid "Teras" msgstr "TB" msgid "Tebis" msgstr "TB" msgid "Total" msgstr "Gesamt" msgid "Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]\n" msgstr "Aufruf: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]\n" msgid "Used" msgstr "Benutzt" msgid "Yottas" msgstr "Yottas" msgid "Yobis" msgstr "Yobis" msgid "Zettas" msgstr "Zettas" msgid "Zebis" msgstr "Zebis" #, c-format msgid "di version %s Default Format: %s\n" msgstr "di version %s Standardformat: %s\n" #, c-format msgid "di version %s Default Format: %s\n" msgstr "di version %s Standardformat: %s\n" #, no-c-format msgid "fs Type" msgstr "D.typ" msgid "fsType" msgstr "D.typ" di-4.47/di.10000644000175000017500000003032713334050206010627 0ustar bllbll.\" .\" di.1 .\" .\" Copyright 1994-2018 Brad Lanam Walnut Creek CA USA .\" .\" brad.lanam.di_at_gmail.com .\" .TH di 1 "17 Jan 2013" .SH Name di \- disk information .SH Synopsis .\" di [-AacghHklLmnPqRtZ] [-B block-size] [-d display-size] [-f format] .\" [-I include-fstyp-list] [-s sort-type] [-w block-width] .\" [-W inode-width] [-x exclude-fstyp-list] [-X debug-level] .\" [-z zone-name] [file [...]] .B di [\fB\-AacghHklLmnPqRtZ\fP] [\fB\-B\fP \fIblock\-size\fP] [\fB\-d\fP \fIdisplay\-size\fP] [\fB\-f\fP \fIformat\fP] [\fB\-I\fP \fIinclude\-fstyp\-list\fP] [\fB\-s\fP \fIsort\-type\fP] [\fB\-w\fP \fIblock\-width\fP] [\fB\-W\fP \fIinode\-width\fP] [\fB\-x\fP \fIexclude\-fstyp\-list\fP] [\fB\-X\fP \fIdebug-level\fP] [\fB\-z\fP \fIzone\-name\fP] [\fIfile\fP [...]] .PP .B mi .SH Description \fIdi\fP Displays usage information on mounted filesystems. Block values are reported in a human readable format. If the user or group has a disk quota, the values reported are adjusted according the quotas that apply to the user. .PP If \fIfile\fP is specified, the usage information for the partition on which \fIfile\fP is located is printed. .PP Unless the \-a flag is specified, the following mounted filesystems will not normally be displayed: filesystems with total space <= 0; loopback filesystems that are duplicates of other normally mounted filesystems (filesystem type of 'lofs' , 'none', or 'nullfs'); loopback filesystems that are part of a zone (Solaris). .PP Filesystems that the user does not have permissions to access will not be displayed at all. .PP \fImi\fP Displays the mounted filesystem information. .PP Several options may be specified to control the output of \fIdi\fP and \fImi\fP: .TP .B \-A Print all fields (used for debugging). Mount points and special device names are printed at full width. .TP .B \-a (compatibility: \fB\-\-all\fP) .br Prints all mounted devices (normally, those with 0 total space are not printed \- e.g. \fB/dev/proc\fP, \fB/dev/fd\fP). .TP .B \-B .I block\-size (compatibility: \fB\-\-block\-size\fP, \fB\-b\fP) .br Change the base block size from 1024 (default) to the size specified. \fIblock\-size\fP may be one of: k\ \-\ 1024 bytes, si\ \-\ 1000 bytes, or a specific size. .TP .B \-c (alias: \fB\-\-csv\-output\fP) .br Comma separated values are output. The titles are output as the format string specifiers. Totals are turned off. See also the \-n flag. .TP .B \-C (alias: \fB\-\-csv\-tabs\fP) .br Values are output with tab separators. See also the \-c option. .TP .B \-d .I display\-size (alias: \fB\-\-display\-size\fP) .br Display the usage in units specified by \fIdisplay\-size\fP. Note that if the base block size is SI units of 1000 bytes, the display size is calculated using those units. \fIdisplay\-size\fP may be one of: 512\ \-\ POSIX, k\ \-\ kilobytes, m\ \-\ megabytes, g\ \-\ gigabytes, t\ \-\ terabytes, p\ \-\ petabytes, e\ \-\ exabytes, z\ \-\ zettabytes, y\ \-\ yottabytes, h\ \-\ Scaled alternative 1, H\ \-\ Scaled alternative 2, or a specific value to use as the block size. .IP Block display sizes greater than 1024 bytes are displayed with a precision of one decimal place after the radix. .IP The Scaled alternatives scale the sizes displayed and appends a suffix (e.g. 48.0k, 3.4M). .IP With scaled alternative 1, sizes within a line may scale to different units. .IP Scaled alternative 2 scales all the sizes in each individual line to the same unit size (the largest needed). .TP .B \-f .I format Use the specified format string \fIformat\fP. See the \fBFormat Strings\fP section. .TP .B \-g (alias for: \fB\-dg\fP) .br Display sizes in gigabytes. .TP .B \-h (alias for: \fB\-dh\fP) .br Display partition sizes in scaled alternative 1 format. .TP .B \-\-help .br Display some basic usage information. .TP .B \-H (alias for: \fB\-dH\fP; compatibility: \fB\-\-human\-readable\fP) .br Display partition sizes in scaled alternative 2 format. .TP .B \-I .I include\-fstype\-list (compatibility: \fB\-F\fP, \fB\-\-type\fP) .br Include \fIonly\fP the file system types listed in \fIinclude\-fstyp\-list\fP. The list is a comma separated list of file system types. Multiple \-I options may be specified. If the 'fuse' filesystem type is specified, all fuse* filesystems will be included. .br e.g. \-I nfs,tmpfs or \-I nfs \-I tmpfs. .TP .B \-\-inodes Ignored. Use the \-f option. .TP .B \-k (alias for: \fB\-dk\fP) .br Display sizes in Kbytes. .TP .B \-l (compatibility: \fB\-\-local\fP) .br Display only local file systems. .TP .B \-L Turn off check for duplicate filesystems (loopback (lofs/none) mounts). .TP .B \-m (alias for: \fB\-dm\fP) .br Display sizes in megabytes. .TP .B \-n Do not print a header line above the list of file systems. Useful when parsing the output of \fIdi\fP. .TP .B \-\-no\-sync Ignored. .TP .B \-P (compatibility: \fB\-\-portability\fP) .br Output format is POSIX standard. 512 byte block size is the default. The \-k option may be used. .TP .B \-\-print\-type Ignored. Use the \-f option. .TP .B \-q Disable quota checks. .TP .B \-R (also: \-\-dont\-resolve\-symlinks) .br Do not resolve symlinks (for mount points that have a trailing UUID). .TP .B \-s .I sort\-type .br Use \fIsort\-type\fP to sort the output. The output of \fIdi\fP is normally sorted by mount point. The following sort flags may be used to change the sort order: \fBm\fP \- by mount point (default); \fBn\fP \- leave unsorted (as it appears in the mount table); \fBs\fP \- by special device name; \fBT\fP \- by total space; \fBf\fP \- by free space; \fBa\fP \- by available space; \fBt\fP \- by filesystem type; \fBr\fP \- reverse the sort order; This will apply to all sort flags following this sort flag. .IP These sort options may be combined in any order. e.g.: .RS di \-stsrm # by type, special, reversed mount; .br di \-strsrm # by type, reversed special, mount. .RE .TP .B \-\-si An alias for \fB-dH -Bsi\fP. .TP .B \-\-sync Ignored. .TP .B \-t (compatibility: \fB\-\-total\fP) .br Print a totals line below the list of file systems. Pooled filesystems (zfs, advfs) have only the main pool added to the total. It is up to the user to exclude (using the \-x option) read\-only filesystems (cdfs, iso9660), swap-based (memfs, mfs, tmpfs) filesystems and user (fuse*) filesystems. Excluding the 'fuse' filesystem will exclude all fuse* filesystems. .TP .B \-w .I block\-width .br Set the print width for block values. The default is eight. .TP .B \-v Ignored. .TP .B \-\-version .br Display di's version and default format string. .TP .B \-W .I inode\-width .br Set the print width for inode values. Default is seven. .TP .B \-x .I exclude\-fstype\-list (compatibility: \fB\-\-exclude\-type\fP) .br Exclude the file system types listed in \fIexclude\-fstyp\-list\fP. The list is a comma separated list of file system types. Multiple \-x options may be specified. If the 'fuse' filesystem type is excluded, all fuse* filesystems will be excluded. e.g. \-x nfs,tmpfs or \-x nfs \-x tmpfs. .TP .B \-X .I level .br Set the program's debugging level to \fIdebug-level\fP. .TP .B \-z .I zone-name .br Display the filesystems for the specified zone. The zone must be visible to the user. .TP .B \-Z (alias for: \fB\-z all\fP) .br Display the filesystems for all visible zones. .SH Format Strings The output of \fIdi\fP may be specified via a format string. This string may be given either via the \fB-f\fP command line option or as part of the \fBDI_ARGS\fP environment variable. The format string may specify the following columns: .RS .5 .TP .B m Print the name of the mount point. .TP .B M Print the name of the mount point, at full length. The mount point is formatted to the maximum width necessary for the longest mount point name. .TP .B s Print the file system name (special device or remote mount point). .TP .B S Print the file system name (special device or remote mount point), at full length. The file system name is formatted to the maximum width necessary for the longest file system name. .TP .B t Print the file system type. .TP .B T Print the file system type at full length. The file system type is formatted to the maximum width necessary for the longest file system type. .TP .B Total Available .TP .B b Print the total number of megabytes on the file system. .TP .B B Print the total number of megabytes on the file system available for use by normal users. .TP .B In Use .TP .B u Print the number of megabytes in use on the file system (actual number of megabytes used = total \- free). .TP .B c Print the number of megabytes not available for use by normal users (total \- available). .TP .B Free .TP .B f Print the number of free (unused) megabytes on the file system. .TP .B v Print the number of megabytes available for use by normal users. .TP .B Percentage Used .TP .B p Print the percentage of megabytes not available for use by normal users (number of megabytes not available for use / total disk space). .TP .B 1 Print the percentage of total megabytes in use (actual number of megabytes used / total disk space). .TP .B 2 Print the percentage of megabytes in use, BSD-style. Represents the percentage of user-available space in use. Note that values over 100% are possible (actual number of megabytes used / disk space available to non-root users). .TP .B Percentage Free .TP .B a Print the percentage of megabytes available for use by normal users (number of megabytes available for use / total disk space). .TP .B 3 Print the percentage of total megabytes free (actual number of megabytes free / total disk space). .TP .B Inodes .TP .B i Print the total number of file slots (inodes) that can be created on the file system. .TP .B U Print the number of file slots in use. .TP .B F Print the number of file slots available. .TP .B P Print the percentage of file slots in use. .TP .B Mount Information .TP .B I Print the time the filesystem was mounted. This column is not supported on all systems. .TP .B O Print the filesystem mount options. .RE .PP The default format string for \fIdi\fP is \fBsmbuvpT\fP. .PP The default format string for \fImi\fP is \fBMSTIO\fP. .PP The format string may also contain any other character not listed above. The character will be printed as is. e.g. di \-f 'mbuvp|iUFP' will print the character '|' between the disk usage and the file slot usage. The command sequence: .RS .br di \-f 'mbuvp .br miUFP' .br .RE will print two lines of data for each filesystem. .SH Examples Various \fIdf\fP equivalent format strings for System V release 4 are: .RS \fI/usr/bin/df \-v\fP di \-P \-f msbuf1 .br \fI/usr/bin/df \-k\fP di \-dk \-f sbcvpm .br \fI/usr/ucb/df\fP di \-dk \-f sbuv2m .RE GNU df: .RS \fIdf\fP di \-dk \-f SbuvpM \-w 10 .br \fIdf \-T\fP di \-dk \-f STbuvpM \-w 10 .RE AIX df: .RS \fIdf\fP di \-d 512 \-f Sbf1UPM \-w 10 .br \fIdf \-I\fP di -d 512 \-f Sbuf1M .br \fIdf \-I \-M\fP di \-d 512 \-f SMbuf1 \-w 10 .RE HP-UX bdf: .RS \fIbdf\fP di \-d k \-f Sbuv2M .br \fIbdf \-i\fP di \-d k \-f Sbuv2UFPM .RE .PP If you like your numbers to add up/calculate the percentage correctly, try one of the following format strings: .PP .RS di \-f SMbuf1T .br di \-f SMbcvpT .br di \-f SMBuv2T .RE .SH Environment Variables The DI_ARGS environment variable may be used to specify command line arguments. e.g. If you always want gigabytes displayed, set DI_ARGS equal to "\-dg". Any command line arguments specified will override the DI_ARGS environment variable. .PP The DI_LOCALE_DIR environment variable may be used to specify the location of the di program's locale message files. .PP The GNU df POSIXLY_CORRECT, and DF_BLOCK_SIZE and the BSD BLOCKSIZE environment variables are honored. .SH Note For filesystems that do not report available space (e.g. System V release 3), the number of available space is set to the free space. .SH WARNING Do not replace your system's \fIdf\fP command with this program. You will in all likelihood break your installation procedures. .SH See Also df(1), fstab(5), getmnt(2), getmntinfo(2), mnttab(4), mount(1M) statfs(2), statvfs(2) .SH Bugs Send bug reports to: brad.lanam.di_at_gmail.com .PP Known Issues: .PP di will probably not process a zettabyte or yottabyte sized filesystem properly due to overflow of a long long. .SH Website https://gentoo.com/di/ .SH Author This program is Copyright 1994-2011 by Brad Lanam. .PP Brad Lanam, Walnut Creek, CA (brad.lanam.di_at_gmail.com) di-4.47/mktar.sh0000755000175000017500000000071013334050206011617 0ustar bllbll#!/bin/sh ver=`grep DI_VERSION C/version.h | sed -e 's/"$//' -e 's/.*"//'` PKG=di cwd=`pwd` dir="${PKG}-${ver}" rm -rf $dir > /dev/null 2>&1 mkdir $dir chmod 755 $dir sed 's,[/]*[ ].*$,,' MANIFEST | while read f; do if [ -d $f ]; then mkdir $dir/$f chmod 755 $dir/$f else d=`dirname $f` cp $f $dir/$d fi done cp -r mkconfig $dir chmod -R a+r $dir tar cf - $dir | gzip -9 > $dir.tar.gz rm -rf $dir > /dev/null 2>&1 exit 0 di-4.47/C/0000755000175000017500000000000013334050206010326 5ustar bllblldi-4.47/C/display.c0000644000175000017500000011461613334050206012150 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #include "display.h" #include "options.h" #include "version.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_ctype # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _hdr_libintl # include #endif #if _hdr_wchar # include #endif #if _use_mcheck # include #endif extern int debug; #define DI_FMT_VALID_CHARS "mMsStTbBucfvp12a3iUFPIO" /* mount information */ #define DI_FMT_MOUNT 'm' #define DI_FMT_MOUNT_FULL 'M' #define DI_FMT_SPECIAL 's' #define DI_FMT_SPECIAL_FULL 'S' #define DI_FMT_TYPE 't' #define DI_FMT_TYPE_FULL 'T' /* disk information */ #define DI_FMT_BTOT 'b' #define DI_FMT_BTOT_AVAIL 'B' #define DI_FMT_BUSED 'u' #define DI_FMT_BCUSED 'c' #define DI_FMT_BFREE 'f' #define DI_FMT_BAVAIL 'v' #define DI_FMT_BPERC_NAVAIL 'p' #define DI_FMT_BPERC_USED '1' #define DI_FMT_BPERC_BSD '2' #define DI_FMT_BPERC_AVAIL 'a' #define DI_FMT_BPERC_FREE '3' #define DI_FMT_ITOT 'i' #define DI_FMT_IUSED 'U' #define DI_FMT_IFREE 'F' #define DI_FMT_IPERC 'P' #define DI_FMT_MOUNT_TIME 'I' #define DI_FMT_MOUNT_OPTIONS 'O' #define DI_SORT_NONE 'n' #define DI_SORT_MOUNT 'm' #define DI_SORT_SPECIAL 's' #define DI_SORT_TOTAL 'T' #define DI_SORT_FREE 'f' #define DI_SORT_AVAIL 'a' #define DI_SORT_REVERSE 'r' #define DI_SORT_TYPE 't' #define DI_SORT_ASCENDING 1 #define DI_PERC_FMT " %%3.0%s%%%% " #define DI_POSIX_PERC_FMT " %%3.0%s%%%% " #define DI_JUST_LEFT 0 #define DI_JUST_RIGHT 1 typedef struct { _print_size_t low; _print_size_t high; _print_size_t dbs; /* display block size */ const char *format; const char *suffix; } sizeTable_t; static sizeTable_t sizeTable [] = { { 0, 0, 1, (char *) NULL, " " }, { 0, 0, 0, (char *) NULL, "K" }, #define DI_ONE_MEG_SZTAB 2 { 0, 0, 0, (char *) NULL, "M" }, { 0, 0, 0, (char *) NULL, "G" }, { 0, 0, 0, (char *) NULL, "T" }, { 0, 0, 0, (char *) NULL, "P" }, { 0, 0, 0, (char *) NULL, "E" }, { 0, 0, 0, (char *) NULL, "Z" }, { 0, 0, 0, (char *) NULL, "Y" } }; #define DI_SIZETAB_SIZE (sizeof (sizeTable) / sizeof (sizeTable_t)) #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif static void addTotals _((const diDiskInfo_t *, diDiskInfo_t *, int)); static void getMaxFormatLengths _((diData_t *)); static int diCompare _((const diOptions_t *, const diDiskInfo_t *, unsigned int, unsigned int)); static int findDispSize _((_print_size_t)); static Size_t istrlen _((const char *)); static char *printInfo _((diDiskInfo_t *, diOptions_t *, diOutput_t *)); static char *printSpace _((const diOptions_t *, const diOutput_t *, _fs_size_t, int)); static char *processTitles _((diOptions_t *, diOutput_t *)); static char *printPerc _((_fs_size_t, _fs_size_t, const char *)); static void initSizeTable _((diOptions_t *, diOutput_t *)); static void appendFormatStr _((char *, const char *, char **, Size_t *, Size_t *)); static void appendFormatVal _((char *, _fs_size_t, char **, Size_t *, Size_t *)); static void append _((const char *, char **, Size_t *, Size_t *)); #if defined (__cplusplus) || defined (c_plusplus) } #endif /* * printDiskInfo * * Print out the disk information table. * Loops through all mounted disks, prints and calculates totals. * * The method to get widths and handle titles and etc. is rather a * mess. There may be a better way to handle it. * */ char * #if _proto_stdc printDiskInfo (diData_t *diData) #else printDiskInfo (diData) diData_t *diData; #endif { int i; diOptions_t *diopts; diDiskInfo_t *diskInfo; diDiskInfo_t totals; char lastpool [DI_SPEC_NAME_LEN + 1]; Size_t lastpoollen = { 0 }; int inpool = { FALSE }; diOutput_t *diout; char *out; Size_t outlen; Size_t outcurrlen; char *tout; out = (char *) NULL; outlen = 0; outcurrlen = 0; lastpool[0] = '\0'; diopts = &diData->options; diout = &diData->output; initSizeTable (diopts, diout); if (diopts->printTotals) { di_initDiskInfo (&totals); strncpy (totals.name, DI_GT("Total"), (Size_t) DI_NAME_LEN); totals.printFlag = DI_PRNT_OK; } getMaxFormatLengths (diData); tout = processTitles (diopts, diout); if (diopts->printHeader) { append (tout, &out, &outcurrlen, &outlen); } free (tout); if (diopts->dispBlockSize == (_print_size_t) DI_DISP_HR || diopts->dispBlockSize == (_print_size_t) DI_DISP_HR_2) { --diout->width; } if (diopts->dispBlockSize != (_print_size_t) DI_DISP_HR && diopts->dispBlockSize != (_print_size_t) DI_DISP_HR_2 && (diopts->dispBlockSize > 0 && diopts->dispBlockSize <= (_print_size_t) DI_VAL_1024)) { if (diopts->csv_output) { Snprintf1 (diout->blockFormat, sizeof (diout->blockFormat), "%%.0%s%%s", DI_Lf); } else { Snprintf2 (diout->blockFormat, sizeof (diout->blockFormat), "%%%d.0%s%%s", (int) diout->width, DI_Lf); } } else { if (diopts->csv_output) { Snprintf1 (diout->blockFormatNR, sizeof (diout->blockFormatNR), "%%.0%s%%s", DI_Lf); if (diopts->csv_tabs) { Snprintf1 (diout->blockFormat, sizeof (diout->blockFormat), "%%.1%s%%s", DI_Lf); } else { Snprintf1 (diout->blockFormat, sizeof (diout->blockFormat), "\"%%.1%s%%s\"", DI_Lf); } } else { Snprintf2 (diout->blockFormatNR, sizeof (diout->blockFormatNR), "%%%d.0%s%%s", (int) diout->width, DI_Lf); Snprintf2 (diout->blockFormat, sizeof (diout->blockFormat), "%%%d.1%s%%s", (int) diout->width, DI_Lf); } } if (diopts->dispBlockSize == (_print_size_t) DI_DISP_HR || diopts->dispBlockSize == (_print_size_t) DI_DISP_HR_2) { ++diout->width; } if (diopts->csv_output) { Snprintf1 (diout->inodeFormat, sizeof (diout->inodeFormat), "%%%s", DI_LLu); } else { Snprintf2 (diout->inodeFormat, sizeof (diout->inodeFormat), "%%%d%s", (int) diout->inodeWidth, DI_LLu); } diskInfo = diData->diskInfo; if (diopts->printTotals) { if (diData->haspooledfs && ! diData->totsorted) { char tempSortType [DI_SORT_MAX + 1]; /* in order to find the main pool entries, */ /* we must have the array sorted by special device name */ strncpy (tempSortType, diopts->sortType, DI_SORT_MAX); strncpy (diopts->sortType, "s", DI_SORT_MAX); sortArray (diopts, diskInfo, diData->count, DI_TOT_SORT_IDX); strncpy (diopts->sortType, tempSortType, DI_SORT_MAX); diData->totsorted = TRUE; } for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; int ispooled; int startpool; ispooled = FALSE; startpool = FALSE; dinfo = &(diskInfo [diskInfo [i].sortIndex[DI_TOT_SORT_IDX]]); /* is it a pooled filesystem type? */ if (diData->haspooledfs && di_isPooledFs (dinfo)) { ispooled = TRUE; if (lastpoollen == 0 || strncmp (lastpool, dinfo->special, lastpoollen) != 0) { strncpy (lastpool, dinfo->special, DI_SPEC_NAME_LEN); lastpoollen = di_mungePoolName (lastpool); inpool = FALSE; startpool = TRUE; if (strcmp (dinfo->fsType, "null") == 0 && strcmp (dinfo->special + strlen (dinfo->special) - 5, "00000") != 0) { /* dragonflybsd doesn't have the main pool mounted */ inpool = TRUE; } } } else { inpool = FALSE; } if (dinfo->doPrint) { addTotals (dinfo, &totals, inpool); } else { if (debug > 2) { printf ("tot:%s:%s:skip\n", dinfo->special, dinfo->name); } } if (startpool) { inpool = TRUE; } } /* for each entry */ } /* if the totals are to be printed */ diskInfo = diData->diskInfo; if (strcmp (diopts->sortType, "n") != 0) { sortArray (diopts, diskInfo, diData->count, DI_MAIN_SORT_IDX); } for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &(diskInfo [diskInfo [i].sortIndex[DI_MAIN_SORT_IDX]]); if (debug > 5) { printf ("pdi:%s:%s:%d:\n", dinfo->name, getPrintFlagText ((int) dinfo->printFlag), dinfo->doPrint); } if (! dinfo->doPrint) { continue; } tout = printInfo (dinfo, diopts, diout); append (tout, &out, &outcurrlen, &outlen); free (tout); } if (diopts->printTotals) { tout = printInfo (&totals, diopts, diout); append (tout, &out, &outcurrlen, &outlen); free (tout); } return out; } /* * sortArray * */ void #if _proto_stdc sortArray (diOptions_t *diopts, diDiskInfo_t *data, int count, int sidx) #else sortArray (diopts, data, count, sidx) diOptions_t *diopts; diDiskInfo_t *data; int count; int sidx; #endif { unsigned int tempIndex; int gap; register int j; register int i; if (count <= 1) { return; } gap = 1; while (gap < count) { gap = 3 * gap + 1; } for (gap /= 3; gap > 0; gap /= 3) { for (i = gap; i < count; ++i) { tempIndex = data[i].sortIndex[sidx]; j = i - gap; while (j >= 0 && diCompare (diopts, data, data[j].sortIndex[sidx], tempIndex) > 0) { data[j + gap].sortIndex[sidx] = data[j].sortIndex[sidx]; j -= gap; } j += gap; if (j != i) { data[j].sortIndex[sidx] = tempIndex; } } } } /* for debugging */ const char * #if _proto_stdc getPrintFlagText (int pf) #else getPrintFlagText (pf) int pf; #endif { return pf == DI_PRNT_OK ? "ok" : pf == DI_PRNT_BAD ? "bad" : pf == DI_PRNT_IGNORE ? "ignore" : pf == DI_PRNT_EXCLUDE ? "exclude" : pf == DI_PRNT_OUTOFZONE ? "outofzone" : pf == DI_PRNT_FORCE ? "force" : pf == DI_PRNT_SKIP ? "skip" : "unknown"; } static void #if _proto_stdc appendFormatStr (char *fmt, const char *val, char **ptr, Size_t *clen, Size_t *len) #else appendFormatStr (fmt, val, ptr, clen, len) char *fmt; const char *val; char **ptr; Size_t *clen; Size_t *len; #endif { char tdata [1024]; Snprintf1 (tdata, sizeof(tdata), fmt, val); append (tdata, ptr, clen, len); } static void #if _proto_stdc appendFormatVal (char *fmt, _fs_size_t val, char **ptr, Size_t *clen, Size_t *len) #else appendFormatVal (fmt, val, ptr, clen, len) char *fmt; _fs_size_t val; char **ptr; Size_t *clen; Size_t *len; #endif { char tdata [1024]; Snprintf1 (tdata, sizeof(tdata), fmt, val); append (tdata, ptr, clen, len); } static void #if _proto_stdc append (const char *val, char **ptr, Size_t *clen, Size_t *len) #else append (val, ptr, len) const char *val; char **ptr; Size_t *clen; Size_t *len; #endif { Size_t vlen; Size_t bumplen; Size_t nlen; if (val == (char *) NULL) { return; } bumplen = 100; vlen = strlen (val); if (*clen + vlen >= *len) { nlen = vlen + *clen + 1; *ptr = realloc (*ptr, nlen); memset (*ptr+*clen, 0, nlen-*clen); *len = nlen; } strcat (*ptr, val); *clen += vlen; } /* * printInfo * * Print the information for a single partition. Loop through the * format string and print the particular items wanted. * */ static char * #if _proto_stdc printInfo (diDiskInfo_t *diskInfo, diOptions_t *diopts, diOutput_t *diout) #else printInfo (diskInfo, diopts, diout) diDiskInfo_t *diskInfo; diOptions_t *diopts; diOutput_t *diout; #endif { _fs_size_t used; _fs_size_t totAvail; const char *ptr; char tfmt[2]; int valid; _print_size_t temp; int idx; int tidx; static char percFormat [15]; static int percInit = FALSE; int first; char ttext[2]; char *out; char *tout; const char *t; Size_t outlen; Size_t outcurrlen; out = (char *) NULL; outlen = 0; outcurrlen = 0; first = TRUE; if (! percInit) { if (diopts->csv_output) { Snprintf1 (percFormat, sizeof(percFormat), "%%.0%s%%%%", DI_Lf); } else { if (diopts->posix_compat) { Snprintf1 (percFormat, sizeof(percFormat), DI_POSIX_PERC_FMT, DI_Lf); } else { Snprintf1 (percFormat, sizeof(percFormat), DI_PERC_FMT, DI_Lf); } } percInit = TRUE; } idx = 0; temp = (_print_size_t) 0.0; /* gcc compile warning */ if (diopts->dispBlockSize == (_print_size_t) DI_DISP_HR_2) { idx = DI_ONE_MEG_SZTAB; /* default */ ptr = diopts->formatString; while (*ptr) { valid = FALSE; switch (*ptr) { case DI_FMT_BTOT: { temp = (_print_size_t) diskInfo->totalSpace; valid = TRUE; break; } case DI_FMT_BTOT_AVAIL: { temp = (_print_size_t) (diskInfo->totalSpace - (diskInfo->freeSpace - diskInfo->availSpace)); valid = TRUE; break; } case DI_FMT_BUSED: { temp = (_print_size_t) (diskInfo->totalSpace - diskInfo->freeSpace); valid = TRUE; break; } case DI_FMT_BCUSED: { temp = (_print_size_t) (diskInfo->totalSpace - diskInfo->availSpace); valid = TRUE; break; } case DI_FMT_BFREE: { temp = (_print_size_t) diskInfo->freeSpace; valid = TRUE; break; } case DI_FMT_BAVAIL: { temp = (_print_size_t) diskInfo->availSpace; valid = TRUE; break; } } if (valid) { tidx = findDispSize (temp); /* want largest index */ if (tidx > idx) { idx = tidx; } } ++ptr; } } ptr = diopts->formatString; while (*ptr) { tfmt[0] = *ptr; tfmt[1] = '\0'; valid = strstr (DI_FMT_VALID_CHARS, tfmt) == NULL ? FALSE : TRUE; if (*ptr == DI_FMT_MOUNT_TIME && diout->maxMntTimeString == 0) { valid = FALSE; } if (valid && diopts->csv_output) { if (! first) { t = ","; if (diopts->csv_tabs) { t = " "; /* tab here */ } append (t, &out, &outcurrlen, &outlen); } first = FALSE; } switch (*ptr) { case DI_FMT_MOUNT: case DI_FMT_MOUNT_FULL: { appendFormatStr (diout->mountFormat, diskInfo->name, &out, &outcurrlen, &outlen); break; } case DI_FMT_BTOT: { tout = printSpace (diopts, diout, diskInfo->totalSpace, idx); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BTOT_AVAIL: { tout = printSpace (diopts, diout, diskInfo->totalSpace - (diskInfo->freeSpace - diskInfo->availSpace), idx); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BUSED: { tout = printSpace (diopts, diout, diskInfo->totalSpace - diskInfo->freeSpace, idx); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BCUSED: { tout = printSpace (diopts, diout, diskInfo->totalSpace - diskInfo->availSpace, idx); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BFREE: { tout = printSpace (diopts, diout, diskInfo->freeSpace, idx); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BAVAIL: { tout = printSpace (diopts, diout, diskInfo->availSpace, idx); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BPERC_NAVAIL: { used = diskInfo->totalSpace - diskInfo->availSpace; totAvail = diskInfo->totalSpace; tout = printPerc (used, totAvail, percFormat); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BPERC_USED: { used = diskInfo->totalSpace - diskInfo->freeSpace; totAvail = diskInfo->totalSpace; tout = printPerc (used, totAvail, percFormat); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BPERC_BSD: { used = diskInfo->totalSpace - diskInfo->freeSpace; totAvail = diskInfo->totalSpace - (diskInfo->freeSpace - diskInfo->availSpace); tout = printPerc (used, totAvail, percFormat); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BPERC_AVAIL: { _fs_size_t bfree; bfree = diskInfo->availSpace; totAvail = diskInfo->totalSpace; tout = printPerc (bfree, totAvail, percFormat); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_BPERC_FREE: { _fs_size_t bfree; bfree = diskInfo->freeSpace; totAvail = diskInfo->totalSpace; tout = printPerc (bfree, totAvail, percFormat); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_ITOT: { appendFormatVal (diout->inodeFormat, diskInfo->totalInodes, &out, &outcurrlen, &outlen); break; } case DI_FMT_IUSED: { appendFormatVal (diout->inodeFormat, diskInfo->totalInodes - diskInfo->freeInodes, &out, &outcurrlen, &outlen); break; } case DI_FMT_IFREE: { appendFormatVal (diout->inodeFormat, diskInfo->freeInodes, &out, &outcurrlen, &outlen); break; } case DI_FMT_IPERC: { used = diskInfo->totalInodes - diskInfo->availInodes; totAvail = diskInfo->totalInodes; tout = printPerc (used, totAvail, percFormat); append (tout, &out, &outcurrlen, &outlen); break; } case DI_FMT_SPECIAL: case DI_FMT_SPECIAL_FULL: { appendFormatStr (diout->specialFormat, diskInfo->special, &out, &outcurrlen, &outlen); break; } case DI_FMT_TYPE: case DI_FMT_TYPE_FULL: { appendFormatStr (diout->typeFormat, diskInfo->fsType, &out, &outcurrlen, &outlen); break; } case DI_FMT_MOUNT_OPTIONS: { if (diopts->csv_output && ! diopts->csv_tabs) { append ("\"", &out, &outcurrlen, &outlen); } appendFormatStr (diout->optFormat, diskInfo->options, &out, &outcurrlen, &outlen); if (diopts->csv_output && ! diopts->csv_tabs) { append ("\"", &out, &outcurrlen, &outlen); } break; } case DI_FMT_MOUNT_TIME: { break; } default: { ttext[0] = *ptr; ttext[1] = '\0'; append (ttext, &out, &outcurrlen, &outlen); break; } } ++ptr; if (! diopts->csv_output && *ptr && valid) { append (" ", &out, &outcurrlen, &outlen); } } if (outcurrlen > 0) { append ("\n", &out, &outcurrlen, &outlen); } return out; } static char * #if _proto_stdc printSpace (const diOptions_t *diopts, const diOutput_t *diout, _fs_size_t usage, int idx) #else printSpace (diopts, diout, usage, idx) const diOptions_t *diopts; const diOutput_t *diout; _fs_size_t usage; int idx; #endif { _print_size_t tdbs; _print_size_t mult; _print_size_t temp; const char *suffix; const char *format; static char tdata [1024]; suffix = ""; format = diout->blockFormat; tdbs = diopts->dispBlockSize; if (diopts->dispBlockSize == (_print_size_t) DI_DISP_HR) { temp = (_print_size_t) usage; idx = findDispSize (temp); } if (diopts->dispBlockSize == (_print_size_t) DI_DISP_HR || diopts->dispBlockSize == (_print_size_t) DI_DISP_HR_2) { if (idx == -1) { tdbs = sizeTable [DI_ONE_MEG].dbs; } else { tdbs = sizeTable [idx].dbs; format = sizeTable [idx].format; suffix = sizeTable [idx].suffix; } } mult = (_print_size_t) 1.0 / tdbs; Snprintf2 (tdata, sizeof(tdata), format, (_print_size_t) usage * mult, suffix); return tdata; } static int #if _proto_stdc findDispSize (_print_size_t siz) #else findDispSize (siz) _print_size_t siz; #endif { int i; for (i = 0; i < (int) DI_SIZETAB_SIZE; ++i) { if (siz >= sizeTable [i].low && siz < sizeTable [i].high) { return i; } } return -1; } /* * addTotals * * Add up the totals for the blocks/inodes * */ static void #if _proto_stdc addTotals (const diDiskInfo_t *diskInfo, diDiskInfo_t *totals, int inpool) #else addTotals (diskInfo, totals, inpool) const diDiskInfo_t *diskInfo; diDiskInfo_t *totals; int inpool; #endif { if (debug > 2) { printf ("tot:%s:%s:inp:%d\n", diskInfo->special, diskInfo->name, inpool); } if (inpool) { if (debug > 2) {printf (" tot:inpool:add total used\n"); } /* if in a pool of disks, add the total used to the totals also */ totals->totalSpace += diskInfo->totalSpace - diskInfo->freeSpace; totals->totalInodes += diskInfo->totalInodes - diskInfo->freeInodes; } else { if (debug > 2) {printf (" tot:not inpool:add all totals\n"); } totals->totalSpace += diskInfo->totalSpace; totals->freeSpace += diskInfo->freeSpace; totals->availSpace += diskInfo->availSpace; totals->totalInodes += diskInfo->totalInodes; totals->freeInodes += diskInfo->freeInodes; totals->availInodes += diskInfo->availInodes; } } /* * processTitles * * Sets up the column format strings w/the appropriate defaults. * Loop through the format string and adjust the various column sizes. * * At the same time print the titles. * */ static char * #if _proto_stdc processTitles (diOptions_t *diopts, diOutput_t *diout) #else processTitles (diopts, diout) diOptions_t *diopts; diOutput_t *diout; #endif { const char *ptr; int valid; Size_t wlen; Size_t *wlenptr; int justification; const char *pstr = { "" }; char *fstr; Size_t maxsize; char tformat [30]; char ttext [2]; int first; char *out; Size_t outcurrlen; Size_t outlen; out = (char *) NULL; outlen = 0; outcurrlen = 0; first = TRUE; if (diopts->printDebugHeader) { printf (DI_GT("di version %s Default Format: %s\n"), DI_VERSION, DI_DEFAULT_FORMAT); } ptr = diopts->formatString; while (*ptr) { valid = TRUE; wlen = 0; wlenptr = (Size_t *) NULL; fstr = (char *) NULL; maxsize = 0; justification = DI_JUST_LEFT; switch (*ptr) { case DI_FMT_MOUNT: { wlen = 15; wlenptr = &diout->maxMountString; pstr = "Mount"; fstr = diout->mountFormat; maxsize = sizeof (diout->mountFormat) - 1; break; } case DI_FMT_MOUNT_FULL: { wlen = diout->maxMountString; if (wlen <= 0) { wlen = 7; } wlenptr = &diout->maxMountString; fstr = diout->mountFormat; maxsize = sizeof (diout->mountFormat) - 1; if (diopts->posix_compat) { pstr = "Mounted On"; } else { pstr = "Mount"; } break; } case DI_FMT_BTOT: case DI_FMT_BTOT_AVAIL: { wlen = diout->width; wlenptr = &diout->width; justification = DI_JUST_RIGHT; pstr = diout->dispBlockLabel; break; } case DI_FMT_BUSED: case DI_FMT_BCUSED: { wlen = diout->width; wlenptr = &diout->width; justification = DI_JUST_RIGHT; pstr = "Used"; break; } case DI_FMT_BFREE: { wlen = diout->width; wlenptr = &diout->width; justification = DI_JUST_RIGHT; pstr = "Free"; break; } case DI_FMT_BAVAIL: { wlen = diout->width; wlenptr = &diout->width; justification = DI_JUST_RIGHT; if (diopts->posix_compat) { pstr = "Available"; } else { pstr = "Avail"; } break; } case DI_FMT_BPERC_NAVAIL: case DI_FMT_BPERC_USED: case DI_FMT_BPERC_BSD: { if (diopts->posix_compat) { wlen = 9; pstr = "Capacity"; } else { wlen = 6; pstr = "%Used"; } break; } case DI_FMT_BPERC_AVAIL: case DI_FMT_BPERC_FREE: { wlen = 5; pstr = "%Free"; break; } case DI_FMT_ITOT: { justification = DI_JUST_RIGHT; wlen = diout->inodeWidth; wlenptr = &diout->inodeWidth; fstr = diout->inodeLabelFormat; maxsize = sizeof (diout->inodeLabelFormat) - 1; pstr = "Inodes"; break; } case DI_FMT_IUSED: { justification = DI_JUST_RIGHT; wlen = diout->inodeWidth; wlenptr = &diout->inodeWidth; fstr = diout->inodeLabelFormat; maxsize = sizeof (diout->inodeLabelFormat) - 1; pstr = "IUsed"; break; } case DI_FMT_IFREE: { justification = DI_JUST_RIGHT; wlen = diout->inodeWidth; wlenptr = &diout->inodeWidth; fstr = diout->inodeLabelFormat; maxsize = sizeof (diout->inodeLabelFormat) - 1; pstr = "IFree"; break; } case DI_FMT_IPERC: { wlen = 6; pstr = "%IUsed"; break; } case DI_FMT_SPECIAL: { wlen = 18; wlenptr = &diout->maxSpecialString; fstr = diout->specialFormat; maxsize = sizeof (diout->specialFormat) - 1; pstr = "Filesystem"; break; } case DI_FMT_SPECIAL_FULL: { wlen = diout->maxSpecialString; wlenptr = &diout->maxSpecialString; fstr = diout->specialFormat; maxsize = sizeof (diout->specialFormat) - 1; pstr = "Filesystem"; break; } case DI_FMT_TYPE: { wlen = 7; wlenptr = &diout->maxTypeString; fstr = diout->typeFormat; maxsize = sizeof (diout->typeFormat) - 1; pstr = "fsType"; break; } case DI_FMT_TYPE_FULL: { wlen = diout->maxTypeString; wlenptr = &diout->maxTypeString; fstr = diout->typeFormat; maxsize = sizeof (diout->typeFormat) - 1; pstr = "fs Type"; break; } case DI_FMT_MOUNT_OPTIONS: { wlen = diout->maxOptString; wlenptr = &diout->maxOptString; fstr = diout->optFormat; maxsize = sizeof (diout->optFormat) - 1; pstr = "Options"; break; } case DI_FMT_MOUNT_TIME: { break; } default: { ttext[0] = *ptr; ttext[1] = '\0'; append (ttext, &out, &outcurrlen, &outlen); valid = FALSE; break; } } if (wlen > 0) { Size_t ilen; Size_t olen; Size_t len; Size_t tlen; const char *jstr; pstr = DI_GT (pstr); olen = (Size_t) strlen (pstr); ilen = (Size_t) istrlen (pstr); wlen = ilen > wlen ? ilen : wlen; len = wlen; tlen = len + olen - ilen; /* for the title only */ jstr = justification == DI_JUST_LEFT ? "-" : ""; Snprintf3 (tformat, sizeof (tformat), "%%%s%d.%ds", jstr, (int) tlen, (int) tlen); if (diopts->csv_output) { if (! first) { if (diopts->csv_tabs) { append (" ", &out, &outcurrlen, &outlen); /* tab here */ } else { append (",", &out, &outcurrlen, &outlen); } } first = FALSE; } if (diopts->csv_output) { ttext[0] = *ptr; ttext[1] = '\0'; append (ttext, &out, &outcurrlen, &outlen); } else { appendFormatStr (tformat, pstr, &out, &outcurrlen, &outlen); } if (fstr != (char *) NULL) { if (diopts->csv_output) { if (diopts->csv_tabs) { strncpy (tformat, "%s", sizeof (tformat)); } else { strncpy (tformat, "\"%s\"", sizeof (tformat)); } } if (tlen != len) { if (! diopts->csv_output) { Snprintf3 (tformat, sizeof (tformat), "%%%s%d.%ds", jstr, (int) len, (int) len); } } /* copy the format string to whereever fstr is pointing */ strncpy (fstr, tformat, maxsize); } if (wlenptr != (Size_t *) NULL) { *wlenptr = wlen; } } ++ptr; if (! diopts->csv_output && *ptr && valid) { append (" ", &out, &outcurrlen, &outlen); } } if (outcurrlen > 0) { append ("\n", &out, &outcurrlen, &outlen); } return out; } /* * printPerc * * Calculate and print a percentage using the values and format passed. * */ static char * #if _proto_stdc printPerc (_fs_size_t used, _fs_size_t totAvail, const char *format) #else printPerc (used, totAvail, format) _fs_size_t used; _fs_size_t totAvail; const char *format; #endif { _print_size_t perc; static char tdata [1024]; if (totAvail > 0L) { perc = (_print_size_t) used / (_print_size_t) totAvail; perc *= (_print_size_t) 100.0; } else { perc = (_print_size_t) 0.0; } Snprintf1 (tdata, sizeof(tdata), format, perc); return tdata; } static int #if _proto_stdc diCompare (const diOptions_t *diopts, const diDiskInfo_t *data, unsigned int idx1, unsigned int idx2) #else diCompare (diopts, data, idx1, idx2) const diOptions_t *diopts; const diDiskInfo_t *data; unsigned int idx1; unsigned int idx2; #endif { int rc; int sortOrder; const char *ptr; const diDiskInfo_t *d1; const diDiskInfo_t *d2; /* reset sort order to the default start value */ sortOrder = DI_SORT_ASCENDING; rc = 0; d1 = &(data[idx1]); d2 = &(data[idx2]); ptr = diopts->sortType; while (*ptr) { switch (*ptr) { case DI_SORT_NONE: { break; } case DI_SORT_MOUNT: { rc = strcoll (d1->name, d2->name); rc *= sortOrder; break; } case DI_SORT_REVERSE: { sortOrder *= -1; break; } case DI_SORT_SPECIAL: { rc = strcoll (d1->special, d2->special); rc *= sortOrder; break; } case DI_SORT_TYPE: { rc = strcoll (d1->fsType, d2->fsType); rc *= sortOrder; break; } case DI_SORT_AVAIL: case DI_SORT_FREE: case DI_SORT_TOTAL: { int temp; temp = 0; switch (*ptr) { case DI_SORT_AVAIL: { temp = d1->availSpace == d2->availSpace ? 0 : d1->availSpace < d2->availSpace ? -1 : 1; break; } case DI_SORT_FREE: { temp = d1->freeSpace == d2->freeSpace ? 0 : d1->freeSpace < d2->freeSpace ? -1 : 1; break; } case DI_SORT_TOTAL: { temp = d1->totalSpace == d2->totalSpace ? 0 : d1->totalSpace < d2->totalSpace ? -1 : 1; break; } } rc *= sortOrder; break; } } /* switch on sort type */ if (rc != 0) { return rc; } ++ptr; } return rc; } static void #if _proto_stdc getMaxFormatLengths (diData_t *diData) #else getMaxFormatLengths (diData) diData_t *diData; #endif { int i; unsigned int len; diOutput_t *diout; diout = &diData->output; /* this loop gets the max string lengths */ for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[i]; if (dinfo->doPrint) { if (diData->haspooledfs && (strcmp (dinfo->fsType, "zfs") == 0 || strcmp (dinfo->fsType, "advfs") == 0)) { diData->disppooledfs = TRUE; } len = (unsigned int) strlen (dinfo->name); if (len > diout->maxMountString) { diout->maxMountString = len; } len = (unsigned int) strlen (dinfo->special); if (len > diout->maxSpecialString) { diout->maxSpecialString = len; } len = (unsigned int) strlen (dinfo->fsType); if (len > diout->maxTypeString) { diout->maxTypeString = len; } len = (unsigned int) strlen (dinfo->options); if (len > diout->maxOptString) { diout->maxOptString = len; } len = (unsigned int) strlen (dinfo->mountTime); if (len > diout->maxMntTimeString) { diout->maxMntTimeString = len; } } /* if we are printing this item */ } /* for all disks */ } static Size_t #if _proto_stdc istrlen (const char *str) #else istrlen (str) const char *str; #endif { Size_t len; #if _lib_mbrlen && _enable_nls Size_t mlen; Size_t slen; mbstate_t ps; const char *tstr; len = 0; memset (&ps, 0, sizeof (mbstate_t)); slen = strlen (str); tstr = str; while (slen > 0) { mlen = mbrlen (tstr, slen, &ps); if ((int) mlen <= 0) { return strlen (str); } ++len; tstr += mlen; slen -= mlen; } #else len = strlen (str); #endif return len; } static void #if _proto_stdc initSizeTable (diOptions_t *diopts, diOutput_t *diout) #else initSizeTable (diopts, diout) diOptions_t *diopts; diOutput_t *diout; #endif { int i; /* initialize display size tables */ sizeTable [0].format = diout->blockFormatNR; sizeTable [1].format = diout->blockFormat; sizeTable [0].high = diopts->baseDispSize; sizeTable [1].low = diopts->baseDispSize; sizeTable [1].high = diopts->baseDispSize * diopts->baseDispSize; sizeTable [1].dbs = diopts->baseDispSize; for (i = 2; i < (int) DI_SIZETAB_SIZE; ++i) { sizeTable [i].format = diout->blockFormat; sizeTable [i].low = sizeTable [i - 1].low * diopts->baseDispSize; sizeTable [i].high = sizeTable [i - 1].high * diopts->baseDispSize; sizeTable [i].dbs = sizeTable [i - 1].dbs * diopts->baseDispSize; } } di-4.47/C/Perl/0000755000175000017500000000000013334050206011230 5ustar bllblldi-4.47/C/Perl/Makefile.PL0000644000175000017500000000156213334050206013206 0ustar bllblluse 5.00503; use ExtUtils::MakeMaker; # See lib/ExtUtils/MakeMaker.pm for details of how to influence # the contents of the Makefile that is written. WriteMakefile( NAME => 'Filesys::di', VERSION_FROM => 'lib/Filesys/di.pm', # finds $VERSION PREREQ_PM => {'Test' => 0, }, # e.g., Module::Name => 1.1 ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'lib/Filesys/di.pm', # retrieve abstract from module AUTHOR => 'Brad Lanam ') : ()), LIBS => ['-L.. -ldiperl'], # e.g., '-lm' DEFINE => '', # e.g., '-DHAVE_SOMETHING' INC => '-I.. -I.', # e.g., '-I. -I/usr/include/other' # Un-comment this if you add C files to link with later: # OBJECT => '$(O_FILES)', # link all the C files too ); di-4.47/C/Perl/Changes0000644000175000017500000000012613334050206012522 0ustar bllbllRevision history for Perl extension Filesys::di. 0.01 2016-2-22 - initial version di-4.47/C/Perl/README0000644000175000017500000000075513334050206012117 0ustar bllbllFilesys-di version 0.01 ======================== Perl XS does not seem to have a long long type, so there may be a loss of precision in the conversion of long long to double. INSTALLATION To install this module type the following: perl Makefile.PL make make test make install DEPENDENCIES This module requires these other modules and libraries: Test COPYRIGHT AND LICENSE Copyright (C) 2016 by Brad Lanam Distributed with 'di'. See the LICENSE file at the top level. di-4.47/C/Perl/lib/0000755000175000017500000000000013334050206011776 5ustar bllblldi-4.47/C/Perl/lib/Filesys/0000755000175000017500000000000013334050206013414 5ustar bllblldi-4.47/C/Perl/lib/Filesys/di.pm0000644000175000017500000000352413334050206014352 0ustar bllbllpackage Filesys::di; use 5.00503; use strict; require Exporter; require DynaLoader; use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS); @ISA = qw(Exporter DynaLoader); # Items to export into callers namespace by default. Note: do not export # names by default without a very good reason. Use EXPORT_OK instead. # Do not simply export all your public functions/methods/constants. # This allows declaration use Filesys::di ':all'; # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK # will save memory. %EXPORT_TAGS = ( 'all' => [ qw( ) ] ); @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } ); @EXPORT = qw( diskspace ); $VERSION = '0.01'; bootstrap Filesys::di $VERSION; # Preloaded methods go here. 1; __END__ # Below is stub documentation for your module. You'd better edit it! =head1 NAME Filesys::di - Perl extension for 'di' =head1 SYNOPSIS use Filesys::di; my $di = Filesys::di::diskspace (''); my $di = Filesys::di::diskspace ('-d 1 -f buvp'); =head1 DESCRIPTION Returns a reference to a hash. The hash keys are the mount points. Each hash contains the following keys: device (special device name), fstype (filesystem type), total, free, available, totalinodes, freeinodes, availableinodes, mountoptions. If a format is specified, the hash will also contain a 'display' key pointing to a reference to an array containing the display output from the 'di' program. Perl XS does not seem to have a long long type, so there may be a loss of precision in the conversion of long long to double. See the main 'di' documentation for usage. =head2 EXPORT None by default. =head1 SEE ALSO di(1) http://gentoo.com/di/ =head1 AUTHOR Brad Lanam, Ebrad.lanam.di@gmail.comE =head1 COPYRIGHT AND LICENSE Copyright 2016 Brad Lanam, Walnut Creek CA See the LICENSE file included with the 'di' distribution. =cut di-4.47/C/Perl/ex/0000755000175000017500000000000013334050206011644 5ustar bllblldi-4.47/C/Perl/ex/perl-example.pl0000644000175000017500000000051113334050206014571 0ustar bllblluse lib './blib/lib'; use lib './blib/arch/auto/Filesys/di'; use Filesys::di; use Data::Dumper; my $r_h = diskspace (''); print Dumper ($r_h); $r_h = Filesys::di::diskspace ('-f buvp'); if ( exists($r_h->{'/'}) ) { # unix my $r_a = $r_h->{'/'}->{'display'}; my @b = @{$r_a}; my $count = $#{$r_a}; } print Dumper ($r_h); di-4.47/C/Perl/MANIFEST0000644000175000017500000000012313334050206012355 0ustar bllbllChanges di.xs Makefile.PL MANIFEST ppport.h README t/diskspace.t lib/Filesys/di.pm di-4.47/C/Perl/t/0000755000175000017500000000000013334050206011473 5ustar bllblldi-4.47/C/Perl/t/diskspace.t0000644000175000017500000000157713334050206013640 0ustar bllbll# Before 'make install' is performed this script should be runnable with # 'make test'. After 'make install' it should work as 'perl Filesys-di.t' ######################### use strict; use warnings; use Test::More; BEGIN { use_ok( 'Filesys::di', qw(diskspace) ); } #use Data::Dumper; ######################### # Insert your test code below, the Test::More module is use()ed here so read # its man page ( perldoc Test::More ) for help writing this test script. my $h = diskspace (''); my @a = keys %{$h}; ok ($#a > 0, 'standard'); $h = diskspace ('-d 1 -f buvp'); @a = keys %{$h}; my $path = '/'; if (! exists($h->{$path})) { $path = 'C:\\'; } my $disp = $h->{$path}->{'display'}; my $count = $#{$h->{$path}->{'display'}}; ok ($#a > 0 && $count == 3, 'with arguments'); my $val = $h->{$path}->{'display'}[1]; ok ($#a > 0 && $count == 3 && $val =~ /^\d+$/, 'has a value'); done_testing(); di-4.47/C/Perl/di.xs0000644000175000017500000000702213334050206012201 0ustar bllbll#define PERL_NO_GET_CONTEXT #include "EXTERN.h" #include "perl.h" #include "XSUB.h" #include "ppport.h" #include "config.h" #include "dimain.h" #include "di.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _sys_types \ && ! defined (_DI_INC_SYS_TYPES_H) /* xenix */ # define _DI_INC_SYS_TYPES_H # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #define DI_ARGV_SEP " " /* space, tab */ #define DI_MAX_ARGV 50 static AV * parsedisp (pTHX_ char *val) { AV *a; char *dptr; a = newAV(); dptr = strtok (val, " "); /* tab character */ while (dptr != (char *) NULL) { av_push (a, newSVpv (dptr, 0)); dptr = strtok (NULL, " "); /* tab character */ } return a; } static SV * diproc (pTHX_ char *args) { int argscount; int argc; const char *argv [DI_MAX_ARGV]; char *tptr; char **dispargs; int i; diData_t diDataOut; char *rv; diDiskInfo_t *diskInfo; diDiskInfo_t *dinfo; HV *rh; HV *dh; SV *RETVAL; argv[0] = "diskspace"; if (args == (char *) NULL || strcmp (args, "") == 0) { argc = 3; argv[1] = "-f"; argv[2] = ""; argv[3] = NULL; } else { tptr = strtok (args, DI_ARGV_SEP); argc = 1; while (tptr != (char *) NULL) { if (argc >= DI_MAX_ARGV) { break; } argv[argc++] = tptr; tptr = strtok ((char *) NULL, DI_ARGV_SEP); } } rv = dimainproc (argc, argv, 1, &diDataOut); diskInfo = diDataOut.diskInfo; dispargs = (char **) malloc (sizeof(char *) * (Size_t) diDataOut.count); if (rv != (char *) NULL) { tptr = strtok (rv, "\n"); } else { tptr = (char *) NULL; } for (i = 0; i < diDataOut.count; ++i) { dinfo = &(diskInfo [diskInfo [i].sortIndex[DI_TOT_SORT_IDX]]); if (! dinfo->doPrint) { continue; } dispargs[i] = tptr; if (rv != (char *) NULL) { tptr = strtok (NULL, "\n"); } } rh = (HV *) sv_2mortal ((SV *) newHV()); for (i = 0; i < diDataOut.count; ++i) { dinfo = &(diskInfo [diskInfo [i].sortIndex[DI_TOT_SORT_IDX]]); if (! dinfo->doPrint) { continue; } dh = newHV(); /* dh = (HV *) sv_2mortal ((SV *) newHV()); */ hv_store (dh, "device", 6, newSVpv (dinfo->special, 0), 0); hv_store (dh, "fstype", 6, newSVpv (dinfo->fsType, 0), 0); hv_store (dh, "total", 5, newSVnv (dinfo->totalSpace), 0); hv_store (dh, "free", 4, newSVnv (dinfo->freeSpace), 0); hv_store (dh, "available", 9, newSVnv (dinfo->availSpace), 0); hv_store (dh, "totalinodes", 11, newSVnv (dinfo->totalInodes), 0); hv_store (dh, "freeinodes", 10, newSVnv (dinfo->freeInodes), 0); hv_store (dh, "availableinodes", 15, newSVnv (dinfo->availInodes), 0); hv_store (dh, "mountoptions", 12, newSVpv (dinfo->options, 0), 0); if (dispargs[i] != (char *) NULL) { hv_store (dh, "display", 7, newRV ((SV *) parsedisp (aTHX_ dispargs[i])), 0); } hv_store (rh, dinfo->name, (I32) strlen (dinfo->name), newRV ((SV *) dh), 0); } RETVAL = newRV ((SV *) rh); free (rv); free (dispargs); cleanup (&diDataOut); return RETVAL; } MODULE = Filesys::di PACKAGE = Filesys::di SV * diskspace (char *args) PROTOTYPE: $ CODE: RETVAL = diproc (aTHX_ args); OUTPUT: RETVAL di-4.47/C/Perl/ppport.h0000644000175000017500000054004413334050206012734 0ustar bllbll#if 0 <<'SKIP'; #endif /* ---------------------------------------------------------------------- ppport.h -- Perl/Pollution/Portability Version 3.20 Automatically created by Devel::PPPort running under perl 5.018002. Do NOT edit this file directly! -- Edit PPPort_pm.PL and the includes in parts/inc/ instead. Use 'perldoc ppport.h' to view the documentation below. ---------------------------------------------------------------------- SKIP =pod =head1 NAME ppport.h - Perl/Pollution/Portability version 3.20 =head1 SYNOPSIS perl ppport.h [options] [source files] Searches current directory for files if no [source files] are given --help show short help --version show version --patch=file write one patch file with changes --copy=suffix write changed copies with suffix --diff=program use diff program and options --compat-version=version provide compatibility with Perl version --cplusplus accept C++ comments --quiet don't output anything except fatal errors --nodiag don't show diagnostics --nohints don't show hints --nochanges don't suggest changes --nofilter don't filter input files --strip strip all script and doc functionality from ppport.h --list-provided list provided API --list-unsupported list unsupported API --api-info=name show Perl API portability information =head1 COMPATIBILITY This version of F is designed to support operation with Perl installations back to 5.003, and has been tested up to 5.11.5. =head1 OPTIONS =head2 --help Display a brief usage summary. =head2 --version Display the version of F. =head2 --patch=I If this option is given, a single patch file will be created if any changes are suggested. This requires a working diff program to be installed on your system. =head2 --copy=I If this option is given, a copy of each file will be saved with the given suffix that contains the suggested changes. This does not require any external programs. Note that this does not automagially add a dot between the original filename and the suffix. If you want the dot, you have to include it in the option argument. If neither C<--patch> or C<--copy> are given, the default is to simply print the diffs for each file. This requires either C or a C program to be installed. =head2 --diff=I Manually set the diff program and options to use. The default is to use C, when installed, and output unified context diffs. =head2 --compat-version=I Tell F to check for compatibility with the given Perl version. The default is to check for compatibility with Perl version 5.003. You can use this option to reduce the output of F if you intend to be backward compatible only down to a certain Perl version. =head2 --cplusplus Usually, F will detect C++ style comments and replace them with C style comments for portability reasons. Using this option instructs F to leave C++ comments untouched. =head2 --quiet Be quiet. Don't print anything except fatal errors. =head2 --nodiag Don't output any diagnostic messages. Only portability alerts will be printed. =head2 --nohints Don't output any hints. Hints often contain useful portability notes. Warnings will still be displayed. =head2 --nochanges Don't suggest any changes. Only give diagnostic output and hints unless these are also deactivated. =head2 --nofilter Don't filter the list of input files. By default, files not looking like source code (i.e. not *.xs, *.c, *.cc, *.cpp or *.h) are skipped. =head2 --strip Strip all script and documentation functionality from F. This reduces the size of F dramatically and may be useful if you want to include F in smaller modules without increasing their distribution size too much. The stripped F will have a C<--unstrip> option that allows you to undo the stripping, but only if an appropriate C module is installed. =head2 --list-provided Lists the API elements for which compatibility is provided by F. Also lists if it must be explicitly requested, if it has dependencies, and if there are hints or warnings for it. =head2 --list-unsupported Lists the API elements that are known not to be supported by F and below which version of Perl they probably won't be available or work. =head2 --api-info=I Show portability information for API elements matching I. If I is surrounded by slashes, it is interpreted as a regular expression. =head1 DESCRIPTION In order for a Perl extension (XS) module to be as portable as possible across differing versions of Perl itself, certain steps need to be taken. =over 4 =item * Including this header is the first major one. This alone will give you access to a large part of the Perl API that hasn't been available in earlier Perl releases. Use perl ppport.h --list-provided to see which API elements are provided by ppport.h. =item * You should avoid using deprecated parts of the API. For example, using global Perl variables without the C prefix is deprecated. Also, some API functions used to have a C prefix. Using this form is also deprecated. You can safely use the supported API, as F will provide wrappers for older Perl versions. =item * If you use one of a few functions or variables that were not present in earlier versions of Perl, and that can't be provided using a macro, you have to explicitly request support for these functions by adding one or more C<#define>s in your source code before the inclusion of F. These functions or variables will be marked C in the list shown by C<--list-provided>. Depending on whether you module has a single or multiple files that use such functions or variables, you want either C or global variants. For a C function or variable (used only in a single source file), use: #define NEED_function #define NEED_variable For a global function or variable (used in multiple source files), use: #define NEED_function_GLOBAL #define NEED_variable_GLOBAL Note that you mustn't have more than one global request for the same function or variable in your project. Function / Variable Static Request Global Request ----------------------------------------------------------------------------------------- PL_parser NEED_PL_parser NEED_PL_parser_GLOBAL PL_signals NEED_PL_signals NEED_PL_signals_GLOBAL eval_pv() NEED_eval_pv NEED_eval_pv_GLOBAL grok_bin() NEED_grok_bin NEED_grok_bin_GLOBAL grok_hex() NEED_grok_hex NEED_grok_hex_GLOBAL grok_number() NEED_grok_number NEED_grok_number_GLOBAL grok_numeric_radix() NEED_grok_numeric_radix NEED_grok_numeric_radix_GLOBAL grok_oct() NEED_grok_oct NEED_grok_oct_GLOBAL load_module() NEED_load_module NEED_load_module_GLOBAL my_snprintf() NEED_my_snprintf NEED_my_snprintf_GLOBAL my_sprintf() NEED_my_sprintf NEED_my_sprintf_GLOBAL my_strlcat() NEED_my_strlcat NEED_my_strlcat_GLOBAL my_strlcpy() NEED_my_strlcpy NEED_my_strlcpy_GLOBAL newCONSTSUB() NEED_newCONSTSUB NEED_newCONSTSUB_GLOBAL newRV_noinc() NEED_newRV_noinc NEED_newRV_noinc_GLOBAL newSV_type() NEED_newSV_type NEED_newSV_type_GLOBAL newSVpvn_flags() NEED_newSVpvn_flags NEED_newSVpvn_flags_GLOBAL newSVpvn_share() NEED_newSVpvn_share NEED_newSVpvn_share_GLOBAL pv_display() NEED_pv_display NEED_pv_display_GLOBAL pv_escape() NEED_pv_escape NEED_pv_escape_GLOBAL pv_pretty() NEED_pv_pretty NEED_pv_pretty_GLOBAL sv_2pv_flags() NEED_sv_2pv_flags NEED_sv_2pv_flags_GLOBAL sv_2pvbyte() NEED_sv_2pvbyte NEED_sv_2pvbyte_GLOBAL sv_catpvf_mg() NEED_sv_catpvf_mg NEED_sv_catpvf_mg_GLOBAL sv_catpvf_mg_nocontext() NEED_sv_catpvf_mg_nocontext NEED_sv_catpvf_mg_nocontext_GLOBAL sv_pvn_force_flags() NEED_sv_pvn_force_flags NEED_sv_pvn_force_flags_GLOBAL sv_setpvf_mg() NEED_sv_setpvf_mg NEED_sv_setpvf_mg_GLOBAL sv_setpvf_mg_nocontext() NEED_sv_setpvf_mg_nocontext NEED_sv_setpvf_mg_nocontext_GLOBAL vload_module() NEED_vload_module NEED_vload_module_GLOBAL vnewSVpvf() NEED_vnewSVpvf NEED_vnewSVpvf_GLOBAL warner() NEED_warner NEED_warner_GLOBAL To avoid namespace conflicts, you can change the namespace of the explicitly exported functions / variables using the C macro. Just C<#define> the macro before including C: #define DPPP_NAMESPACE MyOwnNamespace_ #include "ppport.h" The default namespace is C. =back The good thing is that most of the above can be checked by running F on your source code. See the next section for details. =head1 EXAMPLES To verify whether F is needed for your module, whether you should make any changes to your code, and whether any special defines should be used, F can be run as a Perl script to check your source code. Simply say: perl ppport.h The result will usually be a list of patches suggesting changes that should at least be acceptable, if not necessarily the most efficient solution, or a fix for all possible problems. If you know that your XS module uses features only available in newer Perl releases, if you're aware that it uses C++ comments, and if you want all suggestions as a single patch file, you could use something like this: perl ppport.h --compat-version=5.6.0 --cplusplus --patch=test.diff If you only want your code to be scanned without any suggestions for changes, use: perl ppport.h --nochanges You can specify a different C program or options, using the C<--diff> option: perl ppport.h --diff='diff -C 10' This would output context diffs with 10 lines of context. If you want to create patched copies of your files instead, use: perl ppport.h --copy=.new To display portability information for the C function, use: perl ppport.h --api-info=newSVpvn Since the argument to C<--api-info> can be a regular expression, you can use perl ppport.h --api-info=/_nomg$/ to display portability information for all C<_nomg> functions or perl ppport.h --api-info=/./ to display information for all known API elements. =head1 BUGS If this version of F is causing failure during the compilation of this module, please check if newer versions of either this module or C are available on CPAN before sending a bug report. If F was generated using the latest version of C and is causing failure of this module, please file a bug report using the CPAN Request Tracker at L. Please include the following information: =over 4 =item 1. The complete output from running "perl -V" =item 2. This file. =item 3. The name and version of the module you were trying to build. =item 4. A full log of the build that failed. =item 5. Any other information that you think could be relevant. =back For the latest version of this code, please get the C module from CPAN. =head1 COPYRIGHT Version 3.x, Copyright (c) 2004-2010, Marcus Holland-Moritz. Version 2.x, Copyright (C) 2001, Paul Marquess. Version 1.x, Copyright (C) 1999, Kenneth Albanowski. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO See L. =cut use strict; # Disable broken TRIE-optimization BEGIN { eval '${^RE_TRIE_MAXBUF} = -1' if $] >= 5.009004 && $] <= 5.009005 } my $VERSION = 3.20; my %opt = ( quiet => 0, diag => 1, hints => 1, changes => 1, cplusplus => 0, filter => 1, strip => 0, version => 0, ); my($ppport) = $0 =~ /([\w.]+)$/; my $LF = '(?:\r\n|[\r\n])'; # line feed my $HS = "[ \t]"; # horizontal whitespace # Never use C comments in this file! my $ccs = '/'.'*'; my $cce = '*'.'/'; my $rccs = quotemeta $ccs; my $rcce = quotemeta $cce; eval { require Getopt::Long; Getopt::Long::GetOptions(\%opt, qw( help quiet diag! filter! hints! changes! cplusplus strip version patch=s copy=s diff=s compat-version=s list-provided list-unsupported api-info=s )) or usage(); }; if ($@ and grep /^-/, @ARGV) { usage() if "@ARGV" =~ /^--?h(?:elp)?$/; die "Getopt::Long not found. Please don't use any options.\n"; } if ($opt{version}) { print "This is $0 $VERSION.\n"; exit 0; } usage() if $opt{help}; strip() if $opt{strip}; if (exists $opt{'compat-version'}) { my($r,$v,$s) = eval { parse_version($opt{'compat-version'}) }; if ($@) { die "Invalid version number format: '$opt{'compat-version'}'\n"; } die "Only Perl 5 is supported\n" if $r != 5; die "Invalid version number: $opt{'compat-version'}\n" if $v >= 1000 || $s >= 1000; $opt{'compat-version'} = sprintf "%d.%03d%03d", $r, $v, $s; } else { $opt{'compat-version'} = 5; } my %API = map { /^(\w+)\|([^|]*)\|([^|]*)\|(\w*)$/ ? ( $1 => { ($2 ? ( base => $2 ) : ()), ($3 ? ( todo => $3 ) : ()), (index($4, 'v') >= 0 ? ( varargs => 1 ) : ()), (index($4, 'p') >= 0 ? ( provided => 1 ) : ()), (index($4, 'n') >= 0 ? ( nothxarg => 1 ) : ()), } ) : die "invalid spec: $_" } qw( AvFILLp|5.004050||p AvFILL||| BhkDISABLE||5.014000| BhkENABLE||5.014000| BhkENTRY_set||5.014000| BhkENTRY||| BhkFLAGS||| CALL_BLOCK_HOOKS||| CLASS|||n CPERLscope|5.005000||p CX_CURPAD_SAVE||| CX_CURPAD_SV||| CopFILEAV|5.006000||p CopFILEGV_set|5.006000||p CopFILEGV|5.006000||p CopFILESV|5.006000||p CopFILE_set|5.006000||p CopFILE|5.006000||p CopSTASHPV_set|5.006000||p CopSTASHPV|5.006000||p CopSTASH_eq|5.006000||p CopSTASH_set|5.006000||p CopSTASH|5.006000||p CopyD|5.009002||p Copy||| CvPADLIST||| CvSTASH||| CvWEAKOUTSIDE||| DEFSV_set|5.010001||p DEFSV|5.004050||p END_EXTERN_C|5.005000||p ENTER||| ERRSV|5.004050||p EXTEND||| EXTERN_C|5.005000||p F0convert|||n FREETMPS||| GIMME_V||5.004000|n GIMME|||n GROK_NUMERIC_RADIX|5.007002||p G_ARRAY||| G_DISCARD||| G_EVAL||| G_METHOD|5.006001||p G_NOARGS||| G_SCALAR||| G_VOID||5.004000| GetVars||| GvSVn|5.009003||p GvSV||| Gv_AMupdate||5.011000| HEf_SVKEY||5.004000| HeHASH||5.004000| HeKEY||5.004000| HeKLEN||5.004000| HePV||5.004000| HeSVKEY_force||5.004000| HeSVKEY_set||5.004000| HeSVKEY||5.004000| HeUTF8||5.010001| HeVAL||5.004000| HvENAME||5.013007| HvNAMELEN_get|5.009003||p HvNAME_get|5.009003||p HvNAME||| INT2PTR|5.006000||p IN_LOCALE_COMPILETIME|5.007002||p IN_LOCALE_RUNTIME|5.007002||p IN_LOCALE|5.007002||p IN_PERL_COMPILETIME|5.008001||p IS_NUMBER_GREATER_THAN_UV_MAX|5.007002||p IS_NUMBER_INFINITY|5.007002||p IS_NUMBER_IN_UV|5.007002||p IS_NUMBER_NAN|5.007003||p IS_NUMBER_NEG|5.007002||p IS_NUMBER_NOT_INT|5.007002||p IVSIZE|5.006000||p IVTYPE|5.006000||p IVdf|5.006000||p LEAVE||| LINKLIST||5.013006| LVRET||| MARK||| MULTICALL||5.014000| MY_CXT_CLONE|5.009002||p MY_CXT_INIT|5.007003||p MY_CXT|5.007003||p MoveD|5.009002||p Move||| NOOP|5.005000||p NUM2PTR|5.006000||p NVTYPE|5.006000||p NVef|5.006001||p NVff|5.006001||p NVgf|5.006001||p Newxc|5.009003||p Newxz|5.009003||p Newx|5.009003||p Nullav||| Nullch||| Nullcv||| Nullhv||| Nullsv||| OP_CLASS||5.013007| OP_DESC||5.007003| OP_NAME||5.007003| ORIGMARK||| PAD_BASE_SV||| PAD_CLONE_VARS||| PAD_COMPNAME_FLAGS||| PAD_COMPNAME_GEN_set||| PAD_COMPNAME_GEN||| PAD_COMPNAME_OURSTASH||| PAD_COMPNAME_PV||| PAD_COMPNAME_TYPE||| PAD_DUP||| PAD_RESTORE_LOCAL||| PAD_SAVE_LOCAL||| PAD_SAVE_SETNULLPAD||| PAD_SETSV||| PAD_SET_CUR_NOSAVE||| PAD_SET_CUR||| PAD_SVl||| PAD_SV||| PERLIO_FUNCS_CAST|5.009003||p PERLIO_FUNCS_DECL|5.009003||p PERL_ABS|5.008001||p PERL_BCDVERSION|5.014000||p PERL_GCC_BRACE_GROUPS_FORBIDDEN|5.008001||p PERL_HASH|5.004000||p PERL_INT_MAX|5.004000||p PERL_INT_MIN|5.004000||p PERL_LONG_MAX|5.004000||p PERL_LONG_MIN|5.004000||p PERL_MAGIC_arylen|5.007002||p PERL_MAGIC_backref|5.007002||p PERL_MAGIC_bm|5.007002||p PERL_MAGIC_collxfrm|5.007002||p PERL_MAGIC_dbfile|5.007002||p PERL_MAGIC_dbline|5.007002||p PERL_MAGIC_defelem|5.007002||p PERL_MAGIC_envelem|5.007002||p PERL_MAGIC_env|5.007002||p PERL_MAGIC_ext|5.007002||p PERL_MAGIC_fm|5.007002||p PERL_MAGIC_glob|5.014000||p PERL_MAGIC_isaelem|5.007002||p PERL_MAGIC_isa|5.007002||p PERL_MAGIC_mutex|5.014000||p PERL_MAGIC_nkeys|5.007002||p PERL_MAGIC_overload_elem|5.007002||p PERL_MAGIC_overload_table|5.007002||p PERL_MAGIC_overload|5.007002||p PERL_MAGIC_pos|5.007002||p PERL_MAGIC_qr|5.007002||p PERL_MAGIC_regdata|5.007002||p PERL_MAGIC_regdatum|5.007002||p PERL_MAGIC_regex_global|5.007002||p PERL_MAGIC_shared_scalar|5.007003||p PERL_MAGIC_shared|5.007003||p PERL_MAGIC_sigelem|5.007002||p PERL_MAGIC_sig|5.007002||p PERL_MAGIC_substr|5.007002||p PERL_MAGIC_sv|5.007002||p PERL_MAGIC_taint|5.007002||p PERL_MAGIC_tiedelem|5.007002||p PERL_MAGIC_tiedscalar|5.007002||p PERL_MAGIC_tied|5.007002||p PERL_MAGIC_utf8|5.008001||p PERL_MAGIC_uvar_elem|5.007003||p PERL_MAGIC_uvar|5.007002||p PERL_MAGIC_vec|5.007002||p PERL_MAGIC_vstring|5.008001||p PERL_PV_ESCAPE_ALL|5.009004||p PERL_PV_ESCAPE_FIRSTCHAR|5.009004||p PERL_PV_ESCAPE_NOBACKSLASH|5.009004||p PERL_PV_ESCAPE_NOCLEAR|5.009004||p PERL_PV_ESCAPE_QUOTE|5.009004||p PERL_PV_ESCAPE_RE|5.009005||p PERL_PV_ESCAPE_UNI_DETECT|5.009004||p PERL_PV_ESCAPE_UNI|5.009004||p PERL_PV_PRETTY_DUMP|5.009004||p PERL_PV_PRETTY_ELLIPSES|5.010000||p PERL_PV_PRETTY_LTGT|5.009004||p PERL_PV_PRETTY_NOCLEAR|5.010000||p PERL_PV_PRETTY_QUOTE|5.009004||p PERL_PV_PRETTY_REGPROP|5.009004||p PERL_QUAD_MAX|5.004000||p PERL_QUAD_MIN|5.004000||p PERL_REVISION|5.006000||p PERL_SCAN_ALLOW_UNDERSCORES|5.007003||p PERL_SCAN_DISALLOW_PREFIX|5.007003||p PERL_SCAN_GREATER_THAN_UV_MAX|5.007003||p PERL_SCAN_SILENT_ILLDIGIT|5.008001||p PERL_SHORT_MAX|5.004000||p PERL_SHORT_MIN|5.004000||p PERL_SIGNALS_UNSAFE_FLAG|5.008001||p PERL_SUBVERSION|5.006000||p PERL_SYS_INIT3||5.006000| PERL_SYS_INIT||| PERL_SYS_TERM||5.014000| PERL_UCHAR_MAX|5.004000||p PERL_UCHAR_MIN|5.004000||p PERL_UINT_MAX|5.004000||p PERL_UINT_MIN|5.004000||p PERL_ULONG_MAX|5.004000||p PERL_ULONG_MIN|5.004000||p PERL_UNUSED_ARG|5.009003||p PERL_UNUSED_CONTEXT|5.009004||p PERL_UNUSED_DECL|5.007002||p PERL_UNUSED_VAR|5.007002||p PERL_UQUAD_MAX|5.004000||p PERL_UQUAD_MIN|5.004000||p PERL_USE_GCC_BRACE_GROUPS|5.009004||p PERL_USHORT_MAX|5.004000||p PERL_USHORT_MIN|5.004000||p PERL_VERSION|5.006000||p PL_DBsignal|5.005000||p PL_DBsingle|||pn PL_DBsub|||pn PL_DBtrace|||pn PL_Sv|5.005000||p PL_bufend|5.014000||p PL_bufptr|5.014000||p PL_compiling|5.004050||p PL_copline|5.014000||p PL_curcop|5.004050||p PL_curstash|5.004050||p PL_debstash|5.004050||p PL_defgv|5.004050||p PL_diehook|5.004050||p PL_dirty|5.004050||p PL_dowarn|||pn PL_errgv|5.004050||p PL_error_count|5.014000||p PL_expect|5.014000||p PL_hexdigit|5.005000||p PL_hints|5.005000||p PL_in_my_stash|5.014000||p PL_in_my|5.014000||p PL_keyword_plugin||5.011002| PL_last_in_gv|||n PL_laststatval|5.005000||p PL_lex_state|5.014000||p PL_lex_stuff|5.014000||p PL_linestr|5.014000||p PL_modglobal||5.005000|n PL_na|5.004050||pn PL_no_modify|5.006000||p PL_ofsgv|||n PL_opfreehook||5.011000|n PL_parser|5.009005|5.009005|p PL_peepp||5.007003|n PL_perl_destruct_level|5.004050||p PL_perldb|5.004050||p PL_ppaddr|5.006000||p PL_rpeepp||5.013005|n PL_rsfp_filters|5.014000||p PL_rsfp|5.014000||p PL_rs|||n PL_signals|5.008001||p PL_stack_base|5.004050||p PL_stack_sp|5.004050||p PL_statcache|5.005000||p PL_stdingv|5.004050||p PL_sv_arenaroot|5.004050||p PL_sv_no|5.004050||pn PL_sv_undef|5.004050||pn PL_sv_yes|5.004050||pn PL_tainted|5.004050||p PL_tainting|5.004050||p PL_tokenbuf|5.014000||p POP_MULTICALL||5.014000| POPi|||n POPl|||n POPn|||n POPpbytex||5.007001|n POPpx||5.005030|n POPp|||n POPs|||n PTR2IV|5.006000||p PTR2NV|5.006000||p PTR2UV|5.006000||p PTR2nat|5.009003||p PTR2ul|5.007001||p PTRV|5.006000||p PUSHMARK||| PUSH_MULTICALL||5.014000| PUSHi||| PUSHmortal|5.009002||p PUSHn||| PUSHp||| PUSHs||| PUSHu|5.004000||p PUTBACK||| PerlIO_clearerr||5.007003| PerlIO_close||5.007003| PerlIO_context_layers||5.009004| PerlIO_eof||5.007003| PerlIO_error||5.007003| PerlIO_fileno||5.007003| PerlIO_fill||5.007003| PerlIO_flush||5.007003| PerlIO_get_base||5.007003| PerlIO_get_bufsiz||5.007003| PerlIO_get_cnt||5.007003| PerlIO_get_ptr||5.007003| PerlIO_read||5.007003| PerlIO_seek||5.007003| PerlIO_set_cnt||5.007003| PerlIO_set_ptrcnt||5.007003| PerlIO_setlinebuf||5.007003| PerlIO_stderr||5.007003| PerlIO_stdin||5.007003| PerlIO_stdout||5.007003| PerlIO_tell||5.007003| PerlIO_unread||5.007003| PerlIO_write||5.007003| Perl_signbit||5.009005|n PoisonFree|5.009004||p PoisonNew|5.009004||p PoisonWith|5.009004||p Poison|5.008000||p RETVAL|||n Renewc||| Renew||| SAVECLEARSV||| SAVECOMPPAD||| SAVEPADSV||| SAVETMPS||| SAVE_DEFSV|5.004050||p SPAGAIN||| SP||| START_EXTERN_C|5.005000||p START_MY_CXT|5.007003||p STMT_END|||p STMT_START|||p STR_WITH_LEN|5.009003||p ST||| SV_CONST_RETURN|5.009003||p SV_COW_DROP_PV|5.008001||p SV_COW_SHARED_HASH_KEYS|5.009005||p SV_GMAGIC|5.007002||p SV_HAS_TRAILING_NUL|5.009004||p SV_IMMEDIATE_UNREF|5.007001||p SV_MUTABLE_RETURN|5.009003||p SV_NOSTEAL|5.009002||p SV_SMAGIC|5.009003||p SV_UTF8_NO_ENCODING|5.008001||p SVfARG|5.009005||p SVf_UTF8|5.006000||p SVf|5.006000||p SVt_IV||| SVt_NV||| SVt_PVAV||| SVt_PVCV||| SVt_PVHV||| SVt_PVMG||| SVt_PV||| Safefree||| Slab_Alloc||| Slab_Free||| Slab_to_rw||| StructCopy||| SvCUR_set||| SvCUR||| SvEND||| SvGAMAGIC||5.006001| SvGETMAGIC|5.004050||p SvGROW||| SvIOK_UV||5.006000| SvIOK_notUV||5.006000| SvIOK_off||| SvIOK_only_UV||5.006000| SvIOK_only||| SvIOK_on||| SvIOKp||| SvIOK||| SvIVX||| SvIV_nomg|5.009001||p SvIV_set||| SvIVx||| SvIV||| SvIsCOW_shared_hash||5.008003| SvIsCOW||5.008003| SvLEN_set||| SvLEN||| SvLOCK||5.007003| SvMAGIC_set|5.009003||p SvNIOK_off||| SvNIOKp||| SvNIOK||| SvNOK_off||| SvNOK_only||| SvNOK_on||| SvNOKp||| SvNOK||| SvNVX||| SvNV_nomg||5.013002| SvNV_set||| SvNVx||| SvNV||| SvOK||| SvOOK_offset||5.011000| SvOOK||| SvPOK_off||| SvPOK_only_UTF8||5.006000| SvPOK_only||| SvPOK_on||| SvPOKp||| SvPOK||| SvPVX_const|5.009003||p SvPVX_mutable|5.009003||p SvPVX||| SvPV_const|5.009003||p SvPV_flags_const_nolen|5.009003||p SvPV_flags_const|5.009003||p SvPV_flags_mutable|5.009003||p SvPV_flags|5.007002||p SvPV_force_flags_mutable|5.009003||p SvPV_force_flags_nolen|5.009003||p SvPV_force_flags|5.007002||p SvPV_force_mutable|5.009003||p SvPV_force_nolen|5.009003||p SvPV_force_nomg_nolen|5.009003||p SvPV_force_nomg|5.007002||p SvPV_force|||p SvPV_mutable|5.009003||p SvPV_nolen_const|5.009003||p SvPV_nolen|5.006000||p SvPV_nomg_const_nolen|5.009003||p SvPV_nomg_const|5.009003||p SvPV_nomg_nolen||5.013007| SvPV_nomg|5.007002||p SvPV_renew|5.009003||p SvPV_set||| SvPVbyte_force||5.009002| SvPVbyte_nolen||5.006000| SvPVbytex_force||5.006000| SvPVbytex||5.006000| SvPVbyte|5.006000||p SvPVutf8_force||5.006000| SvPVutf8_nolen||5.006000| SvPVutf8x_force||5.006000| SvPVutf8x||5.006000| SvPVutf8||5.006000| SvPVx||| SvPV||| SvREFCNT_dec||| SvREFCNT_inc_NN|5.009004||p SvREFCNT_inc_simple_NN|5.009004||p SvREFCNT_inc_simple_void_NN|5.009004||p SvREFCNT_inc_simple_void|5.009004||p SvREFCNT_inc_simple|5.009004||p SvREFCNT_inc_void_NN|5.009004||p SvREFCNT_inc_void|5.009004||p SvREFCNT_inc|||p SvREFCNT||| SvROK_off||| SvROK_on||| SvROK||| SvRV_set|5.009003||p SvRV||| SvRXOK||5.009005| SvRX||5.009005| SvSETMAGIC||| SvSHARED_HASH|5.009003||p SvSHARE||5.007003| SvSTASH_set|5.009003||p SvSTASH||| SvSetMagicSV_nosteal||5.004000| SvSetMagicSV||5.004000| SvSetSV_nosteal||5.004000| SvSetSV||| SvTAINTED_off||5.004000| SvTAINTED_on||5.004000| SvTAINTED||5.004000| SvTAINT||| SvTRUE_nomg||5.013006| SvTRUE||| SvTYPE||| SvUNLOCK||5.007003| SvUOK|5.007001|5.006000|p SvUPGRADE||| SvUTF8_off||5.006000| SvUTF8_on||5.006000| SvUTF8||5.006000| SvUVXx|5.004000||p SvUVX|5.004000||p SvUV_nomg|5.009001||p SvUV_set|5.009003||p SvUVx|5.004000||p SvUV|5.004000||p SvVOK||5.008001| SvVSTRING_mg|5.009004||p THIS|||n UNDERBAR|5.009002||p UTF8_MAXBYTES|5.009002||p UVSIZE|5.006000||p UVTYPE|5.006000||p UVXf|5.007001||p UVof|5.006000||p UVuf|5.006000||p UVxf|5.006000||p WARN_ALL|5.006000||p WARN_AMBIGUOUS|5.006000||p WARN_ASSERTIONS|5.014000||p WARN_BAREWORD|5.006000||p WARN_CLOSED|5.006000||p WARN_CLOSURE|5.006000||p WARN_DEBUGGING|5.006000||p WARN_DEPRECATED|5.006000||p WARN_DIGIT|5.006000||p WARN_EXEC|5.006000||p WARN_EXITING|5.006000||p WARN_GLOB|5.006000||p WARN_INPLACE|5.006000||p WARN_INTERNAL|5.006000||p WARN_IO|5.006000||p WARN_LAYER|5.008000||p WARN_MALLOC|5.006000||p WARN_MISC|5.006000||p WARN_NEWLINE|5.006000||p WARN_NUMERIC|5.006000||p WARN_ONCE|5.006000||p WARN_OVERFLOW|5.006000||p WARN_PACK|5.006000||p WARN_PARENTHESIS|5.006000||p WARN_PIPE|5.006000||p WARN_PORTABLE|5.006000||p WARN_PRECEDENCE|5.006000||p WARN_PRINTF|5.006000||p WARN_PROTOTYPE|5.006000||p WARN_QW|5.006000||p WARN_RECURSION|5.006000||p WARN_REDEFINE|5.006000||p WARN_REGEXP|5.006000||p WARN_RESERVED|5.006000||p WARN_SEMICOLON|5.006000||p WARN_SEVERE|5.006000||p WARN_SIGNAL|5.006000||p WARN_SUBSTR|5.006000||p WARN_SYNTAX|5.006000||p WARN_TAINT|5.006000||p WARN_THREADS|5.008000||p WARN_UNINITIALIZED|5.006000||p WARN_UNOPENED|5.006000||p WARN_UNPACK|5.006000||p WARN_UNTIE|5.006000||p WARN_UTF8|5.006000||p WARN_VOID|5.006000||p XCPT_CATCH|5.009002||p XCPT_RETHROW|5.009002||p XCPT_TRY_END|5.009002||p XCPT_TRY_START|5.009002||p XPUSHi||| XPUSHmortal|5.009002||p XPUSHn||| XPUSHp||| XPUSHs||| XPUSHu|5.004000||p XSPROTO|5.010000||p XSRETURN_EMPTY||| XSRETURN_IV||| XSRETURN_NO||| XSRETURN_NV||| XSRETURN_PV||| XSRETURN_UNDEF||| XSRETURN_UV|5.008001||p XSRETURN_YES||| XSRETURN|||p XST_mIV||| XST_mNO||| XST_mNV||| XST_mPV||| XST_mUNDEF||| XST_mUV|5.008001||p XST_mYES||| XS_APIVERSION_BOOTCHECK||5.013004| XS_VERSION_BOOTCHECK||| XS_VERSION||| XSprePUSH|5.006000||p XS||| XopDISABLE||5.014000| XopENABLE||5.014000| XopENTRY_set||5.014000| XopENTRY||5.014000| XopFLAGS||5.013007| ZeroD|5.009002||p Zero||| _aMY_CXT|5.007003||p _append_range_to_invlist||| _new_invlist||| _pMY_CXT|5.007003||p _swash_inversion_hash||| _swash_to_invlist||| aMY_CXT_|5.007003||p aMY_CXT|5.007003||p aTHXR_|5.014000||p aTHXR|5.014000||p aTHX_|5.006000||p aTHX|5.006000||p add_alternate||| add_cp_to_invlist||| add_data|||n add_range_to_invlist||| add_utf16_textfilter||| addmad||| allocmy||| amagic_call||| amagic_cmp_locale||| amagic_cmp||| amagic_deref_call||5.013007| amagic_i_ncmp||| amagic_ncmp||| anonymise_cv_maybe||| any_dup||| ao||| append_madprops||| apply_attrs_my||| apply_attrs_string||5.006001| apply_attrs||| apply||| assert_uft8_cache_coherent||| atfork_lock||5.007003|n atfork_unlock||5.007003|n av_arylen_p||5.009003| av_clear||| av_create_and_push||5.009005| av_create_and_unshift_one||5.009005| av_delete||5.006000| av_exists||5.006000| av_extend||| av_fetch||| av_fill||| av_iter_p||5.011000| av_len||| av_make||| av_pop||| av_push||| av_reify||| av_shift||| av_store||| av_undef||| av_unshift||| ax|||n bad_type||| bind_match||| block_end||| block_gimme||5.004000| block_start||| blockhook_register||5.013003| boolSV|5.004000||p boot_core_PerlIO||| boot_core_UNIVERSAL||| boot_core_mro||| bytes_cmp_utf8||5.013007| bytes_from_utf8||5.007001| bytes_to_uni|||n bytes_to_utf8||5.006001| call_argv|5.006000||p call_atexit||5.006000| call_list||5.004000| call_method|5.006000||p call_pv|5.006000||p call_sv|5.006000||p caller_cx||5.013005| calloc||5.007002|n cando||| cast_i32||5.006000| cast_iv||5.006000| cast_ulong||5.006000| cast_uv||5.006000| check_type_and_open||| check_uni||| check_utf8_print||| checkcomma||| checkposixcc||| ckWARN|5.006000||p ck_entersub_args_list||5.013006| ck_entersub_args_proto_or_list||5.013006| ck_entersub_args_proto||5.013006| ck_warner_d||5.011001|v ck_warner||5.011001|v ckwarn_common||| ckwarn_d||5.009003| ckwarn||5.009003| cl_and|||n cl_anything|||n cl_init|||n cl_is_anything|||n cl_or|||n clear_placeholders||| clone_params_del|||n clone_params_new|||n closest_cop||| convert||| cop_free||| cop_hints_2hv||5.013007| cop_hints_fetch_pvn||5.013007| cop_hints_fetch_pvs||5.013007| cop_hints_fetch_pv||5.013007| cop_hints_fetch_sv||5.013007| cophh_2hv||5.013007| cophh_copy||5.013007| cophh_delete_pvn||5.013007| cophh_delete_pvs||5.013007| cophh_delete_pv||5.013007| cophh_delete_sv||5.013007| cophh_fetch_pvn||5.013007| cophh_fetch_pvs||5.013007| cophh_fetch_pv||5.013007| cophh_fetch_sv||5.013007| cophh_free||5.013007| cophh_new_empty||5.014000| cophh_store_pvn||5.013007| cophh_store_pvs||5.013007| cophh_store_pv||5.013007| cophh_store_sv||5.013007| cr_textfilter||| create_eval_scope||| croak_no_modify||5.013003| croak_nocontext|||vn croak_sv||5.013001| croak_xs_usage||5.010001| croak|||v csighandler||5.009003|n curmad||| curse||| custom_op_desc||5.007003| custom_op_name||5.007003| custom_op_register||5.013007| custom_op_xop||5.013007| cv_ckproto_len||| cv_clone||| cv_const_sv||5.004000| cv_dump||| cv_get_call_checker||5.013006| cv_set_call_checker||5.013006| cv_undef||| cvgv_set||| cvstash_set||| cx_dump||5.005000| cx_dup||| cxinc||| dAXMARK|5.009003||p dAX|5.007002||p dITEMS|5.007002||p dMARK||| dMULTICALL||5.009003| dMY_CXT_SV|5.007003||p dMY_CXT|5.007003||p dNOOP|5.006000||p dORIGMARK||| dSP||| dTHR|5.004050||p dTHXR|5.014000||p dTHXa|5.006000||p dTHXoa|5.006000||p dTHX|5.006000||p dUNDERBAR|5.009002||p dVAR|5.009003||p dXCPT|5.009002||p dXSARGS||| dXSI32||| dXSTARG|5.006000||p deb_curcv||| deb_nocontext|||vn deb_stack_all||| deb_stack_n||| debop||5.005000| debprofdump||5.005000| debprof||| debstackptrs||5.007003| debstack||5.007003| debug_start_match||| deb||5.007003|v del_sv||| delete_eval_scope||| delimcpy||5.004000|n deprecate_commaless_var_list||| despatch_signals||5.007001| destroy_matcher||| die_nocontext|||vn die_sv||5.013001| die_unwind||| die|||v dirp_dup||| div128||| djSP||| do_aexec5||| do_aexec||| do_aspawn||| do_binmode||5.004050| do_chomp||| do_close||| do_delete_local||| do_dump_pad||| do_eof||| do_exec3||| do_execfree||| do_exec||| do_gv_dump||5.006000| do_gvgv_dump||5.006000| do_hv_dump||5.006000| do_ipcctl||| do_ipcget||| do_join||| do_magic_dump||5.006000| do_msgrcv||| do_msgsnd||| do_oddball||| do_op_dump||5.006000| do_op_xmldump||| do_open9||5.006000| do_openn||5.007001| do_open||5.004000| do_pmop_dump||5.006000| do_pmop_xmldump||| do_print||| do_readline||| do_seek||| do_semop||| do_shmio||| do_smartmatch||| do_spawn_nowait||| do_spawn||| do_sprintf||| do_sv_dump||5.006000| do_sysseek||| do_tell||| do_trans_complex_utf8||| do_trans_complex||| do_trans_count_utf8||| do_trans_count||| do_trans_simple_utf8||| do_trans_simple||| do_trans||| do_vecget||| do_vecset||| do_vop||| docatch||| doeval||| dofile||| dofindlabel||| doform||| doing_taint||5.008001|n dooneliner||| doopen_pm||| doparseform||| dopoptoeval||| dopoptogiven||| dopoptolabel||| dopoptoloop||| dopoptosub_at||| dopoptowhen||| doref||5.009003| dounwind||| dowantarray||| dump_all_perl||| dump_all||5.006000| dump_eval||5.006000| dump_exec_pos||| dump_fds||| dump_form||5.006000| dump_indent||5.006000|v dump_mstats||| dump_packsubs_perl||| dump_packsubs||5.006000| dump_sub_perl||| dump_sub||5.006000| dump_sv_child||| dump_trie_interim_list||| dump_trie_interim_table||| dump_trie||| dump_vindent||5.006000| dumpuntil||| dup_attrlist||| emulate_cop_io||| eval_pv|5.006000||p eval_sv|5.006000||p exec_failed||| expect_number||| fbm_compile||5.005000| fbm_instr||5.005000| feature_is_enabled||| fetch_cop_label||5.011000| filter_add||| filter_del||| filter_gets||| filter_read||| find_and_forget_pmops||| find_array_subscript||| find_beginning||| find_byclass||| find_hash_subscript||| find_in_my_stash||| find_runcv||5.008001| find_rundefsvoffset||5.009002| find_rundefsv||5.013002| find_script||| find_uninit_var||| first_symbol|||n foldEQ_latin1||5.013008|n foldEQ_locale||5.013002|n foldEQ_utf8_flags||5.013010| foldEQ_utf8||5.013002| foldEQ||5.013002|n fold_constants||| forbid_setid||| force_ident||| force_list||| force_next||| force_strict_version||| force_version||| force_word||| forget_pmop||| form_nocontext|||vn form||5.004000|v fp_dup||| fprintf_nocontext|||vn free_global_struct||| free_tied_hv_pool||| free_tmps||| gen_constant_list||| get_aux_mg||| get_av|5.006000||p get_context||5.006000|n get_cvn_flags|5.009005||p get_cvs|5.011000||p get_cv|5.006000||p get_db_sub||| get_debug_opts||| get_hash_seed||| get_hv|5.006000||p get_mstats||| get_no_modify||| get_num||| get_op_descs||5.005000| get_op_names||5.005000| get_opargs||| get_ppaddr||5.006000| get_re_arg||| get_sv|5.006000||p get_vtbl||5.005030| getcwd_sv||5.007002| getenv_len||| glob_2number||| glob_assign_glob||| glob_assign_ref||| gp_dup||| gp_free||| gp_ref||| grok_bin|5.007003||p grok_bslash_c||| grok_bslash_o||| grok_hex|5.007003||p grok_number|5.007002||p grok_numeric_radix|5.007002||p grok_oct|5.007003||p group_end||| gv_AVadd||| gv_HVadd||| gv_IOadd||| gv_SVadd||| gv_add_by_type||5.011000| gv_autoload4||5.004000| gv_check||| gv_const_sv||5.009003| gv_dump||5.006000| gv_efullname3||5.004000| gv_efullname4||5.006001| gv_efullname||| gv_ename||| gv_fetchfile_flags||5.009005| gv_fetchfile||| gv_fetchmeth_autoload||5.007003| gv_fetchmethod_autoload||5.004000| gv_fetchmethod_flags||5.011000| gv_fetchmethod||| gv_fetchmeth||| gv_fetchpvn_flags|5.009002||p gv_fetchpvs|5.009004||p gv_fetchpv||| gv_fetchsv|5.009002||p gv_fullname3||5.004000| gv_fullname4||5.006001| gv_fullname||| gv_get_super_pkg||| gv_handler||5.007001| gv_init_sv||| gv_init||| gv_magicalize_isa||| gv_magicalize_overload||| gv_name_set||5.009004| gv_stashpvn|5.004000||p gv_stashpvs|5.009003||p gv_stashpv||| gv_stashsv||| gv_try_downgrade||| he_dup||| hek_dup||| hfreeentries||| hsplit||| hv_assert||| hv_auxinit|||n hv_backreferences_p||| hv_clear_placeholders||5.009001| hv_clear||| hv_common_key_len||5.010000| hv_common||5.010000| hv_copy_hints_hv||5.009004| hv_delayfree_ent||5.004000| hv_delete_common||| hv_delete_ent||5.004000| hv_delete||| hv_eiter_p||5.009003| hv_eiter_set||5.009003| hv_ename_add||| hv_ename_delete||| hv_exists_ent||5.004000| hv_exists||| hv_fetch_ent||5.004000| hv_fetchs|5.009003||p hv_fetch||| hv_fill||5.013002| hv_free_ent||5.004000| hv_iterinit||| hv_iterkeysv||5.004000| hv_iterkey||| hv_iternext_flags||5.008000| hv_iternextsv||| hv_iternext||| hv_iterval||| hv_kill_backrefs||| hv_ksplit||5.004000| hv_magic_check|||n hv_magic||| hv_name_set||5.009003| hv_notallowed||| hv_placeholders_get||5.009003| hv_placeholders_p||5.009003| hv_placeholders_set||5.009003| hv_riter_p||5.009003| hv_riter_set||5.009003| hv_scalar||5.009001| hv_store_ent||5.004000| hv_store_flags||5.008000| hv_stores|5.009004||p hv_store||| hv_undef_flags||| hv_undef||| ibcmp_locale||5.004000| ibcmp_utf8||5.007003| ibcmp||| incline||| incpush_if_exists||| incpush_use_sep||| incpush||| ingroup||| init_argv_symbols||| init_dbargs||| init_debugger||| init_global_struct||| init_i18nl10n||5.006000| init_i18nl14n||5.006000| init_ids||| init_interp||| init_main_stash||| init_perllib||| init_postdump_symbols||| init_predump_symbols||| init_stacks||5.005000| init_tm||5.007002| instr|||n intro_my||| intuit_method||| intuit_more||| invert||| invlist_array||| invlist_destroy||| invlist_extend||| invlist_intersection||| invlist_len||| invlist_max||| invlist_set_array||| invlist_set_len||| invlist_set_max||| invlist_trim||| invlist_union||| invoke_exception_hook||| io_close||| isALNUMC|5.006000||p isALPHA||| isASCII|5.006000||p isBLANK|5.006001||p isCNTRL|5.006000||p isDIGIT||| isGRAPH|5.006000||p isGV_with_GP|5.009004||p isLOWER||| isOCTAL||5.013005| isPRINT|5.004000||p isPSXSPC|5.006001||p isPUNCT|5.006000||p isSPACE||| isUPPER||| isWORDCHAR||5.013006| isXDIGIT|5.006000||p is_an_int||| is_ascii_string||5.011000|n is_gv_magical_sv||| is_handle_constructor|||n is_inplace_av||| is_list_assignment||| is_lvalue_sub||5.007001| is_uni_alnum_lc||5.006000| is_uni_alnum||5.006000| is_uni_alpha_lc||5.006000| is_uni_alpha||5.006000| is_uni_ascii_lc||5.006000| is_uni_ascii||5.006000| is_uni_cntrl_lc||5.006000| is_uni_cntrl||5.006000| is_uni_digit_lc||5.006000| is_uni_digit||5.006000| is_uni_graph_lc||5.006000| is_uni_graph||5.006000| is_uni_idfirst_lc||5.006000| is_uni_idfirst||5.006000| is_uni_lower_lc||5.006000| is_uni_lower||5.006000| is_uni_print_lc||5.006000| is_uni_print||5.006000| is_uni_punct_lc||5.006000| is_uni_punct||5.006000| is_uni_space_lc||5.006000| is_uni_space||5.006000| is_uni_upper_lc||5.006000| is_uni_upper||5.006000| is_uni_xdigit_lc||5.006000| is_uni_xdigit||5.006000| is_utf8_X_LVT||| is_utf8_X_LV_LVT_V||| is_utf8_X_LV||| is_utf8_X_L||| is_utf8_X_T||| is_utf8_X_V||| is_utf8_X_begin||| is_utf8_X_extend||| is_utf8_X_non_hangul||| is_utf8_X_prepend||| is_utf8_alnum||5.006000| is_utf8_alpha||5.006000| is_utf8_ascii||5.006000| is_utf8_char_slow|||n is_utf8_char||5.006000|n is_utf8_cntrl||5.006000| is_utf8_common||| is_utf8_digit||5.006000| is_utf8_graph||5.006000| is_utf8_idcont||5.008000| is_utf8_idfirst||5.006000| is_utf8_lower||5.006000| is_utf8_mark||5.006000| is_utf8_perl_space||5.011001| is_utf8_perl_word||5.011001| is_utf8_posix_digit||5.011001| is_utf8_print||5.006000| is_utf8_punct||5.006000| is_utf8_space||5.006000| is_utf8_string_loclen||5.009003|n is_utf8_string_loc||5.008001|n is_utf8_string||5.006001|n is_utf8_upper||5.006000| is_utf8_xdigit||5.006000| is_utf8_xidcont||5.013010| is_utf8_xidfirst||5.013010| isa_lookup||| items|||n ix|||n jmaybe||| join_exact||| keyword_plugin_standard||| keyword||| leave_scope||| lex_bufutf8||5.011002| lex_discard_to||5.011002| lex_grow_linestr||5.011002| lex_next_chunk||5.011002| lex_peek_unichar||5.011002| lex_read_space||5.011002| lex_read_to||5.011002| lex_read_unichar||5.011002| lex_start||5.009005| lex_stuff_pvn||5.011002| lex_stuff_pvs||5.013005| lex_stuff_pv||5.013006| lex_stuff_sv||5.011002| lex_unstuff||5.011002| listkids||| list||| load_module_nocontext|||vn load_module|5.006000||pv localize||| looks_like_bool||| looks_like_number||| lop||| mPUSHi|5.009002||p mPUSHn|5.009002||p mPUSHp|5.009002||p mPUSHs|5.010001||p mPUSHu|5.009002||p mXPUSHi|5.009002||p mXPUSHn|5.009002||p mXPUSHp|5.009002||p mXPUSHs|5.010001||p mXPUSHu|5.009002||p mad_free||| madlex||| madparse||| magic_clear_all_env||| magic_clearenv||| magic_clearhints||| magic_clearhint||| magic_clearisa||| magic_clearpack||| magic_clearsig||| magic_dump||5.006000| magic_existspack||| magic_freearylen_p||| magic_freeovrld||| magic_getarylen||| magic_getdefelem||| magic_getnkeys||| magic_getpack||| magic_getpos||| magic_getsig||| magic_getsubstr||| magic_gettaint||| magic_getuvar||| magic_getvec||| magic_get||| magic_killbackrefs||| magic_len||| magic_methcall1||| magic_methcall|||v magic_methpack||| magic_nextpack||| magic_regdata_cnt||| magic_regdatum_get||| magic_regdatum_set||| magic_scalarpack||| magic_set_all_env||| magic_setamagic||| magic_setarylen||| magic_setcollxfrm||| magic_setdbline||| magic_setdefelem||| magic_setenv||| magic_sethint||| magic_setisa||| magic_setmglob||| magic_setnkeys||| magic_setpack||| magic_setpos||| magic_setregexp||| magic_setsig||| magic_setsubstr||| magic_settaint||| magic_setutf8||| magic_setuvar||| magic_setvec||| magic_set||| magic_sizepack||| magic_wipepack||| make_matcher||| make_trie_failtable||| make_trie||| malloc_good_size|||n malloced_size|||n malloc||5.007002|n markstack_grow||| matcher_matches_sv||| measure_struct||| memEQs|5.009005||p memEQ|5.004000||p memNEs|5.009005||p memNE|5.004000||p mem_collxfrm||| mem_log_common|||n mess_alloc||| mess_nocontext|||vn mess_sv||5.013001| mess||5.006000|v method_common||| mfree||5.007002|n mg_clear||| mg_copy||| mg_dup||| mg_findext||5.013008| mg_find||| mg_free_type||5.013006| mg_free||| mg_get||| mg_length||5.005000| mg_localize||| mg_magical||| mg_set||| mg_size||5.005000| mini_mktime||5.007002| missingterm||| mode_from_discipline||| modkids||| mod||| more_bodies||| more_sv||| moreswitches||| mro_clean_isarev||| mro_gather_and_rename||| mro_get_from_name||5.010001| mro_get_linear_isa_dfs||| mro_get_linear_isa||5.009005| mro_get_private_data||5.010001| mro_isa_changed_in||| mro_meta_dup||| mro_meta_init||| mro_method_changed_in||5.009005| mro_package_moved||| mro_register||5.010001| mro_set_mro||5.010001| mro_set_private_data||5.010001| mul128||| mulexp10|||n munge_qwlist_to_paren_list||| my_atof2||5.007002| my_atof||5.006000| my_attrs||| my_bcopy|||n my_betoh16|||n my_betoh32|||n my_betoh64|||n my_betohi|||n my_betohl|||n my_betohs|||n my_bzero|||n my_chsize||| my_clearenv||| my_cxt_index||| my_cxt_init||| my_dirfd||5.009005| my_exit_jump||| my_exit||| my_failure_exit||5.004000| my_fflush_all||5.006000| my_fork||5.007003|n my_htobe16|||n my_htobe32|||n my_htobe64|||n my_htobei|||n my_htobel|||n my_htobes|||n my_htole16|||n my_htole32|||n my_htole64|||n my_htolei|||n my_htolel|||n my_htoles|||n my_htonl||| my_kid||| my_letoh16|||n my_letoh32|||n my_letoh64|||n my_letohi|||n my_letohl|||n my_letohs|||n my_lstat_flags||| my_lstat||5.014000| my_memcmp||5.004000|n my_memset|||n my_ntohl||| my_pclose||5.004000| my_popen_list||5.007001| my_popen||5.004000| my_setenv||| my_snprintf|5.009004||pvn my_socketpair||5.007003|n my_sprintf|5.009003||pvn my_stat_flags||| my_stat||5.014000| my_strftime||5.007002| my_strlcat|5.009004||pn my_strlcpy|5.009004||pn my_swabn|||n my_swap||| my_unexec||| my_vsnprintf||5.009004|n need_utf8|||n newANONATTRSUB||5.006000| newANONHASH||| newANONLIST||| newANONSUB||| newASSIGNOP||| newATTRSUB||5.006000| newAVREF||| newAV||| newBINOP||| newCONDOP||| newCONSTSUB|5.004050||p newCVREF||| newDEFSVOP||| newFORM||| newFOROP||5.013007| newGIVENOP||5.009003| newGIVWHENOP||| newGP||| newGVOP||| newGVREF||| newGVgen||| newHVREF||| newHVhv||5.005000| newHV||| newIO||| newLISTOP||| newLOGOP||| newLOOPEX||| newLOOPOP||| newMADPROP||| newMADsv||| newMYSUB||| newNULLLIST||| newOP||| newPADOP||| newPMOP||| newPROG||| newPVOP||| newRANGE||| newRV_inc|5.004000||p newRV_noinc|5.004000||p newRV||| newSLICEOP||| newSTATEOP||| newSUB||| newSVOP||| newSVREF||| newSV_type|5.009005||p newSVhek||5.009003| newSViv||| newSVnv||| newSVpv_share||5.013006| newSVpvf_nocontext|||vn newSVpvf||5.004000|v newSVpvn_flags|5.010001||p newSVpvn_share|5.007001||p newSVpvn_utf8|5.010001||p newSVpvn|5.004050||p newSVpvs_flags|5.010001||p newSVpvs_share|5.009003||p newSVpvs|5.009003||p newSVpv||| newSVrv||| newSVsv||| newSVuv|5.006000||p newSV||| newTOKEN||| newUNOP||| newWHENOP||5.009003| newWHILEOP||5.013007| newXS_flags||5.009004| newXSproto||5.006000| newXS||5.006000| new_collate||5.006000| new_constant||| new_ctype||5.006000| new_he||| new_logop||| new_numeric||5.006000| new_stackinfo||5.005000| new_version||5.009000| new_warnings_bitfield||| next_symbol||| nextargv||| nextchar||| ninstr|||n no_bareword_allowed||| no_fh_allowed||| no_op||| not_a_number||| nothreadhook||5.008000| nuke_stacks||| num_overflow|||n oopsAV||| oopsHV||| op_append_elem||5.013006| op_append_list||5.013006| op_clear||| op_const_sv||| op_contextualize||5.013006| op_dump||5.006000| op_free||| op_getmad_weak||| op_getmad||| op_linklist||5.013006| op_lvalue||5.013007| op_null||5.007002| op_prepend_elem||5.013006| op_refcnt_dec||| op_refcnt_inc||| op_refcnt_lock||5.009002| op_refcnt_unlock||5.009002| op_scope||5.013007| op_xmldump||| open_script||| opt_scalarhv||| pMY_CXT_|5.007003||p pMY_CXT|5.007003||p pTHX_|5.006000||p pTHX|5.006000||p packWARN|5.007003||p pack_cat||5.007003| pack_rec||| package_version||| package||| packlist||5.008001| pad_add_anon||| pad_add_name_sv||| pad_add_name||| pad_alloc||| pad_block_start||| pad_check_dup||| pad_compname_type||| pad_findlex||| pad_findmy||5.011002| pad_fixup_inner_anons||| pad_free||| pad_leavemy||| pad_new||| pad_peg|||n pad_push||| pad_reset||| pad_setsv||| pad_sv||| pad_swipe||| pad_tidy||| padlist_dup||| parse_arithexpr||5.013008| parse_barestmt||5.013007| parse_block||5.013007| parse_body||| parse_fullexpr||5.013008| parse_fullstmt||5.013005| parse_label||5.013007| parse_listexpr||5.013008| parse_stmtseq||5.013006| parse_termexpr||5.013008| parse_unicode_opts||| parser_dup||| parser_free||| path_is_absolute|||n peep||| pending_Slabs_to_ro||| perl_alloc_using|||n perl_alloc|||n perl_clone_using|||n perl_clone|||n perl_construct|||n perl_destruct||5.007003|n perl_free|||n perl_parse||5.006000|n perl_run|||n pidgone||| pm_description||| pmop_dump||5.006000| pmop_xmldump||| pmruntime||| pmtrans||| pop_scope||| populate_isa|||v pregcomp||5.009005| pregexec||| pregfree2||5.011000| pregfree||| prepend_madprops||| prescan_version||5.011004| printbuf||| printf_nocontext|||vn process_special_blocks||| ptr_table_clear||5.009005| ptr_table_fetch||5.009005| ptr_table_find|||n ptr_table_free||5.009005| ptr_table_new||5.009005| ptr_table_split||5.009005| ptr_table_store||5.009005| push_scope||| put_byte||| pv_display|5.006000||p pv_escape|5.009004||p pv_pretty|5.009004||p pv_uni_display||5.007003| qerror||| qsortsvu||| re_compile||5.009005| re_croak2||| re_dup_guts||| re_intuit_start||5.009005| re_intuit_string||5.006000| readpipe_override||| realloc||5.007002|n reentrant_free||| reentrant_init||| reentrant_retry|||vn reentrant_size||| ref_array_or_hash||| refcounted_he_chain_2hv||| refcounted_he_fetch_pvn||| refcounted_he_fetch_pvs||| refcounted_he_fetch_pv||| refcounted_he_fetch_sv||| refcounted_he_free||| refcounted_he_inc||| refcounted_he_new_pvn||| refcounted_he_new_pvs||| refcounted_he_new_pv||| refcounted_he_new_sv||| refcounted_he_value||| refkids||| refto||| ref||5.014000| reg_check_named_buff_matched||| reg_named_buff_all||5.009005| reg_named_buff_exists||5.009005| reg_named_buff_fetch||5.009005| reg_named_buff_firstkey||5.009005| reg_named_buff_iter||| reg_named_buff_nextkey||5.009005| reg_named_buff_scalar||5.009005| reg_named_buff||| reg_namedseq||| reg_node||| reg_numbered_buff_fetch||| reg_numbered_buff_length||| reg_numbered_buff_store||| reg_qr_package||| reg_recode||| reg_scan_name||| reg_skipcomment||| reg_temp_copy||| reganode||| regatom||| regbranch||| regclass_swash||5.009004| regclass||| regcppop||| regcppush||| regcurly||| regdump_extflags||| regdump||5.005000| regdupe_internal||| regexec_flags||5.005000| regfree_internal||5.009005| reghop3|||n reghop4|||n reghopmaybe3|||n reginclass||| reginitcolors||5.006000| reginsert||| regmatch||| regnext||5.005000| regpiece||| regpposixcc||| regprop||| regrepeat||| regtail_study||| regtail||| regtry||| reguni||| regwhite|||n reg||| repeatcpy|||n report_evil_fh||| report_uninit||| report_wrongway_fh||| require_pv||5.006000| require_tie_mod||| restore_magic||| rninstr|||n rpeep||| rsignal_restore||| rsignal_save||| rsignal_state||5.004000| rsignal||5.004000| run_body||| run_user_filter||| runops_debug||5.005000| runops_standard||5.005000| rv2cv_op_cv||5.013006| rvpv_dup||| rxres_free||| rxres_restore||| rxres_save||| safesyscalloc||5.006000|n safesysfree||5.006000|n safesysmalloc||5.006000|n safesysrealloc||5.006000|n same_dirent||| save_I16||5.004000| save_I32||| save_I8||5.006000| save_adelete||5.011000| save_aelem_flags||5.011000| save_aelem||5.004050| save_alloc||5.006000| save_aptr||| save_ary||| save_bool||5.008001| save_clearsv||| save_delete||| save_destructor_x||5.006000| save_destructor||5.006000| save_freeop||| save_freepv||| save_freesv||| save_generic_pvref||5.006001| save_generic_svref||5.005030| save_gp||5.004000| save_hash||| save_hdelete||5.011000| save_hek_flags|||n save_helem_flags||5.011000| save_helem||5.004050| save_hints||5.010001| save_hptr||| save_int||| save_item||| save_iv||5.005000| save_lines||| save_list||| save_long||| save_magic||| save_mortalizesv||5.007001| save_nogv||| save_op||5.005000| save_padsv_and_mortalize||5.010001| save_pptr||| save_pushi32ptr||5.010001| save_pushptri32ptr||| save_pushptrptr||5.010001| save_pushptr||5.010001| save_re_context||5.006000| save_scalar_at||| save_scalar||| save_set_svflags||5.009000| save_shared_pvref||5.007003| save_sptr||| save_svref||| save_vptr||5.006000| savepvn||| savepvs||5.009003| savepv||| savesharedpvn||5.009005| savesharedpvs||5.013006| savesharedpv||5.007003| savesharedsvpv||5.013006| savestack_grow_cnt||5.008001| savestack_grow||| savesvpv||5.009002| sawparens||| scalar_mod_type|||n scalarboolean||| scalarkids||| scalarseq||| scalarvoid||| scalar||| scan_bin||5.006000| scan_commit||| scan_const||| scan_formline||| scan_heredoc||| scan_hex||| scan_ident||| scan_inputsymbol||| scan_num||5.007001| scan_oct||| scan_pat||| scan_str||| scan_subst||| scan_trans||| scan_version||5.009001| scan_vstring||5.009005| scan_word||| screaminstr||5.005000| search_const||| seed||5.008001| sequence_num||| sequence_tail||| sequence||| set_context||5.006000|n set_numeric_local||5.006000| set_numeric_radix||5.006000| set_numeric_standard||5.006000| set_regclass_bit_fold||| set_regclass_bit||| setdefout||| share_hek_flags||| share_hek||5.004000| si_dup||| sighandler|||n simplify_sort||| skipspace0||| skipspace1||| skipspace2||| skipspace||| softref2xv||| sortcv_stacked||| sortcv_xsub||| sortcv||| sortsv_flags||5.009003| sortsv||5.007003| space_join_names_mortal||| ss_dup||| stack_grow||| start_force||| start_glob||| start_subparse||5.004000| stashpv_hvname_match||5.014000| stdize_locale||| store_cop_label||| strEQ||| strGE||| strGT||| strLE||| strLT||| strNE||| str_to_version||5.006000| strip_return||| strnEQ||| strnNE||| study_chunk||| sub_crush_depth||| sublex_done||| sublex_push||| sublex_start||| sv_2bool_flags||5.013006| sv_2bool||| sv_2cv||| sv_2io||| sv_2iuv_common||| sv_2iuv_non_preserve||| sv_2iv_flags||5.009001| sv_2iv||| sv_2mortal||| sv_2num||| sv_2nv_flags||5.013001| sv_2pv_flags|5.007002||p sv_2pv_nolen|5.006000||p sv_2pvbyte_nolen|5.006000||p sv_2pvbyte|5.006000||p sv_2pvutf8_nolen||5.006000| sv_2pvutf8||5.006000| sv_2pv||| sv_2uv_flags||5.009001| sv_2uv|5.004000||p sv_add_arena||| sv_add_backref||| sv_backoff||| sv_bless||| sv_cat_decode||5.008001| sv_catpv_flags||5.013006| sv_catpv_mg|5.004050||p sv_catpv_nomg||5.013006| sv_catpvf_mg_nocontext|||pvn sv_catpvf_mg|5.006000|5.004000|pv sv_catpvf_nocontext|||vn sv_catpvf||5.004000|v sv_catpvn_flags||5.007002| sv_catpvn_mg|5.004050||p sv_catpvn_nomg|5.007002||p sv_catpvn||| sv_catpvs_flags||5.013006| sv_catpvs_mg||5.013006| sv_catpvs_nomg||5.013006| sv_catpvs|5.009003||p sv_catpv||| sv_catsv_flags||5.007002| sv_catsv_mg|5.004050||p sv_catsv_nomg|5.007002||p sv_catsv||| sv_catxmlpvn||| sv_catxmlpv||| sv_catxmlsv||| sv_chop||| sv_clean_all||| sv_clean_objs||| sv_clear||| sv_cmp_flags||5.013006| sv_cmp_locale_flags||5.013006| sv_cmp_locale||5.004000| sv_cmp||| sv_collxfrm_flags||5.013006| sv_collxfrm||| sv_compile_2op_is_broken||| sv_compile_2op||5.008001| sv_copypv||5.007003| sv_dec_nomg||5.013002| sv_dec||| sv_del_backref||| sv_derived_from||5.004000| sv_destroyable||5.010000| sv_does||5.009004| sv_dump||| sv_dup_common||| sv_dup_inc_multiple||| sv_dup_inc||| sv_dup||| sv_eq_flags||5.013006| sv_eq||| sv_exp_grow||| sv_force_normal_flags||5.007001| sv_force_normal||5.006000| sv_free2||| sv_free_arenas||| sv_free||| sv_gets||5.004000| sv_grow||| sv_i_ncmp||| sv_inc_nomg||5.013002| sv_inc||| sv_insert_flags||5.010001| sv_insert||| sv_isa||| sv_isobject||| sv_iv||5.005000| sv_kill_backrefs||| sv_len_utf8||5.006000| sv_len||| sv_magic_portable|5.014000|5.004000|p sv_magicext||5.007003| sv_magic||| sv_mortalcopy||| sv_ncmp||| sv_newmortal||| sv_newref||| sv_nolocking||5.007003| sv_nosharing||5.007003| sv_nounlocking||| sv_nv||5.005000| sv_peek||5.005000| sv_pos_b2u_midway||| sv_pos_b2u||5.006000| sv_pos_u2b_cached||| sv_pos_u2b_flags||5.011005| sv_pos_u2b_forwards|||n sv_pos_u2b_midway|||n sv_pos_u2b||5.006000| sv_pvbyten_force||5.006000| sv_pvbyten||5.006000| sv_pvbyte||5.006000| sv_pvn_force_flags|5.007002||p sv_pvn_force||| sv_pvn_nomg|5.007003|5.005000|p sv_pvn||5.005000| sv_pvutf8n_force||5.006000| sv_pvutf8n||5.006000| sv_pvutf8||5.006000| sv_pv||5.006000| sv_recode_to_utf8||5.007003| sv_reftype||| sv_release_COW||| sv_replace||| sv_report_used||| sv_reset||| sv_rvweaken||5.006000| sv_setiv_mg|5.004050||p sv_setiv||| sv_setnv_mg|5.006000||p sv_setnv||| sv_setpv_mg|5.004050||p sv_setpvf_mg_nocontext|||pvn sv_setpvf_mg|5.006000|5.004000|pv sv_setpvf_nocontext|||vn sv_setpvf||5.004000|v sv_setpviv_mg||5.008001| sv_setpviv||5.008001| sv_setpvn_mg|5.004050||p sv_setpvn||| sv_setpvs_mg||5.013006| sv_setpvs|5.009004||p sv_setpv||| sv_setref_iv||| sv_setref_nv||| sv_setref_pvn||| sv_setref_pvs||5.013006| sv_setref_pv||| sv_setref_uv||5.007001| sv_setsv_cow||| sv_setsv_flags||5.007002| sv_setsv_mg|5.004050||p sv_setsv_nomg|5.007002||p sv_setsv||| sv_setuv_mg|5.004050||p sv_setuv|5.004000||p sv_tainted||5.004000| sv_taint||5.004000| sv_true||5.005000| sv_unglob||| sv_uni_display||5.007003| sv_unmagicext||5.013008| sv_unmagic||| sv_unref_flags||5.007001| sv_unref||| sv_untaint||5.004000| sv_upgrade||| sv_usepvn_flags||5.009004| sv_usepvn_mg|5.004050||p sv_usepvn||| sv_utf8_decode||5.006000| sv_utf8_downgrade||5.006000| sv_utf8_encode||5.006000| sv_utf8_upgrade_flags_grow||5.011000| sv_utf8_upgrade_flags||5.007002| sv_utf8_upgrade_nomg||5.007002| sv_utf8_upgrade||5.007001| sv_uv|5.005000||p sv_vcatpvf_mg|5.006000|5.004000|p sv_vcatpvfn||5.004000| sv_vcatpvf|5.006000|5.004000|p sv_vsetpvf_mg|5.006000|5.004000|p sv_vsetpvfn||5.004000| sv_vsetpvf|5.006000|5.004000|p sv_xmlpeek||| svtype||| swallow_bom||| swash_fetch||5.007002| swash_get||| swash_init||5.006000| sys_init3||5.010000|n sys_init||5.010000|n sys_intern_clear||| sys_intern_dup||| sys_intern_init||| sys_term||5.010000|n taint_env||| taint_proper||| tied_method|||v tmps_grow||5.006000| toLOWER||| toUPPER||| to_byte_substr||| to_uni_fold||5.007003| to_uni_lower_lc||5.006000| to_uni_lower||5.007003| to_uni_title_lc||5.006000| to_uni_title||5.007003| to_uni_upper_lc||5.006000| to_uni_upper||5.007003| to_utf8_case||5.007003| to_utf8_fold||5.007003| to_utf8_lower||5.007003| to_utf8_substr||| to_utf8_title||5.007003| to_utf8_upper||5.007003| token_free||| token_getmad||| tokenize_use||| tokeq||| tokereport||| too_few_arguments||| too_many_arguments||| try_amagic_bin||| try_amagic_un||| uiv_2buf|||n unlnk||| unpack_rec||| unpack_str||5.007003| unpackstring||5.008001| unreferenced_to_tmp_stack||| unshare_hek_or_pvn||| unshare_hek||| unsharepvn||5.004000| unwind_handler_stack||| update_debugger_info||| upg_version||5.009005| usage||| utf16_textfilter||| utf16_to_utf8_reversed||5.006001| utf16_to_utf8||5.006001| utf8_distance||5.006000| utf8_hop||5.006000| utf8_length||5.007001| utf8_mg_len_cache_update||| utf8_mg_pos_cache_update||| utf8_to_bytes||5.006001| utf8_to_uvchr||5.007001| utf8_to_uvuni||5.007001| utf8n_to_uvchr||| utf8n_to_uvuni||5.007001| utilize||| uvchr_to_utf8_flags||5.007003| uvchr_to_utf8||| uvuni_to_utf8_flags||5.007003| uvuni_to_utf8||5.007001| validate_suid||| varname||| vcmp||5.009000| vcroak||5.006000| vdeb||5.007003| vform||5.006000| visit||| vivify_defelem||| vivify_ref||| vload_module|5.006000||p vmess||5.006000| vnewSVpvf|5.006000|5.004000|p vnormal||5.009002| vnumify||5.009000| vstringify||5.009000| vverify||5.009003| vwarner||5.006000| vwarn||5.006000| wait4pid||| warn_nocontext|||vn warn_sv||5.013001| warner_nocontext|||vn warner|5.006000|5.004000|pv warn|||v watch||| whichsig||| with_queued_errors||| write_no_mem||| write_to_stderr||| xmldump_all_perl||| xmldump_all||| xmldump_attr||| xmldump_eval||| xmldump_form||| xmldump_indent|||v xmldump_packsubs_perl||| xmldump_packsubs||| xmldump_sub_perl||| xmldump_sub||| xmldump_vindent||| xs_apiversion_bootcheck||| xs_version_bootcheck||| yyerror||| yylex||| yyparse||| yyunlex||| yywarn||| ); if (exists $opt{'list-unsupported'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{todo}; print "$f ", '.'x(40-length($f)), " ", format_version($API{$f}{todo}), "\n"; } exit 0; } # Scan for possible replacement candidates my(%replace, %need, %hints, %warnings, %depends); my $replace = 0; my($hint, $define, $function); sub find_api { my $code = shift; $code =~ s{ / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]*) | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' }{}egsx; grep { exists $API{$_} } $code =~ /(\w+)/mg; } while () { if ($hint) { my $h = $hint->[0] eq 'Hint' ? \%hints : \%warnings; if (m{^\s*\*\s(.*?)\s*$}) { for (@{$hint->[1]}) { $h->{$_} ||= ''; # suppress warning with older perls $h->{$_} .= "$1\n"; } } else { undef $hint } } $hint = [$1, [split /,?\s+/, $2]] if m{^\s*$rccs\s+(Hint|Warning):\s+(\w+(?:,?\s+\w+)*)\s*$}; if ($define) { if ($define->[1] =~ /\\$/) { $define->[1] .= $_; } else { if (exists $API{$define->[0]} && $define->[1] !~ /^DPPP_\(/) { my @n = find_api($define->[1]); push @{$depends{$define->[0]}}, @n if @n } undef $define; } } $define = [$1, $2] if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(.*)}; if ($function) { if (/^}/) { if (exists $API{$function->[0]}) { my @n = find_api($function->[1]); push @{$depends{$function->[0]}}, @n if @n } undef $function; } else { $function->[1] .= $_; } } $function = [$1, ''] if m{^DPPP_\(my_(\w+)\)}; $replace = $1 if m{^\s*$rccs\s+Replace:\s+(\d+)\s+$rcce\s*$}; $replace{$2} = $1 if $replace and m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+)}; $replace{$2} = $1 if m{^\s*#\s*define\s+(\w+)(?:\([^)]*\))?\s+(\w+).*$rccs\s+Replace\s+$rcce}; $replace{$1} = $2 if m{^\s*$rccs\s+Replace (\w+) with (\w+)\s+$rcce\s*$}; if (m{^\s*$rccs\s+(\w+(\s*,\s*\w+)*)\s+depends\s+on\s+(\w+(\s*,\s*\w+)*)\s+$rcce\s*$}) { my @deps = map { s/\s+//g; $_ } split /,/, $3; my $d; for $d (map { s/\s+//g; $_ } split /,/, $1) { push @{$depends{$d}}, @deps; } } $need{$1} = 1 if m{^#if\s+defined\(NEED_(\w+)(?:_GLOBAL)?\)}; } for (values %depends) { my %s; $_ = [sort grep !$s{$_}++, @$_]; } if (exists $opt{'api-info'}) { my $f; my $count = 0; my $match = $opt{'api-info'} =~ m!^/(.*)/$! ? $1 : "^\Q$opt{'api-info'}\E\$"; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $f =~ /$match/; print "\n=== $f ===\n\n"; my $info = 0; if ($API{$f}{base} || $API{$f}{todo}) { my $base = format_version($API{$f}{base} || $API{$f}{todo}); print "Supported at least starting from perl-$base.\n"; $info++; } if ($API{$f}{provided}) { my $todo = $API{$f}{todo} ? format_version($API{$f}{todo}) : "5.003"; print "Support by $ppport provided back to perl-$todo.\n"; print "Support needs to be explicitly requested by NEED_$f.\n" if exists $need{$f}; print "Depends on: ", join(', ', @{$depends{$f}}), ".\n" if exists $depends{$f}; print "\n$hints{$f}" if exists $hints{$f}; print "\nWARNING:\n$warnings{$f}" if exists $warnings{$f}; $info++; } print "No portability information available.\n" unless $info; $count++; } $count or print "Found no API matching '$opt{'api-info'}'."; print "\n"; exit 0; } if (exists $opt{'list-provided'}) { my $f; for $f (sort { lc $a cmp lc $b } keys %API) { next unless $API{$f}{provided}; my @flags; push @flags, 'explicit' if exists $need{$f}; push @flags, 'depend' if exists $depends{$f}; push @flags, 'hint' if exists $hints{$f}; push @flags, 'warning' if exists $warnings{$f}; my $flags = @flags ? ' ['.join(', ', @flags).']' : ''; print "$f$flags\n"; } exit 0; } my @files; my @srcext = qw( .xs .c .h .cc .cpp -c.inc -xs.inc ); my $srcext = join '|', map { quotemeta $_ } @srcext; if (@ARGV) { my %seen; for (@ARGV) { if (-e) { if (-f) { push @files, $_ unless $seen{$_}++; } else { warn "'$_' is not a file.\n" } } else { my @new = grep { -f } glob $_ or warn "'$_' does not exist.\n"; push @files, grep { !$seen{$_}++ } @new; } } } else { eval { require File::Find; File::Find::find(sub { $File::Find::name =~ /($srcext)$/i and push @files, $File::Find::name; }, '.'); }; if ($@) { @files = map { glob "*$_" } @srcext; } } if (!@ARGV || $opt{filter}) { my(@in, @out); my %xsc = map { /(.*)\.xs$/ ? ("$1.c" => 1, "$1.cc" => 1) : () } @files; for (@files) { my $out = exists $xsc{$_} || /\b\Q$ppport\E$/i || !/($srcext)$/i; push @{ $out ? \@out : \@in }, $_; } if (@ARGV && @out) { warning("Skipping the following files (use --nofilter to avoid this):\n| ", join "\n| ", @out); } @files = @in; } die "No input files given!\n" unless @files; my(%files, %global, %revreplace); %revreplace = reverse %replace; my $filename; my $patch_opened = 0; for $filename (@files) { unless (open IN, "<$filename") { warn "Unable to read from $filename: $!\n"; next; } info("Scanning $filename ..."); my $c = do { local $/; }; close IN; my %file = (orig => $c, changes => 0); # Temporarily remove C/XS comments and strings from the code my @ccom; $c =~ s{ ( ^$HS*\#$HS*include\b[^\r\n]+\b(?:\Q$ppport\E|XSUB\.h)\b[^\r\n]* | ^$HS*\#$HS*(?:define|elif|if(?:def)?)\b[^\r\n]* ) | ( ^$HS*\#[^\r\n]* | "[^"\\]*(?:\\.[^"\\]*)*" | '[^'\\]*(?:\\.[^'\\]*)*' | / (?: \*[^*]*\*+(?:[^$ccs][^*]*\*+)* / | /[^\r\n]* ) ) }{ defined $2 and push @ccom, $2; defined $1 ? $1 : "$ccs$#ccom$cce" }mgsex; $file{ccom} = \@ccom; $file{code} = $c; $file{has_inc_ppport} = $c =~ /^$HS*#$HS*include[^\r\n]+\b\Q$ppport\E\b/m; my $func; for $func (keys %API) { my $match = $func; $match .= "|$revreplace{$func}" if exists $revreplace{$func}; if ($c =~ /\b(?:Perl_)?($match)\b/) { $file{uses_replace}{$1}++ if exists $revreplace{$func} && $1 eq $revreplace{$func}; $file{uses_Perl}{$func}++ if $c =~ /\bPerl_$func\b/; if (exists $API{$func}{provided}) { $file{uses_provided}{$func}++; if (!exists $API{$func}{base} || $API{$func}{base} > $opt{'compat-version'}) { $file{uses}{$func}++; my @deps = rec_depend($func); if (@deps) { $file{uses_deps}{$func} = \@deps; for (@deps) { $file{uses}{$_} = 0 unless exists $file{uses}{$_}; } } for ($func, @deps) { $file{needs}{$_} = 'static' if exists $need{$_}; } } } if (exists $API{$func}{todo} && $API{$func}{todo} > $opt{'compat-version'}) { if ($c =~ /\b$func\b/) { $file{uses_todo}{$func}++; } } } } while ($c =~ /^$HS*#$HS*define$HS+(NEED_(\w+?)(_GLOBAL)?)\b/mg) { if (exists $need{$2}) { $file{defined $3 ? 'needed_global' : 'needed_static'}{$2}++; } else { warning("Possibly wrong #define $1 in $filename") } } for (qw(uses needs uses_todo needed_global needed_static)) { for $func (keys %{$file{$_}}) { push @{$global{$_}{$func}}, $filename; } } $files{$filename} = \%file; } # Globally resolve NEED_'s my $need; for $need (keys %{$global{needs}}) { if (@{$global{needs}{$need}} > 1) { my @targets = @{$global{needs}{$need}}; my @t = grep $files{$_}{needed_global}{$need}, @targets; @targets = @t if @t; @t = grep /\.xs$/i, @targets; @targets = @t if @t; my $target = shift @targets; $files{$target}{needs}{$need} = 'global'; for (@{$global{needs}{$need}}) { $files{$_}{needs}{$need} = 'extern' if $_ ne $target; } } } for $filename (@files) { exists $files{$filename} or next; info("=== Analyzing $filename ==="); my %file = %{$files{$filename}}; my $func; my $c = $file{code}; my $warnings = 0; for $func (sort keys %{$file{uses_Perl}}) { if ($API{$func}{varargs}) { unless ($API{$func}{nothxarg}) { my $changes = ($c =~ s{\b(Perl_$func\s*\(\s*)(?!aTHX_?)(\)|[^\s)]*\))} { $1 . ($2 eq ')' ? 'aTHX' : 'aTHX_ ') . $2 }ge); if ($changes) { warning("Doesn't pass interpreter argument aTHX to Perl_$func"); $file{changes} += $changes; } } } else { warning("Uses Perl_$func instead of $func"); $file{changes} += ($c =~ s{\bPerl_$func(\s*)\((\s*aTHX_?)?\s*} {$func$1(}g); } } for $func (sort keys %{$file{uses_replace}}) { warning("Uses $func instead of $replace{$func}"); $file{changes} += ($c =~ s/\b$func\b/$replace{$func}/g); } for $func (sort keys %{$file{uses_provided}}) { if ($file{uses}{$func}) { if (exists $file{uses_deps}{$func}) { diag("Uses $func, which depends on ", join(', ', @{$file{uses_deps}{$func}})); } else { diag("Uses $func"); } } $warnings += hint($func); } unless ($opt{quiet}) { for $func (sort keys %{$file{uses_todo}}) { print "*** WARNING: Uses $func, which may not be portable below perl ", format_version($API{$func}{todo}), ", even with '$ppport'\n"; $warnings++; } } for $func (sort keys %{$file{needed_static}}) { my $message = ''; if (not exists $file{uses}{$func}) { $message = "No need to define NEED_$func if $func is never used"; } elsif (exists $file{needs}{$func} && $file{needs}{$func} ne 'static') { $message = "No need to define NEED_$func when already needed globally"; } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_$func\b.*$LF//mg); } } for $func (sort keys %{$file{needed_global}}) { my $message = ''; if (not exists $global{uses}{$func}) { $message = "No need to define NEED_${func}_GLOBAL if $func is never used"; } elsif (exists $file{needs}{$func}) { if ($file{needs}{$func} eq 'extern') { $message = "No need to define NEED_${func}_GLOBAL when already needed globally"; } elsif ($file{needs}{$func} eq 'static') { $message = "No need to define NEED_${func}_GLOBAL when only used in this file"; } } if ($message) { diag($message); $file{changes} += ($c =~ s/^$HS*#$HS*define$HS+NEED_${func}_GLOBAL\b.*$LF//mg); } } $file{needs_inc_ppport} = keys %{$file{uses}}; if ($file{needs_inc_ppport}) { my $pp = ''; for $func (sort keys %{$file{needs}}) { my $type = $file{needs}{$func}; next if $type eq 'extern'; my $suffix = $type eq 'global' ? '_GLOBAL' : ''; unless (exists $file{"needed_$type"}{$func}) { if ($type eq 'global') { diag("Files [@{$global{needs}{$func}}] need $func, adding global request"); } else { diag("File needs $func, adding static request"); } $pp .= "#define NEED_$func$suffix\n"; } } if ($pp && ($c =~ s/^(?=$HS*#$HS*define$HS+NEED_\w+)/$pp/m)) { $pp = ''; $file{changes}++; } unless ($file{has_inc_ppport}) { diag("Needs to include '$ppport'"); $pp .= qq(#include "$ppport"\n) } if ($pp) { $file{changes} += ($c =~ s/^($HS*#$HS*define$HS+NEED_\w+.*?)^/$1$pp/ms) || ($c =~ s/^(?=$HS*#$HS*include.*\Q$ppport\E)/$pp/m) || ($c =~ s/^($HS*#$HS*include.*XSUB.*\s*?)^/$1$pp/m) || ($c =~ s/^/$pp/); } } else { if ($file{has_inc_ppport}) { diag("No need to include '$ppport'"); $file{changes} += ($c =~ s/^$HS*?#$HS*include.*\Q$ppport\E.*?$LF//m); } } # put back in our C comments my $ix; my $cppc = 0; my @ccom = @{$file{ccom}}; for $ix (0 .. $#ccom) { if (!$opt{cplusplus} && $ccom[$ix] =~ s!^//!!) { $cppc++; $file{changes} += $c =~ s/$rccs$ix$rcce/$ccs$ccom[$ix] $cce/; } else { $c =~ s/$rccs$ix$rcce/$ccom[$ix]/; } } if ($cppc) { my $s = $cppc != 1 ? 's' : ''; warning("Uses $cppc C++ style comment$s, which is not portable"); } my $s = $warnings != 1 ? 's' : ''; my $warn = $warnings ? " ($warnings warning$s)" : ''; info("Analysis completed$warn"); if ($file{changes}) { if (exists $opt{copy}) { my $newfile = "$filename$opt{copy}"; if (-e $newfile) { error("'$newfile' already exists, refusing to write copy of '$filename'"); } else { local *F; if (open F, ">$newfile") { info("Writing copy of '$filename' with changes to '$newfile'"); print F $c; close F; } else { error("Cannot open '$newfile' for writing: $!"); } } } elsif (exists $opt{patch} || $opt{changes}) { if (exists $opt{patch}) { unless ($patch_opened) { if (open PATCH, ">$opt{patch}") { $patch_opened = 1; } else { error("Cannot open '$opt{patch}' for writing: $!"); delete $opt{patch}; $opt{changes} = 1; goto fallback; } } mydiff(\*PATCH, $filename, $c); } else { fallback: info("Suggested changes:"); mydiff(\*STDOUT, $filename, $c); } } else { my $s = $file{changes} == 1 ? '' : 's'; info("$file{changes} potentially required change$s detected"); } } else { info("Looks good"); } } close PATCH if $patch_opened; exit 0; sub try_use { eval "use @_;"; return $@ eq '' } sub mydiff { local *F = shift; my($file, $str) = @_; my $diff; if (exists $opt{diff}) { $diff = run_diff($opt{diff}, $file, $str); } if (!defined $diff and try_use('Text::Diff')) { $diff = Text::Diff::diff($file, \$str, { STYLE => 'Unified' }); $diff = <
$tmp") { print F $str; close F; if (open F, "$prog $file $tmp |") { while () { s/\Q$tmp\E/$file.patched/; $diff .= $_; } close F; unlink $tmp; return $diff; } unlink $tmp; } else { error("Cannot open '$tmp' for writing: $!"); } return undef; } sub rec_depend { my($func, $seen) = @_; return () unless exists $depends{$func}; $seen = {%{$seen||{}}}; return () if $seen->{$func}++; my %s; grep !$s{$_}++, map { ($_, rec_depend($_, $seen)) } @{$depends{$func}}; } sub parse_version { my $ver = shift; if ($ver =~ /^(\d+)\.(\d+)\.(\d+)$/) { return ($1, $2, $3); } elsif ($ver !~ /^\d+\.[\d_]+$/) { die "cannot parse version '$ver'\n"; } $ver =~ s/_//g; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "cannot parse version '$ver'\n"; } } return ($r, $v, $s); } sub format_version { my $ver = shift; $ver =~ s/$/000000/; my($r,$v,$s) = $ver =~ /(\d+)\.(\d{3})(\d{3})/; $v = int $v; $s = int $s; if ($r < 5 || ($r == 5 && $v < 6)) { if ($s % 10) { die "invalid version '$ver'\n"; } $s /= 10; $ver = sprintf "%d.%03d", $r, $v; $s > 0 and $ver .= sprintf "_%02d", $s; return $ver; } return sprintf "%d.%d.%d", $r, $v, $s; } sub info { $opt{quiet} and return; print @_, "\n"; } sub diag { $opt{quiet} and return; $opt{diag} and print @_, "\n"; } sub warning { $opt{quiet} and return; print "*** ", @_, "\n"; } sub error { print "*** ERROR: ", @_, "\n"; } my %given_hints; my %given_warnings; sub hint { $opt{quiet} and return; my $func = shift; my $rv = 0; if (exists $warnings{$func} && !$given_warnings{$func}++) { my $warn = $warnings{$func}; $warn =~ s!^!*** !mg; print "*** WARNING: $func\n", $warn; $rv++; } if ($opt{hints} && exists $hints{$func} && !$given_hints{$func}++) { my $hint = $hints{$func}; $hint =~ s/^/ /mg; print " --- hint for $func ---\n", $hint; } $rv; } sub usage { my($usage) = do { local(@ARGV,$/)=($0); <> } =~ /^=head\d$HS+SYNOPSIS\s*^(.*?)\s*^=/ms; my %M = ( 'I' => '*' ); $usage =~ s/^\s*perl\s+\S+/$^X $0/; $usage =~ s/([A-Z])<([^>]+)>/$M{$1}$2$M{$1}/g; print < }; my($copy) = $self =~ /^=head\d\s+COPYRIGHT\s*^(.*?)^=\w+/ms; $copy =~ s/^(?=\S+)/ /gms; $self =~ s/^$HS+Do NOT edit.*?(?=^-)/$copy/ms; $self =~ s/^SKIP.*(?=^__DATA__)/SKIP if (\@ARGV && \$ARGV[0] eq '--unstrip') { eval { require Devel::PPPort }; \$@ and die "Cannot require Devel::PPPort, please install.\\n"; if (eval \$Devel::PPPort::VERSION < $VERSION) { die "$0 was originally generated with Devel::PPPort $VERSION.\\n" . "Your Devel::PPPort is only version \$Devel::PPPort::VERSION.\\n" . "Please install a newer version, or --unstrip will not work.\\n"; } Devel::PPPort::WriteFile(\$0); exit 0; } print <$0" or die "cannot strip $0: $!\n"; print OUT "$pl$c\n"; exit 0; } __DATA__ */ #ifndef _P_P_PORTABILITY_H_ #define _P_P_PORTABILITY_H_ #ifndef DPPP_NAMESPACE # define DPPP_NAMESPACE DPPP_ #endif #define DPPP_CAT2(x,y) CAT2(x,y) #define DPPP_(name) DPPP_CAT2(DPPP_NAMESPACE, name) #ifndef PERL_REVISION # if !defined(__PATCHLEVEL_H_INCLUDED__) && !(defined(PATCHLEVEL) && defined(SUBVERSION)) # define PERL_PATCHLEVEL_H_IMPLICIT # include # endif # if !(defined(PERL_VERSION) || (defined(SUBVERSION) && defined(PATCHLEVEL))) # include # endif # ifndef PERL_REVISION # define PERL_REVISION (5) /* Replace: 1 */ # define PERL_VERSION PATCHLEVEL # define PERL_SUBVERSION SUBVERSION /* Replace PERL_PATCHLEVEL with PERL_VERSION */ /* Replace: 0 */ # endif #endif #define _dpppDEC2BCD(dec) ((((dec)/100)<<8)|((((dec)%100)/10)<<4)|((dec)%10)) #define PERL_BCDVERSION ((_dpppDEC2BCD(PERL_REVISION)<<24)|(_dpppDEC2BCD(PERL_VERSION)<<12)|_dpppDEC2BCD(PERL_SUBVERSION)) /* It is very unlikely that anyone will try to use this with Perl 6 (or greater), but who knows. */ #if PERL_REVISION != 5 # error ppport.h only works with Perl version 5 #endif /* PERL_REVISION != 5 */ #ifndef dTHR # define dTHR dNOOP #endif #ifndef dTHX # define dTHX dNOOP #endif #ifndef dTHXa # define dTHXa(x) dNOOP #endif #ifndef pTHX # define pTHX void #endif #ifndef pTHX_ # define pTHX_ #endif #ifndef aTHX # define aTHX #endif #ifndef aTHX_ # define aTHX_ #endif #if (PERL_BCDVERSION < 0x5006000) # ifdef USE_THREADS # define aTHXR thr # define aTHXR_ thr, # else # define aTHXR # define aTHXR_ # endif # define dTHXR dTHR #else # define aTHXR aTHX # define aTHXR_ aTHX_ # define dTHXR dTHX #endif #ifndef dTHXoa # define dTHXoa(x) dTHXa(x) #endif #ifdef I_LIMITS # include #endif #ifndef PERL_UCHAR_MIN # define PERL_UCHAR_MIN ((unsigned char)0) #endif #ifndef PERL_UCHAR_MAX # ifdef UCHAR_MAX # define PERL_UCHAR_MAX ((unsigned char)UCHAR_MAX) # else # ifdef MAXUCHAR # define PERL_UCHAR_MAX ((unsigned char)MAXUCHAR) # else # define PERL_UCHAR_MAX ((unsigned char)~(unsigned)0) # endif # endif #endif #ifndef PERL_USHORT_MIN # define PERL_USHORT_MIN ((unsigned short)0) #endif #ifndef PERL_USHORT_MAX # ifdef USHORT_MAX # define PERL_USHORT_MAX ((unsigned short)USHORT_MAX) # else # ifdef MAXUSHORT # define PERL_USHORT_MAX ((unsigned short)MAXUSHORT) # else # ifdef USHRT_MAX # define PERL_USHORT_MAX ((unsigned short)USHRT_MAX) # else # define PERL_USHORT_MAX ((unsigned short)~(unsigned)0) # endif # endif # endif #endif #ifndef PERL_SHORT_MAX # ifdef SHORT_MAX # define PERL_SHORT_MAX ((short)SHORT_MAX) # else # ifdef MAXSHORT /* Often used in */ # define PERL_SHORT_MAX ((short)MAXSHORT) # else # ifdef SHRT_MAX # define PERL_SHORT_MAX ((short)SHRT_MAX) # else # define PERL_SHORT_MAX ((short) (PERL_USHORT_MAX >> 1)) # endif # endif # endif #endif #ifndef PERL_SHORT_MIN # ifdef SHORT_MIN # define PERL_SHORT_MIN ((short)SHORT_MIN) # else # ifdef MINSHORT # define PERL_SHORT_MIN ((short)MINSHORT) # else # ifdef SHRT_MIN # define PERL_SHORT_MIN ((short)SHRT_MIN) # else # define PERL_SHORT_MIN (-PERL_SHORT_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif #ifndef PERL_UINT_MAX # ifdef UINT_MAX # define PERL_UINT_MAX ((unsigned int)UINT_MAX) # else # ifdef MAXUINT # define PERL_UINT_MAX ((unsigned int)MAXUINT) # else # define PERL_UINT_MAX (~(unsigned int)0) # endif # endif #endif #ifndef PERL_UINT_MIN # define PERL_UINT_MIN ((unsigned int)0) #endif #ifndef PERL_INT_MAX # ifdef INT_MAX # define PERL_INT_MAX ((int)INT_MAX) # else # ifdef MAXINT /* Often used in */ # define PERL_INT_MAX ((int)MAXINT) # else # define PERL_INT_MAX ((int)(PERL_UINT_MAX >> 1)) # endif # endif #endif #ifndef PERL_INT_MIN # ifdef INT_MIN # define PERL_INT_MIN ((int)INT_MIN) # else # ifdef MININT # define PERL_INT_MIN ((int)MININT) # else # define PERL_INT_MIN (-PERL_INT_MAX - ((3 & -1) == 3)) # endif # endif #endif #ifndef PERL_ULONG_MAX # ifdef ULONG_MAX # define PERL_ULONG_MAX ((unsigned long)ULONG_MAX) # else # ifdef MAXULONG # define PERL_ULONG_MAX ((unsigned long)MAXULONG) # else # define PERL_ULONG_MAX (~(unsigned long)0) # endif # endif #endif #ifndef PERL_ULONG_MIN # define PERL_ULONG_MIN ((unsigned long)0L) #endif #ifndef PERL_LONG_MAX # ifdef LONG_MAX # define PERL_LONG_MAX ((long)LONG_MAX) # else # ifdef MAXLONG # define PERL_LONG_MAX ((long)MAXLONG) # else # define PERL_LONG_MAX ((long) (PERL_ULONG_MAX >> 1)) # endif # endif #endif #ifndef PERL_LONG_MIN # ifdef LONG_MIN # define PERL_LONG_MIN ((long)LONG_MIN) # else # ifdef MINLONG # define PERL_LONG_MIN ((long)MINLONG) # else # define PERL_LONG_MIN (-PERL_LONG_MAX - ((3 & -1) == 3)) # endif # endif #endif #if defined(HAS_QUAD) && (defined(convex) || defined(uts)) # ifndef PERL_UQUAD_MAX # ifdef ULONGLONG_MAX # define PERL_UQUAD_MAX ((unsigned long long)ULONGLONG_MAX) # else # ifdef MAXULONGLONG # define PERL_UQUAD_MAX ((unsigned long long)MAXULONGLONG) # else # define PERL_UQUAD_MAX (~(unsigned long long)0) # endif # endif # endif # ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN ((unsigned long long)0L) # endif # ifndef PERL_QUAD_MAX # ifdef LONGLONG_MAX # define PERL_QUAD_MAX ((long long)LONGLONG_MAX) # else # ifdef MAXLONGLONG # define PERL_QUAD_MAX ((long long)MAXLONGLONG) # else # define PERL_QUAD_MAX ((long long) (PERL_UQUAD_MAX >> 1)) # endif # endif # endif # ifndef PERL_QUAD_MIN # ifdef LONGLONG_MIN # define PERL_QUAD_MIN ((long long)LONGLONG_MIN) # else # ifdef MINLONGLONG # define PERL_QUAD_MIN ((long long)MINLONGLONG) # else # define PERL_QUAD_MIN (-PERL_QUAD_MAX - ((3 & -1) == 3)) # endif # endif # endif #endif /* This is based on code from 5.003 perl.h */ #ifdef HAS_QUAD # ifdef cray #ifndef IVTYPE # define IVTYPE int #endif #ifndef IV_MIN # define IV_MIN PERL_INT_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_INT_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UINT_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UINT_MAX #endif # ifdef INTSIZE #ifndef IVSIZE # define IVSIZE INTSIZE #endif # endif # else # if defined(convex) || defined(uts) #ifndef IVTYPE # define IVTYPE long long #endif #ifndef IV_MIN # define IV_MIN PERL_QUAD_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_QUAD_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_UQUAD_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_UQUAD_MAX #endif # ifdef LONGLONGSIZE #ifndef IVSIZE # define IVSIZE LONGLONGSIZE #endif # endif # else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif # ifdef LONGSIZE #ifndef IVSIZE # define IVSIZE LONGSIZE #endif # endif # endif # endif #ifndef IVSIZE # define IVSIZE 8 #endif #ifndef PERL_QUAD_MIN # define PERL_QUAD_MIN IV_MIN #endif #ifndef PERL_QUAD_MAX # define PERL_QUAD_MAX IV_MAX #endif #ifndef PERL_UQUAD_MIN # define PERL_UQUAD_MIN UV_MIN #endif #ifndef PERL_UQUAD_MAX # define PERL_UQUAD_MAX UV_MAX #endif #else #ifndef IVTYPE # define IVTYPE long #endif #ifndef IV_MIN # define IV_MIN PERL_LONG_MIN #endif #ifndef IV_MAX # define IV_MAX PERL_LONG_MAX #endif #ifndef UV_MIN # define UV_MIN PERL_ULONG_MIN #endif #ifndef UV_MAX # define UV_MAX PERL_ULONG_MAX #endif #endif #ifndef IVSIZE # ifdef LONGSIZE # define IVSIZE LONGSIZE # else # define IVSIZE 4 /* A bold guess, but the best we can make. */ # endif #endif #ifndef UVTYPE # define UVTYPE unsigned IVTYPE #endif #ifndef UVSIZE # define UVSIZE IVSIZE #endif #ifndef sv_setuv # define sv_setuv(sv, uv) \ STMT_START { \ UV TeMpUv = uv; \ if (TeMpUv <= IV_MAX) \ sv_setiv(sv, TeMpUv); \ else \ sv_setnv(sv, (double)TeMpUv); \ } STMT_END #endif #ifndef newSVuv # define newSVuv(uv) ((uv) <= IV_MAX ? newSViv((IV)uv) : newSVnv((NV)uv)) #endif #ifndef sv_2uv # define sv_2uv(sv) ((PL_Sv = (sv)), (UV) (SvNOK(PL_Sv) ? SvNV(PL_Sv) : sv_2nv(PL_Sv))) #endif #ifndef SvUVX # define SvUVX(sv) ((UV)SvIVX(sv)) #endif #ifndef SvUVXx # define SvUVXx(sv) SvUVX(sv) #endif #ifndef SvUV # define SvUV(sv) (SvIOK(sv) ? SvUVX(sv) : sv_2uv(sv)) #endif #ifndef SvUVx # define SvUVx(sv) ((PL_Sv = (sv)), SvUV(PL_Sv)) #endif /* Hint: sv_uv * Always use the SvUVx() macro instead of sv_uv(). */ #ifndef sv_uv # define sv_uv(sv) SvUVx(sv) #endif #if !defined(SvUOK) && defined(SvIOK_UV) # define SvUOK(sv) SvIOK_UV(sv) #endif #ifndef XST_mUV # define XST_mUV(i,v) (ST(i) = sv_2mortal(newSVuv(v)) ) #endif #ifndef XSRETURN_UV # define XSRETURN_UV(v) STMT_START { XST_mUV(0,v); XSRETURN(1); } STMT_END #endif #ifndef PUSHu # define PUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); PUSHTARG; } STMT_END #endif #ifndef XPUSHu # define XPUSHu(u) STMT_START { sv_setuv(TARG, (UV)(u)); XPUSHTARG; } STMT_END #endif #ifdef HAS_MEMCMP #ifndef memNE # define memNE(s1,s2,l) (memcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!memcmp(s1,s2,l)) #endif #else #ifndef memNE # define memNE(s1,s2,l) (bcmp(s1,s2,l)) #endif #ifndef memEQ # define memEQ(s1,s2,l) (!bcmp(s1,s2,l)) #endif #endif #ifndef memEQs # define memEQs(s1, l, s2) \ (sizeof(s2)-1 == l && memEQ(s1, (s2 ""), (sizeof(s2)-1))) #endif #ifndef memNEs # define memNEs(s1, l, s2) !memEQs(s1, l, s2) #endif #ifndef MoveD # define MoveD(s,d,n,t) memmove((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifndef CopyD # define CopyD(s,d,n,t) memcpy((char*)(d),(char*)(s), (n) * sizeof(t)) #endif #ifdef HAS_MEMSET #ifndef ZeroD # define ZeroD(d,n,t) memzero((char*)(d), (n) * sizeof(t)) #endif #else #ifndef ZeroD # define ZeroD(d,n,t) ((void)memzero((char*)(d), (n) * sizeof(t)), d) #endif #endif #ifndef PoisonWith # define PoisonWith(d,n,t,b) (void)memset((char*)(d), (U8)(b), (n) * sizeof(t)) #endif #ifndef PoisonNew # define PoisonNew(d,n,t) PoisonWith(d,n,t,0xAB) #endif #ifndef PoisonFree # define PoisonFree(d,n,t) PoisonWith(d,n,t,0xEF) #endif #ifndef Poison # define Poison(d,n,t) PoisonFree(d,n,t) #endif #ifndef Newx # define Newx(v,n,t) New(0,v,n,t) #endif #ifndef Newxc # define Newxc(v,n,t,c) Newc(0,v,n,t,c) #endif #ifndef Newxz # define Newxz(v,n,t) Newz(0,v,n,t) #endif #ifndef PERL_UNUSED_DECL # ifdef HASATTRIBUTE # if (defined(__GNUC__) && defined(__cplusplus)) || defined(__INTEL_COMPILER) # define PERL_UNUSED_DECL # else # define PERL_UNUSED_DECL __attribute__((unused)) # endif # else # define PERL_UNUSED_DECL # endif #endif #ifndef PERL_UNUSED_ARG # if defined(lint) && defined(S_SPLINT_S) /* www.splint.org */ # include # define PERL_UNUSED_ARG(x) NOTE(ARGUNUSED(x)) # else # define PERL_UNUSED_ARG(x) ((void)x) # endif #endif #ifndef PERL_UNUSED_VAR # define PERL_UNUSED_VAR(x) ((void)x) #endif #ifndef PERL_UNUSED_CONTEXT # ifdef USE_ITHREADS # define PERL_UNUSED_CONTEXT PERL_UNUSED_ARG(my_perl) # else # define PERL_UNUSED_CONTEXT # endif #endif #ifndef NOOP # define NOOP /*EMPTY*/(void)0 #endif #ifndef dNOOP # define dNOOP extern int /*@unused@*/ Perl___notused PERL_UNUSED_DECL #endif #ifndef NVTYPE # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) # define NVTYPE long double # else # define NVTYPE double # endif typedef NVTYPE NV; #endif #ifndef INT2PTR # if (IVSIZE == PTRSIZE) && (UVSIZE == PTRSIZE) # define PTRV UV # define INT2PTR(any,d) (any)(d) # else # if PTRSIZE == LONGSIZE # define PTRV unsigned long # else # define PTRV unsigned # endif # define INT2PTR(any,d) (any)(PTRV)(d) # endif #endif #ifndef PTR2ul # if PTRSIZE == LONGSIZE # define PTR2ul(p) (unsigned long)(p) # else # define PTR2ul(p) INT2PTR(unsigned long,p) # endif #endif #ifndef PTR2nat # define PTR2nat(p) (PTRV)(p) #endif #ifndef NUM2PTR # define NUM2PTR(any,d) (any)PTR2nat(d) #endif #ifndef PTR2IV # define PTR2IV(p) INT2PTR(IV,p) #endif #ifndef PTR2UV # define PTR2UV(p) INT2PTR(UV,p) #endif #ifndef PTR2NV # define PTR2NV(p) NUM2PTR(NV,p) #endif #undef START_EXTERN_C #undef END_EXTERN_C #undef EXTERN_C #ifdef __cplusplus # define START_EXTERN_C extern "C" { # define END_EXTERN_C } # define EXTERN_C extern "C" #else # define START_EXTERN_C # define END_EXTERN_C # define EXTERN_C extern #endif #if defined(PERL_GCC_PEDANTIC) # ifndef PERL_GCC_BRACE_GROUPS_FORBIDDEN # define PERL_GCC_BRACE_GROUPS_FORBIDDEN # endif #endif #if defined(__GNUC__) && !defined(PERL_GCC_BRACE_GROUPS_FORBIDDEN) && !defined(__cplusplus) # ifndef PERL_USE_GCC_BRACE_GROUPS # define PERL_USE_GCC_BRACE_GROUPS # endif #endif #undef STMT_START #undef STMT_END #ifdef PERL_USE_GCC_BRACE_GROUPS # define STMT_START (void)( /* gcc supports ``({ STATEMENTS; })'' */ # define STMT_END ) #else # if defined(VOIDFLAGS) && (VOIDFLAGS) && (defined(sun) || defined(__sun__)) && !defined(__GNUC__) # define STMT_START if (1) # define STMT_END else (void)0 # else # define STMT_START do # define STMT_END while (0) # endif #endif #ifndef boolSV # define boolSV(b) ((b) ? &PL_sv_yes : &PL_sv_no) #endif /* DEFSV appears first in 5.004_56 */ #ifndef DEFSV # define DEFSV GvSV(PL_defgv) #endif #ifndef SAVE_DEFSV # define SAVE_DEFSV SAVESPTR(GvSV(PL_defgv)) #endif #ifndef DEFSV_set # define DEFSV_set(sv) (DEFSV = (sv)) #endif /* Older perls (<=5.003) lack AvFILLp */ #ifndef AvFILLp # define AvFILLp AvFILL #endif #ifndef ERRSV # define ERRSV get_sv("@",FALSE) #endif /* Hint: gv_stashpvn * This function's backport doesn't support the length parameter, but * rather ignores it. Portability can only be ensured if the length * parameter is used for speed reasons, but the length can always be * correctly computed from the string argument. */ #ifndef gv_stashpvn # define gv_stashpvn(str,len,create) gv_stashpv(str,create) #endif /* Replace: 1 */ #ifndef get_cv # define get_cv perl_get_cv #endif #ifndef get_sv # define get_sv perl_get_sv #endif #ifndef get_av # define get_av perl_get_av #endif #ifndef get_hv # define get_hv perl_get_hv #endif /* Replace: 0 */ #ifndef dUNDERBAR # define dUNDERBAR dNOOP #endif #ifndef UNDERBAR # define UNDERBAR DEFSV #endif #ifndef dAX # define dAX I32 ax = MARK - PL_stack_base + 1 #endif #ifndef dITEMS # define dITEMS I32 items = SP - MARK #endif #ifndef dXSTARG # define dXSTARG SV * targ = sv_newmortal() #endif #ifndef dAXMARK # define dAXMARK I32 ax = POPMARK; \ register SV ** const mark = PL_stack_base + ax++ #endif #ifndef XSprePUSH # define XSprePUSH (sp = PL_stack_base + ax - 1) #endif #if (PERL_BCDVERSION < 0x5005000) # undef XSRETURN # define XSRETURN(off) \ STMT_START { \ PL_stack_sp = PL_stack_base + ax + ((off) - 1); \ return; \ } STMT_END #endif #ifndef XSPROTO # define XSPROTO(name) void name(pTHX_ CV* cv) #endif #ifndef SVfARG # define SVfARG(p) ((void*)(p)) #endif #ifndef PERL_ABS # define PERL_ABS(x) ((x) < 0 ? -(x) : (x)) #endif #ifndef dVAR # define dVAR dNOOP #endif #ifndef SVf # define SVf "_" #endif #ifndef UTF8_MAXBYTES # define UTF8_MAXBYTES UTF8_MAXLEN #endif #ifndef CPERLscope # define CPERLscope(x) x #endif #ifndef PERL_HASH # define PERL_HASH(hash,str,len) \ STMT_START { \ const char *s_PeRlHaSh = str; \ I32 i_PeRlHaSh = len; \ U32 hash_PeRlHaSh = 0; \ while (i_PeRlHaSh--) \ hash_PeRlHaSh = hash_PeRlHaSh * 33 + *s_PeRlHaSh++; \ (hash) = hash_PeRlHaSh; \ } STMT_END #endif #ifndef PERLIO_FUNCS_DECL # ifdef PERLIO_FUNCS_CONST # define PERLIO_FUNCS_DECL(funcs) const PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (PerlIO_funcs*)(funcs) # else # define PERLIO_FUNCS_DECL(funcs) PerlIO_funcs funcs # define PERLIO_FUNCS_CAST(funcs) (funcs) # endif #endif /* provide these typedefs for older perls */ #if (PERL_BCDVERSION < 0x5009003) # ifdef ARGSproto typedef OP* (CPERLscope(*Perl_ppaddr_t))(ARGSproto); # else typedef OP* (CPERLscope(*Perl_ppaddr_t))(pTHX); # endif typedef OP* (CPERLscope(*Perl_check_t)) (pTHX_ OP*); #endif #ifndef isPSXSPC # define isPSXSPC(c) (isSPACE(c) || (c) == '\v') #endif #ifndef isBLANK # define isBLANK(c) ((c) == ' ' || (c) == '\t') #endif #ifdef EBCDIC #ifndef isALNUMC # define isALNUMC(c) isalnum(c) #endif #ifndef isASCII # define isASCII(c) isascii(c) #endif #ifndef isCNTRL # define isCNTRL(c) iscntrl(c) #endif #ifndef isGRAPH # define isGRAPH(c) isgraph(c) #endif #ifndef isPRINT # define isPRINT(c) isprint(c) #endif #ifndef isPUNCT # define isPUNCT(c) ispunct(c) #endif #ifndef isXDIGIT # define isXDIGIT(c) isxdigit(c) #endif #else # if (PERL_BCDVERSION < 0x5010000) /* Hint: isPRINT * The implementation in older perl versions includes all of the * isSPACE() characters, which is wrong. The version provided by * Devel::PPPort always overrides a present buggy version. */ # undef isPRINT # endif #ifndef isALNUMC # define isALNUMC(c) (isALPHA(c) || isDIGIT(c)) #endif #ifndef isASCII # define isASCII(c) ((U8) (c) <= 127) #endif #ifndef isCNTRL # define isCNTRL(c) ((U8) (c) < ' ' || (c) == 127) #endif #ifndef isGRAPH # define isGRAPH(c) (isALNUM(c) || isPUNCT(c)) #endif #ifndef isPRINT # define isPRINT(c) (((c) >= 32 && (c) < 127)) #endif #ifndef isPUNCT # define isPUNCT(c) (((c) >= 33 && (c) <= 47) || ((c) >= 58 && (c) <= 64) || ((c) >= 91 && (c) <= 96) || ((c) >= 123 && (c) <= 126)) #endif #ifndef isXDIGIT # define isXDIGIT(c) (isDIGIT(c) || ((c) >= 'a' && (c) <= 'f') || ((c) >= 'A' && (c) <= 'F')) #endif #endif #ifndef PERL_SIGNALS_UNSAFE_FLAG #define PERL_SIGNALS_UNSAFE_FLAG 0x0001 #if (PERL_BCDVERSION < 0x5008000) # define D_PPP_PERL_SIGNALS_INIT PERL_SIGNALS_UNSAFE_FLAG #else # define D_PPP_PERL_SIGNALS_INIT 0 #endif #if defined(NEED_PL_signals) static U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #elif defined(NEED_PL_signals_GLOBAL) U32 DPPP_(my_PL_signals) = D_PPP_PERL_SIGNALS_INIT; #else extern U32 DPPP_(my_PL_signals); #endif #define PL_signals DPPP_(my_PL_signals) #endif /* Hint: PL_ppaddr * Calling an op via PL_ppaddr requires passing a context argument * for threaded builds. Since the context argument is different for * 5.005 perls, you can use aTHXR (supplied by ppport.h), which will * automatically be defined as the correct argument. */ #if (PERL_BCDVERSION <= 0x5005005) /* Replace: 1 */ # define PL_ppaddr ppaddr # define PL_no_modify no_modify /* Replace: 0 */ #endif #if (PERL_BCDVERSION <= 0x5004005) /* Replace: 1 */ # define PL_DBsignal DBsignal # define PL_DBsingle DBsingle # define PL_DBsub DBsub # define PL_DBtrace DBtrace # define PL_Sv Sv # define PL_bufend bufend # define PL_bufptr bufptr # define PL_compiling compiling # define PL_copline copline # define PL_curcop curcop # define PL_curstash curstash # define PL_debstash debstash # define PL_defgv defgv # define PL_diehook diehook # define PL_dirty dirty # define PL_dowarn dowarn # define PL_errgv errgv # define PL_error_count error_count # define PL_expect expect # define PL_hexdigit hexdigit # define PL_hints hints # define PL_in_my in_my # define PL_laststatval laststatval # define PL_lex_state lex_state # define PL_lex_stuff lex_stuff # define PL_linestr linestr # define PL_na na # define PL_perl_destruct_level perl_destruct_level # define PL_perldb perldb # define PL_rsfp_filters rsfp_filters # define PL_rsfp rsfp # define PL_stack_base stack_base # define PL_stack_sp stack_sp # define PL_statcache statcache # define PL_stdingv stdingv # define PL_sv_arenaroot sv_arenaroot # define PL_sv_no sv_no # define PL_sv_undef sv_undef # define PL_sv_yes sv_yes # define PL_tainted tainted # define PL_tainting tainting # define PL_tokenbuf tokenbuf /* Replace: 0 */ #endif /* Warning: PL_parser * For perl versions earlier than 5.9.5, this is an always * non-NULL dummy. Also, it cannot be dereferenced. Don't * use it if you can avoid is and unless you absolutely know * what you're doing. * If you always check that PL_parser is non-NULL, you can * define DPPP_PL_parser_NO_DUMMY to avoid the creation of * a dummy parser structure. */ #if (PERL_BCDVERSION >= 0x5009005) # ifdef DPPP_PL_parser_NO_DUMMY # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (croak("panic: PL_parser == NULL in %s:%d", \ __FILE__, __LINE__), (yy_parser *) NULL))->var) # else # ifdef DPPP_PL_parser_NO_DUMMY_WARNING # define D_PPP_parser_dummy_warning(var) # else # define D_PPP_parser_dummy_warning(var) \ warn("warning: dummy PL_" #var " used in %s:%d", __FILE__, __LINE__), # endif # define D_PPP_my_PL_parser_var(var) ((PL_parser ? PL_parser : \ (D_PPP_parser_dummy_warning(var) &DPPP_(dummy_PL_parser)))->var) #if defined(NEED_PL_parser) static yy_parser DPPP_(dummy_PL_parser); #elif defined(NEED_PL_parser_GLOBAL) yy_parser DPPP_(dummy_PL_parser); #else extern yy_parser DPPP_(dummy_PL_parser); #endif # endif /* PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf depends on PL_parser */ /* Warning: PL_expect, PL_copline, PL_rsfp, PL_rsfp_filters, PL_linestr, PL_bufptr, PL_bufend, PL_lex_state, PL_lex_stuff, PL_tokenbuf * Do not use this variable unless you know exactly what you're * doint. It is internal to the perl parser and may change or even * be removed in the future. As of perl 5.9.5, you have to check * for (PL_parser != NULL) for this variable to have any effect. * An always non-NULL PL_parser dummy is provided for earlier * perl versions. * If PL_parser is NULL when you try to access this variable, a * dummy is being accessed instead and a warning is issued unless * you define DPPP_PL_parser_NO_DUMMY_WARNING. * If DPPP_PL_parser_NO_DUMMY is defined, the code trying to access * this variable will croak with a panic message. */ # define PL_expect D_PPP_my_PL_parser_var(expect) # define PL_copline D_PPP_my_PL_parser_var(copline) # define PL_rsfp D_PPP_my_PL_parser_var(rsfp) # define PL_rsfp_filters D_PPP_my_PL_parser_var(rsfp_filters) # define PL_linestr D_PPP_my_PL_parser_var(linestr) # define PL_bufptr D_PPP_my_PL_parser_var(bufptr) # define PL_bufend D_PPP_my_PL_parser_var(bufend) # define PL_lex_state D_PPP_my_PL_parser_var(lex_state) # define PL_lex_stuff D_PPP_my_PL_parser_var(lex_stuff) # define PL_tokenbuf D_PPP_my_PL_parser_var(tokenbuf) # define PL_in_my D_PPP_my_PL_parser_var(in_my) # define PL_in_my_stash D_PPP_my_PL_parser_var(in_my_stash) # define PL_error_count D_PPP_my_PL_parser_var(error_count) #else /* ensure that PL_parser != NULL and cannot be dereferenced */ # define PL_parser ((void *) 1) #endif #ifndef mPUSHs # define mPUSHs(s) PUSHs(sv_2mortal(s)) #endif #ifndef PUSHmortal # define PUSHmortal PUSHs(sv_newmortal()) #endif #ifndef mPUSHp # define mPUSHp(p,l) sv_setpvn(PUSHmortal, (p), (l)) #endif #ifndef mPUSHn # define mPUSHn(n) sv_setnv(PUSHmortal, (NV)(n)) #endif #ifndef mPUSHi # define mPUSHi(i) sv_setiv(PUSHmortal, (IV)(i)) #endif #ifndef mPUSHu # define mPUSHu(u) sv_setuv(PUSHmortal, (UV)(u)) #endif #ifndef mXPUSHs # define mXPUSHs(s) XPUSHs(sv_2mortal(s)) #endif #ifndef XPUSHmortal # define XPUSHmortal XPUSHs(sv_newmortal()) #endif #ifndef mXPUSHp # define mXPUSHp(p,l) STMT_START { EXTEND(sp,1); sv_setpvn(PUSHmortal, (p), (l)); } STMT_END #endif #ifndef mXPUSHn # define mXPUSHn(n) STMT_START { EXTEND(sp,1); sv_setnv(PUSHmortal, (NV)(n)); } STMT_END #endif #ifndef mXPUSHi # define mXPUSHi(i) STMT_START { EXTEND(sp,1); sv_setiv(PUSHmortal, (IV)(i)); } STMT_END #endif #ifndef mXPUSHu # define mXPUSHu(u) STMT_START { EXTEND(sp,1); sv_setuv(PUSHmortal, (UV)(u)); } STMT_END #endif /* Replace: 1 */ #ifndef call_sv # define call_sv perl_call_sv #endif #ifndef call_pv # define call_pv perl_call_pv #endif #ifndef call_argv # define call_argv perl_call_argv #endif #ifndef call_method # define call_method perl_call_method #endif #ifndef eval_sv # define eval_sv perl_eval_sv #endif /* Replace: 0 */ #ifndef PERL_LOADMOD_DENY # define PERL_LOADMOD_DENY 0x1 #endif #ifndef PERL_LOADMOD_NOIMPORT # define PERL_LOADMOD_NOIMPORT 0x2 #endif #ifndef PERL_LOADMOD_IMPORT_OPS # define PERL_LOADMOD_IMPORT_OPS 0x4 #endif #ifndef G_METHOD # define G_METHOD 64 # ifdef call_sv # undef call_sv # endif # if (PERL_BCDVERSION < 0x5006000) # define call_sv(sv, flags) ((flags) & G_METHOD ? perl_call_method((char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : perl_call_sv(sv, flags)) # else # define call_sv(sv, flags) ((flags) & G_METHOD ? Perl_call_method(aTHX_ (char *) SvPV_nolen_const(sv), \ (flags) & ~G_METHOD) : Perl_call_sv(aTHX_ sv, flags)) # endif #endif /* Replace perl_eval_pv with eval_pv */ #ifndef eval_pv #if defined(NEED_eval_pv) static SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); static #else extern SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error); #endif #ifdef eval_pv # undef eval_pv #endif #define eval_pv(a,b) DPPP_(my_eval_pv)(aTHX_ a,b) #define Perl_eval_pv DPPP_(my_eval_pv) #if defined(NEED_eval_pv) || defined(NEED_eval_pv_GLOBAL) SV* DPPP_(my_eval_pv)(char *p, I32 croak_on_error) { dSP; SV* sv = newSVpv(p, 0); PUSHMARK(sp); eval_sv(sv, G_SCALAR); SvREFCNT_dec(sv); SPAGAIN; sv = POPs; PUTBACK; if (croak_on_error && SvTRUE(GvSV(errgv))) croak(SvPVx(GvSV(errgv), na)); return sv; } #endif #endif #ifndef vload_module #if defined(NEED_vload_module) static void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); static #else extern void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args); #endif #ifdef vload_module # undef vload_module #endif #define vload_module(a,b,c,d) DPPP_(my_vload_module)(aTHX_ a,b,c,d) #define Perl_vload_module DPPP_(my_vload_module) #if defined(NEED_vload_module) || defined(NEED_vload_module_GLOBAL) void DPPP_(my_vload_module)(U32 flags, SV *name, SV *ver, va_list *args) { dTHR; dVAR; OP *veop, *imop; OP * const modname = newSVOP(OP_CONST, 0, name); /* 5.005 has a somewhat hacky force_normal that doesn't croak on SvREADONLY() if PL_compling is true. Current perls take care in ck_require() to correctly turn off SvREADONLY before calling force_normal_flags(). This seems a better fix than fudging PL_compling */ SvREADONLY_off(((SVOP*)modname)->op_sv); modname->op_private |= OPpCONST_BARE; if (ver) { veop = newSVOP(OP_CONST, 0, ver); } else veop = NULL; if (flags & PERL_LOADMOD_NOIMPORT) { imop = sawparens(newNULLLIST()); } else if (flags & PERL_LOADMOD_IMPORT_OPS) { imop = va_arg(*args, OP*); } else { SV *sv; imop = NULL; sv = va_arg(*args, SV*); while (sv) { imop = append_elem(OP_LIST, imop, newSVOP(OP_CONST, 0, sv)); sv = va_arg(*args, SV*); } } { const line_t ocopline = PL_copline; COP * const ocurcop = PL_curcop; const int oexpect = PL_expect; #if (PERL_BCDVERSION >= 0x5004000) utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(FALSE, 0), veop, modname, imop); #else utilize(!(flags & PERL_LOADMOD_DENY), start_subparse(), modname, imop); #endif PL_expect = oexpect; PL_copline = ocopline; PL_curcop = ocurcop; } } #endif #endif #ifndef load_module #if defined(NEED_load_module) static void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); static #else extern void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...); #endif #ifdef load_module # undef load_module #endif #define load_module DPPP_(my_load_module) #define Perl_load_module DPPP_(my_load_module) #if defined(NEED_load_module) || defined(NEED_load_module_GLOBAL) void DPPP_(my_load_module)(U32 flags, SV *name, SV *ver, ...) { va_list args; va_start(args, ver); vload_module(flags, name, ver, &args); va_end(args); } #endif #endif #ifndef newRV_inc # define newRV_inc(sv) newRV(sv) /* Replace */ #endif #ifndef newRV_noinc #if defined(NEED_newRV_noinc) static SV * DPPP_(my_newRV_noinc)(SV *sv); static #else extern SV * DPPP_(my_newRV_noinc)(SV *sv); #endif #ifdef newRV_noinc # undef newRV_noinc #endif #define newRV_noinc(a) DPPP_(my_newRV_noinc)(aTHX_ a) #define Perl_newRV_noinc DPPP_(my_newRV_noinc) #if defined(NEED_newRV_noinc) || defined(NEED_newRV_noinc_GLOBAL) SV * DPPP_(my_newRV_noinc)(SV *sv) { SV *rv = (SV *)newRV(sv); SvREFCNT_dec(sv); return rv; } #endif #endif /* Hint: newCONSTSUB * Returns a CV* as of perl-5.7.1. This return value is not supported * by Devel::PPPort. */ /* newCONSTSUB from IO.xs is in the core starting with 5.004_63 */ #if (PERL_BCDVERSION < 0x5004063) && (PERL_BCDVERSION != 0x5004005) #if defined(NEED_newCONSTSUB) static void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); static #else extern void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv); #endif #ifdef newCONSTSUB # undef newCONSTSUB #endif #define newCONSTSUB(a,b,c) DPPP_(my_newCONSTSUB)(aTHX_ a,b,c) #define Perl_newCONSTSUB DPPP_(my_newCONSTSUB) #if defined(NEED_newCONSTSUB) || defined(NEED_newCONSTSUB_GLOBAL) /* This is just a trick to avoid a dependency of newCONSTSUB on PL_parser */ /* (There's no PL_parser in perl < 5.005, so this is completely safe) */ #define D_PPP_PL_copline PL_copline void DPPP_(my_newCONSTSUB)(HV *stash, const char *name, SV *sv) { U32 oldhints = PL_hints; HV *old_cop_stash = PL_curcop->cop_stash; HV *old_curstash = PL_curstash; line_t oldline = PL_curcop->cop_line; PL_curcop->cop_line = D_PPP_PL_copline; PL_hints &= ~HINT_BLOCK_SCOPE; if (stash) PL_curstash = PL_curcop->cop_stash = stash; newSUB( #if (PERL_BCDVERSION < 0x5003022) start_subparse(), #elif (PERL_BCDVERSION == 0x5003022) start_subparse(0), #else /* 5.003_23 onwards */ start_subparse(FALSE, 0), #endif newSVOP(OP_CONST, 0, newSVpv((char *) name, 0)), newSVOP(OP_CONST, 0, &PL_sv_no), /* SvPV(&PL_sv_no) == "" -- GMB */ newSTATEOP(0, Nullch, newSVOP(OP_CONST, 0, sv)) ); PL_hints = oldhints; PL_curcop->cop_stash = old_cop_stash; PL_curstash = old_curstash; PL_curcop->cop_line = oldline; } #endif #endif /* * Boilerplate macros for initializing and accessing interpreter-local * data from C. All statics in extensions should be reworked to use * this, if you want to make the extension thread-safe. See ext/re/re.xs * for an example of the use of these macros. * * Code that uses these macros is responsible for the following: * 1. #define MY_CXT_KEY to a unique string, e.g. "DynaLoader_guts" * 2. Declare a typedef named my_cxt_t that is a structure that contains * all the data that needs to be interpreter-local. * 3. Use the START_MY_CXT macro after the declaration of my_cxt_t. * 4. Use the MY_CXT_INIT macro such that it is called exactly once * (typically put in the BOOT: section). * 5. Use the members of the my_cxt_t structure everywhere as * MY_CXT.member. * 6. Use the dMY_CXT macro (a declaration) in all the functions that * access MY_CXT. */ #if defined(MULTIPLICITY) || defined(PERL_OBJECT) || \ defined(PERL_CAPI) || defined(PERL_IMPLICIT_CONTEXT) #ifndef START_MY_CXT /* This must appear in all extensions that define a my_cxt_t structure, * right after the definition (i.e. at file scope). The non-threads * case below uses it to declare the data as static. */ #define START_MY_CXT #if (PERL_BCDVERSION < 0x5004068) /* Fetches the SV that keeps the per-interpreter data. */ #define dMY_CXT_SV \ SV *my_cxt_sv = get_sv(MY_CXT_KEY, FALSE) #else /* >= perl5.004_68 */ #define dMY_CXT_SV \ SV *my_cxt_sv = *hv_fetch(PL_modglobal, MY_CXT_KEY, \ sizeof(MY_CXT_KEY)-1, TRUE) #endif /* < perl5.004_68 */ /* This declaration should be used within all functions that use the * interpreter-local data. */ #define dMY_CXT \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = INT2PTR(my_cxt_t*,SvUV(my_cxt_sv)) /* Creates and zeroes the per-interpreter data. * (We allocate my_cxtp in a Perl SV so that it will be released when * the interpreter goes away.) */ #define MY_CXT_INIT \ dMY_CXT_SV; \ /* newSV() allocates one more than needed */ \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Zero(my_cxtp, 1, my_cxt_t); \ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) /* This macro must be used to access members of the my_cxt_t structure. * e.g. MYCXT.some_data */ #define MY_CXT (*my_cxtp) /* Judicious use of these macros can reduce the number of times dMY_CXT * is used. Use is similar to pTHX, aTHX etc. */ #define pMY_CXT my_cxt_t *my_cxtp #define pMY_CXT_ pMY_CXT, #define _pMY_CXT ,pMY_CXT #define aMY_CXT my_cxtp #define aMY_CXT_ aMY_CXT, #define _aMY_CXT ,aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE /* Clones the per-interpreter data. */ #define MY_CXT_CLONE \ dMY_CXT_SV; \ my_cxt_t *my_cxtp = (my_cxt_t*)SvPVX(newSV(sizeof(my_cxt_t)-1));\ Copy(INT2PTR(my_cxt_t*, SvUV(my_cxt_sv)), my_cxtp, 1, my_cxt_t);\ sv_setuv(my_cxt_sv, PTR2UV(my_cxtp)) #endif #else /* single interpreter */ #ifndef START_MY_CXT #define START_MY_CXT static my_cxt_t my_cxt; #define dMY_CXT_SV dNOOP #define dMY_CXT dNOOP #define MY_CXT_INIT NOOP #define MY_CXT my_cxt #define pMY_CXT void #define pMY_CXT_ #define _pMY_CXT #define aMY_CXT #define aMY_CXT_ #define _aMY_CXT #endif /* START_MY_CXT */ #ifndef MY_CXT_CLONE #define MY_CXT_CLONE NOOP #endif #endif #ifndef IVdf # if IVSIZE == LONGSIZE # define IVdf "ld" # define UVuf "lu" # define UVof "lo" # define UVxf "lx" # define UVXf "lX" # else # if IVSIZE == INTSIZE # define IVdf "d" # define UVuf "u" # define UVof "o" # define UVxf "x" # define UVXf "X" # endif # endif #endif #ifndef NVef # if defined(USE_LONG_DOUBLE) && defined(HAS_LONG_DOUBLE) && \ defined(PERL_PRIfldbl) && (PERL_BCDVERSION != 0x5006000) /* Not very likely, but let's try anyway. */ # define NVef PERL_PRIeldbl # define NVff PERL_PRIfldbl # define NVgf PERL_PRIgldbl # else # define NVef "e" # define NVff "f" # define NVgf "g" # endif #endif #ifndef SvREFCNT_inc # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (SvREFCNT(_sv))++; \ _sv; \ }) # else # define SvREFCNT_inc(sv) \ ((PL_Sv=(SV*)(sv)) ? (++(SvREFCNT(PL_Sv)),PL_Sv) : NULL) # endif #endif #ifndef SvREFCNT_inc_simple # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_simple(sv) \ ({ \ if (sv) \ (SvREFCNT(sv))++; \ (SV *)(sv); \ }) # else # define SvREFCNT_inc_simple(sv) \ ((sv) ? (SvREFCNT(sv)++,(SV*)(sv)) : NULL) # endif #endif #ifndef SvREFCNT_inc_NN # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_NN(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ SvREFCNT(_sv)++; \ _sv; \ }) # else # define SvREFCNT_inc_NN(sv) \ (PL_Sv=(SV*)(sv),++(SvREFCNT(PL_Sv)),PL_Sv) # endif #endif #ifndef SvREFCNT_inc_void # ifdef PERL_USE_GCC_BRACE_GROUPS # define SvREFCNT_inc_void(sv) \ ({ \ SV * const _sv = (SV*)(sv); \ if (_sv) \ (void)(SvREFCNT(_sv)++); \ }) # else # define SvREFCNT_inc_void(sv) \ (void)((PL_Sv=(SV*)(sv)) ? ++(SvREFCNT(PL_Sv)) : 0) # endif #endif #ifndef SvREFCNT_inc_simple_void # define SvREFCNT_inc_simple_void(sv) STMT_START { if (sv) SvREFCNT(sv)++; } STMT_END #endif #ifndef SvREFCNT_inc_simple_NN # define SvREFCNT_inc_simple_NN(sv) (++SvREFCNT(sv), (SV*)(sv)) #endif #ifndef SvREFCNT_inc_void_NN # define SvREFCNT_inc_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef SvREFCNT_inc_simple_void_NN # define SvREFCNT_inc_simple_void_NN(sv) (void)(++SvREFCNT((SV*)(sv))) #endif #ifndef newSV_type #if defined(NEED_newSV_type) static SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); static #else extern SV* DPPP_(my_newSV_type)(pTHX_ svtype const t); #endif #ifdef newSV_type # undef newSV_type #endif #define newSV_type(a) DPPP_(my_newSV_type)(aTHX_ a) #define Perl_newSV_type DPPP_(my_newSV_type) #if defined(NEED_newSV_type) || defined(NEED_newSV_type_GLOBAL) SV* DPPP_(my_newSV_type)(pTHX_ svtype const t) { SV* const sv = newSV(0); sv_upgrade(sv, t); return sv; } #endif #endif #if (PERL_BCDVERSION < 0x5006000) # define D_PPP_CONSTPV_ARG(x) ((char *) (x)) #else # define D_PPP_CONSTPV_ARG(x) (x) #endif #ifndef newSVpvn # define newSVpvn(data,len) ((data) \ ? ((len) ? newSVpv((data), (len)) : newSVpv("", 0)) \ : newSV(0)) #endif #ifndef newSVpvn_utf8 # define newSVpvn_utf8(s, len, u) newSVpvn_flags((s), (len), (u) ? SVf_UTF8 : 0) #endif #ifndef SVf_UTF8 # define SVf_UTF8 0 #endif #ifndef newSVpvn_flags #if defined(NEED_newSVpvn_flags) static SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); static #else extern SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags); #endif #ifdef newSVpvn_flags # undef newSVpvn_flags #endif #define newSVpvn_flags(a,b,c) DPPP_(my_newSVpvn_flags)(aTHX_ a,b,c) #define Perl_newSVpvn_flags DPPP_(my_newSVpvn_flags) #if defined(NEED_newSVpvn_flags) || defined(NEED_newSVpvn_flags_GLOBAL) SV * DPPP_(my_newSVpvn_flags)(pTHX_ const char *s, STRLEN len, U32 flags) { SV *sv = newSVpvn(D_PPP_CONSTPV_ARG(s), len); SvFLAGS(sv) |= (flags & SVf_UTF8); return (flags & SVs_TEMP) ? sv_2mortal(sv) : sv; } #endif #endif /* Backwards compatibility stuff... :-( */ #if !defined(NEED_sv_2pv_flags) && defined(NEED_sv_2pv_nolen) # define NEED_sv_2pv_flags #endif #if !defined(NEED_sv_2pv_flags_GLOBAL) && defined(NEED_sv_2pv_nolen_GLOBAL) # define NEED_sv_2pv_flags_GLOBAL #endif /* Hint: sv_2pv_nolen * Use the SvPV_nolen() or SvPV_nolen_const() macros instead of sv_2pv_nolen(). */ #ifndef sv_2pv_nolen # define sv_2pv_nolen(sv) SvPV_nolen(sv) #endif #ifdef SvPVbyte /* Hint: SvPVbyte * Does not work in perl-5.6.1, ppport.h implements a version * borrowed from perl-5.7.3. */ #if (PERL_BCDVERSION < 0x5007000) #if defined(NEED_sv_2pvbyte) static char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); static #else extern char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp); #endif #ifdef sv_2pvbyte # undef sv_2pvbyte #endif #define sv_2pvbyte(a,b) DPPP_(my_sv_2pvbyte)(aTHX_ a,b) #define Perl_sv_2pvbyte DPPP_(my_sv_2pvbyte) #if defined(NEED_sv_2pvbyte) || defined(NEED_sv_2pvbyte_GLOBAL) char * DPPP_(my_sv_2pvbyte)(pTHX_ SV *sv, STRLEN *lp) { sv_utf8_downgrade(sv,0); return SvPV(sv,*lp); } #endif /* Hint: sv_2pvbyte * Use the SvPVbyte() macro instead of sv_2pvbyte(). */ #undef SvPVbyte #define SvPVbyte(sv, lp) \ ((SvFLAGS(sv) & (SVf_POK|SVf_UTF8)) == (SVf_POK) \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pvbyte(sv, &lp)) #endif #else # define SvPVbyte SvPV # define sv_2pvbyte sv_2pv #endif #ifndef sv_2pvbyte_nolen # define sv_2pvbyte_nolen(sv) sv_2pv_nolen(sv) #endif /* Hint: sv_pvn * Always use the SvPV() macro instead of sv_pvn(). */ /* Hint: sv_pvn_force * Always use the SvPV_force() macro instead of sv_pvn_force(). */ /* If these are undefined, they're not handled by the core anyway */ #ifndef SV_IMMEDIATE_UNREF # define SV_IMMEDIATE_UNREF 0 #endif #ifndef SV_GMAGIC # define SV_GMAGIC 0 #endif #ifndef SV_COW_DROP_PV # define SV_COW_DROP_PV 0 #endif #ifndef SV_UTF8_NO_ENCODING # define SV_UTF8_NO_ENCODING 0 #endif #ifndef SV_NOSTEAL # define SV_NOSTEAL 0 #endif #ifndef SV_CONST_RETURN # define SV_CONST_RETURN 0 #endif #ifndef SV_MUTABLE_RETURN # define SV_MUTABLE_RETURN 0 #endif #ifndef SV_SMAGIC # define SV_SMAGIC 0 #endif #ifndef SV_HAS_TRAILING_NUL # define SV_HAS_TRAILING_NUL 0 #endif #ifndef SV_COW_SHARED_HASH_KEYS # define SV_COW_SHARED_HASH_KEYS 0 #endif #if (PERL_BCDVERSION < 0x5007002) #if defined(NEED_sv_2pv_flags) static char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_2pv_flags # undef sv_2pv_flags #endif #define sv_2pv_flags(a,b,c) DPPP_(my_sv_2pv_flags)(aTHX_ a,b,c) #define Perl_sv_2pv_flags DPPP_(my_sv_2pv_flags) #if defined(NEED_sv_2pv_flags) || defined(NEED_sv_2pv_flags_GLOBAL) char * DPPP_(my_sv_2pv_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_2pv(sv, lp ? lp : &n_a); } #endif #if defined(NEED_sv_pvn_force_flags) static char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); static #else extern char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags); #endif #ifdef sv_pvn_force_flags # undef sv_pvn_force_flags #endif #define sv_pvn_force_flags(a,b,c) DPPP_(my_sv_pvn_force_flags)(aTHX_ a,b,c) #define Perl_sv_pvn_force_flags DPPP_(my_sv_pvn_force_flags) #if defined(NEED_sv_pvn_force_flags) || defined(NEED_sv_pvn_force_flags_GLOBAL) char * DPPP_(my_sv_pvn_force_flags)(pTHX_ SV *sv, STRLEN *lp, I32 flags) { STRLEN n_a = (STRLEN) flags; return sv_pvn_force(sv, lp ? lp : &n_a); } #endif #endif #if (PERL_BCDVERSION < 0x5008008) || ( (PERL_BCDVERSION >= 0x5009000) && (PERL_BCDVERSION < 0x5009003) ) # define DPPP_SVPV_NOLEN_LP_ARG &PL_na #else # define DPPP_SVPV_NOLEN_LP_ARG 0 #endif #ifndef SvPV_const # define SvPV_const(sv, lp) SvPV_flags_const(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_mutable # define SvPV_mutable(sv, lp) SvPV_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_flags # define SvPV_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_2pv_flags(sv, &lp, flags)) #endif #ifndef SvPV_flags_const # define SvPV_flags_const(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_const(sv)) : \ (const char*) sv_2pv_flags(sv, &lp, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_const_nolen # define SvPV_flags_const_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : \ (const char*) sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags|SV_CONST_RETURN)) #endif #ifndef SvPV_flags_mutable # define SvPV_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) : \ sv_2pv_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_force # define SvPV_force(sv, lp) SvPV_force_flags(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nolen # define SvPV_force_nolen(sv) SvPV_force_flags_nolen(sv, SV_GMAGIC) #endif #ifndef SvPV_force_mutable # define SvPV_force_mutable(sv, lp) SvPV_force_flags_mutable(sv, lp, SV_GMAGIC) #endif #ifndef SvPV_force_nomg # define SvPV_force_nomg(sv, lp) SvPV_force_flags(sv, lp, 0) #endif #ifndef SvPV_force_nomg_nolen # define SvPV_force_nomg_nolen(sv) SvPV_force_flags_nolen(sv, 0) #endif #ifndef SvPV_force_flags # define SvPV_force_flags(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX(sv)) : sv_pvn_force_flags(sv, &lp, flags)) #endif #ifndef SvPV_force_flags_nolen # define SvPV_force_flags_nolen(sv, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? SvPVX(sv) : sv_pvn_force_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, flags)) #endif #ifndef SvPV_force_flags_mutable # define SvPV_force_flags_mutable(sv, lp, flags) \ ((SvFLAGS(sv) & (SVf_POK|SVf_THINKFIRST)) == SVf_POK \ ? ((lp = SvCUR(sv)), SvPVX_mutable(sv)) \ : sv_pvn_force_flags(sv, &lp, flags|SV_MUTABLE_RETURN)) #endif #ifndef SvPV_nolen # define SvPV_nolen(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC)) #endif #ifndef SvPV_nolen_const # define SvPV_nolen_const(sv) \ ((SvFLAGS(sv) & (SVf_POK)) == SVf_POK \ ? SvPVX_const(sv) : sv_2pv_flags(sv, DPPP_SVPV_NOLEN_LP_ARG, SV_GMAGIC|SV_CONST_RETURN)) #endif #ifndef SvPV_nomg # define SvPV_nomg(sv, lp) SvPV_flags(sv, lp, 0) #endif #ifndef SvPV_nomg_const # define SvPV_nomg_const(sv, lp) SvPV_flags_const(sv, lp, 0) #endif #ifndef SvPV_nomg_const_nolen # define SvPV_nomg_const_nolen(sv) SvPV_flags_const_nolen(sv, 0) #endif #ifndef SvPV_renew # define SvPV_renew(sv,n) STMT_START { SvLEN_set(sv, n); \ SvPV_set((sv), (char *) saferealloc( \ (Malloc_t)SvPVX(sv), (MEM_SIZE)((n)))); \ } STMT_END #endif #ifndef SvMAGIC_set # define SvMAGIC_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_magic = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5009003) #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*) (0 + SvPVX(sv))) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) (0 + SvPVX(sv)) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ (((XRV*) SvANY(sv))->xrv_rv = (val)); } STMT_END #endif #else #ifndef SvPVX_const # define SvPVX_const(sv) ((const char*)((sv)->sv_u.svu_pv)) #endif #ifndef SvPVX_mutable # define SvPVX_mutable(sv) ((sv)->sv_u.svu_pv) #endif #ifndef SvRV_set # define SvRV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_RV); \ ((sv)->sv_u.svu_rv = (val)); } STMT_END #endif #endif #ifndef SvSTASH_set # define SvSTASH_set(sv, val) \ STMT_START { assert(SvTYPE(sv) >= SVt_PVMG); \ (((XPVMG*) SvANY(sv))->xmg_stash = (val)); } STMT_END #endif #if (PERL_BCDVERSION < 0x5004000) #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVIV*) SvANY(sv))->xiv_iv = (IV) (val)); } STMT_END #endif #else #ifndef SvUV_set # define SvUV_set(sv, val) \ STMT_START { assert(SvTYPE(sv) == SVt_IV || SvTYPE(sv) >= SVt_PVIV); \ (((XPVUV*) SvANY(sv))->xuv_uv = (val)); } STMT_END #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(vnewSVpvf) #if defined(NEED_vnewSVpvf) static SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); static #else extern SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args); #endif #ifdef vnewSVpvf # undef vnewSVpvf #endif #define vnewSVpvf(a,b) DPPP_(my_vnewSVpvf)(aTHX_ a,b) #define Perl_vnewSVpvf DPPP_(my_vnewSVpvf) #if defined(NEED_vnewSVpvf) || defined(NEED_vnewSVpvf_GLOBAL) SV * DPPP_(my_vnewSVpvf)(pTHX_ const char *pat, va_list *args) { register SV *sv = newSV(0); sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); return sv; } #endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf) # define sv_vcatpvf(sv, pat, args) sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf) # define sv_vsetpvf(sv, pat, args) sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)) #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) static void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_catpvf_mg DPPP_(my_sv_catpvf_mg) #if defined(NEED_sv_catpvf_mg) || defined(NEED_sv_catpvf_mg_GLOBAL) void DPPP_(my_sv_catpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) static void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #define Perl_sv_catpvf_mg_nocontext DPPP_(my_sv_catpvf_mg_nocontext) #if defined(NEED_sv_catpvf_mg_nocontext) || defined(NEED_sv_catpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_catpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vcatpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_catpvf_mg depends on sv_catpvf_mg_nocontext */ #ifndef sv_catpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_catpvf_mg Perl_sv_catpvf_mg_nocontext # else # define sv_catpvf_mg Perl_sv_catpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vcatpvf_mg) # define sv_vcatpvf_mg(sv, pat, args) \ STMT_START { \ sv_vcatpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) static void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...); #endif #define Perl_sv_setpvf_mg DPPP_(my_sv_setpvf_mg) #if defined(NEED_sv_setpvf_mg) || defined(NEED_sv_setpvf_mg_GLOBAL) void DPPP_(my_sv_setpvf_mg)(pTHX_ SV *sv, const char *pat, ...) { va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #ifdef PERL_IMPLICIT_CONTEXT #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) static void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); static #else extern void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...); #endif #define sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #define Perl_sv_setpvf_mg_nocontext DPPP_(my_sv_setpvf_mg_nocontext) #if defined(NEED_sv_setpvf_mg_nocontext) || defined(NEED_sv_setpvf_mg_nocontext_GLOBAL) void DPPP_(my_sv_setpvf_mg_nocontext)(SV *sv, const char *pat, ...) { dTHX; va_list args; va_start(args, pat); sv_vsetpvfn(sv, pat, strlen(pat), &args, Null(SV**), 0, Null(bool*)); SvSETMAGIC(sv); va_end(args); } #endif #endif #endif /* sv_setpvf_mg depends on sv_setpvf_mg_nocontext */ #ifndef sv_setpvf_mg # ifdef PERL_IMPLICIT_CONTEXT # define sv_setpvf_mg Perl_sv_setpvf_mg_nocontext # else # define sv_setpvf_mg Perl_sv_setpvf_mg # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(sv_vsetpvf_mg) # define sv_vsetpvf_mg(sv, pat, args) \ STMT_START { \ sv_vsetpvfn(sv, pat, strlen(pat), args, Null(SV**), 0, Null(bool*)); \ SvSETMAGIC(sv); \ } STMT_END #endif /* Hint: newSVpvn_share * The SVs created by this function only mimic the behaviour of * shared PVs without really being shared. Only use if you know * what you're doing. */ #ifndef newSVpvn_share #if defined(NEED_newSVpvn_share) static SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); static #else extern SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash); #endif #ifdef newSVpvn_share # undef newSVpvn_share #endif #define newSVpvn_share(a,b,c) DPPP_(my_newSVpvn_share)(aTHX_ a,b,c) #define Perl_newSVpvn_share DPPP_(my_newSVpvn_share) #if defined(NEED_newSVpvn_share) || defined(NEED_newSVpvn_share_GLOBAL) SV * DPPP_(my_newSVpvn_share)(pTHX_ const char *src, I32 len, U32 hash) { SV *sv; if (len < 0) len = -len; if (!hash) PERL_HASH(hash, (char*) src, len); sv = newSVpvn((char *) src, len); sv_upgrade(sv, SVt_PVIV); SvIVX(sv) = hash; SvREADONLY_on(sv); SvPOK_on(sv); return sv; } #endif #endif #ifndef SvSHARED_HASH # define SvSHARED_HASH(sv) (0 + SvUVX(sv)) #endif #ifndef HvNAME_get # define HvNAME_get(hv) HvNAME(hv) #endif #ifndef HvNAMELEN_get # define HvNAMELEN_get(hv) (HvNAME_get(hv) ? (I32)strlen(HvNAME_get(hv)) : 0) #endif #ifndef GvSVn # define GvSVn(gv) GvSV(gv) #endif #ifndef isGV_with_GP # define isGV_with_GP(gv) isGV(gv) #endif #ifndef gv_fetchpvn_flags # define gv_fetchpvn_flags(name, len, flags, svt) gv_fetchpv(name, flags, svt) #endif #ifndef gv_fetchsv # define gv_fetchsv(name, flags, svt) gv_fetchpv(SvPV_nolen_const(name), flags, svt) #endif #ifndef get_cvn_flags # define get_cvn_flags(name, namelen, flags) get_cv(name, flags) #endif #ifndef WARN_ALL # define WARN_ALL 0 #endif #ifndef WARN_CLOSURE # define WARN_CLOSURE 1 #endif #ifndef WARN_DEPRECATED # define WARN_DEPRECATED 2 #endif #ifndef WARN_EXITING # define WARN_EXITING 3 #endif #ifndef WARN_GLOB # define WARN_GLOB 4 #endif #ifndef WARN_IO # define WARN_IO 5 #endif #ifndef WARN_CLOSED # define WARN_CLOSED 6 #endif #ifndef WARN_EXEC # define WARN_EXEC 7 #endif #ifndef WARN_LAYER # define WARN_LAYER 8 #endif #ifndef WARN_NEWLINE # define WARN_NEWLINE 9 #endif #ifndef WARN_PIPE # define WARN_PIPE 10 #endif #ifndef WARN_UNOPENED # define WARN_UNOPENED 11 #endif #ifndef WARN_MISC # define WARN_MISC 12 #endif #ifndef WARN_NUMERIC # define WARN_NUMERIC 13 #endif #ifndef WARN_ONCE # define WARN_ONCE 14 #endif #ifndef WARN_OVERFLOW # define WARN_OVERFLOW 15 #endif #ifndef WARN_PACK # define WARN_PACK 16 #endif #ifndef WARN_PORTABLE # define WARN_PORTABLE 17 #endif #ifndef WARN_RECURSION # define WARN_RECURSION 18 #endif #ifndef WARN_REDEFINE # define WARN_REDEFINE 19 #endif #ifndef WARN_REGEXP # define WARN_REGEXP 20 #endif #ifndef WARN_SEVERE # define WARN_SEVERE 21 #endif #ifndef WARN_DEBUGGING # define WARN_DEBUGGING 22 #endif #ifndef WARN_INPLACE # define WARN_INPLACE 23 #endif #ifndef WARN_INTERNAL # define WARN_INTERNAL 24 #endif #ifndef WARN_MALLOC # define WARN_MALLOC 25 #endif #ifndef WARN_SIGNAL # define WARN_SIGNAL 26 #endif #ifndef WARN_SUBSTR # define WARN_SUBSTR 27 #endif #ifndef WARN_SYNTAX # define WARN_SYNTAX 28 #endif #ifndef WARN_AMBIGUOUS # define WARN_AMBIGUOUS 29 #endif #ifndef WARN_BAREWORD # define WARN_BAREWORD 30 #endif #ifndef WARN_DIGIT # define WARN_DIGIT 31 #endif #ifndef WARN_PARENTHESIS # define WARN_PARENTHESIS 32 #endif #ifndef WARN_PRECEDENCE # define WARN_PRECEDENCE 33 #endif #ifndef WARN_PRINTF # define WARN_PRINTF 34 #endif #ifndef WARN_PROTOTYPE # define WARN_PROTOTYPE 35 #endif #ifndef WARN_QW # define WARN_QW 36 #endif #ifndef WARN_RESERVED # define WARN_RESERVED 37 #endif #ifndef WARN_SEMICOLON # define WARN_SEMICOLON 38 #endif #ifndef WARN_TAINT # define WARN_TAINT 39 #endif #ifndef WARN_THREADS # define WARN_THREADS 40 #endif #ifndef WARN_UNINITIALIZED # define WARN_UNINITIALIZED 41 #endif #ifndef WARN_UNPACK # define WARN_UNPACK 42 #endif #ifndef WARN_UNTIE # define WARN_UNTIE 43 #endif #ifndef WARN_UTF8 # define WARN_UTF8 44 #endif #ifndef WARN_VOID # define WARN_VOID 45 #endif #ifndef WARN_ASSERTIONS # define WARN_ASSERTIONS 46 #endif #ifndef packWARN # define packWARN(a) (a) #endif #ifndef ckWARN # ifdef G_WARN_ON # define ckWARN(a) (PL_dowarn & G_WARN_ON) # else # define ckWARN(a) PL_dowarn # endif #endif #if (PERL_BCDVERSION >= 0x5004000) && !defined(warner) #if defined(NEED_warner) static void DPPP_(my_warner)(U32 err, const char *pat, ...); static #else extern void DPPP_(my_warner)(U32 err, const char *pat, ...); #endif #define Perl_warner DPPP_(my_warner) #if defined(NEED_warner) || defined(NEED_warner_GLOBAL) void DPPP_(my_warner)(U32 err, const char *pat, ...) { SV *sv; va_list args; PERL_UNUSED_ARG(err); va_start(args, pat); sv = vnewSVpvf(pat, &args); va_end(args); sv_2mortal(sv); warn("%s", SvPV_nolen(sv)); } #define warner Perl_warner #define Perl_warner_nocontext Perl_warner #endif #endif /* concatenating with "" ensures that only literal strings are accepted as argument * note that STR_WITH_LEN() can't be used as argument to macros or functions that * under some configurations might be macros */ #ifndef STR_WITH_LEN # define STR_WITH_LEN(s) (s ""), (sizeof(s)-1) #endif #ifndef newSVpvs # define newSVpvs(str) newSVpvn(str "", sizeof(str) - 1) #endif #ifndef newSVpvs_flags # define newSVpvs_flags(str, flags) newSVpvn_flags(str "", sizeof(str) - 1, flags) #endif #ifndef newSVpvs_share # define newSVpvs_share(str) newSVpvn_share(str "", sizeof(str) - 1, 0) #endif #ifndef sv_catpvs # define sv_catpvs(sv, str) sv_catpvn(sv, str "", sizeof(str) - 1) #endif #ifndef sv_setpvs # define sv_setpvs(sv, str) sv_setpvn(sv, str "", sizeof(str) - 1) #endif #ifndef hv_fetchs # define hv_fetchs(hv, key, lval) hv_fetch(hv, key "", sizeof(key) - 1, lval) #endif #ifndef hv_stores # define hv_stores(hv, key, val) hv_store(hv, key "", sizeof(key) - 1, val, 0) #endif #ifndef gv_fetchpvs # define gv_fetchpvs(name, flags, svt) gv_fetchpvn_flags(name "", sizeof(name) - 1, flags, svt) #endif #ifndef gv_stashpvs # define gv_stashpvs(name, flags) gv_stashpvn(name "", sizeof(name) - 1, flags) #endif #ifndef get_cvs # define get_cvs(name, flags) get_cvn_flags(name "", sizeof(name)-1, flags) #endif #ifndef SvGETMAGIC # define SvGETMAGIC(x) STMT_START { if (SvGMAGICAL(x)) mg_get(x); } STMT_END #endif #ifndef PERL_MAGIC_sv # define PERL_MAGIC_sv '\0' #endif #ifndef PERL_MAGIC_overload # define PERL_MAGIC_overload 'A' #endif #ifndef PERL_MAGIC_overload_elem # define PERL_MAGIC_overload_elem 'a' #endif #ifndef PERL_MAGIC_overload_table # define PERL_MAGIC_overload_table 'c' #endif #ifndef PERL_MAGIC_bm # define PERL_MAGIC_bm 'B' #endif #ifndef PERL_MAGIC_regdata # define PERL_MAGIC_regdata 'D' #endif #ifndef PERL_MAGIC_regdatum # define PERL_MAGIC_regdatum 'd' #endif #ifndef PERL_MAGIC_env # define PERL_MAGIC_env 'E' #endif #ifndef PERL_MAGIC_envelem # define PERL_MAGIC_envelem 'e' #endif #ifndef PERL_MAGIC_fm # define PERL_MAGIC_fm 'f' #endif #ifndef PERL_MAGIC_regex_global # define PERL_MAGIC_regex_global 'g' #endif #ifndef PERL_MAGIC_isa # define PERL_MAGIC_isa 'I' #endif #ifndef PERL_MAGIC_isaelem # define PERL_MAGIC_isaelem 'i' #endif #ifndef PERL_MAGIC_nkeys # define PERL_MAGIC_nkeys 'k' #endif #ifndef PERL_MAGIC_dbfile # define PERL_MAGIC_dbfile 'L' #endif #ifndef PERL_MAGIC_dbline # define PERL_MAGIC_dbline 'l' #endif #ifndef PERL_MAGIC_mutex # define PERL_MAGIC_mutex 'm' #endif #ifndef PERL_MAGIC_shared # define PERL_MAGIC_shared 'N' #endif #ifndef PERL_MAGIC_shared_scalar # define PERL_MAGIC_shared_scalar 'n' #endif #ifndef PERL_MAGIC_collxfrm # define PERL_MAGIC_collxfrm 'o' #endif #ifndef PERL_MAGIC_tied # define PERL_MAGIC_tied 'P' #endif #ifndef PERL_MAGIC_tiedelem # define PERL_MAGIC_tiedelem 'p' #endif #ifndef PERL_MAGIC_tiedscalar # define PERL_MAGIC_tiedscalar 'q' #endif #ifndef PERL_MAGIC_qr # define PERL_MAGIC_qr 'r' #endif #ifndef PERL_MAGIC_sig # define PERL_MAGIC_sig 'S' #endif #ifndef PERL_MAGIC_sigelem # define PERL_MAGIC_sigelem 's' #endif #ifndef PERL_MAGIC_taint # define PERL_MAGIC_taint 't' #endif #ifndef PERL_MAGIC_uvar # define PERL_MAGIC_uvar 'U' #endif #ifndef PERL_MAGIC_uvar_elem # define PERL_MAGIC_uvar_elem 'u' #endif #ifndef PERL_MAGIC_vstring # define PERL_MAGIC_vstring 'V' #endif #ifndef PERL_MAGIC_vec # define PERL_MAGIC_vec 'v' #endif #ifndef PERL_MAGIC_utf8 # define PERL_MAGIC_utf8 'w' #endif #ifndef PERL_MAGIC_substr # define PERL_MAGIC_substr 'x' #endif #ifndef PERL_MAGIC_defelem # define PERL_MAGIC_defelem 'y' #endif #ifndef PERL_MAGIC_glob # define PERL_MAGIC_glob '*' #endif #ifndef PERL_MAGIC_arylen # define PERL_MAGIC_arylen '#' #endif #ifndef PERL_MAGIC_pos # define PERL_MAGIC_pos '.' #endif #ifndef PERL_MAGIC_backref # define PERL_MAGIC_backref '<' #endif #ifndef PERL_MAGIC_ext # define PERL_MAGIC_ext '~' #endif /* That's the best we can do... */ #ifndef sv_catpvn_nomg # define sv_catpvn_nomg sv_catpvn #endif #ifndef sv_catsv_nomg # define sv_catsv_nomg sv_catsv #endif #ifndef sv_setsv_nomg # define sv_setsv_nomg sv_setsv #endif #ifndef sv_pvn_nomg # define sv_pvn_nomg sv_pvn #endif #ifndef SvIV_nomg # define SvIV_nomg SvIV #endif #ifndef SvUV_nomg # define SvUV_nomg SvUV #endif #ifndef sv_catpv_mg # define sv_catpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catpvn_mg # define sv_catpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_catpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_catsv_mg # define sv_catsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_catsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setiv_mg # define sv_setiv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setiv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setnv_mg # define sv_setnv_mg(sv, num) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setnv(TeMpSv,num); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpv_mg # define sv_setpv_mg(sv, ptr) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpv(TeMpSv,ptr); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setpvn_mg # define sv_setpvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setpvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setsv_mg # define sv_setsv_mg(dsv, ssv) \ STMT_START { \ SV *TeMpSv = dsv; \ sv_setsv(TeMpSv,ssv); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_setuv_mg # define sv_setuv_mg(sv, i) \ STMT_START { \ SV *TeMpSv = sv; \ sv_setuv(TeMpSv,i); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef sv_usepvn_mg # define sv_usepvn_mg(sv, ptr, len) \ STMT_START { \ SV *TeMpSv = sv; \ sv_usepvn(TeMpSv,ptr,len); \ SvSETMAGIC(TeMpSv); \ } STMT_END #endif #ifndef SvVSTRING_mg # define SvVSTRING_mg(sv) (SvMAGICAL(sv) ? mg_find(sv, PERL_MAGIC_vstring) : NULL) #endif /* Hint: sv_magic_portable * This is a compatibility function that is only available with * Devel::PPPort. It is NOT in the perl core. * Its purpose is to mimic the 5.8.0 behaviour of sv_magic() when * it is being passed a name pointer with namlen == 0. In that * case, perl 5.8.0 and later store the pointer, not a copy of it. * The compatibility can be provided back to perl 5.004. With * earlier versions, the code will not compile. */ #if (PERL_BCDVERSION < 0x5004000) /* code that uses sv_magic_portable will not compile */ #elif (PERL_BCDVERSION < 0x5008000) # define sv_magic_portable(sv, obj, how, name, namlen) \ STMT_START { \ SV *SvMp_sv = (sv); \ char *SvMp_name = (char *) (name); \ I32 SvMp_namlen = (namlen); \ if (SvMp_name && SvMp_namlen == 0) \ { \ MAGIC *mg; \ sv_magic(SvMp_sv, obj, how, 0, 0); \ mg = SvMAGIC(SvMp_sv); \ mg->mg_len = -42; /* XXX: this is the tricky part */ \ mg->mg_ptr = SvMp_name; \ } \ else \ { \ sv_magic(SvMp_sv, obj, how, SvMp_name, SvMp_namlen); \ } \ } STMT_END #else # define sv_magic_portable(a, b, c, d, e) sv_magic(a, b, c, d, e) #endif #ifdef USE_ITHREADS #ifndef CopFILE # define CopFILE(c) ((c)->cop_file) #endif #ifndef CopFILEGV # define CopFILEGV(c) (CopFILE(c) ? gv_fetchfile(CopFILE(c)) : Nullgv) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) ((c)->cop_file = savepv(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILE(c) ? GvSV(gv_fetchfile(CopFILE(c))) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILE(c) ? GvAV(gv_fetchfile(CopFILE(c))) : Nullav) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) ((c)->cop_stashpv) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) ((c)->cop_stashpv = ((pv) ? savepv(pv) : Nullch)) #endif #ifndef CopSTASH # define CopSTASH(c) (CopSTASHPV(c) ? gv_stashpv(CopSTASHPV(c),GV_ADD) : Nullhv) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) CopSTASHPV_set(c, (hv) ? HvNAME(hv) : Nullch) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) ((hv) && (CopSTASHPV(c) == HvNAME(hv) \ || (CopSTASHPV(c) && HvNAME(hv) \ && strEQ(CopSTASHPV(c), HvNAME(hv))))) #endif #else #ifndef CopFILEGV # define CopFILEGV(c) ((c)->cop_filegv) #endif #ifndef CopFILEGV_set # define CopFILEGV_set(c,gv) ((c)->cop_filegv = (GV*)SvREFCNT_inc(gv)) #endif #ifndef CopFILE_set # define CopFILE_set(c,pv) CopFILEGV_set((c), gv_fetchfile(pv)) #endif #ifndef CopFILESV # define CopFILESV(c) (CopFILEGV(c) ? GvSV(CopFILEGV(c)) : Nullsv) #endif #ifndef CopFILEAV # define CopFILEAV(c) (CopFILEGV(c) ? GvAV(CopFILEGV(c)) : Nullav) #endif #ifndef CopFILE # define CopFILE(c) (CopFILESV(c) ? SvPVX(CopFILESV(c)) : Nullch) #endif #ifndef CopSTASH # define CopSTASH(c) ((c)->cop_stash) #endif #ifndef CopSTASH_set # define CopSTASH_set(c,hv) ((c)->cop_stash = (hv)) #endif #ifndef CopSTASHPV # define CopSTASHPV(c) (CopSTASH(c) ? HvNAME(CopSTASH(c)) : Nullch) #endif #ifndef CopSTASHPV_set # define CopSTASHPV_set(c,pv) CopSTASH_set((c), gv_stashpv(pv,GV_ADD)) #endif #ifndef CopSTASH_eq # define CopSTASH_eq(c,hv) (CopSTASH(c) == (hv)) #endif #endif /* USE_ITHREADS */ #ifndef IN_PERL_COMPILETIME # define IN_PERL_COMPILETIME (PL_curcop == &PL_compiling) #endif #ifndef IN_LOCALE_RUNTIME # define IN_LOCALE_RUNTIME (PL_curcop->op_private & HINT_LOCALE) #endif #ifndef IN_LOCALE_COMPILETIME # define IN_LOCALE_COMPILETIME (PL_hints & HINT_LOCALE) #endif #ifndef IN_LOCALE # define IN_LOCALE (IN_PERL_COMPILETIME ? IN_LOCALE_COMPILETIME : IN_LOCALE_RUNTIME) #endif #ifndef IS_NUMBER_IN_UV # define IS_NUMBER_IN_UV 0x01 #endif #ifndef IS_NUMBER_GREATER_THAN_UV_MAX # define IS_NUMBER_GREATER_THAN_UV_MAX 0x02 #endif #ifndef IS_NUMBER_NOT_INT # define IS_NUMBER_NOT_INT 0x04 #endif #ifndef IS_NUMBER_NEG # define IS_NUMBER_NEG 0x08 #endif #ifndef IS_NUMBER_INFINITY # define IS_NUMBER_INFINITY 0x10 #endif #ifndef IS_NUMBER_NAN # define IS_NUMBER_NAN 0x20 #endif #ifndef GROK_NUMERIC_RADIX # define GROK_NUMERIC_RADIX(sp, send) grok_numeric_radix(sp, send) #endif #ifndef PERL_SCAN_GREATER_THAN_UV_MAX # define PERL_SCAN_GREATER_THAN_UV_MAX 0x02 #endif #ifndef PERL_SCAN_SILENT_ILLDIGIT # define PERL_SCAN_SILENT_ILLDIGIT 0x04 #endif #ifndef PERL_SCAN_ALLOW_UNDERSCORES # define PERL_SCAN_ALLOW_UNDERSCORES 0x01 #endif #ifndef PERL_SCAN_DISALLOW_PREFIX # define PERL_SCAN_DISALLOW_PREFIX 0x02 #endif #ifndef grok_numeric_radix #if defined(NEED_grok_numeric_radix) static bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); static #else extern bool DPPP_(my_grok_numeric_radix)(pTHX_ const char ** sp, const char * send); #endif #ifdef grok_numeric_radix # undef grok_numeric_radix #endif #define grok_numeric_radix(a,b) DPPP_(my_grok_numeric_radix)(aTHX_ a,b) #define Perl_grok_numeric_radix DPPP_(my_grok_numeric_radix) #if defined(NEED_grok_numeric_radix) || defined(NEED_grok_numeric_radix_GLOBAL) bool DPPP_(my_grok_numeric_radix)(pTHX_ const char **sp, const char *send) { #ifdef USE_LOCALE_NUMERIC #ifdef PL_numeric_radix_sv if (PL_numeric_radix_sv && IN_LOCALE) { STRLEN len; char* radix = SvPV(PL_numeric_radix_sv, len); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #else /* older perls don't have PL_numeric_radix_sv so the radix * must manually be requested from locale.h */ #include dTHR; /* needed for older threaded perls */ struct lconv *lc = localeconv(); char *radix = lc->decimal_point; if (radix && IN_LOCALE) { STRLEN len = strlen(radix); if (*sp + len <= send && memEQ(*sp, radix, len)) { *sp += len; return TRUE; } } #endif #endif /* USE_LOCALE_NUMERIC */ /* always try "." if numeric radix didn't match because * we may have data from different locales mixed */ if (*sp < send && **sp == '.') { ++*sp; return TRUE; } return FALSE; } #endif #endif #ifndef grok_number #if defined(NEED_grok_number) static int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); static #else extern int DPPP_(my_grok_number)(pTHX_ const char * pv, STRLEN len, UV * valuep); #endif #ifdef grok_number # undef grok_number #endif #define grok_number(a,b,c) DPPP_(my_grok_number)(aTHX_ a,b,c) #define Perl_grok_number DPPP_(my_grok_number) #if defined(NEED_grok_number) || defined(NEED_grok_number_GLOBAL) int DPPP_(my_grok_number)(pTHX_ const char *pv, STRLEN len, UV *valuep) { const char *s = pv; const char *send = pv + len; const UV max_div_10 = UV_MAX / 10; const char max_mod_10 = UV_MAX % 10; int numtype = 0; int sawinf = 0; int sawnan = 0; while (s < send && isSPACE(*s)) s++; if (s == send) { return 0; } else if (*s == '-') { s++; numtype = IS_NUMBER_NEG; } else if (*s == '+') s++; if (s == send) return 0; /* next must be digit or the radix separator or beginning of infinity */ if (isDIGIT(*s)) { /* UVs are at least 32 bits, so the first 9 decimal digits cannot overflow. */ UV value = *s - '0'; /* This construction seems to be more optimiser friendly. (without it gcc does the isDIGIT test and the *s - '0' separately) With it gcc on arm is managing 6 instructions (6 cycles) per digit. In theory the optimiser could deduce how far to unroll the loop before checking for overflow. */ if (++s < send) { int digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { digit = *s - '0'; if (digit >= 0 && digit <= 9) { value = value * 10 + digit; if (++s < send) { /* Now got 9 digits, so need to check each time for overflow. */ digit = *s - '0'; while (digit >= 0 && digit <= 9 && (value < max_div_10 || (value == max_div_10 && digit <= max_mod_10))) { value = value * 10 + digit; if (++s < send) digit = *s - '0'; else break; } if (digit >= 0 && digit <= 9 && (s < send)) { /* value overflowed. skip the remaining digits, don't worry about setting *valuep. */ do { s++; } while (s < send && isDIGIT(*s)); numtype |= IS_NUMBER_GREATER_THAN_UV_MAX; goto skip_value; } } } } } } } } } } } } } } } } } } numtype |= IS_NUMBER_IN_UV; if (valuep) *valuep = value; skip_value: if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT; while (s < send && isDIGIT(*s)) /* optional digits after the radix */ s++; } } else if (GROK_NUMERIC_RADIX(&s, send)) { numtype |= IS_NUMBER_NOT_INT | IS_NUMBER_IN_UV; /* valuep assigned below */ /* no digits before the radix means we need digits after it */ if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); if (valuep) { /* integer approximation is valid - it's 0. */ *valuep = 0; } } else return 0; } else if (*s == 'I' || *s == 'i') { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'F' && *s != 'f')) return 0; s++; if (s < send && (*s == 'I' || *s == 'i')) { s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; if (s == send || (*s != 'I' && *s != 'i')) return 0; s++; if (s == send || (*s != 'T' && *s != 't')) return 0; s++; if (s == send || (*s != 'Y' && *s != 'y')) return 0; s++; } sawinf = 1; } else if (*s == 'N' || *s == 'n') { /* XXX TODO: There are signaling NaNs and quiet NaNs. */ s++; if (s == send || (*s != 'A' && *s != 'a')) return 0; s++; if (s == send || (*s != 'N' && *s != 'n')) return 0; s++; sawnan = 1; } else return 0; if (sawinf) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_INFINITY | IS_NUMBER_NOT_INT; } else if (sawnan) { numtype &= IS_NUMBER_NEG; /* Keep track of sign */ numtype |= IS_NUMBER_NAN | IS_NUMBER_NOT_INT; } else if (s < send) { /* we can have an optional exponent part */ if (*s == 'e' || *s == 'E') { /* The only flag we keep is sign. Blow away any "it's UV" */ numtype &= IS_NUMBER_NEG; numtype |= IS_NUMBER_NOT_INT; s++; if (s < send && (*s == '-' || *s == '+')) s++; if (s < send && isDIGIT(*s)) { do { s++; } while (s < send && isDIGIT(*s)); } else return 0; } } while (s < send && isSPACE(*s)) s++; if (s >= send) return numtype; if (len == 10 && memEQ(pv, "0 but true", 10)) { if (valuep) *valuep = 0; return IS_NUMBER_IN_UV; } return 0; } #endif #endif /* * The grok_* routines have been modified to use warn() instead of * Perl_warner(). Also, 'hexdigit' was the former name of PL_hexdigit, * which is why the stack variable has been renamed to 'xdigit'. */ #ifndef grok_bin #if defined(NEED_grok_bin) static UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_bin)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_bin # undef grok_bin #endif #define grok_bin(a,b,c,d) DPPP_(my_grok_bin)(aTHX_ a,b,c,d) #define Perl_grok_bin DPPP_(my_grok_bin) #if defined(NEED_grok_bin) || defined(NEED_grok_bin_GLOBAL) UV DPPP_(my_grok_bin)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_2 = UV_MAX / 2; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading b or 0b. for compatibility silently suffer "b" and "0b" as valid binary numbers. */ if (len >= 1) { if (s[0] == 'b') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'b') { s+=2; len-=2; } } } for (; len-- && *s; s++) { char bit = *s; if (bit == '0' || bit == '1') { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_bin. */ redo: if (!overflowed) { if (value <= max_div_2) { value = (value << 1) | (bit - '0'); continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in binary number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 2.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount. */ value_nv += (NV)(bit - '0'); continue; } if (bit == '_' && len && allow_underscores && (bit = s[1]) && (bit == '0' || bit == '1')) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal binary digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Binary number > 0b11111111111111111111111111111111 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_hex #if defined(NEED_grok_hex) static UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_hex)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_hex # undef grok_hex #endif #define grok_hex(a,b,c,d) DPPP_(my_grok_hex)(aTHX_ a,b,c,d) #define Perl_grok_hex DPPP_(my_grok_hex) #if defined(NEED_grok_hex) || defined(NEED_grok_hex_GLOBAL) UV DPPP_(my_grok_hex)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_16 = UV_MAX / 16; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; const char *xdigit; if (!(*flags & PERL_SCAN_DISALLOW_PREFIX)) { /* strip off leading x or 0x. for compatibility silently suffer "x" and "0x" as valid hex numbers. */ if (len >= 1) { if (s[0] == 'x') { s++; len--; } else if (len >= 2 && s[0] == '0' && s[1] == 'x') { s+=2; len-=2; } } } for (; len-- && *s; s++) { xdigit = strchr((char *) PL_hexdigit, *s); if (xdigit) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. With gcc seems to be much straighter code than old scan_hex. */ redo: if (!overflowed) { if (value <= max_div_16) { value = (value << 4) | ((xdigit - PL_hexdigit) & 15); continue; } warn("Integer overflow in hexadecimal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 16.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 16-tuples. */ value_nv += (NV)((xdigit - PL_hexdigit) & 15); continue; } if (*s == '_' && len && allow_underscores && s[1] && (xdigit = strchr((char *) PL_hexdigit, s[1]))) { --len; ++s; goto redo; } if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal hexadecimal digit '%c' ignored", *s); break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Hexadecimal number > 0xffffffff non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #ifndef grok_oct #if defined(NEED_grok_oct) static UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); static #else extern UV DPPP_(my_grok_oct)(pTHX_ const char * start, STRLEN * len_p, I32 * flags, NV * result); #endif #ifdef grok_oct # undef grok_oct #endif #define grok_oct(a,b,c,d) DPPP_(my_grok_oct)(aTHX_ a,b,c,d) #define Perl_grok_oct DPPP_(my_grok_oct) #if defined(NEED_grok_oct) || defined(NEED_grok_oct_GLOBAL) UV DPPP_(my_grok_oct)(pTHX_ const char *start, STRLEN *len_p, I32 *flags, NV *result) { const char *s = start; STRLEN len = *len_p; UV value = 0; NV value_nv = 0; const UV max_div_8 = UV_MAX / 8; bool allow_underscores = *flags & PERL_SCAN_ALLOW_UNDERSCORES; bool overflowed = FALSE; for (; len-- && *s; s++) { /* gcc 2.95 optimiser not smart enough to figure that this subtraction out front allows slicker code. */ int digit = *s - '0'; if (digit >= 0 && digit <= 7) { /* Write it in this wonky order with a goto to attempt to get the compiler to make the common case integer-only loop pretty tight. */ redo: if (!overflowed) { if (value <= max_div_8) { value = (value << 3) | digit; continue; } /* Bah. We're just overflowed. */ warn("Integer overflow in octal number"); overflowed = TRUE; value_nv = (NV) value; } value_nv *= 8.0; /* If an NV has not enough bits in its mantissa to * represent a UV this summing of small low-order numbers * is a waste of time (because the NV cannot preserve * the low-order bits anyway): we could just remember when * did we overflow and in the end just multiply value_nv by the * right amount of 8-tuples. */ value_nv += (NV)digit; continue; } if (digit == ('_' - '0') && len && allow_underscores && (digit = s[1] - '0') && (digit >= 0 && digit <= 7)) { --len; ++s; goto redo; } /* Allow \octal to work the DWIM way (that is, stop scanning * as soon as non-octal characters are seen, complain only iff * someone seems to want to use the digits eight and nine). */ if (digit == 8 || digit == 9) { if (!(*flags & PERL_SCAN_SILENT_ILLDIGIT)) warn("Illegal octal digit '%c' ignored", *s); } break; } if ( ( overflowed && value_nv > 4294967295.0) #if UVSIZE > 4 || (!overflowed && value > 0xffffffff ) #endif ) { warn("Octal number > 037777777777 non-portable"); } *len_p = s - start; if (!overflowed) { *flags = 0; return value; } *flags = PERL_SCAN_GREATER_THAN_UV_MAX; if (result) *result = value_nv; return UV_MAX; } #endif #endif #if !defined(my_snprintf) #if defined(NEED_my_snprintf) static int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); static #else extern int DPPP_(my_my_snprintf)(char * buffer, const Size_t len, const char * format, ...); #endif #define my_snprintf DPPP_(my_my_snprintf) #define Perl_my_snprintf DPPP_(my_my_snprintf) #if defined(NEED_my_snprintf) || defined(NEED_my_snprintf_GLOBAL) int DPPP_(my_my_snprintf)(char *buffer, const Size_t len, const char *format, ...) { dTHX; int retval; va_list ap; va_start(ap, format); #ifdef HAS_VSNPRINTF retval = vsnprintf(buffer, len, format, ap); #else retval = vsprintf(buffer, format, ap); #endif va_end(ap); if (retval < 0 || (len > 0 && (Size_t)retval >= len)) Perl_croak(aTHX_ "panic: my_snprintf buffer overflow"); return retval; } #endif #endif #if !defined(my_sprintf) #if defined(NEED_my_sprintf) static int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); static #else extern int DPPP_(my_my_sprintf)(char * buffer, const char * pat, ...); #endif #define my_sprintf DPPP_(my_my_sprintf) #define Perl_my_sprintf DPPP_(my_my_sprintf) #if defined(NEED_my_sprintf) || defined(NEED_my_sprintf_GLOBAL) int DPPP_(my_my_sprintf)(char *buffer, const char* pat, ...) { va_list args; va_start(args, pat); vsprintf(buffer, pat, args); va_end(args); return strlen(buffer); } #endif #endif #ifdef NO_XSLOCKS # ifdef dJMPENV # define dXCPT dJMPENV; int rEtV = 0 # define XCPT_TRY_START JMPENV_PUSH(rEtV); if (rEtV == 0) # define XCPT_TRY_END JMPENV_POP; # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW JMPENV_JUMP(rEtV) # else # define dXCPT Sigjmp_buf oldTOP; int rEtV = 0 # define XCPT_TRY_START Copy(top_env, oldTOP, 1, Sigjmp_buf); rEtV = Sigsetjmp(top_env, 1); if (rEtV == 0) # define XCPT_TRY_END Copy(oldTOP, top_env, 1, Sigjmp_buf); # define XCPT_CATCH if (rEtV != 0) # define XCPT_RETHROW Siglongjmp(top_env, rEtV) # endif #endif #if !defined(my_strlcat) #if defined(NEED_my_strlcat) static Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcat)(char * dst, const char * src, Size_t size); #endif #define my_strlcat DPPP_(my_my_strlcat) #define Perl_my_strlcat DPPP_(my_my_strlcat) #if defined(NEED_my_strlcat) || defined(NEED_my_strlcat_GLOBAL) Size_t DPPP_(my_my_strlcat)(char *dst, const char *src, Size_t size) { Size_t used, length, copy; used = strlen(dst); length = strlen(src); if (size > 0 && used < size - 1) { copy = (length >= size - used) ? size - used - 1 : length; memcpy(dst + used, src, copy); dst[used + copy] = '\0'; } return used + length; } #endif #endif #if !defined(my_strlcpy) #if defined(NEED_my_strlcpy) static Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); static #else extern Size_t DPPP_(my_my_strlcpy)(char * dst, const char * src, Size_t size); #endif #define my_strlcpy DPPP_(my_my_strlcpy) #define Perl_my_strlcpy DPPP_(my_my_strlcpy) #if defined(NEED_my_strlcpy) || defined(NEED_my_strlcpy_GLOBAL) Size_t DPPP_(my_my_strlcpy)(char *dst, const char *src, Size_t size) { Size_t length, copy; length = strlen(src); if (size > 0) { copy = (length >= size) ? size - 1 : length; memcpy(dst, src, copy); dst[copy] = '\0'; } return length; } #endif #endif #ifndef PERL_PV_ESCAPE_QUOTE # define PERL_PV_ESCAPE_QUOTE 0x0001 #endif #ifndef PERL_PV_PRETTY_QUOTE # define PERL_PV_PRETTY_QUOTE PERL_PV_ESCAPE_QUOTE #endif #ifndef PERL_PV_PRETTY_ELLIPSES # define PERL_PV_PRETTY_ELLIPSES 0x0002 #endif #ifndef PERL_PV_PRETTY_LTGT # define PERL_PV_PRETTY_LTGT 0x0004 #endif #ifndef PERL_PV_ESCAPE_FIRSTCHAR # define PERL_PV_ESCAPE_FIRSTCHAR 0x0008 #endif #ifndef PERL_PV_ESCAPE_UNI # define PERL_PV_ESCAPE_UNI 0x0100 #endif #ifndef PERL_PV_ESCAPE_UNI_DETECT # define PERL_PV_ESCAPE_UNI_DETECT 0x0200 #endif #ifndef PERL_PV_ESCAPE_ALL # define PERL_PV_ESCAPE_ALL 0x1000 #endif #ifndef PERL_PV_ESCAPE_NOBACKSLASH # define PERL_PV_ESCAPE_NOBACKSLASH 0x2000 #endif #ifndef PERL_PV_ESCAPE_NOCLEAR # define PERL_PV_ESCAPE_NOCLEAR 0x4000 #endif #ifndef PERL_PV_ESCAPE_RE # define PERL_PV_ESCAPE_RE 0x8000 #endif #ifndef PERL_PV_PRETTY_NOCLEAR # define PERL_PV_PRETTY_NOCLEAR PERL_PV_ESCAPE_NOCLEAR #endif #ifndef PERL_PV_PRETTY_DUMP # define PERL_PV_PRETTY_DUMP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_QUOTE #endif #ifndef PERL_PV_PRETTY_REGPROP # define PERL_PV_PRETTY_REGPROP PERL_PV_PRETTY_ELLIPSES|PERL_PV_PRETTY_LTGT|PERL_PV_ESCAPE_RE #endif /* Hint: pv_escape * Note that unicode functionality is only backported to * those perl versions that support it. For older perl * versions, the implementation will fall back to bytes. */ #ifndef pv_escape #if defined(NEED_pv_escape) static char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); static #else extern char * DPPP_(my_pv_escape)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags); #endif #ifdef pv_escape # undef pv_escape #endif #define pv_escape(a,b,c,d,e,f) DPPP_(my_pv_escape)(aTHX_ a,b,c,d,e,f) #define Perl_pv_escape DPPP_(my_pv_escape) #if defined(NEED_pv_escape) || defined(NEED_pv_escape_GLOBAL) char * DPPP_(my_pv_escape)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, STRLEN * const escaped, const U32 flags) { const char esc = flags & PERL_PV_ESCAPE_RE ? '%' : '\\'; const char dq = flags & PERL_PV_ESCAPE_QUOTE ? '"' : esc; char octbuf[32] = "%123456789ABCDF"; STRLEN wrote = 0; STRLEN chsize = 0; STRLEN readsize = 1; #if defined(is_utf8_string) && defined(utf8_to_uvchr) bool isuni = flags & PERL_PV_ESCAPE_UNI ? 1 : 0; #endif const char *pv = str; const char * const end = pv + count; octbuf[0] = esc; if (!(flags & PERL_PV_ESCAPE_NOCLEAR)) sv_setpvs(dsv, ""); #if defined(is_utf8_string) && defined(utf8_to_uvchr) if ((flags & PERL_PV_ESCAPE_UNI_DETECT) && is_utf8_string((U8*)pv, count)) isuni = 1; #endif for (; pv < end && (!max || wrote < max) ; pv += readsize) { const UV u = #if defined(is_utf8_string) && defined(utf8_to_uvchr) isuni ? utf8_to_uvchr((U8*)pv, &readsize) : #endif (U8)*pv; const U8 c = (U8)u & 0xFF; if (u > 255 || (flags & PERL_PV_ESCAPE_ALL)) { if (flags & PERL_PV_ESCAPE_FIRSTCHAR) chsize = my_snprintf(octbuf, sizeof octbuf, "%"UVxf, u); else chsize = my_snprintf(octbuf, sizeof octbuf, "%cx{%"UVxf"}", esc, u); } else if (flags & PERL_PV_ESCAPE_NOBACKSLASH) { chsize = 1; } else { if (c == dq || c == esc || !isPRINT(c)) { chsize = 2; switch (c) { case '\\' : /* fallthrough */ case '%' : if (c == esc) octbuf[1] = esc; else chsize = 1; break; case '\v' : octbuf[1] = 'v'; break; case '\t' : octbuf[1] = 't'; break; case '\r' : octbuf[1] = 'r'; break; case '\n' : octbuf[1] = 'n'; break; case '\f' : octbuf[1] = 'f'; break; case '"' : if (dq == '"') octbuf[1] = '"'; else chsize = 1; break; default: chsize = my_snprintf(octbuf, sizeof octbuf, pv < end && isDIGIT((U8)*(pv+readsize)) ? "%c%03o" : "%c%o", esc, c); } } else { chsize = 1; } } if (max && wrote + chsize > max) { break; } else if (chsize > 1) { sv_catpvn(dsv, octbuf, chsize); wrote += chsize; } else { char tmp[2]; my_snprintf(tmp, sizeof tmp, "%c", c); sv_catpvn(dsv, tmp, 1); wrote++; } if (flags & PERL_PV_ESCAPE_FIRSTCHAR) break; } if (escaped != NULL) *escaped= pv - str; return SvPVX(dsv); } #endif #endif #ifndef pv_pretty #if defined(NEED_pv_pretty) static char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); static #else extern char * DPPP_(my_pv_pretty)(pTHX_ SV * dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags); #endif #ifdef pv_pretty # undef pv_pretty #endif #define pv_pretty(a,b,c,d,e,f,g) DPPP_(my_pv_pretty)(aTHX_ a,b,c,d,e,f,g) #define Perl_pv_pretty DPPP_(my_pv_pretty) #if defined(NEED_pv_pretty) || defined(NEED_pv_pretty_GLOBAL) char * DPPP_(my_pv_pretty)(pTHX_ SV *dsv, char const * const str, const STRLEN count, const STRLEN max, char const * const start_color, char const * const end_color, const U32 flags) { const U8 dq = (flags & PERL_PV_PRETTY_QUOTE) ? '"' : '%'; STRLEN escaped; if (!(flags & PERL_PV_PRETTY_NOCLEAR)) sv_setpvs(dsv, ""); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, "<"); if (start_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(start_color)); pv_escape(dsv, str, count, max, &escaped, flags | PERL_PV_ESCAPE_NOCLEAR); if (end_color != NULL) sv_catpv(dsv, D_PPP_CONSTPV_ARG(end_color)); if (dq == '"') sv_catpvs(dsv, "\""); else if (flags & PERL_PV_PRETTY_LTGT) sv_catpvs(dsv, ">"); if ((flags & PERL_PV_PRETTY_ELLIPSES) && escaped < count) sv_catpvs(dsv, "..."); return SvPVX(dsv); } #endif #endif #ifndef pv_display #if defined(NEED_pv_display) static char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); static #else extern char * DPPP_(my_pv_display)(pTHX_ SV * dsv, const char * pv, STRLEN cur, STRLEN len, STRLEN pvlim); #endif #ifdef pv_display # undef pv_display #endif #define pv_display(a,b,c,d,e) DPPP_(my_pv_display)(aTHX_ a,b,c,d,e) #define Perl_pv_display DPPP_(my_pv_display) #if defined(NEED_pv_display) || defined(NEED_pv_display_GLOBAL) char * DPPP_(my_pv_display)(pTHX_ SV *dsv, const char *pv, STRLEN cur, STRLEN len, STRLEN pvlim) { pv_pretty(dsv, pv, cur, pvlim, NULL, NULL, PERL_PV_PRETTY_DUMP); if (len > cur && pv[cur] == '\0') sv_catpvs(dsv, "\\0"); return SvPVX(dsv); } #endif #endif #endif /* _P_P_PORTABILITY_H_ */ /* End of File ppport.h */ di-4.47/C/digetentries.c0000644000175000017500000017674613334050206013205 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ /********************************************************/ /* di_getDiskEntries () Get a list of mounted filesystems. In many cases, this also does the work of di_getDiskInfo (). */ /********************************************************/ #include "config.h" #include "di.h" #include "dimntopt.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_dirent # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _sys_param # include #endif #if _sys_ftype /* QNX */ # include #endif #if _sys_dcmd_blk /* QNX */ # include #endif #if _sys_io /* QNX */ # include #endif #if _hdr_errno # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _hdr_memory # include #endif #if _hdr_malloc # include #endif #if _hdr_mntent \ && ! defined (DI_INC_MNTENT) /* Linux, kFreeBSD, HP-UX */ # define DI_INC_MNTENT 1 # include /* hasmntopt(); _PATH_MNTTAB */ #endif /* HP-UX: set/get/endmntent(); hasmntopt() */ #if _sys_mount \ && ! defined (DI_INC_SYS_MOUNT) /* FreeBSD, OpenBSD, NetBSD, HP-UX */ # define DI_INC_SYS_MOUNT 1 # include /* getmntinfo(); struct statfs */ #endif #if _sys_fstypes /* NetBSD */ # include #endif #if _sys_fs_types /* OSF/1, AROS */ # include #endif #if _sys_mnttab /* Solaris, SCO_SV, UnixWare */ # include /* getmntent(); MNTTAB */ #endif #if _sys_statfs && ! _sys_statvfs /* Linux, FreeBSD, SysV.3 */ # include /* struct statfs; statfs() */ #endif #if _sys_statvfs /* NetBSD, Solaris */ # include /* struct statvfs; statvfs() */ #endif #if _sys_vfs /* BSD 4.3 */ # include /* struct statfs */ #endif #if _sys_mntctl /* AIX */ # include #endif #if _sys_vmount /* AIX */ # include #endif #if _hdr_fshelp /* AIX */ # include #endif #if _hdr_windows /* windows */ # include #endif #if _hdr_winioctl /* windows */ # include #endif #if _hdr_kernel_fs_info /* BeOS */ # include #endif #if _hdr_storage_Directory /* BeOS */ # include #endif #if _hdr_storage_Entry /* BeOS */ # include #endif #if _hdr_storage_Path /* BeOS */ # include #endif /* bozo syllable volumes header requires gui/window */ #if _hdr_gui_window /* Syllable */ # include /* gack! */ #endif #if _hdr_storage_volumes /* Syllable */ # include /* class os::Volumes */ #endif #if _hdr_util_string /* Syllable */ # include /* os::String - to get mount name */ #endif #if _hdr_starlet /* VMS */ # include #endif #if _hdr_descrip /* VMS */ # include #endif #if _hdr_dcdef /* VMS */ # include #endif #if _hdr_dvsdef /* VMS */ # include #endif #if _hdr_ssdef /* VMS */ # include #endif #if _hdr_dvidef /* VMS */ # include #endif /********************************************************/ #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif /* workaround for AIX - mntctl not declared */ # if _lib_mntctl && _npt_mntctl extern int mntctl _((int, Size_t, char *)); # endif #if (_lib_getmntent \ || _args_statfs > 0) \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_mntctl \ && ! _lib_getmnt \ && ! _class_os__Volumes # if defined (_PATH_MOUNTED) # define DI_MOUNT_FILE _PATH_MOUNTED # else # if defined (_PATH_MNTTAB) # define DI_MOUNT_FILE _PATH_MNTTAB # else # if defined (MOUNTED) # define DI_MOUNT_FILE MOUNTED # else # if defined (MNTTAB) # define DI_MOUNT_FILE MNTTAB # else # if (USE_ETC_FILESYSTEMS) # define DI_MOUNT_FILE "/etc/filesystems" /* AIX 4.x or /etc/mntent? */ # else # define DI_MOUNT_FILE "/etc/mnttab" /* SysV.3 default */ # endif # endif # endif # endif # endif #endif #if defined (__QNX__) static int di_getQNXDiskEntries _((char *ipath, diDiskInfo_t **diskInfo, int *diCount)); #endif extern int debug; #if defined (__cplusplus) || defined (c_plusplus) } #endif /********************************************************/ #if _lib_getmntent \ && ! _lib_setmntent \ && ! _lib_mntctl \ && ! _class_os__Volumes #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif static char *checkMountOptions _((struct mnttab *, char *)); #if defined (__cplusplus) || defined (c_plusplus) } #endif /* * di_getDiskEntries * * For SysV.4, we open the file and call getmntent () repeatedly. * */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; FILE *f; int idx; struct mnttab mntEntry; char *devp; /* local ptr to dev entry */ if (debug > 0) { printf ("# di_getDiskEntries: getmntent\n"); } if ((f = fopen (DI_MOUNT_FILE, "r")) == (FILE *) NULL) { fprintf (stderr, "Unable to open: %s errno %d\n", DI_MOUNT_FILE, errno); return -1; } while (getmntent (f, &mntEntry) == 0) { idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); strncpy (diptr->special, mntEntry.mnt_special, DI_SPEC_NAME_LEN); strncpy (diptr->name, mntEntry.mnt_mountp, DI_NAME_LEN); if (checkMountOptions (&mntEntry, DI_MNTOPT_IGNORE) != (char *) NULL) { diptr->printFlag = DI_PRNT_IGNORE; if (debug > 2) { printf ("mnt: ignore: mntopt 'ignore': %s\n", diptr->name); } } if ((devp = checkMountOptions (&mntEntry, DI_MNTOPT_DEV)) != (char *) NULL) { if (devp != mntEntry.mnt_mntopts) { --devp; } *devp = 0; /* point to preceeding comma and cut off */ } if (checkMountOptions (&mntEntry, DI_MNTOPT_RO) != (char *) NULL) { diptr->isReadOnly = TRUE; } strncpy (diptr->options, mntEntry.mnt_mntopts, DI_OPT_LEN); /* get the file system type now... */ strncpy (diptr->fsType, mntEntry.mnt_fstype, DI_TYPE_LEN); if (debug > 2) { printf ("mnt:%s - %s\n", diptr->name, diptr->fsType); } if (debug > 1) { printf ("mnt:%s - %s\n", diptr->name, diptr->special); } } fclose (f); return 0; } static char * # if _proto_stdc checkMountOptions (struct mnttab *mntEntry, char *str) # else checkMountOptions (mntEntry, str) struct mnttab *mntEntry; char *str; # endif { # if _lib_hasmntopt return hasmntopt (mntEntry, str); # else return chkMountOptions (mntEntry->mnt_mntopts, str); # endif } #endif #if _lib_getmntent \ && _lib_setmntent \ && _lib_endmntent \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_mntctl \ && ! _lib_GetDriveType \ && ! _lib_GetLogicalDriveStrings \ && ! _class_os__Volumes /* * di_getDiskEntries * * SunOS supplies an open and close routine for the mount table. * */ #if ! defined (MNTTYPE_IGNORE) # define MNTTYPE_IGNORE "ignore" #endif int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; FILE *f; int idx; struct mntent *mntEntry; char *devp; /* local ptr to dev entry */ if (debug > 0) { printf ("# getDiskEntries: set/get/endmntent\n"); } /* if both are set not an ansi compiler... */ #if _args_setmntent == 1 if ((f = setmntent (DI_MOUNT_FILE)) == (FILE *) NULL) #else if ((f = setmntent (DI_MOUNT_FILE, "r")) == (FILE *) NULL) #endif { fprintf (stderr, "Unable to open: %s errno %d\n", DI_MOUNT_FILE, errno); return -1; } while ((mntEntry = getmntent (f)) != (struct mntent *) NULL) { idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); strncpy (diptr->special, mntEntry->mnt_fsname, (Size_t) DI_SPEC_NAME_LEN); strncpy (diptr->name, mntEntry->mnt_dir, (Size_t) DI_NAME_LEN); strncpy (diptr->fsType, mntEntry->mnt_type, (Size_t) DI_TYPE_LEN); if (strcmp (mntEntry->mnt_fsname, "none") == 0) { diptr->printFlag = DI_PRNT_IGNORE; if (debug > 2) { printf ("mnt: ignore: special 'none': %s\n", diptr->name); } } if (strcmp (mntEntry->mnt_type, MNTTYPE_IGNORE) == 0) { diptr->printFlag = DI_PRNT_IGNORE; if (debug > 2) { printf ("mnt: ignore: mntopt 'ignore': %s\n", diptr->name); } } if ((devp = strstr (mntEntry->mnt_opts, "dev=")) != (char *) NULL) { if (devp != mntEntry->mnt_opts) { --devp; } *devp = 0; /* point to preceeding comma and cut off */ } if (chkMountOptions (mntEntry->mnt_opts, DI_MNTOPT_RO) != (char *) NULL) { diptr->isReadOnly = TRUE; } strncpy (diptr->options, mntEntry->mnt_opts, (Size_t) DI_OPT_LEN); if (debug > 1) { printf ("mnt:%s - %s : %s\n", diptr->name, diptr->special, diptr->fsType); } } endmntent (f); return 0; } #endif /* _lib_getmntent && _lib_setmntent && _lib_endmntent */ /* QNX */ #if ! _lib_getmntent \ && ! _lib_mntctl \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_getmnt \ && ! _lib_GetDriveType \ && ! _lib_GetLogicalDriveStrings \ && ! _lib_fs_stat_dev \ && ! _class_os__Volumes \ && ! _lib_sys_dollar_device_scan \ && defined (__QNX__) /* * di_getDiskEntries * * QNX * * This is bloody slow. * It would be nice to have a way to short-circuit some of * the directory subtrees. * /proc/mount/dev is not processed...hopefully that won't affect much. * */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { if (debug > 0) { printf ("# getDiskEntries: QNX\n"); } return di_getQNXDiskEntries ("/proc/mount", diskInfo, diCount); } static int # if _proto_stdc di_getQNXDiskEntries (char *ipath, diDiskInfo_t **diskInfo, int *diCount) # else di_getQNXDiskEntries (ipath, diskInfo, diCount) char *ipath; diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int idx; char path [MAXPATHLEN + 1]; int len; /* current length of path */ DIR *dirp; struct dirent *dent; int ret; int nodeid; int pid; int chid; int handle; int ftype; struct stat statinfo; int fd; char tspecial [DI_SPEC_NAME_LEN]; if (strcmp (ipath, "/proc/mount/dev") == 0) { return 0; } strncpy (path, ipath, MAXPATHLEN); len = strlen (path); if (!(dirp = opendir(path))) { return 0; } while ((dent = readdir(dirp))) { if (strcmp (dent->d_name, ".") == 0 || strcmp (dent->d_name, "..") == 0) { continue; } path[len] = '\0'; ret = sscanf(dent->d_name, "%d,%d,%d,%d,%d", &nodeid, &pid, &chid, &handle, &ftype); if (len + strlen(dent->d_name) + 1 > MAXPATHLEN) { continue; } path[len] = '/'; strncpy (&path[len+1], dent->d_name, MAXPATHLEN - len - 1); if (debug > 4) { printf ("check: %s\n", path); } memset(&statinfo, 0, sizeof(statinfo)); if (stat(path, &statinfo) == -1) { continue; } if (ret != 5) { if (S_ISDIR (statinfo.st_mode)) { if (debug > 4) { printf ("into: %s\n", path); } di_getQNXDiskEntries (path, diskInfo, diCount); } continue; } if (ftype != _FTYPE_ANY) { continue; } *tspecial = '\0'; if (S_ISDIR(statinfo.st_mode) && ftype == _FTYPE_ANY) { if ((fd = open (path, /* O_ACCMODE */ O_RDONLY | O_NOCTTY)) != -1) { devctl (fd, DCMD_FSYS_MOUNTED_ON, tspecial, DI_SPEC_NAME_LEN, 0); close (fd); if (*tspecial == '\0') { /* unfortunately, this cuts out /proc, /dev/sem, etc. */ /* but it also removes strange duplicate stuff */ continue; } } else { continue; } } else { continue; } idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); path[len] = '\0'; strncpy (diptr->special, tspecial, DI_SPEC_NAME_LEN); strncpy (diptr->name, path + 11, DI_NAME_LEN); if (*diptr->name == '\0') { strncpy (diptr->name, "/", DI_NAME_LEN); } if (debug > 4) { printf ("found: %s %s\n", diptr->special, diptr->name); } } closedir (dirp); return 0; } #endif /* QNX */ /* if nothing matches, assume a SysV.3 /etc/mnttab or similar */ #if ! _lib_getmntent \ && ! _lib_mntctl \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_getmnt \ && ! _lib_GetDriveType \ && ! _lib_GetLogicalDriveStrings \ && ! _lib_fs_stat_dev \ && ! _class_os__Volumes \ && ! _lib_sys_dollar_device_scan \ && ! defined (__QNX__) /* * di_getDiskEntries * * For SysV.3 we open the file and read it ourselves. * */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; FILE *f; int idx; struct mnttab mntEntry; if (debug > 0) { printf ("# getDiskEntries: not anything; sys v.3\n"); } if ((f = fopen (DI_MOUNT_FILE, "r")) == (FILE *) NULL) { fprintf (stderr, "Unable to open: %s errno %d\n", DI_MOUNT_FILE, errno); return -1; } while (fread ((char *) &mntEntry, sizeof (struct mnttab), 1, f) == 1) { /* xenix allows null mount table entries */ /* sco nfs background mounts are marked as "nothing" */ if (mntEntry.mt_filsys [0] && strcmp (mntEntry.mt_filsys, "nothing") != 0) { idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); # if defined (COHERENT) /* Coherent seems to have these fields reversed. oh well. */ strncpy (diptr->name, mntEntry.mt_dev, DI_NAME_LEN); strncpy (diptr->special, mntEntry.mt_filsys, DI_SPEC_NAME_LEN); # else strncpy (diptr->special, mntEntry.mt_dev, DI_SPEC_NAME_LEN); strncpy (diptr->name, mntEntry.mt_filsys, DI_NAME_LEN); # endif # if _mem_struct_mnttab_mntopts strncpy (diptr->options, mntEntry.mt_mntopts, DI_OPT_LEN); # endif } if (debug > 1) { printf ("mnt:%s - %s\n", diptr->name, diptr->special); } } fclose (f); return 0; } #endif /* Sys V.3 */ /* * All of the following routines also replace di_getDiskInfo() */ #if _lib_getfsstat \ && ! (_lib_getvfsstat && _args_getvfsstat == 3) /* * di_getDiskEntries * * OSF/1 / Digital Unix / Compaq Tru64 / FreeBSD / NetBSD 2.x / OpenBSD * */ # if _dcl_mnt_names # if ! defined (MNT_NUMTYPES) # define MNT_NUMTYPES (sizeof(mnt_names)/sizeof(char *)) # endif # endif int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int count; int idx; # if _dcl_mnt_names && _mem_struct_statfs_f_type short fstype; # endif _c_arg_2_getfsstat bufsize; struct statfs *mntbufp; struct statfs *sp; if (debug > 0) { printf ("# getDiskEntries: getfsstat\n"); } count = getfsstat ((struct statfs *) NULL, (_c_arg_2_getfsstat) 0, MNT_NOWAIT); if (count < 1) { fprintf (stderr, "Unable to do getfsstat () errno %d\n", errno); return -1; } bufsize = (_c_arg_2_getfsstat) (sizeof (struct statfs) * (Size_t) count); mntbufp = malloc ((Size_t) bufsize); if (mntbufp == (struct statfs *) NULL) { fprintf (stderr, "malloc failed for mntbufp. errno %d\n", errno); return -1; } memset ((char *) mntbufp, '\0', sizeof (struct statfs) * (Size_t) count); count = getfsstat (mntbufp, bufsize, MNT_NOWAIT); *diCount = count; *diskInfo = (diDiskInfo_t *) malloc (sizeof (diDiskInfo_t) * (Size_t) count); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } memset ((char *) *diskInfo, '\0', sizeof (diDiskInfo_t) * (Size_t) count); for (idx = 0; idx < count; idx++) { _fs_size_t tblocksz; diptr = *diskInfo + idx; di_initDiskInfo (diptr); sp = mntbufp + idx; # if defined (MNT_RDONLY) if ((sp->f_flags & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } # endif # if defined (MNT_LOCAL) if ((sp->f_flags & MNT_LOCAL) != MNT_LOCAL) { diptr->isLocal = FALSE; } # endif convertMountOptions ((unsigned long) sp->f_flags, diptr); # if _mem_struct_statfs_f_type # if defined (MOUNT_NFS3) if (sp->f_type == MOUNT_NFS3) { strncat (diptr->options, "v3,", DI_OPT_LEN - strlen (diptr->options) - 1); } # endif # endif # if _mem_struct_statfs_mount_info \ && defined (MOUNT_NFS) \ && (_mem_struct_statfs_f_type || _mem_struct_statfs_f_fstypename) # if _mem_struct_statfs_f_type if (sp->f_type == MOUNT_NFS # endif # if _mem_struct_statfs_f_fstypename if (strcmp (sp->f_fstypename, MOUNT_NFS) == 0 # endif # if _mem_struct_statfs_f_fstypename && defined (MOUNT_NFS3) || strcmp (sp->f_fstypename, MOUNT_NFS3) == 0 # endif # if _mem_struct_statfs_f_type && defined (MOUNT_NFS3) || sp->f_type == MOUNT_NFS3 # endif ) { struct nfs_args *na; na = &sp->mount_info.nfs_args; convertNFSMountOptions (na->flags, na->wsize, na->rsize, diptr); } # endif trimChar (diptr->options, ','); strncpy (diptr->special, sp->f_mntfromname, (Size_t) DI_SPEC_NAME_LEN); strncpy (diptr->name, sp->f_mntonname, (Size_t) DI_NAME_LEN); # if _mem_struct_statfs_f_fsize tblocksz = (_fs_size_t) sp->f_fsize; # endif # if _mem_struct_statfs_f_bsize && ! _mem_struct_statfs_f_fsize tblocksz = (_fs_size_t) sp->f_bsize; # endif di_saveBlockSizes (diptr, tblocksz, (_fs_size_t) sp->f_blocks, (_fs_size_t) sp->f_bfree, (_fs_size_t) sp->f_bavail); di_saveInodeSizes (diptr, (_fs_size_t) sp->f_files, (_fs_size_t) sp->f_ffree, (_fs_size_t) sp->f_ffree); # if _mem_struct_statfs_f_fstypename strncpy (diptr->fsType, sp->f_fstypename, (Size_t) DI_TYPE_LEN); # else # if _lib_sysfs && _mem_struct_statfs_f_type sysfs (GETFSTYP, sp->f_type, diptr->fsType); # else # if _dcl_mnt_names && _mem_struct_statfs_f_type # define DI_UNKNOWN_FSTYPE "(%.2d)?" fstype = sp->f_type; if ((fstype >= 0) && (fstype < MNT_NUMTYPES)) { strncpy (diptr->fsType, mnt_names [fstype], DI_TYPE_LEN); } else { Snprintf1 (diptr->fsType, sizeof (diptr->fsType), DI_UNKNOWN_FSTYPE, fstype); } # endif # endif # endif } free ((char *) mntbufp); return 0; } #endif /* _lib_getfsstat */ #if _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat /* * di_getDiskEntries * * Old OSF/1 system call. * OSF/1 does this with a system call and library routine. * [mogul@wrl.dec.com (Jeffrey Mogul)] * */ # if defined (INITMOUNTNAMES) && ! _dcl_mnt_names static char *mnt_names [] = INITMOUNTNAMES; # if ! defined (MNT_NUMTYPES) # define MNT_NUMTYPES (MOUNT_MAXTYPE + 1) # endif # endif int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int count; int idx; short fstype; struct statfs *mntbufp; if (debug > 0) { printf ("# getDiskEntries: getmntinfo\n"); } count = getmntinfo (&mntbufp, MNT_WAIT); if (count < 1) { fprintf (stderr, "Unable to do getmntinfo() errno %d\n", errno); return -1; } *diCount = count; *diskInfo = (diDiskInfo_t *) malloc (sizeof (diDiskInfo_t) * (Size_t) count); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } memset ((char *) *diskInfo, '\0', sizeof (diDiskInfo_t) * (Size_t) count); if (debug > 1) { printf ("type_len %d name_len %d spec_name_len %d\n", DI_TYPE_LEN, DI_NAME_LEN, DI_SPEC_NAME_LEN); } for (idx = 0; idx < count; idx++) { _fs_size_t tblocksz; diptr = *diskInfo + idx; di_initDiskInfo (diptr); # if defined (MNT_LOCAL) if ((mntbufp [idx].f_flags & MNT_LOCAL) != MNT_LOCAL) { diptr->isLocal = FALSE; } # endif strncpy (diptr->special, mntbufp [idx].f_mntfromname, DI_SPEC_NAME_LEN); strncpy (diptr->name, mntbufp [idx].f_mntonname, DI_NAME_LEN); tblocksz = (_fs_size_t) 1024; # if _mem_struct_statfs_f_fsize /* OSF 1.x */ tblocksz = (_fs_size_t) mntbufp [idx].f_fsize; # endif # if _mem_struct_statfs_f_bsize /* OSF 2.x */ tblocksz = (_fs_size_t) mntbufp [idx].f_bsize; # endif di_saveBlockSizes (diptr, tblocksz, (_fs_size_t) mntbufp [idx].f_blocks, (_fs_size_t) mntbufp [idx].f_bfree, (_fs_size_t) mntbufp [idx].f_bavail); di_saveInodeSizes (diptr, (_fs_size_t) mntbufp [idx].f_files, (_fs_size_t) mntbufp [idx].f_ffree, (_fs_size_t) mntbufp [idx].f_ffree); fstype = mntbufp [idx].f_type; # if ! _sys_fs_types && ! defined (INITMOUNTNAMES) \ && ! _mem_struct_statfs_f_fstypename if ((fstype >= 0) && (fstype <= MOUNT_MAXTYPE)) { switch (fstype) { # if defined (MOUNT_NONE) case MOUNT_NONE: /* No Filesystem */ { strncpy (diptr->fsType, "none", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_UFS) case MOUNT_UFS: /* UNIX "Fast" Filesystem */ { strncpy (diptr->fsType, "ufs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_NFS) case MOUNT_NFS: /* Network Filesystem */ { strncpy (diptr->fsType, "nfs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_MFS) case MOUNT_MFS: /* Memory Filesystem */ { strncpy (diptr->fsType, "mfs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_MSDOS) case MOUNT_MSDOS: /* MSDOS Filesystem */ { strncpy (diptr->fsType, "msdos", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_LFS) case MOUNT_LFS: { strncpy (diptr->fsType, "lfs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_LOFS) case MOUNT_LOFS: { strncpy (diptr->fsType, "lofs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_FDESC) case MOUNT_FDESC: { strncpy (diptr->fsType, "fdesc", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_PORTAL) case MOUNT_PORTAL: { strncpy (diptr->fsType, "portal", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_NULL) case MOUNT_NULL: { strncpy (diptr->fsType, "null", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_UMAP) case MOUNT_UMAP: { strncpy (diptr->fsType, "umap", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_KERNFS) case MOUNT_KERNFS: { strncpy (diptr->fsType, "kernfs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_PROCFS) case MOUNT_PROCFS: /* proc filesystem */ { strncpy (diptr->fsType, "pfs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_AFS) case MOUNT_AFS: { strncpy (diptr->fsType, "afs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_ISOFS) case MOUNT_ISOFS: /* iso9660 cdrom */ { strncpy (diptr->fsType, "iso9660fs", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_ISO9660) && ! defined (MOUNT_CD9660) case MOUNT_ISO9660: /* iso9660 cdrom */ { strncpy (diptr->fsType, "iso9660", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_CD9660) case MOUNT_CD9660: /* iso9660 cdrom */ { strncpy (diptr->fsType, "cd9660", DI_TYPE_LEN); break; } # endif # if defined (MOUNT_UNION) case MOUNT_UNION: { strncpy (diptr->fsType, "union", DI_TYPE_LEN); break; } # endif } /* switch on mount type */ } # else # if _mem_struct_statfs_f_fstypename strncpy (diptr->fsType, mntbufp [idx].f_fstypename, DI_TYPE_LEN); # else # define DI_UNKNOWN_FSTYPE "(%.2d)?" /* could use getvfsbytype here... */ if ((fstype >= 0) && (fstype < MNT_NUMTYPES)) { strncpy (diptr->fsType, mnt_names [fstype], DI_TYPE_LEN); } else { Snprintf1 (diptr->fsType, sizeof (diptr->fsType), DI_UNKNOWN_FSTYPE, fstype); } # endif # endif /* else has sys/fs_types.h */ diptr->isReadOnly = FALSE; # if defined (MNT_RDONLY) if ((mntbufp [idx].f_flags & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } # endif convertMountOptions ((unsigned long) mntbufp [idx].f_flags, diptr); trimChar (diptr->options, ','); if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tblocks: tot:%ld free:%ld avail:%ld\n", (long) mntbufp [idx].f_blocks, (long) mntbufp [idx].f_bfree, (long) mntbufp [idx].f_bavail); # if _mem_struct_statfs_f_fsize printf ("\tfsize:%ld \n", (long) mntbufp [idx].f_fsize); # endif # if _mem_struct_statfs_f_bsize printf ("\tbsize:%ld \n", (long) mntbufp [idx].f_bsize); # endif # if _mem_struct_statfs_f_iosize printf ("\tiosize:%ld \n", (long) mntbufp [idx].f_iosize); # endif printf ("\tinodes: tot:%ld free:%ld\n", (long) mntbufp [idx].f_files, (long) mntbufp [idx].f_ffree); } } free ((char *) mntbufp); /* man page says this can't be freed. */ /* is it ok to try? */ return 0; } #endif /* _lib_getmntinfo */ #if _lib_getvfsstat && _args_getvfsstat == 3 /* * di_getDiskEntries * * NetBSD * */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int count; int idx; Size_t bufsize; struct statvfs *mntbufp; struct statvfs *sp; if (debug > 0) { printf ("# getDiskEntries: getvfsstat\n"); } count = getvfsstat ((struct statvfs *) NULL, 0, ST_NOWAIT); if (count < 1) { fprintf (stderr, "Unable to do getvfsstat () errno %d\n", errno); return -1; } bufsize = sizeof (struct statvfs) * (Size_t) count; mntbufp = malloc ((Size_t) bufsize); if (mntbufp == (struct statvfs *) NULL) { fprintf (stderr, "malloc failed for mntbufp. errno %d\n", errno); return -1; } memset ((char *) mntbufp, '\0', sizeof (struct statvfs) * (Size_t) count); count = getvfsstat (mntbufp, (Size_t) bufsize, ST_NOWAIT); *diCount = count; *diskInfo = (diDiskInfo_t *) malloc (sizeof (diDiskInfo_t) * (Size_t) count); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } memset ((char *) *diskInfo, '\0', sizeof (diDiskInfo_t) * (Size_t) count); for (idx = 0; idx < count; idx++) { _fs_size_t tblocksz; diptr = *diskInfo + idx; di_initDiskInfo (diptr); sp = mntbufp + idx; # if defined (MNT_RDONLY) if ((sp->f_flag & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } # endif # if defined (MNT_LOCAL) if ((sp->f_flag & MNT_LOCAL) != MNT_LOCAL) { diptr->isLocal = FALSE; } # endif convertMountOptions ((unsigned long) sp->f_flag, diptr); trimChar (diptr->options, ','); if (sp->f_frsize == 0 && sp->f_bsize != 0) { tblocksz = (_fs_size_t) sp->f_bsize; } else { tblocksz = (_fs_size_t) sp->f_frsize; } di_saveBlockSizes (diptr, tblocksz, (_fs_size_t) sp->f_blocks, (_fs_size_t) sp->f_bfree, (_fs_size_t) sp->f_bavail); di_saveInodeSizes (diptr, (_fs_size_t) sp->f_files, (_fs_size_t) sp->f_ffree, (_fs_size_t) sp->f_ffree); strncpy (diptr->special, sp->f_mntfromname, DI_SPEC_NAME_LEN); strncpy (diptr->name, sp->f_mntonname, DI_NAME_LEN); strncpy (diptr->fsType, sp->f_fstypename, DI_TYPE_LEN); if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tbsize:%ld frsize:%ld\n", (long) sp->f_bsize, (long) sp->f_frsize); #if _siz_long_long >= 8 printf ("\tblocks: tot:%llu free:%lld avail:%llu\n", sp->f_blocks, sp->f_bfree, sp->f_bavail); printf ("\tinodes: tot:%llu free:%llu avail:%llu\n", sp->f_files, sp->f_ffree, sp->f_favail); #else printf ("\tblocks: tot:%lu free:%lu avail:%lu\n", sp->f_blocks, sp->f_bfree, sp->f_bavail); printf ("\tinodes: tot:%lu free:%lu avail:%lu\n", sp->f_files, sp->f_ffree, sp->f_favail); #endif } } free ((char *) mntbufp); return 0; } #endif /* _lib_getvfsstat */ #if _lib_getmnt # if _npt_getmnt int getmnt _((int *, struct fs_data *, int, int, char *)); # endif /* * di_getDiskEntries * * ULTRIX does this with a system call. The system call allows one * to retrieve the information in a series of calls, but coding that * looks a little tricky; I just allocate a huge buffer and do it in * one shot. * * [mogul@wrl.dec.com (Jeffrey Mogul)] */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int count; int bufsize; int idx; short fstype; struct fs_data *fsdbuf; int start; int len; if (debug > 0) { printf ("# getDiskEntries: getmnt\n"); } bufsize = NMOUNT * sizeof (struct fs_data); /* enough for max # mounts */ fsdbuf = (struct fs_data *) malloc ((Size_t) bufsize); if (fsdbuf == (struct fs_data *) NULL) { fprintf (stderr, "malloc (%d) for getmnt () failed errno %d\n", bufsize, errno); return -1; } start = 0; count = getmnt (&start, fsdbuf, bufsize, STAT_MANY, 0); if (count < 1) { fprintf (stderr, "Unable to do getmnt () [= %d] errno %d\n", count, errno); free ((char *) fsdbuf); return -1; } *diCount = count; *diskInfo = (diDiskInfo_t *) malloc (sizeof (diDiskInfo_t) * (Size_t) count); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); free ((char *) fsdbuf); return -1; } memset ((char *) *diskInfo, '\0', sizeof (diDiskInfo_t) * count); for (idx = 0; idx < count; idx++) { diptr = *diskInfo + idx; di_initDiskInfo (diptr); if ((fsdbuf [idx].fd_req.flags & MNT_LOCAL) != MNT_LOCAL) { diptr->isLocal = FALSE; } strncpy (diptr->special, fsdbuf [idx].fd_devname, DI_SPEC_NAME_LEN); strncpy (diptr->name, fsdbuf [idx].fd_path, DI_NAME_LEN); /* ULTRIX keeps these fields in units of 1K byte */ di_saveBlockSizes (diptr, (_fs_size_t) 1024, (_fs_size_t) fsdbuf [idx].fd_btot, (_fs_size_t) fsdbuf [idx].fd_bfree, (_fs_size_t) fsdbuf [idx].fd_bfreen); di_saveInodeSizes (diptr, (_fs_size_t) fsdbuf [idx].fd_gtot, (_fs_size_t) fsdbuf [idx].fd_gfree, (_fs_size_t) fsdbuf [idx].fd_gfree); fstype = fsdbuf [idx].fd_fstype; if (fstype == GT_UNKWN) { diptr->printFlag = DI_PRNT_IGNORE; if (debug > 2) { printf ("mnt: ignore: disk type unknown: %s\n", diptr->name); } } else if ((fstype > 0) && (fstype < GT_NUMTYPES)) { strncpy (diptr->fsType, gt_names [fstype], DI_TYPE_LEN); } else { Snprintf1 (diptr->fsType, sizeof (diptr->fsType), "Unknown fstyp %.2d", fstype); } if ((fsdbuf [idx].fd_req.flags & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } else { diptr->isReadOnly = FALSE; } convertMountOptions ((unsigned long) fsdbuf [idx].fd_req.flags, diptr); trimChar (diptr->options, ','); if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tblocks: tot:%ld free:%ld avail:%ld\n", fsdbuf [idx].fd_btot, fsdbuf [idx].fd_bfree, (int) fsdbuf [idx].fd_bfreen); printf ("\tinodes: tot:%ld free:%ld\n", fsdbuf [idx].fd_gtot, fsdbuf [idx].fd_gfree); } } free ((char *) fsdbuf); return 0; } #endif /* _lib_getmnt */ #if _lib_mntctl /* * di_getDiskEntries * * AIX uses mntctl to find out about mounted file systems * This seems to be better than set/get/end, as we get the * remote filesystem flag. * */ # define DI_FSMAGIC 10 /* base AIX configuration has 5 file systems */ # define NUM_AIX_FSTYPES 6 static char *AIX_fsType [NUM_AIX_FSTYPES] = { "oaix", "", "nfs", "jfs", "", "cdrom" }; /* * from xfsm-1.80: * * MNT_AIX - "aix" * MNT_NFS - "nfs" * MNT_JFS - "jfs" * MNT_CDROM - "cdrom" * other - "user defined" * */ #define DI_RETRY_COUNT 5 int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int num; /* number of vmount structs returned */ char *vmbuf; /* buffer for vmount structs returned */ Size_t vmbufsz; /* size in bytes of vmbuf */ int i; /* index for looping and stuff */ char *bufp; /* pointer into vmbuf */ struct vmount *vmtp; /* pointer into vmbuf */ struct vfs_ent *ve; /* pointer for file system type entry */ if (debug > 0) { printf ("# getDiskEntries: mntctl\n"); } i = 0; vmbufsz = sizeof (struct vmount) * DI_FSMAGIC; /* initial vmount buffer */ do { if ((vmbuf = (char *) malloc (vmbufsz)) == (char *) NULL) { fprintf (stderr, "malloc (%d) for mntctl() failed errno %d\n", (int) vmbufsz, errno); return -1; } num = mntctl (MCTL_QUERY, vmbufsz, vmbuf); /* * vmbuf is too small, could happen for * following reasons: * - inital buffer is too small * - newly mounted file system */ if (num == 0) { memcpy (&vmbufsz, vmbuf, sizeof (vmbufsz)); /* see mntctl(2) */ if (debug > 0) { printf ("vmbufsz too small, new size: %d\n", (int) vmbufsz); } free ((char *) vmbuf); /* free this last, it's still being used! */ ++i; } } while (num == 0 && i < DI_RETRY_COUNT); if (i >= DI_RETRY_COUNT) { free ((char *) vmbuf); fprintf (stderr, "unable to allocate adequate buffer for mntctl\n"); return -1; } if (num == -1) { free ((char *) vmbuf); fprintf (stderr, "%s errno %d\n", strerror (errno), errno); return -1; } /* vmount structs returned in vmbuf */ *diCount = num; *diskInfo = (diDiskInfo_t *) malloc (sizeof (diDiskInfo_t) * (Size_t) *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. %s errno %d\n", strerror (errno), errno); return -1; } bufp = vmbuf; for (i = 0; i < num; i++) { diptr = *diskInfo + i; di_initDiskInfo (diptr); vmtp = (struct vmount *) bufp; if ((vmtp->vmt_flags & MNT_REMOTE) == MNT_REMOTE) { diptr->isLocal = FALSE; } if ((vmtp->vmt_flags & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } *diptr->special = '\0'; if (diptr->isLocal == FALSE) { strncpy (diptr->special, (char *) vmt2dataptr (vmtp, VMT_HOSTNAME), DI_SPEC_NAME_LEN); strncat (diptr->special, ":", DI_SPEC_NAME_LEN - strlen (diptr->special) - 1); } strncat (diptr->special, (char *) vmt2dataptr (vmtp, VMT_OBJECT), DI_SPEC_NAME_LEN - strlen (diptr->special) - 1); strncpy (diptr->name, (char *) vmt2dataptr (vmtp, VMT_STUB), DI_NAME_LEN); ve = getvfsbytype (vmtp->vmt_gfstype); if (ve == (struct vfs_ent *) NULL || *ve->vfsent_name == '\0') { if (vmtp->vmt_gfstype >= 0 && (vmtp->vmt_gfstype < NUM_AIX_FSTYPES)) { strncpy (diptr->fsType, AIX_fsType [vmtp->vmt_gfstype], DI_TYPE_LEN); } } else { strncpy (diptr->fsType, ve->vfsent_name, DI_TYPE_LEN); } strncpy (diptr->options, (char *) vmt2dataptr (vmtp, VMT_ARGS), DI_OPT_LEN); trimChar (diptr->options, ','); bufp += vmtp->vmt_length; if (debug > 1) { printf ("mnt:%s - %s : %s\n", diptr->name, diptr->special, diptr->fsType); printf ("\t%s\n", (char *) vmt2dataptr (vmtp, VMT_ARGS)); } } return 0; } #endif /* _lib_mntctl */ #if _lib_GetDriveType \ && _lib_GetLogicalDriveStrings /* * di_getDiskInfo * * Windows * */ # define MSDOS_BUFFER_SIZE 256 # define BYTES_PER_LOGICAL_DRIVE 4 int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int i; char diskflag; int rc; char *p; char buff [MSDOS_BUFFER_SIZE]; if (debug > 0) { printf ("# getDiskInfo: GetLogicalDriveStrings GetDriveType\n"); } diskflag = DI_PRNT_SKIP; rc = (int) GetLogicalDriveStrings (MSDOS_BUFFER_SIZE, buff); *diCount = rc / BYTES_PER_LOGICAL_DRIVE; *diskInfo = (diDiskInfo_t *) malloc (sizeof (diDiskInfo_t) * (Size_t) *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } for (i = 0; i < *diCount; ++i) { diptr = *diskInfo + i; p = buff + (BYTES_PER_LOGICAL_DRIVE * i); strncpy (diptr->name, p, DI_NAME_LEN); rc = (int) GetDriveType (p); diptr->printFlag = DI_PRNT_OK; if (rc == DRIVE_NO_ROOT_DIR) { diptr->printFlag = DI_PRNT_BAD; } /* assume that any removable drives before the */ /* first non-removable disk are floppies... */ else if (rc == DRIVE_REMOVABLE) { DWORD br; BOOL bSuccess; char handleName [MSDOS_BUFFER_SIZE + 1]; diptr->printFlag = diskflag; bSuccess = 1; strncpy (handleName, "\\\\.\\", MSDOS_BUFFER_SIZE); strncat (handleName, p, MSDOS_BUFFER_SIZE); handleName[strlen(handleName)-1] = '\0'; # if _define_IOCTL_STORAGE_CHECK_VERIFY2 HANDLE hDevice = CreateFile (handleName, FILE_READ_ATTRIBUTES, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); bSuccess = DeviceIoControl (hDevice, IOCTL_STORAGE_CHECK_VERIFY2, NULL, 0, NULL, 0, &br, (LPOVERLAPPED) NULL); # else HANDLE hDevice = CreateFile (handleName, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); bSuccess = DeviceIoControl (hDevice, IOCTL_STORAGE_CHECK_VERIFY, NULL, 0, NULL, 0, &br, (LPOVERLAPPED) NULL); # endif CloseHandle (hDevice); if (! bSuccess) { diptr->printFlag = DI_PRNT_BAD; } } else { diskflag = DI_PRNT_OK; } if (rc != DRIVE_REMOTE) { diptr->isLocal = TRUE; } } /* for each mounted drive */ return *diCount; } #endif /* _lib_GetDiskFreeSpace || _lib_GetDiskFreeSpaceEx */ #if _lib_fs_stat_dev \ && _lib_next_dev /* * di_getDiskEntries * * For BeOS. * */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; status_t stat; int idx; int32 count; dev_t dev; char buff [B_FILE_NAME_LENGTH]; fs_info fsinfo; node_ref nref; BDirectory *dir; BEntry entry; BPath path; if (debug > 0) { printf ("# getDiskEntries: fs_stat_dev\n"); } count = 0; while ((dev = next_dev (&count)) != B_BAD_VALUE) { if ((stat = fs_stat_dev (dev, &fsinfo)) == B_BAD_VALUE) { break; } idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); *buff = '\0'; nref.device = dev; nref.node = fsinfo.root; dir = new BDirectory (&nref); stat = dir->GetEntry (&entry); stat = entry.GetPath (&path); strncpy (diptr->name, path.Path(), DI_NAME_LEN); strncpy (diptr->special, fsinfo.device_name, DI_SPEC_NAME_LEN); strncpy (diptr->fsType, fsinfo.fsh_name, DI_TYPE_LEN); di_saveBlockSizes (diptr, (_fs_size_t) fsinfo.block_size, (_fs_size_t) fsinfo.total_blocks, (_fs_size_t) fsinfo.free_blocks, (_fs_size_t) fsinfo.free_blocks); di_saveInodeSizes (diptr, (_fs_size_t) fsinfo.total_nodes, (_fs_size_t) fsinfo.free_nodes, (_fs_size_t) fsinfo.free_nodes); # if defined (MNT_RDONLY) if ((fsinfo.flags & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } # endif # if defined (MNT_PERSISTENT) if ((fsinfo.flags & MNT_PERSISTENT) != MNT_PERSISTENT) { diptr->printFlag = DI_PRNT_IGNORE; } # endif convertMountOptions ((unsigned long) fsinfo.flags, diptr); trimChar (diptr->options, ','); if (debug > 1) { printf ("mnt:%s - %s\n", diptr->name, diptr->special); printf ("dev:%d fs:%s\n", dev, diptr->fsType); } if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tblocks: tot:%ld free:%ld\n", fsinfo.total_blocks, fsinfo.free_blocks); printf ("\tinodes: tot:%ld free:%ld\n", fsinfo.total_nodes, fsinfo.free_nodes); } } return 0; } #endif #if _class_os__Volumes /* * di_getDiskEntries * * For Syllable. * */ int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int idx; Uint_t i; status_t stat; uint32 count; fs_info fsinfo; os::Volumes *vols; os::String mpString; if (debug > 0) { printf ("# getDiskEntries: os::Volumes\n"); } vols = new os::Volumes; count = vols->GetMountPointCount (); for (i = 0; i < count; ++i) { if ((stat = vols->GetFSInfo (i, &fsinfo)) != 0) { break; } idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * *diCount); if (*diskInfo == (diDiskInfo_t *) NULL) { fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); stat = vols->GetMountPoint (i, &mpString); strncpy (diptr->name, mpString.c_str(), DI_NAME_LEN); strncpy (diptr->special, fsinfo.fi_device_path, DI_SPEC_NAME_LEN); strncpy (diptr->fsType, fsinfo.fi_driver_name, DI_TYPE_LEN); di_saveBlockSizes (diptr, (_fs_size_t) fsinfo.fi_block_size, (_fs_size_t) fsinfo.fi_total_blocks, (_fs_size_t) fsinfo.fi_free_blocks, (_fs_size_t) fsinfo.fi_free_user_blocks); di_saveInodeSizes (diptr, (_fs_size_t) fsinfo.fi_total_inodes, (_fs_size_t) fsinfo.fi_free_inodes, (_fs_size_t) fsinfo.fi_free_inodes); # if defined (MNT_RDONLY) if ((fsinfo.fi_flags & MNT_RDONLY) == MNT_RDONLY) { diptr->isReadOnly = TRUE; } # endif # if defined (MNT_PERSISTENT) if ((fsinfo.fi_flags & MNT_PERSISTENT) != MNT_PERSISTENT) { diptr->printFlag = DI_PRNT_IGNORE; } # endif convertMountOptions ((unsigned long) fsinfo.fi_flags, diptr); trimChar (diptr->options, ','); if (debug > 1) { printf ("mnt:%s - %s\n", diptr->name, diptr->special); printf ("dev:%d fs:%s\n", fsinfo.fi_dev, diptr->fsType); } if (debug > 1) { printf ("mount_args: %s\n", fsinfo.fi_mount_args); printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tblocks: tot:%ld free:%ld avail:%ld\n", (long int) fsinfo.fi_total_blocks, (long int) fsinfo.fi_free_blocks, (long int) fsinfo.fi_free_user_blocks); printf ("\tinodes: tot:%ld free:%ld\n", (long int) fsinfo.fi_total_inodes, (long int) fsinfo.fi_free_inodes); } } return 0; } #endif /* * VMS */ #if _lib_sys_dollar_device_scan && _lib_sys_dollar_getdviw /* Thanks to Craig Berry's VMS::Device for the VMS code. */ char *monthNames[12] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" }; genericID_t devInfoList[] = { #ifdef DVI$_DISPLAY_DEVNAM DVI_ENT(DISPLAY_DEVNAM, 256, DVI_IS_STRING), #endif #ifdef DVI$_DEVBUFSIZ DVI_ENT(DEVBUFSIZ, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_MAXBLOCK DVI_ENT(MAXBLOCK, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_FREEBLOCKS DVI_ENT(FREEBLOCKS, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_MAXFILES DVI_ENT(MAXFILES, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_REMOTE_DEVICE DVI_ENT(REMOTE_DEVICE, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_VOLNAM DVI_ENT(VOLNAM, 12, DVI_IS_STRING), #endif #ifdef DVI$_AVL DVI_ENT(AVL, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_MNT DVI_ENT(MNT, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_SHR DVI_ENT(SHR, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_ODS2_SUBSET0 DVI_ENT(ODS2_SUBSET0, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_ODS5 DVI_ENT(ODS5, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_NET DVI_ENT(NET, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_DEVICE_TYPE_NAME DVI_ENT(DEVICE_TYPE_NAME, 64, DVI_IS_STRING), #endif #ifdef DVI$_SHDW_MASTER DVI_ENT(SHDW_MASTER, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_SHDW_MEMBER DVI_ENT(SHDW_MEMBER, 4, DVI_IS_LONGWORD), #endif #ifdef DVI$_SHDW_MASTER_NAME DVI_ENT(SHDW_MASTER_NAME, 64, DVI_IS_STRING), #endif {NULL, 0, 0, 0} }; #define devInfoListCount ((sizeof(devInfoList)/sizeof (genericID_t)) - 1) int # if _proto_stdc di_getDiskEntries (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskEntries (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int idx; unsigned short devNameLen; unsigned short devReturnLen; unsigned int deviceClass; char context[8] = {0,0,0,0,0,0,0,0}; struct dsc$descriptor_s devNameDesc; struct dsc$descriptor_s devSearchNameDesc; VMS_ITMLST scanItemList; VMS_ITMLST *itemList; unsigned short *returnLengths; char **returnBuffers; long *tempLong; char returnedDevName [65]; unsigned short returnedTime[7]; char displayTime[100]; int i; int status; # ifdef __ALPHA __int64 *tempLongLong; # endif _fs_size_t freeBlocks; _fs_size_t totBlocks; _fs_size_t maxFiles; _fs_size_t tblocksz; if (debug > 0) { printf ("# getDiskEntries: sys$device_scan/sys$getdviw\n"); } devNameDesc.dsc$a_pointer = returnedDevName; devNameDesc.dsc$w_length = 64; devNameDesc.dsc$b_dtype = DSC$K_DTYPE_T; devNameDesc.dsc$b_class = DSC$K_CLASS_S; devSearchNameDesc.dsc$a_pointer = "*"; devSearchNameDesc.dsc$w_length = 1; devSearchNameDesc.dsc$b_dtype = DSC$K_DTYPE_T; devSearchNameDesc.dsc$b_class = DSC$K_CLASS_S; memset (&scanItemList, 0, sizeof(VMS_ITMLST)); itemList = malloc (sizeof(VMS_ITMLST) * (devInfoListCount)); if (itemList == (VMS_ITMLST *) NULL) { fprintf (stderr, "malloc failed for itemList. errno %d\n", errno); return -1; } memset (itemList, 0, sizeof(VMS_ITMLST) * (devInfoListCount)); returnBuffers = (char **) malloc (sizeof (char *) * devInfoListCount); if (returnBuffers == (char **) NULL) { fprintf (stderr, "malloc failed for returnBuffers. errno %d\n", errno); free ((char *) itemList); return -1; } returnLengths = malloc (sizeof(short) * devInfoListCount); if (returnLengths == (short *) NULL) { fprintf (stderr, "malloc failed for returnLengths. errno %d\n", errno); free ((char *) itemList); free ((char *) returnBuffers); return -1; } for (i = 0; i < devInfoListCount; i++) { returnBuffers[i] = malloc (devInfoList[i].bufferLen + 1); if (returnBuffers[i] == (char *) NULL) { fprintf (stderr, "malloc failed for returnBuffers[i]. errno %d\n", errno); free ((char *) itemList); free ((char *) returnBuffers); free ((char *) returnLengths); return -1; } memset (returnBuffers[i], 0, devInfoList[i].bufferLen + 1); init_itemlist (&itemList[i], devInfoList[i].bufferLen, devInfoList[i].syscallValue, returnBuffers[i], &returnLengths[i]); } deviceClass = DC$_DISK; init_itemlist (&scanItemList, sizeof(deviceClass), DVS$_DEVCLASS, &deviceClass, NULL); while (sys$device_scan (&devNameDesc, &devReturnLen, &devSearchNameDesc, &scanItemList, context) == SS$_NORMAL) { idx = *diCount; ++*diCount; *diskInfo = (diDiskInfo_t *) di_realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); if (*diskInfo == (di_DiskInfo_t *) NULL) fprintf (stderr, "malloc failed for diskInfo. errno %d\n", errno); return -1; } diptr = *diskInfo + idx; di_initDiskInfo (diptr); returnedDevName [devReturnLen] = '\0'; if (debug > 4) { printf ("%s\n", returnedDevName); } devNameDesc.dsc$a_pointer = returnedDevName; devNameDesc.dsc$w_length = devReturnLen; devNameDesc.dsc$b_dtype = DSC$K_DTYPE_T; devNameDesc.dsc$b_class = DSC$K_CLASS_S; strncpy (diptr->fsType, "ODS-2", DI_TYPE_LEN); /* _$9$LDA2: */ if (strlen (returnedDevName) > 4 && returnedDevName[4] == 'L') { strncpy (diptr->fsType, "LD", DI_TYPE_LEN); } status = sys$getdviw(0, 0, &devNameDesc, itemList, NULL, NULL, NULL, NULL); if (status == SS$_NORMAL) { for (i = 0; i < devInfoListCount; i++) { switch (devInfoList[i].returnType) { case DVI_IS_STRING: if (debug > 4) { printf (" string:"); printf ("%s:", devInfoList[i].name); printf ("%*s:\n", (int) returnLengths[i], (char *) returnBuffers[i]); } if (strcmp (devInfoList[i].name, "DISPLAY_DEVNAM") == 0) { strncpy (diptr->special, returnBuffers[i], returnLengths[i]); diptr->special[returnLengths[i]] = '\0'; } if (strcmp (devInfoList[i].name, "VOLNAM") == 0) { strncpy (diptr->name, returnBuffers[i], returnLengths[i]); diptr->name[returnLengths[i]] = '\0'; } if (strcmp (devInfoList[i].name, "DEVICE_TYPE_NAME") == 0) { returnBuffers[i][returnLengths[i]] = '\0'; strncat (diptr->options, "dev=", DI_OPT_LEN - strlen (diptr->options) - 1); strncat (diptr->options, returnBuffers[i], DI_OPT_LEN - strlen (diptr->options) - 1); strncat (diptr->options, ",", DI_OPT_LEN - strlen (diptr->options) - 1); } if (strcmp (devInfoList[i].name, "SHDW_MASTER_NAME") == 0) { if (returnLengths[i] > 0) { returnBuffers[i][returnLengths[i]] = '\0'; strncat (diptr->options, returnBuffers[i], DI_OPT_LEN - strlen (diptr->options) - 1); strncat (diptr->options, "),", DI_OPT_LEN - strlen (diptr->options) - 1); } } break; case DVI_IS_VMSDATE: sys$numtim (returnedTime, returnBuffers[i]); sprintf (displayTime, "%02hi-%s-%hi %02hi:%02hi:%02hi.%02hi", returnedTime[2], monthNames[returnedTime[1] - 1], returnedTime[0], returnedTime[3], returnedTime[4], returnedTime[5], returnedTime[6]); if (debug > 4) { printf (" date:"); printf ("%s:", devInfoList[i].name); printf ("%s:\n", displayTime); } break; case DVI_IS_ENUM: tempLong = (long *) returnBuffers[i]; if (debug > 4) { printf (" enum:"); printf ("%s:", devInfoList[i].name); printf ("%ld:\n", *tempLong); } break; case DVI_IS_BITMAP: case DVI_IS_LONGWORD: tempLong = (long *) returnBuffers[i]; if (debug > 4) { printf (" long:"); printf ("%s:", devInfoList[i].name); printf ("%ld:\n", *tempLong); } if (strcmp (devInfoList[i].name, "MAXBLOCK") == 0) { totBlocks = *tempLong; } if (strcmp (devInfoList[i].name, "FREEBLOCKS") == 0) { freeBlocks = *tempLong; } if (strcmp (devInfoList[i].name, "MAXFILES") == 0) { maxFiles = *tempLong; } if (strcmp (devInfoList[i].name, "REMOTE_DEVICE") == 0) { if (*tempLong == 1L) { diptr->isLocal = FALSE; } } if (strcmp (devInfoList[i].name, "NET") == 0) { if (*tempLong == 1L) { diptr->isLocal = FALSE; } } if (strcmp (devInfoList[i].name, "DEVBUFSIZ") == 0) { tblocksz = *tempLong; } if (strcmp (devInfoList[i].name, "AVL") == 0) { if (*tempLong == 0L) { diptr->printFlag = DI_PRNT_IGNORE; strncat (diptr->options, "Offline,", DI_OPT_LEN - strlen (diptr->options) - 1); } if (*tempLong == 1L) { strncat (diptr->options, "Online,", DI_OPT_LEN - strlen (diptr->options) - 1); } } if (strcmp (devInfoList[i].name, "MNT") == 0) { if (*tempLong == 1L) { strncat (diptr->options, "Mounted,", DI_OPT_LEN - strlen (diptr->options) - 1); } else { diptr->printFlag = DI_PRNT_IGNORE; } } if (strcmp (devInfoList[i].name, "SHR") == 0) { if (*tempLong == 1L) { strncat (diptr->options, "Shareable,", DI_OPT_LEN - strlen (diptr->options) - 1); } } if (strcmp (devInfoList[i].name, "SHDW_MASTER") == 0) { if (*tempLong == 1L) { strncat (diptr->options, "Shadow Master,", DI_OPT_LEN - strlen (diptr->options) - 1); } } if (strcmp (devInfoList[i].name, "SHDW_MEMBER") == 0) { if (*tempLong == 1L) { strncat (diptr->options, "Shadow Member(", DI_OPT_LEN - strlen (diptr->options) - 1); } } if (strcmp (devInfoList[i].name, "ODS2_SUBSET0") == 0) { if (*tempLong == 1L) { strncpy (diptr->fsType, "ODS-2/0", DI_TYPE_LEN); } } if (strcmp (devInfoList[i].name, "ODS5") == 0) { if (*tempLong == 1L) { strncpy (diptr->fsType, "ODS-5", DI_TYPE_LEN); } } break; # ifdef __ALPHA case DVI_IS_QUADWORD: tempLongLong = (__int64 *) returnBuffers[i]; if (debug > 4) { printf (" quad:"); printf ("%s:", devInfoList[i].name); printf ("%llu:\n", (long long) *tempLongLong); } break; # endif } } } else { /* fail */ ; } di_saveBlockSizes (diptr, tblocksz, totBlocks, freeBlocks, freeBlocks); di_saveInodeSizes (diptr, maxFiles, 0, 0); /* reset this so there's room during the next syscall */ devNameDesc.dsc$w_length = 64; trimChar (diptr->options, ','); } /* while there are entries */ for (i = 0; i < devInfoListCount; i++) { free (returnBuffers[i]); } free (returnBuffers); free (returnLengths); free (itemList); return 0; } #endif di-4.47/C/dimntopt.h0000644000175000017500000000667013334050206012346 0ustar bllbll/* * Copyright 2011-2018 Brad Lanam, Walnut Creek, CA */ #ifndef DI_INC_DIMNTOPT_H_ #define DI_INC_DIMNTOPT_H_ #include "config.h" #if _hdr_mntent \ && ! defined (DI_INC_MNTENT) /* Linux, kFreeBSD, HP-UX */ # define DI_INC_MNTENT 1 # include /* MNTOPT_... */ #endif #if _sys_mount \ && ! defined (DI_INC_SYS_MOUNT) /* FreeBSD, OpenBSD, NetBSD, HP-UX */ # define DI_INC_SYS_MOUNT 1 # include /* MNT_...; M_... (hp-ux) */ #endif #if _sys_mnttab /* SCO_SV, UnixWare */ # include /* required for mntent.h */ #endif #if _sys_mntent /* Solaris, SCO_SV, UnixWare */ # include /* MNTOPT_... */ #endif #if _sys_fstypes /* NetBSD */ # include #endif #if _sys_vmount /* AIX */ # include /* MNT_... */ #endif #if _hdr_mnttab /* SysV.3 */ # include #endif /********************************************************/ /* remap mount flags */ #if defined (B_FS_IS_READONLY) # define MNT_RDONLY B_FS_IS_READONLY #endif #if defined (FS_IS_READONLY) # define MNT_RDONLY FS_IS_READONLY #endif #if defined (M_RDONLY) # define MNT_RDONLY M_RDONLY #endif #if defined (MNT_READONLY) # define MNT_RDONLY MNT_READONLY #endif #if defined (M_RONLY) # define MNT_RDONLY M_RONLY #endif #if defined (M_SYNCHRONOUS) # define MNT_SYNCHRONOUS M_SYNCHRONOUS #endif #if defined (M_NOEXEC) # define MNT_NOEXEC M_NOEXEC #endif #if defined (M_NOSUID) # define MNT_NOSUID M_NOSUID #endif #if defined (M_NODEV) # define MNT_NODEV M_NODEV #endif #if defined (M_NOATIMES) # define MNT_NOATIMES M_NOATIMES #endif #if defined (M_GRPID) # define MNT_GRPID M_GRPID #endif #if defined (M_SECURE) # define MNT_SECURE M_SECURE #endif #if defined (M_MLSD) # define MNT_MLSD M_MLSD #endif #if defined (M_SMSYNC2) # define MNT_SMSYNC2 M_SMSYNC2 #endif #if defined (M_LOCAL) # define MNT_LOCAL M_LOCAL #endif #if defined (M_FORCE) # define MNT_FORCE M_FORCE #endif #if defined (M_SYNC) # define MNT_SYNC M_SYNC #endif #if defined (M_NOCACHE) # define MNT_NOCACHE M_NOCACHE #endif #if defined (B_FS_IS_REMOVABLE) # define MNT_REMOVABLE B_FS_IS_REMOVABLE #endif #if defined (FS_IS_REMOVABLE) # define MNT_REMOVABLE FS_IS_REMOVABLE #endif #if defined (B_FS_IS_PERSISTENT) # define MNT_PERSISTENT B_FS_IS_PERSISTENT #endif #if defined (FS_IS_PERSISTENT) # define MNT_PERSISTENT FS_IS_PERSISTENT #endif #if defined (B_FS_IS_SHARED) # define MNT_SHARED B_FS_IS_SHARED #endif #if defined (FS_IS_SHARED) # define MNT_SHARED FS_IS_SHARED #endif #if defined (FS_IS_BLOCKBASED) # define MNT_BLOCKBASED FS_IS_BLOCKBASED #endif #if defined (B_FS_HAS_MIME) # define MNT_HAS_MIME B_FS_HAS_MIME #endif #if defined (FS_HAS_MIME) # define MNT_HAS_MIME FS_HAS_MIME #endif #if defined (B_FS_HAS_ATTR) # define MNT_HAS_ATTR B_FS_HAS_ATTR #endif #if defined (FS_HAS_ATTR) # define MNT_HAS_ATTR FS_HAS_ATTR #endif #if defined (B_FS_HAS_QUERY) # define MNT_HAS_QUERY B_FS_HAS_QUERY #endif #if defined (FS_HAS_QUERY) # define MNT_HAS_QUERY FS_HAS_QUERY #endif #if defined (MNTOPT_IGNORE) # define DI_MNTOPT_IGNORE MNTOPT_IGNORE #else # define DI_MNTOPT_IGNORE "ignore" #endif #if defined (MNTOPT_RO) # define DI_MNTOPT_RO MNTOPT_RO #else # define DI_MNTOPT_RO "ro" #endif #if defined (MNTOPT_DEV) # define DI_MNTOPT_DEV MNTOPT_DEV #else # define DI_MNTOPT_DEV "dev=" #endif #endif /* DI_INC_DIMNTOPT_H_ */ di-4.47/C/di.h0000644000175000017500000002472213334050206011102 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #ifndef DI_INC_DI_H #define DI_INC_DI_H #include "config.h" /*****************************************************/ #include #if _hdr_fcntl \ && ! defined (DI_INC_FCNTL_H) /* xenix */ # define DI_INC_FCNTL_H # include #endif #if _sys_file # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _hdr_limits # include /* PATH_MAX */ #endif #if _sys_param # include /* MAXPATHLEN */ #endif #if _hdr_zone # include #endif #if ! defined (O_NOCTTY) # define O_NOCTTY 0 #endif #if ! defined (MAXPATHLEN) # if defined (_POSIX_PATH_MAX) # define MAXPATHLEN _POSIX_PATH_MAX # else # if defined (PATH_MAX) # define MAXPATHLEN PATH_MAX # endif # if defined (LPNMAX) # define MAXPATHLEN LPNMAX # endif # endif #endif #if ! defined (MAXPATHLEN) # define MAXPATHLEN 255 #endif #if _sys_fstyp /* HP-UX, Solaris */ # include /* FSTYPSZ */ # if defined (FSTYPSZ) # define DI_TYPE_LEN FSTYPSZ # endif #endif #if _sys_mount \ && ! defined (DI_INC_SYS_MOUNT) /* NetBSD */ # define DI_INC_SYS_MOUNT 1 # include /* MFSNAMELEN */ # if ! defined (DI_TYPE_LEN) && defined (MFSNAMELEN) # define DI_TYPE_LEN MFSNAMELEN # endif #endif #if _sys_vfstab /* ??? */ # include # if ! defined (DI_TYPE_LEN) && defined (FSTYPSZ) # define DI_TYPE_LEN FSTYPSZ # endif #endif #if ! defined (DI_TYPE_LEN) # define DI_TYPE_LEN 65 #endif #if ! _lib_memcpy && ! _define_memcpy # if ! _lib_bcopy && ! _define_bcopy #error No_memcpy/bcopy_available. # else # define memcpy(dst, src, cnt) (bcopy((src), (dst), (cnt)), dst) # endif #endif #if ! _lib_memset && ! _define_memset # if ! _lib_bzero && ! _define_bzero #error No_memset/bzero_available. # else # define memset(s,c,n) (bzero ((s), (n)), s) # endif #endif #define DI_NAME_LEN MAXPATHLEN #define DI_SPEC_NAME_LEN MAXPATHLEN #define DI_OPT_LEN MAXPATHLEN #define DI_MNT_TIME_LEN 24 #if _siz_long_long >= 4 typedef unsigned long long _fs_size_t; typedef long long _s_fs_size_t; # define DI_LL "ll" # define DI_LLu "llu" #else typedef unsigned long _fs_size_t; typedef long _s_fs_size_t; # define DI_LL "l" # define DI_LLu "lu" #endif #if _siz_long_double >= 8 && _printf_long_double typedef long double _print_size_t; # define DI_Lf "Lf" #else typedef double _print_size_t; # define DI_Lf "f" #endif typedef unsigned long __ulong; #if ! defined (TRUE) # define TRUE 1 #endif #if ! defined (FALSE) # define FALSE 0 #endif #define DI_PRNT_IGNORE 0 #define DI_PRNT_OK 1 #define DI_PRNT_BAD 2 #define DI_PRNT_OUTOFZONE 3 #define DI_PRNT_EXCLUDE 4 #define DI_PRNT_FORCE 5 #define DI_PRNT_SKIP 6 #define DI_MAIN_SORT_IDX 0 #define DI_TOT_SORT_IDX 1 typedef struct { unsigned int sortIndex [2]; _fs_size_t totalSpace; _fs_size_t freeSpace; _fs_size_t availSpace; _fs_size_t totalInodes; _fs_size_t freeInodes; _fs_size_t availInodes; __ulong st_dev; /* disk device number */ __ulong sp_dev; /* special device number */ __ulong sp_rdev; /* special rdev # */ char doPrint; /* do we want to print */ /* this entry? */ char printFlag; /* print flags */ char isLocal; /* is this mount point */ /* local? */ char isReadOnly; /* is this mount point */ /* read-only? */ char isLoopback; /* lofs or none fs type? */ char name [DI_NAME_LEN + 1]; /* mount point */ char special [DI_SPEC_NAME_LEN + 1]; /* special device name */ char fsType [DI_TYPE_LEN + 1]; /* type of file system */ char options [DI_OPT_LEN + 1]; char mountTime [DI_MNT_TIME_LEN + 1]; } diDiskInfo_t; typedef struct { char *special; char *name; char *type; Uid_t uid; Gid_t gid; _fs_size_t blockSize; _fs_size_t limit; _fs_size_t used; _fs_size_t ilimit; _fs_size_t iused; } diQuota_t; typedef struct { int count; char **list; } iList_t; #if ! _lib_zone_list # define zoneid_t int # define ZONENAME_MAX 65 #endif typedef struct { zoneid_t zoneid; char name [ZONENAME_MAX + 1]; char rootpath [MAXPATHLEN + 1]; Size_t rootpathlen; } zoneSummary_t; typedef struct { Uid_t uid; zoneid_t myzoneid; zoneSummary_t *zones; Uint_t zoneCount; char zoneDisplay [MAXPATHLEN + 1]; int globalIdx; } zoneInfo_t; #define DI_SORT_MAX 10 /* order from best to worst */ #define DI_EXIT_NORM 0 #define DI_EXIT_OK 1 #define DI_EXIT_WARN 2 #define DI_EXIT_FAIL 3 typedef struct { const char *formatString; _print_size_t dispBlockSize; _print_size_t baseDispSize; unsigned int baseDispIdx; char sortType [DI_SORT_MAX + 1]; unsigned int posix_compat; unsigned int quota_check; unsigned int csv_output; unsigned int csv_tabs; unsigned int excludeLoopback; unsigned int printTotals; unsigned int printDebugHeader; unsigned int printHeader; unsigned int displayAll; unsigned int localOnly; unsigned int dontResolveSymlink; unsigned int exitFlag; int errorCount; } diOptions_t; typedef struct { Size_t inodeWidth; Size_t maxMntTimeString; Size_t maxMountString; Size_t maxOptString; Size_t maxSpecialString; Size_t maxTypeString; Size_t width; const char *dispBlockLabel; char blockFormat [15]; char blockFormatNR [15]; /* no radix */ char inodeFormat [15]; char inodeLabelFormat [15]; char mountFormat [10]; char mTimeFormat [15]; char optFormat [15]; char specialFormat [15]; char typeFormat [10]; } diOutput_t; typedef struct { int count; int haspooledfs; int disppooledfs; int totsorted; diOptions_t options; diOutput_t output; diDiskInfo_t *diskInfo; iList_t ignoreList; iList_t includeList; zoneInfo_t zoneInfo; } diData_t; # if defined (__cplusplus) || defined (c_plusplus) extern "C" { # endif #if ! _dcl_errno extern int errno; #endif /* digetentries.c */ extern int di_getDiskEntries _((diDiskInfo_t **, int *)); /* digetinfo.c */ extern void di_getDiskInfo _((diDiskInfo_t **, int *)); /* diquota.c */ extern void diquota _((diQuota_t *)); /* strdup.c */ # if ! _lib_strdup extern char *strdup _((const char *)); # endif /* strstr.c */ # if ! _lib_strstr extern char *strstr _((const char *, const char *)); # endif /* trimchar.c */ extern void trimChar _((char *, int)); /* realloc.c */ extern _pvoid di_realloc _((_pvoid, Size_t)); /* didiskutil.c */ extern void di_initDiskInfo _((diDiskInfo_t *)); extern void di_saveBlockSizes _((diDiskInfo_t *, _fs_size_t, _fs_size_t, _fs_size_t, _fs_size_t)); extern void di_saveInodeSizes _((diDiskInfo_t *, _fs_size_t, _fs_size_t, _fs_size_t)); #if _lib_getmntent \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_mntctl \ && ! _class_os__Volumes extern char *chkMountOptions _((const char *, const char *)); #endif extern void convertMountOptions _((unsigned long, diDiskInfo_t *)); extern void convertNFSMountOptions _((long, long, long, diDiskInfo_t *)); extern void di_testRemoteDisk _((diDiskInfo_t *)); extern int di_isPooledFs _((diDiskInfo_t *)); extern int di_isLoopbackFs _((diDiskInfo_t *)); extern Size_t di_mungePoolName _((char *)); # if defined (__cplusplus) || defined (c_plusplus) } # endif /* macro for gettext() */ #ifndef DI_GT # if _enable_nls # define DI_GT(args) gettext(args) # else # define DI_GT(args) (args) # endif #endif # if _lib_sys_dollar_device_scan && _lib_sys_dollar_getdviw /* Thanks to Craig Berry's VMS::Device for the VMS code. */ typedef struct { short buflen; /* Length of output buffer */ short itmcode; /* Item code */ void *buffer; /* Buffer address */ void *retlen; /* Return length address */ } VMS_ITMLST; # define DVI_IS_STRING 1 # define DVI_IS_LONGWORD 2 # define DVI_IS_QUADWORD 3 # define DVI_IS_WORD 4 # define DVI_IS_BYTE 5 # define DVI_IS_VMSDATE 6 # define DVI_IS_BITMAP 7 /* Each bit in the return value indicates something */ # define DVI_IS_ENUM 8 /* Each returned value has a name, and we ought to */ /* return the name instead of the value */ # define DVI_IS_ODD 9 /* A catchall */ # define DVI_IS_INPUT (1<<0) # define DVI_IS_OUTPUT (1<<1) # define DVI_ENT(a, b, c) {#a, DVI$_##a, b, c, DVI_IS_OUTPUT} typedef struct { char *name; /* Pointer to the item name */ int syscallValue; /* Value to use in the getDVI item list */ int bufferLen; /* Length the return va buf needs to be. (no nul */ /* terminators, so must be careful with the return */ /* values. */ int returnType; /* Type of data the item returns */ int inOut; /* Is this an input or an output item? */ } genericID_t ; /* Macro to fill in a 'traditional' item-list entry */ # define init_itemlist(ile, length, code, bufaddr, retlen_addr) \ { \ (ile)->buflen = (length); \ (ile)->itmcode = (code); \ (ile)->buffer = (bufaddr); \ (ile)->retlen = (retlen_addr) ;} # endif #endif /* DI_INC_DI_H */ di-4.47/C/configs/0000755000175000017500000000000013334050206011756 5ustar bllblldi-4.47/C/configs/config.ultrix.cc0000644000175000017500000001530013334050206015057 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 /* ULTRIX requires time.h for rpc/rpc.h */ /* ULTRIX requires rpc/rpc.h for rpcsvc/rquota.h */ #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 0 #define _param_void_star 1 #define _proto_stdc 0 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 1 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 1 #define _hdr_malloc 1 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 0 #define _hdr_mnttab 0 #define _hdr_time 1 #define _hdr_quota 0 #define _hdr_rpc_rpc 1 #define _hdr_rpcsvc_rquota 1 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 0 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 1 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 1 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 0 #define _sys_time 1 #define _sys_vfs 0 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 0 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 1 #define _typ_struct_dqblk 1 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 0 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 0 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 1 #define _lib_getmntent 0 #define _lib_getmntinfo 0 #define _lib_gettext 1 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 0 #define _lib_lstat 1 #define _lib_mbrlen 0 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 0 #define _lib_realpath 0 #define _lib_setlocale 1 #define _lib_setmntent 0 #define _lib_snprintf 0 #define _lib_statfs 1 #define _lib_statvfs 0 #define _lib_strcoll 1 #define _lib_strdup 0 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 0 #define _lib_vquotactl 0 #define _lib_xdr_int 1 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define xdr_rq_bhardlimit xdr_u_long #define _memberxdr_rquota_rq_bhardlimit 1 #define xdr_rq_bsoftlimit xdr_u_long #define _memberxdr_rquota_rq_bsoftlimit 1 #define xdr_rq_curblocks xdr_u_long #define _memberxdr_rquota_rq_curblocks 1 #define xdr_rq_fhardlimit xdr_u_long #define _memberxdr_rquota_rq_fhardlimit 1 #define xdr_rq_fsoftlimit xdr_u_long #define _memberxdr_rquota_rq_fsoftlimit 1 #define xdr_rq_curfiles xdr_u_long #define _memberxdr_rquota_rq_curfiles 1 #define _mem_struct_mnttab_mt_mntopts 0 #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _args_quotactl 0 #define _quotactl_pos_1 0 #define _quotactl_pos_2 0 #define _args_setmntent 0 #define _args_statfs 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct fs_data #define _c_type_statfs int #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 1 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_getquota_rslt_gqr_status 1 #define _mem_struct_getquota_rslt_gqr_rquota 1 #define _mem_struct_statfs_f_bsize 0 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 0 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 0 #define _siz_long_double 0 #define _printf_long_double 0 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.hpux.bcc0000644000175000017500000001556413334050206014672 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 0 #define _param_void_star 1 #define _proto_stdc 0 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 1 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 1 #define _hdr_malloc 1 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 1 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 0 #define _hdr_rpcsvc_rquota 1 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 1 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 1 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 1 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 1 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 1 #define _sys_time 1 #define _sys_vfs 1 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 1 #define _cmd_loc_msgfmt "/usr/bin/msgfmt" #define _command_rpmbuild 0 #define _const_O_NOCTTY 1 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 1 #define _typ_struct_dqblk 1 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 0 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 1 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 1 #define _lib_getmntinfo 0 #define _lib_gettext 1 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 1 #define _lib_lstat 1 #define _lib_mbrlen 0 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 1 #define _lib_realpath 1 #define _lib_setlocale 1 #define _lib_setmntent 1 #define _lib_snprintf 1 #define _lib_statfs 1 #define _lib_statvfs 1 #define _lib_strcoll 1 #define _lib_strdup 1 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 1 #define _lib_textdomain 0 #define _lib_vquotactl 0 #define _lib_xdr_int 1 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define xdr_rq_bhardlimit xdr_u_long #define _memberxdr_rquota_rq_bhardlimit 1 #define xdr_rq_bsoftlimit xdr_u_long #define _memberxdr_rquota_rq_bsoftlimit 1 #define xdr_rq_curblocks xdr_u_long #define _memberxdr_rquota_rq_curblocks 1 #define xdr_rq_fhardlimit xdr_u_long #define _memberxdr_rquota_rq_fhardlimit 1 #define xdr_rq_fsoftlimit xdr_u_long #define _memberxdr_rquota_rq_fsoftlimit 1 #define xdr_rq_curfiles xdr_u_long #define _memberxdr_rquota_rq_curfiles 1 #define _mem_struct_mnttab_mt_mntopts 0 #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _args_quotactl 4 #define _c_arg_1__quotactl int #define _c_arg_2__quotactl char * #define _c_arg_3__quotactl int #define _c_arg_4__quotactl caddr_t #define _quotactl_pos_1 0 #define _quotactl_pos_2 1 #define _c_arg_1_setmntent char * #define _c_arg_2_setmntent char * #define _c_type_setmntent FILE * #define _args_setmntent 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct statfs * #define _c_type_statfs int #define _args_statfs 2 #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_libquota 1 #define _npt_mntctl 1 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 1 #define _mem_struct_dqblk_dqb_fhardlimit 1 #define _mem_struct_dqblk_dqb_fsoftlimit 1 #define _mem_struct_dqblk_dqb_curfiles 1 #define _mem_struct_getquota_rslt_gqr_status 1 #define _mem_struct_getquota_rslt_gqr_rquota 1 #define _mem_struct_statfs_f_bsize 1 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 1 #define _mem_struct_statvfs_f_basetype 1 #define _siz_long_long 8 #define _siz_long_double 0 #define _printf_long_double 0 #define _has_std_quotas 1 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.vms0000644000175000017500000001441213334050206013754 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 0 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 #define _hdr_ctype 1 #define _hdr_dcdef 1 #define _hdr_descrip 1 #define _hdr_dirent 1 #define _hdr_dvidef 1 #define _hdr_dvsdef 1 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 1 #define _hdr_malloc 0 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 0 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 0 #define _hdr_rpcsvc_rquota 0 #define _hdr_ssdef 1 #define _hdr_starlet 1 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 1 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 0 #define _sys_quota 0 #define _sys_stat 1 #define _sys_statfs 1 #define _sys_statvfs 1 #define _sys_time 1 #define _sys_vfs 0 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 1 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 0 #define _typ_struct_dqblk 0 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 1 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 0 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 0 #define _lib_getmntinfo 0 #define _lib_gettext 1 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 1 #define _lib_lstat 0 #define _lib_mbrlen 1 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 0 #define _lib_realpath 0 #define _lib_setlocale 1 #define _lib_setmntent 0 #define _lib_snprintf 1 #define _lib_statfs 0 #define _lib_statvfs 0 #define _lib_strcoll 1 #define _lib_strdup 1 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 1 #define _lib_sys_dollar_getdviw 1 #define _lib_sysfs 0 #define _lib_textdomain 1 #define _lib_vquotactl 0 #define _lib_xdr_int 0 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define _memberxdr_rquota_rq_bhardlimit 0 #define _memberxdr_rquota_rq_bsoftlimit 0 #define _memberxdr_rquota_rq_curblocks 0 #define _memberxdr_rquota_rq_fhardlimit 0 #define _memberxdr_rquota_rq_fsoftlimit 0 #define _memberxdr_rquota_rq_curfiles 0 #define _mem_struct_mnttab_mt_mntopts 0 #define _memberxdr_getquota_args_gqa_uid 0 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _args_quotactl 0 #define _quotactl_pos_1 0 #define _quotactl_pos_2 0 #define _args_setmntent 0 #define _args_statfs 0 #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 0 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_statfs_f_bsize 0 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 0 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 8 #define _siz_long_double 12 #define _printf_long_double 1 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.bsd43.cc0000644000175000017500000001554313334050206014460 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 0 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 0 #define _param_void_star 0 #define _proto_stdc 0 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 0 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 0 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 0 #define _hdr_malloc 0 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 1 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 1 #define _hdr_rpcsvc_rquota 0 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 1 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 0 #define _hdr_util_string 0 #define _hdr_wchar 0 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 0 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 0 #define _sys_time 1 #define _sys_vfs 1 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 0 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 0 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 1 #define _typ_struct_dqblk 1 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 0 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 1 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 1 #define _lib_getmntinfo 0 #define _lib_gettext 0 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 1 #define _lib_lstat 1 #define _lib_mbrlen 0 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 1 #define _lib_realpath 0 #define _lib_setlocale 0 #define _lib_setmntent 1 #define _lib_snprintf 0 #define _lib_statfs 1 #define _lib_statvfs 0 #define _lib_strcoll 0 #define _lib_strdup 0 #define _lib_strstr 0 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 0 #define _lib_vquotactl 0 #define _lib_xdr_int 1 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define xdr_rq_bhardlimit xdr_u_long #define _memberxdr_rquota_rq_bhardlimit 1 #define xdr_rq_bsoftlimit xdr_u_long #define _memberxdr_rquota_rq_bsoftlimit 1 #define xdr_rq_curblocks xdr_u_long #define _memberxdr_rquota_rq_curblocks 1 #define xdr_rq_fhardlimit xdr_u_long #define _memberxdr_rquota_rq_fhardlimit 1 #define xdr_rq_fsoftlimit xdr_u_long #define _memberxdr_rquota_rq_fsoftlimit 1 #define xdr_rq_curfiles xdr_u_long #define _memberxdr_rquota_rq_curfiles 1 #define _mem_struct_mnttab_mt_mntopts 0 #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _c_arg_1_quotactl int #define _c_arg_2_quotactl char * #define _c_arg_3_quotactl int #define _c_arg_4_quotactl caddr_t #define _c_type_quotactl int #define _args_quotactl 4 #define _quotactl_pos_1 0 #define _quotactl_pos_2 1 #define _c_arg_1_setmntent char * #define _c_arg_2_setmntent char * #define _c_type_setmntent FILE * #define _args_setmntent 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct statfs * #define _c_type_statfs int #define _args_statfs 2 #define _class_os__Volumes 0 #define _npt_getenv 1 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 1 #define _dcl_errno 0 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 1 #define _mem_struct_dqblk_dqb_fhardlimit 1 #define _mem_struct_dqblk_dqb_fsoftlimit 1 #define _mem_struct_dqblk_dqb_curfiles 1 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_statfs_f_bsize 1 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 1 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 0 #define _siz_long_double 0 #define _printf_long_double 0 #define _has_std_quotas 1 #define _has_std_nfs_quotas 1 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.bsd43.gcc0000644000175000017500000001554213334050206014626 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 0 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 0 #define _hdr_malloc 0 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 1 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 1 #define _hdr_rpcsvc_rquota 0 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 1 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 0 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 0 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 0 #define _sys_time 1 #define _sys_vfs 1 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 0 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 1 #define _typ_struct_dqblk 1 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 0 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 1 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 1 #define _lib_getmntinfo 0 #define _lib_gettext 0 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 1 #define _lib_lstat 1 #define _lib_mbrlen 0 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 1 #define _lib_realpath 0 #define _lib_setlocale 0 #define _lib_setmntent 1 #define _lib_snprintf 0 #define _lib_statfs 1 #define _lib_statvfs 0 #define _lib_strcoll 0 #define _lib_strdup 0 #define _lib_strstr 0 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 0 #define _lib_vquotactl 0 #define _lib_xdr_int 1 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define xdr_rq_bhardlimit xdr_u_long #define _memberxdr_rquota_rq_bhardlimit 1 #define xdr_rq_bsoftlimit xdr_u_long #define _memberxdr_rquota_rq_bsoftlimit 1 #define xdr_rq_curblocks xdr_u_long #define _memberxdr_rquota_rq_curblocks 1 #define xdr_rq_fhardlimit xdr_u_long #define _memberxdr_rquota_rq_fhardlimit 1 #define xdr_rq_fsoftlimit xdr_u_long #define _memberxdr_rquota_rq_fsoftlimit 1 #define xdr_rq_curfiles xdr_u_long #define _memberxdr_rquota_rq_curfiles 1 #define _mem_struct_mnttab_mt_mntopts 0 #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _c_arg_1_quotactl int #define _c_arg_2_quotactl char * #define _c_arg_3_quotactl int #define _c_arg_4_quotactl caddr_t #define _c_type_quotactl int #define _args_quotactl 4 #define _quotactl_pos_1 0 #define _quotactl_pos_2 1 #define _c_arg_1_setmntent char * #define _c_arg_2_setmntent char * #define _c_type_setmntent FILE * #define _args_setmntent 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct statfs * #define _c_type_statfs int #define _args_statfs 2 #define _class_os__Volumes 0 #define _npt_getenv 1 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 1 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 1 #define _mem_struct_dqblk_dqb_fhardlimit 1 #define _mem_struct_dqblk_dqb_fsoftlimit 1 #define _mem_struct_dqblk_dqb_curfiles 1 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_statfs_f_bsize 1 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 1 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 8 #define _siz_long_double 0 #define _printf_long_double 0 #define _has_std_quotas 1 #define _has_std_nfs_quotas 1 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.ultrix.gcc0000644000175000017500000001530013334050206015226 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 /* ULTRIX requires time.h for rpc/rpc.h */ /* ULTRIX requires rpc/rpc.h for rpcsvc/rquota.h */ #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 1 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 1 #define _hdr_libprop_proplib 0 #define _hdr_locale 1 #define _hdr_malloc 1 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 0 #define _hdr_mnttab 0 #define _hdr_time 1 #define _hdr_quota 0 #define _hdr_rpc_rpc 1 #define _hdr_rpcsvc_rquota 1 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 0 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 1 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 1 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 0 #define _sys_time 1 #define _sys_vfs 0 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 0 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 1 #define _typ_struct_dqblk 1 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 1 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 0 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 1 #define _lib_getmntent 0 #define _lib_getmntinfo 0 #define _lib_gettext 1 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 0 #define _lib_lstat 1 #define _lib_mbrlen 0 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 0 #define _lib_realpath 0 #define _lib_setlocale 1 #define _lib_setmntent 0 #define _lib_snprintf 0 #define _lib_statfs 1 #define _lib_statvfs 0 #define _lib_strcoll 1 #define _lib_strdup 0 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 1 #define _lib_vquotactl 0 #define _lib_xdr_int 1 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define xdr_rq_bhardlimit xdr_u_long #define _memberxdr_rquota_rq_bhardlimit 1 #define xdr_rq_bsoftlimit xdr_u_long #define _memberxdr_rquota_rq_bsoftlimit 1 #define xdr_rq_curblocks xdr_u_long #define _memberxdr_rquota_rq_curblocks 1 #define xdr_rq_fhardlimit xdr_u_long #define _memberxdr_rquota_rq_fhardlimit 1 #define xdr_rq_fsoftlimit xdr_u_long #define _memberxdr_rquota_rq_fsoftlimit 1 #define xdr_rq_curfiles xdr_u_long #define _memberxdr_rquota_rq_curfiles 1 #define _mem_struct_mnttab_mt_mntopts 0 #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _args_quotactl 0 #define _quotactl_pos_1 0 #define _quotactl_pos_2 0 #define _args_setmntent 0 #define _args_statfs 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct fs_data #define _c_type_statfs int #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 1 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_getquota_rslt_gqr_status 1 #define _mem_struct_getquota_rslt_gqr_rquota 1 #define _mem_struct_statfs_f_bsize 0 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 0 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 8 #define _siz_long_double 8 #define _printf_long_double 1 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 1 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.vms.b0000644000175000017500000001441113334050206014173 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 0 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 #define _hdr_ctype 1 #define _hdr_dcdef 1 #define _hdr_descrip 1 #define _hdr_dirent 1 #define _hdr_dvidef 1 #define _hdr_dvsdef 1 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_locale 1 #define _hdr_malloc 0 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 0 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 0 #define _hdr_rpcsvc_rquota 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_ssdef 1 #define _hdr_starlet 1 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 1 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 0 #define _sys_quota 0 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 0 #define _sys_time 1 #define _sys_vfs 0 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 1 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 0 #define _typ_struct_dqblk 0 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 1 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 0 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 0 #define _lib_getmntinfo 0 #define _lib_gettext 1 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 1 #define _lib_lstat 0 #define _lib_mbrlen 1 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 0 #define _lib_realpath 0 #define _lib_setlocale 1 #define _lib_setmntent 0 #define _lib_snprintf 0 #define _lib_statfs 0 #define _lib_statvfs 0 #define _lib_strcoll 1 #define _lib_strdup 1 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 1 #define _lib_sys_dollar_getdviw 1 #define _lib_sysfs 0 #define _lib_textdomain 1 #define _lib_vquotactl 0 #define _lib_xdr_int 0 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define _memberxdr_rquota_rq_bhardlimit 0 #define _memberxdr_rquota_rq_bsoftlimit 0 #define _memberxdr_rquota_rq_curblocks 0 #define _memberxdr_rquota_rq_fhardlimit 0 #define _memberxdr_rquota_rq_fsoftlimit 0 #define _memberxdr_rquota_rq_curfiles 0 #define _mem_struct_mnttab_mt_mntopts 0 #define _memberxdr_getquota_args_gqa_uid 0 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _args_quotactl 0 #define _quotactl_pos_1 0 #define _quotactl_pos_2 0 #define _args_setmntent 0 #define _args_statfs 0 #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 0 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_statfs_f_bsize 0 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 0 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 0 #define _siz_long_double 0 #define _printf_long_double 0 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/conf.xenix.cc0000644000175000017500000001577613334050206014364 0ustar bllbll#ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 0 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 0 #define _param_void_star 1 #define _proto_stdc 0 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 1 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 0 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 0 #define _hdr_malloc 1 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 0 #define _hdr_mnttab 1 #define _hdr_quota 0 #define _hdr_rpc_rpc 0 #define _hdr_rpcsvc_rquota 0 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 0 #define _hdr_time 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 0 #define _hdr_util_string 0 #define _hdr_wchar 0 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 0 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 0 #define _sys_stat 1 #define _sys_statfs 1 #define _sys_statvfs 0 #define _sys_time 0 #define _sys_vfs 0 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _command_rpmbuild 0 #define _const_O_NOCTTY 0 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 0 #define _typ_struct_dqblk 0 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 0 #define _typ_statvfs_t 0 #define _typ_size_t 0 #define _typ_uint_t 0 #define _typ_uid_t 0 #define _lib_bcopy 0 #define _lib_bindtextdomain 0 #define _lib_bzero 0 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 0 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 0 #define _lib_getmntinfo 0 #define _lib_gettext 0 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 0 #define _lib_lstat 0 #define _lib_mbrlen 0 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 0 #define _lib_realpath 0 #define _lib_setlocale 0 #define _lib_setmntent 0 #define _lib_snprintf 0 #define _lib_statfs 1 #define _lib_statvfs 0 #define _lib_strcoll 0 #define _lib_strdup 0 #define _lib_strstr 0 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 0 #define _lib_vquotactl 0 #define _lib_xdr_int 1 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define xdr_rq_bhardlimit xdr_u_long #define _memberxdr_rquota_rq_bhardlimit 1 #define xdr_rq_bsoftlimit xdr_u_long #define _memberxdr_rquota_rq_bsoftlimit 1 #define xdr_rq_curblocks xdr_u_long #define _memberxdr_rquota_rq_curblocks 1 #define xdr_rq_fhardlimit xdr_u_long #define _memberxdr_rquota_rq_fhardlimit 1 #define xdr_rq_fsoftlimit xdr_u_long #define _memberxdr_rquota_rq_fsoftlimit 1 #define xdr_rq_curfiles xdr_u_long #define _memberxdr_rquota_rq_curfiles 1 #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _c_arg_1_quotactl int #define _c_arg_2_quotactl char * #define _c_arg_3_quotactl int #define _c_arg_4_quotactl caddr_t #define _c_type_quotactl int #define _args_quotactl 4 #define _quotactl_pos_1 0 #define _quotactl_pos_2 1 #define _c_arg_1_setmntent char * #define _c_arg_2_setmntent char * #define _c_type_setmntent FILE * #define _args_setmntent 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct statfs * #define _c_arg_3_statfs size_t #define _c_arg_4_statfs int #define _c_type_statfs int #define _args_statfs 4 #define _class_os__Volumes 0 #define _npt_getenv 1 #define _npt_getmnt 1 #define _npt_libquota 0 #define _npt_mntctl 1 #define _npt_statfs 1 #define _dcl_errno 0 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 0 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_mnttab_mt_mntopts 0 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_statfs_f_bsize 1 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 1 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 1 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 0 #define _siz_long_double 0 #define _printf_long_double 0 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_statvfs_t # define Statvfs_t statvfs_t #else # define Statvfs_t struct statvfs #endif #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.cygwin.gcc0000644000175000017500000001554413334050206015211 0ustar bllbll/* Created on: Fri Jan 22 10:41:21 PST 2016 From: ../features/mkconfig.dat Using: mkconfig-1.27 */ #ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 1 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 1 #define _hdr_libprop_proplib 0 #define _hdr_locale 1 #define _hdr_malloc 1 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 1 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 0 #define _hdr_rpcsvc_rquota 0 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 1 #define _hdr_windows 0 #define _hdr_winioctl 0 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 1 #define _sys_quota 1 #define _sys_stat 1 #define _sys_statfs 1 #define _sys_statvfs 1 #define _sys_time 1 #define _sys_vfs 1 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 1 #define _cmd_loc_msgfmt "/usr/bin/msgfmt" #define _command_rpmbuild 0 #define _const_O_NOCTTY 1 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 1 #define _define_S_ISLNK 1 #define _typ_struct_dqblk 1 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 1 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 1 #define _lib_bcopy 1 #define _lib_bindtextdomain 1 #define _lib_bzero 1 #define _lib_CreateFile 0 #define _lib_DeviceIoControl 0 #define _lib_endmntent 1 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 0 #define _lib_GetDiskFreeSpaceEx 0 #define _lib_GetDriveType 0 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 0 #define _lib_GetVolumeInformation 0 #define _lib_getmnt 0 #define _lib_getmntent 1 #define _lib_getmntinfo 0 #define _lib_gettext 1 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 0 #define _lib_lstat 1 #define _lib_mbrlen 1 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 1 #define _lib_realpath 1 #define _lib_setlocale 1 #define _lib_setmntent 1 #define _lib_snprintf 1 #define _lib_statfs 1 #define _lib_statvfs 1 #define _lib_strcoll 1 #define _lib_strdup 1 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 1 #define _lib_vquotactl 0 #define _lib_xdr_int 0 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define _memberxdr_rquota_rq_bhardlimit 0 #define _memberxdr_rquota_rq_bsoftlimit 0 #define _memberxdr_rquota_rq_curblocks 0 #define _memberxdr_rquota_rq_fhardlimit 0 #define _memberxdr_rquota_rq_fsoftlimit 0 #define _memberxdr_rquota_rq_curfiles 0 #define _memberxdr_getquota_args_gqa_uid 0 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _c_arg_1_quotactl int #define _c_arg_2_quotactl char * #define _c_arg_3_quotactl int #define _c_arg_4_quotactl caddr_t #define _c_type_quotactl int #define _args_quotactl 4 #define _quotactl_pos_1 0 #define _quotactl_pos_2 1 #define _c_arg_1_setmntent char * #define _c_arg_2_setmntent char * #define _c_type_setmntent FILE * #define _args_setmntent 2 #define _c_arg_1_statfs char * #define _c_arg_2_statfs struct statfs * #define _c_type_statfs int #define _args_statfs 2 #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_mntctl 1 #define _npt_quotactl 0 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 1 #define _mem_struct_dqblk_dqb_curblocks 0 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_mnttab_mt_mntopts 0 #define _mem_struct_statfs_f_bsize 1 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 1 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 8 #define _siz_long_double 16 #define _printf_long_double 1 #define _has_std_quotas 1 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 1 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_statvfs_t # define Statvfs_t statvfs_t #else # define Statvfs_t struct statvfs #endif #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/configs/config.mingw0000644000175000017500000001500113334050206014263 0ustar bllbll/* Created on: Fri Jan 22 10:38:48 PST 2016 From: ../features/mkconfig.dat Using: mkconfig-1.27 */ #ifndef __INC_CONFIG_H #define __INC_CONFIG_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 #define _hdr_ctype 1 #define _hdr_dcdef 0 #define _hdr_descrip 0 #define _hdr_dirent 1 #define _hdr_dvidef 0 #define _hdr_dvsdef 0 #define _hdr_errno 1 #define _hdr_fcntl 1 #define _hdr_fshelp 0 #define _hdr_gui_window 0 #define _hdr_jfs_quota 0 #define _hdr_kernel_fs_info 0 #define _hdr_limits 1 #define _hdr_linux_dqblk_xfs 0 #define _hdr_linux_quota 0 #define _hdr_libintl 0 #define _hdr_libprop_proplib 0 #define _hdr_locale 0 #define _hdr_malloc 1 #define _hdr_mcheck 0 #define _hdr_memory 1 #define _hdr_mntent 0 #define _hdr_mnttab 0 #define _hdr_quota 0 #define _hdr_rpc_rpc 0 #define _hdr_rpcsvc_rquota 0 #define _hdr_ssdef 0 #define _hdr_starlet 0 #define _hdr_storage_Directory 0 #define _hdr_storage_Entry 0 #define _hdr_storage_Path 0 #define _hdr_storage_volumes 0 #define _hdr_string 1 #define _hdr_strings 1 #define _hdr_time 1 #define _hdr_ufs_quota 0 #define _hdr_ufs_ufs_quota 0 #define _hdr_unistd 1 #define _hdr_util_string 0 #define _hdr_wchar 1 #define _hdr_windows 1 #define _hdr_winioctl 1 #define _hdr_zone 0 #define _sys_dcmd_blk 0 #define _sys_file 1 #define _sys_fs_types 0 #define _sys_fs_ufs_quota 0 #define _sys_fstyp 0 #define _sys_fstypes 0 #define _sys_ftype 0 #define _sys_io 0 #define _sys_mntctl 0 #define _sys_mntent 0 #define _sys_mnttab 0 #define _sys_mount 0 #define _sys_quota 0 #define _sys_stat 1 #define _sys_statfs 0 #define _sys_statvfs 0 #define _sys_time 1 #define _sys_vfs 0 #define _sys_vfs_quota 0 #define _sys_vfstab 0 #define _sys_vmount 0 #define _inc_conflict__hdr_time__sys_time 1 #define _inc_conflict__sys_quota__hdr_linux_quota 1 #define _command_msgfmt 0 #define _cmd_loc_msgfmt "/usr/bin/msgfmt" #define _command_rpmbuild 0 #define _const_O_NOCTTY 0 #define _define_bcopy 0 #define _define_bzero 0 #define _define_MCTL_QUERY 0 #define _define_memcpy 0 #define _define_memset 0 #define _define_QCMD 0 #define _define_S_ISLNK 0 #define _typ_struct_dqblk 0 #define _typ_struct_quotaval 0 #define _typ_struct_ufs_dqblk 0 #define _typ_fs_disk_quota_t 0 #define _typ_gid_t 0 #define _typ_statvfs_t 0 #define _typ_size_t 1 #define _typ_uint_t 0 #define _typ_uid_t 0 #define _lib_bcopy 0 #define _lib_bindtextdomain 0 #define _lib_bzero 0 #define _lib_CreateFile 1 #define _lib_DeviceIoControl 1 #define _lib_endmntent 0 #define _lib_fs_stat_dev 0 #define _lib_fshelp 0 #define _lib_GetDiskFreeSpace 1 #define _lib_GetDiskFreeSpaceEx 1 #define _lib_GetDriveType 1 #define _lib_getfsstat 0 #define _lib_GetLogicalDriveStrings 1 #define _lib_GetVolumeInformation 1 #define _lib_getmnt 0 #define _lib_getmntent 0 #define _lib_getmntinfo 0 #define _lib_gettext 0 #define _lib_getvfsstat 0 #define _lib_getzoneid 0 #define _lib_hasmntopt 0 #define _lib_lstat 0 #define _lib_mbrlen 1 #define _lib_mcheck_pedantic 0 #define _lib_memcpy 1 #define _lib_memset 1 #define _lib_mntctl 0 #define _lib_next_dev 0 #define _lib_prop_dictionary_create 0 #define _lib_quota_open 0 #define _lib_quotactl 0 #define _lib_realpath 0 #define _lib_setlocale 0 #define _lib_setmntent 0 #define _lib_snprintf 1 #define _lib_statfs 0 #define _lib_statvfs 0 #define _lib_strcoll 1 #define _lib_strdup 1 #define _lib_strstr 1 #define _lib_sys_dollar_device_scan 0 #define _lib_sys_dollar_getdviw 0 #define _lib_sysfs 0 #define _lib_textdomain 0 #define _lib_vquotactl 0 #define _lib_xdr_int 0 #define _lib_zone_getattr 0 #define _lib_zone_list 0 #define _memberxdr_rquota_rq_bhardlimit 0 #define _memberxdr_rquota_rq_bsoftlimit 0 #define _memberxdr_rquota_rq_curblocks 0 #define _memberxdr_rquota_rq_fhardlimit 0 #define _memberxdr_rquota_rq_fsoftlimit 0 #define _memberxdr_rquota_rq_curfiles 0 #define _memberxdr_getquota_args_gqa_uid 0 #define _args_getfsstat 0 #define _args_getvfsstat 0 #define _args_quotactl 0 #define _quotactl_pos_1 0 #define _quotactl_pos_2 0 #define _args_setmntent 0 #define _args_statfs 0 #define _class_os__Volumes 0 #define _npt_getenv 0 #define _npt_getmnt 1 #define _npt_mntctl 1 #define _npt_quotactl 1 #define _npt_statfs 0 #define _dcl_errno 1 #define _dcl_mnt_names 0 #define _mem_struct_dqblk_dqb_curspace 0 #define _mem_struct_dqblk_dqb_curblocks 0 #define _mem_struct_dqblk_dqb_fhardlimit 0 #define _mem_struct_dqblk_dqb_fsoftlimit 0 #define _mem_struct_dqblk_dqb_curfiles 0 #define _mem_struct_getquota_rslt_gqr_status 0 #define _mem_struct_getquota_rslt_gqr_rquota 0 #define _mem_struct_mnttab_mt_mntopts 0 #define _mem_struct_statfs_f_bsize 0 #define _mem_struct_statfs_f_fsize 0 #define _mem_struct_statfs_f_fstyp 0 #define _mem_struct_statfs_f_iosize 0 #define _mem_struct_statfs_f_frsize 0 #define _mem_struct_statfs_f_fstypename 0 #define _mem_struct_statfs_mount_info 0 #define _mem_struct_statfs_f_type 0 #define _mem_struct_statvfs_f_basetype 0 #define _siz_long_long 8 #define _siz_long_double 16 #define _printf_long_double 0 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _use_mcheck 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #ifndef __MKC_STANDARD_DEFS # define __MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* __MKC_STANDARD_DEFS */ #if _typ_statvfs_t # define Statvfs_t statvfs_t #else # define Statvfs_t struct statvfs #endif #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif #endif /* __INC_CONFIG_H */ di-4.47/C/didiskutil.c0000644000175000017500000003167213334050206012650 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #include "dimntopt.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _hdr_memory # include #endif #if _hdr_malloc # include #endif #if _hdr_errno # include #endif #if _use_mcheck # include #endif /********************************************************/ /* This module contains utility routines for conversion and checking the data. di_initDiskInfo () initialize disk info structure di_saveBlockSizes () save the block sizes in the diskinfo structure. di_saveInodeSizes () save the inode sizes in the diskinfo structure. convertMountOptions () converts mount options to text format. convertNFSMountOptions () converts NFS mount options to text format. chkMountOptions () Checks to see if the mount option is set. Used if hasmntopt() is not present. di_testRemoteDisk () test a disk to see if it is remote (nfs, nfs3). */ void #if _proto_stdc di_initDiskInfo (diDiskInfo_t *diptr) #else di_initDiskInfo (diptr) diDiskInfo_t *diptr; #endif { memset ((char *) diptr, '\0', sizeof (diDiskInfo_t)); diptr->printFlag = DI_PRNT_OK; diptr->isLocal = TRUE; diptr->isReadOnly = FALSE; diptr->isLoopback = FALSE; } void #if _proto_stdc di_saveBlockSizes (diDiskInfo_t *diptr, _fs_size_t block_size, _fs_size_t total_blocks, _fs_size_t free_blocks, _fs_size_t avail_blocks) #else di_saveBlockSizes (diptr, block_size, total_blocks, free_blocks, avail_blocks) diDiskInfo_t *diptr; _fs_size_t block_size; _fs_size_t total_blocks; _fs_size_t free_blocks; _fs_size_t avail_blocks; #endif { diptr->totalSpace = (_fs_size_t) total_blocks * (_fs_size_t) block_size; diptr->freeSpace = (_fs_size_t) free_blocks * (_fs_size_t) block_size; diptr->availSpace = (_fs_size_t) avail_blocks * (_fs_size_t) block_size; } void #if _proto_stdc di_saveInodeSizes (diDiskInfo_t *diptr, _fs_size_t total_nodes, _fs_size_t free_nodes, _fs_size_t avail_nodes) #else di_saveInodeSizes (diptr, total_nodes, free_nodes, avail_nodes) diDiskInfo_t *diptr; _fs_size_t total_nodes; _fs_size_t free_nodes; _fs_size_t avail_nodes; #endif { diptr->totalInodes = total_nodes; diptr->freeInodes = free_nodes; diptr->availInodes = avail_nodes; } void #if _proto_stdc convertMountOptions (unsigned long flags, diDiskInfo_t *diptr) #else convertMountOptions (flags, diptr) unsigned long flags; diDiskInfo_t *diptr; #endif { #if defined (MNT_RDONLY) if ((flags & MNT_RDONLY) == MNT_RDONLY) { strncat (diptr->options, "ro,", DI_OPT_LEN - strlen (diptr->options) - 1); } else { strncat (diptr->options, "rw,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_EXRDONLY) if ((flags & MNT_EXRDONLY) == MNT_EXRDONLY) { strncat (diptr->options, "expro,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_DEFEXPORTED) if ((flags & MNT_DEFEXPORTED) == MNT_DEFEXPORTED) { strncat (diptr->options, "exprwany,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_EXPORTANON) if ((flags & MNT_EXPORTANON) == MNT_EXPORTANON) { strncat (diptr->options, "expanon,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_EXKERB) if ((flags & MNT_EXKERB) == MNT_EXKERB) { strncat (diptr->options, "expkerb,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_FORCE) if ((flags & MNT_FORCE) == MNT_FORCE) { strncat (diptr->options, "force,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_GRPID) if ((flags & MNT_GRPID) == MNT_GRPID) { strncat (diptr->options, "grpid,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_MAGICLINKS) if ((flags & MNT_MAGICLINKS) == MNT_MAGICLINKS) { strncat (diptr->options, "magiclinks,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_MLSD) if ((flags & MNT_MLSD) == MNT_MLSD) { strncat (diptr->options, "mlsd,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NOATIMES) if ((flags & MNT_NOATIMES) == MNT_NOATIMES) { strncat (diptr->options, "noatime,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NOCACHE) if ((flags & MNT_NOCACHE) == MNT_NOCACHE) { strncat (diptr->options, "nocache,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NOCOREDUMP) if ((flags & MNT_NOCOREDUMP) == MNT_NOCOREDUMP) { strncat (diptr->options, "nocoredump,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NODEV) if ((flags & MNT_NODEV) == MNT_NODEV) { strncat (diptr->options, "nodev,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NODEVMTIME) if ((flags & MNT_NODEVMTIME) == MNT_NODEVMTIME) { strncat (diptr->options, "nodevmtime,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NOEXEC) if ((flags & MNT_NOEXEC) == MNT_NOEXEC) { strncat (diptr->options, "noexec,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_NOSUID) if ((flags & MNT_NOSUID) == MNT_NOSUID) { strncat (diptr->options, "nosuid,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_QUOTA) if ((flags & MNT_QUOTA) == MNT_QUOTA) { strncat (diptr->options, "quota,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SECURE) if ((flags & MNT_SECURE) == MNT_SECURE) { strncat (diptr->options, "secure,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SMSYNC2) if ((flags & MNT_SMSYNC2) == MNT_SMSYNC2) { strncat (diptr->options, "smsync2,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SOFTDEP) if ((flags & MNT_SOFTDEP) == MNT_SOFTDEP) { strncat (diptr->options, "softdep,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SYMPERM) if ((flags & MNT_SYMPERM) == MNT_SYMPERM) { strncat (diptr->options, "symperm,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SYNC) if ((flags & MNT_SYNC) == MNT_SYNC) { strncat (diptr->options, "sync,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SYNCHRONOUS) if ((flags & MNT_SYNCHRONOUS) == MNT_SYNCHRONOUS) { strncat (diptr->options, "sync,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_THROTTLE) if ((flags & MNT_THROTTLE) == MNT_THROTTLE) { strncat (diptr->options, "throttle,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_UNION) if ((flags & MNT_UNION) == MNT_UNION) { strncat (diptr->options, "union,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_UNION) if ((flags & MNT_UNION) == MNT_UNION) { strncat (diptr->options, "union,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_REMOVABLE) if ((flags & MNT_REMOVABLE) == MNT_REMOVABLE) { strncat (diptr->options, "removable,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_PERSISTENT) if ((flags & MNT_PERSISTENT) == MNT_PERSISTENT) { strncat (diptr->options, "persistent,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_SHARED) if ((flags & MNT_SHARED) == MNT_SHARED) { strncat (diptr->options, "shared,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_BLOCKBASED) if ((flags & MNT_BLOCKBASED) == MNT_BLOCKBASED) { strncat (diptr->options, "blockbased,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_HAS_MIME) if ((flags & MNT_HAS_MIME) == MNT_HAS_MIME) { strncat (diptr->options, "mime,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_HAS_QUERY) if ((flags & MNT_HAS_QUERY) == MNT_HAS_QUERY) { strncat (diptr->options, "query,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (MNT_HAS_ATTR) if ((flags & MNT_HAS_ATTR) == MNT_HAS_ATTR) { strncat (diptr->options, "attr,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif return; } void #if _proto_stdc convertNFSMountOptions (long flags, long wsize, long rsize, diDiskInfo_t *diptr) #else convertNFSMountOptions (flags, wsize, rsize, diptr) long flags; long wsize; long rsize; diDiskInfo_t *diptr; #endif { #if defined (NFSMNT_SOFT) if ((flags & NFSMNT_SOFT) != NFSMNT_SOFT) { strncat (diptr->options, "hard,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (NFSMNT_WSIZE) if ((flags & NFSMNT_WSIZE) == NFSMNT_WSIZE) { char tmp [64]; Snprintf1 (tmp, sizeof (tmp), "wsize=%ld,", wsize); strncat (diptr->options, tmp, DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (NFSMNT_RSIZE) if ((flags & NFSMNT_RSIZE) == NFSMNT_RSIZE) { char tmp [64]; Snprintf1 (tmp, sizeof (tmp), "rsize=%ld,", rsize); strncat (diptr->options, tmp, DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (NFSMNT_INT) && defined (NFSMNT_SOFT) if ((flags & NFSMNT_SOFT) != NFSMNT_SOFT && (flags & NFSMNT_INT) == NFSMNT_INT) { strncat (diptr->options, "intr,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif #if defined (NFSMNT_TCP) if ((flags & NFSMNT_TCP) != NFSMNT_TCP) { strncat (diptr->options, "udp,", DI_OPT_LEN - strlen (diptr->options) - 1); } #endif return; } #if _lib_getmntent \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_mntctl \ && ! _class_os__Volumes char * #if _proto_stdc chkMountOptions (const char *mntopts, const char *str) #else chkMountOptions (mntopts, str) const char *mntopts; const char *str; #endif { char *ptr; char *tstr; tstr = strdup (mntopts); if (tstr == (char *) NULL) { fprintf (stderr, "strdup failed in chkMountOptions (1). errno %d\n", errno); exit (1); } ptr = strtok (tstr, ","); while (ptr != (char *) NULL) { if (strcmp (ptr, str) == 0) { free (tstr); return ptr; } ptr = strtok ((char *) NULL, ","); } free (tstr); return (char *) NULL; } #endif /* _lib_getmntent */ void #if _proto_stdc di_testRemoteDisk (diDiskInfo_t *diskInfo) #else di_testRemoteDisk (diskInfo) diDiskInfo_t *diskInfo; #endif { if (strncmp (diskInfo->fsType, "nfs", 3) == 0) { diskInfo->isLocal = FALSE; } } int #if _proto_stdc di_isPooledFs (diDiskInfo_t *diskInfo) #else di_isPooledFs (diskInfo) diDiskInfo_t *diskInfo; #endif { if (strcmp (diskInfo->fsType, "zfs") == 0 || strcmp (diskInfo->fsType, "advfs") == 0 || (strcmp (diskInfo->fsType, "null") == 0 && strstr (diskInfo->special, "/@@-") != (char *) NULL)) { return TRUE; } return FALSE; } int #if _proto_stdc di_isLoopbackFs (diDiskInfo_t *diskInfo) #else di_isLoopbackFs (diskInfo) diDiskInfo_t *diskInfo; #endif { if ((strcmp (diskInfo->fsType, "lofs") == 0 && diskInfo->sp_rdev != 0) || (strcmp (diskInfo->fsType, "null") == 0 && strstr (diskInfo->special, "/@@-") == (char *) NULL) || strcmp (diskInfo->fsType, "none") == 0) { return TRUE; } return FALSE; } Size_t #if _proto_stdc di_mungePoolName (char *poolname) #else di_mungePoolName (poolname) char *poolname; #endif { char *ptr; ptr = strchr (poolname, '#'); /* advfs */ if (ptr != (char *) NULL) { *ptr = '\0'; } else { ptr = strchr (poolname, ':'); /* dragonflybsd */ if (ptr != (char *) NULL) { *ptr = '\0'; } else { ptr = strchr (poolname, '/'); /* zfs */ if (ptr != (char *) NULL) { *ptr = '\0'; } } } return strlen (poolname); } di-4.47/C/tests.d/0000755000175000017500000000000013334050206011712 5ustar bllblldi-4.47/C/tests.d/getoptn.sh0000755000175000017500000000122313334050206013727 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'getoptn' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ cd $_MKCONFIG_RUNTOPDIR unset MAKEFLAGS ${MAKE:-make} ${TMAKEFLAGS} realclean ${MAKE:-make} ${TMAKEFLAGS} -e di.env . ./di.env ${MAKE:-make} ${TMAKEFLAGS} -e getoptn_test.exe > ${_MKCONFIG_TSTRUNTMPDIR}/make.log 2>&1 rc=$? if [ $rc != 0 ]; then grc=$rc; fi if [ $grc -eq 0 ]; then ./getoptn_test.exe > ${_MKCONFIG_TSTRUNTMPDIR}/getoptn_test.out 2>&1 if [ -s ${_MKCONFIG_TSTRUNTMPDIR}/getoptn_test.out ]; then chkdiff ${_MKCONFIG_RUNTESTDIR}/getoptn.txt \ ${_MKCONFIG_TSTRUNTMPDIR}/getoptn_test.out fi fi exit $grc di-4.47/C/tests.d/env.sh0000755000175000017500000000225113334050206013041 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh . $_MKCONFIG_DIR/bin/shellfuncs.sh maindodisplay $1 'check environment in make' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ cd ${_MKCONFIG_RUNTOPDIR} rc=$? if [ $rc -ne 0 ]; then puts "ERROR: Unable to cd to ${_MKCONFIG_RUNTOPDIR}" exit $rc fi ${MAKE:-make} di.env . ./di.env unset MAKEFLAGS ${MAKE:-make} ${TMAKEFLAGS} --version 2>&1 | egrep "GNU Make" > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then ${MAKE:-make} ${TMAKEFLAGS} -e --no-print-directory rtest-env | sed -e 's/^ *//' -e 's/ *$//' > ${_MKCONFIG_TSTRUNTMPDIR}/e2 2>/dev/null ${_MKCONFIG_TSTRUNTMPDIR}/e2 2>/dev/null else ${MAKE:-make} ${TMAKEFLAGS} -e rtest-env | sed -e 's/^ *//' -e 's/ *$//' > ${_MKCONFIG_TSTRUNTMPDIR}/e2 2>/dev/null fi cd ${_MKCONFIG_TSTRUNTMPDIR} rc=$? if [ $rc -ne 0 ]; then puts "ERROR: Unable to cd to ${_MKCONFIG_TSTRUNTMPDIR}" exit $rc fi echo "${_MKCONFIG_SYSTYPE} ${_MKCONFIG_SYSREV} ${_MKCONFIG_SYSARCH} ${CC} ${_MKCONFIG_USING_GCC} ${CFLAGS_OPTIMIZE} ${CFLAGS_COMPILER} ${LDFLAGS_COMPILER} ${OBJ_EXT} ${EXE_EXT} ${XMSGFMT}" | sed -e 's/^ *//' -e 's/ *$//' > e1 chkdiff e1 e2 testcleanup e1 e2 env.log exit $grc di-4.47/C/tests.d/compshpl.sh0000755000175000017500000000266513334050206014107 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'compare mkconfig.sh mkconfig.pl' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ cd $_MKCONFIG_RUNTOPDIR grc=0 unset MAKEFLAGS ${MAKE:-make} ${TMAKEFLAGS} realclean rm -f config.h.sh config.h.pl cache.pl cache.sh \ vars.pl vars.sh ${MAKE:-make} ${TMAKEFLAGS} -e config.h sed -e '/Created on: /,/Using: mkc/d' config.h > config.h.sh rm -f config.h grep -v '^mkc_env' mkconfig.cache | sort > cache.sh sort mkc_config_c.vars > vars.sh mv mkconfig.cache ${_MKCONFIG_TSTRUNTMPDIR}/mkconfig_sh.cache mv mkc_config_c.vars ${_MKCONFIG_TSTRUNTMPDIR}/mkc_config_c_sh.vars mv mkc_di_env.vars ${_MKCONFIG_TSTRUNTMPDIR}/mkc_di_env.vars mv mkconfig.log ${_MKCONFIG_TSTRUNTMPDIR}/mkconfig_sh.log mv di.env ${_MKCONFIG_TSTRUNTMPDIR}/di_sh.env ${MAKE:-make} ${TMAKEFLAGS} -e MKCONFIG_TYPE=perl config.h sed -e '/Created on: /,/Using: mkc/d' config.h > config.h.pl rm -f config.h sort mkconfig.cache > cache.pl sort mkc_config_c.vars > vars.pl mv mkconfig.cache $_MKCONFIG_TSTRUNTMPDIR/mkconfig_pl.cache mv mkc_config_c.vars $_MKCONFIG_TSTRUNTMPDIR/mkc_config_c_pl.vars mv mkconfig.log $_MKCONFIG_TSTRUNTMPDIR/mkconfig_pl.log mv di.env $_MKCONFIG_TSTRUNTMPDIR/di_pl.env chkdiff config.h.sh config.h.pl mv config.h.sh config.h.pl $_MKCONFIG_TSTRUNTMPDIR chkdiff cache.sh cache.pl mv cache.sh cache.pl $_MKCONFIG_TSTRUNTMPDIR chkdiff vars.sh vars.pl mv vars.sh vars.pl $_MKCONFIG_TSTRUNTMPDIR exit $grc di-4.47/C/tests.d/getoptn.txt0000644000175000017500000000071113334050206014132 0ustar bllbll** expect argument missing test 32: -i argument missing ** expect invalid size test 33: int: invalid size (line 7) ** expect invalid size test 34: long: invalid size (line 8) ** expect invalid size test 35: long: invalid size (line 9) ** expect invalid pointer test 45: string: invalid pointer (line 21) ** expect invalid pointer test 46: func_bool: invalid function ptr (line 22) ** expect invalid pointer test 47: func_val: invalid function ptr (line 23) di-4.47/C/tests.d/rpmbuild.sh0000755000175000017500000000173413334050206014074 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh getsname $0 dosetup $@ maindodisplay $1 rpmbuild maindoquery $1 $_MKC_ONCE . $_MKCONFIG_DIR/bin/shellfuncs.sh locatecmd locrpmbuild rpmbuild if [ "${locrpmbuild}" = "" ];then putsnonl " skipped" >&5 exit 0 fi rvers=`rpmbuild --version | tr -cd '0-9' | sed 's/^\(...\).*/\1/'` if [ $rvers -lt 470 ]; then putsnonl " old version skipped" >&5 exit 0 fi march=`rpmbuild --showrc | grep '^build arch' | sed 's/.*: *//'` puts "## Machine Architecture: ${march}" cd ${_MKCONFIG_RUNTOPDIR} DI_VERSION=`grep DI_VERSION version.h | sed -e 's/"$//' -e 's/.*"//'` unset MAKEFLAGS ${MAKE:-make} ${TMAKEFLAGS} -e di.env . ./di.env grc=0 ${MAKE:-make} ${TMAKEFLAGS} -e DI_DIR=".." DI_VERSION=${DI_VERSION} MARCH=${march} testrpmbuild rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi # leave a copy there...realclean will get them... set +f cp mkconfig.log mkconfig.cache mkc*.vars di.env di.reqlibs \ $_MKCONFIG_TSTRUNTMPDIR set -f exit $grc di-4.47/C/tests.d/test_order0000644000175000017500000000006013334050206014003 0ustar bllbll1 env 2 getoptn 3 buildpl 4 compshpl 5 rpmbuild di-4.47/C/tests.d/buildpl.sh0000755000175000017500000000072313334050206013706 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'build w/mkconfig.pl' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ cd $_MKCONFIG_RUNTOPDIR unset MAKEFLAGS ${MAKE:-make} ${TMAKEFLAGS} realclean instdir="`pwd`/test_di" ${MAKE:-make} ${TMAKEFLAGS} -e prefix=${instdir} all-perl grc=$? # leave a copy there...realclean will get them... set +f cp mkconfig.log mkconfig.cache mkc*.vars di.env di.reqlibs \ $_MKCONFIG_TSTRUNTMPDIR set -f exit $grc di-4.47/C/tcldiskspace.c0000644000175000017500000001574413334050206013156 0ustar bllbll/* * Copyright 2016-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "configtcl.h" #include "di.h" #include "dimain.h" #include "version.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _hdr_unistd # include #endif #if _hdr_memory # include #endif #if _hdr_malloc # include #endif #if _hdr_tcl # define USE_TCL_STUBS # include #endif #if _use_mcheck # include #endif #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif #if _npt_getenv extern char *getenv _((const char *)); #endif #if defined (__cplusplus) || defined (c_plusplus) } #endif /* end of system specific includes/configurations */ #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif int Diskspace_Init _((Tcl_Interp *)); int diskspaceObjCmd _((ClientData, Tcl_Interp *, int, Tcl_Obj * const [])); static void addListToDict _((Tcl_Interp *, Tcl_Obj *, const char *, char *)); static void addStringToDict _((Tcl_Interp *, Tcl_Obj *, const char *, const char *)); static void addWideToDict _((Tcl_Interp *, Tcl_Obj *, const char *, _fs_size_t)); static char *diproc _((int, const char **, diData_t *)); #if defined (__cplusplus) || defined (c_plusplus) } #endif int #if _proto_stdc Diskspace_Init (Tcl_Interp *interp) #else Diskspace_Init (interp) Tcl_Interp *interp; #endif { #if _use_mcheck mcheck_pedantic (NULL); mtrace (); #endif if (! Tcl_InitStubs (interp, "8.5", 0)) { return TCL_ERROR; } Tcl_CreateObjCommand (interp, "diskspace", diskspaceObjCmd, (ClientData) NULL, NULL); Tcl_PkgProvide (interp, "diskspace", DI_VERSION); return TCL_OK; } int #if _proto_stdc diskspaceObjCmd ( ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj * const objv[] ) #else diskspaceObjCmd (interp, objc, objv) ClientData cd; Tcl_Interp *interp; int objc; Tcl_Obj * const objv[]; #endif { const char **argv; char *rv; const char *tptr; char *ttptr; char **dispargs; int i; diData_t diData; Tcl_Obj *dictObj; Tcl_Obj *tempDictObj; Tcl_Obj *mountKey; diDiskInfo_t *diskInfo; diDiskInfo_t *dinfo; /* using malloc here causes tcl to crash */ /* rather weird, as this is my value, not Tcl's */ argv = (const char **) ckalloc (sizeof(const char *) * (Size_t) (objc + 1)); for (i = 0; i < objc; ++i) { tptr = Tcl_GetString (objv[i]); argv[i] = tptr; } argv[objc] = NULL; rv = diproc (objc, argv, &diData); if (diData.options.exitFlag == DI_EXIT_FAIL) { Tcl_SetObjResult(interp, Tcl_NewStringObj("malloc failure", -1)); Tcl_SetErrorCode(interp, "diskspace", NULL); ckfree (argv); return TCL_ERROR; } if (diData.options.exitFlag == DI_EXIT_WARN) { Tcl_SetObjResult(interp, Tcl_NewStringObj("invalid arguments", -1)); Tcl_SetErrorCode(interp, "diskspace", NULL); ckfree (argv); return TCL_ERROR; } if (diData.options.exitFlag == DI_EXIT_OK) { ckfree (argv); return TCL_OK; } diskInfo = diData.diskInfo; dictObj = Tcl_NewDictObj (); dispargs = (char **) malloc (sizeof(char *) * (Size_t) diData.count); if (rv != (char *) NULL) { ttptr = strtok (rv, "\n"); } else { ttptr = (char *) NULL; } for (i = 0; i < diData.count; ++i) { dinfo = &(diskInfo [diskInfo [i].sortIndex[DI_TOT_SORT_IDX]]); dispargs[i] = (char *) NULL; if (! dinfo->doPrint) { continue; } dispargs[i] = ttptr; if (rv != (char *) NULL) { ttptr = strtok (NULL, "\n"); } } for (i = 0; i < diData.count; ++i) { dinfo = &(diskInfo [diskInfo [i].sortIndex[DI_TOT_SORT_IDX]]); if (! dinfo->doPrint) { continue; } tempDictObj = Tcl_NewDictObj (); addStringToDict (interp, tempDictObj, "device", dinfo->special); addStringToDict (interp, tempDictObj, "fstype", dinfo->fsType); addWideToDict (interp, tempDictObj, "total", dinfo->totalSpace); addWideToDict (interp, tempDictObj, "free", dinfo->freeSpace); addWideToDict (interp, tempDictObj, "available", dinfo->availSpace); addWideToDict (interp, tempDictObj, "totalinodes", dinfo->totalInodes); addWideToDict (interp, tempDictObj, "freeinodes", dinfo->freeInodes); addWideToDict (interp, tempDictObj, "availableinodes", dinfo->availInodes); addStringToDict (interp, tempDictObj, "mountoptions", dinfo->options); if (dispargs[i] != (char *) NULL) { addListToDict (interp, tempDictObj, "display", dispargs[i]); } mountKey = Tcl_NewStringObj (dinfo->name, -1); Tcl_DictObjPut (interp, dictObj, mountKey, tempDictObj); } Tcl_SetObjResult(interp, dictObj); if (rv != (char *) NULL) { free (rv); } free (dispargs); cleanup (&diData); ckfree (argv); return TCL_OK; } static void #if _proto_stdc addListToDict (Tcl_Interp *interp, Tcl_Obj *dict, const char *nm, char *val) #else addListToDict (interp, dict, nm, val) Tcl_Interp *interp; Tcl_Obj *dict; const char *nm; char *val; #endif { Tcl_Obj *tempObj; Tcl_Obj *tempObj1; Tcl_Obj *tempObj2; char *dptr; tempObj2 = Tcl_NewListObj (0, NULL); dptr = strtok (val, " "); /* tab character */ while (dptr != (char *) NULL) { tempObj = Tcl_NewStringObj (dptr, -1); Tcl_ListObjAppendElement (interp, tempObj2, tempObj); dptr = strtok (NULL, " "); /* tab character */ } tempObj1 = Tcl_NewStringObj (nm, -1); Tcl_DictObjPut (interp, dict, tempObj1, tempObj2); } static void #if _proto_stdc addStringToDict (Tcl_Interp *interp, Tcl_Obj *dict, const char *nm, const char *val) #else addStringToDict (interp, dict, nm, val) Tcl_Interp *interp; Tcl_Obj *dict; const char *nm; const char *val; #endif { Tcl_Obj *tempObj1; Tcl_Obj *tempObj2; tempObj1 = Tcl_NewStringObj (nm, -1); tempObj2 = Tcl_NewStringObj (val, -1); Tcl_DictObjPut (interp, dict, tempObj1, tempObj2); } static void #if _proto_stdc addWideToDict (Tcl_Interp *interp, Tcl_Obj *dict, const char *nm, _fs_size_t val) #else addWideToDict (interp, dict, nm, val) Tcl_Interp *interp; Tcl_Obj *dict; const char *nm; _fs_size_t val; #endif { Tcl_Obj *tempObj1; Tcl_Obj *tempObj2; Tcl_WideInt wideVal; wideVal = (Tcl_WideInt) val; tempObj1 = Tcl_NewStringObj (nm, -1); tempObj2 = Tcl_NewWideIntObj (wideVal); Tcl_DictObjPut (interp, dict, tempObj1, tempObj2); } static char * #if _proto_stdc diproc (int argc, const char **argv, diData_t *diData) #else diproc (argc, argv) int argc; const char **argv; diData_t *diData; #endif { char *disp; disp = dimainproc (argc, (const char * const *) argv, 1, diData); return disp; } di-4.47/C/Makefile0000644000175000017500000003166713334050206012003 0ustar bllbll# # di makefile - C # # Copyright 2001-2018 Brad Lanam Walnut Creek CA, USA # CC = cc # for tests.done DC = gdc OBJ_EXT = .o EXE_EXT = MAKE = make ### # common programs # CAT = cat CHGRP = chgrp CHMOD = chmod CHOWN = chown CP = cp LN = ln MKDIR = mkdir MV = mv RM = rm RPMBUILD = rpmbuild SED = sed TEST = test ### # installation options # prefix = /usr/local LOCALEDIR = $(prefix)/share/locale ### # additional flags/libraries # DI_SHARED = DI_CFLAGS = -DDI_LOCALE_DIR=\\\"$(LOCALEDIR)\\\" ### # mkconfig variables MKC_DIR = ../mkconfig MKCONFIG_TYPE = sh MKC_REQLIB = di.reqlibs MKC_TCLREQLIB = di-tcl.reqlibs MKC_ECHO = #MKC_ECHO = -e ### # main # have to get various environment variables set up. .PHONY: all all: all-sh .PHONY: all-sh all-sh: di.env . ./di.env;$(MAKE) -e MKCONFIG_TYPE=sh di-programs .PHONY: all-perl all-perl: di.env . ./di.env;$(MAKE) -e MKCONFIG_TYPE=perl di-programs # tcl interface .PHONY: tcl-sh tcl-sh: di-sh.env . ./di-sh.env;$(MAKE) -e MKCONFIG_TYPE=sh tcl-programs # this is not working...need to research #tcl-perl: di-sh.env # . ./di-sh.env;$(MAKE) -e MKCONFIG_TYPE=perl tcl-programs # perl interface .PHONY: perl-sh perl-sh: di-sh.env . ./di-sh.env;$(MAKE) -e MKCONFIG_TYPE=sh perl-programs .PHONY: perl-perl perl-perl: di-sh.env . ./di-sh.env;$(MAKE) -e MKCONFIG_TYPE=perl perl-programs .PHONY: test test: tests.done ### # environment di.env: features/env.dat ../dioptions.dat @-$(RM) -f di.env tests.done CC=$(CC) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkconfig.sh features/env.dat di-sh.env: features/shenv.dat @-$(RM) -f di-sh.env tests.done CC=$(CC) $(_MKCONFIG_SHELL) $(MKC_DIR)/mkconfig.sh features/shenv.dat ### # specific builds # This was tested using vc++ 5.0. (many years ago) # seriously out of date; config.cygwin.gcc is incorrect for this build. .PHONY: windows windows: @$(MAKE) ../dioptions.dat copy /y NUL: di.env -del config.h copy /y /b NUL:+configs\config.cygwin.gcc config.h copy /y NUL: $(MKC_REQLIB) $(MAKE) \ CC=cl LD=cl EXE_EXT=".exe" OBJ_EXT=".obj" \ CFLAGS="$(CFLAGS) -nologo -O2 \ -DDEFAULT_FORMAT=\\\"MbuvpT\\\"" \ LDFLAGS="-nologo -O2" di-programs # This was tested using cygwin .PHONY: windows-gcc windows-gcc: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done $(CP) -f configs/config.cygwin.gcc config.h @echo '-lintl' > $(MKC_REQLIB) $(MAKE) \ CC=gcc LD=gcc EXE_EXT=".exe" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -g -O2 \ -DDEFAULT_FORMAT=\\\"MbuvpT\\\"" \ LDFLAGS="-g -O2" di-programs # Gets an immediate segmentation fault. .PHONY: windows-clang windows-clang: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done $(CP) -f configs/config.cygwin.clang config.h @echo '-lintl' > $(MKC_REQLIB) $(MAKE) \ CC=clang LD=clang EXE_EXT=".exe" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -g -O2 \ --without-libintl-prefix \ --without-libiconv-prefix \ -DDEFAULT_FORMAT=\\\"MbuvpT\\\"" \ LDFLAGS="-g -O2" di-programs .PHONY: windows-msys windows-msys: MAKE=mingw32-make cp ../features/dioptions.dat ../dioptions.dat > di.env -rm config.h cp configs/config.mingw config.h > $(MKC_REQLIB) $(MAKE) \ MAKE=$(MAKE) \ CC=gcc \ EXE_EXT=".exe" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -g -O2 \ -DDEFAULT_FORMAT=\\\"MbuvpT\\\"" \ LDFLAGS="-g -O2" di-programs .PHONY: windows-mingw windows-mingw: MAKE=mingw32-make copy /y /b NUL:+..\features\dioptions.dat ..\dioptions.dat copy /y NUL: di.env -del config.h copy /y /b NUL:+configs\config.mingw config.h copy /y NUL: $(MKC_REQLIB) $(MAKE) \ MAKE=$(MAKE) \ CC=gcc LD=gcc \ EXE_EXT=".exe" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -g -O2 \ -DDEFAULT_FORMAT=\\\"MbuvpT\\\"" \ LDFLAGS="-g -O2" mingw-di.exe .PHONY: os2-gcc os2-gcc: @echo ':' > di.env;chmod a+rx di.env $(MAKE) MKCONFIG_TYPE=perl \ CC=gcc LD=gcc EXE_EXT=".exe" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -g -O2 \ LDFLAGS="-g -O2 -Zexe" di.exe .PHONY: bsd43-cc bsd43-cc: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done sleep 1 $(CP) configs/config.bsd43.cc config.h sleep 1 @touch $(MKC_REQLIB) $(MAKE) _MKCONFIG_SHELL=$(MKCONFIG_SHELL) \ CC=cc LD=cc EXE_EXT="" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -O" \ LDFLAGS="-O" di-programs .PHONY: bsd43-gcc bsd43-gcc: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done sleep 1 $(CP) configs/config.bsd43.gcc config.h sleep 1 @touch $(MKC_REQLIB) $(MAKE) _MKCONFIG_SHELL=$(MKCONFIG_SHELL) \ CC=gcc LD=gcc EXE_EXT="" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -O2" \ LDFLAGS="-O2" di-programs .PHONY: ultrix-cc ultrix-cc: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done sleep 1 $(CP) configs/config.ultrix.cc config.h sleep 1 @touch $(MKC_REQLIB) $(MAKE) _MKCONFIG_SHELL=$(MKCONFIG_SHELL) \ CC=cc LD=cc EXE_EXT="" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -O" \ LDFLAGS="-O" di-programs .PHONY: ultrix-gcc ultrix-gcc: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done sleep 1 $(CP) configs/config.ultrix.gcc config.h sleep 1 @echo '-lintl' > $(MKC_REQLIB) $(MAKE) _MKCONFIG_SHELL=$(MKCONFIG_SHELL) \ CC=gcc LD=gcc EXE_EXT="" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -O2" \ LDFLAGS="-O2" di-programs .PHONY: hpux-cc hpux-cc: @$(MAKE) -e ../dioptions.dat @$(MAKE) CC=/usr/ccs/bin/cc -e di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done sleep 1 $(CP) configs/config.hpux.bcc config.h sleep 1;touch $(MKC_REQLIB) . ./di.env;$(MAKE) -e CC=/usr/ccs/bin/cc \ _MKCONFIG_SHELL=$(MKCONFIG_SHELL) di-programs .PHONY: xenix-cc xenix-cc: @$(MAKE) ../dioptions.dat @echo ':' > di.env;chmod a+rx di.env @-$(RM) -f config.h mkconfig.cache mkc*.vars tests.done sleep 1 $(CP) configs/conf.xenix.cc config.h sleep 1 @touch $(MKC_REQLIB) $(MAKE) _MKCONFIG_SHELL=$(MKCONFIG_SHELL) \ CC=cc LD=cc EXE_EXT="" OBJ_EXT=".o" \ CFLAGS="$(CFLAGS) -O" \ LDFLAGS="-O" di-programs ### # cleaning # leaves: # config.h configtcl.h di.reqlibs # ../dioptions.dat, tests.done, test_di, di.env, di-sh.env .PHONY: clean clean: @-$(RM) -rf di mi \ di.exe mingw-di.exe mi.exe \ tcldiskspace.bld diskspace.so diskspace.dylib diskspace.dll \ perlfilesysdi.bld libdiperl.a \ *.o *.obj mkconfig.log \ tests.done _tmp_mkconfig tests.d/chksh* \ mkconfig.cache mkc*.vars \ getoptn_test* gconfig.h getoptn.reqlibs \ mkconfig.reqlibs mkc_compile.log \ Perl/Filesys-di-*.tar.gz \ Perl/Makefile.old \ >/dev/null 2>&1; exit 0 @-cd Perl; \ if [ -f Makefile ]; then \ $(MAKE) clean; \ fi @-find . -name '*~' -print | xargs rm > /dev/null 2>&1; exit 0 # leaves: # _mkconfig_runtests, _tmp_mkconfig, ../dioptions.dat # tests.done, test_di .PHONY: realclean realclean: @$(MAKE) clean > /dev/null 2>&1 @-$(RM) -rf config.h configtcl.h gconfig.h \ di.env di-sh.env $(MKC_REQLIB) $(MKC_TCLREQLIB) \ >/dev/null 2>&1; exit 0 # leaves: # ../dioptions.dat .PHONY: distclean distclean: @$(MAKE) realclean > /dev/null 2>&1 @-$(RM) -rf tests.done test_di \ _mkconfig_runtests _tmp_mkconfig \ *~ *.orig */*.orig \ >/dev/null 2>&1; exit 0 @-cd Perl; \ if [ -f Makefile ]; then \ $(MAKE) distclean; \ fi ### # installation .PHONY: install install: di.env di-programs . ./di.env;cd ..;$(MAKE) -e prefix=$(prefix) \ LOCALEDIR=$(LOCALEDIR) FROMDIR=C install ### # programs .PHONY: di-programs di-programs: di$(EXE_EXT) .PHONY: tcl-programs tcl-programs: tcldiskspace.bld .PHONY: perl-programs perl-programs: perlfilesysdi.bld ### # configuration file ../dioptions.dat: ../features/dioptions.dat cd ../;$(MAKE) dioptions.dat config.h: di.env ../dioptions.dat features/mkconfig.dat @-$(RM) -f config.h tests.done @if [ "$(DI_NO_NLS)" != "" ]; then \ echo "*** User requested no NLS"; \ $(MKC_DIR)/mkc.sh -setopt -o ../dioptions.dat NLS F; fi @if [ "$(MKCONFIG_TYPE)" = "sh" -o "$(MKCONFIG_TYPE)" = "" ]; then \ . ./di.env;$(_MKCONFIG_SHELL) \ $(MKC_DIR)/mkconfig.sh \ features/mkconfig.dat; fi @if [ "$(MKCONFIG_TYPE)" = "perl" ]; then \ . ./di.env;perl \ $(MKC_DIR)/mkconfig.pl \ features/mkconfig.dat; fi configtcl.h: di-sh.env ../dioptions.dat features/mkconfig-tcl.dat @-$(RM) -f configtcl.h @if [ "$(MKCONFIG_TYPE)" = "sh" -o "$(MKCONFIG_TYPE)" = "" ]; then \ . ./di-sh.env;$(_MKCONFIG_SHELL) \ $(MKC_DIR)/mkconfig.sh \ features/mkconfig-tcl.dat; fi @if [ "$(MKCONFIG_TYPE)" = "perl" ]; then \ . ./di-sh.env;perl \ $(MKC_DIR)/mkconfig.pl \ features/mkconfig-tcl.dat; fi $(MKC_REQLIB): config.h @$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -reqlib \ -o $(MKC_REQLIB) config.h $(MKC_TCLREQLIB): configtcl.h @$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -reqlib \ -o $(MKC_TCLREQLIB) configtcl.h ### # executables LIBOBJECTS = dimain$(OBJ_EXT) didiskutil$(OBJ_EXT) \ digetentries$(OBJ_EXT) digetinfo$(OBJ_EXT) \ diquota$(OBJ_EXT) display$(OBJ_EXT) getoptn$(OBJ_EXT) \ options$(OBJ_EXT) realloc$(OBJ_EXT) strdup$(OBJ_EXT) \ strstr$(OBJ_EXT) trimchar$(OBJ_EXT) MAINOBJECTS = di$(OBJ_EXT) TCLOBJECTS = tcldiskspace$(OBJ_EXT) di$(EXE_EXT): $(MKC_REQLIB) $(MAINOBJECTS) $(LIBOBJECTS) @$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -link -exec $(MKC_ECHO) \ -r $(MKC_REQLIB) -o di$(EXE_EXT) \ $(MAINOBJECTS) $(LIBOBJECTS) tcldiskspace.bld: $(MKC_REQLIB) $(MKC_TCLREQLIB) \ $(TCLOBJECTS) $(LIBOBJECTS) @$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -link -shared $(MKC_ECHO) \ -lib -o diskspace$(SHLIB_EXT) \ -r $(MKC_REQLIB) -r $(MKC_TCLREQLIB) \ $(TCLOBJECTS) $(LIBOBJECTS) $(LIBS) @touch tcldiskspace.bld perlfilesysdi.bld: $(MKC_REQLIB) $(LIBOBJECTS) @echo "*** Using libs: `$(CAT) $(MKC_REQLIB)`" @$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -staticlib $(MKC_ECHO) \ -o libdiperl.a $(LIBOBJECTS) $(LIBS) \ `$(CAT) $(MKC_REQLIB)` # Don't know how to pass additional libs to Makefile.PL # so pass all the information. ( \ cd Perl ; \ perl Makefile.PL LIBS="-L.. -ldiperl `$(CAT) ../$(MKC_REQLIB)`" ; \ make ; \ make test ; \ ) @touch perlfilesysdi.bld mingw-di$(EXE_EXT): $(MAINOBJECTS) $(LIBOBJECTS) $(CC) -o mingw-di$(EXE_EXT) \ $(CFLAGS) $(LDFLAGS) $(LIBOBJECTS) $(LIBS) ### # objects .c$(OBJ_EXT): @$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -compile $(MKC_ECHO) \ $(DI_SHARED) $(DI_CFLAGS) $< di$(OBJ_EXT): di.c config.h di.h dimain.h getoptn.h \ options.h version.h tcldiskspace$(OBJ_EXT): tcldiskspace.c config.h di.h \ dimain.h getoptn.h \ options.h dimain$(OBJ_EXT): dimain.c config.h di.h dimain.h getoptn.h \ options.h digetinfo$(OBJ_EXT): digetinfo.c config.h di.h dimntopt.h didiskutil$(OBJ_EXT): didiskutil.c config.h di.h dimntopt.h digetentries$(OBJ_EXT): digetentries.c config.h di.h dimntopt.h diquota$(OBJ_EXT): diquota.c config.h di.h display$(OBJ_EXT): display.c config.h di.h display.h options.h version.h getoptn$(OBJ_EXT): getoptn.c config.h getoptn.h options$(OBJ_EXT): options.c config.h di.h options.h realloc$(OBJ_EXT): realloc.c config.h di.h strdup$(OBJ_EXT): strdup.c config.h di.h strstr$(OBJ_EXT): strstr.c config.h di.h trimchar$(OBJ_EXT): trimchar.c config.h di.h ### # regression testing .PHONY: all-test all-test: tests.done tests.done: $(MKC_DIR)/runtests.sh @echo "## running tests" CC=$(CC) DC=$(DC) $(_MKCONFIG_SHELL) \ $(MKC_DIR)/runtests.sh ./tests.d touch tests.done # needs environment .PHONY: testrpmbuild testrpmbuild: -$(TEST) -d ./rpmbuild && rm -rf ./rpmbuild $(MKDIR) -p ./rpmbuild/SOURCES $(MKDIR) -p ./rpmbuild/BUILD $(CP) -f $(DI_DIR)/di-$(DI_VERSION).tar.gz ./rpmbuild/SOURCES $(RPMBUILD) --define="_topdir `pwd`/rpmbuild" -ba ../di.spec $(TEST) -f ./rpmbuild/RPMS/$(MARCH)/di-$(DI_VERSION)-1.$(MARCH).rpm || exit 1 $(TEST) -f ./rpmbuild/SRPMS/di-$(DI_VERSION)-1.src.rpm || exit 1 $(TEST) -d ./rpmbuild && rm -rf ./rpmbuild # needs environment .PHONY: rtest-env rtest-env: @echo "$(_MKCONFIG_SYSTYPE)" @echo "$(_MKCONFIG_SYSREV)" @echo "$(_MKCONFIG_SYSARCH)" @echo "$(CC)" @echo "$(_MKCONFIG_USING_GCC)" @echo "$(CFLAGS_OPTIMIZE)" @echo "$(CFLAGS_COMPILER)" @echo "$(LDFLAGS_COMPILER)" @echo "$(OBJ_EXT)" @echo "$(EXE_EXT)" @echo "$(XMSGFMT)" gconfig.h: di.env features/getoptn.dat @-$(RM) -f gconfig.h @if [ "$(MKCONFIG_TYPE)" = "sh" -o "$(MKCONFIG_TYPE)" = "" ]; then \ . ./di.env; \ $(_MKCONFIG_SHELL) $(MKC_DIR)/mkconfig.sh \ features/getoptn.dat; fi @if [ "$(MKCONFIG_TYPE)" = "perl" ]; then \ . ./di.env; \ perl $(MKC_DIR)/mkconfig.pl \ features/getoptn.dat; fi getoptn_test$(OBJ_EXT): getoptn.c gconfig.h getoptn.h @. ./di.env;$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -compile \ -DTEST_GETOPTN=1 \ -o getoptn_test$(OBJ_EXT) getoptn.c getoptn.reqlibs: di.env gconfig.h @. ./di.env;$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -reqlib \ -o getoptn.reqlibs gconfig.h getoptn_test.exe: getoptn_test$(OBJ_EXT) getoptn.reqlibs @. ./di.env;$(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -link -exec \ $(MKC_ECHO) -o getoptn_test.exe $(LDFLAGS) \ getoptn_test$(OBJ_EXT) \ `$(CAT) getoptn.reqlibs` di-4.47/C/features/0000755000175000017500000000000013334050206012144 5ustar bllblldi-4.47/C/features/shenv.dat0000644000175000017500000000312713334050206013764 0ustar bllblloption-file ../dioptions.dat loadunit env-main loadunit env-systype loadunit env-cc loadunit env-msgfmt loadunit env-extension output di-sh.env system type system rev system arch cc using_gcc using_gnu_ld using_clang cflags ldflags # needed for tcl build addcflag -fPIC # standard flags addcflag -Wextra addcflag -Wno-unused-but-set-variable addcflag -Wno-unused-parameter addcflag -Wno-float-equal addcflag -Wno-shift-sign-overflow # gcc hardening # reference: wiki.debian.org/Hardening addcflag -Wformat addcflag -Wformat-security addcflag -Werror=format-security addcflag -D_FORTIFY_SOURCE=2 # these confuse other compilers...make them GCC only # solaris will not link w/-fstack-protector, so it # can only be set when the gnu linker is in use. if UsingGNU_LD ( == _MKCONFIG_USING_GNU_LD Y ) && ( == _MKCONFIG_USING_GCC Y ) ifnotoption NO_PIE addcflag -fstack-protector-strong addcflag -fstack-protector-all addldflag -fstack-protector-strong addldflag -fstack-protector-all endif endif # these confuse other compilers...make them CLANG only if UsingCLANG == _MKCONFIG_USING_CLANG Y addcflag -Werror,-Wunused-command-line-argument ifnotoption NO_PIE addcflag -fstack-protector-strong addcflag -fstack-protector-all addldflag -fstack-protector-strong addldflag -fstack-protector-all endif endif libs shcflags shldflags sharednameflag shareexeclinkflag sharerunpathflag findconfig tclConfig if Have_tclConfig == config_tclConfig Y addconfig TCL_STUB_LIB_SPEC ldflags_libs_application addconfig TCL_INCLUDE_SPEC cflags_include endif extension obj extension exe cmd_msgfmt extension shlib di-4.47/C/features/mkconfig.dat0000644000175000017500000001764213334050206014445 0ustar bllbll# # Copyright 2006-2018 Brad Lanam, Walnut Creek, California USA # # option-file ../dioptions.dat loadunit c-main loadunit c-include-conflict output config.h standard hdr ctype.h hdr dcdef.h hdr descrip.h hdr dirent.h hdr dvidef.h hdr dvsdef.h hdr errno.h hdr fcntl.h hdr fshelp.h hdr gui/window.h hdr jfs/quota.h hdr kernel/fs_info.h hdr limits.h hdr linux/dqblk_xfs.h # aix 5 doesn't declare their own, use the compatibility version hdr linux/quota.h hdr libintl.h hdr libprop/proplib.h hdr locale.h hdr malloc.h hdr mcheck.h hdr memory.h hdr mntent.h hdr mnttab.h # NetBSD hdr quota.h hdr rpc/rpc.h hdr rpcsvc/rquota.h hdr ssdef.h hdr starlet.h hdr storage/Directory.h hdr storage/Entry.h hdr storage/Path.h # syllable: broken design, broken header hdr storage/volumes.h gui/window.h hdr string.h hdr strings.h hdr time.h hdr ufs/quota.h hdr ufs/ufs/quota.h hdr unistd.h hdr util/string.h hdr wchar.h hdr windows.h hdr winioctl.h windows.h hdr zone.h sys dcmd_blk.h sys file.h sys fs_types.h sys fs/ufs_quota.h sys fstyp.h sys fstypes.h sys ftype.h sys io.h sys mntctl.h # SCO OpenServer/UnixWare require sys/mnttab.h for struct mnttab declaration. sys mntent.h sys/mnttab.h sys mnttab.h sys mount.h sys quota.h sys stat.h sys statfs.h sys statvfs.h sys time.h sys vfs.h sys vfs_quota.h sys vfstab.h sys vmount.h include_conflict time.h sys/time.h include_conflict sys/quota.h linux/quota.h command msgfmt gmsgfmt # rpmbuild used for regression tests command rpmbuild const O_NOCTTY define bcopy define bzero define IOCTL_STORAGE_CHECK_VERIFY2 define MCTL_QUERY define memcpy define memset define QCMD define S_ISLNK typ struct dqblk typ struct quotaval typ struct ufs_dqblk typ fs_disk_quota_t typ gid_t typ statvfs_t typ size_t typ uint_t typ uid_t lib bcopy lib bindtextdomain -lintl, -lintl -liconv lib bzero lib CreateFile lib DeviceIoControl # unknown if -lsun, -lseq are needed (old irix, sequent) lib endmntent -lsun, -lseq lib fs_stat_dev lib fshelp lib GetDiskFreeSpace lib GetDiskFreeSpaceEx lib GetDriveType lib getfsstat lib GetLogicalDriveStrings lib GetVolumeInformation lib getmnt # unixware put getmntent into libgen for some reason # -lsun, -lseq are untested (old irix, sequent) lib getmntent -lgen, -lsun, -lseq lib getmntinfo lib gettext -lintl, -lintl -liconv lib getvfsstat lib getzoneid lib hasmntopt lib lstat lib mbrlen lib mcheck_pedantic -lmcheck lib memcpy lib memset # AIX doesn't declare this :( # Look for MCTL_QUERY (see below) lib mntctl lib next_dev # dragonflybsd; need this to get the library lib prop_dictionary_create -lprop # quota_open is a new interface from NetBSD lib quota_open -lquota -lrpcsvc lib quotactl lib realpath lib setlocale -lintl, -lintl -liconv # unknown if -lsun, -lseq are needed (old irix, sequent) lib setmntent -lsun, -lseq lib snprintf -lsnprintf lib statfs lib statvfs lib strcoll lib strdup lib strstr # VMS lib sys_dollar_device_scan # VMS lib sys_dollar_getdviw lib sysfs lib textdomain -lintl, -lintl -liconv # dragonflybsd lib vquotactl # need this to get the optional library lib xdr_int -lnsl lib zone_getattr lib zone_list # get the correct xdr types... memberxdr rquota rq_bhardlimit memberxdr rquota rq_bsoftlimit memberxdr rquota rq_curblocks memberxdr rquota rq_fhardlimit memberxdr rquota rq_fsoftlimit memberxdr rquota rq_curfiles memberxdr getquota_args gqa_uid # to prevent warnings # some systems are u_int, size_t, u_long args noconst getfsstat args noconst getvfsstat args noconst quotactl setint _quotactl_pos_1 0 setint _quotactl_pos_2 0 if quotactl_pos_1 == _c_arg_1_quotactl 'char *' setint _quotactl_pos_1 1 endif if quotactl_pos_2 == _c_arg_2_quotactl 'char *' setint _quotactl_pos_2 1 endif if quotactl_pos_2 == _c_arg_2_quotactl 'caddr_t' setint _quotactl_pos_2 1 endif args noconst setmntent args noconst statfs class os::Volumes -lsyllable npt getenv npt getmnt npt mntctl npt quotactl npt statfs _lib_statfs dcl int errno dcl ptr mnt_names member struct dqblk dqb_curspace member struct dqblk dqb_curblocks member struct dqblk dqb_fhardlimit member struct dqblk dqb_fsoftlimit member struct dqblk dqb_curfiles member struct getquota_rslt gqr_status member struct getquota_rslt gqr_rquota member struct mnttab mt_mntopts member struct statfs f_bsize member struct statfs f_fsize member struct statfs f_fstyp member struct statfs f_iosize member struct statfs f_frsize member struct statfs f_fstypename member struct statfs mount_info member struct statfs f_type member struct statvfs f_basetype size long long size long double if have_long_double ( ( == _siz_long_double 8 ) || ( == _siz_long_double 16 ) ) printf_long_double else setint _printf_long_double 0 endif # workaround for AIX # mntctl() is not declared if AIX_mntctl _sys_vmount && _define_MCTL_QUERY set _lib_mntctl 1 endif # dragonflybsd may have vquotactl, but it may not be turned on. if DFLYBSD_vquotactl _lib_vquotactl grep DFLYBSD_vquota vfs.quota_enabled=.*1 /boot/loader.conf if DFLYBSD_vquota_chk ! _grep_DFLYBSD_vquota set _lib_vquotactl 0 set _lib_prop_dictionary_create 0 endif endif if stdquotas ( _lib_quotactl || _lib_quota_open || _lib_vquotactl || \ _typ_struct_dqblk || _typ_struct_ufs_dqblk ) setint _has_std_quotas 1 else setint _has_std_quotas 0 endif if stdnfsquotas _hdr_rpc_rpc && _hdr_rpcsvc_rquota && _lib_xdr_int && \ _memberxdr_rquota_rq_bhardlimit && _memberxdr_getquota_args_gqa_uid setint _has_std_nfs_quotas 1 else setint _has_std_nfs_quotas 0 endif ifoption MCHECK if mcheckexists _hdr_mcheck && _lib_mcheck_pedantic setint _use_mcheck 1 else setint _use_mcheck 0 endif else setint _use_mcheck 0 endif ifnotoption NLS set _lib_bindtextdomain 0 set _lib_gettext 0 set _lib_setlocale 0 set _lib_textdomain 0 set _hdr_libintl 0 set _hdr_locale 0 set _command_msgfmt 0 endif if hasnls _lib_bindtextdomain && _lib_gettext && _lib_setlocale && \ _lib_textdomain && _hdr_libintl && _hdr_locale && \ _command_msgfmt setint _enable_nls 1 else set _lib_bindtextdomain 0 set _lib_gettext 0 set _lib_setlocale 0 set _lib_textdomain 0 set _hdr_libintl 0 set _hdr_locale 0 set _command_msgfmt 0 setint _enable_nls 0 endif ifnotoption WINAPI set _hdr_windows 0 set _hdr_winioctl 0 set _lib_CreateFile 0 set _lib_DeviceIoControl 0 set _lib_GetDiskFreeSpace 0 set _lib_GetDiskFreeSpaceEx 0 set _lib_GetDriveType 0 set _lib_GetLogicalDriveStrings 0 set _lib_GetVolumeInformation 0 endif # see dioptions.dat to change these option DI_DEFAULT_FORMAT smbuvpT option DI_DEFAULT_DISP_SIZE H include #if _typ_statvfs_t # define Statvfs_t statvfs_t #else # define Statvfs_t struct statvfs #endif #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif #if _typ_uint_t # define Uint_t uint_t #else # define Uint_t unsigned int #endif #if _typ_uid_t # define Uid_t uid_t #else # define Uid_t int #endif #if _typ_gid_t # define Gid_t gid_t #else # define Gid_t int #endif /* Do this the old-fashioned way for old compilers */ /* Have to work around MacOSX's snprintf macro. */ #if _lib_snprintf # define Snprintf1 snprintf # define Snprintf2 snprintf # define Snprintf3 snprintf # define Snprintf4 snprintf #else # define Snprintf1(a1,a2,a3,a4) sprintf(a1,a3,a4) # define Snprintf2(a1,a2,a3,a4,a5) sprintf(a1,a3,a4,a5) # define Snprintf3(a1,a2,a3,a4,a5,a6) sprintf(a1,a3,a4,a5,a6) # define Snprintf4(a1,a2,a3,a4,a5,a6,a7) sprintf(a1,a3,a4,a5,a6,a7) #endif #if ! _lib_strcoll # define strcoll strcmp #endif endinclude di-4.47/C/features/env.dat0000644000175000017500000000257513334050206013437 0ustar bllblloption-file ../dioptions.dat loadunit env-main loadunit env-systype loadunit env-cc loadunit env-msgfmt loadunit env-extension output di.env system type system rev system arch cc using_gcc using_gnu_ld using_clang cflags ldflags addcflag -Wextra addcflag -Wno-unused-but-set-variable addcflag -Wno-unused-parameter addcflag -Wno-float-equal addcflag -Wno-shift-sign-overflow # gcc hardening # reference: wiki.debian.org/Hardening addcflag -Wformat addcflag -Wformat-security addcflag -Werror=format-security addcflag -D_FORTIFY_SOURCE=2 # these confuse other compilers...make them GCC only # solaris will not link w/-fstack-protector, so it # can only be set when the gnu linker is in use. if UsingGNU_LD == _MKCONFIG_USING_GNU_LD Y && == _MKCONFIG_USING_GCC Y ifnotoption NO_PIE addcflag -fstack-protector-strong addcflag -fstack-protector-all addcflag -fPIE addldflag -fstack-protector-strong addldflag -fstack-protector-all addldflag -pie addldflag -Wl,-pie addldflag -Wl,-z,relro addldflag -Wl,-z,now endif endif # these confuse other compilers...make them CLANG only if UsingCLANG == _MKCONFIG_USING_CLANG Y addcflag -Werror,-Wunused-command-line-argument ifnotoption NO_PIE addcflag -fstack-protector-strong addcflag -fstack-protector-all addcflag -DPIE addcflag -fPIE addldflag -pie addldflag -Wl,-pie endif endif libs extension obj extension exe cmd_msgfmt di-4.47/C/features/getoptn.dat0000644000175000017500000000045513334050206014322 0ustar bllbll# # Copyright 2006-2018 Brad Lanam, Walnut Creek, California USA # # loadunit c-main output gconfig.h standard hdr string.h hdr strings.h hdr math.h lib fabs -lm typ size_t include #if _typ_size_t # define Size_t size_t #else # define Size_t unsigned int #endif endinclude di-4.47/C/features/mkconfig-tcl.dat0000644000175000017500000000017013334050206015211 0ustar bllblloption-file ../dioptions.dat loadunit c-main output configtcl.h hdr tcl.h lib Tcl_InitStubs -DUSE_TCL_STUBS di-4.47/C/display.h0000644000175000017500000000070513334050206012146 0ustar bllbll#ifndef DI_INC_DISPLAY_H #define DI_INC_DISPLAY_H #include "config.h" #include "di.h" # if defined (__cplusplus) || defined (c_plusplus) extern "C" { # endif /* display.c */ extern char *printDiskInfo _((diData_t *)); extern void sortArray _((diOptions_t *, diDiskInfo_t *, int, int)); extern const char *getPrintFlagText _((int)); # if defined (__cplusplus) || defined (c_plusplus) } # endif #endif /* DI_INC_DISPLAY_H */ di-4.47/C/dimain.c0000644000175000017500000010354713334050206011745 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #include "dimain.h" #include "display.h" #include "version.h" #include "options.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _hdr_ctype # include #endif #if _hdr_errno # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _hdr_libintl # include #endif #if _hdr_locale # include #endif #if _sys_stat # include #endif #if _hdr_unistd # include #endif #if _hdr_memory # include #endif #if _hdr_malloc # include #endif #if _hdr_zone # include #endif #if _sys_file # include #endif #if _hdr_fcntl \ && ! defined (DI_INC_FCNTL_H) /* xenix */ # define DI_INC_FCNTL_H # include /* O_RDONLY, O_NOCTTY */ #endif #if _use_mcheck # include #endif #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif #if _npt_getenv extern char *getenv _((const char *)); #endif #if defined (__cplusplus) || defined (c_plusplus) } #endif /* end of system specific includes/configurations */ #define DI_UNKNOWN_DEV -1L extern int debug; int debug = { 0 }; #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif #if _lib_zone_list && _lib_getzoneid && _lib_zone_getattr static void checkZone _((diDiskInfo_t *, zoneInfo_t *, unsigned int)); #endif static void checkIgnoreList _((diDiskInfo_t *, iList_t *)); static void checkIncludeList _((diDiskInfo_t *, iList_t *)); static int isIgnoreFSType _((char *)); #if _lib_realpath && _define_S_ISLNK && _lib_lstat static int checkForUUID _((char *)); #endif #if defined (__cplusplus) || defined (c_plusplus) } #endif char * #if _proto_stdc dimainproc (int argc, const char * const argv [], int intfcflag, diData_t *diData) #else dimainproc (argc, argv, intfcflag, diData) int argc; const char * const argv []; int intfcflag; diData_t *diData; #endif { diOptions_t *diopts; diOutput_t *diout; int hasLoop; int optidx; char *disp; /* initialization */ disp = (char *) NULL; diData->count = 0; diData->haspooledfs = FALSE; diData->disppooledfs = FALSE; diData->totsorted = FALSE; diData->diskInfo = (diDiskInfo_t *) NULL; diData->ignoreList.count = 0; diData->ignoreList.list = (char **) NULL; diData->includeList.count = 0; diData->includeList.list = (char **) NULL; /* options defaults */ diopts = &diData->options; diopts->formatString = DI_DEFAULT_FORMAT; /* change default display format here */ diopts->dispBlockSize = (_print_size_t) (DI_VAL_1024 * DI_VAL_1024); diopts->printTotals = FALSE; diopts->printDebugHeader = FALSE; diopts->printHeader = TRUE; diopts->localOnly = FALSE; diopts->displayAll = FALSE; diopts->dontResolveSymlink = FALSE; /* loopback devices (lofs) should be excluded by default */ diopts->excludeLoopback = FALSE; #if ! _lib_sys_dollar_device_scan /* not VMS */ diopts->excludeLoopback = TRUE; #endif strncpy (diopts->sortType, "m", DI_SORT_MAX); /* default - by mount point*/ diopts->posix_compat = FALSE; diopts->baseDispSize = (_print_size_t) DI_VAL_1024; diopts->baseDispIdx = DI_DISP_1024_IDX; diopts->quota_check = TRUE; diopts->csv_output = FALSE; diopts->csv_tabs = FALSE; diopts->exitFlag = DI_EXIT_NORM; diopts->errorCount = 0; diout = &diData->output; diout->width = 8; diout->inodeWidth = 9; diout->maxMountString = 0; /* 15 */ diout->maxSpecialString = 0; /* 18 */ diout->maxTypeString = 0; /* 7 */ diout->maxOptString = 0; diout->maxMntTimeString = 0; if (intfcflag) { diopts->csv_output = TRUE; diopts->csv_tabs = TRUE; diopts->printHeader = FALSE; } initLocale (); /* first argument is defaults */ optidx = getDIOptions (argc, argv, diData); if (diData->options.exitFlag != DI_EXIT_NORM) { return disp; } initZones (diData); if (diData->options.exitFlag != DI_EXIT_NORM) { return disp; } if (debug > 0) { printf ("di version %s\n", DI_VERSION); } /* main processing */ if (di_getDiskEntries (&diData->diskInfo, &diData->count) < 0) { cleanup (diData); return disp; } hasLoop = FALSE; preCheckDiskInfo (diData); if (optidx < argc || diopts->excludeLoopback) { getDiskStatInfo (diData); hasLoop = getDiskSpecialInfo (diData, diopts->dontResolveSymlink); } if (optidx < argc) { int rc; rc = checkFileInfo (diData, optidx, argc, argv); if (rc < 0) { cleanup (diData); diData->options.exitFlag = DI_EXIT_WARN; return disp; } } di_getDiskInfo (&diData->diskInfo, &diData->count); checkDiskInfo (diData, hasLoop); if (diopts->quota_check == TRUE) { checkDiskQuotas (diData); } disp = printDiskInfo (diData); return disp; } /* * cleanup * * free up allocated memory * */ extern void #if _proto_stdc cleanup (diData_t *diData) #else cleanup (diData) diData_t *diData; #endif { if (diData->diskInfo != (diDiskInfo_t *) NULL) { free ((char *) diData->diskInfo); } if (diData->ignoreList.count > 0 && diData->ignoreList.list != (char **) NULL) { free ((char *) diData->ignoreList.list); } if (diData->includeList.count > 0 && diData->includeList.list != (char **) NULL) { free ((char *) diData->includeList.list); } if (diData->zoneInfo.zones != (zoneSummary_t *) NULL) { free ((void *) diData->zoneInfo.zones); } } extern int #if _proto_stdc checkFileInfo ( diData_t *diData, int optidx, int argc, const char * const argv []) #else checkFileInfo (diData, optidx, argc, argv) diData_t *diData; int optidx; int argc; const char * const argv []; #endif { int rc; int i; int j; struct stat statBuf; diOptions_t *diopts; diDiskInfo_t *diskInfo; rc = 0; diopts = &diData->options; diskInfo = diData->diskInfo; if (diData->haspooledfs && ! diData->totsorted) { char tempSortType [DI_SORT_MAX + 1]; strncpy (tempSortType, diopts->sortType, DI_SORT_MAX); strncpy (diopts->sortType, "s", DI_SORT_MAX); sortArray (diopts, diskInfo, diData->count, DI_TOT_SORT_IDX); strncpy (diopts->sortType, tempSortType, DI_SORT_MAX); diData->totsorted = TRUE; } for (i = optidx; i < argc; ++i) { int fd; int src; /* do this to automount devices. */ /* stat() will not necessarily cause an automount. */ fd = open (argv[i], O_RDONLY | O_NOCTTY); if (fd < 0) { src = stat (argv [i], &statBuf); } else { src = fstat (fd, &statBuf); } if (src == 0) { int saveIdx; int found = { FALSE }; int inpool = { FALSE }; Size_t lastpoollen = { 0 }; char lastpool [DI_SPEC_NAME_LEN + 1]; saveIdx = 0; /* should get overridden below */ for (j = 0; j < diData->count; ++j) { diDiskInfo_t *dinfo; int startpool; int poolmain; startpool = FALSE; poolmain = FALSE; dinfo = &(diskInfo [diskInfo [j].sortIndex[DI_TOT_SORT_IDX]]); /* is it a pooled filesystem type? */ if (diData->haspooledfs && di_isPooledFs (dinfo)) { if (lastpoollen == 0 || strncmp (lastpool, dinfo->special, lastpoollen) != 0) { strncpy (lastpool, dinfo->special, DI_SPEC_NAME_LEN); lastpoollen = di_mungePoolName (lastpool); inpool = FALSE; } if (strncmp (lastpool, dinfo->special, lastpoollen) == 0) { startpool = TRUE; if (inpool == FALSE) { poolmain = TRUE; } } } else { inpool = FALSE; } if (poolmain) { saveIdx = j; } if (found && inpool) { dinfo = &(diskInfo [diskInfo [j].sortIndex[DI_TOT_SORT_IDX]]); dinfo->printFlag = DI_PRNT_SKIP; if (debug > 2) { printf (" inpool B: also process %s %s\n", dinfo->special, dinfo->name); } } if (dinfo->st_dev != (__ulong) DI_UNKNOWN_DEV && (__ulong) statBuf.st_dev == dinfo->st_dev && ! dinfo->isLoopback) { int foundnew = 0; ++foundnew; if (dinfo->printFlag == DI_PRNT_OK) { ++foundnew; } if (! isIgnoreFSType (dinfo->fsType)) { ++foundnew; } if (foundnew == 3) { dinfo->printFlag = DI_PRNT_FORCE; } found = TRUE; if (debug > 2) { printf ("file %s specified: found device %ld : %d (%s %s)\n", argv[i], dinfo->st_dev, foundnew, dinfo->special, dinfo->name); } if (inpool) { int k; for (k = saveIdx; k < j; ++k) { dinfo = &(diskInfo [diskInfo [k].sortIndex[DI_TOT_SORT_IDX]]); dinfo->printFlag = DI_PRNT_SKIP; if (debug > 2) { printf (" inpool A: also process %s %s\n", dinfo->special, dinfo->name); } } } } if (startpool) { inpool = TRUE; } } } /* if stat ok */ else { if (errno != EACCES) { fprintf (stderr, "stat: %s ", argv[i]); perror (""); } rc = -1; } if (fd >= 0) { close (fd); } } /* for each file specified on command line */ /* turn everything off */ for (j = 0; j < diData->count; ++j) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[j]; if (dinfo->printFlag == DI_PRNT_OK) { dinfo->printFlag = DI_PRNT_IGNORE; } } /* also turn off the -I and -x lists */ diData->includeList.count = 0; diData->ignoreList.count = 0; return rc; } /* * getDiskStatInfo * * gets the disk device number for each entry. * */ extern void #if _proto_stdc getDiskStatInfo (diData_t *diData) #else getDiskStatInfo (diData) diData_t *diData; #endif { int i; struct stat statBuf; for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo [i]; /* don't try to stat devices that are not accessible */ if (dinfo->printFlag == DI_PRNT_EXCLUDE || dinfo->printFlag == DI_PRNT_BAD || dinfo->printFlag == DI_PRNT_OUTOFZONE) { continue; } dinfo->st_dev = (__ulong) DI_UNKNOWN_DEV; if (stat (dinfo->name, &statBuf) == 0) { dinfo->st_dev = (__ulong) statBuf.st_dev; if (debug > 2) { printf ("dev: %s: %ld\n", dinfo->name, dinfo->st_dev); } } else { if (errno != EACCES) { fprintf (stderr, "stat: %s ", dinfo->name); perror (""); } } } } /* * getDiskSpecialInfo * * gets the disk device number for each entry. * */ extern int #if _proto_stdc getDiskSpecialInfo (diData_t *diData, unsigned int dontResolveSymlink) #else getDiskSpecialInfo (diData, dontResolveSymlink) diData_t *diData; unsigned int dontResolveSymlink; #endif { int i; struct stat statBuf; int hasLoop; hasLoop = FALSE; for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; int rc; dinfo = &diData->diskInfo [i]; /* check for initial slash; otherwise we can pick up normal files */ if (*(dinfo->special) == '/' && stat (dinfo->special, &statBuf) == 0) { #if _lib_realpath && _define_S_ISLNK && _lib_lstat if (! dontResolveSymlink && checkForUUID (dinfo->special)) { struct stat tstatBuf; rc = lstat (dinfo->special, &tstatBuf); if (rc == 0 && S_ISLNK(tstatBuf.st_mode)) { char tspecial [DI_SPEC_NAME_LEN + 1]; if (realpath (dinfo->special, tspecial) != (char *) NULL) { strncpy (dinfo->special, tspecial, DI_SPEC_NAME_LEN); } } } #endif dinfo->sp_dev = (__ulong) statBuf.st_dev; dinfo->sp_rdev = (__ulong) statBuf.st_rdev; /* Solaris's loopback device is "lofs" */ /* linux loopback device is "none" */ /* linux has rdev = 0 */ /* DragonFlyBSD's loopback device is "null" */ /* but not with special = /.../@@- */ /* DragonFlyBSD has rdev = -1 */ /* solaris is more consistent; rdev != 0 for lofs */ /* solaris makes sense. */ if (di_isLoopbackFs (dinfo)) { dinfo->isLoopback = TRUE; hasLoop = TRUE; } if (debug > 2) { printf ("special dev: %s %s: %ld rdev: %ld loopback: %d\n", dinfo->special, dinfo->name, dinfo->sp_dev, dinfo->sp_rdev, dinfo->isLoopback); } } else { dinfo->sp_dev = 0; dinfo->sp_rdev = 0; } } return hasLoop; } /* * checkDiskInfo * * checks the disk information returned for various return values. * */ extern void #if _proto_stdc checkDiskInfo (diData_t *diData, int hasLoop) #else checkDiskInfo (diData, hasLoop) diData_t *diData; int hasLoop; #endif { int i; int j; _fs_size_t temp; diOptions_t *diopts; diopts = &diData->options; for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[i]; dinfo->doPrint = TRUE; /* these are never printed... */ if (dinfo->printFlag == DI_PRNT_EXCLUDE || dinfo->printFlag == DI_PRNT_BAD || dinfo->printFlag == DI_PRNT_OUTOFZONE) { if (debug > 2) { printf ("chk: skipping(%s):%s\n", getPrintFlagText ((int) dinfo->printFlag), dinfo->name); } dinfo->doPrint = FALSE; continue; } /* need to check against include list */ if (dinfo->printFlag == DI_PRNT_IGNORE || dinfo->printFlag == DI_PRNT_SKIP) { if (debug > 2) { printf ("chk: skipping(%s):%s\n", getPrintFlagText ((int) dinfo->printFlag), dinfo->name); } dinfo->doPrint = (char) diopts->displayAll; } /* Solaris reports a cdrom as having no free blocks, */ /* no available. Their df doesn't always work right! */ /* -1 is returned. */ if (debug > 5) { #if _siz_long_long >= 8 printf ("chk: %s free: %llu\n", dinfo->name, dinfo->freeSpace); #else printf ("chk: %s free: %lu\n", dinfo->name, dinfo->freeSpace); #endif } if ((_s_fs_size_t) dinfo->freeSpace == -1L || (_s_fs_size_t) dinfo->freeSpace == -2L) { dinfo->freeSpace = 0L; } if ((_s_fs_size_t) dinfo->availSpace == -1L || (_s_fs_size_t) dinfo->availSpace == -2L) { dinfo->availSpace = 0L; } temp = (_fs_size_t) ~ 0; if (dinfo->totalInodes == temp) { dinfo->totalInodes = 0; dinfo->freeInodes = 0; dinfo->availInodes = 0; } if (dinfo->printFlag == DI_PRNT_OK) { if (debug > 5) { #if _siz_long_long >= 8 printf ("chk: %s total: %lld\n", dinfo->name, dinfo->totalSpace); #else printf ("chk: %s total: %ld\n", dinfo->name, dinfo->totalSpace); #endif } if (isIgnoreFSType (dinfo->fsType)) { dinfo->printFlag = DI_PRNT_IGNORE; dinfo->doPrint = (char) diopts->displayAll; if (debug > 2) { printf ("chk: ignore: rootfs/procfs/devfs/devtmpfs: %s\n", dinfo->name); } } /* Some systems return a -1 or -2 as an indicator. */ if (dinfo->totalSpace == 0L || (_s_fs_size_t) dinfo->totalSpace == -1L || (_s_fs_size_t) dinfo->totalSpace == -2L) { dinfo->printFlag = DI_PRNT_IGNORE; dinfo->doPrint = (char) diopts->displayAll; if (debug > 2) { printf ("chk: ignore: totalSpace <= 0: %s\n", dinfo->name); } } } /* make sure anything in the include list didn't get turned off */ checkIncludeList (dinfo, &diData->includeList); } /* for all disks */ if (hasLoop && diopts->excludeLoopback) { /* this loop sets duplicate entries to be ignored. */ for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[i]; if (dinfo->printFlag != DI_PRNT_OK) { if (debug > 2) { printf ("dup: chk: skipping(%s):%s\n", getPrintFlagText ((int) dinfo->printFlag), dinfo->name); } continue; } /* don't need to bother checking real partitions */ if (dinfo->sp_dev != 0 && dinfo->isLoopback) { __ulong sp_dev; __ulong sp_rdev; sp_dev = dinfo->sp_dev; sp_rdev = dinfo->sp_rdev; if (debug > 2) { printf ("dup: chk: i: %s dev: %ld rdev: %ld\n", dinfo->name, sp_dev, sp_rdev); } for (j = 0; j < diData->count; ++j) { diDiskInfo_t *dinfob; if (i == j) { continue; } dinfob = &diData->diskInfo [j]; if (dinfob->sp_dev != 0 && dinfob->st_dev == sp_dev) { if (debug > 2) { printf ("dup: for %s %ld: found: %s %ld\n", dinfo->name, sp_dev, dinfob->name, dinfob->st_dev); } dinfo->printFlag = DI_PRNT_IGNORE; dinfo->doPrint = (char) diopts->displayAll; if (debug > 2) { printf ("dup: chk: ignore: %s duplicate of %s\n", dinfo->name, dinfob->name); printf ("dup: j: dev: %ld rdev: %ld \n", dinfob->sp_dev, dinfob->sp_rdev); } } /* if dup */ } } /* if this is a loopback, non-real */ else { if (debug > 2) { printf ("chk: dup: not checked: %s prnt: %d dev: %ld rdev: %ld %s\n", dinfo->name, dinfo->printFlag, dinfo->sp_dev, dinfo->sp_rdev, dinfo->fsType); } } } /* for each disk */ } /* if the duplicate loopback mounts are to be excluded */ } extern void #if _proto_stdc checkDiskQuotas (diData_t *diData) #else checkDiskQuotas (diData) diData_t *diData; #endif { int i; Uid_t uid; Gid_t gid; diQuota_t diqinfo; _fs_size_t tsize; uid = 0; gid = 0; #if _has_std_quotas uid = geteuid (); gid = getegid (); #endif for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[i]; if (! dinfo->doPrint) { continue; } diqinfo.special = dinfo->special; diqinfo.name = dinfo->name; diqinfo.type = dinfo->fsType; diqinfo.uid = uid; diqinfo.gid = gid; diquota (&diqinfo); if (debug > 2) { printf ("quota: %s limit: %lld\n", dinfo->name, diqinfo.limit); printf ("quota: tot: %lld\n", dinfo->totalSpace); printf ("quota: %s used: %lld\n", dinfo->name, diqinfo.used); printf ("quota: avail: %lld\n", dinfo->availSpace); } if (diqinfo.limit != 0 && diqinfo.limit < dinfo->totalSpace) { dinfo->totalSpace = diqinfo.limit; tsize = diqinfo.limit - diqinfo.used; if ((_s_fs_size_t) tsize < 0) { tsize = 0; } if (tsize < dinfo->availSpace) { dinfo->availSpace = tsize; dinfo->freeSpace = tsize; if (debug > 2) { printf ("quota: using quota for: total free avail\n"); } } else if (tsize > dinfo->availSpace && tsize < dinfo->freeSpace) { dinfo->freeSpace = tsize; if (debug > 2) { printf ("quota: using quota for: total free\n"); } } else { if (debug > 2) { printf ("quota: using quota for: total\n"); } } } if (diqinfo.ilimit != 0 && diqinfo.ilimit < dinfo->totalInodes) { dinfo->totalInodes = diqinfo.ilimit; tsize = diqinfo.ilimit - diqinfo.iused; if ((_s_fs_size_t) tsize < 0) { tsize = 0; } if (tsize < dinfo->availInodes) { dinfo->availInodes = tsize; dinfo->freeInodes = tsize; if (debug > 2) { printf ("quota: using quota for inodes: total free avail\n"); } } else if (tsize > dinfo->availInodes && tsize < dinfo->freeInodes) { dinfo->freeInodes = tsize; if (debug > 2) { printf ("quota: using quota for inodes: total free\n"); } } else { if (debug > 2) { printf ("quota: using quota for inodes: total\n"); } } } } return; } /* * preCheckDiskInfo * * checks for ignore/include list; check for remote filesystems * and local only flag set. * checks for zones (Solaris) * */ extern void #if _proto_stdc preCheckDiskInfo (diData_t *diData) #else preCheckDiskInfo (diData) diData_t *diData; #endif { int i; diOptions_t *diopts; int hasLoop; hasLoop = FALSE; diopts = &diData->options; for (i = 0; i < diData->count; ++i) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[i]; dinfo->sortIndex[0] = (unsigned int) i; dinfo->sortIndex[1] = (unsigned int) i; if (debug > 4) { printf ("## prechk:%s:\n", dinfo->name); } #if _lib_zone_list && _lib_getzoneid && _lib_zone_getattr checkZone (dinfo, &diData->zoneInfo, diopts->displayAll); #endif if (di_isPooledFs (dinfo)) { diData->haspooledfs = TRUE; } if (dinfo->printFlag == DI_PRNT_OK) { /* don't bother w/this check is all flag is set. */ if (! diopts->displayAll) { di_testRemoteDisk (dinfo); if (dinfo->isLocal == FALSE && diopts->localOnly) { dinfo->printFlag = DI_PRNT_IGNORE; if (debug > 2) { printf ("prechk: ignore: remote disk; local flag set: %s\n", dinfo->name); } } } } if (dinfo->printFlag == DI_PRNT_OK || dinfo->printFlag == DI_PRNT_IGNORE) { /* do these checks to override the all flag */ checkIgnoreList (dinfo, &diData->ignoreList); checkIncludeList (dinfo, &diData->includeList); } } /* for all disks */ } static void #if _proto_stdc checkIgnoreList (diDiskInfo_t *diskInfo, iList_t *ignoreList) #else checkIgnoreList (diskInfo, ignoreList) diDiskInfo_t *diskInfo; iList_t *ignoreList; #endif { char *ptr; int i; /* if the file system type is in the ignore list, skip it */ if (ignoreList->count > 0) { for (i = 0; i < ignoreList->count; ++i) { ptr = ignoreList->list [i]; if (debug > 2) { printf ("chkign: test: fstype %s/%s : %s\n", ptr, diskInfo->fsType, diskInfo->name); } if (strcmp (ptr, diskInfo->fsType) == 0 || (strcmp (ptr, "fuse") == 0 && strncmp ("fuse", diskInfo->fsType, (Size_t) 4) == 0)) { diskInfo->printFlag = DI_PRNT_EXCLUDE; diskInfo->doPrint = FALSE; if (debug > 2) { printf ("chkign: ignore: fstype %s match: %s\n", ptr, diskInfo->name); } break; } } } /* if an ignore list was specified */ } static void #if _proto_stdc checkIncludeList (diDiskInfo_t *diskInfo, iList_t *includeList) #else checkIncludeList (diskInfo, includeList) diDiskInfo_t *diskInfo; iList_t *includeList; #endif { char *ptr; int i; /* if the file system type is not in the include list, skip it */ if (includeList->count > 0) { for (i = 0; i < includeList->count; ++i) { ptr = includeList->list [i]; if (debug > 2) { printf ("chkinc: test: fstype %s/%s : %s\n", ptr, diskInfo->fsType, diskInfo->name); } if (strcmp (ptr, diskInfo->fsType) == 0 || (strcmp (ptr, "fuse") == 0 && strncmp ("fuse", diskInfo->fsType, (Size_t) 4) == 0)) { diskInfo->printFlag = DI_PRNT_OK; diskInfo->doPrint = TRUE; if (debug > 2) { printf ("chkinc:include:fstype %s match: %s\n", ptr, diskInfo->name); } break; } else { diskInfo->printFlag = DI_PRNT_EXCLUDE; diskInfo->doPrint = FALSE; if (debug > 2) { printf ("chkinc:!include:fstype %s no match: %s\n", ptr, diskInfo->name); } } } } /* if an include list was specified */ } #if _lib_zone_list && _lib_getzoneid && _lib_zone_getattr static void # if _proto_stdc checkZone (diDiskInfo_t *diskInfo, zoneInfo_t *zoneInfo, unsigned int allFlag) # else checkZone (diskInfo, zoneInfo, allFlag) diDiskInfo_t *diskInfo; zoneInfo_t *zoneInfo; unsigned int allFlag; # endif { int i; int idx = { -1 }; if (strcmp (zoneInfo->zoneDisplay, "all") == 0 && zoneInfo->uid == 0) { return; } for (i = 0; i < (int) zoneInfo->zoneCount; ++i) { /* find the zone the filesystem is in, if non-global */ if (debug > 5) { printf (" checkZone:%s:compare:%d:%s:\n", diskInfo->name, zoneInfo->zones[i].rootpathlen, zoneInfo->zones[i].rootpath); } if (strncmp (zoneInfo->zones[i].rootpath, diskInfo->name, zoneInfo->zones[i].rootpathlen) == 0) { if (debug > 4) { printf (" checkZone:%s:found zone:%s:\n", diskInfo->name, zoneInfo->zones[i].name); } idx = i; break; } if (idx == -1) { idx = zoneInfo->globalIdx; } } /* no root access, ignore any zones */ /* that don't match our zone id */ /* this will override any ignore flags */ /* already set */ if (zoneInfo->uid != 0) { if (debug > 5) { printf (" checkZone:uid non-zero:chk zone:%d:%d:\n", (int) zoneInfo->myzoneid, (int) zoneInfo->zones[idx].zoneid); } if (zoneInfo->myzoneid != zoneInfo->zones[idx].zoneid) { if (debug > 4) { printf (" checkZone:not root, not zone:%d:%d:outofzone:\n", (int) zoneInfo->myzoneid, (int) zoneInfo->zones[idx].zoneid); } diskInfo->printFlag = DI_PRNT_OUTOFZONE; } } if (debug > 5) { printf (" checkZone:chk name:%s:%s:\n", zoneInfo->zoneDisplay, zoneInfo->zones[idx].name); } /* not the zone we want. ignore */ if (! allFlag && diskInfo->printFlag == DI_PRNT_OK && strcmp (zoneInfo->zoneDisplay, "all") != 0 && strcmp (zoneInfo->zoneDisplay, zoneInfo->zones[idx].name) != 0) { if (debug > 4) { printf (" checkZone:wrong zone:ignore:\n"); } diskInfo->printFlag = DI_PRNT_IGNORE; } /* if displaying a non-global zone, */ /* don't display loopback filesystems */ if (! allFlag && diskInfo->printFlag == DI_PRNT_OK && strcmp (zoneInfo->zoneDisplay, "global") != 0 && diskInfo->isLoopback) { if (debug > 4) { printf (" checkZone:non-global/lofs:ignore:\n"); } diskInfo->printFlag = DI_PRNT_IGNORE; } return; } #endif extern void #if _proto_stdc initLocale (void) #else initLocale () #endif { #if _enable_nls const char *localeptr; #endif #if _lib_setlocale && defined (LC_ALL) setlocale (LC_ALL, ""); #endif #if _enable_nls if ((localeptr = getenv ("DI_LOCALE_DIR")) == (char *) NULL) { localeptr = DI_LOCALE_DIR; } bindtextdomain ("di", localeptr); textdomain ("di"); #endif } extern void #if _proto_stdc initZones (diData_t *diData) #else initZones (diData) diData_t *diData; #endif { #if _lib_zone_list && _lib_getzoneid && _lib_zone_getattr diData->zoneInfo.uid = geteuid (); #endif diData->zoneInfo.zoneDisplay [0] = '\0'; diData->zoneInfo.zoneCount = 0; diData->zoneInfo.zones = (zoneSummary_t *) NULL; #if _lib_zone_list && _lib_getzoneid && _lib_zone_getattr { int i; zoneid_t *zids = (zoneid_t *) NULL; zoneInfo_t *zi; zi = &diData->zoneInfo; zi->myzoneid = getzoneid (); if (zone_list (zids, &zi->zoneCount) == 0) { if (zi->zoneCount > 0) { zids = malloc (sizeof (zoneid_t) * zi->zoneCount); if (zids == (zoneid_t *) NULL) { fprintf (stderr, "malloc failed in main() (1). errno %d\n", errno); diData->options.exitFlag = DI_EXIT_FAIL; return; } zone_list (zids, &zi->zoneCount); zi->zones = malloc (sizeof (zoneSummary_t) * zi->zoneCount); if (zi->zones == (zoneSummary_t *) NULL) { fprintf (stderr, "malloc failed in main() (2). errno %d\n", errno); diData->options.exitFlag = DI_EXIT_FAIL; return; } } } zi->globalIdx = 0; for (i = 0; i < (int) zi->zoneCount; ++i) { int len; zi->zones[i].zoneid = zids[i]; len = zone_getattr (zids[i], ZONE_ATTR_ROOT, zi->zones[i].rootpath, MAXPATHLEN); if (len >= 0) { zi->zones[i].rootpathlen = (Size_t) len; strncat (zi->zones[i].rootpath, "/", MAXPATHLEN); if (zi->zones[i].zoneid == 0) { zi->globalIdx = i; } len = zone_getattr (zids[i], ZONE_ATTR_NAME, zi->zones[i].name, ZONENAME_MAX); if (*zi->zoneDisplay == '\0' && zi->myzoneid == zi->zones[i].zoneid) { strncpy (zi->zoneDisplay, zi->zones[i].name, MAXPATHLEN); } if (debug > 4) { printf ("zone:%d:%s:%s:\n", (int) zi->zones[i].zoneid, zi->zones[i].name, zi->zones[i].rootpath); } } } free ((void *) zids); } if (debug > 4) { printf ("zone:my:%d:%s:glob:%d:\n", (int) diData->zoneInfo.myzoneid, diData->zoneInfo.zoneDisplay, diData->zoneInfo.globalIdx); } #endif } static int #if _proto_stdc isIgnoreFSType (char *fstype) #else isIgnoreFSType (fstype) char *fstype; #endif { if (strcmp (fstype, "rootfs") == 0 || strcmp (fstype, "procfs") == 0 || strcmp (fstype, "ptyfs") == 0 || strcmp (fstype, "kernfs") == 0 || strcmp (fstype, "devfs") == 0 || strcmp (fstype, "devtmpfs") == 0) { return TRUE; } return FALSE; } #if _lib_realpath && _define_S_ISLNK && _lib_lstat static int # if _proto_stdc checkForUUID (char *spec) # else checkForUUID (spec) char *spec; # endif { /* * /dev/mapper/luks-828fc648-9f30-43d8-a0b1-f7196a2edb66 * /dev/disk/by-uuid/cfbbd7b3-b37a-4587-a711-58fd36b2cac6 * 1 2 3 4 * 01234567890123456789012345678901234567890 * cfbbd7b3-b37a-4587-a711-58fd36b2cac6 */ Size_t len; len = strlen (spec); if (len > 36) { Size_t offset; offset = len - 36; if (*(spec + offset + 8) == '-' && *(spec + offset + 13) == '-' && *(spec + offset + 18) == '-' && *(spec + offset + 23) == '-' && strspn (spec + offset, "-1234567890abcdef") == 36) { return TRUE; } } return FALSE; } #endif /* have _lib_realpath, etc. */ di-4.47/C/dimain.h0000644000175000017500000000166413334050206011747 0ustar bllbll#ifndef DI_INC_DIMAIN_H #define DI_INC_DIMAIN_H /* * Copyright 2016-2018 Brad Lanam Walnut Creek CA USA */ #include "config.h" #include "di.h" # if defined (__cplusplus) || defined (c_plusplus) extern "C" { # endif #if ! _dcl_errno extern int errno; #endif /* dimain.c */ extern char *dimainproc _((int, const char * const [], int, diData_t *)); extern void checkDiskInfo _((diData_t *, int)); extern void checkDiskQuotas _((diData_t *)); extern int checkFileInfo _((diData_t *, int, int, const char *const[])); extern void cleanup _((diData_t *)); extern int getDiskSpecialInfo _((diData_t *, unsigned int)); extern void getDiskStatInfo _((diData_t *)); extern void preCheckDiskInfo _((diData_t *)); extern void initLocale _((void)); extern void initZones _((diData_t *)); # if defined (__cplusplus) || defined (c_plusplus) } # endif #endif /* DI_INC_DIMAIN_H */ di-4.47/C/trimchar.c0000644000175000017500000000106713334050206012307 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif void #if _proto_stdc trimChar (char *str, int ch) #else trimChar (str, ch) char *str; int ch; #endif { int len; len = (int) strlen (str); if (len > 0) { --len; } if (len >= 0) { if (str [len] == ch) { str [len] = '\0'; } } } di-4.47/C/getoptn.h0000644000175000017500000000255113334050206012162 0ustar bllbll/* * Copyright 2011-2018 Brad Lanam, Walnut Creek, CA */ #ifndef DI_INC_GETOPTN_H_ #define DI_INC_GETOPTN_H_ #if defined(TEST_GETOPTN) # include "gconfig.h" #else # include "config.h" #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if ! defined (TRUE) # define TRUE 1 #endif #if ! defined (FALSE) # define FALSE 0 #endif #define GETOPTN_NOTFOUND -1 /* option style */ /* GETOPTN_LEGACY: * -ab processes both -a and -b flags. * GETOPTN_MODERN: * -ab processes -ab flag. */ #define GETOPTN_LEGACY 'l' #define GETOPTN_MODERN 'm' /* option types */ #define GETOPTN_BOOL 0 /* flips the value */ #define GETOPTN_INT 1 #define GETOPTN_LONG 2 #define GETOPTN_DOUBLE 3 #define GETOPTN_STRING 4 #define GETOPTN_STRPTR 5 #define GETOPTN_FUNC_BOOL 6 #define GETOPTN_FUNC_VALUE 7 #define GETOPTN_ALIAS 8 #define GETOPTN_IGNORE 9 #define GETOPTN_SIZET 10 typedef struct { const char *option; int option_type; void *valptr; Size_t valsiz; void *value2; } getoptn_opt_t; extern int getoptn _((int style, int argc, const char * const argv [], Size_t optcount, getoptn_opt_t opts [], int *errorCount)); #endif /*DI_INC_GETOPTN_H_ */ di-4.47/C/di.c0000644000175000017500000000671213334050206011074 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ /* * di.c * * Warning: Do not replace your system's 'df' command with this program. * You will in all likelihood break your installation procedures. * * Display sizes: * 512 - posix (512 bytes) * k - kilobytes * m - megabytes * g - gigabytes * t - terabytes * P - petabytes * E - exabytes * h - "human readable" scaled alternative 1 * H - "human readable" scaled alternative 2 * * Sort types: * N - name (default) * n - none (mount order) * s - special * a - avail * t - type * r - reverse sort * * Format string values: * m - mount point * M - mount point, full length * b - total kbytes * B - total kbytes available for use by the user. * [ (tot - (free - avail)) ] * u - kbytes used (actual number of kbytes used) [ (tot - free) ] * c - calculated number of kbytes used [ (tot - avail) ] * f - kbytes free * v - kbytes available * p - percentage not available for use. * (space not available for use / total disk space) * [ (tot - avail) / tot ] * 1 - percentage used. * (actual space used / total disk space) * [ (tot - free) / tot ] * 2 - percentage of user-available space in use (bsd style). * Note that values over 100% are possible. * (actual space used / disk space available to user) * [ (tot - free) / (tot - (free - avail)) ] * i - total i-nodes (files) * U - used i-nodes * F - free i-nodes * P - percent i-nodes used [ (tot - avail) / tot ] * s - filesystem name (special) * S - filesystem name (special), full length * t - disk partition type * T - disk partition type (full length) * I - mount time * O - mount options. * * System V.4 `/usr/bin/df -v` Has format: msbuf1 * System V.4 `/usr/bin/df -k` Has format: sbcvpm * System V.4 `/usr/ucb/df` Has format: sbuv2m * * The default format string for this program is: smbuvpT * * Environment variables: * DI_ARGS: specifies any arguments to di. * POSIXLY_CORRECT: forces posix mode. * BLOCKSIZE: BSD df block size. * DF_BLOCK_SIZE: GNU df block size. * * Note that for filesystems that do not have, or systems (SysV.3) * that do not report, available space, the amount of available space is * set to the free space. * */ #include "config.h" #include "dimain.h" #include "di.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _use_mcheck # include #endif /* end of system specific includes/configurations */ int #if _proto_stdc main (int argc, const char * argv []) #else main (argc, argv) int argc; const char * argv []; #endif { char *disp; diData_t diData; #if _use_mcheck mcheck_pedantic (NULL); mtrace (); #endif disp = dimainproc (argc, argv, 0, &diData); if (diData.options.exitFlag == DI_EXIT_FAIL) { exit (2); } if (diData.options.exitFlag == DI_EXIT_WARN) { exit (1); } if (diData.options.exitFlag == DI_EXIT_OK) { exit (0); } if (disp != (char *) NULL) { fputs (disp, stdout); free (disp); } cleanup (&diData); return 0; } di-4.47/C/options.c0000644000175000017500000006304513334050206012175 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #include "getoptn.h" #include "options.h" #include "version.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _hdr_ctype # include #endif #if _hdr_errno # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _hdr_libintl # include #endif #if _use_mcheck # include #endif struct pa_tmp { diData_t *diData; diOptions_t *diopts; diOutput_t *diout; char *dbsstr; Size_t dbsstr_sz; }; typedef struct { _print_size_t size; const char *disp[2]; } dispTable_t; static dispTable_t dispTable [] = { { (_print_size_t) 0.0, { "KBytes", "KBytes" } }, { (_print_size_t) 0.0, { "Megs", "Mebis" } }, { (_print_size_t) 0.0, { "Gigs", "Gibis" } }, { (_print_size_t) 0.0, { "Teras", "Tebis" } }, { (_print_size_t) 0.0, { "Petas", "Pebis" } }, { (_print_size_t) 0.0, { "Exas", "Exbis" } }, { (_print_size_t) 0.0, { "Zettas", "Zebis" } }, { (_print_size_t) 0.0, { "Yottas", "Yobis" } } }; #define DI_DISPTAB_SIZE (sizeof (dispTable) / sizeof (dispTable_t)) #define DI_ARGV_SEP " " /* space, tab */ #define DI_MAX_ARGV 50 #define DI_LIST_SEP "," #define DI_POSIX_FORMAT "SbuvpM" #define DI_DEF_MOUNT_FORMAT "MST\n\tO" #define DI_ALL_FORMAT "MTS\n\tO\n\tbuf13\n\tbcvpa\n\tBuv2\n\tiUFP" # if defined (__cplusplus) || defined (c_plusplus) extern "C" { # endif extern int debug; static void processStringArgs _((char *, diData_t *, char *)); static int processArgs _((int, const char * const [], diData_t *, char *, Size_t)); static int parseList _((iList_t *, char *)); static void processOptions _((const char *, char *)); static void processOptionsVal _((const char *, char *, char *)); static void usage _((void)); static void setDispBlockSize _((char *, diOptions_t *, diOutput_t *)); static void initDisplayTable _((diOptions_t *)); static void setExitFlag _((diOptions_t *, unsigned int)); # if defined (__cplusplus) || defined (c_plusplus) } # endif static void #if _proto_stdc processStringArgs (char *ptr, diData_t *diData, char *dbsstr) #else processStringArgs (ptr, diData, dbsstr) char *ptr; diData_t *diData; char *dbsstr; #endif { char *dptr; char *tptr; int nargc; const char *nargv [DI_MAX_ARGV]; diOptions_t *diopts; if (ptr == (char *) NULL || strcmp (ptr, "") == 0) { return; } diopts = &diData->options; dptr = (char *) NULL; dptr = strdup (ptr); if (dptr == (char *) NULL) { fprintf (stderr, "strdup failed in main() (1). errno %d\n", errno); setExitFlag (diopts, DI_EXIT_FAIL); return; } if (dptr != (char *) NULL) { tptr = strtok (dptr, DI_ARGV_SEP); nargc = 1; nargv[0] = ""; while (tptr != (char *) NULL) { if (nargc >= DI_MAX_ARGV) { break; } nargv[nargc++] = tptr; tptr = strtok ((char *) NULL, DI_ARGV_SEP); } processArgs (nargc, nargv, diData, dbsstr, sizeof (dbsstr) - 1); free ((char *) dptr); } } int #if _proto_stdc getDIOptions (int argc, const char * const argv[], diData_t *diData) #else getDIOptions (argc, argv, diData) int argc; const char * const argv[]; diData_t *diData; #endif { const char * argvptr; char * ptr; char dbsstr [30]; int optidx; int ec; diOptions_t *diopts; diOutput_t *diout; diopts = &diData->options; diout = &diData->output; strncpy (dbsstr, DI_DEFAULT_DISP_SIZE, sizeof (dbsstr)); /* default */ ec = 0; argvptr = argv [0] + strlen (argv [0]) - 2; if (memcmp (argvptr, "mi", (Size_t) 2) == 0) { diopts->formatString = DI_DEF_MOUNT_FORMAT; } else /* don't use DIFMT env var if running mi. */ { if ((ptr = getenv ("DIFMT")) != (char *) NULL) { diopts->formatString = ptr; } } /* gnu df */ if ((ptr = getenv ("POSIXLY_CORRECT")) != (char *) NULL) { strncpy (dbsstr, "512", sizeof (dbsstr)); diopts->formatString = DI_POSIX_FORMAT; diopts->posix_compat = TRUE; diopts->csv_output = FALSE; } /* bsd df */ if ((ptr = getenv ("BLOCKSIZE")) != (char *) NULL) { strncpy (dbsstr, ptr, sizeof (dbsstr)-1); } /* gnu df */ if ((ptr = getenv ("DF_BLOCK_SIZE")) != (char *) NULL) { strncpy (dbsstr, ptr, sizeof (dbsstr)-1); } if ((ptr = getenv ("DI_ARGS")) != (char *) NULL) { if (debug > 0) { printf ("# DI_ARGS:%s\n", ptr); } processStringArgs (ptr, diData, dbsstr); } if (debug > 0) { int j; printf ("# ARGS:"); for (j = 0; j < argc; ++j) { printf (" %s", argv[j]); } printf ("\n"); printf ("# blocksize: %s\n", dbsstr); } optidx = processArgs (argc, argv, diData, dbsstr, sizeof (dbsstr) - 1); initDisplayTable (diopts); setDispBlockSize (dbsstr, diopts, diout); return optidx; } static int #if _proto_stdc processArgs (int argc, const char * const argv [], diData_t *diData, char *dbsstr, Size_t dbsstr_sz) #else processArgs (argc, argv, diData, dbsstr, dbsstr_sz) int argc; const char * const argv []; diData_t *diData; char *dbsstr; Size_t dbsstr_sz; #endif { int i; int optidx; int errorCount; diOptions_t *diopts; diOutput_t *diout; struct pa_tmp padata; /* the really old compilers don't have automatic initialization */ static getoptn_opt_t opts[] = { { "-A", GETOPTN_STRPTR, /* 0 */ NULL /*&diopts->formatString*/, 0, (void *) DI_ALL_FORMAT }, { "-a", GETOPTN_FUNC_BOOL, NULL /*&padata*/, 0, NULL /*processOptions*/ }, { "--all", GETOPTN_ALIAS, (void *) "-a", 0, NULL }, { "-B", GETOPTN_FUNC_VALUE, NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "-b", GETOPTN_ALIAS, (void *) "-B", 0, NULL }, { "--block-size", GETOPTN_ALIAS, /* 5 */ (void *) "-B", 0, NULL }, { "-c", GETOPTN_BOOL, NULL /*&diopts->csv_output*/, 0 /*sizeof(diopts->csv_output)*/, NULL }, { "-C", GETOPTN_BOOL, NULL /*&diopts->csv_tabs*/, 0 /*sizeof(diopts->csv_tabs)*/, NULL }, { "--csv-output", GETOPTN_ALIAS, (void *) "-c", 0, NULL }, { "--csv-tabs", GETOPTN_ALIAS, (void *) "-C", 0, NULL }, { "-d", GETOPTN_STRING, /* 10 */ NULL /*dbsstr*/, 0 /*dbsstr_sz*/, NULL }, { "--display-size", GETOPTN_ALIAS, (void *) "-d", 0, NULL }, { "--dont-resolve-symlink", GETOPTN_ALIAS, /* 12 */ (void *) "-R", 0, NULL }, { "-f", GETOPTN_STRPTR, /* 13 */ NULL /*&diopts->formatString*/, 0, NULL }, { "--format-string", GETOPTN_ALIAS, (void *) "-f", 0, NULL }, { "-F", GETOPTN_ALIAS, (void *) "-I", 0, NULL }, { "-g", GETOPTN_STRING, NULL /*dbsstr*/, 0 /*dbsstr_sz*/, (void *) "g" }, { "-h", GETOPTN_STRING, /* 17 */ NULL /*dbsstr*/, 0 /*dbsstr_sz*/, (void *) "h" }, { "-H", GETOPTN_STRING, /* 18 */ NULL /*dbsstr*/, 0 /*dbsstr_sz*/, (void *) "H" }, { "--help", GETOPTN_FUNC_BOOL, NULL, 0, NULL /*processOptions*/ }, { "--human-readable", GETOPTN_ALIAS, (void *) "-H", 0, NULL }, { "-?", GETOPTN_FUNC_BOOL, NULL, 0, NULL /*processOptions*/ }, { "-i", GETOPTN_ALIAS, /* 22 */ (void *) "-x", 0, NULL }, { "-I", GETOPTN_FUNC_VALUE, /* 23 */ NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "--inodes",GETOPTN_IGNORE, NULL, 0, NULL }, { "-k", GETOPTN_STRING, NULL /*dbsstr*/, 0 /*dbsstr_sz*/, (void *) "k" }, { "-l", GETOPTN_BOOL, NULL /*&diopts->localOnly*/, 0 /*sizeof (diopts->localOnly)*/, NULL }, { "--local",GETOPTN_ALIAS, /* 27 */ (void *) "-l", 0, NULL }, { "-L", GETOPTN_BOOL, /* 28 */ NULL /*&diopts->excludeLoopback*/, 0 /*sizeof (diopts->excludeLoopback)*/, NULL }, { "-m", GETOPTN_STRING, NULL /*dbsstr*/, 0 /*dbsstr_sz*/, (void *) "m" }, { "-n", GETOPTN_BOOL, NULL /*&diopts->printHeader*/, 0 /*sizeof (diopts->printHeader)*/, NULL }, { "--no-sync", GETOPTN_IGNORE, NULL, 0, NULL }, { "-P", GETOPTN_FUNC_BOOL, /* 32 */ NULL /*&padata*/, 0, NULL /*processOptions*/ }, { "--portability", GETOPTN_ALIAS, /* 33 */ (void *) "-P", 0, NULL }, { "--print-type", GETOPTN_IGNORE, NULL, 0, NULL }, { "-q", GETOPTN_BOOL, NULL /*&diopts->quota_check*/, 0 /*sizeof (diopts->quota_check)*/, NULL }, { "-R", GETOPTN_BOOL, NULL /*&diopts->dontResolveSymlink*/, 0 /*sizeof (diopts->dontResolveSymlink)*/, NULL }, { "-s", GETOPTN_FUNC_VALUE, /* 37 */ NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "--si", GETOPTN_FUNC_BOOL, /* 38 */ NULL /*&padata*/, 0, NULL /*processOptions*/ }, { "--sync", GETOPTN_IGNORE, /* 39 */ NULL, 0, NULL }, { "-t", GETOPTN_BOOL, NULL /*&diopts->printTotals*/, 0 /*sizeof (diopts->printTotals)*/, NULL }, { "--total",GETOPTN_ALIAS, (void *) "-t", 0, NULL }, { "--type", GETOPTN_ALIAS, /* 42 */ (void *) "-I", 0, NULL }, { "-v", GETOPTN_IGNORE, /* 43 */ NULL, 0, NULL }, { "--version", GETOPTN_FUNC_BOOL, /* 44 */ NULL, 0, NULL /*processOptions*/ }, { "-w", GETOPTN_SIZET, NULL /*&diout->width*/, 0 /*sizeof (diout->width)*/, NULL }, { "-W", GETOPTN_SIZET, NULL /*&diout->inodeWidth*/, 0 /*sizeof (diout->inodeWidth)*/, NULL }, { "-x", GETOPTN_FUNC_VALUE, NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "--exclude-type", GETOPTN_ALIAS, /* 48 */ (void *) "-x", 0, NULL }, { "-X", GETOPTN_FUNC_VALUE, NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "-z", GETOPTN_STRING, /* 50 */ NULL /*&diData->zoneInfo.zoneDisplay*/, 0 /*sizeof (diData->zoneInfo.zoneDisplay)*/, NULL }, { "-Z", GETOPTN_STRING, NULL /*&diData->zoneInfo.zoneDisplay*/, 0 /*sizeof (diData->zoneInfo.zoneDisplay)*/, (void *) "all" } }; static int dbsids[] = { 10, 16, 17, 18, 25, 29 }; static int paidb[] = { 1, 19, 21, 32, 38, 44, }; static int paidv[] = { 3, 23, 37, 47, 49 }; diopts = &diData->options; diout = &diData->output; /* this is seriously gross, but the old compilers don't have */ /* automatic aggregate initialization */ /* don't forget to change dbsids, paidb and paidv above also */ opts[0].valptr = (void *) &diopts->formatString; /* -A */ opts[6].valptr = (void *) &diopts->csv_output; /* -c */ opts[6].valsiz = sizeof (diopts->csv_output); opts[7].valptr = (void *) &diopts->csv_tabs; /* -C */ opts[7].valsiz = sizeof (diopts->csv_tabs); opts[13].valptr = (void *) &diopts->formatString; /* -f */ opts[26].valptr = (void *) &diopts->localOnly; /* -l */ opts[26].valsiz = sizeof (diopts->localOnly); opts[28].valptr = (void *) &diopts->excludeLoopback; /* -L */ opts[28].valsiz = sizeof (diopts->excludeLoopback); opts[30].valptr = (void *) &diopts->printHeader; /* -n */ opts[30].valsiz = sizeof (diopts->printHeader); opts[35].valptr = (void *) &diopts->quota_check; /* -q */ opts[35].valsiz = sizeof (diopts->quota_check); opts[36].valptr = (void *) &diopts->dontResolveSymlink; /* -R */ opts[36].valsiz = sizeof (diopts->dontResolveSymlink); opts[40].valptr = (void *) &diopts->printTotals; /* -t */ opts[40].valsiz = sizeof (diopts->printTotals); opts[45].valptr = (void *) &diout->width; /* -w */ opts[45].valsiz = sizeof (diout->width); opts[46].valptr = (void *) &diout->inodeWidth; /* -W */ opts[46].valsiz = sizeof (diout->inodeWidth); opts[50].valptr = (void *) diData->zoneInfo.zoneDisplay; /* -z */ opts[50].valsiz = sizeof (diData->zoneInfo.zoneDisplay); opts[51].valptr = (void *) diData->zoneInfo.zoneDisplay; /* -Z */ opts[51].valsiz = sizeof (diData->zoneInfo.zoneDisplay); for (i = 0; i < (int) (sizeof (dbsids) / sizeof (int)); ++i) { opts[dbsids[i]].valptr = (void *) dbsstr; opts[dbsids[i]].valsiz = dbsstr_sz; } for (i = 0; i < (int) (sizeof (paidb) / sizeof (int)); ++i) { opts[paidb[i]].valptr = (void *) &padata; opts[paidb[i]].value2 = (void *) processOptions; if (diopts->exitFlag != DI_EXIT_NORM) { break; } } for (i = 0; i < (int) (sizeof (paidv) / sizeof (int)); ++i) { opts[paidv[i]].valptr = (void *) &padata; opts[paidv[i]].value2 = (void *) processOptionsVal; if (diopts->exitFlag != DI_EXIT_NORM) { break; } } optidx = -1; if (diopts->exitFlag != DI_EXIT_NORM) { return optidx; } padata.diData = diData; padata.diopts = diopts; padata.diout = diout; padata.dbsstr = dbsstr; padata.dbsstr_sz = dbsstr_sz; optidx = getoptn (GETOPTN_LEGACY, argc, argv, sizeof (opts) / sizeof (getoptn_opt_t), opts, &errorCount); diopts->errorCount += errorCount; if (diopts->errorCount > 0) { setExitFlag (diopts, DI_EXIT_WARN); } if (diopts->csv_tabs) { diopts->csv_output = TRUE; } if (diopts->csv_output) { diopts->printTotals = FALSE; } return optidx; } static void #if _proto_stdc processOptions (const char *arg, char *valptr) #else processOptions (arg, valptr) const char *arg; char *valptr; #endif { struct pa_tmp *padata; padata = (struct pa_tmp *) valptr; if (strcmp (arg, "-a") == 0) { padata->diopts->displayAll = TRUE; strncpy (padata->diData->zoneInfo.zoneDisplay, "all", MAXPATHLEN); } else if (strcmp (arg, "--help") == 0 || strcmp (arg, "-?") == 0) { usage(); setExitFlag (padata->diopts, DI_EXIT_OK); } else if (strcmp (arg, "-P") == 0) { if (strcmp (padata->dbsstr, "k") != 0) /* don't override -k option */ { strncpy (padata->dbsstr, "512", padata->dbsstr_sz); } padata->diopts->formatString = DI_POSIX_FORMAT; padata->diopts->posix_compat = TRUE; padata->diopts->csv_output = FALSE; } else if (strcmp (arg, "--si") == 0) { padata->diopts->baseDispSize = (_print_size_t) DI_VAL_1000; padata->diopts->baseDispIdx = DI_DISP_1000_IDX; strncpy (padata->dbsstr, "H", padata->dbsstr_sz); } else if (strcmp (arg, "--version") == 0) { printf (DI_GT("di version %s Default Format: %s\n"), DI_VERSION, DI_DEFAULT_FORMAT); setExitFlag (padata->diopts, DI_EXIT_OK); } else { fprintf (stderr, "di_panic: bad option setup\n"); } return; } static void #if _proto_stdc processOptionsVal (const char *arg, char *valptr, char *value) #else processOptionsVal (arg, valptr, value) const char *arg; char *valptr; char *value; #endif { struct pa_tmp *padata; int rc; padata = (struct pa_tmp *) valptr; if (strcmp (arg, "-B") == 0) { if (isdigit ((int) (*value))) { padata->diopts->baseDispSize = (_print_size_t) atof (value); padata->diopts->baseDispIdx = DI_DISP_1000_IDX; /* unknown, really */ if (padata->diopts->baseDispSize == (_print_size_t) DI_VAL_1024) { padata->diopts->baseDispIdx = DI_DISP_1024_IDX; } } else if (strcmp (value, "k") == 0) { padata->diopts->baseDispSize = (_print_size_t) DI_VAL_1024; padata->diopts->baseDispIdx = DI_DISP_1024_IDX; } else if (strcmp (value, "d") == 0 || strcmp (value, "si") == 0) { padata->diopts->baseDispSize = (_print_size_t) DI_VAL_1000; padata->diopts->baseDispIdx = DI_DISP_1000_IDX; } } else if (strcmp (arg, "-I") == 0) { rc = parseList (&padata->diData->includeList, value); if (rc != 0) { setExitFlag (padata->diopts, DI_EXIT_FAIL); return; } } else if (strcmp (arg, "-s") == 0) { strncpy (padata->diopts->sortType, value, DI_SORT_MAX); /* for backwards compatibility */ /* reverse by itself - change to reverse mount point */ if (strcmp (padata->diopts->sortType, "r") == 0) { strncpy (padata->diopts->sortType, "rm", DI_SORT_MAX); } /* add some sense to the sort order */ if (strcmp (padata->diopts->sortType, "t") == 0) { strncpy (padata->diopts->sortType, "tm", DI_SORT_MAX); } } else if (strcmp (arg, "-x") == 0) { parseList (&padata->diData->ignoreList, value); } else if (strcmp (arg, "-X") == 0) { debug = atoi (value); padata->diopts->printDebugHeader = TRUE; padata->diopts->printTotals = TRUE; padata->diopts->printHeader = TRUE; padata->diout->width = 10; padata->diout->inodeWidth = 10; } else { fprintf (stderr, "di_panic: bad option setup\n"); } return; } static int #if _proto_stdc parseList (iList_t *list, char *str) #else parseList (list, str) iList_t *list; char *str; #endif { char *dstr; char *ptr; char *lptr; int count; int ocount; int ncount; int i; unsigned int len; dstr = strdup (str); if (dstr == (char *) NULL) { fprintf (stderr, "strdup failed in parseList() (1). errno %d\n", errno); return 1; } ptr = strtok (dstr, DI_LIST_SEP); count = 0; while (ptr != (char *) NULL) { ++count; ptr = strtok ((char *) NULL, DI_LIST_SEP); } ocount = list->count; list->count += count; ncount = list->count; list->list = (char **) di_realloc ((char *) list->list, (Size_t) list->count * sizeof (char *)); if (list->list == (char **) NULL) { fprintf (stderr, "malloc failed in parseList() (2). errno %d\n", errno); free ((char *) dstr); return 1; } ptr = dstr; for (i = ocount; i < ncount; ++i) { len = (unsigned int) strlen (ptr); lptr = (char *) malloc ((Size_t) len + 1); if (lptr == (char *) NULL) { fprintf (stderr, "malloc failed in parseList() (3). errno %d\n", errno); free ((char *) dstr); return 1; } strncpy (lptr, ptr, (Size_t) len); lptr[len] = '\0'; list->list [i] = lptr; ptr += len + 1; } free ((char *) dstr); return 0; } /* * usage */ static void #if _proto_stdc usage (void) #else usage () #endif { printf (DI_GT("di version %s Default Format: %s\n"), DI_VERSION, DI_DEFAULT_FORMAT); /* 12345678901234567890123456789012345678901234567890123456789012345678901234567890 */ printf (DI_GT("Usage: di [-ant] [-d display-size] [-f format] [-x exclude-fstyp-list]\n")); printf (DI_GT(" [-I include-fstyp-list] [file [...]]\n")); printf (DI_GT(" -a : print all mounted devices\n")); printf (DI_GT(" -d x : size to print blocks in (512 - POSIX, k - kbytes,\n")); printf (DI_GT(" m - megabytes, g - gigabytes, t - terabytes, h - human readable).\n")); printf (DI_GT(" -f x : use format string \n")); printf (DI_GT(" -I x : include only file system types in \n")); printf (DI_GT(" -x x : exclude file system types in \n")); printf (DI_GT(" -l : display local filesystems only\n")); printf (DI_GT(" -n : don't print header\n")); printf (DI_GT(" -t : print totals\n")); printf (DI_GT(" Format string values:\n")); printf (DI_GT(" m - mount point M - mount point, full length\n")); printf (DI_GT(" b - total kbytes B - kbytes available for use\n")); printf (DI_GT(" u - used kbytes c - calculated kbytes in use\n")); printf (DI_GT(" f - kbytes free v - kbytes available\n")); printf (DI_GT(" p - percentage not avail. for use 1 - percentage used\n")); printf (DI_GT(" 2 - percentage of user-available space in use.\n")); printf (DI_GT(" i - total file slots (i-nodes) U - used file slots\n")); printf (DI_GT(" F - free file slots P - percentage file slots used\n")); printf (DI_GT(" s - filesystem name S - filesystem name, full length\n")); printf (DI_GT(" t - disk partition type T - partition type, full length\n")); printf (DI_GT("See manual page for more options.\n")); } static void #if _proto_stdc setDispBlockSize (char *ptr, diOptions_t *diopts, diOutput_t *diout) #else setDispBlockSize (ptr, diopts, diout) char *ptr; diOptions_t *diopts; diOutput_t *diout; #endif { unsigned int len; _print_size_t val; char *tptr; static char tempbl [15]; char ttempbl [15]; if (isdigit ((int) (*ptr))) { val = (_print_size_t) atof (ptr); } else { val = (_print_size_t) 1.0; } tptr = ptr; len = (unsigned int) strlen (ptr); if (! isdigit ((int) *tptr)) { int idx; idx = -1; switch (*tptr) { case 'k': case 'K': { idx = DI_ONE_K; break; } case 'm': case 'M': { idx = DI_ONE_MEG; break; } case 'g': case 'G': { idx = DI_ONE_GIG; break; } case 't': case 'T': { idx = DI_ONE_TERA; break; } case 'p': case 'P': { idx = DI_ONE_PETA; break; } case 'e': case 'E': { idx = DI_ONE_EXA; break; } case 'z': case 'Z': { idx = DI_ONE_ZETTA; break; } case 'y': case 'Y': { idx = DI_ONE_YOTTA; break; } case 'h': { val = (_print_size_t) DI_DISP_HR; diout->dispBlockLabel = "Size"; break; } case 'H': { val = (_print_size_t) DI_DISP_HR_2; diout->dispBlockLabel = "Size"; break; } default: { if (strncmp (ptr, "HUMAN", (Size_t) 5) == 0) { val = (_print_size_t) DI_DISP_HR; } else { /* some unknown string value */ idx = DI_ONE_MEG; } break; } } if (idx >= 0) { if (len > 1) { ++tptr; if (*tptr == 'B') { diopts->baseDispSize = (_print_size_t) DI_VAL_1000; diopts->baseDispIdx = DI_DISP_1000_IDX; } } if (val == (_print_size_t) 1.0) { diout->dispBlockLabel = dispTable [idx].disp [diopts->baseDispIdx]; } else { Snprintf1 (ttempbl, sizeof (tempbl), "%%.0%s %%s", DI_Lf); Snprintf2 (tempbl, sizeof (tempbl), ttempbl, val, DI_GT (dispTable [idx].disp [diopts->baseDispIdx])); diout->dispBlockLabel = tempbl; } val *= dispTable [idx].size; } /* known size multiplier */ } else { int i; int ok; ok = 0; for (i = 0; i < (int) DI_DISPTAB_SIZE; ++i) { if (val == dispTable [i].size) { diout->dispBlockLabel = dispTable [i].disp [diopts->baseDispIdx]; ok = 1; break; } } if (ok == 0) { Snprintf1 (ttempbl, sizeof (ttempbl), "%%.0%sb", DI_Lf); Snprintf1 (tempbl, sizeof (tempbl), ttempbl, val); diout->dispBlockLabel = tempbl; } } /* some oddball block size */ if (diopts->posix_compat && val == (_print_size_t) DI_VAL_512) { diout->dispBlockLabel = "512-blocks"; } if (diopts->posix_compat && val == (_print_size_t) DI_VAL_1024) { diout->dispBlockLabel = "1024-blocks"; } diopts->dispBlockSize = val; } static void #if _proto_stdc initDisplayTable (diOptions_t *diopts) #else initDisplayTable (diopts) diOptions_t *diopts; #endif { int i; /* initialize dispTable array */ dispTable [0].size = diopts->baseDispSize; for (i = 1; i < (int) DI_DISPTAB_SIZE; ++i) { dispTable [i].size = dispTable [i - 1].size * diopts->baseDispSize; } } static void #if _proto_stdc setExitFlag (diOptions_t *diopts, unsigned int exitFlag) #else setExitFlag (diopts, exitFlag) diOptions_t *diopts; unsigned int exitFlag; #endif { if (exitFlag > diopts->exitFlag) { diopts->exitFlag = exitFlag; } } di-4.47/C/strdup.c0000644000175000017500000000143313334050206012014 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #if ! _lib_strdup # include "di.h" #if _hdr_stdio # include #endif # if _hdr_stdlib # include # endif # if _hdr_memory # include # endif # if _hdr_malloc # include # endif # if _hdr_string # include # endif # if _hdr_strings # include # endif #if _use_mcheck # include #endif char * # if _proto_stdc strdup (const char *ptr) # else strdup (ptr) const char *ptr; # endif { Size_t len; char *nptr; if (ptr == (char *) NULL) { return (char *) NULL; } len = strlen (ptr); nptr = (char *) malloc (len + 1); strncpy (nptr, ptr, len); return nptr; } #else extern int debug; #endif di-4.47/C/realloc.c0000644000175000017500000000132513334050206012114 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_memory # include #endif #if _hdr_malloc # include #endif #if _use_mcheck # include #endif /* * * portable realloc * some variants don't accept a null pointer for initial allocation. * */ _pvoid #if _proto_stdc di_realloc (_pvoid ptr, Size_t size) #else di_realloc (ptr, size) _pvoid ptr; Size_t size; #endif { if (ptr == (_pvoid) NULL) { ptr = (_pvoid) malloc (size); } else { ptr = (_pvoid) realloc (ptr, size); } return ptr; } di-4.47/C/getoptn.c0000644000175000017500000010132313334050206012152 0ustar bllbll/* * Copyright 2011-2018 Brad Lanam, Walnut Creek, CA */ /* * A new version of getopt() * Boolean short flags: -a -b (a, b) * With values: -c 123 -d=abcdef -ef * (-c = 123, -d = abcdef, -e = f) * Long options: --a --b --c 123 --d=abcdef * LEGACY: * Boolean short flags: -ab (a, b) * short flags: -version (-v = ersion) * MODERN: * Boolean long name: -ab (ab) * long flags: -version (-version) * */ #if defined(TEST_GETOPTN) # include "gconfig.h" #else # include "config.h" #endif #include "getoptn.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _use_mcheck # include #endif typedef struct { Size_t optionlen; int idx; } getoptn_optinfo_t; typedef struct { int style; int optidx; Size_t optcount; getoptn_opt_t *opts; getoptn_optinfo_t *optinfo; int argc; const char * const *argv; const char *arg; /* current arg we're processing */ Size_t arglen; /* and the length of it */ int hasvalue; /* does this arg have a value attached? */ Size_t argidx; /* index to the value */ Size_t optionlen; /* length of the option for this arg */ Size_t reprocess; /* -ab legacy form? must be 0 or 1 */ Size_t offset; /* reprocessing offset */ } getoptn_info_t; typedef void (*getoptn_func_bool_t) _((const char *option, void *valptr)); typedef void (*getoptn_func_value_t) _((const char *option, void *valptr, const char *value)); static int #if _proto_stdc find_option (getoptn_info_t *info, const char *arg, const char *oarg, Size_t *argidx) #else find_option (info, arg, oarg, argidx) getoptn_info_t *info; const char *arg; const char *oarg; Size_t *argidx; #endif { int i; Size_t junk; for (i = 0; i < (int) info->optcount; ++i) { if (info->optinfo[i].optionlen == 0) { info->optinfo[i].optionlen = strlen (info->opts[i].option); info->optinfo[i].idx = i; } if (strncmp (arg + info->offset, info->opts[i].option + info->reprocess, info->optinfo[i].optionlen - info->reprocess) == 0) { info->hasvalue = FALSE; /* info->argidx == 0 indicates top level of recursion */ if (info->argidx == 0) { info->optionlen = info->optinfo[i].optionlen; } if (info->style == GETOPTN_LEGACY) { if (info->arglen - info->offset > info->optionlen - info->reprocess) { if (info->opts[i].option_type == GETOPTN_BOOL) { info->reprocess = TRUE; if (info->offset == 0) { ++info->offset; } ++info->offset; if (info->offset >= info->arglen) { info->offset = 0; info->reprocess = FALSE; } } else { info->hasvalue = TRUE; } } else { info->offset = 0; info->reprocess = FALSE; } } if (info->style == GETOPTN_MODERN) { if (info->arglen > info->optionlen) { if (info->arg[info->optionlen] == '=') { info->hasvalue = TRUE; } else { continue; /* partial match */ } } } *argidx = info->optinfo[i].optionlen; if (info->opts[i].option_type == GETOPTN_ALIAS) { return find_option (info, (const char *) info->opts[i].valptr, oarg, &junk); } return i; } } info->reprocess = FALSE; info->offset = 0; return GETOPTN_NOTFOUND; } static const char * #if _proto_stdc getoption_value (getoptn_info_t *info, getoptn_opt_t *opt) #else getoption_value (info, opt) getoptn_info_t *info; getoptn_opt_t *opt; #endif { const char *ptr; ptr = (char *) NULL; if (opt->option_type != GETOPTN_FUNC_VALUE && opt->value2 != (void *) NULL) { ptr = (const char *) opt->value2; return ptr; } if (info->hasvalue && info->arg[info->argidx] == '=') { ptr = &info->arg[info->argidx + 1]; } else if (info->hasvalue) { ptr = &info->arg[info->argidx]; } else if (info->optidx + 1 < info->argc) { ++info->optidx; ptr = info->argv[info->optidx]; } return ptr; } static int #if _proto_stdc dooptchecks (getoptn_info_t *info, getoptn_opt_t *opt, getoptn_optinfo_t *optinfo, const char *tag, Size_t sz) #else dooptchecks (info, opt, optinfo, tag, sz) getoptn_info_t *info; getoptn_opt_t *opt; getoptn_optinfo_t *optinfo; const char *tag; Size_t sz; #endif { if (sz != 0 && opt->valsiz != sz) { fprintf (stderr, "%s: %s: invalid size (line %d)\n", info->argv[0], tag, optinfo->idx); return 1; } if (opt->valptr == NULL) { fprintf (stderr, "%s: %s: invalid pointer (line %d)\n", info->argv[0], tag, optinfo->idx); return 1; } return 0; } static int #if _proto_stdc process_opt (getoptn_info_t *info, getoptn_opt_t *opt, getoptn_optinfo_t *optinfo) #else process_opt (info, opt, optinfo) getoptn_info_t *info; getoptn_opt_t *opt; getoptn_optinfo_t *optinfo; #endif { const char *ptr; ptr = (char *) NULL; if (opt->option_type == GETOPTN_INT || opt->option_type == GETOPTN_LONG || opt->option_type == GETOPTN_SIZET || opt->option_type == GETOPTN_DOUBLE || opt->option_type == GETOPTN_STRING || opt->option_type == GETOPTN_STRPTR || opt->option_type == GETOPTN_FUNC_VALUE) { ptr = getoption_value (info, opt); if (ptr == (char *) NULL) { fprintf (stderr, "%s: %s argument missing\n", info->argv[0], info->arg); return 1; } } if (opt->option_type == GETOPTN_BOOL) { int *v; if (dooptchecks (info, opt, optinfo, "bool", sizeof(int)) != 0) { return 1; } v = (int *) opt->valptr; *v = 1 - *v; /* flip it */ } else if (opt->option_type == GETOPTN_INT) { int *v; if (dooptchecks (info, opt, optinfo, "int", sizeof(int)) != 0) { return 1; } v = (int *) opt->valptr; *v = atoi (ptr); } else if (opt->option_type == GETOPTN_LONG) { long *v; if (dooptchecks (info, opt, optinfo, "long", sizeof(long)) != 0) { return 1; } v = (long *) opt->valptr; *v = atol (ptr); } else if (opt->option_type == GETOPTN_SIZET) { Size_t *v; if (dooptchecks (info, opt, optinfo, "Size_t", sizeof(Size_t)) != 0) { return 1; } v = (Size_t *) opt->valptr; *v = (Size_t) atol (ptr); } else if (opt->option_type == GETOPTN_DOUBLE) { double *v; if (dooptchecks (info, opt, optinfo, "double", sizeof(double)) != 0) { return 1; } v = (double *) opt->valptr; *v = atof (ptr); } else if (opt->option_type == GETOPTN_STRING) { char *v; if (dooptchecks (info, opt, optinfo, "string", 0) != 0) { return 1; } v = (char *) opt->valptr; strncpy (v, ptr, opt->valsiz - 1); } else if (opt->option_type == GETOPTN_STRPTR) { const char **v; if (dooptchecks (info, opt, optinfo, "strptr", 0) != 0) { return 1; } v = (const char **) opt->valptr; *v = strdup (ptr); /* memory leak (one time) */ } else if (opt->option_type == GETOPTN_FUNC_BOOL) { getoptn_func_bool_t f; if (opt->value2 == (void *) NULL) { fprintf (stderr, "%s: %s: invalid function ptr (line %d)\n", info->argv[0], "func_bool", optinfo->idx); return 1; } f = (getoptn_func_bool_t) opt->value2; (f)(opt->option, opt->valptr); } else if (opt->option_type == GETOPTN_FUNC_VALUE) { getoptn_func_value_t f; if (opt->value2 == (void *) NULL) { fprintf (stderr, "%s: %s: invalid function ptr (line %d)\n", info->argv[0], "func_val", optinfo->idx); return 1; } f = (getoptn_func_value_t) opt->value2; (f)(opt->option, opt->valptr, ptr); } else { info->reprocess = FALSE; info->offset = 0; fprintf (stderr, "%s: unknown option type %d\n", info->argv[0], opt->option_type); return 1; } return 0; } int #if _proto_stdc getoptn (int style, int argc, const char * const argv [], Size_t optcount, getoptn_opt_t opts [], int *errorCount) #else getoptn (style, argc, argv, optcount, opts, errorCount) int style; int argc; const char * const argv []; Size_t optcount; getoptn_opt_t opts []; int *errorCount; #endif { int i; int rc; const char *arg; getoptn_opt_t *opt; getoptn_info_t info; info.style = style; info.argc = argc; info.argv = argv; info.optcount = optcount; info.opts = opts; info.optinfo = (getoptn_optinfo_t *) NULL; *errorCount = 0; if (optcount > 0) { info.optinfo = (getoptn_optinfo_t *) malloc (sizeof (getoptn_optinfo_t) * optcount); for (i = 0; i < (int) info.optcount; ++i) { info.optinfo[i].optionlen = 0; } } else { return 1 < argc ? 1 : -1; } for (info.optidx = 1; info.optidx < argc; info.optidx++) { arg = argv[info.optidx]; if (*arg != '-') { if (info.optinfo != (getoptn_optinfo_t *) NULL) { free (info.optinfo); } return info.optidx; } if (strcmp (arg, "--") == 0) { info.optidx++; if (info.optinfo != (getoptn_optinfo_t *) NULL) { free (info.optinfo); } return info.optidx; } info.argidx = 0; info.arg = arg; info.arglen = strlen (arg); info.reprocess = FALSE; info.offset = 0; do { i = find_option (&info, arg, arg, &info.argidx); if (opts[i].option_type == GETOPTN_IGNORE) { continue; } if (i == GETOPTN_NOTFOUND) { if (info.reprocess == FALSE) { fprintf (stderr, "%s: unknown option %s\n", argv[0], arg); ++*errorCount; } continue; } opt = &opts[i]; rc = process_opt (&info, opt, &info.optinfo[i]); if (rc) { ++*errorCount; } } while (info.reprocess); } if (info.optinfo != (getoptn_optinfo_t *) NULL) { free (info.optinfo); } return argc; } #if defined(TEST_GETOPTN) #if _hdr_math # include #endif static void #if _proto_stdc process_opts (const char *arg, char *valptr) #else process_opts (arg, valptr) const char *arg; char *valptr; #endif { if (strcmp (arg, "-h") == 0) { double *v; v = (double *) valptr; *v = 9.9; } return; } static void #if _proto_stdc process_opts_val (const char *arg, char *valptr, char *value) #else process_opts_val (arg, valptr, value) const char *arg; char *valptr; char *value; #endif { if (strcmp (arg, "-g") == 0) { double *v; v = (double *) valptr; *v = atof (value); } return; } int #if _proto_stdc main (int argc, const char * const argv[]) #else main (argc, argv) int argc; const char * const argv[]; #endif { char tmp[40]; char s[40]; char s2[5]; char *sp; long l; double d; int i; int j; int k; int ec; int optidx; int ac; const char *av[10]; int grc = 0; int testno = 0; getoptn_opt_t opts[] = { { "-D", GETOPTN_STRING, &s, sizeof(s), (void *) "abc123" }, { "-b", GETOPTN_BOOL, &i, sizeof(i), NULL }, { "--b", GETOPTN_BOOL, &i, sizeof(i), NULL }, { "-c", GETOPTN_BOOL, &j, sizeof(j), NULL }, { "--c", GETOPTN_ALIAS, (void *) "-c", 0, NULL }, { "-bc", GETOPTN_BOOL, &k, sizeof(k), NULL }, { "-d", GETOPTN_DOUBLE, &d, sizeof(d), NULL }, { "-f1", GETOPTN_INT, &i, 8, NULL }, { "-f2", GETOPTN_LONG, &i, 2, NULL }, { "-f3", GETOPTN_LONG, &l, 12, NULL }, { "--i", GETOPTN_INT, &i, sizeof(i), NULL }, { "-i", GETOPTN_INT, &i, sizeof(i), NULL }, { "-i15",GETOPTN_INT, &j, sizeof(j), NULL }, { "-i17",GETOPTN_INT, &j, sizeof(j), NULL }, { "-l", GETOPTN_LONG, &l, sizeof(l), NULL }, { "-s", GETOPTN_STRING, &s, sizeof(s), NULL }, { "-sabcd", GETOPTN_BOOL, &i, sizeof(i), NULL }, { "-sp", GETOPTN_STRPTR, &sp, 0, NULL }, { "-p", GETOPTN_STRPTR, &sp, 0, NULL }, { "-S", GETOPTN_STRPTR, &sp, 0, (void *) "abc1234" }, { "-s2", GETOPTN_STRING, &s2, sizeof(s2), NULL }, { "-np1", GETOPTN_STRING, NULL, sizeof(s2), NULL }, { "-np2", GETOPTN_FUNC_BOOL, NULL, sizeof(s2), NULL }, { "-np3", GETOPTN_FUNC_VALUE, NULL, sizeof(s2), NULL }, { "-z1", GETOPTN_ALIAS, (void *) "--c", 0, NULL }, { "-z2", GETOPTN_ALIAS, (void *) "-z1", 0, NULL }, { "-z3", GETOPTN_ALIAS, (void *) "-z2", 0, NULL } }; /* test 1 */ ++testno; memset (s, '\0', sizeof (s)); ac = 2; sprintf (tmp, "test: %d", testno); av[0] = tmp; av[1] = "-D"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abc123") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 2 */ ++testno; i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-b"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 1 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 3 */ ++testno; i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "--b"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 1 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 4 */ ++testno; i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "--i=13"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 13 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 5 */ ++testno; i = 0; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "--i"; av[2] = "14"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 14 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 6 */ ++testno; i = 0; j = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i15"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 15 || j != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 7 */ ++testno; i = 0; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i"; av[2] = "16"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 16 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 8 */ ++testno; i = 0; j = 0; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i17"; av[2] = "5"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || j != 5 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 9 */ ++testno; i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i=17"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 17 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 10 */ ++testno; i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i7"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 7 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 11 */ ++testno; l = 0L; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-l"; av[2] = "19"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (l != 19 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 12 */ ++testno; i = 0; j = 0; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-b"; av[2] = "-c"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 1 || j != 1 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 13 */ ++testno; i = 0; j = 0; k = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-bc"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 1 || j != 1 || k != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 14 */ ++testno; i = 0; j = 0; k = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-bc"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || j != 0 || k != 1 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 15 */ ++testno; memset (s, '\0', sizeof (s)); ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s=abc"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abc") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 16 */ ++testno; d = 0.0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-d=1.2"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (fabs(d - 1.2) > 0.00001 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d: %.2g %d\n", testno, d, optidx); grc = 1; } /* test 17 */ ++testno; memset (s, '\0', sizeof (s)); i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-sabcd"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abcd") != 0 || i != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 18 */ ++testno; memset (s, '\0', sizeof (s)); ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s=abcde"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abcde") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 19 */ ++testno; memset (s, '\0', sizeof (s)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s"; av[2] = "abcdef"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abcdef") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 20 */ ++testno; sp = ""; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-sp"; av[2] = "0123"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (sp, "0123") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 21 */ ++testno; sp = ""; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-sp=01234"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (sp, "01234") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 22 */ ++testno; sp = ""; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-p012345"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (sp, "012345") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 23 */ ++testno; sp = ""; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-S"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (sp, "abc1234") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 24 */ ++testno; sp = ""; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-p=0123456"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (sp, "0123456") != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 25 */ ++testno; memset (s, '\0', sizeof (s)); i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-sabcd"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "") != 0 || i != 1 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 26 */ ++testno; i = 1; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-b"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 27 */ ++testno; i = 1; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "--b"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 28 */ ++testno; i = 1; j = 1; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-b"; av[2] = "-c"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || j != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 29 */ ++testno; i = 1; j = 1; k = 1; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-bc"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || j != 0 || k != 1 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d / i:%d j:%d k:%d optidx:%d ec:%d\n", testno, i, j, k, optidx, ec); grc = 1; } /* test 30 */ ++testno; i = 1; j = 1; k = 1; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-bc"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 1 || j != 1 || k != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d / i:%d j:%d k:%d optidx:%d ec:%d\n", testno, i, j, k, optidx, ec); grc = 1; } /* test 31 - empty value */ ++testno; i = 0; j = 0; k = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i="; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d / i:%d optidx:%d ec:%d\n", testno, i, optidx, ec); grc = 1; } /* test 32 - no value; should print error */ ++testno; i = 0; j = 0; k = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i"; av[2] = NULL; ec = 0; fprintf (stderr, "** expect argument missing\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || optidx != 2 || ec != 1) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 33 - wrong size; should print error */ ++testno; i = 0; j = 0; k = 0; l = 0L; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-f1=7"; av[2] = NULL; ec = 0; fprintf (stderr, "** expect invalid size\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || l != 0 || optidx != 2 || ec != 1) { fprintf (stderr, "fail test %d; %d %ld %d\n", testno, i, l, optidx); grc = 1; } /* test 34 - wrong size; should print error */ ++testno; i = 0; j = 0; k = 0; l = 0L; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-f2=7"; av[2] = NULL; ec = 0; fprintf (stderr, "** expect invalid size\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || l != 0 || optidx != 2 || ec != 1) { fprintf (stderr, "fail test %d; %d %ld %d\n", testno, i, l, optidx); grc = 1; } /* test 35 - wrong size; should print error */ ++testno; i = 0; j = 0; k = 0; l = 0L; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-f3=7"; av[2] = NULL; ec = 0; fprintf (stderr, "** expect invalid size\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || l != 0 || optidx != 2 || ec != 1) { fprintf (stderr, "fail test %d; %d %ld %d\n", testno, i, l, optidx); grc = 1; } /* test 36 - end of options */ ++testno; i = 0; j = 0; k = 0; l = 0L; ac = 4; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i=7"; av[2] = "--"; av[3] = "abc"; av[4] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 7 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 37 - no more options */ ++testno; i = 0; j = 0; k = 0; l = 0L; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-i=7"; av[2] = "abc"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 7 || optidx != 2 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 38 - empty value followed by another option; returns the option */ ++testno; i = 0; j = 0; k = 0; memset (s, '\0', sizeof (s)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s"; av[2] = "-s"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "-s") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 39 - unknown options */ ++testno; i = 0; j = 0; k = 0; memset (s, '\0', sizeof (s)); ac = 5; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-b"; av[2] = "-c"; av[3] = "-s"; av[4] = "abc"; av[5] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abc") != 0 || i != 1 || j != 1 || optidx != 5 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 40 - legacy: mixed boolean + arg */ ++testno; i = 0; j = 0; k = 0; memset (s, '\0', sizeof (s)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-bcs"; av[2] = "abc"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s, "abc") != 0 || i != 1 || j != 1 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 41 */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s2"; av[2] = "abc"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "abc") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 42 - short string */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s2"; av[2] = "abcd"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "abcd") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 43 - short string */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s2"; av[2] = "abcde"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "abcd") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d: %s\n", testno, s2); grc = 1; } /* test 44 - short string */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-s2"; av[2] = "abcdef"; av[3] = NULL; ec = 0; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "abcd") != 0 || optidx != 3 || ec != 0) { fprintf (stderr, "fail test %d: %s\n", testno, s2); grc = 1; } /* test 45 - null ptr */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-np1"; av[2] = "abcdef"; av[3] = NULL; ec = 0; fprintf (stderr, "** expect invalid pointer\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "") != 0 || ec != 1) { fprintf (stderr, "fail test %d: %s %d\n", testno, s2, optidx); grc = 1; } /* test 46 - null ptr */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-np2"; av[2] = "abcdef"; av[3] = NULL; ec = 0; fprintf (stderr, "** expect invalid pointer\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "") != 0 || ec != 1) { fprintf (stderr, "fail test %d: %s %d\n", testno, s2, optidx); grc = 1; } /* test 47 - null ptr */ ++testno; memset (s2, '\0', sizeof (s2)); ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-np3"; av[2] = "abcdef"; av[3] = NULL; ec = 0; fprintf (stderr, "** expect invalid pointer\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (strcmp (s2, "") != 0 || ec != 1) { fprintf (stderr, "fail test %d: %s %d\n", testno, s2, optidx); grc = 1; } /* test 48 - alias chain */ ++testno; i = 0; j = 0; k = 0; memset (s2, '\0', sizeof (s2)); ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-z3"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || j != 1 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 49 - test boolean initial value */ ++testno; i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-c"; av[2] = NULL; ec = 0; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts, &ec); if (i != 0 || ec != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } return grc; } #endif /* TEST_GETOPTN */ di-4.47/C/options.h0000644000175000017500000000163113334050206012173 0ustar bllbll#ifndef DI_INC_OPTIONS_H #define DI_INC_OPTIONS_H #include "config.h" #include "di.h" #define DI_VAL_512 512.0 #define DI_VAL_1000 1000.0 #define DI_DISP_1000_IDX 0 #define DI_VAL_1024 1024.0 #define DI_DISP_1024_IDX 1 /* these are indexes into the dispTable array... */ #define DI_ONE_K 0 #define DI_ONE_MEG 1 #define DI_ONE_GIG 2 #define DI_ONE_TERA 3 #define DI_ONE_PETA 4 #define DI_ONE_EXA 5 #define DI_ONE_ZETTA 6 #define DI_ONE_YOTTA 7 #define DI_DISP_HR -20.0 #define DI_DISP_HR_2 -21.0 # if defined (__cplusplus) || defined (c_plusplus) extern "C" { # endif extern int getDIOptions _((int , const char * const [], diData_t *)); # if defined (__cplusplus) || defined (c_plusplus) } # endif #endif /* DI_INC_OPTIONS_H */ di-4.47/C/di-example.tcl0000755000175000017500000000140713334050206013064 0ustar bllbll#!/usr/bin/tclsh # # example tcl script # # To build the sharedlibrary: # make -e tcl-sh # On windows: # make -e WINAPI=T NO_PIE=yes tcl-sh # package require platform # the load wants the full path, not relative... set ext [info sharedlibextension] set lfn [file normalize [file join [file dirname [info script]] diskspace$ext]] load $lfn puts "== Basic information only" set d [diskspace -f {}] dict for {mount dline} $d { puts "$mount: $dline" } puts "== Basic information and some display data" set d [diskspace -f buvp] dict for {mount dline} $d { puts "$mount: $dline" } # dictionary is nested with the mount point as the key. set dir / if { [regexp -nocase {^win} [platform::generic]] } { set dir "C:\\" } puts "$dir total space: [dict get $d $dir total]" di-4.47/C/digetinfo.c0000644000175000017500000004043713334050206012452 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ /********************************************************/ /* In the cases where di_getDiskEntries() does not get the volume information, di_getDiskInfo() is used to fetch the info. di_getDiskInfo () Gets the disk space used/available on the partitions we want displayed. */ /********************************************************/ #include "config.h" #include "di.h" #include "dimntopt.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _sys_param # include #endif #if _hdr_errno # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _sys_mount \ && ! defined (DI_INC_SYS_MOUNT) /* FreeBSD, OpenBSD, NetBSD, HP-UX */ # define DI_INC_SYS_MOUNT 1 # include /* statfs(); struct statfs; getfsstat() */ #endif #if _sys_statvfs /* Linux, Solaris, FreeBSD, NetBSD, HP-UX */ # include /* statvfs(); struct statvfs */ #endif #if _sys_vfs /* Linux, HP-UX, BSD 4.3 */ # include /* struct statfs */ #endif #if _sys_statfs && ! _sys_statvfs /* Linux, SysV.3 */ # include /* statfs(); struct statfs */ #endif #if _sys_fstyp /* SysV.3 */ # include /* sysfs() */ #endif #if _hdr_windows /* windows */ # include /* GetDiskFreeSpace(); GetVolumeInformation() */ #endif /********************************************************/ #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif #if ! _lib_statvfs \ && _lib_statfs \ && _npt_statfs # if _lib_statfs && _args_statfs == 2 extern int statfs _((char *, struct statfs *)); # endif # if _lib_statfs && _args_statfs == 3 extern int statfs _((char *, struct statfs *, int)); # endif # if _lib_statfs && _args_statfs == 4 extern int statfs _((char *, struct statfs *, int, int)); # endif #endif extern int debug; #if defined (__cplusplus) || defined (c_plusplus) } #endif /********************************************************/ #if _lib_statvfs \ && ! _lib_fs_stat_dev \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_GetVolumeInformation \ && ! _class_os__Volumes /* * di_getDiskInfo * * SysV.4. statvfs () returns both the free and available blocks. * */ # define DI_GETDISKINFO_DEF 1 void # if _proto_stdc di_getDiskInfo (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskInfo (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int i; Statvfs_t statBuf; if (debug > 0) { printf ("# getDiskInfo: statvfs\n"); } for (i = 0; i < *diCount; ++i) { diptr = *diskInfo + i; if (diptr->printFlag == DI_PRNT_OK || diptr->printFlag == DI_PRNT_SKIP || diptr->printFlag == DI_PRNT_FORCE) { _fs_size_t tblocksz; if (statvfs (diptr->name, &statBuf) == 0) { /* data general DG/UX 5.4R3.00 sometime returns 0 */ /* in the fragment size field. */ if (statBuf.f_frsize == 0 && statBuf.f_bsize != 0) { tblocksz = statBuf.f_bsize; } else { tblocksz = statBuf.f_frsize; } /* Linux! statvfs() returns values in f_bsize rather f_frsize. Bleah. */ /* Non-POSIX! Linux manual pages are incorrect. */ # if linux tblocksz = statBuf.f_bsize; # endif /* linux */ di_saveBlockSizes (diptr, tblocksz, (_fs_size_t) statBuf.f_blocks, (_fs_size_t) statBuf.f_bfree, (_fs_size_t) statBuf.f_bavail); di_saveInodeSizes (diptr, (_fs_size_t) statBuf.f_files, (_fs_size_t) statBuf.f_ffree, (_fs_size_t) statBuf.f_favail); # if _mem_struct_statvfs_f_basetype if (! *diptr->fsType) { strncpy (diptr->fsType, statBuf.f_basetype, DI_TYPE_LEN); } # endif if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tbsize:%ld frsize:%ld\n", (long) statBuf.f_bsize, (long) statBuf.f_frsize); # if _siz_long_long >= 8 printf ("\tblocks: tot:%llu free:%lld avail:%llu\n", (long long) statBuf.f_blocks, (long long) statBuf.f_bfree, (long long) statBuf.f_bavail); printf ("\tinodes: tot:%llu free:%llu avail:%llu\n", (long long) statBuf.f_files, (long long) statBuf.f_ffree, (long long) statBuf.f_favail); # else printf ("\tblocks: tot:%lu free:%lu avail:%lu\n", (long) statBuf.f_blocks, (long) statBuf.f_bfree, (long) statBuf.f_bavail); printf ("\tinodes: tot:%lu free:%lu avail:%lu\n", (long) statBuf.f_files, (long) statBuf.f_ffree, (long) statBuf.f_favail); # endif } } else { diptr->printFlag = DI_PRNT_BAD; if (errno != EACCES) { fprintf (stderr, "statvfs: %s ", diptr->name); perror (""); } } } } /* for each entry */ } #endif /* _lib_statvfs */ #if _lib_statfs && _args_statfs == 4 \ && ! _lib_statvfs \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getvfsstat \ && ! _lib_getmnt /* xenix reports a block size of 1024 bytes, but the blocks reported */ /* are based on a 512 byte block size. */ # if defined (M_XENIX) # define UBSIZE 512 # else # if ! defined (UBSIZE) # if defined (BSIZE) # define UBSIZE BSIZE # else # define UBSIZE 512 # endif # endif # endif /* * di_getDiskInfo * * SysV.3. We don't have available blocks; just set it to free blocks. * The sysfs () call is used to get the disk type name. * */ # define DI_GETDISKINFO_DEF 1 void # if _proto_stdc di_getDiskInfo (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskInfo (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int i; struct statfs statBuf; if (debug > 0) { printf ("# getDiskInfo: sysv-statfs 4arg\n"); } for (i = 0; i < *diCount; ++i) { diptr = *diskInfo + i; if (diptr->printFlag == DI_PRNT_OK || diptr->printFlag == DI_PRNT_SKIP || diptr->printFlag == DI_PRNT_FORCE) { _fs_size_t tblocksz; if (statfs (diptr->name, &statBuf, sizeof (statBuf), 0) == 0) { # if _mem_struct_statfs_f_frsize if (statBuf.f_frsize == 0 && statBuf.f_bsize != 0) { tblocksz = (_fs_size_t) statBuf.f_bsize; } else { tblocksz = (_fs_size_t) statBuf.f_frsize; } # else tblocksz = UBSIZE; # endif di_saveBlockSizes (diptr, tblocksz, (_fs_size_t) statBuf.f_blocks, (_fs_size_t) statBuf.f_bfree, (_fs_size_t) statBuf.f_bfree); di_saveInodeSizes (diptr, (_fs_size_t) statBuf.f_files, (_fs_size_t) statBuf.f_ffree, (_fs_size_t) statBuf.f_ffree); # if _lib_sysfs && _mem_struct_statfs_f_fstyp sysfs (GETFSTYP, statBuf.f_fstyp, diptr->fsType); # endif if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); # if _mem_struct_statfs_f_frsize printf ("\tbsize:%ld\n", statBuf.f_bsize); printf ("\tfrsize:%ld\n", statBuf.f_frsize); # else printf ("\tUBSIZE:%ld\n", UBSIZE); # endif printf ("\tblocks: tot:%ld free:%ld\n", statBuf.f_blocks, statBuf.f_bfree); printf ("\tinodes: tot:%ld free:%ld\n", statBuf.f_files, statBuf.f_ffree); } } /* if we got the info */ else { diptr->printFlag = DI_PRNT_BAD; if (errno != EACCES) { fprintf (stderr, "statfs: %s ", diptr->name); perror (""); } } } } /* for each entry */ } #endif /* _args_statfs == 4 */ #if _lib_statfs && (_args_statfs == 2 || _args_statfs == 3) \ && ! _lib_statvfs \ && ! _lib_getmntinfo \ && ! _lib_getfsstat \ && ! _lib_getmnt \ && ! _lib_GetDiskFreeSpace \ && ! _lib_GetDiskFreeSpaceEx /* * di_getDiskInfo * * SunOS/BSD/Pyramid/Some Linux * */ # define DI_GETDISKINFO_DEF 1 void # if _proto_stdc di_getDiskInfo (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskInfo (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int i; struct statfs statBuf; if (debug > 0) { printf ("# getDiskInfo: bsd-statfs 2/3arg\n"); } for (i = 0; i < *diCount; ++i) { diptr = *diskInfo + i; if (diptr->printFlag == DI_PRNT_OK || diptr->printFlag == DI_PRNT_SKIP || diptr->printFlag == DI_PRNT_FORCE) { if (statfs (diptr->name, &statBuf) == 0) { di_saveBlockSizes (diptr, (_fs_size_t) statBuf.f_bsize, (_fs_size_t) statBuf.f_blocks, (_fs_size_t) statBuf.f_bfree, (_fs_size_t) statBuf.f_bavail); di_saveInodeSizes (diptr, (_fs_size_t) statBuf.f_files, (_fs_size_t) statBuf.f_ffree, (_fs_size_t) statBuf.f_ffree); # if _lib_sysfs && _mem_struct_statfs_f_fstyp sysfs (GETFSTYP, statBuf.f_fstyp, diptr->fsType); # endif if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\tbsize:%ld\n", (long) statBuf.f_bsize); printf ("\tblocks: tot:%ld free:%ld avail:%ld\n", (long) statBuf.f_blocks, (long) statBuf.f_bfree, (long) statBuf.f_bavail); printf ("\tinodes: tot:%ld free:%ld\n", (long) statBuf.f_files, (long) statBuf.f_ffree); } } /* if we got the info */ else { diptr->printFlag = DI_PRNT_BAD; if (errno != EACCES) { fprintf (stderr, "statfs: %s ", diptr->name); perror (""); } } } } /* for each entry */ } #endif /* _args_statfs == 2 or 3 */ #if _lib_GetVolumeInformation /* * di_getDiskInfo * * Windows * */ # define DI_GETDISKINFO_DEF 1 # define MSDOS_BUFFER_SIZE 256 void # if _proto_stdc di_getDiskInfo (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskInfo (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { diDiskInfo_t *diptr; int i; int rc; char volName [MSDOS_BUFFER_SIZE]; char fsName [MSDOS_BUFFER_SIZE]; DWORD serialNo; DWORD maxCompLen; DWORD fsFlags; # if _lib_GetDiskFreeSpaceEx if (debug > 0) { printf ("# getDiskInfo: GetDiskFreeSpaceEx\n"); } # endif # if _lib_GetDiskFreeSpace if (debug > 0) { printf ("# getDiskInfo: GetDiskFreeSpace\n"); } # endif if (debug > 0) { printf ("# getDiskInfo: GetVolumeInformation\n"); } for (i = 0; i < *diCount; ++i) { diptr = *diskInfo + i; if (diptr->printFlag == DI_PRNT_OK || diptr->printFlag == DI_PRNT_SKIP || diptr->printFlag == DI_PRNT_FORCE) { rc = GetVolumeInformation (diptr->name, volName, MSDOS_BUFFER_SIZE, &serialNo, &maxCompLen, &fsFlags, fsName, MSDOS_BUFFER_SIZE); strncpy (diptr->fsType, fsName, DI_TYPE_LEN); strncpy (diptr->special, volName, DI_SPEC_NAME_LEN); # if _lib_GetDiskFreeSpaceEx { ULONGLONG bytesAvail; ULONGLONG bytesTotal; ULONGLONG bytesFree; rc = GetDiskFreeSpaceEx (diptr->name, (PULARGE_INTEGER) &bytesAvail, (PULARGE_INTEGER) &bytesTotal, (PULARGE_INTEGER) &bytesFree); if (rc > 0) { di_saveBlockSizes (diptr, (_fs_size_t) 1, (_fs_size_t) bytesTotal, (_fs_size_t) bytesFree, (_fs_size_t) bytesAvail); di_saveInodeSizes (diptr, (_fs_size_t) 0, (_fs_size_t) 0, (_fs_size_t) 0); } else { diptr->printFlag = DI_PRNT_BAD; if (debug) { printf ("disk %s; could not get disk space\n", diptr->name); } } if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\ttot:%llu free:%llu\n", bytesTotal, bytesFree); printf ("\tavail:%llu\n", bytesAvail); } } # else # if _lib_GetDiskFreeSpace { unsigned long sectorspercluster; unsigned long bytespersector; unsigned long totalclusters; unsigned long freeclusters; rc = GetDiskFreeSpace (diptr->name, (LPDWORD) §orspercluster, (LPDWORD) &bytespersector, (LPDWORD) &freeclusters, (LPDWORD) &totalclusters); if (rc > 0) { di_saveBlockSizes (diptr, (_fs_size_t) (sectorspercluster * bytespersector), (_fs_size_t) totalclusters, (_fs_size_t) freeclusters, (_fs_size_t) freeclusters); di_saveInodeSizes (diptr, (_fs_size_t) 0, (_fs_size_t) 0, (_fs_size_t) 0); } else { diptr->printFlag = DI_PRNT_BAD; if (debug) { printf ("disk %s; could not get disk space\n", diptr->name); } } if (debug > 1) { printf ("%s: %s\n", diptr->name, diptr->fsType); printf ("\ts/c:%ld b/s:%ld\n", sectorspercluster, bytespersector); printf ("\tclusters: tot:%ld free:%ld\n", totalclusters, freeclusters); } } # endif # endif } /* if printable drive */ } /* for each mounted drive */ } #endif /* _lib_GetVolumeInformation */ #if ! defined (DI_GETDISKINFO_DEF) void # if _proto_stdc di_getDiskInfo (diDiskInfo_t **diskInfo, int *diCount) # else di_getDiskInfo (diskInfo, diCount) diDiskInfo_t **diskInfo; int *diCount; # endif { if (debug > 0) { printf ("# getDiskInfo: empty\n"); } return; } #endif di-4.47/C/diquota.c0000644000175000017500000005603313334050206012147 0ustar bllbll/* * Copyright 2011-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #include "di.h" #if _hdr_stdio # include #endif #if _hdr_stdlib # include #endif #if _hdr_unistd # include #endif #if _sys_param # include #endif #if _hdr_string # include #endif #if _hdr_strings # include #endif #if _sys_types \ && ! defined (DI_INC_SYS_TYPES_H) /* xenix */ # define DI_INC_SYS_TYPES_H # include #endif #if _hdr_errno # include #endif #if _hdr_time # include #endif #if _sys_time && _inc_conflict__hdr_time__sys_time # include #endif #if _hdr_libprop_proplib /* dragonflybsd */ # include #endif #if _hdr_quota # include #endif #if _sys_quota /* netbsd */ # include #endif #if _sys_fs_ufs_quota # include #endif #if _sys_vfs_quota /* dragonflybsd */ # include #endif #if _hdr_ufs_quota # include #endif #if _hdr_ufs_ufs_quota # include #endif #if _hdr_linux_dqblk_xfs # include #endif #if _hdr_jfs_quota # include #endif /* AIX 5.1 doesn't seem to have quotactl declared.... */ /* use their compatibility routine. */ #if ! _args_quotactl && _hdr_linux_quota \ && _inc_conflict__sys_quota__hdr_linux_quota # include #endif #if _hdr_rpc_rpc # include #endif #if _hdr_rpcsvc_rquota # include #endif #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif #if _has_std_quotas /* workaround for HPUX - quotactl not declared */ # if _lib_quotactl && _npt_quotactl extern int quotactl _((int, const char *, uid_t, void *)); # endif typedef union { int val; # if _typ_struct_dqblk struct dqblk qinfo; # endif # if _typ_struct_ufs_dqblk struct ufs_dqblk qinfo; # endif # if _typ_fs_disk_quota_t fs_disk_quota_t xfsqinfo; # endif # if _typ_struct_quotaval struct qval { struct quotaval qbval; struct quotaval qival; } qval; # endif # if _lib_vquotactl struct vqval { struct vqvalentry { _fs_size_t usage; _fs_size_t limit; } uvqval; struct vqvalentry gvqval; struct vqvalentry *vqvalptr; } vqval; # endif } qdata_t; static void di_process_quotas _((const char *, diQuota_t *, int, int, qdata_t *)); #endif #if _has_std_quotas && _lib_vquotactl static void vq_updUsage _((struct vqvalentry *, _fs_size_t)); static void vq_updLimit _((struct vqvalentry *, _fs_size_t)); static int vquotactl_send _((char *, char *, prop_dictionary_t, prop_dictionary_t *)); static int vquotactl_get _((diQuota_t *, struct vqval *)); #endif #if _has_std_quotas && _lib_quota_open static int quota_open_get _((struct quotahandle *, int, Uid_t, struct qval *)); #endif #if _has_std_quotas && ! _lib_quota_open && ! _lib_vquotactl static int quotactl_get _((diQuota_t *, int, Uid_t, qdata_t *)); #endif #if _has_std_nfs_quotas && ! _lib_quota_open static bool_t xdr_quota_get _((XDR *, struct getquota_args *)); static bool_t xdr_quota_rslt _((XDR *, struct getquota_rslt *)); static void diquota_nfs _((diQuota_t *)); #endif extern int debug; #if defined (__cplusplus) || defined (c_plusplus) } #endif #ifdef BLOCK_SIZE /* linux */ # define DI_QUOT_BLOCK_SIZE BLOCK_SIZE #else # ifdef DQBSIZE /* AIX */ # define DI_QUOT_BLOCK_SIZE DQBSIZE # else # ifdef DEV_BSIZE /* tru64, et. al. */ # define DI_QUOT_BLOCK_SIZE DEV_BSIZE # else # define DI_QUOT_BLOCK_SIZE 512 # endif # endif #endif /* rename certain structure members for portability */ /* it make the code below cleaner, but it's a bit more */ /* difficult to read it */ #if _mem_struct_dqblk_dqb_fsoftlimit # define dqb_isoftlimit dqb_fsoftlimit #endif #if _mem_struct_dqblk_dqb_fhardlimit # define dqb_ihardlimit dqb_fhardlimit #endif #if _mem_struct_dqblk_dqb_curfiles # define dqb_curinodes dqb_curfiles #endif /* dragonflybsd has a rather complicated method of getting */ /* the quota data. */ /* Since all results are returned, make sure to only iterate */ /* once. Much of this code is straight from vquota.c. */ #if _lib_vquotactl static void vq_updUsage (struct vqvalentry *entry, _fs_size_t usage) { if (usage > entry->usage) { entry->usage = usage; } } static void vq_updLimit (struct vqvalentry *entry, _fs_size_t limit) { if (entry->limit == 0 || limit < entry->limit) { entry->limit = limit; } } static int vquotactl_send (char *spec, char *cmd, prop_dictionary_t args, prop_dictionary_t *res) { prop_dictionary_t dict; struct plistref pref; int rv; int error; dict = prop_dictionary_create(); if (dict == NULL) { return FALSE; } rv = prop_dictionary_set_cstring (dict, "command", cmd); if (! rv) { prop_object_release (dict); return FALSE; } rv = prop_dictionary_set (dict, "arguments", args); if (! rv) { prop_object_release (dict); return FALSE; } error = prop_dictionary_send_syscall (dict, &pref); if (error != 0) { prop_object_release (dict); return FALSE; } error = vquotactl (spec, &pref); if (error != 0) { prop_object_release (dict); return FALSE; } error = prop_dictionary_recv_syscall(&pref, res); if (error != 0) { prop_object_release (dict); return FALSE; } prop_object_release (dict); return TRUE; } static int vquotactl_get (diQuota_t *diqinfo, struct vqval *vqval) { prop_dictionary_t args; prop_dictionary_t res; prop_array_t reslist; prop_object_iterator_t iter; prop_dictionary_t item; int rv; int urv; int grv; Uid_t tuid; Uid_t tgid; _fs_size_t space; _fs_size_t limit; args = prop_dictionary_create(); if (args == NULL) { return errno; } res = prop_dictionary_create(); if (res == NULL) { return errno; } rv = vquotactl_send (diqinfo->name, "get usage all", args, &res); if (! rv) { prop_object_release (args); prop_object_release (res); return -4; } reslist = prop_dictionary_get (res, "returned data"); if (reslist == NULL) { prop_object_release (args); prop_object_release (res); return errno; } iter = prop_array_iterator (reslist); if (iter == NULL) { prop_object_release (args); prop_object_release (res); return errno; } vqval->uvqval.usage = 0; vqval->uvqval.limit = 0; vqval->gvqval.usage = 0; vqval->gvqval.limit = 0; while ((item = prop_object_iterator_next(iter)) != NULL) { rv = prop_dictionary_get_uint64 (item, "limit", &limit); if (rv && limit != 0) { rv = prop_dictionary_get_uint64 (item, "space used", &space); urv = prop_dictionary_get_uint32 (item, "uid", &tuid); grv = prop_dictionary_get_uint32 (item, "gid", &tgid); if (urv && tuid == diqinfo->uid) { vq_updUsage (&(vqval->uvqval), space); vq_updLimit (&(vqval->uvqval), limit); } else if (grv && tgid == diqinfo->gid) { vq_updUsage (&(vqval->gvqval), space); vq_updLimit (&(vqval->gvqval), limit); } else if (! urv && ! grv) { vq_updUsage (&(vqval->uvqval), space); vq_updLimit (&(vqval->uvqval), limit); vq_updUsage (&(vqval->gvqval), space); vq_updLimit (&(vqval->gvqval), limit); } } } prop_object_iterator_release (iter); prop_object_release (args); prop_object_release (res); return 0; } #endif /* _lib_vquotactl */ #if _lib_quota_open static int quota_open_get (struct quotahandle *qh, int idtype, Uid_t id, struct qval *qval) { struct quotakey qkey; int rc; rc = -3; if (qh != (struct quotahandle *) NULL) { memset (&qkey, 0, sizeof (struct quotakey)); qkey.qk_idtype = idtype; qkey.qk_id = (id_t) id; qkey.qk_objtype = QUOTA_OBJTYPE_BLOCKS; rc = quota_get (qh, &qkey, &(qval->qbval)); if (rc == 0) { qkey.qk_objtype = QUOTA_OBJTYPE_FILES; rc = quota_get (qh, &qkey, &(qval->qival)); } } return rc; } #endif #if _has_std_quotas && ! _lib_quota_open && ! _lib_vquotactl static int # if _proto_stdc quotactl_get (diQuota_t *diqinfo, int cmd, Uid_t id, qdata_t *qdata) # else quotactl_get (diqinfo, cmd, id, qdata) diQuota_t *diqinfo; int cmd; Uid_t id; qdata_t *qdata; # endif { int rc; rc = -4; # if defined (__FreeBSD__) && __FreeBSD__ == 5 /* quotactl on devfs fs panics the system (FreeBSD 5.1) */ if (strcmp (diqinfo->type, "ufs") != 0) { return -4; } # endif if (debug > 5) { printf ("quota: quotactl on %s (%d %d)\n", diqinfo->name, _quotactl_pos_1, _quotactl_pos_2); } /* AIX 7 has quotactl position 1 */ # if _lib_quotactl && _quotactl_pos_1 rc = quotactl (diqinfo->name, cmd, (int) id, (caddr_t) &(qdata->qinfo)); # endif # if _lib_quotactl && ! _quotactl_pos_1 && (_quotactl_pos_2 || defined(_AIX)) # if defined(_AIX) /* AIX has linux compatibility routine, but needs name rather than special */ rc = quotactl (cmd, diqinfo->name, (int) id, (caddr_t) &(qdata->qinfo)); # else rc = quotactl (cmd, (_c_arg_2_quotactl) diqinfo->special, (int) id, (caddr_t) &(qdata->qinfo)); # endif # endif # if _has_std_quotas && _sys_fs_ufs_quota && ! _lib_vquotactl /* Solaris */ { int fd; struct quotctl qop; char tname [DI_NAME_LEN + 1]; qop.op = Q_GETQUOTA; qop.uid = id; qop.addr = (caddr_t) &(qdata->qinfo); strncpy (tname, diqinfo->name, DI_NAME_LEN); strncat (tname, "/quotas", DI_NAME_LEN); fd = open (tname, O_RDONLY | O_NOCTTY); if (fd >= 0) { rc = ioctl (fd, Q_QUOTACTL, &qop); close (fd); } else { rc = fd; } } # endif /* _sys_fs_ufs_quota */ return rc; } #endif /* ! _lib_quota_open */ void #if _proto_stdc diquota (diQuota_t *diqinfo) #else diquota (diqinfo) diQuota_t *diqinfo; #endif { int rc; int xfsflag; #if _has_std_quotas qdata_t qdata; #endif #if _lib_quota_open struct quotahandle *qh; #endif #if _has_std_quotas && ! _lib_quota_open && ! _lib_vquotactl int ucmd = 0; int gcmd = 0; #endif if (debug > 5) { printf ("quota: diquota\n"); } rc = -1; xfsflag = FALSE; diqinfo->limit = 0; diqinfo->used = 0; diqinfo->ilimit = 0; diqinfo->iused = 0; #if _lib_vquotactl rc = vquotactl_get (diqinfo, &qdata.vqval); qdata.vqval.vqvalptr = &qdata.vqval.uvqval; #endif #if _lib_quota_open qh = quota_open (diqinfo->name); rc = quota_open_get (qh, QUOTA_IDTYPE_USER, diqinfo->uid, &qdata.qval); #endif #if ! _lib_quota_open if (strncmp (diqinfo->type, "nfs", (Size_t) 3) == 0 && strcmp (diqinfo->type, "nfsd") != 0) { # if _has_std_nfs_quotas diquota_nfs (diqinfo); # endif return; } #endif #if _has_std_quotas && ! _lib_quota_open && ! _lib_vquotactl if (strcmp (diqinfo->type, "xfs") == 0) { # if _hdr_linux_dqblk_xfs ucmd = QCMD (Q_XGETQUOTA, USRQUOTA); gcmd = QCMD (Q_XGETQUOTA, GRPQUOTA); xfsflag = TRUE; # endif ; } else { # if _define_QCMD ucmd = QCMD (Q_GETQUOTA, USRQUOTA); gcmd = QCMD (Q_GETQUOTA, GRPQUOTA); # else /* hp-ux doesn't have QCMD */ ucmd = Q_GETQUOTA; gcmd = Q_GETQUOTA; # endif } rc = quotactl_get (diqinfo, ucmd, diqinfo->uid, &qdata); #endif /* _has_std_quotas && ! _lib_quota_open && ! _lib_vquotactl */ #if _has_std_quotas di_process_quotas ("usr", diqinfo, rc, xfsflag, &qdata); #if _lib_vquotactl qdata.vqval.vqvalptr = &qdata.vqval.gvqval; #endif # if _lib_quota_open rc = quota_open_get (qh, QUOTA_IDTYPE_GROUP, diqinfo->uid, &qdata.qval); # endif # if ! _lib_quota_open && ! _lib_vquotactl # ifdef GRPQUOTA if (rc == 0 || errno != ESRCH) { rc = quotactl_get (diqinfo, gcmd, diqinfo->gid, &qdata); } # endif /* ifdef GRPQUOTA */ # endif /* ! _lib_quota_open && ! _lib_vquotactl */ # if _lib_quota_open if (qh != (struct quotahandle *) NULL) { quota_close (qh); } # endif # if defined(GRPQUOTA) || _lib_quota_open || _lib_vquotactl di_process_quotas ("grp", diqinfo, rc, xfsflag, &qdata); # endif #endif /* _has_std_quotas */ } #if _has_std_nfs_quotas && ! _lib_quota_open #ifdef RQ_PATHLEN # define DI_RQ_PATHLEN RQ_PATHLEN #else # define DI_RQ_PATHLEN 1024 #endif static bool_t # if _proto_stdc xdr_quota_get (XDR *xp, struct getquota_args *args) # else xdr_quota_get (xp, args) XDR *xp; struct getquota_args *args; # endif { if (debug > 5) { printf ("quota: xdr_quota_get\n"); } if (! xdr_string (xp, &args->gqa_pathp, DI_RQ_PATHLEN)) { return 0; } if (! xdr_gqa_uid (xp, &args->gqa_uid)) { return 0; } return 1; } static bool_t # if _proto_stdc xdr_quota_rslt (XDR *xp, struct getquota_rslt *rslt) # else xdr_quota_rslt (xp, rslt) XDR *xp; struct getquota_rslt *rslt; # endif { int quotastat; struct rquota *rptr; if (debug > 5) { printf ("quota: xdr_quota_rslt\n"); } if (! xdr_int (xp, "astat)) { return 0; } # if _mem_struct_getquota_rslt_gqr_status rslt->gqr_status = quotastat; # else # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wsign-conversion" rslt->status = quotastat; # pragma clang diagnostic pop # endif # if _mem_struct_getquota_rslt_gqr_rquota rptr = &rslt->gqr_rquota; # else rptr = &rslt->getquota_rslt_u.gqr_rquota; # endif if (! xdr_int (xp, &rptr->rq_bsize)) { return 0; } if (! xdr_bool (xp, &rptr->rq_active)) { return 0; } if (! xdr_rq_bhardlimit (xp, &rptr->rq_bhardlimit)) { return 0; } if (! xdr_rq_bsoftlimit (xp, &rptr->rq_bsoftlimit)) { return 0; } if (! xdr_rq_curblocks (xp, &rptr->rq_curblocks)) { return 0; } if (! xdr_rq_fhardlimit (xp, &rptr->rq_fhardlimit)) { return 0; } if (! xdr_rq_fsoftlimit (xp, &rptr->rq_fsoftlimit)) { return 0; } if (! xdr_rq_curfiles (xp, &rptr->rq_curfiles)) { return 0; } return (1); } static void # if _proto_stdc diquota_nfs (diQuota_t *diqinfo) # else diquota_nfs (diqinfo) diQuota_t *diqinfo; # endif { CLIENT *rqclnt; enum clnt_stat clnt_stat; struct timeval timeout; char host [DI_SPEC_NAME_LEN + 1]; char *ptr; char *path; struct getquota_args args; struct getquota_rslt result; struct rquota *rptr; int quotastat; _fs_size_t tsize; if (debug > 5) { printf ("quota: diquota_nfs\n"); } timeout.tv_sec = 2; timeout.tv_usec = 0; strncpy (host, diqinfo->special, DI_SPEC_NAME_LEN); path = host; ptr = strchr (host, ':'); if (ptr != (char *) NULL) { *ptr = '\0'; path = ptr + 1; } if (debug > 2) { printf ("quota: nfs: host: %s path: %s\n", host, path); } args.gqa_pathp = path; args.gqa_uid = (int) diqinfo->uid; rqclnt = clnt_create (host, (unsigned long) RQUOTAPROG, (unsigned long) RQUOTAVERS, "udp"); if (rqclnt == (CLIENT *) NULL) { if (debug > 2) { printf ("quota: nfs: create failed %d\n", errno); } return; } rqclnt->cl_auth = authunix_create_default(); clnt_stat = clnt_call (rqclnt, (unsigned long) RQUOTAPROC_GETQUOTA, (xdrproc_t) xdr_quota_get, (caddr_t) &args, (xdrproc_t) xdr_quota_rslt, (caddr_t) &result, timeout); if (clnt_stat != RPC_SUCCESS) { if (debug > 2) { printf ("quota: nfs: not success\n"); } if (rqclnt->cl_auth) { auth_destroy (rqclnt->cl_auth); } clnt_destroy (rqclnt); return; } # if _mem_struct_getquota_rslt_gqr_status quotastat = result.gqr_status; # else quotastat = result.status; # endif if (quotastat == 1) { # if _mem_struct_getquota_rslt_gqr_rquota rptr = &result.gqr_rquota; # else rptr = &result.getquota_rslt_u.gqr_rquota; # endif if (debug > 2) { printf ("quota: nfs: status 1\n"); printf ("quota: nfs: rq_bsize: %d\n", rptr->rq_bsize); printf ("quota: nfs: rq_active: %d\n", rptr->rq_active); } diqinfo->limit = (_fs_size_t) rptr->rq_bhardlimit * (_fs_size_t) rptr->rq_bsize; tsize = (_fs_size_t) rptr->rq_bsoftlimit * (_fs_size_t) rptr->rq_bsize; if (tsize != 0 && tsize < diqinfo->limit) { diqinfo->limit = tsize; } if (diqinfo->limit != 0) { diqinfo->used = (_fs_size_t) rptr->rq_curblocks * (_fs_size_t) rptr->rq_bsize; } diqinfo->ilimit = rptr->rq_fhardlimit; tsize = rptr->rq_fsoftlimit; if (tsize != 0 && tsize < diqinfo->ilimit) { diqinfo->ilimit = tsize; } if (diqinfo->ilimit != 0) { diqinfo->iused = rptr->rq_curfiles; } } if (rqclnt->cl_auth) { auth_destroy (rqclnt->cl_auth); } clnt_destroy (rqclnt); } #endif /* have std nfs quotas */ #if _has_std_quotas static void # if _proto_stdc di_process_quotas (const char *tag, diQuota_t *diqinfo, int rc, int xfsflag, qdata_t *qdata) # else di_process_quotas (tag, diqinfo, rc, xfsflag, qdata) const char *tag; diQuota_t *diqinfo; int rc; int xfsflag; qdata_t *qdata; # endif { _fs_size_t quotBlockSize = { DI_QUOT_BLOCK_SIZE }; _fs_size_t spaceBlockSize = { DI_QUOT_BLOCK_SIZE }; _fs_size_t tsize; _fs_size_t tlimit; if (debug > 5) { printf ("quota: di_process_quotas\n"); } # if _lib_vquotactl quotBlockSize = 1; spaceBlockSize = 1; # endif # if _mem_struct_dqblk_dqb_curspace spaceBlockSize = 1; # endif if (xfsflag) { quotBlockSize = 512; spaceBlockSize = 512; } if (rc == 0) { tsize = 0; tlimit = 0; if (debug > 1) { printf ("# diquota: blocksize: %lld\n", quotBlockSize); } if (xfsflag) { # if _typ_fs_disk_quota_t if (debug > 1) { printf ("# diquota: fs_disk_quota_t\n"); } tsize = qdata->xfsqinfo.d_blk_hardlimit; # endif ; } else { # if _lib_vquotactl if (debug > 1) { printf ("# diquota: vquotactl\n"); } tsize = qdata->vqval.vqvalptr->limit; # endif # if _typ_struct_quotaval if (debug > 1) { printf ("# diquota: struct quotaval\n"); } tsize = qdata->qval.qbval.qv_hardlimit; # endif # if _typ_struct_dqblk && ! _lib_vquotactl if (debug > 1) { printf ("# diquota: struct dqblk\n"); } tsize = qdata->qinfo.dqb_bhardlimit; # endif } if (debug > 2) { printf ("quota: %s %s b hard: %lld\n", tag, diqinfo->name, tsize); } if ((_s_fs_size_t) tsize > 0) { tsize *= quotBlockSize; if (tsize > 0 && (tsize < diqinfo->limit || diqinfo->limit == 0)) { if (debug > 2) { printf ("quota: using b hard: %lld (%lld)\n", tsize, quotBlockSize); } diqinfo->limit = tsize; tlimit = tsize; } } if (xfsflag) { # if _typ_fs_disk_quota_t tsize = qdata->xfsqinfo.d_blk_softlimit; # endif ; } else { # if _lib_vquotactl /* no soft limit, use hard */ tsize = qdata->vqval.vqvalptr->limit; # endif # if _typ_struct_quotaval tsize = qdata->qval.qbval.qv_softlimit; # endif # if _typ_struct_dqblk && ! _lib_vquotactl tsize = qdata->qinfo.dqb_bsoftlimit; # endif } if (debug > 2) { printf ("quota: %s %s b soft: %lld\n", tag, diqinfo->name, tsize); } if ((_s_fs_size_t) tsize > 0) { tsize *= quotBlockSize; if (tsize > 0 && (tsize < diqinfo->limit || diqinfo->limit == 0)) { if (debug > 2) { printf ("quota: using b soft: %lld (%lld)\n", tsize, quotBlockSize); } diqinfo->limit = tsize; tlimit = tsize; } } /* any quota set? */ if (tlimit == 0) { if (debug > 2) { printf ("quota: %s %s no quota\n", tag, diqinfo->name); } return; } if (debug > 1) { printf ("# diquota: space block size: %lld\n", spaceBlockSize); } tlimit = 0; if (xfsflag) { # if _typ_fs_disk_quota_t if (debug > 1) { printf ("# diquota: fs_disk_quota_t\n"); } tsize = qdata->xfsqinfo.d_bcount; # endif ; } else { # if _lib_vquotactl if (debug > 1) { printf ("# diquota: vquotactl\n"); } tsize = qdata->vqval.vqvalptr->usage; # endif # if _typ_struct_quotaval if (debug > 1) { printf ("# diquota: struct quotaval\n"); } tsize = qdata->qval.qbval.qv_usage; # endif # if _mem_struct_dqblk_dqb_curspace if (debug > 1) { printf ("# diquota: dqb_curspace\n"); } tsize = qdata->qinfo.dqb_curspace; # endif # if _mem_struct_dqblk_dqb_curblocks && ! _lib_vquotactl if (debug > 1) { printf ("# diquota: dqb_curblocks\n"); } tsize = qdata->qinfo.dqb_curblocks; # endif } tsize *= spaceBlockSize; if (tsize > diqinfo->used || diqinfo->used == 0) { diqinfo->used = tsize; } if (debug > 2) { printf ("quota: %s %s used: %lld limit: %lld\n", tag, diqinfo->name, diqinfo->used, diqinfo->limit); } # if ! _lib_vquotactl /* no inode limits */ if (xfsflag) { # if _typ_fs_disk_quota_t tsize = qdata->xfsqinfo.d_ino_hardlimit; # endif ; } else { # if _typ_struct_quotaval tsize = qdata->qval.qival.qv_hardlimit; # endif # if _typ_struct_dqblk && ! _lib_vquotactl tsize = qdata->qinfo.dqb_ihardlimit; # endif } if (tsize > 0 && (tsize < diqinfo->ilimit || diqinfo->ilimit == 0)) { diqinfo->ilimit = tsize; tlimit = tsize; } if (debug > 2) { printf ("quota: %s %s i hard: %lld\n", tag, diqinfo->name, tsize); } if (xfsflag) { # if _typ_fs_disk_quota_t tsize = qdata->xfsqinfo.d_ino_softlimit; # endif ; } else { # if _typ_struct_quotaval tsize = qdata->qval.qival.qv_softlimit; # endif # if _typ_struct_dqblk && ! _lib_vquotactl tsize = qdata->qinfo.dqb_isoftlimit; # endif } if (tsize > 0 && (tsize < diqinfo->ilimit || diqinfo->ilimit == 0)) { diqinfo->ilimit = tsize; tlimit = tsize; } if (debug > 2) { printf ("quota: %s %s i soft: %lld\n", tag, diqinfo->name, tsize); } /* any quota set? */ if (tlimit == 0) { if (debug > 2) { printf ("quota: %s %s no inode quota\n", tag, diqinfo->name); } return; } if (xfsflag) { # if _typ_fs_disk_quota_t tsize = qdata->xfsqinfo.d_icount; # endif ; } else { # if _typ_struct_quotaval tsize = qdata->qval.qival.qv_usage; # endif # if ! _lib_quota_open && ! _lib_vquotactl tsize = qdata->qinfo.dqb_curinodes; # endif } if (tsize > diqinfo->iused || diqinfo->iused == 0) { diqinfo->iused = tsize; } if (debug > 2) { printf ("quota: %s %s i used: %lld\n", tag, diqinfo->name, tsize); } # endif /* ! _lib_vquotactl */ } else { if (debug > 2) { printf ("quota: %s %s errno %d\n", tag, diqinfo->name, errno); } } } #endif /* _has_std_quotas */ di-4.47/C/version.h0000644000175000017500000000012613334050206012163 0ustar bllbll#ifndef DI_INC_VERSION_H #define DI_INC_VERSION_H # define DI_VERSION "4.47" #endif di-4.47/C/strstr.c0000644000175000017500000000137313334050206012037 0ustar bllbll/* * Copyright 1994-2018 Brad Lanam, Walnut Creek, CA */ #include "config.h" #if ! _lib_strstr # include "di.h" #if _hdr_stdio # include #endif # if _hdr_stdlib # include # endif # if _hdr_string # include # endif # if _hdr_strings # include # endif char * # if _proto_stdc strstr (const char *buff, const char *srch) # else strstr (buff, srch) const char *buff; const char *srch; # endif { Size_t len; char * p; p = (char *) buff; if (srch == (char *) NULL) { return p; } len = strlen (srch); for (; (p = strchr (p, *srch)) != (char *) NULL; p++) { if (strncmp (p, srch, len) == 0) { return (p); } } return (char *) NULL; } #else extern int debug; #endif di-4.47/mkconfig/0000755000175000017500000000000013334050206011741 5ustar bllblldi-4.47/mkconfig/mkconfig.pl0000755000175000017500000014056713334050206014113 0ustar bllbll#!/usr/bin/perl # # Copyright 2006-2018 Brad Lanam Walnut Creek, CA USA # # HP-UX doesn't have these installed. # use strict; # use Config; require 5.005; my $CONFH; my $LOG = "mkconfig.log"; my $_MKCONFIG_TMP = "_tmp_mkconfig"; my $OPTIONFILE = "options.dat"; my $VARSFILE = "mkc_none_c.vars"; my $CACHEFILE = "mkconfig.cache"; my $REQLIB = "mkconfig.reqlibs"; my $_MKCONFIG_DIR = "invalid"; my $precc = <<'_HERE_'; #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif #if defined(__cplusplus) || defined (c_plusplus) # define CPP_EXTERNS_BEG extern "C" { # define CPP_EXTERNS_END } CPP_EXTERNS_BEG extern int printf (const char *, ...); CPP_EXTERNS_END #else # define CPP_EXTERNS_BEG # define CPP_EXTERNS_END #endif _HERE_ my $postcc = <<'_HERE_'; /* some gcc's (cygwin) redefine __restrict again */ #if defined (__restrict) # undef __restrict #endif #define __restrict _HERE_ my $optionsloaded = 0; my %optionshash; my $iflevels = ''; my $awkcmd = 'awk'; foreach my $p (split /[;:]/o, $ENV{'PATH'}) { if (-x "$p/awk" && $awkcmd == "") { $awkcmd = "$p/awk"; } if (-x "$p/nawk" && $awkcmd !~ /mawk$/o && $awkcmd !~ /gawk$/o) { $awkcmd = "$p/nawk"; } if (-x "$p/mawk" && $awkcmd !~ /gawk$/o) { $awkcmd = "$p/mawk"; } if (-x "$p/gawk") { $awkcmd = "$p/gawk"; } } sub exitmkconfig { my $rc = shift; exit 1; } sub printlabel { my ($name, $label) = @_; print LOGFH "## ${iflevels}[$name] $label ... \n"; print STDOUT "${iflevels}$label ... "; } sub printyesno_actual { my ($name, $val, $tag) = @_; print LOGFH "## [$name] $val $tag\n"; print STDOUT "$val $tag\n"; } sub printyesno_val { my ($name, $val, $tag) = @_; if ($val ne '0') { printyesno_actual ($name, $val, $tag); } else { printyesno_actual ($name, 'no', $tag); } } sub printyesno { my ($name, $val, $tag) = @_; if ($val ne "0") { $val = "yes"; } printyesno_val $name, $val, $tag; } sub savevars { my ($r_clist) = @_; open (MKCV, ">$VARSFILE"); foreach my $val (@{$r_clist->{'vars'}}) { print MKCV $val, "\n"; } close (MKCV); } sub savecache { my ($r_clist, $r_config) = @_; open (MKCC, ">$CACHEFILE"); foreach my $val (@{$r_clist->{'clist'}}) { if ($val =~ /^lib__lib_/o) { $tval = $val; $tval =~ s/^lib_//o; print MKCC "mkc_c_lib_${tval}='" . $r_config->{$val} . "'\n"; } else { print MKCC "mkc_c_${val}='" . $r_config->{$val} . "'\n"; } } close (MKCC); } sub checkcache_val { my ($name, $r_clist, $r_config) = @_; my $rc = 1; if (defined ($r_config->{$name}) && $r_config->{$name} ne "" ) { push @{$r_clist->{'vars'}}, $name; my $r_hash = $r_clist->{'vhash'}; $r_hash->{$name} = 1; printyesno_val $name, $r_config->{$name}, " (cached)"; $rc = 0; } return $rc; } sub checkcache { my ($name, $r_clist, $r_config) = @_; my $rc = 1; if (defined ($r_config->{$name}) && $r_config->{$name} ne "" ) { push @{$r_clist->{'vars'}}, $name; my $r_hash = $r_clist->{'vhash'}; $r_hash->{$name} = 1; printyesno $name, $r_config->{$name}, " (cached)"; $rc = 0; } return $rc; } sub loadoptions { if ($optionsloaded == 0 && open (OPTS, "<$OPTIONFILE")) { while (my $o = ) { chomp $o; if ($o =~ /^$/o || $o =~ /^#/o) { next; } my ($onm, $val) = split (/=/, $o); printf LOGFH "## load: $onm = $val\n"; $optionshash{$onm} = $val; } $optionsloaded = 1; close (OPTS); } } sub setclist { my ($r_clist, $name) = @_; $r_hash = $r_clist->{'chash'}; if (! defined ($r_hash->{$name})) { push @{$r_clist->{'clist'}}, $name; $r_hash->{$name} = 1; } } sub setlist { my ($r_clist, $name) = @_; my $r_hash = $r_clist->{'vhash'}; if (! defined ($r_hash->{$name})) { push @{$r_clist->{'vars'}}, $name; $r_hash->{$name} = 1; } setclist ($r_clist, $name); } sub setcflags { my $CFLAGS = ''; if ( $ENV{'CFLAGS_ALL'} != "" ) { $CFLAGS= $ENV{'CFLAGS_ALL'}; } else { $CFLAGS .= ' ' . $ENV{'CFLAGS_OPTIMIZE'}; $CFLAGS .= ' ' . $ENV{'CFLAGS_DEBUG'}; $CFLAGS .= ' ' . $ENV{'CFLAGS_INCLUDE'}; $CFLAGS .= ' ' . $ENV{'CFLAGS_USER'}; $CFLAGS .= ' ' . $ENV{'CFLAGS_APPLICATION'}; $CFLAGS .= ' ' . $ENV{'CFLAGS_COMPILER'}; $CFLAGS .= ' ' . $ENV{'CFLAGS_SYSTEM'}; } $ENV{'CFLAGS'} = $CFLAGS; } sub setldflags { my $LDFLAGS = ''; if ( $ENV{'LDFLAGS_ALL'} != "" ) { $LDFLAGS = $ENV{'LDFLAGS_ALL'} } else { $LDFLAGS .= ' ' . $ENV{'LDFLAGS_OPTIMIZE'}; $LDFLAGS .= ' ' . $ENV{'LDFLAGS_DEBUG'}; $LDFLAGS .= ' ' . $ENV{'LDFLAGS_USER'}; $LDFLAGS .= ' ' . $ENV{'LDFLAGS_APPLICATION'}; $LDFLAGS .= ' ' . $ENV{'LDFLAGS_COMPILER'}; $LDFLAGS .= ' ' . $ENV{'LDFLAGS_SYSTEM'}; } $ENV{'LDFLAGS'} = $LDFLAGS; } sub setlibs { my $LIBS = ''; if ( $ENV{'LDFLAGS_LIBS_ALL'} != "" ) { $LIBS = $ENV{'LDFLAGS_LIBS_ALL'} } else { $LIBS .= ' ' . $ENV{'LDFLAGS_LIBS_USER'}; $LIBS .= ' ' . $ENV{'LDFLAGS_LIBS_APPLICATION'}; $LIBS .= ' ' . $ENV{'LDFLAGS_LIBS_SYSTEM'}; } $ENV{'LIBS'} = $LIBS; } sub print_headers { my ($r_a, $r_clist, $r_config, $cppchk) = @_; my $txt; $txt = ''; if ($r_a->{'incheaders'} eq 'all' || $r_a->{'incheaders'} eq 'std') { # always include these four if present ... foreach my $val ('_hdr_stdio', '_hdr_stdlib', '_sys_types', '_sys_param') { if (defined ($r_config->{$val}) && $r_config->{$val} ne '0') { $txt .= "#include <" . $r_config->{$val} . ">\n"; # for cygwin/gcc if ($cppchk && $val eq '_hdr_stdio') { $txt .= $postcc; } } } } if ($r_a->{'incheaders'} eq 'all') { foreach my $val (@{$r_clist->{'vars'}}) { if ($val !~ m#^(_hdr_|_sys_)#o) { next; } if ($val eq '_hdr_stdio' || $val eq '_hdr_stdlib' || $val eq '_sys_types' || $val eq '_sys_param') { next; } if ($val eq '_sys_time' && $r_config->{'_sys_time'} ne '0' && $r_config->{'_inc_conflict__hdr_time__sys_time'} eq '0') { next; } if ($val eq '_hdr_linux_quota' && $r_config->{'_hdr_linux_quota'} ne '0' && $r_config->{'_inc_conflict__sys_quota__hdr_linux_quota'} eq '0') { next; } if ($r_config->{$val} ne '0') { $txt .= "#include <" . $r_config->{$val} . ">\n"; } } $txt .= "\n"; } return $txt; } sub _chk_run { my ($name, $code, $r_val, $r_clist, $r_config, $r_a) = @_; my $rc = _chk_link ($name, $code, $r_clist, $r_config, { 'incheaders' => 'all', %$r_a, }); print LOGFH "## run test: link: $rc\n"; $$r_val = 0; if ($rc == 0) { $rc = system ("./$name.exe > $name.out"); if ($rc & 127) { exitmkconfig ($rc); } $rc >>= 8; print LOGFH "## run test: run: $rc\n"; if ($rc == 0) { open (CRFH, "<$name.out"); $$r_val = ; chomp $$r_val; close CRFH; } } return $rc; } sub _chk_link { my ($name, $code, $r_clist, $r_config, $r_a) = @_; my $otherlibs = ''; if (defined ($r_a->{'otherlibs'})) { $otherlibs = $r_a->{'otherlibs'}; } open (CLFH, ">$name.c"); print CLFH $precc; my $hdrs = print_headers ($r_a, $r_clist, $r_config, 0); print CLFH $hdrs; print CLFH $code; close CLFH; my $rc = system ("cat $name.c >> $LOG"); if ($rc & 127) { exitmkconfig ($rc); } my $dlibs = ''; $rc = _chk_link_libs ($name, {} ); if ($rc != 0) { if ($otherlibs ne '') { my @olibs = split (/,/, $otherlibs); my $oliblist = ''; foreach my $olib (@olibs) { $oliblist = $oliblist . ' ' . $olib; $rc = _chk_link_libs ($name, { 'otherlibs' => $oliblist, } ); if ($rc == 0) { my $r_hash = $r_config->{'reqlibs'}; my @vals = split (/\s+/, $oliblist); $dlibs = ''; foreach my $val (@vals) { if ($val eq '') { next; } if (! defined ($r_hash->{$val})) { print LOGFH " reqlib: $val: new\n"; push @{$r_config->{'reqlibs_list'}}, $val; } else { print LOGFH " reqlib: $val: already\n"; } $r_hash->{$val} = 1; $dlibs .= $val . ' '; } last; } } } } $dlibs =~ s/ *$//o; $r_a->{'dlibs'} = $dlibs; return $rc; } sub _chk_link_libs { my ($name, $r_a) = @_; setcflags setldflags setlibs my $cmd = "$ENV{'CC'} $ENV{'CFLAGS'} "; if (defined ($r_a->{'cflags'})) { $cmd .= ' ' . $r_a->{'cflags'} . ' '; } $cmd .= "-o $name.exe $name.c"; $cmd .= " $ENV{'LDFLAGS'} $ENV{'LIBS'}"; if (defined ($r_a->{'otherlibs'}) && $r_a->{'otherlibs'} ne undef) { $cmd .= ' ' . $r_a->{'otherlibs'} . ' '; } print LOGFH "## link test: $cmd\n"; my $rc = system ("$cmd >> $LOG 2>&1"); if ($rc & 127) { exitmkconfig ($rc); } print LOGFH "## link test: $rc\n"; if ($rc == 0) { if (! -x "$name.exe") # not executable. { $rc = 1; } } return $rc; } sub _chk_cpp { my ($name, $code, $r_clist, $r_config, $r_a) = @_; open (CCFH, ">$name.c"); print CCFH $precc; my $hdrs = print_headers ($r_a, $r_clist, $r_config, 1); print CCFH $hdrs; print CCFH $code; close CCFH; setcflags my $cmd = "$ENV{'CC'} $ENV{'CFLAGS'} "; if (defined ($r_a->{'cflags'})) { $cmd .= ' ' . $r_a->{'cflags'} . ' '; } $cmd .= "-E $name.c > $name.out "; my $rc = system ("cat $name.c >> $LOG"); if ($rc & 127) { exitmkconfig ($rc); } $rc = system ("$cmd 2>>$LOG"); print LOGFH "## cpp test: $cmd\n"; if ($rc & 127) { exitmkconfig ($rc); } print LOGFH "## cpp test: $rc\n"; if ($rc == 0 && ! -f "$name.out") { print LOGFH "## can't locate $name.out\n"; $rc = -2; } return $rc; } sub _chk_compile { my ($name, $code, $r_clist, $r_config, $r_a) = @_; open (CCFH, ">$name.c"); print CCFH $precc; my $hdrs = print_headers ($r_a, $r_clist, $r_config, 0); print CCFH $hdrs; print CCFH $code; close CCFH; setcflags my $cmd = "$ENV{'CC'} $ENV{'CFLAGS'} -c $name.c"; print LOGFH "## compile test: $cmd\n"; my $rc = system ("cat $name.c >> $LOG"); if ($rc & 127) { exitmkconfig ($rc); } $rc = system ("$cmd >> $LOG 2>&1"); if ($rc & 127) { exitmkconfig ($rc); } print LOGFH "## compile test: $rc\n"; return $rc; } sub do_chk_compile { my ($name, $code, $inc, $r_clist, $r_config) = @_; my $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => $inc, }); my $trc = 0; if ($rc == 0) { $trc = 1; } printyesno $name, $trc; setlist $r_clist, $name; $r_config->{$name} = $trc; } sub check_header { my ($name, $file, $r_clist, $r_config, $r_a) = @_; printlabel $name, "header: $file"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } my $r_rh = $r_a->{'reqhdr'} || []; my $code = ''; foreach my $reqhdr (@$r_rh) { $code .= <<"_HERE_"; #include <$reqhdr> _HERE_ } $code .= <<"_HERE_"; #include <${file}> main () { return (0); } _HERE_ my $rc = 1; $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => 'std', }); my $val = 0; if ($rc == 0) { $val = $file; } printyesno $name, $val; setlist $r_clist, $name; $r_config->{$name} = $val; } sub check_constant { my ($name, $constant, $r_clist, $r_config, $r_a) = @_; printlabel $name, "constant: $constant"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } my $r_rh = $r_a->{'reqhdr'} || []; my $code = ''; foreach my $reqhdr (@$r_rh) { $code .= <<"_HERE_"; #include <$reqhdr> _HERE_ } $code .= <<"_HERE_"; main () { if (${constant} == 0) { 1; } return (0); } _HERE_ do_chk_compile ($name, $code, 'all', $r_clist, $r_config); } # if the keyword is reserved, the compile will fail. sub check_keyword { my ($name, $keyword, $r_clist, $r_config) = @_; printlabel $name, "keyword: $keyword"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } $r_config->{$name} = 0; my $code = <<"_HERE_"; main () { int ${keyword}; ${keyword} = 1; return (0); } _HERE_ my $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => 'std', }); setlist $r_clist, $name; if ($rc != 0) # failure means it is reserved... { $r_config->{$name} = 1; } printyesno $name, $r_config->{$name}; } sub check_proto { my ($name, $r_clist, $r_config) = @_; printlabel $name, "supported: prototypes"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } my $code = <<"_HERE_"; CPP_EXTERNS_BEG extern int foo (int, int); CPP_EXTERNS_END int bar () { int rc; rc = foo (1,1); return 0; } _HERE_ my $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => 'all', }); setlist $r_clist, $name; $r_config->{$name} = 0; if ($rc == 0) { $r_config->{$name} = 1; } printyesno $name, $r_config->{$name}; } sub check_command { my ($name, $cmds, $r_clist, $r_config) = @_; my @cmdlist = split (/ +/o, $cmds); my $cmd = $cmdlist[0]; $name = "_command_${cmd}"; my $locnm = "_cmd_loc_${cmd}"; printlabel $name, "command: $cmd"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; $r_config->{$name} = 0; foreach my $cmd (@cmdlist) { foreach my $p (split /[;:]/o, $ENV{'PATH'}) { if (-x "$p/$cmd") { setlist $r_clist, $locnm; $r_config->{$locnm} = "$p/$cmd"; $r_config->{$name} = 1; last; } } } printyesno_val $name, $r_config->{$name}; } sub check_grep { my ($name, $args, $r_clist, $r_config) = @_; my @arglist = split (/ +/o, $args); my $tag = $arglist[0]; my $pat= $arglist[1]; my $fn = $arglist[2]; $name = "_grep_${tag}"; my $locnm = "_grep_${tag}"; printlabel $name, "grep: $tag"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; $r_config->{$name} = 0; my $rc = system ("grep '${pat}' $fn > /dev/null 2>&1"); if ($rc == 0) { $r_config->{$name} = 1; } printyesno_val $name, $r_config->{$name}; } sub check_ifoption { my ($ifcount, $type, $name, $opt, $r_clist, $r_config) = @_; printlabel $name, "$type ($ifcount): $opt"; loadoptions (); my $trc = 0; my $found = 'F'; if ($optionsloaded && defined ($optionshash{$opt})) { $found = 'T'; $trc = lc $optionshash{$opt}; print LOGFH "## found: $opt => $trc\n"; if ($trc eq 't') { $trc = 1; } if ($trc eq 'enable') { $trc = 1; } if ($trc eq 'f') { $trc = 0; } if ($trc eq 'disable') { $trc = 0; } if ($trc eq 'true') { $trc = 1; } if ($trc eq 'false') { $trc = 0; } if ($trc eq 'yes') { $trc = 1; } if ($trc eq 'no') { $trc = 0; } } if (! $optionsloaded) { $trc = 0; } elsif ($found eq 'F') { $trc = 0; } if ($type eq 'ifnotoption') { $trc = $trc == 0 ? 1 : 0; } if (! $optionsloaded) { printyesno_actual $name, "no options file"; } elsif ($found eq 'F') { printyesno_actual $name, "option not found"; } else { printyesno $name, $trc; } return $trc; } sub check_if { my ($iflabel, $ifcount, $ifline, $r_clist, $r_config) = @_; my $name = "_if_$iflabel"; my $trc = 0; # make parseable $ifline =~ s/!/ ! /og; $ifline =~ s/\(/ ( /og; $ifline =~ s/\)/ ) /og; $ifline =~ s/&&/ \&\& /og; $ifline =~ s/ and / && /og; $ifline =~ s/ -a / && /og; $ifline =~ s/\|\|/ || /og; $ifline =~ s/ or / || /og; $ifline =~ s/ -o / || /og; $ifline =~ s/ not / ! /og; $ifline =~ s/ +/ /og; $ifline =~ s/^ *//og; $ifline =~ s/ *$//og; printlabel $name, "if ($ifcount): $iflabel"; my $nline = ''; print LOGFH "## ifline: $ifline\n"; my $ineq = 0; my $val; my $quoted = 0; my $qtoken; foreach my $token (split (/\s/, $ifline)) { if ($token =~ /^'.*'$/o) { print LOGFH "## start/end qtoken\n"; $token =~ s/'//go; } elsif ($token =~ /^'/o) { $qtoken = $token; $quoted = 1; print LOGFH "## start qtoken\n"; next; } if ($quoted) { if ($token =~ /'$/o) { $token = $qtoken . ' ' . $token; $token =~ s/'//go; print LOGFH "## end qtoken\n"; $quoted = 0; } else { $qtoken = $qtoken . ' ' . $token; print LOGFH "## in qtoken\n"; next; } } if ($ineq == 1) { $ineq = 2; print LOGFH "## value of $token(B): " . $r_config->{$token} . "\n"; $val = $r_config->{$token}; } elsif ($ineq == 2) { print LOGFH "## end ==\n"; $ineq = 0; $nline .= "('$val' eq '$token') ? 1 : 0"; $nline .= ' '; } elsif ($token eq '==') { print LOGFH "## begin ==\n"; $ineq = 1; } elsif ($token eq '(' || $token eq ')' || $token eq '&&' || $token eq '||' || $token eq '!') { $nline .= $token . ' '; } else { print LOGFH "## value of $token: " . $r_config->{$token} . "\n"; $nline .= $r_config->{$token} ne '0' && $r_config->{$token} ne '' ? 1 : 0; $nline .= ' '; } } print LOGFH "## nline: $nline\n"; $trc = eval $nline; printyesno $name, $trc; return $trc; } sub check_set { my ($name, $type, $val, $r_clist, $r_config) = @_; my $tnm = $name; $tnm =~ s/^_setint_//; $tnm =~ s/^_setstr_//; printlabel $name, "${type}: $tnm"; if ($type eq 'set') { if (defined ($r_config->{$name})) { setlist $r_clist, $name; $r_config->{$name} = $val; printyesno $name, $r_config->{$name}; } else { printyesno_actual $name, 'no such variable'; } } elsif ($type eq 'setint') { setlist $r_clist, $name; $r_config->{$name} = $val; printyesno_actual $name, $r_config->{$name}; } else { setlist $r_clist, $name; $r_config->{$name} = $val; printyesno_actual $name, $r_config->{$name}; } } sub check_option { my ($name, $onm, $def, $r_clist, $r_config) = @_; printlabel $name, "option: $onm"; loadoptions (); my $oval = $def; if ($optionsloaded && defined ($optionshash{$onm})) { $oval = $optionshash{$onm}; print LOGFH "## found: $onm => $oval\n"; } setlist $r_clist, $name; $r_config->{$name} = $oval; printyesno_actual $name, $r_config->{$name}; } sub check_include_conflict { my ($name, $h1, $h2, $r_clist, $r_config) = @_; my $i1 = $h1; $i1 =~ s,/,_,go; $i1 =~ s,\.h$,,o; $i1 =~ s,:,,go; if ($i1 =~ m#^sys#o) { $i1 = "_${i1}"; } else { $i1 = "_hdr_${i1}"; } my $i2 = $h2; $i2 =~ s,/,_,go; $i2 =~ s,\.h$,,o; $i2 =~ s,:,,go; if ($i2 =~ m#^sys#o) { $i2 = "_${i2}"; } else { $i2 = "_hdr_${i2}"; } $name = "${name}_${i1}_${i2}"; printlabel $name, "header: include both $h1 & $h2"; if (defined ($r_config->{${i1}}) && $r_config->{${i1}} ne '0' && defined ($r_config->{${i2}}) && $r_config->{${i2}} ne '0') { if (checkcache ($name, $r_clist, $r_config) == 0) { return; } my $code = <<"_HERE_"; #include <$h1> #include <$h2> main () { return 0; } _HERE_ do_chk_compile ($name, $code, 'std', $r_clist, $r_config); } else { setlist $r_clist, $name; $r_config->{$name} = 1; printyesno $name, $r_config->{$name}; } } sub check_npt { my ($name, $proto, $req, $r_clist, $r_config) = @_; printlabel $name, "need prototype: $proto"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } if (defined ($r_config->{$req}) && $r_config->{$req} eq '0') { $r_config->{$name} = 0; setlist $r_clist, $name; printyesno $name, $r_config->{$name}; return; } my $code = <<"_HERE_"; CPP_EXTERNS_BEG struct _TEST_struct { int _TEST_member; }; extern struct _TEST_struct* $proto _((struct _TEST_struct*)); CPP_EXTERNS_END _HERE_ do_chk_compile ($name, $code, 'all', $r_clist, $r_config); } sub check_type { my ($name, $type, $r_clist, $r_config) = @_; $type =~ s/star/*/og; printlabel $name, "type: $type"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } my $code = <<"_HERE_"; struct xxx { $type mem; }; static struct xxx v; struct xxx* f() { return &v; } main () { struct xxx *tmp; tmp = f(); return (0); } _HERE_ do_chk_compile ($name, $code, 'all', $r_clist, $r_config); } sub check_defined { my ($name, $def, $r_clist, $r_config) = @_; printlabel $name, "defined: $def"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; my $code = <<"_HERE_"; main () { #ifdef ${def} return (0); #else return (1); #endif } _HERE_ my $val = 0; my $rc = _chk_run ($name, $code, \$val, $r_clist, $r_config, {}); $r_config->{$name} = $rc == 0 ? 1 : 0; printyesno $name, $r_config->{$name}; } sub check_param_void_star { my ($name, $r_clist, $r_config) = @_; printlabel $name, "parameter: void *"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } my $code = <<"_HERE_"; char * tparamvs (ptr) void *ptr; { ptr = (void *) NULL; return (char *) ptr; } _HERE_ do_chk_compile ($name, $code, 'all', $r_clist, $r_config); } sub check_printf_long_double { my ($name, $r_clist, $r_config) = @_; printlabel $name, "printf: long double printable"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; my $code = << "_HERE_"; int main (int argc, char *argv[]) { long double a; long double b; char t[40]; a = 1.0; b = 2.0; a = a / b; sprintf (t, \"%.1Lf\", a); if (strcmp(t,\"0.5\") == 0) { return (0); } return (1); } _HERE_ my $val = 0; my %a = ( 'incheaders' => 'all', ); my $rc = _chk_run ($name, $code, \$val, $r_clist, $r_config, \%a); $r_config->{$name} = $rc == 0 ? 1 : 0; printyesno $name, $r_config->{$name}; } sub check_lib { my ($name, $func, $r_clist, $r_config, $r_a) = @_; setlist $r_clist, $name; my $val = $r_a->{'otherlibs'} || ''; $rfunc = $func; $rfunc =~ s/_dollar_/\$/g; if ($val ne '') { printlabel $name, "function: $rfunc [$val]"; } else { printlabel $name, "function: $rfunc"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } } $r_config->{$name} = 0; # unfortunately, this does not work if the function # is not declared. my $code = <<"_HERE_"; typedef int (*_TEST_fun_)(); static _TEST_fun_ i=(_TEST_fun_) $rfunc; main () { i(); return (i==0); } _HERE_ my %a = ( 'incheaders' => 'all', 'otherlibs' => $val, ); my $rc = _chk_link ($name, $code, $r_clist, $r_config, \%a); my $tag = ''; if ($rc == 0) { $r_config->{$name} = 1; if ($a{'dlibs'} ne '') { $tag = " with $a{'dlibs'}"; $r_config->{"lib_$name"} = $a{'dlibs'}; setclist $r_clist, "lib_$name"; } } printyesno $name, $r_config->{$name}, $tag; } sub check_class { my ($name, $class, $r_clist, $r_config, $r_a) = @_; setlist $r_clist, $name; my $val = $r_a->{'otherlibs'} || ''; if ($val ne '') { printlabel $name, "class: $class [$val]"; } else { printlabel $name, "class: $class"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } } $r_config->{$name} = 0; my $code = <<"_HERE_"; main () { $class testclass; } _HERE_ my %a = ( 'incheaders' => 'all', 'otherlibs' => $val, ); my $rc = _chk_link ($name, $code, $r_clist, $r_config, \%a); my $tag = ''; if ($rc == 0) { $r_config->{$name} = 1; if ($a{'dlibs'} ne '') { $tag = " with $a{'dlibs'}"; $r_config->{"lib_$name"} = $a{'dlibs'}; setlist $r_clist, "lib_$name"; } } printyesno $name, $r_config->{$name}, $tag; } sub check_args { my ($name, $funcnm, $r_a, $r_clist, $r_config) = @_; printlabel $name, "args: $funcnm"; # no cache if ($ENV{'_MKCONFIG_USING_GCC'} == 'N' && $ENV{'_MKCONFIG_SYSTYPE'} == 'HP-UX' ) { my $tcc = `$ENV{'CC'} -v 2>&1`; if ($tcc =~ /Bundled/o) { print " bundled cc; skipped"; return; } } my $oldprecc = $precc; $precc .= "/* get rid of most gcc-isms */ #define __asm(a) #define __asm__(a) #define __attribute__(a) #define __nonnull__(a,b) #define __restrict #define __restrict__ #if defined(__THROW) # undef __THROW #endif #define __THROW #define __const const "; my $rc = _chk_cpp ($name, "", $r_clist, $r_config, { 'incheaders' => 'all', }); $precc = $oldprecc; my $ccount = 0; if ($rc == 0) { my $cmd = "egrep \"[ *]" . ${funcnm} . "[ ]*\\(\" $name.out >/dev/null 2>&1"; $rc = system ($cmd); print LOGFH "## args: $cmd $rc\n"; if ($rc == 0) { my $dcl = `${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextdcl.awk ${name}.out ${funcnm}`; # $dcl may be multi-line...fix this now. $dcl =~ s/[ \n\r]/ /gos; $dcl =~ s/extern *//o; $dcl =~ s/;//o; print LOGFH "## dcl(A): $dcl\n"; $dcl =~ s/\( *void *\)/()/o; print LOGFH "## dcl(C): $dcl\n"; my $c = $dcl; $c =~ s/[^,]*//go; $ccount = length ($c); $ccount += 1; $c = $dcl; $c =~ s/^[^\(]*\(//o; $c =~ s/\)[^\)]*$//o; print LOGFH "## c(E): ${c}\n"; my $val = 1; while (${c} ne "") { my $tc = $c; $tc =~ s/ *,.*$//o; $tc =~ s/[ ]+/ /go; if ($r_a->{'noconst'} eq 'T') { $tc =~ s/const *//o; } $tc =~ s/^ *//; $tc =~ s/ *$//; # only do the following if the names of the variables are declared $tc =~ s/(struct|union|enum) /$1#/; if ($tc =~ / /o) { $tc =~ s/ *[A-Za-z0-9_]*$//o; } $tc =~ s/(struct|union|enum)#/$1 /; print LOGFH "## tc(F): ${tc}\n"; my $nm = "_c_arg_${val}_${funcnm}"; setlist $r_clist, $nm; $r_config->{$nm} = $tc; $val += 1; $c =~ s/^[^,]*//o; $c =~ s/^[ ,]*//o; print LOGFH "## c(G): ${c}\n"; } $c = $dcl; $c =~ s/[ ]+/ /go; $c =~ s/([ \*])${funcnm}[ \(].*/$1/; $c =~ s/^ *//o; $c =~ s/ *$//o; if ($r_a->{'noconst'}) { $c =~ s/const *//; } $nm = "_c_type_${funcnm}"; setlist $r_clist, $nm; $r_config->{$nm} = $c; } } setlist $r_clist, $name; $r_config->{$name} = $ccount; printyesno_val $name, $r_config->{$name}; } sub check_size { my ($name, $type, $r_clist, $r_config) = @_; printlabel $name, "sizeof: $type"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; $r_config->{$name} = 0; my $code = <<"_HERE_"; main () { printf("%u\\n", sizeof($type)); return (0); } _HERE_ my $val = 0; my $rc = _chk_run ($name, $code, \$val, $r_clist, $r_config, {}); if ($rc == 0) { $val =~ s/\r//gos; $r_config->{$name} = $val; } printyesno_val $name, $r_config->{$name}; } sub check_member { my ($name, $struct, $member, $r_clist, $r_config) = @_; printlabel $name, "exists: $struct.$member"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; $r_config->{$name} = 0; my $code = <<"_HERE_"; main () { $struct s; int i; i = sizeof (s.$member); } _HERE_ my $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => 'all', }); if ($rc == 0) { $r_config->{$name} = 1; } printyesno $name, $r_config->{$name}; } sub check_memberxdr { my ($name, $struct, $member, $r_clist, $r_config) = @_; printlabel $name, "member:xdr: $struct.$member"; # no cache $r_config->{$name} = 0; my $rc = _chk_cpp ($name, "", $r_clist, $r_config, { 'incheaders' => 'all', }); if ($rc == 0) { print LOGFH `pwd` . "\n"; print LOGFH "## ${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextstruct.awk ${name}.out ${struct}\n"; my $st = `${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextstruct.awk ${name}.out ${struct}`; print LOGFH "## xdr(A): $st\n"; if ($st =~ m/${member}\s*;/s) { my $mtype = $st; $mtype =~ s/\s*${member}\s*;.*//s; $mtype =~ s/.*\s//os; print LOGFH "## xdr(B): $mtype\n"; setlist $r_clist, "xdr_${member}"; $r_config->{"xdr_${member}"} = "xdr_${mtype}"; $r_config->{$name} = 1; } } setlist $r_clist, $name; printyesno $name, $r_config->{$name}; } sub check_int_declare { my ($name, $function, $r_clist, $r_config) = @_; printlabel $name, "declared: $function"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; $r_config->{$name} = 0; my $code = <<"_HERE_"; main () { int x; x = $function; } _HERE_ my $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => 'all', }); if ($rc == 0) { $r_config->{$name} = 1; } printyesno $name, $r_config->{$name}; } sub check_ptr_declare { my ($name, $function, $r_clist, $r_config) = @_; printlabel $name, "declared: $function"; if (checkcache ($name, $r_clist, $r_config) == 0) { return; } setlist $r_clist, $name; $r_config->{$name} = 0; my $code = <<"_HERE_"; main () { void *x; x = $function; } _HERE_ my $rc = _chk_compile ($name, $code, $r_clist, $r_config, { 'incheaders' => 'all', }); if ($rc == 0) { $r_config->{$name} = 1; } printyesno $name, $r_config->{$name}; } sub check_standard { my ($r_clist, $r_config) = @_; # FreeBSD has buggy headers, requires sys/param.h as a required include. # always check for these headers. my @headlist1 = ( [ "_hdr_stdio", "stdio.h", ], [ "_hdr_stdlib", "stdlib.h", ], [ "_sys_types", "sys/types.h", ], [ "_sys_param", "sys/param.h", ], ); foreach my $r_arr (@headlist1) { check_header ($$r_arr[0], $$r_arr[1], $r_clist, $r_config, { 'reqhdr' => [], }); } check_keyword ('_key_void', 'void', $r_clist, $r_config); check_keyword ('_key_const', 'const', $r_clist, $r_config); check_param_void_star ('_param_void_star', $r_clist, $r_config); check_proto ('_proto_stdc', $r_clist, $r_config); } sub create_output { my ($r_clist, $r_config, $include, $configfile) = @_; if ($CONFH eq 'none') { return; } my $dt=`date`; open (CCOFH, ">$CONFH"); print CCOFH <<"_HERE_"; /* Created on: ${dt} From: ${configfile} Using: mkconfig-${_MKCONFIG_VERSION} (perl) */ #ifndef MKC_INC_${CONFHTAGUC}_H #define MKC_INC_${CONFHTAGUC}_H 1 _HERE_ foreach my $val (@{$r_clist->{'vars'}}) { if ($val =~ m#^lib__lib_#o) { next; } my $tval = 0; if ($r_config->{$val} ne "0") { $tval = 1; } if ($val =~ m#^_setint_#o) { $tnm = $val; $tnm =~ s/^_setint_//; print CCOFH "#define $tnm " . $r_config->{$val} . "\n"; } elsif ($val =~ m#^(_setstr_|_opt_|_cmd_loc_)#o) { $tnm = $val; $tnm =~ s/^_setstr_//; $tnm =~ s/^_opt_//; print CCOFH "#define $tnm \"" . $r_config->{$val} . "\"\n"; } elsif ($val =~ m#^(_hdr|_sys|_command)#o) { print CCOFH "#define $val $tval\n"; } else { print CCOFH "#define $val " . $r_config->{$val} . "\n"; } } # standard tail -- always needed; non specific print CCOFH <<'_HERE_'; #ifndef MKC_STANDARD_DEFS # define MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* MKC_STANDARD_DEFS */ _HERE_ print CCOFH $include; print CCOFH <<"_HERE_"; #endif /* MKC_INC_${CONFHTAGUC}_H */ _HERE_ close CCOFH; } sub main_process { my ($configfile) = @_; my (%clist, %config); $clist{'clist'} = (); $clist{'chash'} = {}; $clist{'vars'} = (); $clist{'vhash'} = {}; $config{'reqlibs'} = {}; $config{'reqlibs_list'} = (); if (-f $CACHEFILE) { open (MKCC, "<$CACHEFILE"); while (my $line = ) { chomp $line; if ($line =~ m/^mkc_c_(.*)=\$?'?(.*)'?/o) { my $name = $1; my $val = $2; $config{$name} = $val; push @{$clist{'clist'}}, $name; $clist{'chash'}->{$name} = 1; } } close (MKCC); } my $tconfigfile = $configfile; if ($configfile !~ m#^/#) { $tconfigfile = "../$configfile"; } if (! open (DATAIN, "<$tconfigfile")) { print STDOUT "$configfile: $!\n"; exit 1; } my $linenumber = 0; my $inheaders = 1; my $ininclude = 0; my @doproclist; my $inproc = 0; my $doproc = 1; my $include = ''; my $tline = ''; my $ifstmtcount = 0; my $ifcurrlvl = 0; my $doif = $ifcurrlvl; while (my $line = ) { chomp $line; ++$linenumber; if ($ininclude == 0 && ($line =~ /^#/o || $line eq '')) { next; } if ($tline ne '') { $line = $tline . ' ' . $line; $tline = ''; } if ($line =~ /[^\\]\\$/o) { $tline = $line; $tline =~ s/\\$//o; next; } if ($ininclude == 1 && $line =~ m#^\s*endinclude$#o) { print LOGFH "end include\n"; $ininclude = 0; next; } elsif ($ininclude == 1) { $line =~ s,\\(.),$1,g; $include .= $line . "\n"; next; } if ($inheaders && $line !~ m#^\s*(hdr|sys)#o) { $inheaders = 0; } print LOGFH "#### ${linenumber}: ${line}\n"; if ($line =~ m#^\s*else#o) { if ($ifcurrlvl == $doif) { $doproc = $doproc == 0 ? 1 : 0; $iflevels =~ s/.\d+\s$//; $iflevels .= "-$ifstmtcount "; } } elsif ($line =~ m#^\s*if\s#o) { if ($doproc == 0) { $ifcurrlvl += 1; } } elsif ($line =~ m#^\s*endif#o) { if ($ifcurrlvl == $doif) { if ($#doproclist >= 0) { print LOGFH "## endif: doproclist: " . join (' ', @doproclist) . "\n"; $doproc = shift @doproclist; print LOGFH "## endif: doproclist now : " . join (' ', @doproclist) . "\n"; print LOGFH "## endif: doproc: $doproc\n"; $iflevels =~ s/.\d+\s$//; } else { $doproc = 1; $iflevels = ''; } $doif -= 1; } $ifcurrlvl -= 1; } if ($doproc == 1) { if ($line =~ m#^\s*output\s+([^\s]+)#o) { if ($inproc == 1) { savevars (\%clist); create_output (\%clist, \%config, $include, $configfile); $CONFH = 'none'; $CONFHTAG = 'none'; $CONFHTAGUC = 'NONE'; $include = ''; } print "output-file: $1\n"; my $tconfh = $1; if ($tconfh =~ m#^/#o) { $CONFH = $tconfh; } else { $CONFH = "../$tconfh"; } $CONFHTAG = $tconfh; $CONFHTAG =~ s,.*/,,; $CONFHTAG =~ s,\..*$,,; $CONFHTAGUC = uc $CONFHTAG; print LOGFH "config file: $CONFH\n"; $inproc = 1; $VARSFILE = "../mkc_${CONFHTAG}_c.vars"; $clist{'vars'} = (); $clist{'vhash'} = {}; } elsif ($line =~ m#^\s*option\-file\s+([^\s]+)#o) { print "option-file: $1\n"; my $tfile = $1; if ($tfile =~ m#^/#o) { $OPTIONFILE = $tfile; } else { $OPTIONFILE = "../$tfile"; } print LOGFH "options file: $OPTIONFILE\n"; } elsif ($line =~ m#^\s*standard#o) { check_standard (\%clist, \%config); } elsif ($line =~ m#^\s*loadunit#o) { ; } elsif ($line =~ m#^\s*args\s+(.*)$#o) { my $funcnm = $1; %args = ( 'noconst' => 'F' ); if ($funcnm =~ /^noconst */o) { $funcnm =~ s/^noconst *//o; $args{'noconst'} = 'T'; } my $nm = "_args_${funcnm}"; $nm =~ s,/,_,go; $nm =~ s,:,_,go; check_args ($nm, $funcnm, \%args, \%clist, \%config); } elsif ($line =~ m#^\s*include_conflict\s+([^\s]+)\s+([^\s]+)#o) { my $i1 = $1; my $i2 = $2; check_include_conflict ('_inc_conflict', $i1, $i2, \%clist, \%config); } elsif ($line =~ m#^\s*rquota_xdr$#o) { check_rquota_xdr ('_rquota_xdr', \%clist, \%config); } elsif ($line =~ m#^\s*gqa_uid_xdr$#o) { check_gqa_uid_xdr ('_gqa_uid_xdr', \%clist, \%config); } elsif ($line =~ m#^\s*include$#o) { print LOGFH "start include\n"; $ininclude = 1; } elsif ($line =~ m#^\s*(hdr|sys)\s+([^\s]+)\s*(.*)#o) { my $typ = $1; my $hdr = $2; my $reqhdr = $3; my $nm = "_${typ}_"; # create the standard header name for config.h $nm .= $hdr; $nm =~ s,/,_,go; $nm =~ s,\.h$,,o; $nm =~ s,:,_,go; if ($typ eq 'sys') { $hdr = 'sys/' . $hdr; } $reqhdr =~ s/^\s*//o; $reqhdr =~ s/\s*$//o; my @oh = split (/\s+/, $reqhdr); check_header ($nm, $hdr, \%clist, \%config, { 'reqhdr' => \@oh, }); } elsif ($line =~ m#^\s*const\s+([^\s]+)\s*(.*)#o) { my $tnm = $1; my $reqhdr = $2; my $nm = "_const_" . $tnm; $reqhdr =~ s/^\s*//o; $reqhdr =~ s/\s*$//o; my @oh = split (/\s+/, $reqhdr); check_constant ($nm, $tnm, \%clist, \%config, { 'reqhdr' => \@oh, }); } elsif ($line =~ m#^\s*command\s+(.*)#o) { my $cmds = $1; check_command ('', $cmds, \%clist, \%config); } elsif ($line =~ m#^\s*grep\s+(.*)#o) { check_grep ('', $1, \%clist, \%config); } elsif ($line =~ m#^\s*(if(not)?option)\s+([^\s]+)#o) { my $type = $1; my $opt = $3; my $nm = "_${type}_${opt}"; ++$ifstmtcount; my $rc = check_ifoption ($ifstmtcount, $type, $nm, $opt, \%clist, \%config); $iflevels .= "+$ifstmtcount "; unshift @doproclist, $doproc; $doproc = $rc; print LOGFH "## ifoption: doproclist: " . join (' ', @doproclist) . "\n"; print LOGFH "## ifoption: doproc: $doproc\n"; } elsif ($line =~ m#^\s*if\s+([^\s]+)\s+(.*)#o) { my $iflabel = $1; my $ifline = $2; ++$ifcurrlvl; ++$ifstmtcount; print LOGFH "## if: label: $iflabel count $ifstmtcount line: $ifline\n"; my $rc = check_if ($iflabel, $ifstmtcount, $ifline, \%clist, \%config); $iflevels .= "+$ifstmtcount "; unshift @doproclist, $doproc; $doproc = $rc; $doif = $ifcurrlvl; print LOGFH "## if: doproclist: " . join (' ', @doproclist) . "\n"; print LOGFH "## if: doproc: $doproc\n"; } elsif ($line =~ m#^\s*(endif|else)#o) { ; } elsif ($line =~ m#^\s*echo\s+(.*)$#o) { print $1; } elsif ($line =~ m#^\s*exit$#o) { print $1; } elsif ($line =~ m#^\s*(set(int|str)?)\s+([^\s]+)\s*(.*)#o) { my $type = $1; my $nm = $3; if ($type eq 'setint' || $type eq 'setstr') { $nm = "_${type}_$3"; } my $val = $4; check_set ($nm, $type, $val, \%clist, \%config); } elsif ($line =~ m#^\s*option\s+([^\s]+)\s*(.*)#o) { my $nm = "_opt_$1"; my $onm = $1; my $def = $2; check_option ($nm, $onm, $def, \%clist, \%config); } elsif ($line =~ m#^\s*npt\s+([^\s]*)\s*(.*)#o) { my $func = $1; my $req = $2; my $nm = "_npt_" . $func; check_npt ($nm, $func, $req, \%clist, \%config); } elsif ($line =~ m#^\s*key\s+(.*)#o) { my $tnm = $1; my $nm = "_key_" . $tnm; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_keyword ($nm, $tnm, \%clist, \%config); } } elsif ($line =~ m#^\s*class\s+([^\s]+)\s*(.*)?#o) { my $class = $1; my $libs = $2 || ''; my $nm = "_class_" . $class; $nm =~ s,:,_,go; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_class ($nm, $class, \%clist, \%config, { 'otherlibs' => $libs, }); } } elsif ($line =~ m#^\s*typ\s+(.*)#o) { my $tnm = $1; my $nm = "_typ_" . $tnm; $nm =~ s, ,_,go; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_type ($nm, $tnm, \%clist, \%config); } } elsif ($line =~ m#^\s*define\s+(.*)#o) { my $tnm = $1; my $nm = "_define_" . $tnm; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_defined ($nm, $tnm, \%clist, \%config); } } elsif ($line =~ m#^\s*lib\s+([^\s]+)\s*(.*)?#o) { my $func = $1; my $libs = $2 || ''; my $nm = "_lib_" . $func; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_lib ($nm, $func, \%clist, \%config, { 'otherlibs' => $libs, }); } } elsif ($line =~ m#^\s*dcl\s+([^\s]*)\s+(.*)#o) { my $type = $1; my $var = $2; my $nm = "_dcl_" . $var; if (! defined ($config{$nm}) || $config{$nm} eq '0') { if ($type eq 'int') { check_int_declare ($nm, $var, \%clist, \%config); } elsif ($type eq 'ptr') { check_ptr_declare ($nm, $var, \%clist, \%config); } } } elsif ($line =~ m#^\s*printf_long_double#o) { check_printf_long_double ('_printf_long_double', \%clist, \%config); } elsif ($line =~ m#^\s*member\s+(.*)\s+([^\s]+)#o) { my $struct = $1; my $member = $2; my $nm = "_mem_" . $struct . '_' . $member; $nm =~ s/ /_/go; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_member ($nm, $struct, $member, \%clist, \%config); } } elsif ($line =~ m#^\s*memberxdr\s+(.*)\s+([^\s]+)#o) { my $struct = $1; my $member = $2; my $nm = "_memberxdr_" . $struct . '_' . $member; $nm =~ s/ /_/go; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_memberxdr ($nm, $struct, $member, \%clist, \%config); } } elsif ($line =~ m#^\s*size\s+(.*)#o) { my $typ = $1; $typ =~ s/\s*$//o; my $nm = "_siz_" . $typ; $nm =~ s, ,_,go; if (! defined ($config{$nm}) || $config{$nm} eq '0') { check_size ($nm, $typ, \%clist, \%config); } } else { print LOGFH "unknown command: $line\n"; print STDOUT "unknown command: $line\n"; } } } savevars (\%clist); savecache (\%clist, \%config); create_output (\%clist, \%config, $include, $configfile); # This is here for os/2 and other systems w/no usable bourne shell. # it is not up to date, as it will output libraries that are not # needed by the final configuration. open (RLIBFH, ">$REQLIB"); my $r_list = $config{'reqlibs_list'}; print RLIBFH join (' ', @{$r_list}) . "\n"; close RLIBFH; } sub usage { print STDOUT "Usage: $0 [-c ] [-L ]\n"; print STDOUT " [-o ] [-C] \n"; print STDOUT " -C : clear cache-file\n"; print STDOUT "defaults:\n"; print STDOUT " : mkconfig.cache\n"; print STDOUT " : mkconfig.log\n"; print STDOUT " : options.dat\n"; } # main my $clearcache = 0; while ($#ARGV > 0) { if ($ARGV[0] eq "-C") { shift @ARGV; $clearcache = 1; } if ($ARGV[0] eq "-c") { shift @ARGV; $CACHEFILE = $ARGV[0]; shift @ARGV; } if ($ARGV[0] eq "-L") { shift @ARGV; $LOG = $ARGV[0]; shift @ARGV; } if ($ARGV[0] eq "-o") { shift @ARGV; $OPTIONFILE = $ARGV[0]; shift @ARGV; } } my $configfile = $ARGV[0]; if (! defined ($configfile) || ! -f $configfile) { usage; exit 1; } if (-d $_MKCONFIG_TMP && $_MKCONFIG_TMP ne "_tmp_mkconfig") { usage; exit 1; } $LOG = "../$LOG"; $REQLIB = "../$REQLIB"; $CACHEFILE = "../$CACHEFILE"; $VARSFILE = "../$VARSFILE"; $OPTIONFILE = "../$OPTIONFILE"; delete $ENV{'CDPATH'}; delete $ENV{'GREP_OPTIONS'}; delete $ENV{'ENV'}; $ENV{'LC_ALL'} = "C"; my $tpath = $0; $tpath =~ s,/[^/]*$,,; my $currdir =`pwd`; chomp $currdir; if (! chdir $tpath) { die ("Unable to cd to $tpath. $!\n"); } $_MKCONFIG_VERSION=`cat $tpath/VERSION`; chomp $_MKCONFIG_VERSION; $_MKCONFIG_DIR = `pwd`; chomp $_MKCONFIG_DIR; if (! chdir $currdir) { die ("Unable to cd to $currdir. $!\n"); } if (-d $_MKCONFIG_TMP) { system ("rm -rf $_MKCONFIG_TMP"); } mkdir $_MKCONFIG_TMP, 0777; chdir $_MKCONFIG_TMP; if ($clearcache) { unlink $CACHEFILE; unlink $VARSFILE; } print STDOUT "$0 using $configfile\n"; unlink $LOG; open (LOGFH, ">>$LOG"); $ENV{'CFLAGS'} = $ENV{'CFLAGS'}; foreach my $nm ('CC', 'CFLAGS_OPTIMIZE', 'CFLAGS_DEBUG', 'CFLAGS_INCLUDE', 'CFLAGS_USER', 'CFLAGS_APPLICATION', 'CFLAGS_COMPILER', 'CFLAGS_SYSTEM', 'CFLAGS_SHARED', 'CFLAGS_SHARED_USER', 'LDFLAGS_OPTIMIZE', 'LDFLAGS_DEBUG', 'LDFLAGS_USER', 'LDFLAGS_APPLICATION', 'LDFLAGS_COMPILER', 'LDFLAGS_SYSTEM', 'LDFLAGS_SHARED', 'LDFLAGS_LIBS_USER', 'LDFLAGS_LIBS_APPLICATION', 'LDFLAGS_LIBS_SYSTEM') { print LOGFH "$nm: $ENV{$nm}\n"; } print LOGFH "awk: $awkcmd\n"; main_process $configfile; close LOGFH; chdir ".."; if ($ENV{'MKC_KEEP_TMP'} eq "") { if (-d $_MKCONFIG_TMP) { system ("rm -rf $_MKCONFIG_TMP"); } } exit 0; di-4.47/mkconfig/README0000644000175000017500000003444613334050206012634 0ustar bllbllmkconfig - configuration tool (version 2.0.0) Website: https://gentoo.com/di/mkconfig.html SourceForge: https://sourceforge.net/projects/mkconfig/ mkconfig is a build configuration utility. It creates an output file intended to be included as a header file, run as a shell script, used as a configuration file, or any other use. mkconfig is written in portable shell script and designed to be extensible for any configuration use. It also includes tools that can be used to compile, link and build libraries and executables using the shell configuration previously built. An example of mkconfig in use can be seen in the 'di' program at https://sourceforge.net/projects/di/ TESTING Version 2.0.0 has been tested on: Linux RedHat 7.3 (gcc) (ash, bash2, sh/bash2) CentOS 3.9 (gcc) (ash, bash2, pdksh, sh/bash2) Fedora 7 (gcc) (bash3, sh/bash3) Fedora 27 (gcc) (bash4, sh/bash4) MX Linux 17.1 (gcc, clang) (bash4, dash, ksh93, mksh) BSD DragonflyBSD 4.4 (gcc) (bash4, dash, pdksh, ksh93, mksh) FreeBSD 7.0 (cc) (sh) FreeBSD 11.0 (clang) (sh, bash4, dash, pdksh, ksh93, mksh) NetBSD 1.62 (cc) (pdksh, sh) NetBSD 2.0 (cc) (pdksh, sh) NetBSD 7.0.1 (gcc) (pdksh, sh, bash4, mksh) OpenBSD 4.4 (gcc) (pdksh, sh) Windows Msys2 (gcc, clang) (ash, bash4, dash, sh/bash4) Cygwin (gcc) (ash, bash4, dash, mksh, sh/bash4) Other AIX 7.1 (gcc) (bash4, ksh, ksh93, sh) Mac OS X 10.12.6 (clang) (bash3, ksh93, sh/bash3) QNX 6.5 (cc) (pdksh, bash4, sh/pdksh) SCO SV 6.0.0 (cc) (sh, ksh, ksh93, bash3, bash2) Solaris 11/x86 (cc12.3) (bash4, ksh93, sh/ksh93) Solaris 10/sparc (cc12.3) (bash4, sh(1), sh, bash3, ksh) Solaris 9/x86 (gcc3) (bash4, ksh93, sh(1), bash2, sh) Tru64 5.1b (cc) (sh, ksh, bash2) UnixWare 7.1.4 (cc) (sh, ksh93, ksh88, bash2) (1) not a standard solaris shell ISSUES - D Compiler bugs: ldc2 has structure size problems on 64bit (issue #28). gdc 4.6.3 (LinuxMint) has structure size problems on 64bit. - The D language portions have not been tested or used in a long time. CHANGES 2.0.0 [2018-8-12] C: split CFLAGS, LDFLAGS, LIBS into multiple environment variables for easier processing. D language is probably broken. C: fix shared flags C: Various bug fixes for msys2, tru64, etc. Clean up interfaces to mkcl.sh, mkstaticlib.sh Clean output style for mkc.sh. Added compilation log file. Added 'findconfig' and 'addconfig' commands for *Config.sh files. Removed 'findincludefile' command. Remove mksharedlib.sh (now part of mkcl.sh). 1.31 [2018-4-11] env-cc: update findincludepath to search more common paths. Remove Makefile and MANIFEST from standard distribution. 1.30 [2018-4-10] Repo got completely mucked up. Restore lost code. C: size: -lintl option for modern libintl.h C: printf_long_double : -lintl option for modern libintl.h Minor code cleanup. Update copyrights. 1.29 [2018-4-6] Changed .tar.gz creation to not include tests. 1.28 [2016-8-9] Cleaned up some compiler warnings. More fixes for msys/mingw. 1.27 [2016-2-22] Protected standard definitions from multiple inclusion. Fixed ifoption/ifnotoption. Removed 'lib' prefix when creating libraries. Removed LDFLAGS when creating shared libraries. Fixes to run under msys. Added printf_long_double test (for mingw). Fix cache bug with values ending in '='. Fixed args test on mac os x. Fixed args test for cygwin. 1.26 [2016-1-6] Added yes/no as possible option values. Options can be overridden by environment variables. 1.25 [2015-10-18] Fix 'using_gnu_ld' environment test. Add 'addldflag' to env-cc. 1.24 [2014-2-15] Updates for MirOS and Irix. Added -Wno-disabled-macro-expansion for clang. 1.23 [19 Jan 2013] Added the 'using_clang' environment directive. Added default flags for the clang compiler. 1.22 [15 Nov 2012] Fixed the display of the define directive. Fixed issues where the cache should not be used for XDR types and library function arguments. Fixed processing of nested if statements. 1.21 [18 Oct 2012] Added examples directory. clang: add -Wno-unknown-warning-option addcflag directive updated to not add the flag if the compiler has a warning. Fixed read problems with ksh93 93u+. Added a work-around for cd problem w/debian ksh93 93u+ (bug #679966). Handle __restrict__ on NetBSD 6. Remove improper link flags for AIX. Not tested. 1.20 [25 Jan 2012] D: rewrite c-typedef extraction. D: handle situations where structure is typedef'd and a ctypedef directive is issued. D: several fixes for C structure extraction. D: improved nested structure handling. D: basic handling for bitfields in structures. D: changed prefix from C_TYP_ to C_NATIVE_ for native c types. D: Added the noprefix directive to not add C_ST_, C_TYP_, etc. prefixes to the original C language types (but not C_NATIVE_). D: Casts are converted. May still be some issues. env: Added the source directive. D: fixed macro extraction with partial name. D: convert the version keyword to version_ D: handle multi-line statements better. D: added the module directive. D: added the substitute directive. Minor speed improvements for header extraction. D: fixed multiple output files. mkc.sh: -comp: fixed to add -c flag when compiling to object w/-o flag. mkc.sh: merge -link and -comp. D: fixed some D1 conversion issues. Fixed if statements with unknown variables. D: wrap ctypes in extern D: fixed type conversions (followed by asterisk, lone unsigned) 1.19 [20 Nov 2011] Created mkc.sh as a single entry point for compiling, linking, creating libraries, setting options and finding required libraries. Solaris 2.6 /bin/sh is no longer excluded. Fixed problem with .vars file not being cleaned on remake. D: Rework c-structure extraction. D: Better handling of nested structures and typedef'd structures. D: Add aliases for c argument types. D: revert cache check where it shouldn't be cached. D: Add aliases for c basic types (csizes directive). Fixed mkreqlib.sh to handle clibs for D. Fixed c-declaration test for freebsd. Change support for tango library and Dv1. Changed env-dc to compile to get D version. Changed env-cc and env-dc to pick up standard env variables from the options file. This allows the options file to keep all configuration data. Rearranged directory structure. 1.18 [8 Oct 2011] D: C structures are wrapped in extern (C) {} (to properly declare functions). Fixed multiple output files in the same directory. Fixed multiple inclusion tag for C output file. Fixed and updated shell locater for runtests.sh. Removed -std1 for OSF1 (Tru64). Added 'ksh88', 'ksh93' as valid shell names. 1.17 [30 Sep 2011] Fixed cmacro directive for D. Added cmembertype, cmemberxdr for D. Added memberxdr for C. Removed rquota_xdr, gqa_uid_xdr. Improved documentation. Rewrote test suite. Fixed 'lib' for D. Updated env-cc.sh for SCO OpenServer and UnixWare. Fixed structure extraction for HP-UX. Various fixes for HP-UX, SCO OpenServer, UnixWare. * Shared lib tests fail for HP-UX ansi cc. 1.16 [16 Sep 2011] Removed 'di' leftovers. Changed internal prefix to 'mkc'. Added 'echo' and 'exit' directives. Fixed d language tests to be 32/64 bit safe. Fixed d language tests for d version 1. Fixed d language tests for tango library. Added initial support for ldc and tango libraries. * On 64-bit, ldc's unions don't match C language sizes. * ldc1 doesn't have alias for 'string'. * ldc2 tested w/-d flag. Tested with dmd1, dmd2, ldc1, ldc2 on 64-bit. Tested with dmd1, dmd2, ldc1, ldc2, gdc1, gdc2 on 32-bit. 1.15 [11 Sep 2011] Added pdksh in as a valid shell Added 'args' directive (C) Removed statfs, setmntent, quotactl, getfsstat_type (breaks backwards compatibility) Added 'addcflags' directive (env) Fixed args directive to return valid types (C) Fixed cdcl directive to return valid types (D) Updated args directive to save return type (C) Updated cdcl directive to save return type (D) Fixed shell validity tests. 1.14 [22 May 2011] Renamed ctypeconv to ctype (breaks backwards compatibility). Rewrite ctype check command to use the C typedef name, and add an alias. Fixed ctype to handle unsigned typedefs correctly. Fixed nested structure handling. ctypedef will now find function pointer typedefs. Made D-C prefixes more consistent (breaks backwards compatibility). Added cmacro to convert C macros to functions. Merged cdefint and cdefstr to cdefine; made more generic (breaks backwards compatibility). Added breakdown of arg types for "cdcl args ...". 1.13 [27 Feb 2011] Handle gcc __asm__ function renames. Update doc for cdcl. 1.12 [16 Feb 2011] Added d-ctypeconv check command. Renamed d-ctype to d-ctypedef. Updated to work with D1. More fixes for D, D-C checks. 1.11 [29 Dec 2010] Fixed output of "yes with" libraries. Rearranged tests and test directories. Fixed test subdirectory handling. Added c-rquota, c-getfsstat. Added unset CDPATH. The output from the cd command broke the scripts. Added D language (not yet complete). Backwards compatibility broken for mklink.sh. 1.10 [22 Jul 2010] Renamed reqlibs.txt to mkconfig.reqlibs. Breaks backwards compatibility. Added support for multiple output files. Fixed naming of runtest log files. Added mkstaticlib.sh. Added mksharedlib.sh: preliminary support for shared libs. Added mklink.sh: preliminary Added new env-cc vars to support shared libs. Added new env-extension vars to support shared libs. Bug fix: workaround for ksh93 unable to getcwd() on Solaris. Fixed env-extension to match manual page. 1.9 [12 Jul 2010] Fixed regression tests to work w/c++. Code cleanup. 1.8 [10 Jul 2010] Internal code cleanup. Modify tests to take -d parameter for description output. Stop tests on change of pass number on failure. Add check_option. Fixed member test so either structs or typedefs can be used. Changed member test names to be _mem_struct_s_member or _mem_sometype_member. Breaks backwards compatibility. 1.7 [5 Jul 2010] Add labels to if statement. if statement counter and display. 1.6 [4 Jul 2010] Fix getlistofshells() when absolute path. Added c-quotactl unit. Renamed c-include-time to c-include-conflict, and changed how c-include-conflict works. Added define, set, setint, setstr, ifoption, ifnotoption, if. Added option-file. Added mkcsetopt.sh 1.5 [13 May 2010 - separate release] Change tmp directory structure and where logs go. Fixes for mkconfig.pl to handle absolute paths. Remove /bin from path for cygwin (duplicate of /usr/bin). Code cleanup. 1.4 (di ver 4.23) [10 May 2010] Move -lsun, -lseq out of env-cc.sh Update env-cc.sh to handle QNX getconf 'undefined' output. Fix cache test (tests.d/cache.sh). Fix edit when /bin is symlink (shellfuncs.sh). Added test for -n support for shells. Added support to mkconfig.sh to munge set output that has $s in it. Export shelllist in runtests.sh; more efficient. Redo paths in shellfuncs; make sure symlinked paths are present. Needed for Tru64, do: export BIN_SH=svr4 beforehand. 1.3 (di ver 4.22) [1 may 2010] Use the configuration file and cache to determine the necessary libraries to link in rather than linking in all found. Change library format to allow better control of link tests. Change dosubst() to always use sed. It's more reliable. 1.2 (di ver 4.20, 4.21) [12 mar 2010] Rewrite mkconfig.sh to use unit scripts and increase performance. Add environment units. Allow _MKCONFIG_SHELL to override shell. 1.1 (di ver 4.19) [1 Feb 2010] Changed format of config.h file. Fixed a quoting bug in mkconfig.sh. mkconfig enhancements and cleanup. 1.0 (di ver 4.18) [29 Nov 2009] Initial coding di-4.47/mkconfig/util/0000755000175000017500000000000013334050206012716 5ustar bllblldi-4.47/mkconfig/util/mkcexttypedef.awk0000755000175000017500000000232313334050206016301 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2018 Brad Lanam Walnut Creek CA BEGIN { tdstart = "[ ]*typedef"; funcpat = "[ (*]" ARGV[2] "[ )]"; semipat = "[ *]" ARGV[2] "[ ]*;$"; delete ARGV[2]; intypedef = 0; acount = 0; docheck = 0; tarr = ""; lineno = 0; #print "tdstart:" tdstart ":"; #print "funcpat:" funcpat ":"; #print "semipat:" semipat ":"; } { lineno = lineno + 1; #print lineno ": " $0; if ($0 ~ /^#/) { next; } else if (intypedef == 0 && $0 ~ tdstart) { #print "start:"; intypedef = 1; acount = 0; sarr[acount] = $0; acount = acount + 1; tarr = tarr $0; if ($0 ~ /;$/) { #print "have semi"; docheck = 1; } } else if (intypedef == 1) { #print "in:"; sarr[acount] = $0; acount = acount + 1; tarr = tarr $0; if ($0 ~ /;$/) { #print "have semi"; docheck = 1; } } if (docheck == 1) { #print "docheck: tarr:" tarr ":"; if (tarr ~ funcpat || tarr ~ semipat) { #print "docheck: match"; doend = 1; } } if (doend == 1) { for (i = 0; i < acount; ++i) { print sarr[i]; } exit; } if (docheck == 1) { #print "docheck: no match"; acount = 0; tarr = ""; docheck = 0; intypedef = 0; } } di-4.47/mkconfig/util/mkcextdcl.awk0000755000175000017500000000325313334050206015406 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2018 Brad Lanam Walnut Creek CA BEGIN { dclstart = "[ *]" ARGV[2] "[ ]*\\("; delete ARGV[2]; bcount = 0; acount = 0; ins = 0; havestart = 0; doend = 0; sarr[0] = ""; #print "dclstart:" dclstart; } { #print "havestart:" havestart " ins:" ins " bcount:" bcount " acount:" acount; if ($0 ~ /^#/) { next; } else if (ins == 0 && $0 ~ dclstart) { #print "start: " $0; ins = 1; acount = 0; sarr[acount] = $0; acount = acount + 1; havestart = 1; tstr = $0; gsub (/[^\(]/, "", tstr); bcount = bcount + length (tstr); #print "start: " length(tstr) " ("; tstr = $0; gsub (/[^\)]/, "", tstr); bcount = bcount - length (tstr); #print "start: " length(tstr) " )"; if (bcount <= 0 && length (tstr) > 0) { doend = 1; } } else if (ins == 1 && $0 ~ /\(/) { #print "(: " $0; sarr[acount] = $0; acount = acount + 1; tstr = $0; gsub (/[^\(]/, "", tstr); bcount = bcount + length (tstr); #print "(: " length(tstr) " ("; tstr = $0; gsub (/[^\(]/, "", tstr); bcount = bcount - length (tstr); #print "(: " length(tstr) " )"; if (bcount <= 0) { ins = 0; } } else if (ins == 1 && $0 ~ /\)/) { #print "): " $0; sarr[acount] = $0; acount = acount + 1; tstr = $0; gsub (/[^\)]/, "", tstr); bcount = bcount - length (tstr); #print "): " length(tstr) " )"; if (bcount <= 0) { if (havestart == 1) { doend = 1; } ins = 0; } } else if (ins == 1) { #print "1: " $0; sarr[acount] = $0; acount = acount + 1; } if (doend == 1) { for (i = 0; i < acount; ++i) { print sarr[i]; } exit; } } di-4.47/mkconfig/util/mkcextstruct.awk0000755000175000017500000001732413334050206016174 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2018 Brad Lanam Walnut Creek CA BEGIN { if (dcode != "T") { dcode = "F"; } ststructA = "(struct|class|union|enum)[ ]*"; ststruct1 = "(struct|class|union|enum)[ ]*\\{"; ststruct2 = "typedef[ ][ ]*(struct|class|union|enum)[ ]*[a-zA-Z0-9_]*[ ]*{?[ ]*$"; ststart1 = "(struct|class|union|enum)[ ]*" ARGV[2] "$"; ststart2 = "(struct|class|union|enum)[ ]*" ARGV[2] "[^a-zA-Z0-9_]"; stforward = "(struct|class|union|enum)[ ]*" ARGV[2] "[ ]*;"; stother = "(struct|class|union|enum)[ ]*" ARGV[2] "[ ][ ]*[*a-zA-Z0-9_]"; stend = "[ *]" ARGV[2] "_t[ ]*;"; stendb = "[ *]" ARGV[2] "[ ]*;"; delete ARGV[2]; bcount = 0; acount = 0; ins = 0; inend = 0; havestart = 0; doend = 0; hadend = 0; sarr[0] = ""; nsarr[0] = ""; savens = ""; lineno = 0; #print "dcode:" dcode; #print "ststruct1:" ststruct1; #print "ststruct2:" ststruct2; #print "ststart1:" ststart1; #print "ststart2:" ststart2; #print "stforward:" stforward; #print "stother:" stother; #print "stend:" stend; #print "stendb:" stendb; } { lineno = lineno + 1; #print lineno ": " $0; #if ($0 ~ ststruct1) { print " " lineno ": matches ststruct1"; } #if ($0 ~ ststruct2) { print " " lineno ": matches ststruct2"; } #if ($0 ~ ststart1) { print " " lineno ": matches ststart"; } #if ($0 ~ ststart2) { print " " lineno ": matches ststart"; } #if ($0 ~ stforward) { print " " lineno ": matches stforward"; } #if ($0 ~ stother) { print " " lineno ": matches stother: " $0; } #if ($0 ~ stend) { print " " lineno ": matches stend: " $0; } #if ($0 ~ stendb) { print " " lineno ": matches stendb: " $0; } #print "havestart:" havestart ":ins:" ins ":bcount:" bcount ":hadend:" hadend ":"; if ($0 ~ /^#/) { next; } else if (ins == 0 && ($0 ~ ststart1 || $0 ~ ststart2) && $0 !~ stforward && $0 !~ stother) { #print lineno ": start: "; hadend = 0; savens = ""; for (val in nsarr) { delete nsarr[val]; } nsarr[0] = ""; acount = 0; ins = 1; gsub (/[ ]*$/, "", $0); sarr[acount] = $0; acount = acount + 1; havestart = 1; tstr = $0; gsub (/[^\{]/, "", tstr); bcount = bcount + length (tstr); tstr = $0; gsub (/[^}]/, "", tstr); bcount = bcount - length (tstr); if (bcount <= 0 && length (tstr) > 0) { doend = 1; } } else if (havestart == 0 && bcount == 0 && ($0 ~ ststruct1 || $0 ~ ststruct2) && $0 !~ stforward && $0 !~ stother) { #print lineno ": struct: "; hadend = 0; savens = ""; for (val in nsarr) { delete nsarr[val]; } nsarr[0] = ""; acount = 0; ins = 1; tstr = $0; gsub (/[^\{]/, "", tstr); bcount = bcount + length (tstr); tstr = $0; gsub (/[^}]/, "", tstr); bcount = bcount - length (tstr); if (bcount <= 0 && length(tstr) > 0) { ins = 0; bcount = 0; savens = ""; for (val in nsarr) { delete nsarr[val]; } nsarr[0] = ""; } if ($0 ~ stend || $0 ~ stendb) { #print lineno ": matches endA: doend"; doend = 1; } acount = 0; gsub (/[ ]*$/, "", $0); sarr[acount] = $0; acount = acount + 1; } else if (hadend == 1 && acount > 0 && bcount == 0 && havestart == 0 && ($0 ~ stend || $0 ~ stendb)) { #print lineno ": endB: "; hadend = 0; gsub (/[ ]*$/, "", $0); sarr[acount] = $0; acount = acount + 1; doend = 1; } else if (ins == 1 && $0 !~ /(struct|class|union|enum)[ ]*\{/ && $0 ~ /(const *)?(struct|class|union|enum)[ ]*[a-zA-Z_][a-zA-Z0-9_]*[ \{]*$/ && $0 !~ /(const *)?(struct|class|union|enum)[ ].*;/) { # nested structure, not an unnamed structure # is named, but not followed by anything else #print lineno ": nested struct: "; hadend = 0; savens = ""; gsub (/[ ]*$/, "", $0); tstr = $0; if (dcode) { if ($0 ~ /struct/) { ttype = "struct"; tlab = "C_ST_"; #print lineno ": found struct" } if ($0 ~ /class/) { ttype = "class"; tlab = "C_CLASS_"; #print lineno ": found class" } if ($0 ~ /union/) { ttype = "union"; tlab = "C_UN_"; #print lineno ": found union" } if ($0 ~ /enum/) { ttype = "enum"; tlab = "C_ENUM_"; #print lineno ": found enum" } sub (/(struct|class|union|enum)[ ]*/, "&" tlab, tstr); #print lineno ": nested(A): " tstr } sarr [acount] = tstr; acount = acount + 1; tstr = $0; gsub (/[^\{]/, "", tstr); bcount = bcount + length (tstr); tstr = $0; gsub (/[^}]/, "", tstr); bcount = bcount - length (tstr); if (bcount <= 0 && length(tstr) > 0) { ins = 0; } if (ins == 1) { tstr = $0; #print lineno ": nested(B): ", $0 if (dcode) { sub (/[ const]*(struct|class|union|enum)[ ]*/, "", tstr); sub (/[ ].*/, "", tstr); } #print lineno ": nested(C): ", tstr; savens = tstr; if (bcount > 1) { nsarr[bcount] = tstr; savens = ""; #print lineno ": nested save: " tstr; } } } else if (ins == 1 && $0 ~ /\{/) { #print lineno ": {: "; hadend = 0; sarr[acount] = $0; acount = acount + 1; tstr = $0; gsub (/[^\{]/, "", tstr); bcount = bcount + length (tstr); tstr = $0; gsub (/[^}]/, "", tstr); bcount = bcount - length (tstr); if (bcount <= 0 && length(tstr) > 0) { ins = 0; } if (ins == 1 && bcount > 1 && savens != "") { #print lineno ": nested last: ", savens; if (bcount > 1) { nsarr[bcount] = savens; #print lineno ": nested save: " savens; } savens = ""; } } else if (ins == 1 && $0 ~ /}/) { #print lineno ": }: "; gsub (/[ ]*$/, "", $0); sarr[acount] = $0; acount = acount + 1; tstr = $0; gsub (/[^}]/, "", tstr); l = length(tstr); bcount = bcount - l; stendtestb = "}[ *][a-zA-Z0-9_]*[ ]*;"; if (l > 0 && $0 !~ stendtestb) { #print lineno ": }: hadend: =1: "; hadend = 1; } else { #print lineno ": }: hadend: =0: "; hadend = 0; } if (bcount <= 0) { #print lineno ": }: bcount: 0"; bcount = 0; if (havestart == 1) { #print lineno ": }: havestart: doend"; doend = 1; } if ($0 ~ stend || $0 ~ stendb) { #print lineno ": matches endC: doend"; doend = 1; } ins = 0; } else if (l > 0 && $0 !~ /}[ ;]*$/) { #print lineno ": end struct dcl: " $0; if (dcode) { tstr = $0; # if there's a declaration of a pointer to the nested structure # we'll be adding the declaration. # if so, remove the name now. # otherwise, keep the name for processing by d-main.sh if (nsarr[bcount + 1] != "") { sub (/}.*/, "};", tstr); sarr [acount - 1] = tstr; } #print lineno ": nsarr1: " nsarr[bcount + 1]; if (nsarr[bcount + 1] != "") { tstr = $0; sub (/}[ ]*/, tlab nsarr[bcount + 1] " ", tstr); sarr [acount] = tstr; acount = acount + 1; } } hadend = 0; } } else if (ins == 1) { #print lineno ": 1: " $0; #print lineno ": 1: hadend:" hadend; if (hadend == 1 && nsarr[bcount + 1] != "") { if ($0 ~ /[ *]*[_A-Za-z]/) { #print lineno ": 1: hadend: match" tstr = $0; if (dcode) { tstr = " " tlab nsarr[bcount + 1] " " $0; } sarr[acount] = tstr; acount = acount + 1; } else { gsub (/[ ]*$/, "", $0); sarr[acount] = $0; acount = acount + 1; } } else { gsub (/[ ]*$/, "", $0); sarr[acount] = $0; acount = acount + 1; } hadend = 0; } else if (ins == 0) { if ($0 ~ ststructA) { hadend = 0; } } if (doend == 1) { for (i = 0; i < acount; ++i) { print sarr[i]; } exit; } } di-4.47/mkconfig/util/mkcextmacro.awk0000755000175000017500000000702313334050206015744 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2018 Brad Lanam Walnut Creek CA BEGIN { macrostart = "^#[ ]*define[ ]*" ARGV[2] "[ (]" delete ARGV[2]; ins = 0; doend = 0; #print "macrostart:" macrostart; cf = ENVIRON["CFLAGS"]; #print "cf:" cf ":"; split (cf,cfa); for (cfi in cfa) { #print "cfi:" cfi ":cfa[cfi]:" cfa[cfi]; if (cfa[cfi] ~ /^-D/) { gsub (/-D/,"",cfa[cfi]); if (match (cfa[cfi], "=")) { split (cfa[cfi], cfaa, /=/); tcfv = cfaa[1]; if (cfaa[2] > 0) { #print "cflags:" tcfv ":"; cflags[tcfv] = 1; } } else { #print "cflags:" cfa[cfi] ":"; cflags[cfa[cfi]] = 1; } } } exclude = 0; } { #print NR ": " $0; # remove comments gsub (/\/\/.*$/, ""); gsub (/\/\*.*\*\//, ""); gsub (/[ ]*$/, ""); if ($0 ~ /^# *ifndef/) { gsub (/^# *ifndef/, "#if !"); } if ($0 ~ /^# *ifdef/) { gsub (/^# *ifdef/, "#if "); } # this is very simplistic. # there is no precedence and no handling of parentheses if ($0 ~ /^# *if/) { #print "if:"; l = $0; gsub (/^# *if[a-z]*/, "", l); gsub (/defined *\(/, "", l); gsub (/\)/, "", l); gsub (/!/, " NOT ", l); gsub (/\&\&/, " AND ", l); gsub (/\|\|/, " OR ", l); gsub (/^ */, "", l); #print "if:l:" l; l = l " END"; split (l, la); ecount = 0; for (val in ea) { delete ea[val]; } rval = 0; dopop = 0; for (li = 1; la[li] != "END"; ++li) { #print "if:token:" li ":" la[li]; if (la[li] == "END") { continue; } else if (la[li] == "AND" || la[li] == "OR") { ea[ecount++] = rval; ea[ecount++] = la[li]; continue; } else if (la[li] == "NOT") { ea[ecount++] = la[li]; continue; } else { val = 0; if (la[li] ~ /^[0-9]+$/) { val = la[li]; } else if (la[li] in cflags) { #print "ifB':la[li]:" la[li] ":cflags[la[li]]:" cflags[la[li]] ":"; val = 1; } #print "ifB:val:" val; if (ecount > 0) { --ecount; if (ea[ecount] == "AND") { rval = ea[ecount - 1] && val; --ecount; } if (ea[ecount] == "OR") { rval = ea[ecount - 1] || val; --ecount; } if (ea[ecount] == "NOT") { rval = 1 - val; } } else { rval = val; } #print "ifA:rval:" rval; } dopop = 0; } #print "ifEND:rval:" rval; if (rval == 0) { exclude = 1; } } if ($0 ~ /^# *else/) { #print "else:"; exclude = 1 - exclude; } if ($0 ~ /^# *endif/) { #print "endif:"; exclude = 0; } if (exclude == 1) { #print "excluding"; next; } if ($0 ~ /^# *define/ && (NF == 3 || NF == 4)) { l = $0; gsub (/^# *define */, "", l); #print "check define:" l ":"; split (l, la); if (la[2] ~ /^[0-9]+$/) { #print "define:" la[1] ":" la[2]; if (la[2] > 0) { cflags[la[1]] = 1; } if (la[1] in cflags) { cflags[la[1]] = 1; } } } #print "main:" $0; if (ins == 0 && $0 ~ macrostart) { #print "start: " $0; ins = 1; macro = $0; #print "macroA:" macro; doend = 1; if ($0 ~ /\\$/) { doend = 0; gsub (/[ ]*\\$/, " ", macro); #print "macroB:" macro; #print "not end: "; } } else if (ins == 1) { #print "cont: " $0; macro = macro $0; #print "macroC:" macro; doend = 1; if ($0 ~ /\\$/) { doend = 0; gsub (/[ ]*\\$/, " ", macro); #print "macroD:" macro; #print "not end: "; } } else if (ins == 1) { #print "ins = 1; end "; doend = 1; } if (doend == 1) { print macro; exit; } } di-4.47/mkconfig/man/0000755000175000017500000000000013334050206012514 5ustar bllblldi-4.47/mkconfig/man/mkconfig_env.70000644000175000017500000001602713334050206015257 0ustar bllbll.\" .\" mkconfig_env.7 .\" .\" Copyright 2011-2018 Brad Lanam Walnut Creek CA USA .\" .\" brad.lanam.di_at_gmail.com .\" .\" .\" Notes on terminology: .\" check variable - the variable name for the check. .\" directive - a command from the mkconfig config file. .\" mkconfig config file - file where mkconfig check commands are read from .\" not to be confused with "config.h". .\" output file - file to which language units output is written .\" options file - .\" cache file - .\" lib file - output libraries file created by mkreqlib.sh .\" .\" from perl manual pages... .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" .TH mkconfig_env 7 "17 Jan 2013" .SH Name mkconfig_env \- mkconfig environment units .\" .SH Synopsis .SH Description The environment units create an output file that can be used as shell script input to set your environment. .SH Environment Units .TP .B env\-main The env\-main unit creates a shell script with the exported shell variables. .RS .TP \fBsource\fP .RS The source directive will source another shell script. This is useful to make other variables accessible when the the created shell script is executed. .RE .RE .TP .B env-systype The systype environment unit determines what type, revision and architecture of the system you are running on. .RS .TP \fBsystem\fP {type|rev|arch} .RS The system directive with the type, rev and arch arguments will create the _MKCONFIG_SYSTYPE, _MKCONFIG_SYSREV, and _MKCONFIG_SYSARCH environment variables respectively. These correspond to the output of uname -s, uname -r and uname -m. On AIX, the oslevel command is used to attempt to resolve the revision of the operating system. On MacOS X, the revision is the kernel revision and does not correspond to the marketing version. .RE .RE .TP .B env\-cc .br The cc environment unit determines basic flags needed to run the C compiler. Since these units are interdependent on each other, they should be configured in the order: 32bitflags, cc, using_gcc, using_clang, cflags, ldflags, and libs. The CC, CFLAGS, LDFLAGS, LIBS, CFLAGS_SHARED, and LDFLAGS_SHARED environment variables may be set in the options file. Any value set in the environment will override the settings in the options file. .RS .TP \fB32bitflags\fP .RS If used, this directive must appear before the cc, cflags, etc. commands. It turns off use of the 'getconf' command and other 64-bit flags. .RE .TP \fBcc\fP .RS Determines the C compiler being used (default cc). Sets the CC environment variable. .RE .TP \fBusing_gcc\fP .RS Sets the _MKCONFIG_USING_GCC environment variable to 'Y' if the gcc compiler is being used. .RE .TP \fBusing_clang\fP .RS Sets the _MKCONFIG_USING_CLANG environment variable to 'Y' if the clang compiler is being used. .RE .TP \fBcflags\fP .RS Sets the CFLAGS_DEBUG, CFLAGS_OPTIMIZE, CFLAGS_INCLUDE, CFLAGS_USER, CFLAGS_COMPILER, CFLAGS_APPLICATION and CFLAGS_SYSTEM environment variable according to the 'getconf' program and appropriate to the operating system and compiler. .PP The CFLAGS_ALL environment variable can be used to override the c flags. .RE .TP \fBaddcflag\fP compiler\-flag .RS Checks to see if \fIcompiler\-flag\fP is valid for the compiler and if ok, adds it to the CFLAGS environment variable. .RE .TP \fBfindconfig\fP config\-file .RS Locates the config\-file (someConfig.sh) and loads it. .RE .TP \fBaddconfig\fP env\-var mkconfig\-var .RS After a configuration file is loaded, the environment variables contained therein can be loaded into mkconfig variables. Typical mkconfig variables are: \fIcflags_include\fP, \fIldflags_lib_application\fP, etc. .RE .TP \fBldflags\fP .RS Sets the LDFLAGS_DEBUG, LDFLAGS_OPTIMIZE, LDFLAGS_USER, LDFLAGS_COMPILER, LDFLAGS_APPLICATION and LDFLAGS_SYSTEM environment variables according to the 'getconf' program and appropriate to the operating system and compiler. .PP The LDFLAGS_ALL environment variable can be used to override the load flags. .RE .TP \fBlibs\fP .RS Sets the LDFLAGS_LIBS_USER, LDFLAGS_LIBS_APPLICATION and LDFLAGS_LIBS_SYSTEM environment variable according to the 'getconf' program and appropriate to the operating system and compiler. .PP The LDFLAGS_LIBS_ALL environment variable can be used to override the libraries. .RE .TP \fBcflags_shared\fP .RS Sets the CFLAGS_SHARED environment variable for building position independent code as appropriate to the operating system and compiler. .RE .TP \fBldflags_shared\fP .RS Sets the LDFLAGS_SHARED environment variable for building a shared library as appropriate to the operating system and compiler. .RE .TP \fBshareexeclinkflag\fP .RS Sets the LDFLAGS_EXEC_LINK environment variable for building an executable against shared libraries as appropriate to the operating system and compiler. .RE .TP \fBsharerunpathflag\fP .RS Sets the LDFLAGS_RUNPATH environment variable to the flag for setting the shared run path as appropriate to the operating system and compiler. .RE .RE .PP .TP .B env-dc .br The dc environment unit determines basic flags needed to run the D compiler. The D compiler may also be dependent on the C compiler, so the env-cc unit should also be loaded and the C compiler environment should be set up. The DC and DFLAGS environment variables may be set in the options file. Any value set in the environment will override the settings in the options file. .RS .TP \fBdc\fP .br Determines the D compiler being used. Sets the DC environment variable. Due to major differences in compiler command line options, the following environment variables are also set: .br DC_OPT \- Optimizer option for the compiler. .br DC_OF \- Option prepended to the output file (e.g. -ofoutname or -ooutname). Must be used w/o a space due to the dmd compiler usage. .br DC_RELEASE \- Option for release code. .br DC_INLINE \- Option for inline code generation. .br DC_UNITTEST \- Option for unittest code generation. .br DC_DEBUG \- Option for debug code generation. .br DC_INTFC \- Option for interface file generation. .br DC_COV \- Option for code coverage generation. .br DC_LINK \- Option to prepend to linker commands. This should be prepended without a space. Needed for the dmd compiler. e.g. ${DC_LINK}-L/somepath ${DC_LINK}-lmylib .br .TP \fBdflags\fP .br Sets the DFLAGS environment variable. .RE .TP .B env-extension .RS .TP \fBextension\fP {obj|exe|shlib} .br The obj and exe arguments correspond to the OBJ_EXT, EXE_EXT and SHLIB_EXT environment variables. These variables are set to the object file extension (.o, .obj), executable file extension (none or .exe) or the shared library extension (.so, .sl, .a, .dll) per the operating system and compiler. .RE .TP .B env-msgfmt .RS .TP \fBcmd_msgfmt\fP .br Sets the XMSGFMT environment variable to the path of the msgfmt or gmsgfmt command, if any. .RE .SH See Also iffe(1) autoconf(1) dist(7) mkconfig(7) mkconfig_d(7) mkconfig_c(7) .SH Bugs Send bug reports to: brad.lanam.di_at_gmail.com .SH Website http://www.gentoo.com/di/mkconfig.html .SH Author This program is Copyright 2011-2012 by Brad Lanam, Walnut Creek CA .PP Brad Lanam, Walnut Creek, CA (brad.lanam.di_at_gmail.com) di-4.47/mkconfig/man/mkconfig_d.70000644000175000017500000002733513334050206014716 0ustar bllbll.\" .\" mkconfig_d.7 .\" .\" Copyright 2011-2018 Brad Lanam Walnut Creek CA USA .\" .\" brad.lanam.di_at_gmail.com .\" .\" .\" Notes on terminology: .\" check variable - the variable name for the check. .\" directive - a command from the mkconfig config file. .\" [was check command ] .\" mkconfig config file - file where mkconfig directives are read from .\" not to be confused with "config.h". .\" output file - file to which language units output is written .\" options file - .\" cache file - .\" lib file - output libraries file created by mkreqlib.sh .\" .\" from perl manual pages... .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" .TH mkconfig_d 7 "18 Jan 2012" .SH Name mkconfig_d \- mkconfig D language units .\" .SH Synopsis .SH Description The D language units create an import file for use by D programs. .SH D Language Units .TP .B d\-main .br The d\-main unit creates a configuration file for D programs. .PP Check variables are output as type enum where possible. Other variables are also output as enums where possible. .PP .Vb .B e.g. D2 enum bool _d_tango_lib = false; enum int _csiz_long_double = 16; enum int D_VERSION = 2; enum string SYSTYPE = "Linux"; .B e.g. D1 enum : bool { _d_tango_lib = true }; enum : int { _csiz_long_double = 16 }; enum : int { D_VERSION = 1 }; string SYSTYPE = "Linux"; .Ve .TP \fBmodule\fP module\-name .RS Sets the module name to be output to the output file. .RE .TP \fBnoprefix\fP .RS Turns off prefix (C_TYP_, C_ST_, C_ENUM_, C_UN_, C_MACRO_) generation in the converted C code. .RE .TP \fBstandard\fP .RS Executes any \fIStandard\fP checks for the D language. Currently there are checks for: (a) import of std.string for D version 2; (b) see if the 'string' type is valid; and (c) to see if the tango library is in use. If 'string' is not valid, an alias is added to the configuration file. The tango library check creates a check variable named '_d_tango_lib'. .RE .TP \fBimport\fP name\-\of\-module .RS Checks to see if module can be imported. .PP .B e.g. .br import std.stdio .br Check Variable: _import_std_stdio .RE .TP \fBlib\fP function [libs, ...] .br Check to see if the library function \fIfunction\fP exists. If the optional \fIlibs\fP are specified, the test will try first without the libraries, then with the first set of libraries specified linked in, then the next set, etc. Sets of libraries to be tested are separated by commas. If link libraries are specified, any value in the cache is ignored, and the function is retested. .TP \fBclass\fP class [libs, ...] .RS Check to see if the class \fIclass\fP exists. If the optional \fIlibs\fP are specified, the test will try first without the libraries, then with the first set of libraries specified, then the next set, etc. Sets of libraries to be tested are separated by commas. .RE .TP \fBmember\fP struct\-name member .RS Check to see if \fImember\fP is a member of \fIstruct\-name\fP. .RE .TP \fBsize\fP type\-name .RS Check the size of type\-name .RE .TP \fBtype\fP type\-name .RS Check to see if type\-name exists. This is used internally to see if 'string' is valid. .RE .PP .B D Language Units \- C Language Interface .PP All C language types are converted to the corresponding D language type when output (operating system, architecture and compiler dependent). Any variables with two leading underscores will be converted to '_t_'. .TP \fBchdr\fP header .RS Checks to see if the C Language \fIheader\fP exists. The \fIchdr\fP and \fIcsys\fP directives must appear before other C language directives. The appropriate headers must be checked so that structure, typedef, defines and declarations may be extracted. .PP .B e.g. .br chdr stdlib.h .br Check Variable: _hdr_stdlib .RE .TP \fBcsys\fP header .RS Checks to see if the C language sys/\fIheader\fP exists. The \fIchdr\fP and \fIcsys\fP directives must appear before other C language directives. .PP .B e.g. .br csys types.h .br Check Variable: _sys_types .RE .TP \fBcsizes\fP .RS Checks the sizes of the standard C data types. This directive is required for most of the D/C language interface directives. Operating system, architecture and compiler dependent. .PP .Vb .B Output: alias char C_TYP_char; alias short C_TYP_short; alias int C_TYP_int; alias long C_TYP_long; alias long C_TYP_long_long; alias float C_TYP_float; alias double C_TYP_double; alias real C_TYP_long_double; enum int _csiz_char = 1; enum int _csiz_short = 2; enum int _csiz_int = 4; enum int _csiz_long = 8; enum int _csiz_long_long = 8; enum int _csiz_float = 4; enum int _csiz_double = 8; enum int _csiz_long_double = 16; .Ve .RE .TP \fBclib\fP function [libs, ...] .RS Check to see if the C library function \fIfunction\fP exists. If the optional \fIlibs\fP are specified, the test will try first without the libraries, then with the first set of libraries specified linked in, then the next set, etc. Sets of libraries to be tested are separated by commas. .PP Execute \fImkc.sh \-reqlib\fP after creating the output file to output the libraries required for linking. .PP \fImkc.sh \-reqlib\fP creates the list of libraries required for linking based on the output file. This allows the user to modify the output file and only the necessary libraries will be linked in. .PP \fImkc.sh -reqlib\fP is executed with a command line argument of the output file name created by \fImkconfig.sh\fP. The output library file defaults to 'mkconfig.reqlibs', but may be changed with the \-o command line option. .PP .B e.g. .br clib quotactl .br Check Variable: _clib_quotactl .PP clib bindtextdomain -lintl, -lintl -liconv .br [will test w/o any library, then with -lintl, then with both -lintl and -liconv] .RE .TP \fBcdefine {short|int|long|longlong|hex|hexlong|hexlonglong|float|string}\fP def .RS Checks if a C #define of \fIdef\fP exists. A D language 'enum' will be output to the output file. The type is used to properly convert the C definition. The type output as the D enum will be the appropriate type that has the same size. All floats are output as double enums. .PP .B e.g. .br cdefine hex LC_ALL .br cdefine string _PATH_MOUNTED .br Check Variable: _cdefine_LC_ALL .br .RE .TP \fBctype\fP {int|float} type\-name .RS \fItype\-name\fP will be converted to a D language alias for the type. The size of the type will be determined, and the corresponding D type will be used to alias the type. The C language type will be renamed to C_TYP_. All further instances of that type in the output will also be converted. The \fIint\fP or \fIfloat\fP keyword indicates whether or not \fItype\-name\fP is an integer type or a floating point type. For structures, character pointers, function pointers or if the actual typedef is wanted, use ctypedef. .PP .Vb .B e.g. ctype int uid_t Check Variable: _ctype_uid_t .B Output: alias uint C_TYP_uid_t; static assert ((C_TYP_uid_t).sizeof == 4); enum int _ctype_uid_t = 4; .Ve .RE .TP \fBctypedef\fP type\-name .RS Checks for the typedef \fItype\-name\fP, and if it exists, outputs the D language alias for that typedef. Unlike the \fIctype\fP directive, the size of the object is not determined. The typedef is converted to a D alias as is and output. If the type that is converted from is not defined, further \fIctype\fP or \fIctypedef\fP directives will be need to be added to the configuration file. The 'awk' program is a requirement for this directive. .PP For structures, the \fIcstruct\fP directive should be used. .PP .Vb .B e.g. ctypedef __caddr_t ctypedef caddr_t .B Output: alias _t_caddr_t caddr_t; // from: typedef __caddr_t caddr_t; alias char *_t_caddr_t; // from: typedef char * __caddr_t; .Ve .RE .TP \fBcmacro\fP macro\-name req\-header [req\-hdr2 [...]] rettype [type1 ...] .RS \fImacro\-name\fP will be converted to a D language function to replace the macro. The C language macro will be renamed to C_MACRO_. \fIreq\-header\fP is the list of headers where \fImacro\-name\fP will be found. The return type of \fImacro\-name\fP must be listed after the required headers, and if \fImacro\-name\fP takes arguments, then the list of types must be specified at the end of the cmacro directive. The return type is only used for D version 1. D version 2 will always set the macro return type to 'auto'. The 'awk' program is a requirement for this directive. .PP .Vb .B e.g. cmacro MIN sys/types.h int int int Check Variable: _cmacro_MIN auto C_MACRO_MIN(int a, int b) { return ((a) < (b) ? (a) : (b)); } enum bool _cmacro_MIN = true; .Ve .RE .TP \fBcstruct\fP struct\-name .br \fBcunion\fP union\-name .br \fBcenum\fP enum\-name .br .RS Checks to see if struct \fIstruct\-name\fP or a typedef definition for \fIstruct\-name\fP exists. The structure will be modified for the D language and output to the output file. Note that any types used by the structure must be checked for first using the \fIctype\fP or \fIctypedef\fP directives. The structure will be renamed to C_ST_struct\-name (C_UN for unions, C_ENUM for enums). The 'awk' program is a requirement for this directive. .PP .Vb .B e.g. ctype int __time_t ctype int __suseconds_t cstruct timeval .B Output: struct C_ST_timeval { C_TYP___time_t tv_sec; C_TYP___suseconds_t tv_usec; }; alias long C_TYP___time_t; alias long C_TYP___suseconds_t; static assert ((C_TYP___time_t).sizeof == 8); static assert ((C_TYP___suseconds_t).sizeof == 8); static assert ((C_ST_timeval).sizeof == 16); enum bool _cstruct_timeval = true; enum int _ctype___time_t = 8; enum int _ctype___suseconds_t = 8; .Ve .RE .TP \fBcmember\fP struct\-name member .RS Checks to see if \fImember\fP is a member of \fIstruct\-name\fP. The \fIcstruct\fP directive for the structure must appear before this directive. .PP .Vb .B e.g. cmember statvfs f_basetype .B Output: enum bool _cmem_statvfs_f_basetype = false; .Ve .RE .TP \fBcmembertype\fP struct\-name member .RS Gets the type of \fIstruct\-name\fP.\fImember\fP. The \fIcstruct\fP directive for the structure must appear before this directive. .PP .Vb .B e.g. cmembertype getquota_args gqa_uid .B Output: enum bool _cmembertype_getquota_args_gqa_uid = true; .RE .TP \fBcmemberxdr\fP struct\-name member .RS Aliases the appropriate xdr function for \fIstruct\-name.member\fP. The \fIcstruct\fP directive for the structure must appear before this directive. .PP .Vb .B e.g. cmemberxdr getquota_args gqa_uid .B Output: alias xdr_int xdr_gqa_uid; enum bool _cmemberxdr_getquota_args_gqa_uid = true; .Ve .RE .TP \fBcdcl\fP [args [noconst]] function .RS Checks to see if \fIfunction\fP is declared and outputs the declaration to the output file. If the \fIargs\fP keyword is present, the number of arguments to the function is counted, and the check variables: _c_args_function, _c_arg_N_function, and c_type_function are written to the output file. _c_args_function indicates the number of arguments that should be passed to the function. _c_arg_N_function indicates the type of argument where \fIN\fP refers to the argument position. _c_type_function indicates the return type of the function. If the \fInoconst\fP keyword is present, all 'const' keywords are stripped from the type. All C declarations are wrapped in an 'extern (C) { ... }' block in the output file. The 'awk' program is a requirement for this directive. .PP .Vb .B e.g. cdcl args noconst setmntent .B Output: extern (C) { FILE *setmntent (const char *_t_file, const char *_t_mode) ; } enum string _c_arg_1_setmntent = "char *"; enum string _c_arg_2_setmntent = "char *"; enum string _c_type_setmntent = "FILE *"; enum bool _cdcl_setmntent = true; enum int _c_args_setmntent = 2; .Ve .RE .SH See Also iffe(1) autoconf(1) dist(7) mkconfig(7) mkconfig_c(7) mkconfig_env(7) .SH Bugs Send bug reports to: brad.lanam.di_at_gmail.com .SH Website http://www.gentoo.com/di/mkconfig.html .SH Author This program is Copyright 2011-2012 by Brad Lanam, Walnut Creek CA .PP Brad Lanam, Walnut Creek, CA (brad.lanam.di_at_gmail.com) di-4.47/mkconfig/man/mkconfig_c.70000644000175000017500000001677413334050206014722 0ustar bllbll.\" .\" mkconfig_c.7 .\" .\" Copyright 2011-2018 Brad Lanam Walnut Creek CA USA .\" .\" brad.lanam.di_at_gmail.com .\" .\" .\" Notes on terminology: .\" check variable - the variable name for the check. .\" directive - a command from the mkconfig config file. .\" mkconfig config file - file where mkconfig directive are read from .\" not to be confused with "config.h". .\" output file - file to which language units output is written .\" options file - .\" cache file - .\" lib file - output libraries file created by mkreqlib.sh .\" .\" from perl manual pages... .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" .TH mkconfig_c 7 "8 Nov 2011" .SH Name mkconfig_c \- mkconfig C language units .\" .SH Synopsis .SH Description The C language units create an include file for use by C programs. .SH C Language Units .TP .B c\-main .br The c\-main unit creates an include file for C programs. The \fIhdr\fP and \fIsys\fP directives should be listed first in the mkconfig configuration file so that the headers are available for use in the other tests. .RS .TP \fBstandard\fP .RS The \fIstandard\fP checks are: the headers stdio.h, stdlib.h, sys/types.h and sys/param.h, the keywords \fIvoid\fP and \fIconst\fP, the \fIvoid *\fP type as a parameter, and C function prototypes. .PP .Vb .B Output: #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _key_void 1 #define _key_const 1 #define _param_void_star 1 #define _proto_stdc 1 .Ve .RE .TP \fBargs\fP [noconst] name\-of\-function .RS Checks the number of arguments, the types of the arguments and the return type for a function. If 'noconst' is specified, any 'const' keywords will be stripped from the output so only the base data type is returned. Outputs the following check variables: _args_function, _c_arg_N_function, and _c_type_function. _args_function indicates the number of arguments. _c_arg_N_function indicates the argument data type. _c_type_function indicates the return type of the function. The 'awk' program is a requirement for this directive. .PP .Vb .B e.g. args noconst setmntent .B Output: #define _c_arg_1_setmntent char * #define _c_arg_2_setmntent char * #define _c_type_setmntent FILE * #define _args_setmntent 2 .Ve .RE .TP \fBhdr\fP name\-of\-header [required\-headers] .RS Check for a header. The standard include path as set in CFLAGS is used. If \fIrequired\-headers\fP is specified, those headers are included in the compilation test before attempting the compilation test. .PP .Vb .B e.g. hdr getopt hdr storage/volumes.h gui/window.h .B Output: #define _hdr_getopt 1 #define _hdr_storage_volumes 0 .Ve .RE .TP \fBsys\fP name\-of\-sys\-header [required\-headers] .RS Like \fIhdr\fP, but looks in the sys/ directory. .PP .Vb .B e.g. sys types.h .B Output: #define _sys_types 1 .Ve .RE .TP \fBclass\fP class [libs, ...] .RS Check to see if class \fIclass\fP exists. If the optional \fIlibs\fP are specified, the test will try first without the libraries, then with the first set of libraries specified, then the next set, etc. Sets of libraries to be tested are separated by commas. .PP .Vb .B e.g. class os::Volumes .B Output: #define _class_os__Volumes 0 .Ve .PP Execute \fImkc.sh \-reqlib\fP after creating the output file to output the libraries required for linking. See the usage for \fImkc.sh \-reqlib\fP in the lib check below. .RE .TP \fBconst\fP constant\-name [required\-headers] .RS Check to see that a constant exists. If \fIrequired\-headers\fP is specified, those headers are included in the compilation test before attempting the compilation test. .PP .Vb .B e.g. const O_NOCTTY .B Output: #define _const_O_NOCTTY 1 .Ve .RE .TP \fBdcl\fP {int|ptr} variable\-name .RS Check to see if \fIvariable\-name\fP is declared. If \fIint\fP is specified, the variable is a numeric type. If \fIptr\fP is specified, the variable is a pointer type. .PP .Vb .B e.g. dcl int errno dcl ptr optarg .B Output: #define _dcl_errno 1 #define _dcl_optarg 1 .Ve .RE .TP \fBdefine\fP definition\-name .RS Check to see if definition\-name is defined. .PP .Vb .B e.g. define MCTL_QUERY .B Output: #define _define_MCTL_QUERY 0 .Ve .RE .TP \fBkey\fP keyword .RS Check to see if a C\-language keyword is reserved. .PP .Vb .B e.g. key volatile .B Output: #define _key_volatile 1 .Ve .RE .TP \fBlib\fP function [libs, ...] .RS Check to see if the library function \fIfunction\fP exists. If the optional \fIlibs\fP are specified, the test will try first without the libraries, then with the first set of libraries specified linked in, then the next set, etc. Sets of libraries to be tested are separated by commas. If link libraries are specified, any value in the cache is ignored, and the function is retested. .PP .Vb .B e.g. lib gettext -lintl, -lintl -liconv [Will first test gettext, then gettext -lintl, then gettext -lintl -liconv] .B Output: #define _lib_gettext 1 .Ve .PP Execute \fImkc.sh \-reqlib\fP after creating the output file to output the libraries required for linking. .PP \fImkc.sh \-reqlib\fP creates the list of libraries required for linking based on the output file. This allows the user to modify the output file and only the necessary libraries will be linked in. .PP \fImkc.sh -reqlib\fP is executed with a command line argument of the output file name created by \fImkconfig.sh\fP. The output library file defaults to 'mkconfig.reqlibs', but may be changed with the \-o command line option. .PP The string '_dollar_', if included in the library function name will be replaced with the '$' symbol. .RE .TP \fBmember\fP struct struct\-name member .TP \fBmember\fP union union\-name member .TP \fBmember\fP typedef\-name member .RS Check to see if \fImember\fP is a member of \fIstruct struct\-name\fP or \fItypedef-name\fP. .PP .Vb .B e.g. member struct statfs f_bsize .B Output: #define _mem_struct_statfs_f_bsize 1 .Ve .RE .TP \fBmemberxdr\fP struct\-name member .RS Define the appropriate xdr function for \fIstruct\-name.member\fP. The 'awk' program is a requirement for this directive. .PP .Vb .B e.g. memberxdr getquota_args gqa_uid .B Output: #define xdr_gqa_uid xdr_int #define _memberxdr_getquota_args_gqa_uid 1 .Ve .RE .TP \fBnpt\fP function [library\-requirement] .RS Check to see if if \fIfunction\fP needs to have a prototype declared. The optional \fIlibrary\-requirement\fP should be written as: _lib_. If \fIlibrary\-requirement\fP does not exist, _npt_ will be set to false in the output file. .PP .Vb .B e.g. npt getopt npt statfs _lib_statfs .B Output: #define _npt_getopt 0 #define _npt_statfs 0 .Ve .RE .TP \fBsiz\fP type\-name .RS Check the size of type\-name. .PP .Vb .B e.g. siz long long .B Output: #define _siz_long_long 8 .Ve .RE .TP \fBtyp\fP type\-name .RS Check to see if a type\-name exists. type\-name may be a type or a structure. .PP .Vb .B e.g. typ size_t typ struct dqblk .B Output: #define _typ_size_t 1 #define _typ_struct_dqblk 1 .Ve .RE .RE .TP .B c\-include\-conflict .RS .TP \fBinclude_conflict \fP .RS Check to see if there is a compile conflict when including two headers. If there is a conflict, the check variable is set to 0. .PP .Vb .B e.g. include_conflict time.h sys/time.h .B Output: #define _inc_conflict__hdr_time__sys_time 1 .Ve .RE .RE .SH See Also iffe(1) autoconf(1) dist(7) mkconfig(7) mkconfig_env(7) mkconfig_d(7) .SH Bugs Send bug reports to: brad.lanam.di_at_gmail.com .SH Website http://www.gentoo.com/di/mkconfig.html .SH Author This program is Copyright 2011 by Brad Lanam, Walnut Creek CA .PP Brad Lanam, Walnut Creek, CA (brad.lanam.di_at_gmail.com) di-4.47/mkconfig/man/mkconfig.70000644000175000017500000004122313334050206014403 0ustar bllbll.\" .\" mkconfig.7 .\" .\" Copyright 2011-2018 Brad Lanam Walnut Creek CA USA .\" .\" brad.lanam.di_at_gmail.com .\" .\" .\" Notes on terminology: .\" check variable - the variable name for the check. .\" directive - a command from the mkconfig config file. .\" mkconfig config file - file where mkconfig check commands are read from .\" not to be confused with "config.h". .\" output file - file to which language units output is written .\" options file - .\" cache file - .\" lib file - output libraries file created by mkreqlib.sh .\" .\" from perl manual pages... .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" .TH mkconfig 7 "10 Nov 2012" .SH Name mkconfig \- build configuration utilities .SH Synopsis .\" mkconfig.sh [-C] [-c ] .\" [-o ] [-L ] config-file .\" runtests.sh [test1, ...] .\" mkc.sh {-compile|-link} [-shared] [-exec] .\" [-c ] [-e] [-o execname|-o objname] .\" [-r required-lib-file] -- .\" [sourcefile ...] [objectfile ...] [compile-or-link-flags ...] .\" [-L ] [-l ] .\" mkc.sh -reqlib [-c ] [-o ] input-file .\" mkc.sh -setopt [-o ] option value .\" mkc.sh -staticlib [-e] -o libname.a objectfile ... .B mkconfig.sh [\fB\-C\fP] [\fB\-c\fP ] [\fB\-L\fP ] [\fB\-o\fP ] config\-file .PP The \-C option clears any cache file before processing the units. .PP cache\-file defaults to 'mkconfig.cache'. .PP log\-file defaults to 'mkconfig.log'. .PP option\-file defaults to 'options.dat'. .PP config\-file is a file containing a list of mkconfig directives. .PP .B runtests.sh tests\-dir [test1, ...] .PP tests\-dir is a directory containing test scripts. .PP The tests to be run may be specified on the command line. .PP .B mkc.sh \-reqlib [\fB\-c\fP ] [\fB\-o\fP ] input\-file .PP Is used in conjunction with the c\-main language unit or d\-main language unit to output the libraries required for linking. See the description for the 'lib' check routine for the c\-main language unit. .PP cache\-file defaults to 'mkconfig.cache'. .PP output\-file defaults to 'mkconfig.reqlibs'. .PP input\-file is the C/C++ output\-file created by mkconfig.sh. .PP .B mkc.sh \-setopt [\fB\-o\fP ] option value .PP Is used to change the value of the options in the option file. .PP option\-file defaults to 'options.dat'. .PP .B mkc.sh \-staticlib [-e] -o libname.a object\-file [...] .PP The -e option echos the command line. .PP .B mkc.sh \-compile|\-link [\-c ] [\-shared] [\-exec] [\-e] [\-o |\-o ] [\-r required\-lib\-file] \-\- [ ...] [ ...] [ ...] [\-L ] [\-l ] .PP Compiles to an executable or object file given source or object files, compiler options, link options and a list of library paths and libraries. .PP The \-e option echos the command line. .PP Use the \-shared option to build shared object or library files. .PP Use the \-exec option when building an executable against shared objects. .PP The \-staticlib option creates a static library given a library name and a list of object files. .SH Description \fImkconfig.sh\fP is a build configuration utility. It is written in portable shell script and designed to be extensible for any configuration use. Most Bourne Shell compatible shells will work. .PP \fImkconfig.sh\fP is intended to generate a file that can be used as an included file, a shell script, a configuration file, or any other use. If the _MKCONFIG_SHELL environment variable is set to a particular shell, \fImkconfig.sh\fP will restart itself using that shell. .PP \fIruntests.sh\fP is a simple test harness for mkconfig. It is intended as a simple, portable test harness. There are better test harnesses available. .SH Basic Directives (mkconfig.sh) .TP \fB#\fP comment .RS Comments begin with a '#' in column 1. Blank lines are ignored. .RE .TP \fBoutput\fP file\-name (required) .RS Specify the name of the output file. This command may be included multiple times in the mkconfig configuration file to output multiple files. .RE .TP \fBoption\-file\fP file\-name .RS Specify the name of the options file. The options file can also be specified on the command line with the \-o option. .RE .TP \fBloadunit\fP unit\-name .RS Include a mkconfig unit for testing. Units include specific check routines that may be performed. .RE .TP \fBcommand\fP name\-of\-command [alternate\-cmd...] .RS Check if command exists in the path. When listing alternate commands, specify the list from least wanted to best. .PP .Vb .B e.g. command awk nawk gawk .br command sed .B Output: #define _command_sed 1 /* C */ #define _cmd_loc_sed "/bin/sed" /* C */ enum bool _command_sed = true; /* D */ enum string _cmd_loc_sed = "/bin/sed"; /* D */ .Ve .RE .TP \fBgrep\fP tag pattern filename .RS Searches filename for pattern. tag is used for naming and display purposes. .PP .Vb .B e.g. grep mysearch root /etc/passwd .B Output: #define _grep_mysearch 1 /* C */ enum bool _grep_mysearch = true; /* D */ .Ve .RE .TP \fBifoption\fP option\-name ... [else ...] endif .TP \fBifnotoption\fP option\-name ... [else ...] endif .RS The \fIifoption\fP and \fIifnotoption\fP statements check the options set in the options file and process the appropriate block of statements. .PP If there is no options file, or the option does not exist, both \fIifoption\fP and \fIifnotoption\fP will return a false return. .PP The \fIifoption\fP, \fIifnotoption\fP and \fIif\fP statements may be nested. .RE .TP \fBif\fP label if\-statement ... [\fBelse\fP ...] \fBendif\fP .RS The \fIif\fP statement is a combination of check variables, &&, ||, ! (not) and parentheses. It is recommended that parentheses be used copiously to avoid any possible precedence differences between different shells. The \fIlabel\fP is used for display output. .PP The equality operator is supported in prefix notation as: .IP \fIif\fP label == check\-variable value .PP The \fIvalue\fP may be enclosed in quotes, but preservation of extra spaces will not work. .PP .Vb .B e.g. if mylabel _hdr_header1 && ( ! (_lib_func3 || _lib_func4)) && _setint_my_var ... endif if quotactl_pos_1 == _c_arg_1_quotactl 'char *' ... endif .Ve .RE .PP The \fIifoption\fP, \fIifnotoption\fP and \fIif\fP statements may be nested. .RE .TP .B include endinclude .RS Include all of the code between these two tags in the output file. Backslashes must be escaped with a backslash. Note that the included text is only output at the end of the output\-file, not inline with the directive output. .RE .TP \fBoption\fP option\-name default\-value .RS Set \fIoption\-name\fP specified to default\-value. The option\-file is checked for \fIoption\-name\fP, and if present, the value in the option\-file is used. .PP For use in if statements, the check variable is named _opt_option\-name. .RE .TP \fBset\fP check\-variable value .RS Set a check\-variable to value. .PP .Vb .B e.g. lib quotactl set _lib_quotactl 0 .Ve .RE .TP \fBsetint\fP check\-variable\-name value .RS Set an integer variable to a value. The check variable name will be output as specified, but when used in if statements, the check variable is named _setint_. .PP .Vb .B e.g. setint _enable_nls 1 .Ve .RE .TP \fBsetstr\fP check\-variable\-name value .RS Set a string variable to a value. The check variable name will be output as specified, but when used in if statements, the check variable is named _setstr_. .PP .Vb .B e.g. setstr _my_lib_path /lib .Ve .RE .TP \fBstandard\fP .RS Perform any standard checks for the unit that was loaded. See the description of the other units to see what the standard check does. .RE .TP \fBsubstitute\fP pattern1 pattern2 .RS Substitute pattern2 for pattern1. pattern1 and pattern2 are passed to 'sed' and may be regular expressions. Using backslashes in the patterns may be problematical due to quoting by the executing shell. .PP The substitute directive is not available with the perl version of mkconfig. .RE .SH Environment Units The environment units create an output file that can be used as shell script input to set your environment. .PP See mkconfig_env(7). .SH C Language Units The C language units create an include file for C programs. .PP See mkconfig_c(7). .SH D Language Units The D language units create an import file for D programs. .PP See mkconfig_d(7). .SH Tests (runtests.sh) The test directory contains shell scripts that are executed by \fIruntests.sh\fP. If a 'test_order' file exists in the test directory, it indicates the order the tests are run in. The 'test_order' file consists of a pass number followed by the test name (no trailing .sh). If the 'test_order' file exists, only those tests in the file will be run. .PP If there is a test failure, testing will continue until a change in pass number occurs. .SH Writing a mkconfig Unit (mkconfig.sh) \fImkconfig.sh\fP reads the mkconfig configuration file and processes each line sequentially. The \fIoutput\-file\fP command specifies the output file (e.g. config.h for the c-main language unit). A language unit is loaded with the \fIloadunit\fP command. .PP Each language unit script is executed with the unix shell source (\fB.\fP) command, so it has all of the general shell functions from mkconfig.sh available for use. .PP The following functions from mkconfig.sh are used by the language units: printlabel, checkcache, checkcache_val, checkcache_actual, printyesno, printyesno_val, printyesno_actual, getdata, setdata, require_unit, dosubst, doappend, domath, toupper, tolower, and locatecmd. .PP A language unit must provide the following functions: preconfigfile, output_item, stdconfigfile, postconfigfile, output_other. .PP \fImkconfig.sh\fP provides the following generic checks: command, include/endinclude, ifoption, ifnotoption, if, set, setint, setstr, and option. The set, setint, setstr and option commands will execute the \fIoutput_item\fP function from the current unit. Any other unrecognized commands will be passed on to the language unit that has been loaded. .PP The flow of control by \fImkconfig.sh\fP is: .RS 3 process the commands from the mkconfig configuration file .RS 3 set the output\-file name. .br load any units as specified by the loadunit commands from the mkconfig.units directory. .br execute the directives as specified by the mkconfig configuration file. .br .RE save the cache file. .br execute \fIpreconfigfile\fP from the language unit. .br execute \fIoutput_item\fP for each configuration item. .br execute \fIstdconfigfile\fP from the language unit. .br output any \fIinclude\fP text from the mkconfig configuration file. .br execute \fIpostconfigfile\fP from the language unit. .br execute \fIoutput_other\fP from the language unit. .RE .PP A language unit must define the functions listed above. It may also define other functions for use by other units for that language. .PP The main language unit must set the following shell variables: .RS 3 _MKCONFIG_PREFIX is set to a language unit specific prefix. This prefix is used internally and in the cache files to create a unique name. .PP _MKCONFIG_HASEMPTY is set to T or F. If true, the language unit may set check variables to empty values. This modifies certain processing in \fImkconfig.sh\fP. It is faster to have non-empty check variables. .PP _MKCONFIG_EXPORT is set to T or F. If true, the check variable is set and exported so that it can be accessed in the shell environment. .RE .PP Language units may need other functions as defined in other units. The \fIrequire_unit\fP function makes sure that the a particular language unit is loaded for use by the calling unit. .PP A typical directive in a language unit will be structured as follows: .RS 3 .Vb check_somecheck () { chktype=$1 checkarg=$2 name="_somecheck_${checkarg}" printlabel $name "somecheck: ${checkarg}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi # found it in cache # do processing for check here retval=1 printyesno $name $retval setdata ${_MKCONFIG_PREFIX} $name $retval } .Ve .RE The check function's arguments will be the same values read from the mkconfig configuration file. The name should be set to __ as appropriate to be a unique name that is a valid unix shell variable name. .SH Internal Function Definitions (mkconfig.sh) .TP \fBcheckcache\fP prefix name .TP \fBcheckcache_val\fP prefix name .TP \fBcheckcache_actual\fP prefix name .br \fIcheckcache\fP checks the cache to see if the check variable already has a value. If so, the check variable is set to the value and a return code of 0 is returned. \fIprefix\fP is normally $_MKCONFIG_PREFIX and \fIname\fP is the name of the check variable. The different variants of \fIcheckcache\fP correspond to the variants of \fIprintyesno\fP for displaying the check variable to the user. .TP \fBdosubst\fP shellvar pattern repl [pattern repl ...] .br Substitutes \fIrepl\fP for \fIpattern\fP globally throughout \fIshellvar\fP. Multiple patterns and replacement strings may be specified. \fIpattern\fP may be any regular expression recognized by 'sed'. Note that modern 'sed' regular expressions will not be supported on all systems. .TP \fBdoappend\fP shellvar value .br Appends value to \fIshellvar\fP. .TP \fBdomath\fP shellvar "math\-expr" .br Executes the \fImath\-expr\fP and assigns the returned value to \fIshellvar\fP. \fImath\-expr\fP must be quoted and should have spaces around all arguments. .br e.g. count=1; domath count "$count + 1"; echo $count # 2 .TP \fBgetdata\fP shellvar prefix name .br In some cases, the check function may need to retrieve the value of a check variable. The \fIgetdata\fP function returns the value of the check variable \fIname\fP in the shell variable \fIshellvar\fP. \fIprefix\fP is normally ${_MKCONFIG_PREFIX}. .TP \fBlocatecmd\fP shellvar command .br Locates a command in the path. Sets \fIshellvar\fP to the full path of the command. .TP \fBprintlabel\fP name display\-data .br \fIprintlabel\fP displays \fIdisplay\-data\fP to the screen followed by an ellipsis. The name and display\-data is also logged to the log file. .TP \fBprintyesno\fP name value .TP \fBprintyesno_val\fP name value .TP \fBprintyesno_actual\fP name value .br \fIprintyesno\fP is used in conjunction with \fIprintlabel\fP. \fIprintlabel\fP displays the first part of the output for the user and \fIprintyesno\fP displays the result. \fIprintyesno\fP is used for boolean (0 or 1) values. It will display 'yes' or 'no'. \fIprintyesno_val\fP is used for values that are non-zero or a string. It will display the value, or 'no' if set to 0. \fIprintyesno_actual\fP is used for values that should be displayed intact. It will display the actual value (0 or otherwise). .TP \fBrequire_unit\fP unit\-name .br \fIrequire_unit\fP loads another unit file that is needed by the calling unit. .TP \fBsetdata\fP prefix name value .br \fIsetdata\fP is used in a check function to set the value of a check variable. \fIprefix\fP is normally ${_MKCONFIG_PREFIX}. \fIname\fP is the name of the check variable. \fIvalue\fP is the value the check variable is set to. \fIvalue\fP should be enclosed in quotation marks if it has spaces or other special shell characters. .TP \fBtoupper\fP shellvar .br Converts a shell variable to upper case. .TP \fBtolower\fP shellvar .br Coverts a shell variable to lower case. .SH Environment Variables (mkconfig.sh) .TP _MKCONFIG_DIR The directory where mkconfig.sh is installed. .SH File Descriptors (mkconfig.sh) The file descriptors are allocated as follows: .br 9 - The mkconfig log file .br 8 - Used by mkconfig.sh; not available for mkconfig unit scripts. .br 7 - Used by mkconfig.sh; not available for mkconfig unit scripts. .br 6 - Used by c\-main.sh and mkconfig.sh; not available for c language unit scripts. .br 4 - Used by c\-main.sh; not available for c language unit scripts. .SH Writing a test script (runtests.sh) To be completed. .SH Environment Variables (runtests.sh) .TP _MKCONFIG_DIR .br The directory where mkconfig.sh is installed. .TP _MKCONFIG_RUNTOPDIR .br The original directory where the tests were started. .TP _MKCONFIG_RUNTSTDIR .br The directory containing the test scripts and associated files. .TP _MKCONFIG_RUNTMPDIR .br The top level temporary directory. Sub\-directories are created for each test that is run. .TP _MKCONFIG_TSTRUNTMPDIR .br The temporary directory in which the test is run. .TP shelllist .br A list of valid shells installed on the system. .SH See Also iffe(1) autoconf(1) dist(7) mkconfig_env(7) mkconfig_c(7) mkconfig_d(7) .SH Bugs Send bug reports to: brad.lanam.di_at_gmail.com .SH Website http://www.gentoo.com/di/mkconfig.html .SH Author This program is Copyright 2011-2012 by Brad Lanam, Walnut Creek CA .PP Brad Lanam, Walnut Creek, CA (brad.lanam.di_at_gmail.com) di-4.47/mkconfig/VERSION0000644000175000017500000000000613334050206013005 0ustar bllbll2.0.0 di-4.47/mkconfig/mkc.sh0000755000175000017500000000177013334050206013057 0ustar bllbll#!/bin/sh # # Copyright 2009-2018 Brad Lanam Walnut Creek, CA USA # # this is a workaround for ksh93 on solaris unset CDPATH if [ "$1" = "-d" ]; then cd $2 shift shift fi mypath=`echo $0 | sed -e 's,/[^/]*$,,' -e 's,^\.,./.,'` _MKCONFIG_DIR=`(cd $mypath;pwd)` export _MKCONFIG_DIR . ${_MKCONFIG_DIR}/bin/shellfuncs.sh . ${_MKCONFIG_DIR}/bin/envfuncs.sh doshelltest $0 $@ rc=0 args=$@ found=T case $1 in -compile|-comp|-link) ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkcl.sh -d `pwd` "$@" rc=$? shift ;; -staticlib) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkstaticlib.sh -d `pwd` "$@" rc=$? ;; -setopt) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkcsetopt.sh -d `pwd` "$@" rc=$? ;; -reqlib) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkreqlib.sh -d `pwd` "$@" rc=$? ;; *) found=F ;; esac if [ $found = F ]; then echo "Usage: $0 {-compile|-link|-setopt|-reqlib|-staticlib|-sharedlib} " exit 1 fi exit $rc di-4.47/mkconfig/bin/0000755000175000017500000000000013334050206012511 5ustar bllblldi-4.47/mkconfig/bin/envfuncs.sh0000755000175000017500000000213213334050206014675 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek, CA, USA # setcflags () { CFLAGS="" if [ "$CFLAGS_ALL" != "" ]; then CFLAGS="$CFLAGS_ALL" else doappend CFLAGS " ${CFLAGS_OPTIMIZE}" doappend CFLAGS " ${CFLAGS_DEBUG}" doappend CFLAGS " ${CFLAGS_INCLUDE}" doappend CFLAGS " ${CFLAGS_USER}" doappend CFLAGS " ${CFLAGS_APPLICATION}" doappend CFLAGS " ${CFLAGS_COMPILER}" doappend CFLAGS " ${CFLAGS_SYSTEM}" fi export CFLAGS } setldflags () { LDFLAGS="" if [ "$LDFLAGS_ALL" != "" ]; then LDFLAGS="$LDFLAGS_ALL" else doappend LDFLAGS " ${LDFLAGS_OPTIMIZE}" doappend LDFLAGS " ${LDFLAGS_DEBUG}" doappend LDFLAGS " ${LDFLAGS_USER}" doappend LDFLAGS " ${LDFLAGS_APPLICATION}" doappend LDFLAGS " ${LDFLAGS_COMPILER}" doappend LDFLAGS " ${LDFLAGS_SYSTEM}" fi export LDFLAGS } setlibs () { LIBS="" if [ "$LDFLAGS_LIBS_ALL" != "" ]; then LIBS="$LDFLAGS_LIBS_ALL" else doappend LIBS " ${LDFLAGS_LIBS_USER}" doappend LIBS " ${LDFLAGS_LIBS_APPLICATION}" doappend LIBS " ${LDFLAGS_LIBS_SYSTEM}" fi export LIBS } di-4.47/mkconfig/bin/mkcl.sh0000755000175000017500000001670513334050206014007 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek, CA USA # unset CDPATH # this is a workaround for ksh93 on solaris if [ "$1" = "-d" ]; then cd $2 shift shift fi . ${_MKCONFIG_DIR}/bin/shellfuncs.sh doshelltest $0 $@ addlib () { lfn=$1 found=F nlibnames= for tf in $libnames; do if [ $lfn = $tf ]; then found=T # a match will be moved to the end of the list else doappend nlibnames " $tf" fi done doappend nlibnames " ${lfn}" libnames=${nlibnames} } addlibpath () { lp=$1 found=F for tp in $libpathnames; do if [ $lp = $tp ]; then found=T # a match will be kept. break fi done if [ $found = F ]; then doappend libpathnames " ${lp}" fi } compile=F link=F shared=F mkexec=F mklib=F doecho=F comp=${CC} reqlibfiles= logfile=mkc_compile.log c=T d=F while test $# -gt 0; do case $1 in -compile|-comp) shift compile=T shared=F ;; -link) shift link=T ;; -log) shift logfile=$1 shift ;; -shared) shift shared=T ;; -exec) shift mkexec=T ;; -lib) shift mkexec=F mklib=T ;; -c) shift comp=$1 shift case ${comp} in *gdc*|*ldc*|*dmd*) d=T c=F ;; esac ;; -d) shift ndir=$1 cd $ndir rc=$? if [ $rc -ne 0 ]; then puts "## Unable to cd to $ndir" grc=$rc exit $grc fi shift ;; -e) doecho=T shift ;; -o) shift outfile=$1 shift ;; -r) shift doappend reqlibfiles " $1" shift ;; -D*) doappend CFLAGS " $1" shift ;; --) shift break ;; *) break ;; esac done if [ "$logfile" != "" ]; then exec 9>>$logfile puts "# `date`" >&9 fi # DC_LINK should be in environment already. OUTFLAG="-o " DC_LINK= case ${comp} in *dmd*|*ldc*) # catches ldmd, ldmd2 also OUTFLAG=${DC_OF:-"-of"} DC_LINK=-L ;; *gdc*) OUTFLAG=${DC_OF:-"-o "} ;; *gcc*|*cc*) DC_LINK= ;; esac flags= files= objects= libnames= libpathnames= islib=0 ispath=0 olibs= havesource=F if [ "$reqlibfiles" != "" ]; then for rf in $reqlibfiles; do doappend olibs "`cat $rf`" done fi grc=0 for f in $@ $olibs; do case $f in -D*) doappend CFLAGS $1 shift ;; -L) ispath=1 ;; -L*) tf=$f dosubst tf '-L' '' if [ ! -d "$tf" ]; then puts "## unable to locate dir $tf" grc=1 else addlibpath $tf fi ;; -l) islib=1 ;; -l*) addlib $f ;; lib*) addlib $f ;; *${OBJ_EXT}) if [ ! -f "$f" ]; then puts "## unable to locate $f" grc=1 else doappend objects " $f" fi ;; *.c|*.d) if [ ! -f "$f" ]; then puts "## unable to locate $f" grc=1 else doappend files " $f" havesource=T fi ;; "-"*) doappend flags " $f" if [ $f = "-c" ]; then compile=T fi ;; *) if [ $islib -eq 1 ]; then addlib "-l$f" elif [ $ispath -eq 1 ]; then if [ ! -d "$f" ]; then puts "## unable to locate dir $f" grc=1 else addlibpath $f fi fi islib=0 ispath=0 ;; esac done libs= for lfn in $libnames; do doappend libs " ${DC_LINK}${lfn}" done libpath= for lp in $libpathnames; do doappend libpath ":${lp}" done dosubst libpath '^:' '' outflags="" if [ "$outfile" = "" ]; then flags="${flags} -c" else outflags="${OUTFLAG}$outfile" case ${outfile} in *.o|*.obj) flags="${flags} -c" ;; esac fi allcflags= if [ $havesource = T ]; then if [ $c = T ];then if [ "$CFLAGS_ALL" != "" ]; then doappend allcflags " ${CFLAGS_ALL}" else doappend allcflags " ${CFLAGS_OPTIMIZE}" # optimization flags doappend allcflags " ${CFLAGS_DEBUG}" # debug flags doappend allcflags " ${CFLAGS_INCLUDE}" # any include files doappend allcflags " ${CFLAGS_USER}" # specified by the user doappend allcflags " ${CFLAGS}" # specified by the user if [ $shared = T ];then doappend allcflags " ${CFLAGS_SHARED}" doappend allcflags " ${CFLAGS_SHARED_USER}" fi doappend allcflags " ${CFLAGS_APPLICATION}" # added by the config process doappend allcflags " ${CFLAGS_COMPILER}" # compiler flags doappend allcflags " ${CFLAGS_SYSTEM}" # needed for this system fi fi if [ $d = T ];then doappend allcflags " ${DFLAGS}" fi fi allldflags= ldflags_runpath= ldflags_shared_libs= ldflags_exec_link= if [ $link = T ]; then if [ "$LDFLAGS_ALL" != "" ]; then doappend allldflags " ${LDFLAGS_ALL}" else doappend allldflags " ${LDFLAGS_OPTIMIZE}" # optimization flags doappend allldflags " ${LDFLAGS_DEBUG}" # debug flags doappend allldflags " ${LDFLAGS_USER}" # specified by the user doappend allldflags " ${LDFLAGS_APPLICATION}" # added by the config process doappend allldflags " ${LDFLAGS_COMPILER}" # link flags doappend allldflags " ${LDFLAGS_SYSTEM}" # needed for this system fi fi if [ $link = T -a $shared = T ]; then doappend allldflags " ${LDFLAGS_SHARED}" doappend allldflags " ${LDFLAGS_SHARED_USER}" fi if [ \( $shared = T \) -o \( $mkexec = T \) ]; then ldflags_runpath="" if [ "${libpath}" != "" -a "${LDFLAGS_RUNPATH}" != "" ]; then dosubst libpath '^:' '' ldflags_runpath="${LDFLAGS_RUNPATH}${libpath}" fi ldflags_shared_libs="" if [ "${libs}" != "" -a "${libpath}" != "" ]; then ### is this right??? ldflags_shared_libs="${DC_LINK}-L${libpath}" fi ldflags_exec_link="" if [ $mklib = F -a $mkexec = T ]; then if [ "${LDFLAGS_EXEC_LINK}" != "" ]; then ldflags_exec_link="${LDFLAGS_EXEC_LINK}" fi fi fi if [ $link = T ]; then if [ "${DC_LINK}" != "" ]; then ldflags="" for flag in ${LDFLAGS}; do doappend allldflags " ${DC_LINK}${flag}" done fi fi if [ $link = T ]; then if [ "$LDFLAGS_LIBS_ALL" != "" ]; then doappend alllibs " ${LDFLAGS_LIBS_ALL}" else doappend alllibs " ${LDFLAGS_LIBS_USER}" doappend alllibs " ${LDFLAGS_LIBS_APPLICATION}" doappend alllibs " ${LDFLAGS_LIBS_SYSTEM}" fi fi # clear the standard env vars so they don't get picked up. CFLAGS= CPPFLAGS= LDFLAGS= LIBS= cmd="${comp} ${allcflags} ${flags} ${allldflags} ${ldflags_exec_link} \ $outflags $objects \ ${files} ${ldflags_runpath} ${ldflags_shared_libs} ${alllibs} ${libs}" if [ $compile = T ]; then putsnonl "COMPILE ${files} ..." if [ "$logfile" != "" ]; then puts "COMPILE ${files}" >&9 fi fi if [ $link = T ]; then putsnonl "LINK ${outfile} ..." if [ "$logfile" != "" ]; then puts "LINK ${outfile}" >&9 fi fi if [ $doecho = T ]; then puts "" puts " $cmd" fi if [ "$logfile" != "" ]; then puts " $cmd" >&9 fi out="" if [ "$logfile" != "" ]; then out=`eval $cmd 2>&1` rc=$? puts "$out" >&9 if [ $doecho = T ]; then puts "$out" fi else eval $cmd rc=$? fi if [ $rc -eq 0 ]; then puts "$out" | grep -i warning: >/dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then puts " warnings" else puts " ok" fi else puts " fail" grc=$rc fi if [ "$logfile" != "" ]; then exec 9>&- fi exit $grc di-4.47/mkconfig/bin/mkstaticlib.sh0000755000175000017500000000426113334050206015361 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek, CA USA # unset CDPATH # this is a workaround for ksh93 on solaris if [ "$1" = "-d" ]; then cd $2 shift shift fi . ${_MKCONFIG_DIR}/bin/shellfuncs.sh doshelltest $0 $@ libnm="" objects="" grc=0 doecho=F logfile=mkc_compile.log while test $# -gt 0; do case $1 in -e) shift doecho=T ;; --) shift ;; -log) shift logfile=$1 shift ;; -o) shift tf=$1 shift if [ "$libnm" = "" ]; then libnm=$tf continue fi ;; *${OBJ_EXT}) tf=$1 shift if [ ! -f "$tf" ]; then puts "## unable to locate $tf" grc=1 else doappend objects " $tf" fi ;; *) tf=$1 shift if [ "$libnm" = "" ]; then libnm=$tf continue fi ;; esac done if [ "$logfile" != "" ]; then exec 9>>$logfile puts "# `date`" >&9 fi locatecmd ranlibcmd ranlib locatecmd arcmd ar locatecmd lordercmd lorder locatecmd tsortcmd tsort if [ "$arcmd" = "" ]; then puts "## Unable to locate 'ar' command" grc=1 fi if [ $grc -eq 0 ]; then dosubst libnm '${SHLIB_EXT}$' '' libfnm=${libnm} # for really old systems... if [ "$ranlibcmd" = "" -a "$lordercmd" != "" -a "$tsortcmd" != "" ]; then objects=`$lordercmd ${objects} | $tsortcmd` fi test -f $libfnm && rm -f $libfnm cmd="$arcmd cq $libfnm ${objects}" putsnonl "CREATE ${libfnm} ..." if [ "$logfile" != "" ]; then puts "CREATE ${libfnm}" >&9 fi if [ $doecho = "T" ]; then puts "" puts $cmd fi if [ "$logfile" != "" ]; then out=`eval $cmd 2>&1` rc=$? puts "$out" >&9 if [ $doecho = T ]; then puts "$out" fi else eval $cmd rc=$? fi if [ $rc -ne 0 ]; then grc=$rc fi if [ "$ranlibcmd" != "" ]; then cmd="$ranlibcmd $libfnm" if [ $doecho = "T" ]; then puts $cmd fi if [ "$logfile" != "" ]; then eval $cmd >&9 rc=$? else eval $cmd rc=$? fi fi if [ $rc -ne 0 ]; then puts " fail" grc=$rc else puts " ok" fi fi if [ "$logfile" != "" ]; then exec 9>&- fi exit $grc di-4.47/mkconfig/bin/testfuncs.sh0000755000175000017500000000557313334050206015100 0ustar bllbll#!/bin/sh # # Copyright 2011-2018 Brad Lanam Walnut Creek, CA, USA # maindodisplay () { snm=$2 if [ "$1" = "-d" ]; then echo $snm exit 0 fi } maindoquery () { if [ "$1" = "-q" ]; then exit $2 fi } chkccompiler () { if [ "${CC}" = "" ]; then echo " no C compiler; skipped" >&5 exit 0 fi } chkdcompiler () { if [ "${DC}" = "" ]; then echo " no D compiler; skipped" >&5 exit 0 fi } getsname () { tsnm=$1 tsnm=`echo $tsnm | sed -e 's,.*/,,' -e 's,\.sh$,,'` scriptnm=${tsnm} } dosetup () { grc=0 stag="" if [ $# -eq 2 ];then stag=$1 shift fi script=$@ set -f } dorunmkc () { drmclear="-C" if [ "$1" = "-nc" ];then drmclear="" shift fi case ${script} in *mkconfig.sh) ${_MKCONFIG_SHELL} ${script} -d `pwd` \ ${drmclear} ${_MKCONFIG_RUNTESTDIR}/${scriptnm}.dat ;; *) perl ${script} ${drmclear} ${_MKCONFIG_RUNTESTDIR}/${scriptnm}.dat ;; esac if [ "$1" = "reqlibs" ]; then case $script in *mkconfig.sh) ${_MKCONFIG_SHELL} ${_MKCONFIG_RUNTOPDIR}/mkc.sh -d `pwd` -reqlib $2 ;; esac fi } chkccompile () { fn=$1 ${CC} -c ${CFLAGS} ${fn} if [ $? -ne 0 ]; then echo "## compile of ${fn} failed" grc=1 fi } chkouthcompile () { if [ $grc -eq 0 ]; then > testouth.c echo ' #include #include int main () { return 0; } ' chkccompile testouth.c fi } chkdcompile () { fn=$1 bfn=$fn bfn=`echo $fn | sed 's/\.d$//'` cmd="${_MKCONFIG_DIR}/mkc.sh -d `pwd` -complink -e -c ${DC} \ -o ${bfn}${OBJ_EXT} -- ${DFLAGS} ${fn} " eval ${cmd} if [ $? -ne 0 ]; then echo "## compile of ${fn} failed" grc=1 fi } chkdiff () { f1=$1 f2=$2 echo "## diff of $f1 $f2" diff -b $f1 $f2 rc=$? if [ $rc -ne 0 ]; then echo "## diff of $f1 $f2 failed" grc=$rc; fi } chkgrep () { pat=$1 fn=$2 arg=$3 arg2=$4 if [ "$arg" = "wc" ]; then tl=`egrep -l "$pat" ${fn} 2>/dev/null | wc -l` rc=$? if [ ${tl} -ne ${arg2} ]; then grc=1 fi else egrep -l "$pat" ${fn} >/dev/null 2>&1 rc=$? fi if [ "$arg" = "" -a $rc -ne 0 ]; then grc=$rc echo "## ${fn}: grep for '$pat' failed" fi if [ "$arg" = "neg" -a $rc -eq 0 ]; then grc=$rc echo "## ${fn}: grep for '$pat' succeeded when it should not" fi } chkouth () { xp=$1 shift chkgrep "$xp" out.h $@ } chkoutd () { xp=$1 shift chkgrep "$xp" out.d $@ } chkcache () { xp=$1 shift chkgrep "$xp" mkconfig.cache $@ } chkenv () { xp=$1 shift chkgrep "$xp" test.env $@ } testcleanup () { if [ "$stag" != "none" ]; then for x in out.h out.d testouth.c opts test.env mkconfig.log \ mkconfig.cache mkconfig.reqlibs c.env \ mkc_none_mkc.vars mkc_none_c.vars mkc_out_c.vars mkc_out_d.vars \ mkc_none_env.vars \ $@; do test -f ${x} && mv ${x} ${x}${stag} done fi } di-4.47/mkconfig/bin/mkcsetopt.sh0000755000175000017500000000147113334050206015064 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek, CA USA # # This script is used to change an option in an options file. # Usage: # mkcsetopt.sh [-o options-file] option-name value # set -f unset CDPATH # this is a workaround for ksh93 on solaris if [ "$1" = "-d" ]; then cd $2 shift shift fi . ${_MKCONFIG_DIR}/bin/shellfuncs.sh doshelltest $0 $@ OPTFILE=options.dat while test $# -gt 1; do case $1 in -o) shift OPTFILE=$1 shift ;; *) break ;; esac done opt=$1 val=$2 OPTNEW=options.new exec 8>>${OPTNEW} exec 7<&0 < ${OPTFILE} while read oline; do case $oline in ${opt}=*) oline=`echo $oline | sed "s/=.*/=${val}/"` ;; esac echo $oline >&8 done exec <&7 7<&- mv ${OPTNEW} ${OPTFILE} test -f ${OPTNEW} && rm -f ${OPTNEW} exit $rc di-4.47/mkconfig/bin/shellfuncs.sh0000755000175000017500000002016413334050206015221 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek, CA, USA # if [ ! -f "${_MKCONFIG_DIR}/VERSION" ]; then echo "Unable to locate ${_MKCONFIG_DIR}/VERSION." echo "Not a valid mkconfig installation." exit 1 fi # dash on Mandriva 2011 segfaults intermittently when: # read _MKCONFIG_VERSION < ${_MKCONFIG_DIR}/VERSION # export _MKCONFIG_VERSION # was used. _MKCONFIG_VERSION=`cat ${_MKCONFIG_DIR}/VERSION` export _MKCONFIG_VERSION # posh set command doesn't output correct data; don't bother with it. # yash has quoting/backquote issues # zsh is not bourne shell compatible # set | grep can be fixed with: set | strings | grep # and 'emulate ksh' can be set in mkconfig.sh, but there # are more issues, and I'm not interested in tracking them down. tryshell="ash bash dash ksh ksh88 ksh93 mksh pdksh sh sh5" mkconfigversion () { echo "mkconfig version ${_MKCONFIG_VERSION}" } dosubst () { subvar=$1 shift sa="" while test $# -gt 0; do pattern=$1 sub=$2 shift shift sa="${sa} -e \"s~${pattern}~${sub}~g\"" done cmd="${subvar}=\`echo \${${subvar}} | sed ${sa}\`" eval $cmd; } test_echo () { # It was suggested to use printf(). # printf does not quite work the same in the Tru64 shell. # Of course no one uses that any more... _tEN='-n' _tEC='' if [ "`echo -n test`" = "-n test" ]; then _tEN='' _tEC='\c' fi eval 'putsnonl () { echo ${_tEN} "$*"${_tEC}; }' eval 'puts () { echo "$*"; }' } test_append () { shhasappend=0 (eval 'x=a;x+=b; test z$x = zab') 2>/dev/null if [ $? -eq 0 ]; then shhasappend=1 eval 'doappend () { eval $1+=\$2; }' else eval 'doappend () { eval $1=\$${1}\$2; }' fi } test_readraw () { shreqreadraw=0 # unixware 7.14 compiles and runs this code ok, but it's shell gets # completely wacked out later. So run it in a subshell. # (similar to mandriva 2011 problem with read < file) ( rrv='aa\\\\bb' read rrx << _HERE_ $rrv _HERE_ ( eval "read -r rry <<_HERE_ $rrv _HERE_" ) 2>/dev/null yrc=$? if [ $yrc -eq 0 ]; then read -r rry << _HERE_ $rrv _HERE_ if [ "${rrx}" != 'aa\\bb' -a "${rry}" = 'aa\\\\bb' ]; then shreqreadraw=1 fi fi exit $shreqreadraw ) shreqreadraw=$? } test_math () { shhasmath=0 (eval 'x=1;y=$(($x+1)); test z$y = z2') 2>/dev/null if [ $? -eq 0 ]; then shhasmath=1 eval 'domath () { mthvar=$1; mthval=$(($2)); eval $mthvar=$mthval; }' else eval 'domath () { mthvar=$1; mthval=`expr $2`; eval $mthvar=$mthval; }' fi } test_upper () { shhasupper=0 (eval 'typeset -u xuvar;xuvar=x;test z$xuvar = zX') 2>/dev/null if [ $? -eq 0 ]; then shhasupper=1 eval 'toupper () { ucvar=$1; typeset -u ucval; eval "ucval=\${$ucvar};$ucvar=\$ucval"; }' else eval 'toupper () { ucvar=$1; cmd="$ucvar=\`echo \${$ucvar} | tr \"[a-z]\" \"[A-Z]\"\`"; eval "$cmd"; }' fi } test_lower () { shhaslower=0 (eval 'typeset -l xuvar;xuvar=X;test z$xuvar = zx') 2>/dev/null if [ $? -eq 0 ]; then shhaslower=1 eval 'tolower () { lcvar=$1; typeset -l lcval; eval "lcval=\${$lcvar};$lcvar=\$lcval"; }' else eval 'tolower () { lcvar=$1; cmd="$lcvar=\`echo \${$lcvar} | tr \"[A-Z]\" \"[a-z]\"\`"; eval "$cmd"; }' fi } testshcapability () { test_echo test_append test_readraw test_math test_upper test_lower } getshelltype () { if [ "$1" != "" ]; then trs=$1 shift fi gstecho=F if [ "$1" = echo ]; then gstecho=T fi baseshell=${_shell:-sh} # unknown or old shell=${_shell:-sh} # unknown or old if [ "$trs" != "" ]; then dispshell=`echo $trs | sed -e 's,.*/,,'` else dispshell=$shell fi ( eval 'echo ${.sh.version}' ) >/dev/null 2>&1 if [ $? -eq 0 ]; then eval 'KSH_VERSION=${.sh.version}' fi if [ "$KSH_VERSION" != "" ]; then shell=ksh baseshell=ksh shvers=$KSH_VERSION case $KSH_VERSION in *PD*) shell=pdksh ;; *93*) shell=ksh93 ;; *88*) shell=ksh88 ;; *MIRBSD*) shell=mksh ;; esac elif [ "$BASH_VERSION" != "" ]; then shvers=$BASH_VERSION ver=`echo $BASH_VERSION | sed 's/\..*//'` shell=bash${ver} baseshell=bash elif [ "$ZSH_VERSION" != "" ]; then shvers=$ZSH_VERSION shell=zsh baseshell=zsh elif [ "$POSH_VERSION" != "" ]; then shvers=$POSH_VERSION shell=posh baseshell=posh elif [ "$YASH_VERSION" != "" ]; then shvers=$YASH_VERSION shell=yash baseshell=yash fi if [ $dispshell = sh -a $dispshell != $shell ]; then dispshell="$dispshell-$shell" elif [ $dispshell = $baseshell ]; then dispshell=$shell fi # can try --version, but don't really know the path # of the shell running us; can't depend on $SHELL. # and it only works for bash and some versions of ksh. if [ $gstecho = T ]; then echo $dispshell $shvers fi } doshelltest () { # force shell type. if [ "$_MKCONFIG_SHELL" != "" ]; then if [ "$SHELL" != "$_MKCONFIG_SHELL" ]; then SHELL="$_MKCONFIG_SHELL" export SHELL loc=`pwd` s=$1 shift exec $SHELL $dstscript $s -d $loc $@ fi fi getshelltype # for display of error below chkshell if [ $? -ne 0 ]; then echo "The shell in use ($dispshell) does not have the correct functionality:" >&2 echo $chkmsg >&2 echo "Please try another shell. _MKCONFIG_SHELL can be set to the path of another shell to override /bin/sh." >&2 exit 1 fi testshcapability } locatecmd () { lvar=$1 ltcmd=$2 getpaths lcmd="" for p in $_pthlist; do if [ -x "$p/$ltcmd" ]; then lcmd="$p/$ltcmd" break fi done eval $lvar=$lcmd } # function to make sure the shell has # some basic capabilities w/o weirdness. chkshell () { doecho=F if [ "$1" = "echo" ]; then doecho=T fi grc=0 chkmsg="" # test to make sure the set command works properly # some shells output xyzzy=abc def # some shells output xyzzy='abc def' # some shells output xyzzy=$'abc def' (ok; handled in mkconfig.sh) # yash does this correctly, but has quoting/backquote issues ( cmd='xyzzy="abc def"; val=`set | grep "^xyzzy"`; test "$val" = "xyzzy=abc def"' eval $cmd 2>/dev/null if [ $? -eq 0 ]; then exit 0 fi cmd="xyzzy=\"abc def\"; val=\`set | grep \"^xyzzy\"\`; test \"\$val\" = \"xyzzy='abc def'\" -o \"\$val\" = \"xyzzy=\\$'abc def'\"" eval $cmd 2>/dev/null rc=$? exit $rc ) rc=$? if [ $rc -ne 0 ]; then grc=$rc chkmsg="${chkmsg} 'set' output not x=a b or x='a b' or x=\$'a b'." fi # test to make sure the 'set -f' command is supported. ( cmd='set -f' eval $cmd 2>/dev/null rc=$? if [ $rc -eq 0 ]; then exit 0 fi exit $rc ) rc=$? if [ $rc -ne 0 ]; then grc=$rc chkmsg="${chkmsg} 'set -f' not supported" fi if [ $doecho = "T" ]; then echo $chkmsg fi return $grc } getpaths () { if [ "$_pthlist" != "" ]; then return fi systype=`uname -s` tpthlist=`echo $PATH | sed 's/:/ /g'` # cygwin's /bin and /usr/bin are both mounted on same spot case ${systype} in CYGWIN*) d=/bin tpthlist=`echo $tpthlist | sed -e "s,^$d ,," -e "s, $d,,"` ;; esac # remove symlinks for d in $tpthlist; do if [ ! -d $d ]; then tpthlist=`echo $tpthlist | sed -e "s,^$d ,," -e "s, $d,,"` else if [ -h $d ]; then tpthlist=`echo $tpthlist | sed -e "s,^$d ,," -e "s, $d,,"` # make sure path symlink is pointing to is in the list npath=`ls -ld $d | sed 's/.*-> //'` tpthlist="$tpthlist $npath" fi fi done # remove dups _pthlist="" for d in $tpthlist; do _pthlist="$_pthlist $d" done _pthlist=`echo $_pthlist | sort -u` } initifs () { hasifs=0 if [ "$IFS" != "" ]; then OIFS="$IFS" hasifs=1 fi } setifs () { # just newline for parsing include section IFS=" " } resetifs () { if [ $hasifs -eq 1 ]; then IFS="$OIFS" else unset IFS fi } boolclean () { nm=$1 dosubst $nm '(' ' ( ' ')' ' ) ' dosubst $nm ' not ' ' ! ' ' and ' ' -a ' ' or ' ' -o ' dosubst $nm '!' ' ! ' '&&' ' -a ' '||' ' -o ' dosubst $nm ' \+' ' ' '^ *' '' ' *$' '' } di-4.47/mkconfig/bin/mkreqlib.sh0000755000175000017500000000401613334050206014657 0ustar bllbll#!/bin/sh # # Copyright 2009-2018 Brad Lanam Walnut Creek, CA USA # set -f unset CDPATH # this is a workaround for ksh93 on solaris if [ "$1" = "-d" ]; then cd $2 shift shift fi . ${_MKCONFIG_DIR}/bin/shellfuncs.sh doshelltest $0 $@ RUNTOPDIR=`pwd` CACHEFILE="mkconfig.cache" unset GREP_OPTIONS unset ENV getlibdata () { var=$1 gdname=$2 lang=$3 cmd="${var}=\${mkc_${lang}_lib_${gdname}}" eval $cmd } mkconfigversion debug=F OUTLIBFILE="mkconfig.reqlibs" while test $# -gt 1; do case $1 in -X) shift debug=T ;; -c) shift CACHEFILE=$1 shift ;; -o|-l) # -l backwards compatibility shift OUTLIBFILE=$1 shift ;; esac done CONFH=$1 ok=1 if [ ! -f "${CONFH}" ]; then echo "Unable to locate ${CONFH}" ok=0 fi if [ ! -f "$RUNTOPDIR/$CACHEFILE" ]; then echo "Unable to locate $RUNTOPDIR/$CACHEFILE" ok=0 fi if [ $ok -eq 0 ]; then exit 1 fi reqlibs="" . $RUNTOPDIR/$CACHEFILE exec 7<&0 < ${CONFH} dver=0 while read cline; do if [ $debug = T ]; then echo "cline:$cline:" fi case $cline in "#define _lib_"*1) lang=c ;; "enum bool _clib_"*" = true;") lang=d dver=2 ;; "enum bool _lib_"*" = true;") lang=d dver=2 ;; "enum : bool { _clib_"*" = true };") lang=d dver=1 ;; "enum : bool { _lib_"*" = true };") lang=d dver=1 ;; *) continue ;; esac # bash2 can't handle # in subst if [ $lang = "d" -a $dver -eq 1 ]; then dosubst cline ': ' '' '{ ' '' ' }' '' fi dosubst cline '#define ' '' ' 1' '' ' = true;' '' 'enum bool ' '' getlibdata var $cline $lang if [ $debug = T ]; then echo "cline:$cline:lang:$lang:var:$var:" fi if [ "$var" != "" ]; then echo $reqlibs | grep -- $var > /dev/null 2>&1 rc=$? if [ $rc -ne 0 ]; then doappend reqlibs " $var" if [ $debug = T ]; then echo "append:$var" fi fi fi done exec <&7 7<&- echo $reqlibs > $OUTLIBFILE di-4.47/mkconfig/units/0000755000175000017500000000000013334050206013103 5ustar bllblldi-4.47/mkconfig/units/env-msgfmt.sh0000755000175000017500000000203213334050206015522 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam, Walnut Creek, California USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # require_unit env-main # optional unit: cflags check_cmd_msgfmt () { name="$1" name=XMSGFMT printlabel $name "command: locate msgfmt" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi locatecmd xmsgfmt msgfmt locatecmd xgmsgfmt gmsgfmt mfmt="${xmsgfmt}" if [ "$_MKCONFIG_USING_GCC" = "Y" ] then mfmt="${xgmsgfmt:-${xmsgfmt}}" if [ -x "${xccpath}/msgfmt" ] then mfmt="${xccpath}/msgfmt" fi if [ -x "${xccpath}/gmsgfmt" ] then mfmt="${xccpath}/gmsgfmt" fi fi printyesno_val XMSGFMT $xmsgfmt setdata ${_MKCONFIG_PREFIX} "XMSGFMT" "${xmsgfmt}" } di-4.47/mkconfig/units/env-systype.sh0000755000175000017500000000713113334050206015752 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek, CA USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # require_unit env-main env_dolocuname=F _dolocuname () { if [ $env_dolocuname = "T" ]; then return fi locatecmd xuname uname puts "uname located: ${xuname}" >&9 env_dolocuname=T } check_system () { name="_MKCONFIG_SYS" arg=$2 uarg=$arg toupper uarg name="${name}${uarg}" _dolocuname if [ "$arg" = "type" ]; then printlabel $name "system: type" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi if [ "${xuname}" != "" ] then _MKCONFIG_SYSTYPE=`${xuname} -s` else puts "no uname, try some guessing" >&9 # no uname...we'll have to do some guessing. _MKCONFIG_SYSTYPE="unknown" if [ -f /vmunix ]; then # some sort of BSD variant _MKCONFIG_SYSTYPE="BSD" else _MKCONFIG_SYSTYPE="SYSV" # some SysV variant, probably. fi fi puts "type: ${_MKCONFIG_SYSTYPE}" >&9 printyesno_val _MKCONFIG_SYSTYPE "${_MKCONFIG_SYSTYPE}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_SYSTYPE "${_MKCONFIG_SYSTYPE}" fi if [ "$arg" = "rev" ]; then printlabel $name "system: rev" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi if [ "${xuname}" != "" ] then case ${_MKCONFIG_SYSTYPE} in AIX) tmp=`( (oslevel) 2>/dev/null || puts "not found") 2>&1` case "$tmp" in 'not found') _MKCONFIG_SYSREV="$4"."$3" ;; '<3240'|'<>3240') _MKCONFIG_SYSREV=3.2.0 ;; '=3240'|'>3240'|'<3250'|'<>3250') _MKCONFIG_SYSREV=3.2.4 ;; '=3250'|'>3250') _MKCONFIG_SYSREV=3.2.5 ;; *) _MKCONFIG_SYSREV=$tmp ;; esac ;; *) _MKCONFIG_SYSREV=`${xuname} -r` ;; esac else puts "no uname, try some guessing" >&9 # no uname...we'll have to do some guessing. _MKCONFIG_SYSREV="unknown" if [ -f /vmunix ]; then # sys/param.h might have: # #define BSD 43 # #define BSD4_3 1 rev=`grep '^#define.*BSD[^0-9]' /usr/include/sys/param.h | sed 's,/.*,,'` if [ "rev" != "" ]; then rev=`puts $rev | sed 's/^[^0-9]*\([0-9]\)\([0-9]\).*/\1.\2/'` _MKCONFIG_SYSREV="$rev" fi fi fi puts "rev: ${_MKCONFIG_SYSREV}" >&9 printyesno_val _MKCONFIG_SYSREV "${_MKCONFIG_SYSREV}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_SYSREV "${_MKCONFIG_SYSREV}" fi if [ "$arg" = "arch" ]; then printlabel $name "system: arch" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi if [ "${xuname}" != "" ] then _MKCONFIG_SYSARCH=`${xuname} -m` else puts "no uname, try some guessing" >&9 # no uname...we'll have to do some guessing. _MKCONFIG_SYSARCH="unknown" locatecmd xarch arch puts "arch located: ${xarch}" >&9 if [ "${xarch}" != "" ]; then _MKCONFIG_SYSARCH=`arch` fi fi puts "arch: ${_MKCONFIG_SYSARCH}" >&9 printyesno_val _MKCONFIG_SYSARCH "${_MKCONFIG_SYSARCH}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_SYSARCH "${_MKCONFIG_SYSARCH}" fi } di-4.47/mkconfig/units/env-cc.sh0000755000175000017500000004233213334050206014621 0ustar bllbll#!/bin/sh # # Copyright 2001-2018 Brad Lanam, Walnut Creek, California USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # require_unit env-main require_unit env-systype env_dogetconf=F _MKCONFIG_32BIT_FLAGS=F # helper routine _setflags () { while test $# -gt 0; do _tvar=$1 _tenm=$2 shift;shift eval _tval=\$$_tvar dosubst _tval '^ *' '' setdata ${_MKCONFIG_PREFIX} ${_tenm} "$_tval" done } _dogetconf () { if [ "$env_dogetconf" = T ]; then return fi if [ ${_MKCONFIG_32BIT_FLAGS} = T ]; then lfccflags= lfldflags= lflibs= env_dogetconf=T return fi locatecmd xgetconf getconf if [ z${xgetconf} != z ] then puts "using flags from getconf" >&9 lfccflags="`${xgetconf} LFS_CFLAGS 2>/dev/null`" if [ "$lfccflags" = undefined ]; then lfccflags= fi lfldflags="`${xgetconf} LFS_LDFLAGS 2>/dev/null`" if [ "$lfldflags" = undefined ]; then lfldflags= fi lflibs="`${xgetconf} LFS_LIBS 2>/dev/null`" if [ "$lflibs" = undefined ]; then lflibs= fi fi env_dogetconf=T } check_32bitflags () { _MKCONFIG_32BIT_FLAGS=T printlabel _MKCONFIG_32BIT_FLAGS "32 bit flags" printyesno_val _MKCONFIG_32BIT_FLAGS "${_MKCONFIG_32BIT_FLAGS}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_32BIT_FLAGS "${_MKCONFIG_32BIT_FLAGS}" } check_cc () { _read_option CC cc CC=${CC:-${oval}} printlabel CC "C compiler" case ${_MKCONFIG_SYSTYPE} in BeOS|Haiku) case ${CC} in cc|gcc) CC=g++ ;; esac ;; syllable) case ${CC} in cc|gcc) CC=g++ ;; esac ;; esac puts "cc:${CC}" >&9 printyesno_val CC "${CC}" setdata ${_MKCONFIG_PREFIX} CC "${CC}" if [ ${_MKCONFIG_32BIT_FLAGS} = F ]; then setdata ${_MKCONFIG_PREFIX} _MKCONFIG_32BIT_FLAGS "${_MKCONFIG_32BIT_FLAGS}" fi } check_using_gcc () { usinggcc="N" printlabel _MKCONFIG_USING_GCC "Using gcc/g++" # check for gcc... ${CC} -v 2>&1 | grep 'gcc version' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then puts "found gcc" >&9 usinggcc="Y" fi case ${CC} in *gcc*|*g++*) usinggcc="Y" ;; esac printyesno_val _MKCONFIG_USING_GCC "${usinggcc}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GCC "${usinggcc}" } check_using_clang () { usingclang="N" printlabel _MKCONFIG_USING_CLANG "Using clang" # check for clang... ${CC} -v 2>&1 | grep 'clang version' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then puts "found clang" >&9 usingclang="Y" fi case ${CC} in *clang*) usingclang="Y" ;; esac printyesno_val _MKCONFIG_USING_CLANG "${usingclang}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_CLANG "${usingclang}" } check_using_gnu_ld () { usinggnuld="N" printlabel _MKCONFIG_USING_GNU_LD "Using gnu ld" # check for gnu ld... ld -v 2>&1 | grep 'GNU ld' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then puts "found gnu ld" >&9 usinggnuld="Y" fi printyesno_val _MKCONFIG_USING_GNU_LD "${usinggnuld}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GNU_LD "${usinggnuld}" } check_cflags () { cflags_debug= cflags_optimize="-O2" cflags_include= cflags_user= cflags_compiler= cflags_system= cflags_application= if [ "${_MKCONFIG_USING_GCC}" = Y ]; then puts "set gcc flags" >&9 gccflags="-Wall -Waggregate-return -Wconversion -Wformat -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Wpointer-arith -Wshadow -Wstrict-prototypes -Wunused -Wno-unknown-pragmas" # -Wextra -Wno-unused-but-set-variable -Wno-unused-parameter case ${CC} in g++|c++) if [ "${_MKCONFIG_USING_GCC}" = Y ]; then puts "set g++ flags" >&9 gccflags="-Wall -Waggregate-return -Wconversion -Wformat -Wpointer-arith -Wshadow -Wunused" fi ;; esac doappend cflags_compiler " $gccflags" fi if [ "${_MKCONFIG_USING_CLANG}" = Y ]; then puts "set clang flags" >&9 doappend cflags_compiler " -Wno-unknown-warning-option -Weverything -Wno-padded -Wno-format-nonliteral -Wno-cast-align -Wno-system-headers -Wno-disabled-macro-expansion" fi TCC=${CC} if [ "${_MKCONFIG_USING_GCC}" = Y ]; then TCC=gcc fi case ${_MKCONFIG_SYSTYPE} in AIX) if [ "${_MKCONFIG_USING_GCC}" = N ]; then doappend cflags_system " -qhalt=e -qmaxmem=-1" case ${_MKCONFIG_SYSREV} in 4.*) doappend cflags_system " -DUSE_ETC_FILESYSTEMS=1" ;; esac fi ;; FreeBSD) # FreeBSD has many packages that get installed in /usr/local doappend cflags_include " -I/usr/local/include" ;; HP-UX) if [ "z${lfccflags}" = z -a "${_MKCONFIG_32BIT_FLAGS}" = F ]; then doappend cflags_system " -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" fi case ${TCC} in cc) case ${_MKCONFIG_SYSREV} in *.10.*) doappend cflags_system " +DAportable" ;; esac cc -v 2>&1 | grep -l Bundled > /dev/null 2>&1 rc=$? if [ $rc -ne 0 ]; then doappend cflags_system " -Ae" fi _MKCONFIG_USING_GCC=N ;; esac if [ -d /usr/local/include -a \ -d /usr/local/lib ]; then doappend cflags_include " -I/usr/local/include" fi ;; SunOS) case ${_MKCONFIG_SYSREV} in 5.*) case ${TCC} in cc) # If solaris is compile w/strict ansi, we get # a work-around for the long long type with # large files. So we compile w/extensions. doappend cflags_system " -Xa -v" # optimization; -xO3 is good. -xO4 must be set by user. cflags_optimize="-xO3" ;; esac ;; esac ;; esac # largefile flags doappend cflags_system " $lfccflags" _dogetconf # plain CFLAGS will be interpreted as the user's cflags _read_option CFLAGS "" cflags_user=$CFLAGS _read_option CFLAGS_DEBUG "" if [ "z$CFLAGS_DEBUG" != z ]; then cflags_debug="$CFLAGS_DEBUG" fi _read_option CFLAGS_OPTIMIZE "" if [ "z$CFLAGS_OPTIMIZE" != z ]; then cflags_optimize="$CFLAGS_OPTIMIZE" fi _read_option CFLAGS_INCLUDE "" doappend cflags_include " $CFLAGS_INCLUDE" doappend cflags_include " $CPPFLAGS" puts "cflags_debug:${cflags_debug}" >&9 puts "cflags_optimize:${cflags_optimize}" >&9 puts "cflags_include:${cflags_include}" >&9 puts "cflags_user:${cflags_user}" >&9 puts "cflags_compiler:${cflags_compiler}" >&9 puts "cflags_system:${cflags_system}" >&9 puts "cflags_application:${cflags_application}" >&9 _setflags \ cflags_debug CFLAGS_DEBUG \ cflags_optimize CFLAGS_OPTIMIZE \ cflags_user CFLAGS_USER \ cflags_include CFLAGS_INCLUDE \ cflags_compiler CFLAGS_COMPILER \ cflags_system CFLAGS_SYSTEM \ cflags_application CFLAGS_APPLICATION } check_addcflag () { name=$1 flag=$2 printlabel CFLAGS_APPLICATION "Add C flag: ${flag}" puts "#include main () { return 0; }" > t.c puts "# test ${flag}" >&9 # need to set w/all cflags; gcc doesn't always error out otherwise TMPF=t$$.txt setcflags ${CC} ${CFLAGS} ${flag} t.c > $TMPF 2>&1 rc=$? if [ $rc -ne 0 ]; then flag=0 fi grep -i "warning.*${flag}" $TMPF > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then flag=0 fi cat $TMPF >&9 rm -f $TMPF > /dev/null 2>&1 printyesno $name ${flag} if [ $flag != 0 ]; then doappend CFLAGS_APPLICATION " $flag" setdata ${_MKCONFIG_PREFIX} CFLAGS_APPLICATION "$CFLAGS_APPLICATION" fi } check_addldflag () { name=$1 flag=$2 printlabel LDFLAGS_APPLICATION "Add LD flag: ${flag}" setcflags setldflags setlibs puts "#include main () { return 0; }" > t.c puts "# test ${flag}" >&9 # need to set w/all cflags/ldflags; gcc doesn't always error out otherwise TMPF=t$$.txt ${CC} ${CFLAGS} ${LDFLAGS} ${flag} -o t t.c > $TMPF 2>&1 rc=$? if [ $rc -ne 0 ]; then flag=0 fi grep -i "warning.*${flag}" $TMPF > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then flag=0 fi cat $TMPF >&9 rm -f $TMPF > /dev/null 2>&1 printyesno $name ${flag} if [ $flag != 0 ]; then doappend ldflags_application " $flag" _setflags ldflags_application LDFLAGS_APPLICATION fi } check_ldflags () { TCC=${CC} if [ "${_MKCONFIG_USING_GCC}" = Y ]; then TCC=gcc fi ldflags_debug= ldflags_optimize= ldflags_user= ldflags_compiler= ldflags_system= ldflags_application= doappend ldflags_system " $lfldflags" case ${_MKCONFIG_SYSTYPE} in FreeBSD) # FreeBSD has many packages that get installed in /usr/local doappend ldflags_system " -L/usr/local/lib" ;; HP-UX) # check for libintl in other places... if [ -d /usr/local/include -a \ -d /usr/local/lib ]; then doappend ldflags_system " -L/usr/local/lib" if [ -d /usr/local/lib/hpux32 ]; then doappend ldflags_system " -L/usr/local/lib/hpux32" fi fi case ${TCC} in cc) doappend ldflags_system " -Wl,+s" ;; esac ;; OS/2) doappend ldflags_system " -Zexe" ;; SunOS) case ${_MKCONFIG_SYSREV} in 5.*) case ${TCC} in cc) case $CFLAGS_OPTIMIZE in -xO[3456]) ldflags_optimize="-fast" ;; esac ;; esac ;; esac ;; esac _dogetconf # plain LDFLAGS will be interpreted as the user's ldflags _read_option LDFLAGS "" ldflags_user=$LDFLAGS _read_option LDFLAGS_DEBUG "" if [ "z$LDFLAGS_DEBUG" != z ]; then ldflags_debug="$LDFLAGS_DEBUG" fi _read_option LDFLAGS_OPTIMIZE "" if [ "z$LDFLAGS_OPTIMIZE" != z ]; then ldflags_optimize="$LDFLAGS_OPTIMIZE" fi puts "ldflags_debug:${ldflags_debug}" >&9 puts "ldflags_optimize:${ldflags_optimize}" >&9 puts "ldflags_user:${ldflags_user}" >&9 puts "ldflags_compiler:${ldflags_compiler}" >&9 puts "ldflags_system:${ldflags_system}" >&9 puts "ldflags_application:${ldflags_application}" >&9 _setflags \ ldflags_debug LDFLAGS_DEBUG \ ldflags_optimize LDFLAGS_OPTIMIZE \ ldflags_user LDFLAGS_USER \ ldflags_compiler LDFLAGS_COMPILER \ ldflags_system LDFLAGS_SYSTEM \ ldflags_application LDFLAGS_APPLICATION } check_libs () { _dogetconf ldflags_libs_user= ldflags_libs_application= ldflags_libs_system= TCC=${CC} if [ "${_MKCONFIG_USING_GCC}" = Y ]; then TCC=gcc fi case ${_MKCONFIG_SYSTYPE} in BeOS|Haiku) # uname -m does not reflect actual architecture doappend ldflags_libs_system " -lroot -lbe" ;; esac # largefile flags doappend ldflags_libs_system " $lflibs" _read_option LIBS "" doappend ldflags_libs_user " $LIBS" puts "ldflags_libs_user:${ldflags_libs_user}" >&9 puts "ldflags_libs_application:${ldflags_libs_application}" >&9 puts "ldflags_libs_system:${ldflags_libs_system}" >&9 _setflags \ ldflags_libs_user LDFLAGS_LIBS_USER \ ldflags_libs_application LDFLAGS_LIBS_APPLICATION \ ldflags_libs_system LDFLAGS_LIBS_SYSTEM } # for backwards compatibility check_shcflags () { check_cflags_shared } check_shcflags () { printlabel CFLAGS_SHARED "shared library cflags" cflags_shared="" if [ "$_MKCONFIG_USING_GCC" != Y ]; then case ${_MKCONFIG_SYSTYPE} in CYGWIN*|MSYS*|MINGW*) doappend cflags_shared " -fPIC" ;; Darwin) doappend cflags_shared " -fno-common" ;; HP-UX) doappend cflags_shared " +Z" ;; IRIX*) doappend cflags_shared " -KPIC" ;; OSF1) # none doappend cflags_shared " -fPIC" ;; SCO_SV) doappend cflags_shared " -KPIC" ;; SunOS) doappend cflags_shared " -KPIC" ;; UnixWare) doappend cflags_shared " -KPIC" ;; *) doappend cflags_shared " -fPIC" ;; esac else doappend cflags_shared " -fPIC" fi _read_option CFLAGS_SHARED "" if [ "z$CFLAGS_SHARED" != z ]; then cflags_shared_user="${CFLAGS_SHARED}" fi printyesno_val CFLAGS_SHARED "$cflags_shared $cflags_shared_user" _setflags \ cflags_shared CFLAGS_SHARED \ cflags_shared_user CFLAGS_SHARED_USER } # for backwards compatibility check_shldflags () { check_ldflags_shared } check_ldflags_shared () { printlabel LDFLAGS_SHARED "shared library ldflags" if [ "$_MKCONFIG_USING_GCC" != Y ]; then case ${_MKCONFIG_SYSTYPE} in AIX) doappend ldflags_shared " -G" ;; HP-UX) doappend ldflags_shared " -b" ;; IRIX*) # "-shared" doappend ldflags_shared " -shared" ;; OSF1) doappend ldflags_shared " -msym -no_archive" ;; SCO_SV) doappend ldflags_shared " -G" ;; SunOS) doappend ldflags_shared " -G" ;; UnixWare) doappend ldflags_shared " -G" ;; *) doappend ldflags_shared " -shared" ;; esac else doappend ldflags_shared " -shared" fi case ${_MKCONFIG_SYSTYPE} in Darwin) doappend ldflags_shared " -dynamiclib" ;; esac _read_option LDFLAGS_SHARED "" if [ "z$LDFLAGS_SHARED" != z ]; then ldflags_shared_user="${LDFLAGS_SHARED}" fi printyesno_val LDFLAGS_SHARED "$ldflags_shared $ldflags_shared_user" _setflags \ ldflags_shared LDFLAGS_SHARED ldflags_shared_user LDFLAGS_SHARED_USER } check_sharednameflag () { printlabel SHLDNAMEFLAG "shared lib name flag" SHLDNAMEFLAG="-Wl,-soname=" if [ "$_MKCONFIG_USING_GNU_LD" != Y ]; then case ${_MKCONFIG_SYSTYPE} in Darwin) # -compatibility_version -current_version ;; HP-UX) SHLDNAMEFLAG="-Wl,+h " ;; IRIX*) # -soname ;; OSF1) # -soname ;; SunOS) SHLDNAMEFLAG="-Wl,-h " ;; esac fi printyesno_val SHLDNAMEFLAG "$SHLDNAMEFLAG" setdata ${_MKCONFIG_PREFIX} SHLDNAMEFLAG "$SHLDNAMEFLAG" } check_shareexeclinkflag () { printlabel LDFLAGS_EXEC_LINK "shared executable link flag " LDFLAGS_EXEC_LINK="-Bdynamic " if [ "$_MKCONFIG_USING_GCC" != Y ]; then case ${_MKCONFIG_SYSTYPE} in AIX) LDFLAGS_EXEC_LINK="-brtl -bdynamic " ;; Darwin) LDFLAGS_EXEC_LINK= ;; HP-UX) LDFLAGS_EXEC_LINK="+Z" ;; OSF1) LDFLAGS_EXEC_LINK="-msym -no_archive " ;; SCO_SV) LDFLAGS_EXEC_LINK= ;; SunOS) # -Bdynamic ;; UnixWare) LDFLAGS_EXEC_LINK= ;; esac fi printyesno_val LDFLAGS_EXEC_LINK "$LDFLAGS_EXEC_LINK" setdata ${_MKCONFIG_PREFIX} LDFLAGS_EXEC_LINK "$LDFLAGS_EXEC_LINK" } check_sharerunpathflag () { printlabel LDFLAGS_RUNPATH "shared run path flag " LDFLAGS_RUNPATH="-Wl,-rpath=" if [ "$_MKCONFIG_USING_GNU_LD" != Y ]; then case ${_MKCONFIG_SYSTYPE} in AIX) LDFLAGS_RUNPATH= ;; Darwin) LDFLAGS_RUNPATH= ;; HP-UX) LDFLAGS_RUNPATH="-Wl,+b " ;; IRIX*) LDFLAGS_RUNPATH="-Wl,-rpath " ;; OSF1) LDFLAGS_RUNPATH="-rpath " ;; SCO_SV) LDFLAGS_RUNPATH="-Wl,-R " ;; SunOS) LDFLAGS_RUNPATH="-Wl,-R" ;; UnixWare) LDFLAGS_RUNPATH="-Wl,-R " ;; esac fi printyesno_val LDFLAGS_RUNPATH "$LDFLAGS_RUNPATH" setdata ${_MKCONFIG_PREFIX} LDFLAGS_RUNPATH "$LDFLAGS_RUNPATH" } check_addconfig () { name=$1 evar=$2 addto=$3 printlabel ADDCONFIG "Add Config: ${evar} ${addto}" eval _tvar="\$$evar" if [ "z$_tvar" != z ]; then printyesno_val $name yes doappend $addto " $_tvar" puts "got: ${evar} ${_tvar}" >&9 eval puts "\"$addto: \$$addto\"" >&9 ucaddto=$addto toupper ucaddto _setflags $addto $ucaddto else printyesno_val $name no fi } check_findconfig () { name=$1 cfile=$2 printlabel FINDCONFIG "Search for: ${cfile}" sp= incchk= pp=`puts $PATH | sed 's/:/ /g'` for p in $HOME/local/lib /usr/local/lib /opt/local/lib $pp; do td=$p case $p in */bin) td=`puts $p | sed 's,/bin$,/lib,'` ;; esac if [ -d $td ]; then if [ -f "$td/$cfile.sh" ]; then puts "found: ${td}" >&9 sp=$td break fi fi done if [ z$sp != z ]; then printyesno_val $name yes setdata ${_MKCONFIG_PREFIX} config_${cfile} Y setdata ${_MKCONFIG_PREFIX} config_path_${cfile} $sp/$cfile . $sp/$cfile.sh ; # load the environment variables else printyesno_val $name no setdata ${_MKCONFIG_PREFIX} config_${cfile} N fi } di-4.47/mkconfig/units/env-main.sh0000755000175000017500000000332013334050206015152 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek CA USA # # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # _MKCONFIG_PREFIX=env _MKCONFIG_HASEMPTY=T _MKCONFIG_EXPORT=T preconfigfile () { pc_configfile=$1 configfile=$2 puts "#!/bin/sh" puts "# Created on: `date`" puts "# From: ${configfile}" puts "# Using: mkconfig-${_MKCONFIG_VERSION}" return } stdconfigfile () { pc_configfile=$1 return } postconfigfile () { pc_configfile=$1 return } standard_checks () { return } check_source () { nm=$1 fn=$2 tfn=$fn dosubst tfn '.*/' '' '\.' '' '-' '' name=_${nm}_${tfn} printlabel $nm "source: $fn" trc=0 val=0 if [ -f $fn ]; then trc=1 val=$fn fi printyesno $name $trc setdata ${_MKCONFIG_PREFIX} ${name} $val } output_item () { out=$1 name=$2 val=$3 case $name in _source_*) if [ $val != "0" ]; then puts ". ${val}" fi ;; _setint*|_setstr*|_opt_*) tname=$name dosubst tname '_setint_' '' '_setstr_' '' '_opt_' '' puts "${tname}=\"${val}\"" puts "export ${tname}" ;; *) puts "${name}=\"${val}\"" puts "export ${name}" ;; esac } check_test_multword () { name=$1 printlabel $name "test: multiword" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi val="word1 word2" printyesno_val $name "$val" setdata ${_MKCONFIG_PREFIX} $name "$val" } new_output_file () { return 0 } di-4.47/mkconfig/units/env-extension.sh0000755000175000017500000000407713334050206016254 0ustar bllbll#!/bin/sh # # Copyright 2001-2018 Brad Lanam, Walnut Creek, California, USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # require_unit env-main check_extension () { type=$2 name="${type}ext" eval check_${name} } check_objext () { name=OBJ_EXT printlabel $name "extension: object" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi TMPF=objext CC=${CC:-cc} > $TMPF.c puts ' #include main () { printf ("hello\n"); return 0; } ' ${CC} -c $TMPF.c > /dev/null 2>&1 # don't care about warnings... OBJ_EXT=".o" if [ -f "$TMPF.obj" ]; then puts "object extension is .obj" >&9 OBJ_EXT=".obj" else puts "object extension is .o" >&9 fi printyesno_val $name "${OBJ_EXT}" setdata ${_MKCONFIG_PREFIX} $name "${OBJ_EXT}" } check_exeext () { name=EXE_EXT printlabel $name "extension: executable" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $? -eq 0 ]; then return; fi TMPF=exeext CC=${CC:-cc} > $TMPF.c puts ' #include main () { printf ("hello\n"); return 0; } ' ${CC} -o $TMPF $TMPF.c > /dev/null 2>&1 # don't care about warnings EXE_EXT="" if [ -f "$TMPF.exe" ] then puts "executable extension is .exe" >&9 EXE_EXT=".exe" else puts "executable extension is none" >&9 fi printyesno_val $name "${EXE_EXT}" setdata ${_MKCONFIG_PREFIX} $name "${EXE_EXT}" } check_shlibext () { name=SHLIB_EXT printlabel $name "extension: shared library" SHLIB_EXT=".so" case ${_MKCONFIG_SYSTYPE} in HP-UX) SHLIB_EXT=".sl" ;; AIX) SHLIB_EXT=".a" ;; Darwin) SHLIB_EXT=".dylib" ;; CYGWIN*|MSYS*|MINGW*) SHLIB_EXT=".dll" ;; esac printyesno_val $name "$SHLIB_EXT" setdata ${_MKCONFIG_PREFIX} $name "$SHLIB_EXT" } di-4.47/mkconfig/units/c-main.sh0000755000175000017500000004153213334050206014613 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek CA USA # # # The four headers: stdio.h, stdlib.h, sys/types.h, and sys/param.h # are always checked. FreeBSD has header inclusion bugs and requires # sys/param.h. # # The keywords 'void' and 'const' are always tested. # # Prototype support is always tested. # # The following code is present in the final config.h file: # # #ifndef MKC_STANDARD_DEFS # # define MKC_STANDARD_DEFS 1 # # if ! _key_void # # define void int # # endif # # if ! _key_const # # define const # # endif # # if ! _key_void || ! _param_void_star # typedef char *_pvoid; # # else # typedef void *_pvoid; # # endif # # # ifndef _ # # if _proto_stdc # # define _(args) args # # else # # define _(args) () # # endif # # endif # #endif /* MKC_STANDARD_DEFS */ # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 4 - temporary for c-main.sh (c-main.sh) # require_unit c-support _MKCONFIG_PREFIX=c _MKCONFIG_HASEMPTY=F _MKCONFIG_EXPORT=F PH_PREFIX="mkc_ph." PH_STD=F PH_ALL=F precc=' #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif #if defined(__cplusplus) || defined (c_plusplus) # define CPP_EXTERNS_BEG extern "C" { # define CPP_EXTERNS_END } CPP_EXTERNS_BEG extern int printf (const char *, ...); CPP_EXTERNS_END #else # define CPP_EXTERNS_BEG # define CPP_EXTERNS_END #endif ' preconfigfile () { pc_configfile=$1 configfile=$2 # log all of the compiler and linker options for nm in CC CFLAGS_OPTIMIZE CFLAGS_DEBUG CFLAGS_INCLUDE CFLAGS_USER \ CFLAGS_APPLICATION CFLAGS_COMPILER CFLAGS_SYSTEM CFLAGS_SHARED \ CFLAGS_SHARED_USER LDFLAGS_OPTIMIZE LDFLAGS_DEBUG LDFLAGS_USER \ LDFLAGS_APPLICATION LDFLAGS_COMPILER LDFLAGS_SYSTEM LDFLAGS_SHARED \ LDFLAGS_LIBS_USER LDFLAGS_LIBS_APPLICATION LDFLAGS_LIBS_SYSTEM; do cmd="puts \"$nm: \${$nm}\"" eval $cmd >&9 done if [ "${CC}" = "" ]; then puts "No compiler specified" >&2 return fi puts "/* Created on: `date`" puts " From: ${configfile}" puts " Using: mkconfig-${_MKCONFIG_VERSION} */" puts '' puts "#ifndef MKC_INC_${CONFHTAGUC}_H #define MKC_INC_${CONFHTAGUC}_H 1 " } stdconfigfile () { pc_configfile=$1 puts ' #ifndef MKC_STANDARD_DEFS # define MKC_STANDARD_DEFS 1 # if ! _key_void # define void int # endif # if ! _key_void || ! _param_void_star typedef char *_pvoid; # else typedef void *_pvoid; # endif # if ! _key_const # define const # endif # ifndef _ # if _proto_stdc # define _(args) args # else # define _(args) () # endif # endif #endif /* MKC_STANDARD_DEFS */ ' } postconfigfile () { pc_configfile=$1 puts " #endif /* MKC_INC_${CONFHTAGUC}_H */" } standard_checks () { if [ "${CC}" = "" ]; then puts "No compiler specified" >&2 return fi check_hdr hdr "stdio.h" check_hdr hdr "stdlib.h" check_hdr sys "types.h" check_hdr sys "param.h" PH_STD=T check_key key "void" check_key key "const" check_param_void_star check_proto "_proto_stdc" PH_ALL=T } check_hdr () { type=$1 hdr=$2 shift;shift reqhdr=$* # input may be: ctype.h kernel/fs_info.h # storage/Directory.h nm1=`puts ${hdr} | sed -e 's,/.*,,'` nm2="_`puts $hdr | sed -e s,\^${nm1},, -e 's,^/*,,'`" nm="_${type}_${nm1}" if [ "$nm2" != "_" ]; then doappend nm $nm2 fi dosubst nm '/' '_' ':' '_' '\.h' '' case ${type} in sys) hdr="sys/${hdr}" ;; esac name=$nm file=$hdr printlabel $name "header: ${file}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="" if [ "${reqhdr}" != "" ]; then set ${reqhdr} while test $# -gt 0; do doappend code " #include <$1> " shift done fi doappend code " #include <$file> main () { return (0); } " rc=1 _c_chk_compile ${name} "${code}" std rc=$? val=0 if [ $rc -eq 0 ]; then val=${file} fi if [ "$CPPCOUNTER" != "" ]; then domath CPPCOUNTER "$CPPCOUNTER + 1" fi printyesno $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_sys () { check_hdr $@ } check_const () { constant=$2 shift;shift reqhdr=$* nm="_const_${constant}" name=$nm printlabel $name "constant: ${constant}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="" if [ "${reqhdr}" != "" ]; then set ${reqhdr} while test $# -gt 0; do doappend code " #include <$1> " shift done fi doappend code " main () { if (${constant} == 0) { 1; } return (0); } " do_c_check_compile ${name} "${code}" all } check_key () { keyword=$2 name="_key_${keyword}" printlabel $name "keyword: ${keyword}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="main () { int ${keyword}; ${keyword} = 1; return (0); }" _c_chk_compile ${name} "${code}" std rc=$? trc=0 if [ $rc -ne 0 ]; then # failure means it is reserved... trc=1 fi printyesno $name $trc setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_proto () { name=$1 printlabel $name "supported: prototypes" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code=' CPP_EXTERNS_BEG extern int foo (int, int); CPP_EXTERNS_END int bar () { int rc; rc = foo (1,1); return 0; } ' do_c_check_compile ${name} "${code}" std } check_typ () { shift type=$@ nm="_typ_${type}" dosubst nm ' ' '_' name=$nm dosubst type 'star' '*' printlabel $name "type: ${type}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code=" struct xxx { ${type} mem; }; static struct xxx v; struct xxx* f() { return &v; } main () { struct xxx *tmp; tmp = f(); return (0); } " do_c_check_compile ${name} "${code}" all } check_define () { shift def=$1 nm="_define_${def}" name=$nm printlabel $name "defined: ${def}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="int main () { #ifdef ${def} return (0); #else return (1); #endif }" _c_chk_run "$name" "$code" all rc=$? if [ $rc -eq 0 ]; then trc=1; else trc=0; fi setdata ${_MKCONFIG_PREFIX} ${name} ${trc} printyesno $name $trc } check_param_void_star () { name="_param_void_star" printlabel $name "parameter: void *" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code=" char * tparamvs (ptr) void *ptr; { ptr = (void *) NULL; return (char *) ptr; } " do_c_check_compile ${name} "${code}" all } check_printf_long_double () { name="_printf_long_double" otherlibs="-lintl" printlabel $name "printf: long double printable" code="int main (int argc, char *argv[]) { long double a; long double b; char t[40]; a = 1.0; b = 2.0; a = a / b; sprintf (t, \"%.1Lf\", a); if (strcmp(t,\"0.5\") == 0) { return (0); } return (1); }" _c_chk_run "$name" "$code" all rc=$? dlibs=$_retdlibs if [ $rc -eq 0 -a "$dlibs" != "" ]; then cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi if [ $rc -eq 0 ]; then trc=1; else trc=0; fi otherlibs="" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} printyesno $name $trc } check_member () { shift struct=$1 if [ "$struct" = "struct" ]; then shift struct="struct $1" fi if [ "$struct" = "union" ]; then shift struct="union $1" fi shift member=$1 nm="_mem_${struct}_${member}" dosubst nm ' ' '_' name=$nm printlabel $name "exists: ${struct}.${member}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="main () { ${struct} s; int i; i = sizeof (s.${member}); }" do_c_check_compile ${name} "${code}" all } check_memberxdr () { shift struct=$1 shift member=$1 nm="_memberxdr_${struct}_${member}" dosubst nm ' ' '_' name=$nm printlabel $name "member:XDR: ${struct} ${member}" # no cache _c_chk_cpp $name "" all rc=$? trc=0 if [ $rc -eq 0 ]; then st=`${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextstruct.awk ${name}.out ${struct}` if [ "$st" != "" ]; then puts " ${struct}: ${st}" >&9 tmem=`puts "$st" | grep "${member} *;\$"` rc=$? puts " found: ${tmem}" >&9 if [ $rc -eq 0 ]; then mtype=`puts $tmem | sed -e "s/ *${member} *;$//" -e 's/^ *//'` puts " type: ${mtype}" >&9 trc=1 setdata ${_MKCONFIG_PREFIX} xdr_${member} xdr_${mtype} fi fi # found the structure fi # cpp worked printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_size () { shift type=$* otherlibs="-lintl" nm="_siz_${type}" dosubst nm ' ' '_' name=$nm printlabel $name "sizeof: ${type}" code="main () { printf(\"%u\", sizeof(${type})); return (0); }" _c_chk_run ${name} "${code}" all rc=$? dlibs=$_retdlibs val=$_retval if [ $rc -ne 0 ]; then val=0 fi if [ $rc -eq 0 -a "$dlibs" != "" ]; then cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi otherlibs="" printyesno_val $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_dcl () { type=$2 var=$3 nm="_dcl_${var}" if [ "$type" = "int" ]; then check_int_declare $nm $var elif [ "$type" = "ptr" ]; then check_ptr_declare $nm $var fi } check_args () { type=$1 noconst=F if [ "$2" = "noconst" ]; then noconst=T shift fi funcnm=$2 nm="_args_${funcnm}" name=$nm printlabel $name "args: ${funcnm}" # no cache trc=0 ccount=0 oldprecc="${precc}" if [ "$_have_variadic" = "" ]; then precc="" code="#define testvariadic(...)" _c_chk_cpp _args_testvariadic "$code" all rc=$? _have_variadic=F if [ $rc -eq 0 ]; then _have_variadic=T fi fi asmdef="#define __asm__(a)" if [ $_have_variadic = T ]; then asmdef="#define __asm__(...)" fi precc="$oldprecc" doappend precc "/* get rid of most gcc-isms */ #define __asm(a) $asmdef #define __attribute__(a) #define __nonnull__(a,b) #define __restrict #define __restrict__ #if defined(__THROW) # undef __THROW #endif #define __THROW #define __const const " code="" _c_chk_cpp ${name} "/**/" all # force no-reuse due to precc. rc=$? precc="${oldprecc}" if [ $rc -eq 0 ]; then egrep "[ *]${funcnm}[ ]*\(" $name.out >/dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then trc=1 fi # have a declaration if [ $trc -eq 1 ]; then dcl=`${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextdcl.awk ${name}.out ${funcnm}` # make single line, use no quotes # remove carriage returns...msys2 sometimes has them embedded. # \r is not recognized by older shells, use tr. dcl=`puts $dcl | tr '\r' ' '` # extern will be replaced # ; may or may not be present, so remove it. cmd="dcl=\`puts \"\$dcl\" | sed -e 's/extern *//' -e 's/;//' \`" eval $cmd puts "## dcl(A): ${dcl}" >&9 cmd="dcl=\`puts \"\$dcl\" | sed -e 's/( *void *)/()/' \`" eval $cmd puts "## dcl(C): ${dcl}" >&9 c=`puts "${dcl}" | sed 's/[^,]*//g'` ccount=`putsnonl "$c" | wc -c` domath ccount "$ccount + 1" # 0==1 also, unfortunately c=`puts "${dcl}" | sed 's/^[^(]*(//'` c=`puts "${c}" | sed 's/)[^)]*$//'` puts "## c(E): ${c}" >&9 val=1 while test "${c}" != ""; do tmp=$c tmp=`puts "${c}" | sed -e 's/ *,.*$//' -e 's/[ ]/ /g'` dosubst tmp 'struct ' 'struct#' 'union ' 'union#' 'enum ' 'enum#' # only do the following if the names of the variables are declared puts "${tmp}" | grep ' ' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then tmp=`puts "${tmp}" | sed -e 's/ *[A-Za-z0-9_]*$//'` fi dosubst tmp 'struct#' 'struct ' 'union#' 'union ' 'enum#' 'enum ' if [ $noconst = T ]; then tmp=`puts "${tmp}" | sed -e 's/const *//'` fi puts "## tmp(F): ${tmp}" >&9 nm="_c_arg_${val}_${funcnm}" setdata ${_MKCONFIG_PREFIX} ${nm} "${tmp}" domath val "$val + 1" c=`puts "${c}" | sed -e 's/^[^,]*//' -e 's/^[ ,]*//'` puts "## c(G): ${c}" >&9 done c=`puts "${dcl}" | sed -e 's/[ ]/ /g' \ -e "s/\([ \*]\)${funcnm}[ (].*/\1/" \ -e 's/^ *//' \ -e 's/ *$//'` puts "## c(T0): ${c}" >&9 if [ $noconst = T ]; then c=`puts "${c}" | sed -e 's/const *//'` fi puts "## c(T1): ${c}" >&9 nm="_c_type_${funcnm}" setdata ${_MKCONFIG_PREFIX} ${nm} "${c}" fi fi printyesno_val $name $ccount "" nm="_args_${funcnm}" setdata ${_MKCONFIG_PREFIX} ${nm} ${ccount} } check_int_declare () { name=$1 function=$2 printlabel $name "declared: ${function}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="main () { int x; x = ${function}; }" do_c_check_compile ${name} "${code}" all } check_ptr_declare () { name=$1 function=$2 printlabel $name "declared: ${function}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="main () { void *x; x = ${function}; }" do_c_check_compile ${name} "${code}" all } check_npt () { func=$2 req=$3 has=1 if [ "${req}" != "" ]; then getdata has ${_MKCONFIG_PREFIX} "${req}" fi nm="_npt_${func}" name=$nm proto=$func printlabel $name "need prototype: ${proto}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi if [ ${has} -eq 0 ]; then setdata ${_MKCONFIG_PREFIX} ${name} 0 printyesno $name 0 return fi code=" CPP_EXTERNS_BEG struct _TEST_struct { int _TEST_member; }; extern struct _TEST_struct* ${proto} _((struct _TEST_struct*)); CPP_EXTERNS_END " do_c_check_compile ${name} "${code}" all } check_lib () { func=$2 shift;shift otherlibs=$* nm="_lib_${func}" name=$nm rfunc=$func dosubst rfunc '_dollar_' '$' if [ "${otherlibs}" != "" ]; then printlabel $name "function: ${rfunc} [${otherlibs}]" # code to check the cache for which libraries is not written else printlabel $name "function: ${rfunc}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi fi trc=0 # unfortunately, this does not work if the function # is not declared. code=" CPP_EXTERNS_BEG typedef int (*_TEST_fun_)(); static _TEST_fun_ i=(_TEST_fun_) ${func}; CPP_EXTERNS_END main () { i(); return (i==0); } " _c_chk_link_libs ${name} "${code}" all rc=$? dlibs=$_retdlibs if [ $rc -eq 0 ]; then trc=1 fi tag="" if [ $rc -eq 0 -a "$dlibs" != "" ]; then tag=" with ${dlibs}" cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi if [ ${trc} -eq 0 -a "$_MKCONFIG_TEST_EXTERN" != "" ]; then # Normally, we don't want to do this, as # on some systems we can get spurious errors # where the lib does not exist and the link works! # On modern systems, this simply isn't necessary. code=" CPP_EXTERNS_BEG extern int ${func}(); typedef int (*_TEST_fun_)(); static _TEST_fun_ i=(_TEST_fun_) ${func}; CPP_EXTERNS_END main () { i(); return (i==0); } " _c_chk_link_libs ${name} "${code}" all rc=$? dlibs=$_retdlibs if [ $rc -eq 0 ]; then trc=1 fi tag="" if [ $rc -eq 0 -a "$dlibs" != "" ]; then tag=" with ${dlibs}" cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi fi otherlibs="" printyesno $name $trc "$tag" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} return $trc } check_class () { class=$2 shift;shift otherlibs=$* nm="_class_${class}" dosubst nm '/' '_' ':' '_' name=$nm trc=0 code=" main () { ${class} testclass; } " if [ "$otherlibs" != "" ]; then printlabel $name "class: ${class} [${otherlibs}]" else printlabel $name "class: ${class}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi fi _c_chk_link_libs ${name} "${code}" all rc=$? if [ $rc -eq 0 ]; then trc=1 fi tag="" if [ $rc -eq 0 -a "${dlibs}" != "" ]; then tag=" with ${dlibs}" cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi otherlibs="" printyesno $name $trc "$tag" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } output_item () { out=$1 name=$2 val=$3 tval=0 if [ "$val" != "0" ]; then tval=1 fi case ${name} in _setint_*) tname=$name dosubst tname '_setint_' '' puts "#define ${tname} ${val}" ;; _setstr_*|_opt_*|_cmd_loc_*) tname=$name dosubst tname '_setstr_' '' '_opt_' '' puts "#define ${tname} \"${val}\"" ;; _hdr_*|_sys_*|_command_*) puts "#define ${name} ${tval}" ;; *) # _c_arg, _c_type go here also puts "#define ${name} ${val}" ;; esac } new_output_file () { return 0 } di-4.47/mkconfig/units/d-main.sh0000755000175000017500000012372313334050206014617 0ustar bllbll#!/bin/sh # # Copyright 2011-2018 Brad Lanam Walnut Creek CA USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for d-main.sh (d-main.sh) # 4 - temporary for d-main.sh (d-main.sh) # require_unit d-support require_unit c-support _MKCONFIG_PREFIX=d _MKCONFIG_HASEMPTY=F _MKCONFIG_EXPORT=F PH_PREFIX="mkc_ph." PH_STD=F PH_ALL=F PI_PREFIX="mkc_pi." PI_ALL=F chdr_standard_done=F ENUM1="" ENUM2="" ENUM3="" if [ "$DVERSION" = 1 ]; then ENUM1=": " ENUM2="{ " ENUM3=" }" fi _init_var_lists () { cdefs="" cdcls="" ctypes="" cstructs="" cmacros="" daliases="" dasserts="" modname="" } _create_enum () { out=F type=$1 if [ $type = "-o" ]; then out=T shift type=$1 fi var=$2 val=$3 estr="enum " e1=$ENUM1 e2=$ENUM2 e3=$ENUM3 strq="" if [ $type = string ]; then strq="\"" if [ "$DVERSION" = 1 ]; then estr="" e1="" e2="" e3="" fi fi if [ $type = double ]; then if [ "$DVERSION" = 1 ]; then estr="" e1="" e2="" e3="" fi fi tenum="${estr}${e1}${type} ${e2}${var} = ${strq}${val}${strq}${e3};" if [ $out = T ]; then puts $tenum fi } modify_ctypes () { tmcnm1=$1 tcode1=$2 # modify c types cmd=" sed -e 's/[ ]long[ ]*int[ ]/ long /g;# still C' \ -e 's/[ ]short[ ]*int\([ *]\)/ short\1/g;# still C' \ -e 's/[ ]signed[ ]*/ /g;# still C' \ -e 's/[ ]long[ ]*double\([ *]\)/ xlongdx\1/g' \ -e 's/double\([ *]\)/xdoublex\1/g' \ -e 's/float\([ *]\)/xfloatx\1/g' \ -e 's/unsigned[ ]long[ ]*long\([ *]\)/uxlonglongx\1/g' \ -e 's/long[ ]*long\([ *]\)/xlonglongx\1/g' \ -e 's/unsigned[ ]*short\([ *]\)/uxshortx\1/g' \ -e 's/unsigned[ ]*char\([ *]\)/uxbytex\1/g' \ -e 's/unsigned[ ]*int\([ *]\)/uxintx\1/g' \ -e 's/unsigned[ ]*long\([ *]\)/uxlongx\1/g' \ -e 's/[ ]unsigned\([ *]\)/ uxintx\1/g; # unsigned w/o any type' \ -e 's/[ ]char\([ *]\)/ xcharx\1/g' \ -e 's/[ ]short\([ *]\)/ xshortx\1/g' \ -e 's/[ ]int\([ *]\)/ xintx\1/g' \ -e 's/[ ]long\([ *]\)/ xlongx\1/g' \ | sed -e 's/xlongdx/${_c_long_double}/g' \ -e 's/xdoublex/${_c_double}/g' \ -e 's/xfloatx/${_c_float}/g' \ -e 's/xlonglongx/${_c_long_long}/g' \ -e 's/xlongx/${_c_long}/g' \ -e 's/xintx/${_c_int}/g' \ -e 's/xshortx/${_c_short}/g' \ -e 's/xcharx/${_c_char}/g' \ -e 's/xbytex/byte/g' " puts "##### modify_ctypes" >&9 # puts "##### modify_ctypes: before" >&9 # puts "$tcode1" >&9 # puts "##### modify_ctypes: end before" >&9 # puts "##### modify_ctypes: $cmd" >&9 eval "${tmcnm1}=\`puts \"\${tcode1}\" | ${cmd}\`" >&9 2>&9 # puts "#### modify_ctypes: after" >&9 # eval "puts \"\$${tmcnm1}\"" >&9 # puts "#### modify_ctypes: end after" >&9 } modify_cchglist () { tmcnm2=$1 tcode2=$2 puts "##### modify_cchglist" >&9 # puts "##### modify_cchglist: before" >&9 # puts "$tcode2" >&9 # puts "##### modify_cchglist: end before" >&9 cmd="sed ${cchglist2} -e 's/a/a/;# could be empty'" # puts "##### modify_cchglist: $cmd" >&9 eval "tcode2=\`puts \"\${tcode2}\" | ${cmd}\`" >&9 2>&9 cmd="sed ${cchglist1} -e 's/a/a/;# could be empty'" # puts "##### modify_cchglist: $cmd" >&9 eval "tcode2=\`puts \"\${tcode2}\" | ${cmd}\`" >&9 2>&9 # puts "#### modify_cchglist: after" >&9 # puts "${tcode2}" >&9 # puts "#### modify_cchglist: end after" >&9 eval "${tmcnm2}=\"\${tcode2}\"" } modify_ccode () { tmcnm3=$1 tcode3=$2 puts "##### modify_ccode" >&9 # puts "##### modify_ccode: before" >&9 # puts "$tcode3" >&9 # puts "##### modify_ccode: end before" >&9 cmd=" sed -e 's/[ ][ ]*/ /g;# clean up spacing' \ -e 's,/\*[^\*]*\*/,,;# remove /* comments' \ -e 's,//.*$,,;# remove // comments' \ -e '# change sizeof(v) to v.sizeof' \ -e 's/sizeof[ ]*\(([^)]*)\)/\1.sizeof/g' \ -e '# remove gcc-isms' \ -e 's/__extension__//g;# gcc-ism' \ -e 's/__const\([^a-zA-Z0-9_]\)/\1/g;# gcc-ism' \ -e 's/\*[ ]*const/*/g; # not handled: change *const to *' \ -e '# change version to version_ (reserved keyword)' \ -e 's/\([^a-zA-Z0-9_]\)version\([^a-zA-Z0-9_]\)/\1version_\2/g' \ -e '# remove spacing before braces' \ -e 's/[ ]*\([{}]\)/ \1/;' \ " # puts "##### modify_ccode: ${cmd}" >&9 eval "tcode3=\`puts \"\${tcode3}\" | ${cmd} \`" >&9 2>&9 # puts "#### modify_ccode: after A" >&9 # puts "${tcode3}" >&9 # puts "#### modify_ccode: end after A" >&9 modify_cchglist tcode3 "${tcode3}" cmd="sed -e '# handle multi-line statements' \ -e '# next lines append any line w/o semicolon or open brace' \ -e '# this is necessary for the function conversion to work.' \ -e '/^[^;{]*$/ N' \ -e '/^[^;{]*$/ N' \ -e '/^[^;{]*$/ N' \ -e '/^[^;{]*$/ N' \ -e '/^[^;{]*$/ N' \ -e '# convert functions' \ -e 's/^\(.*\)([ ]*\*[ ]*\([a-zA-Z0-9_][a-zA-Z0-9_]*\)[ ]*)[ ]*(\(.*\))[^(),a-zA-Z0-9_*]*;/\1 function(\3) \2;/' \ -e 's/^\(.*alias.*\)[ ][ *]*\([a-zA-Z0-9_][a-zA-Z0-9_]*\)[ ][ ]*(\(.*\))[^(),a-zA-Z0-9_*]*;/\1 function(\3) \2;/' \ -e '# change (void) to ()' \ -e 's/( *void *)/()/' \ -e '# no const functions' \ -e 's/^ *const\( *\)/\1/' \ | sed -e '# leading double underscores are not allowed' \ -e 's/\([ \*]\)__/\1_t_/g' \ -e 's/_t_FILE__/__FILE__/g; # revert' \ -e 's/_t_LINE__/__LINE__/g; # revert' \ -e '# change casts...these do not have the word function...' \ -e '/function/! s/\(([ ]*[a-zA-Z_][a-zA-Z0-9_]*[ *]*)[ ]*[a-zA-Z0-9_(]\)/cast\1/g' \ | sed -e '/^_END_;$/d; # workaround for sed N above' " # puts "##### modify_ccode: ${cmd}" >&9 # add _END_; as workaround for sed N above eval "tcode3=\`puts \"\${tcode3} _END_;\" | ${cmd} \`" >&9 2>&9 if [ "$DVERSION" = 1 ]; then cmd="sed -e 's/const *//g; # remove all const'" eval "tcode3=\`puts \"\${tcode3}\" | ${cmd} \`" >&9 2>&9 fi # puts "#### modify_ccode: after B" >&9 # puts "${tcode3}" >&9 # puts "#### modify_ccode: end after B" >&9 eval "${tmcnm3}=\"\${tcode3}\"" } dump_ccode () { ccode="" if [ "${cdefs}" != "" ]; then doappend ccode "${cdefs}" fi if [ "${ctypes}" != "" ]; then doappend ccode " extern (C) { ${ctypes} } // extern (C) " fi if [ "${cstructs}" != "" ]; then doappend ccode " extern (C) { ${cstructs} } // extern (C) " fi if [ "${cdcls}" != "" ]; then doappend ccode " extern (C) { ${cdcls} } // extern (C) " fi if [ "${ccode}" != "" ]; then # handle types separately; don't want to do this on converted macros modify_ctypes ccode "${ccode}" fi if [ "${cmacros}" != "" ]; then # macros don't get wrapped in extern(C). They are helper functions, # not replacements. doappend ccode " ${cmacros} " fi if [ "${ccode}" != "" ]; then puts "" modify_ccode ccode "${ccode}" puts "${ccode}" fi if [ "${daliases}" != "" ]; then puts "${daliases}" fi if [ "${dasserts}" != "" ]; then puts "${dasserts}" fi } create_chdr_nm () { chvar=$1 thdr=$2 tnm=$thdr # dots are for relative pathnames... dosubst tnm '/' '_' ':' '_' '\.h' '' '\.' '' case $tnm in sys_*) tnm="_${tnm}" ;; *) tnm="_hdr_${tnm}" ;; esac eval "$chvar=${tnm}" } preconfigfile () { pc_configfile=$1 configfile=$2 puts "DC: ${DC}" >&9 puts "DVERSION: ${DVERSION}" >&9 puts "DFLAGS: ${DFLAGS}" >&9 puts "LDFLAGS: ${LDFLAGS}" >&9 puts "LIBS: ${LIBS}" >&9 puts "DC_OF: ${DC_OF}" >&9 puts "// Created on: `date`" puts "// From: ${configfile}" puts "// Using: mkconfig-${_MKCONFIG_VERSION}" if [ "$modname" != "" ]; then puts '' puts "module $modname;" fi if [ "$DVERSION" = 2 ]; then getdata tval ${_MKCONFIG_PREFIX} '_import_std_string' if [ "$tval" != "0" -a "$tval" != "" ]; then puts '' puts "import std.string;" fi fi getdata tval ${_MKCONFIG_PREFIX} '_type_string' if [ "$tval" = "0" ]; then puts "alias char[] string;" fi if [ "${_MKCONFIG_SYSTYPE}" != "" ]; then _create_enum -o string SYSTYPE "${_MKCONFIG_SYSTYPE}" fi cmd="dump_ccode" if [ $noprefix = T ]; then cmd="$cmd | sed -e 's/C_ST_//g' -e 's/C_ENUM_//g' -e 's/C_UN_//'g \ -e 's/C_TYP_//g' -e 's/C_MACRO_//g' " fi eval $cmd if [ "${DC}" = "" ]; then puts "No compiler specified" >&2 return fi } stdconfigfile () { pc_configfile=$1 } postconfigfile () { pc_configfile=$1 } standard_checks () { if [ "${DC}" = "" ]; then puts "No compiler specified" >&2 return fi check_import import std.string check_type type string check_tangolib # this will be output as an enum also. setdata ${_MKCONFIG_PREFIX} _setint_D_VERSION ${DVERSION} } check_type () { shift type=$@ nm="_type_${type}" dosubst nm ' ' '_' name=$nm dosubst type 'star' '*' printlabel $name "type: ${type}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code=" ${type} value; struct xxx { ${type} mem; }; static xxx v; xxx* f() { return &v; }; int main () { xxx *tmp; tmp = f(); return (0); } " do_d_check_compile ${name} "${code}" all } check_tangolib () { tname=_d_tango_lib printlabel $tname "Tango lib:" checkcache ${_MKCONFIG_PREFIX} $tname if [ $rc -eq 0 ]; then return; fi code=" import tango.io.Stdout; int main () { Stdout (\"hello world\"); return (0); } " do_d_check_compile ${tname} "${code}" all } check_import () { type=$1 imp=$2 shift;shift reqimp=$* nm1=`puts ${imp} | sed -e 's,/.*,,'` nm2="_`puts $imp | sed -e \"s,^${nm1},,\" -e 's,^/*,,'`" nm="_${type}_${nm1}" if [ "$nm2" != "_" ]; then doappend nm $nm2 fi dosubst nm '/' '_' '\.' '_' name=$nm file=$imp printlabel $name "import: ${file}" # no cache check code="" if [ "${reqimp}" != "" ]; then set ${reqimp} while test $# -gt 0; do doappend code "import $1; " shift done fi doappend code "import $file; int main (char[][] args) { return 0; } " rc=1 > ${name}.d # re-init file _d_chk_compile ${name} "${code}" std rc=$? val=0 if [ $rc -eq 0 ]; then val=${file} fi printyesno $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_member () { shift struct=$1 shift member=$1 nm="_mem_${struct}_${member}" dosubst nm ' ' '_' name=$nm printlabel $name "exists: ${struct}.${member}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="void main (char[][] args) { ${struct} stmp; int i; i = stmp.${member}.sizeof; }" do_d_check_compile ${name} "${code}" all } check_size () { shift type=$* nm="_siz_${type}" dosubst nm ' ' '_' name=$nm getdata tangoval ${_MKCONFIG_PREFIX} '_d_tango_lib' printlabel $name "sizeof: ${type}" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi if [ $tangoval -eq 0 ]; then code="import std.stdio; void main (char[][] args) { writef(\"%d\", (${type}).sizeof); }" else code="import tango.io.Stdout; void main (char[][] args) { Stdout ((${type}).sizeof); }" fi _d_chk_run ${name} "${code}" all rc=$? val=$_retval if [ $rc -ne 0 ]; then val=0 fi printyesno_val $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_lib () { func=$2 shift;shift libs=$* nm="_lib_${func}" otherlibs=${libs} name=$nm rfunc=$func dosubst rfunc '_dollar_' '$' if [ "${otherlibs}" != "" ]; then printlabel $name "function: ${rfunc} [${otherlibs}]" # code to check the cache for which libraries is not written else printlabel $name "function: ${rfunc}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi fi trc=0 code="int main (char[][] args) { auto f = ${rfunc}; return (is(typeof(${rfunc}) == return)); }" _d_chk_run ${name} "${code}" all rc=$? if [ $rc -eq 1 ]; then rc=0 else rc=1 fi dlibs=$_retdlibs if [ $rc -eq 0 ]; then trc=1 fi tag="" if [ $rc -eq 0 -a "$dlibs" != "" ]; then tag=" with ${dlibs}" cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi printyesno $name $trc "$tag" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_class () { class=$2 shift;shift libs=$* nm="_class_${class}" dosubst nm '/' '_' ':' '_' otherlibs=${libs} name=$nm trc=0 if [ "$otherlibs" != "" ]; then printlabel $name "class: ${class} [${otherlibs}]" else printlabel $name "class: ${class}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi fi code="void main (char[][] args) { ${class} testclass; testclass = new ${class}; }" _d_chk_link_libs ${name} "${code}" all rc=$? if [ $rc -eq 0 ]; then trc=1 fi tag="" if [ $rc -eq 0 -a "${dlibs}" != "" ]; then tag=" with ${dlibs}" cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi printyesno $name $trc "$tag" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } _map_int_csize () { nm=$1 eval "tnm=_csiz_${nm}" getdata tval ${_MKCONFIG_PREFIX} $tnm mval="" if [ $tval -eq 1 ]; then mval=char; fi # leave char as char if [ $tval -eq 2 ]; then mval=short; fi if [ $tval -eq 4 ]; then mval=int; fi if [ $tval -eq 8 ]; then mval=long; fi if [ "$mval" = "" ]; then mval=long; fi doappend daliases "alias ${mval} C_NATIVE_${nm}; " eval "_c_${nm}=${mval}" if [ ${nm} != char ]; then doappend daliases "alias u${mval} C_NATIVE_unsigned_${nm}; " eval "_c_unsigned_${nm}=u${mval}" fi } _map_float_csize () { nm=$1 eval "tnm=_csiz_${nm}" getdata tval ${_MKCONFIG_PREFIX} $tnm mval="" if [ $tval -eq 4 ]; then mval=float; fi if [ $tval -eq 8 ]; then mval=double; fi if [ $tval -eq 12 ]; then mval=real; fi if [ "$mval" = "" ]; then mval=real; fi doappend daliases "alias ${mval} C_NATIVE_${nm}; " eval "_c_${nm}=${mval}" } # the rest of the check() routines are for the C/D language interface. check_csizes () { check_csize int char check_csize int short check_csize int int check_csize int long check_csize int "long long" check_csize float float check_csize float double check_csize float "long double" _map_int_csize char _map_int_csize short _map_int_csize int _map_int_csize long _map_int_csize long_long _map_float_csize float _map_float_csize double _map_float_csize long_double } check_csize () { basetype=$1 shift type=$* nm="_csiz_${type}" dosubst nm ' ' '_' name=$nm printlabel $name "c-sizeof: ${type}" checkcache_val ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="main () { printf(\"%u\", sizeof(${type})); return (0); }" _c_chk_run ${name} "${code}" all rc=$? val=$_retval if [ $rc -ne 0 ]; then val=0 fi printyesno_val $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_clib () { func=$2 shift;shift libs=$* nm="_clib_${func}" otherlibs=${libs} name=$nm rfunc=$func dosubst rfunc '_dollar_' '$' if [ "${otherlibs}" != "" ]; then printlabel $name "c-function: ${rfunc} [${otherlibs}]" # code to check the cache for which libraries is not written else printlabel $name "c-function: ${rfunc}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi fi trc=0 code=" extern (C) { void ${rfunc}(); } alias int function () _TEST_fun_; _TEST_fun_ i= cast(_TEST_fun_) &${rfunc}; void main (char[][] args) { i(); } " _d_chk_link_libs ${name} "${code}" all rc=$? dlibs=$_retdlibs if [ $rc -eq 0 ]; then trc=1 fi tag="" if [ $rc -eq 0 -a "$dlibs" != "" ]; then tag=" with ${dlibs}" cmd="mkc_${_MKCONFIG_PREFIX}_lib_${name}=\"${dlibs}\"" eval $cmd fi printyesno $name $trc "$tag" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_chdr () { chdrargs=$@ if [ $chdr_standard_done = F ]; then _check_chdr chdr "stdio.h" _check_chdr chdr "stdlib.h" _check_chdr csys "types.h" _check_chdr csys "param.h" PH_STD=T PH_ALL=T chdr_standard_done=T fi _check_chdr $chdrargs } _check_chdr () { type=$1 hdr=$2 shift;shift reqhdr=$* case ${type} in csys) hdr="sys/${hdr}" ;; esac create_chdr_nm nm $hdr name=$nm printlabel $name "c-header: ${hdr}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="" if [ "${reqhdr}" != "" ]; then set ${reqhdr} while test $# -gt 0; do doappend code " #include <$1> " shift done fi doappend code "#include <${hdr}> main () { return (0); } " _c_chk_compile ${name} "${code}" std rc=$? val=0 if [ $rc -eq 0 ]; then val=${hdr} fi if [ "$CPPCOUNTER" != "" ]; then domath CPPCOUNTER "$CPPCOUNTER + 1" fi printyesno $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_csys () { check_chdr $@ } check_cdefine () { btype=$2 defname=$3 shift;shift;shift nm="_cdefine_${defname}" name=$nm printlabel $name "c-define ($btype): ${defname}" # no cache case $btype in short) o="%d" btype2=${_c_short} ;; int) o="%d" btype2=${_c_int} ;; long) o="%ld" btype2=${_c_long} ;; longlong) o="%lld" btype2=${_c_long_long} ;; hexshort) o="0x%x" btype2=${_c_short} ;; hex) o="0x%x" btype2=${_c_int} ;; hexlong) o="0x%lx" btype2=${_c_long} ;; hexlonglong) o="0x%llx" btype2=${_c_long_long} ;; float) o="%g" btype2=double ;; string) o="%s" btype2=string ;; char) o="%s" btype2=char ;; esac suffix="" if [ $btype2 = long ]; then suffix=L fi code="int main () { printf (\"${o}${suffix}\", ${defname}); return (0); }" _c_chk_run ${name} "${code}" all rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi val=$_retval trc=0 if [ $rc -eq 0 -a "$val" != "" ]; then _create_enum ${btype2} ${defname} "${val}" trc=1 doappend cdefs "${tenum} " fi printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_ctype () { type=$2 typname=$3 shift;shift;shift nm="_ctype_${typname}" name=$nm printlabel $name "c-type ($type): ${typname}" # no cache val=0 u="" code="int main () { printf (\"%u\", sizeof(${typname})); return (0); }" _c_chk_cpp ${name} "${code}" all rc=$? if [ $rc -eq 0 ]; then tdata=`egrep ".*typedef.*[ \*]+${typname}[ ]*;" $name.out 2>/dev/null | sed -e 's/ *__attribute__ *(.*) *//' ` rc=$? if [ $rc -eq 0 ]; then _c_chk_run ${name} "${code}" all rc=$? val=$_retval fi fi if [ $rc -eq 0 ]; then code="int main () { int rc; ${typname} ww; ww = ~ 0; rc = ww < 0 ? 0 : 1; printf (\"%d\", rc); return (0); }" _c_chk_run ${name}_uchk "${code}" all rc=$? uval=$_retval if [ $rc -ne 0 ]; then uval=0 fi if [ $uval -eq 1 ]; then u=u fi fi if [ $type = int -a $rc -eq 0 ]; then case $val in 1) dtype=byte ;; 2) dtype=short ;; 4) dtype=int ;; *) dtype=long ;; esac fi if [ $type = float -a $rc -eq 0 ]; then case $val in 4) dtype=float ;; 8) dtype=double ;; *) dtype=real ;; esac fi if [ $rc -eq 0 ]; then ntypname=$typname ntypname=C_TYP_${ntypname} if [ $noprefix = F -o ${dtype} != ${ntypname} ]; then doappend daliases "alias ${u}${dtype} ${ntypname}; " fi doappend dasserts "static assert ((${ntypname}).sizeof == ${val}); " doappend cchglist1 "-e 's/\([^a-zA-Z0-9_]\)${typname}\([^a-zA-Z0-9_]\)/\1${ntypname}\2/g' " fi printyesno_val $name $val "" setdata ${_MKCONFIG_PREFIX} ${name} ${val} } check_ctypedef () { type=$1 typname=$2 shift;shift nm="_ctypedef_${typname}" name=$nm printlabel $name "c-typedef: ${typname}" # no cache # check and see if typedef already done by cstruct. # check and make sure cstruct was executed. getdata tval ${_MKCONFIG_PREFIX} $name puts "## chk:got:$tval: for $name" >&9 if [ "$tval" != 0 -a "$tval" != 1 -a "$tval" != "" ]; then getdata ttval ${_MKCONFIG_PREFIX} _cstruct_$tval puts "## chk:got:$ttval: for _cstruct_$tval" >&9 if [ "$ttval" = 1 ]; then puts "## already done by cstruct" >&9 # reset data to 1. setdata ${_MKCONFIG_PREFIX} ${name} 1 printyesno $name "already" return fi fi trc=0 code="" _c_chk_cpp ${name} "" all rc=$? if [ $rc -eq 0 ]; then tdata=`${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcexttypedef.awk ${name}.out ${typname}` tdata=`puts $tdata` # make single line. puts "## tdata(0): ${tdata}" >&9 if [ "$tdata" != "" ]; then trc=1 tdata=`puts $tdata | sed -e \ 's/^\(.*\)([ *]*\([a-zA-Z0-9_][a-zA-Z0-9_]*\)[ ]*)[ ]*(\(.*\))[ ]*;/\1 function(\3) \2;/' \ -e 's/[ ]*;/;/'` puts "## tdata(B): ${tdata}" >&9 dosubst tdata typedef alias puts "## tdata(c): ${tdata}" >&9 tta=a ttb=b if [ $noprefix = T ]; then ttl=`puts $tdata | sed 's/^alias *[sue][trucniom]* *\([a-zA-Z0-9_]*\) *\([a-zA-Z0-9_]*\);/\1 \2/'` set $ttl if [ $# -eq 2 ]; then tta=$1 ttb=$2 fi fi if [ $tta != $ttb ]; then doappend ctypes "$tdata " fi fi fi printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } _findheader () { fhpat=$1 shift # need path to header file if [ "$cmpaths" = "" ]; then cmpaths="/usr/include . " if [ "$CFLAGS" != "" ]; then next=F for f in $CFLAGS; do if [ $next = T ]; then doappend cmpaths ' ' doappend cmpaths $f fi next=F case $f in -I*) if [ $f = "-I" ]; then next=T else dosubst f '-I' '' doappend cmpaths ' ' doappend cmpaths $f fi ;; esac done fi fi fhrc=0 while test $# -gt 0; do thdr=$1 case $thdr in *.h) create_chdr_nm nhdr $thdr getdata vhdr ${_MKCONFIG_PREFIX} $nhdr puts " checking $thdr : $nhdr : $vhdr " >&9 if [ "${vhdr}" != "0" -a "${vhdr}" != "" ]; then for p in $cmpaths; do puts " checking $p/$thdr for $fhpat" >&9 if [ -f $p/$thdr ]; then egrep "$fhpat" $p/$thdr >/dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then fhrc=1 fhdr=$p/$thdr puts " found $fhdr for $mname" >&9 break fi fi done fi ;; *) break ;; esac shift done } check_cmacro () { mname=$2 shift;shift nm="_cmacro_${mname}" name=$nm printlabel $name "c-macro: ${mname}" # no cache trc=0 cmpaths="" _findheader "define[ ]*${mname}[^a-zA-Z0-9_]" $@ puts " \$@:$@" >&9 # eat the rest of the .h args while test $# -gt 0; do thdr=$1 case $thdr in *.h) ;; *) break ;; esac shift done if [ $fhrc -eq 1 ]; then macro=`${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextmacro.awk $fhdr ${mname}` puts " extracted macro: $macro" >&9 macro=`puts ${macro} | sed -e 's/ / /g;# tab to space' \ -e 's/^# *define *//' \ -e 's/\$/; }/' \ -e 's/([ *]*\(a-zA-Z0-9_]*\))->/\1./g' \ -e 's/->/./g' \ -e 's/(\([a-zA-Z0-9_]*\))\./\1./g;# (name). to name.' \ -e 's/^/auto C_MACRO_/' \ -e 's/\(C_MACRO_[a-zA-Z0-9_]*([^)]*) *\)/\1 { return /' \ -e 's/\(C_MACRO_[a-zA-Z0-9_]* *\)/\1 () { return /'` puts " initial macro: $macro" >&9 trc=1 fi # always pull the type off the list, even for D2 type=$1 shift if [ "$type" = "" ]; then type=int fi if [ "$type" = void ]; then macro=`puts ${macro} | sed -e "s/return//"` fi if [ "$DVERSION" = 1 -a $rc -eq 0 -a $trc -eq 1 ]; then macro=`puts ${macro} | sed -e "s/^auto/${type}/"` puts " macroC: $macro" >&9 fi tfirst=1 if [ $rc -eq 0 -a $trc -eq 1 -a $# -gt 0 ]; then while test $# -gt 0; do type=$1 if [ $tfirst -eq 1 ]; then macro=`puts ${macro} | sed -e "s/(/(${type} /" ` puts " macroD: $macro" >&9 tfirst=0 ttype=`puts $type | sed 's/\*/\\\\*/g'` tmp="($ttype [a-zA-Z0-9_]*" else puts " tmp: $tmp" >&9 cmd="macro=\`puts \${macro} | sed -e 's/\(${tmp}\) *, */\\\\1, ${type} /'\`" puts " cmdE: $cmd" >&9 eval $cmd puts " macroE: $macro" >&9 ttype=`puts $type | sed 's/\*/\\\\*/g'` doappend tmp ", ${ttype} [a-zA-Z0-9_]*" fi shift done fi if [ $rc -eq 0 -a $trc -eq 1 ]; then nmname=$mname nmname=C_MACRO_${nmname} doappend cmacros "${macro} " doappend cchglist1 "-e 's/\([^a-zA-Z0-9_]\)${mname}\([^a-zA-Z0-9_]\)/\1${nmname}\2/g' " fi printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_cunion () { check_cstruct $@ } check_cenum () { check_cstruct $@ } check_cstruct () { type=$1 s=$2 shift;shift nm="_${type}_${s}" ctype=$type ctype=`puts $ctype | sed -e 's/^c//'` lab=C_ST_ case $ctype in enum) lab=C_ENUM_ ;; union) lab=C_UN_ ;; esac name=$nm printlabel $name "c-${ctype}: ${s}" # no cache code="" _c_chk_cpp $name "" all rc=$? trc=0 rval=0 origstnm="" stnm="" tdnm="" havest=F if [ $rc -eq 0 ]; then st=`${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextstruct.awk -v dcode=T ${name}.out ${s} ` puts "#### initial ${ctype}" >&9 puts "${st}" >&9 puts "#### end initial ${ctype}" >&9 if [ "${st}" != "" ]; then havest=T tst=`puts ${st} | sed -e 's/{.*}/ = /' -e 's/[ ]/ /g' -e 's/ / /g' \ -e 's/^ *//' -e 's/[ ;]*\$//'` puts "### ${ctype} basics:${tst}:" >&9 # should now be: [typedef] {struct|union|enum} [name] = [name2] if [ "${tst}" != "" ]; then set ${tst} havetypedef=F if [ $1 = typedef ]; then havetypedef=T shift fi shift # the type, which we know already if [ $1 != "=" ]; then stnm=$1 shift fi shift # remove the equals sign if [ $# -gt 0 ]; then tdnm=$1 shift fi puts "#### stnm=${stnm}" >&9 otdnm=$tdnm dosubst otdnm '\*' '' ttdnm=$tdnm dosubst ttdnm '\*' '\\*' puts "#### tdnm=tdnm:${tdnm}:otdnm:${otdnm}:" >&9 if [ "$stnm" != "" -o "$otdnm" != "" ]; then trc=1 fi # remove 'typedef' keyword # remove trailing name before ; # remove "struct $stnm" # remove "struct" # remove all const # remove blank lines st=`puts "${st}" | sed -e 's/[ ]/ /g' -e 's/ / /g' \ -e 's/typedef *//' \ -e "s/${ttdnm} *;/;/; # typedef name or named struct" \ -e "s/ *${ctype} *${stnm} *{/{/" \ -e "s/^ *${ctype} *${stnm} *\$//" \ -e 's/\([^a-zA-Z0-9_]\)const\([^a-zA-Z0-9_]\)/\1 \2/g; # not supported' \ -e 's/^const\([^a-zA-Z0-9_]\)/\1/g; # not supported' \ | grep -v '^ *$' ` # change all other struct/union/enum to our tag. if [ "$stnm" != "" ]; then st=`puts "${st}" | sed -e "s/${ctype} *${stnm}\\([^a-zA-Z0-9_]\\)/${lab}${stnm}\\1/"` fi puts "#### modified ${ctype} (A)" >&9 puts ":${st}:" >&9 puts "#### end modified ${ctype} (A)" >&9 else trc=0 fi fi if [ $havest = T ]; then puts "### check for nested struct/union/enum" >&9 # look for any nested structure definitions as changed by # the awk extractor and add them to the cchglist. # remove the struct/union/enum tags from the structure now also # for those definitions that are found. tst=$st inst=0 bffound=F while read tsline; do case $tsline in *struct*{|*union*{|*enum*{) puts "### found: ${tsline}" >&9 ttype=`puts ${tsline} | sed -e 's/^[ const]*\([sue][trucniom]*\) *.*/\1/'` tl=`puts ${tsline} | sed -e "s/^.*${ttype} *\([a-zA-Z0-9_]*\) *{.*/\1/"` tlab=`puts ${tl} | sed 's/^\(C_[STUNEM]*_\).*/\1/'` tl=`puts ${tl} | sed -e "s/^${tlab}//"` puts "### ttype: ${ttype}" >&9 puts "### tlab: ${tlab}" >&9 puts "### tl: ${tl}" >&9 if [ "$tl" != "" ]; then st=`puts "${st}" | sed -e "s/${ttype} *${tl}/${tl}/g"` doappend cchglist2 "-e 's/\([^a-zA-Z0-9_]\)${tl}\([^a-zA-Z0-9_]\)/\1${tlab}${tl}\2/g' " doappend cchglist2 "-e 's/^${tl}\([^a-zA-Z0-9_]\)/${tlab}${tl}\1/g' " fi domath inst "$inst + 1" ;; *"}"*) if [ $inst -ge 1 ]; then tnname=`puts ${tsline} | sed -e 's/.*}[ *]*\([^; ]*\) *;/\1/'` # doesn't handle } w/no semi right. if [ "$tnname" != "" -a "$tnname" != "}" ]; then puts "### tnname:${tnname}:" >&9 doappend cchglist1 "-e 's/->${tnname}\././g' " doappend cchglist1 "-e 's/\.${tnname}\././g' " st=`puts "${st}" | sed -e "s/}[ *]*${tnname} *;/};/"` fi fi domath inst "$inst - 1" ;; *":"*) bffound=T ;; *) ;; esac # runs the 'while read' in the local shell, not a subshell. done << _HERE_ ${st} _HERE_ if [ $bffound = T ]; then nst="" inbf=0 bftsiz=0 bffcnt=1 while read tsline; do case $tsline in *":"*) inbf=1 tline=`puts $tsline | sed 's/.*://'` puts $tline | grep sizeof > /dev/null 2>&1 rc=$? while test $rc -eq 0; do ttval=`puts $tline | sed -e 's/.*sizeof *( *\([^)]*\) *).*/\1/'` tnm="_csiz_${ttval}" dosubst tnm ' ' '_' getdata tval ${_MKCONFIG_PREFIX} $tnm if [ "$tval" = "" ]; then tval=0 fi tline=`puts $tline | sed -e "s/\(.*\)sizeof *([^)]*)\(.*\)/\1 ${tval} \2/"` puts $tline | grep sizeof > /dev/null 2>&1 rc=$? done # remove casts tline=`puts $tline | \ sed -e 's/([a-z ]*)//g' -e 's/ *;//' -e 's// /g' -e 's/ / /g'` domath tval " $tline " domath bftsiz "$bftsiz + $tval" puts "## bf:$tline:$tval:$bftsiz" >&9 ;; *) if [ $inbf -eq 1 ]; then if [ $bftsiz -ne 0 ]; then domath tval "$bftsiz % 8" if [ $tval -eq 0 ]; then domath tval "$bftsiz / 8" puts "## bf:ubyte[$tval] bitfield_${s}${bffcnt};" >&9 doappend nst " ubyte[$tval] bitfield_${s}${bffcnt};" else doappend nst " #error: structure has bitfields that do not add to a multiple of 8. ubyte bitfield_${s}${bffcnt} : $bftsiz;" fi domath bffcnt "$bffcnt + 1" fi bftsiz=0 inbf=0 fi doappend nst " $tsline" ;; esac # runs the 'while read' in the local shell, not a subshell. done << _HERE_ ${st} _HERE_ puts "## old st:$st:" >&9 st=$nst puts "## new st:$st:" >&9 fi ts=$s if [ "$stnm" = "" -a "$tdnm" != "$otdnm" ]; then ts=${s}_ fi st=`( puts "${ctype} ${lab}${ts} "; puts "${st}" )` puts "#### modified ${ctype} (B)" >&9 puts "${st}" >&9 puts "#### end modified ${ctype} (B)" >&9 # save this for possible later use (cmembertype, cmemberxdr) cmd="CST_${s}=\${st}" eval $cmd puts " save: CST_${s}" >&9 else trc=0 fi if [ $trc -eq 1 ]; then if [ $ctype != enum ]; then # don't try to get size if there's no way to access the structure. # e.g. typedef struct { int a; } *b; if [ "$otdnm" = "" -o \ \( "$tdnm" != "" -a "$otdnm" = "$tdnm" \) ]; then tstnm=$otdnm if [ "$tstnm" = "" ]; then tstnm="${ctype} ${stnm}" # c language name fi puts "#### check size using: ${tstnm}" >&9 code="main () { printf (\"%d\", sizeof (${tstnm})); return (0); }" _c_chk_run ${name} "${code}" all rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi rval=$_retval puts "#### not enum: rval=${rval}" >&9 if [ $rc -ne 0 ]; then trc=0 fi fi fi else trc=0 fi fi if [ $trc -eq 1 ]; then if [ "$stnm" != "" ]; then puts "## add to cchglist: -e 's/\([^a-zA-Z0-9_]\)${ctype} *${stnm}\([^a-zA-Z0-9_]\)/\1${lab}${s}\2/g' " >&9 doappend cchglist2 "-e 's/\([^a-zA-Z0-9_]\)${ctype} *${stnm}\([^a-zA-Z0-9_]\)/\1${lab}${s}\2/g' " puts "## add to cchglist: -e 's/^${ctype} *${stnm}\([^a-zA-Z0-9_]\)/${lab}${s}\1/g' " >&9 doappend cchglist2 "-e 's/^${ctype} *${stnm}\([^a-zA-Z0-9_]\)/${lab}${s}\1/g' " fi if [ $havetypedef = T -a "$otdnm" != "" ]; then puts "## add to cchglist: -e 's/\([^a-zA-Z0-9_]\)${otdnm}\([^a-zA-Z0-9_]\)/\1${lab}${s}\2/g' " >&9 doappend cchglist1 "-e 's/\([^a-zA-Z0-9_]\)${otdnm}\([^a-zA-Z0-9_]\)/\1${lab}${s}\2/g' " puts "## add to cchglist: -e 's/^${otdnm}\([^a-zA-Z0-9_]\)/${lab}${s}\1/g' " >&9 doappend cchglist1 "-e 's/^${otdnm}\([^a-zA-Z0-9_]\)/${lab}${s}\1/g' " fi doappend cstructs " ${st} " if [ $havetypedef = T -a "$otdnm" != "" ]; then # if noprefix is on, don't alias some name to itself. if [ $noprefix = F -o ${s} != ${tdnm} ]; then puts "## add alias: ${lab}${ts} ${tdnm}" >&9 setdata ${_MKCONFIG_PREFIX} _ctypedef_${otdnm} $s doappend daliases "alias ${lab}${ts} ${tdnm}; " fi fi if [ $havetypedef = T -a "$otdnm" != "" -a \ "$stnm" != "" -a "$stnm" != "$s" ]; then puts "## add alias: ${lab}${ts} ${lab}${stnm}" >&9 setdata ${_MKCONFIG_PREFIX} _ctypedef_${stnm} $s doappend daliases "alias ${lab}${ts} ${lab}${stnm}; " fi if [ $lab != enum -a $rval -gt 0 ]; then # save the size setdata ${_MKCONFIG_PREFIX} _csiz_${ctype}_${s} ${rval} doappend dasserts "static assert ((${lab}${s}).sizeof == ${rval}); " fi fi printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_cmember () { shift struct=$1 shift member=$1 nm="_cmem_${struct}_${member}" dosubst nm ' ' '_' name=$nm printlabel $name "exists (C): ${struct}.${member}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi trc=0 tdfile="${name}.d" > ${tdfile} exec 4>>${tdfile} dump_ccode >&4 exec 4>&- code="void main (char[][] args) { C_ST_${struct} stmp; int i; i = stmp.${member}.sizeof; }" do_d_check_compile ${name} "${code}" all } check_cmembertype () { shift struct=$1 shift member=$1 nm="_cmembertype_${struct}_${member}" dosubst nm ' ' '_' name=$nm printlabel $name "member:type (C): ${struct} ${member}" # no cache trc=0 cmd="st=\${CST_${struct}}" puts " get: ${cmd}" >&9 eval $cmd if [ "$st" != "" ]; then puts " struct ${struct}: ${st}" >&9 tmem=`puts "$st" | grep "${member} *;\$"` rc=$? puts " found: ${tmem}" >&9 if [ $rc -eq 0 ]; then mtype=`puts $tmem | sed -e "s/ *${member} *;$//" -e 's/^ *//'` puts " type:${mtype}:" >&9 puts " member:${member}:" >&9 trc=1 if [ "${mtype}" != "" -a "${member}" != "" -a \( \ $noprefix = F -o "${mtype}" != "${member}" \) ]; then doappend daliases "alias ${mtype} C_TYP_${member}; " fi fi fi printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_cmemberxdr () { shift struct=$1 shift member=$1 nm="_cmemberxdr_${struct}_${member}" dosubst nm ' ' '_' name=$nm printlabel $name "member:XDR (C): ${struct} ${member}" # no cache trc=0 cmd="st=\${CST_${struct}}" puts " get: ${cmd}" >&9 eval $cmd if [ "$st" != "" ]; then puts " struct ${struct}: ${st}" >&9 tmem=`puts "$st" | grep "${member} *;\$"` rc=$? puts " found: ${tmem}" >&9 if [ $rc -eq 0 ]; then mtype=`puts $tmem | sed -e "s/ *${member} *;$//" -e 's/^ *//'` puts " type: ${mtype}" >&9 trc=1 doappend daliases "alias xdr_${mtype} xdr_${member}; " fi fi printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_cdcl () { type=$1 dname=$2 argflag=0 ccount=0 noconst=F shift;shift if [ "$dname" = args ]; then argflag=1 dname=$1 shift if [ "$dname" = noconst ]; then noconst=T dname=$1 shift fi fi nm="_cdcl_${dname}" name=$nm printlabel $name "c-dcl: ${dname}" # no cache trc=0 oldprecc="${precc}" doappend precc "/* get rid of most gcc-isms */ /* keep __asm__ to check for function renames */ #define __attribute__(a) #define __nonnull__(a,b) #define __restrict #define __restrict__ #define __THROW #define __const const " code="" _c_chk_cpp ${name} "/**/" all # force no-reuse due to precc rc=$? if [ $rc -eq 0 ]; then egrep "[ \*]${dname}[ ]*\(" $name.out >/dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then trc=1 fi if [ $trc -eq 1 ]; then dcl=`${awkcmd} -f ${_MKCONFIG_DIR}/util/mkcextdcl.awk ${name}.out ${dname}` dcl=`puts $dcl` # make single line. puts "## dcl(0): ${dcl}" >&9 # extern will be replaced # ; may or may not be present, so remove it. cmd="dcl=\`puts \"\$dcl\" | sed -e 's/extern *//' -e 's/;//' \`" eval $cmd if [ "$DVERSION" = 1 ]; then dosubst dcl 'const' '' fi puts "## dcl(A): ${dcl}" >&9 puts $dcl | grep __asm__ > /dev/null 2>&1 rc=$? dclren="" if [ $rc -eq 0 ]; then dclren=`puts $dcl | sed -e 's/.*__asm__[ ]*("" "\([a-z0-9A-Z_]*\)")/\1/'` fi puts "## dclren: ${dclren}" >&9 if [ "$dclren" != "" ]; then doappend daliases "alias ${dclren} ${dname}; " cmd="dcl=\`puts \"\$dcl\" | \ sed -e 's/[ ]*__asm__[ ]*([^)]*)[ ]*//' \ -e 's/\([ \*]\)${dname}\([ (]\)/\1${dclren}\2/' \`" eval $cmd puts "## dcl(B): ${dcl}" >&9 fi cmd="dcl=\`puts \"\$dcl\" | sed -e 's/( *void *)/()/' \`" eval $cmd puts "## dcl(C): ${dcl}" >&9 tdcl=$dcl modify_ctypes tdcl "${tdcl}" modify_cchglist tdcl "${tdcl}" # need any struct renames for args puts "## tdcl(D): ${tdcl}" >&9 if [ $argflag = 1 ]; then c=`puts ${tdcl} | sed 's/[^,]*//g'` ccount=`putsnonl "$c" | wc -c` domath ccount "$ccount + 1" # 0==1 also, unfortunately c=`puts ${tdcl} | sed 's/^[^(]*(//'` c=`puts ${c} | sed 's/)[^)]*$//'` puts "## c(E): ${c}" >&9 val=1 while test "${c}" != ""; do tmp=$c tmp=`puts ${c} | sed -e 's/ *,.*$//' -e 's/[ ]/ /g'` dosubst tmp 'struct ' 'struct#' 'union ' 'union#' 'enum ' 'enum#' # only do the following if the names of the variables are declared puts ${tmp} | grep ' ' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then tmp=`puts ${tmp} | sed -e 's/ *[A-Za-z0-9_]*$//'` fi dosubst tmp 'struct#' 'struct ' 'union#' 'union ' 'enum#' 'enum ' if [ $noconst = T ]; then tmp=`puts ${tmp} | sed -e 's/const *//'` fi puts "## tmp(F): ${tmp}" >&9 nm="_c_arg_${val}_${dname}" setdata ${_MKCONFIG_PREFIX} ${nm} "${tmp}" case ${tmp} in struct*|union*|enum*) ;; *) doappend daliases "alias ${tmp} ${nm}_alias; " ;; esac domath val "$val + 1" c=`puts ${c} | sed -e 's/^[^,]*//' -e 's/^[ ,]*//'` done tname=${dclren:-$dname} puts "## tname(G): ${tname} ($dname - $dclren)" >&9 c=`puts ${tdcl} | sed -e 's/[ ]/ /g' \ -e "s/\([ \*]\)${tname}[ (].*/\1/" \ -e 's/^ *//' \ -e 's/ *$//'` if [ $noconst = T ]; then c=`puts ${c} | sed -e 's/const *//'` fi nm="_c_type_${dname}" setdata ${_MKCONFIG_PREFIX} ${nm} "${c}" fi doappend cdcls " ${dcl}; " fi fi precc="${oldprecc}" printyesno $name $trc "" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} if [ $argflag = 1 ]; then nm="_c_args_${dname}" setdata ${_MKCONFIG_PREFIX} ${nm} ${ccount} fi } check_module () { type=$1 modname=$2 printlabel $name "module:" printyesno_val $name $modname } check_noprefix () { name=$1 noprefix=T printlabel $name "noprefix:" val=1 printyesno $name $val } output_item () { out=$1 name=$2 val=$3 tval=false if [ "$val" != "0" ]; then tval=true fi case ${name} in _setstr_*|_opt_*|_c_arg_*|_c_type_*) tname=$name dosubst tname '_setstr_' '' '_opt_' '' _create_enum -o string ${tname} "${val}" ;; _setint_*|_csiz_*|_siz_*|_c_args_*|_ctype_*) tname=$name dosubst tname '_setint_' '' _create_enum -o int ${tname} ${val} ;; *) _create_enum -o bool ${name} "${tval}" ;; esac } new_output_file () { _init_var_lists return } # initialization _init_var_lists cchglist1="" cchglist2="" cmpaths="" noprefix=F di-4.47/mkconfig/units/c-support.sh0000755000175000017500000001324013334050206015376 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek CA USA # CPPCOUNTER=1 postcc=" /* some gcc's (cygwin) redefine __restrict again */ #if defined (__restrict) # undef __restrict #endif #define __restrict " _c_print_headers () { incheaders=$1 cppchk=$2 out="${PH_PREFIX}${incheaders}" if [ -f $out ]; then cat $out return fi if [ "$PH_STD" = "T" -a "$incheaders" = "std" ]; then _c_print_hdrs std $cppchk > $out cat $out return fi if [ "$PH_ALL" = "T" -a "$incheaders" = "all" ]; then _c_print_hdrs all $cppchk > $out cat $out return fi # until PH_STD/PH_ALL becomes true, just do normal processing. _c_print_hdrs $incheaders $cppchk } _c_print_hdrs () { incheaders=$1 cppchk=$2 if [ "${incheaders}" = "all" -o "${incheaders}" = "std" ]; then for tnm in '_hdr_stdio' '_hdr_stdlib' '_sys_types' '_sys_param'; do getdata tval ${_MKCONFIG_PREFIX} ${tnm} if [ "${tval}" != "0" -a "${tval}" != "" ]; then puts "#include <${tval}>" # for cygwin/gcc if [ "$cppchk" = T -a $tnm = _hdr_stdio ]; then puts "${postcc}" fi fi done fi if [ "${incheaders}" = "all" -a -f "$VARSFILE" ]; then # save stdin in fd 6; open stdin exec 6<&0 < ${VARSFILE} while read cfgvar; do getdata hdval ${_MKCONFIG_PREFIX} ${cfgvar} case ${cfgvar} in _hdr_stdio|_hdr_stdlib|_sys_types|_sys_param) ;; _hdr_linux_quota) if [ "${hdval}" != "0" ]; then getdata iqval ${_MKCONFIG_PREFIX} '_inc_conflict__sys_quota__hdr_linux_quota' if [ "${iqval}" = "1" ]; then puts "#include <${hdval}>" fi fi ;; _sys_time) if [ "${hdval}" != "0" ]; then getdata itval ${_MKCONFIG_PREFIX} '_inc_conflict__hdr_time__sys_time' if [ "${itval}" = "1" ]; then puts "#include <${hdval}>" fi fi ;; _hdr_*|_sys_*) if [ "${hdval}" != "0" -a "${hdval}" != "" ]; then puts "#include <${hdval}>" fi ;; esac done # set std to saved fd 6; close 6 exec <&6 6<&- fi } _c_chk_run () { crname=$1 code=$2 inc=$3 _c_chk_link_libs ${crname} "${code}" $inc rc=$? puts "## run test: link: $rc" >&9 rval=0 if [ $rc -eq 0 ]; then rval=`./${crname}.exe` rc=$? puts "## run test: run: $rc retval:$rval" >&9 if [ $rc -lt 0 ]; then _exitmkconfig $rc fi fi _retval=$rval return $rc } _c_chk_link_libs () { cllname=$1 code=$2 inc=$3 shift;shift;shift ocounter=0 clotherlibs="'$otherlibs'" dosubst clotherlibs ',' "' '" if [ "${clotherlibs}" != "" ]; then eval "set -- $clotherlibs" ocount=$# else ocount=0 fi tcfile=${cllname}.c >${tcfile} # $cllname should be unique exec 4>>${tcfile} puts "${precc}" >&4 _c_print_headers $inc >&4 puts "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- dlibs="" otherlibs="" _c_chk_link $cllname rc=$? puts "## link test (none): $rc" >&9 if [ $rc -ne 0 ]; then while test $ocounter -lt $ocount; do domath ocounter "$ocounter + 1" eval "set -- $clotherlibs" cmd="olibs=\$${ocounter}" eval $cmd dlibs=${olibs} otherlibs=${olibs} _c_chk_link $cllname rc=$? puts "## link test (${olibs}): $rc" >&9 if [ $rc -eq 0 ]; then break fi done fi _retdlibs=$dlibs return $rc } _c_chk_cpp () { cppname=$1 code="$2" inc=$3 tcppfile=${cppname}.c tcppout=${cppname}.out tcppreuse=F if [ "$code" = "" -a $inc = all ]; then tcppreuse=T tcppfile=chkcpp_${CPPCOUNTER}.c tcppout=chkcpp_${CPPCOUNTER}.out if [ -f $tcppfile -a -f $tcppout ]; then test -f ${cppname}.out && rm -f ${cppname}.out ln -s ${tcppout} ${cppname}.out puts "## _cpp test: reusing $tcppout" >&9 rc=0 return $rc fi fi # $cppname should be unique exec 4>>${tcppfile} puts "${precc}" >&4 _c_print_headers $inc T >&4 puts "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- setcflags cmd="${CC} ${CFLAGS} -E ${tcppfile} > ${tcppout} " puts "## _cpp test: $cmd" >&9 cat ${tcppfile} >&9 eval $cmd >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi if [ $tcppreuse = T ]; then test -f ${cppname}.out && rm -f ${cppname}.out ln -s ${tcppout} ${cppname}.out fi puts "## _cpp test: $rc" >&9 return $rc } _c_chk_link () { clname=$1 setcflags setldflags setlibs cmd="${CC} ${CFLAGS} -o ${clname}.exe ${clname}.c " cmd="${cmd} ${LDFLAGS} ${LIBS} " _clotherlibs=$otherlibs if [ "${_clotherlibs}" != "" ]; then cmd="${cmd} ${_clotherlibs} " fi puts "## _link test: $cmd" >&9 cat ${clname}.c >&9 eval $cmd >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi puts "## _link test: $rc" >&9 if [ $rc -eq 0 ]; then if [ ! -x "${clname}.exe" ]; then # not executable rc=1 fi fi return $rc } _c_chk_compile () { ccname=$1 code=$2 inc=$3 tcfile=${ccname}.c >${tcfile} # $ccname should be unique exec 4>>${tcfile} puts "${precc}" >&4 _c_print_headers $inc >&4 puts "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- setcflags cmd="${CC} ${CFLAGS} -c ${tcfile}" puts "## compile test: $cmd" >&9 cat ${ccname}.c >&9 eval ${cmd} >&9 2>&9 rc=$? puts "## compile test: $rc" >&9 return $rc } do_c_check_compile () { dccname=$1 code=$2 inc=$3 _c_chk_compile ${dccname} "${code}" $inc rc=$? try=0 if [ $rc -eq 0 ]; then try=1 fi printyesno $dccname $try setdata ${_MKCONFIG_PREFIX} ${dccname} ${try} } di-4.47/mkconfig/units/c-include-conflict.sh0000755000175000017500000000312613334050206017106 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek CA USA # # # check and see if there is a conflict between include files. # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # require_unit c-main _prefix_header () { nm=$1 val=$2 case $val in sys*) eval "$nm=_${val}" ;; *) eval "$nm=_hdr_${val}" ;; esac } check_include_conflict () { i1=$2 i2=$3 if [ "${CC}" = "" ]; then puts "No compiler specified" >&2 return fi oi1=$i1 dosubst i1 '/' '_' ':' '_' '\.h' '' _prefix_header i1 $i1 oi2=$i2 dosubst i2 '/' '_' ':' '_' '\.h' '' _prefix_header i2 $i2 name="_inc_conflict_${i1}_${i2}" # by default, ok to include both # if one or the other does not exist, the flag will be true. # if it compiles ok with both, the flag will be true. trc=1 printlabel $name "header: include both ${oi1} & ${oi2}" getdata h1 ${_MKCONFIG_PREFIX} $i1 getdata h2 ${_MKCONFIG_PREFIX} $i2 if [ "${h1}" != "0" -a "${h2}" != "0" ]; then checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi code="#include <${h1}> #include <${h2}> main () { return 0; } " do_c_check_compile "${name}" "${code}" std else setdata ${_MKCONFIG_PREFIX} "${name}" "${trc}" printyesno "${name}" $trc "" fi } di-4.47/mkconfig/units/env-dc.sh0000755000175000017500000001024313334050206014616 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam, Walnut Creek, California USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - temporary for mkconfig.sh (mkconfig.sh) # 6 - temporary for c-main.sh (c-main.sh) # 5 - temporary for c-main.sh (c-main.sh) # require_unit env-main require_unit env-systype check_dc () { _read_option DC gdc DC=${DC:-${oval}} printlabel DC "D compiler" puts "dc:${DC}" >&9 case ${DC} in *ldc*|*ldmd*) setdata ${_MKCONFIG_PREFIX} DC_OPT "-O3" setdata ${_MKCONFIG_PREFIX} DC_OF "-of" setdata ${_MKCONFIG_PREFIX} DC_RELEASE "-release" setdata ${_MKCONFIG_PREFIX} DC_INLINE "" setdata ${_MKCONFIG_PREFIX} DC_UNITTEST "-unittest" setdata ${_MKCONFIG_PREFIX} DC_DEBUG "-d-debug" setdata ${_MKCONFIG_PREFIX} DC_VERSION "-d-version" setdata ${_MKCONFIG_PREFIX} DC_INTFC "-d-intfc" setdata ${_MKCONFIG_PREFIX} DC_DEPRECATED "-d-deprecated" setdata ${_MKCONFIG_PREFIX} DC_COV "" setdata ${_MKCONFIG_PREFIX} DC_LINK "-L" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GDC "N" ;; *dmd*) setdata ${_MKCONFIG_PREFIX} DC_OPT "-O" setdata ${_MKCONFIG_PREFIX} DC_OF "-of" setdata ${_MKCONFIG_PREFIX} DC_RELEASE "-release" setdata ${_MKCONFIG_PREFIX} DC_INLINE "-inline" setdata ${_MKCONFIG_PREFIX} DC_UNITTEST "-unittest" setdata ${_MKCONFIG_PREFIX} DC_DEBUG "-debug" setdata ${_MKCONFIG_PREFIX} DC_VERSION "-version" setdata ${_MKCONFIG_PREFIX} DC_INTFC "-H" setdata ${_MKCONFIG_PREFIX} DC_DEPRECATED "-d" setdata ${_MKCONFIG_PREFIX} DC_COV "-cov" setdata ${_MKCONFIG_PREFIX} DC_LINK "-L" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GDC "N" ;; *gdc*) setdata ${_MKCONFIG_PREFIX} DC_OPT "-O2" setdata ${_MKCONFIG_PREFIX} DC_OF "-o" setdata ${_MKCONFIG_PREFIX} DC_RELEASE "-frelease" setdata ${_MKCONFIG_PREFIX} DC_INLINE "--inline" setdata ${_MKCONFIG_PREFIX} DC_UNITTEST "-funittest" setdata ${_MKCONFIG_PREFIX} DC_DEBUG "--debug" setdata ${_MKCONFIG_PREFIX} DC_VERSION "-fversion" setdata ${_MKCONFIG_PREFIX} DC_INTFC "-fintfc" setdata ${_MKCONFIG_PREFIX} DC_DEPRECATED "-fdeprecated" setdata ${_MKCONFIG_PREFIX} DC_COV "--cov" setdata ${_MKCONFIG_PREFIX} DC_LIBS "-lgcov" setdata ${_MKCONFIG_PREFIX} DC_LINK "" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GDC "Y" ;; esac > tv.d puts ' int main (char[][] args) { version (D_Version2) { return 2; } version (D_Version3) { return 3; } version (D_Version4) { return 4; } version (D_Version5) { return 5; } version (D_Version6) { return 6; } return 1; } ' dver= grc=1 ${DC} ${DC_OF}tv.exe tv.d rc=$? if [ $rc -eq 0 ]; then if [ ! -x ./tv.exe ]; then rc=127 else ./tv.exe rc=$? fi case $rc in [1-9]) dver=$rc grc=0 ;; *) ;; esac fi if [ $grc -ne 0 ]; then puts "## Failure to determine D version" exit 1 fi setdata ${_MKCONFIG_PREFIX} DVERSION $dver printyesno_val DC "${DC}" "v${dver}" setdata ${_MKCONFIG_PREFIX} DC "${DC}" } check_using_gdc () { usinggdc="N" printlabel _MKCONFIG_USING_GDC "Using gdc" # check for gdc... ${DC} -v 2>&1 | grep 'gdc version' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ] then puts "found gdc" >&9 usinggdc="Y" fi case ${DC} in *gdc*) usinggdc="Y" ;; esac printyesno_val _MKCONFIG_USING_GDC "${usinggdc}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GDC "${usinggdc}" } check_dflags () { _read_option DFLAGS "" dflags="${DFLAGS:-${oval}}" _read_option DINCLUDES "" dincludes="${DINCLUDES:-${oval}}" printlabel DFLAGS "D flags" gdcflags="" if [ "${_MKCONFIG_USING_GDC}" = "Y" ] then puts "set gdc flags" >&9 gdcflags="" fi TDC=${DC} if [ "${_MKCONFIG_USING_GDC}" = "Y" ] then TDC=gdc fi dflags="$gdcflags $dflags" puts "dflags:${dflags}" >&9 printyesno_val DFLAGS "$dflags" setdata ${_MKCONFIG_PREFIX} DFLAGS "$dflags" } di-4.47/mkconfig/units/d-support.sh0000755000175000017500000001012213334050206015373 0ustar bllbll#!/bin/sh # # Copyright 2010-2018 Brad Lanam Walnut Creek CA USA # # _d_print_imports () { imports=$1 if [ "$imports" = "none" ]; then return fi out="${PI_PREFIX}${imports}" if [ -f $out ]; then cat $out return fi if [ "$PI_ALL" = "T" -a "$imports" = "all" ]; then _d_print_imps all > $out cat $out return fi # until PI_ALL becomes true, just do normal processing. _d_print_imps $imports } _d_print_imps () { imports=$1 if [ "${imports}" = "all" -o "${imports}" = "std" ]; then for tnm in '_import_std_stdio' '_import_std_string'; do getdata tval ${_MKCONFIG_PREFIX} ${tnm} if [ "${tval}" != "0" -a "${tval}" != "" ]; then puts "import ${tval};" fi done fi if [ "${imports}" = "all" -a -f "$VARSFILE" ]; then # save stdin in fd 6; open stdin exec 6<&0 < ${VARSFILE} while read cfgvar; do getdata hdval ${_MKCONFIG_PREFIX} ${cfgvar} case ${cfgvar} in _import_std_stdio|_import_std_string) ;; _import_*) if [ "${hdval}" != "0" -a "${hdval}" != "" ]; then puts "import ${hdval};" fi ;; esac done # set std to saved fd 6; close 6 exec <&6 6<&- fi } _d_chk_run () { drname=$1 code=$2 inc=$3 _d_chk_link_libs ${drname} "${code}" $inc rc=$? puts "## run test: link: $rc" >&9 rval=0 if [ $rc -eq 0 ]; then rval=`./${drname}.exe` rc=$? puts "## run test: run: $rc retval: $rval" >&9 if [ $rc -lt 0 ]; then _exitmkconfig $rc fi fi _retval=$rval return $rc } _d_chk_link_libs () { dllname=$1 code=$2 inc=$3 shift;shift;shift ocounter=0 dlotherlibs="'$otherlibs'" dosubst dlotherlibs ',' "' '" if [ "${dlotherlibs}" != "" ]; then eval "set -- $dlotherlibs" ocount=$# else ocount=0 fi tdfile=${dllname}.d # $dllname should be unique exec 4>>${tdfile} _d_print_imports $inc >&4 puts "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- dlibs="" otherlibs="" _d_chk_link $dllname rc=$? puts "## link test (none): $rc" >&9 if [ $rc -ne 0 ]; then while test $ocounter -lt $ocount; do domath ocounter "$ocounter + 1" eval "set -- $dlotherlibs" cmd="olibs=\$${ocounter}" eval $cmd dlibs=${olibs} otherlibs=${olibs} _d_chk_link $dllname rc=$? puts "## link test (${olibs}): $rc" >&9 if [ $rc -eq 0 ]; then break fi done fi _retdlibs=$dlibs return $rc } _d_chk_link () { dlname=$1 cmd="${_MKCONFIG_DIR}/mkc.sh -d `pwd` -complink -e -c ${DC} \ -o ${dlname}${OBJ_EXT} -- ${DFLAGS} ${dlname}.d " puts "## _link test (compile): $cmd" >&9 cat ${dlname}.d >&9 eval ${cmd} >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi puts "## _link compile: $rc" >&9 cmd="${_MKCONFIG_DIR}/mkc.sh -d `pwd` -complink -e -c ${DC} -o ${dlname}.exe \ -- ${DFLAGS} ${dlname}${OBJ_EXT} ${LDFLAGS} ${LIBS} " _dlotherlibs=$otherlibs if [ "${_dlotherlibs}" != "" ]; then cmd="${cmd} ${_dlotherlibs} " fi puts "## _link test (link): $cmd" >&9 cat ${dlname}.d >&9 eval $cmd >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi puts "## _link link: $rc" >&9 if [ $rc -eq 0 ]; then if [ ! -x "${dlname}.exe" ]; then # not executable rc=1 fi fi return $rc } _d_chk_compile () { dfname=$1 code=$2 inc=$3 tdfile=${dfname}.d # $dfname should be unique exec 4>>${tdfile} _d_print_imports $inc >&4 puts "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- cmd="${_MKCONFIG_DIR}/mkc.sh -d `pwd` -complink -e -c ${DC} \ -o ${dfname}${OBJ_EXT} -- ${DFLAGS} ${tdfile} " puts "## compile test: $cmd" >&9 cat ${dfname}.d >&9 eval ${cmd} >&9 2>&9 rc=$? puts "## compile test: $rc" >&9 return $rc } do_d_check_compile () { ddfname=$1 code=$2 inc=$3 _d_chk_compile ${ddfname} "${code}" $inc rc=$? try=0 if [ $rc -eq 0 ]; then try=1 fi printyesno $ddfname $try setdata ${_MKCONFIG_PREFIX} ${ddfname} ${try} } di-4.47/mkconfig/mkconfig.sh0000755000175000017500000005554613334050206014114 0ustar bllbll#!/bin/sh # # Copyright 2009-2018 Brad Lanam Walnut Creek, CA USA # # # speed at the cost of maintainability... # File Descriptors: # 9 - >>$LOG (mkconfig.sh) # 8 - >>$VARSFILE, >>$CONFH (mkconfig.sh) # 7 - saved stdin (mkconfig.sh) # 6 - temporary (c-main.sh, mkconfig.sh) # 4 - temporary (c-main.sh) # set -f # set this globally. unset CDPATH # this is a workaround for ksh93 on solaris if [ "$1" = -d ]; then cd $2 shift shift fi mypath=`echo $0 | sed -e 's,/[^/]*$,,' -e 's,^\.,./.,'` _MKCONFIG_DIR=`(cd $mypath;pwd)` export _MKCONFIG_DIR . ${_MKCONFIG_DIR}/bin/shellfuncs.sh . ${_MKCONFIG_DIR}/bin/envfuncs.sh doshelltest $0 $@ LOG="mkconfig.log" _MKCONFIG_TMP="_tmp_mkconfig" CACHEFILE="mkconfig.cache" OPTIONFILE="options.dat" _MKCONFIG_PREFIX=mkc # need a default in case no units loaded optionsloaded=F allchglist="" INC="mkcinclude.txt" # temporary _chkconfigfname () { if [ "$CONFH" = "" ]; then puts "Config file name not set. Exiting." _exitmkconfig 1 fi } _exitmkconfig () { rc=$1 exit $rc } _savecache () { # And save the data for re-use. # Some shells don't quote the values in the set # command like bash does. So we do it. # Then we have to undo it for bash. # Other shells do: x=$''; remove the $ # And then there's: x='', which gets munged. # Any value that actually ends with an '=' is going to get mangled. #savecachedebug=F #if [ $savecachedebug = T ]; then # puts "## savecache original" # set | grep "^mkc_" # puts "## savecache A" # set | grep "^mkc_" | \ # sed -e "s/=/='/" # puts "## savecache B" # set | grep "^mkc_" | \ # sed -e "s/=/='/" -e "s/$/'/" # puts "## savecache C" # set | grep "^mkc_" | \ # sed -e "s/=/='/" -e "s/$/'/" -e "s/''/'/g" # puts "## savecache D" # set | grep "^mkc_" | \ # sed -e "s/=/='/" -e "s/$/'/" -e "s/''/'/g" \ # -e "s/^\([^=]*\)='$/\1=''/" # puts "## savecache E" # set | grep "^mkc_" | \ # sed -e "s/=/='/" -e "s/$/'/" -e "s/''/'/g" \ # -e "s/^\([^=]*\)='$/\1=''/" -e "s/='\$'/='/" #fi #unset savecachedebug set | grep "^mkc_" | \ sed -e "s/=/='/" -e "s/$/'/" -e "s/''/'/g" \ -e "s/^\([^=]*\)='$/\1=''/" -e "s/='\$'/='/" \ > ${CACHEFILE} } setvar () { prefix=$1 svname=$2 if [ $varsfileopen = F ]; then for v in `set | grep "^mkv_" | sed -e 's/=.*$//'`; do unset $v done varsfileopen=T >$VARSFILE exec 8>>$VARSFILE fi cmd="test \"X\$mkv_${prefix}_${svname}\" != X > /dev/null 2>&1" eval $cmd rc=$? # if already in the list of vars, don't add it to the file again. if [ $rc -ne 0 ]; then puts ${svname} >&8 fi cmd="mkv_${prefix}_${svname}=T" eval $cmd puts " setvar: $cmd" >&9 } setdata () { prefix=$1 sdname=$2 sdval=$3 if [ "$_MKCONFIG_EXPORT" = T ]; then _doexport $sdname "$sdval" fi cmd="mkc_${prefix}_${sdname}=\"${sdval}\"" eval $cmd puts " setdata: $cmd" >&9 setvar $prefix $sdname } getdata () { var=$1 prefix=$2 gdname=$3 cmd="${var}=\${mkc_${prefix}_${gdname}}" eval $cmd } _setifleveldisp () { ifleveldisp="" for il in $iflevels; do ifleveldisp="${il}${ifleveldisp}" done if [ "$ifleveldisp" != "" ]; then doappend ifleveldisp " " fi } printlabel () { tname=$1 tlabel=$2 puts " $ifleveldisp[${tname}] ${tlabel} ... " >&9 putsnonl "${ifleveldisp}${tlabel} ..." >&1 } _doexport () { var=$1 val=$2 cmd="${var}=\"${val}\"" eval $cmd cmd="export ${var}" eval $cmd } printyesno_actual () { ynname=$1 ynval=$2 yntag=${3:-} puts " [${ynname}] $ynval ${yntag}" >&9 puts " $ynval ${yntag}" >&1 } printyesno_val () { ynname=$1 ynval=$2 yntag=${3:-} if [ "$ynval" != 0 ]; then printyesno_actual "$ynname" "$ynval" "${yntag}" else printyesno_actual "$ynname" no "${yntag}" fi } printyesno () { ynname=$1 ynval=$2 yntag=${3:-} if [ "$ynval" != 0 ]; then ynval=yes fi printyesno_val "$ynname" $ynval "$yntag" } checkcache_val () { prefix=$1 tname=$2 getdata tval ${prefix} ${tname} rc=1 if [ "$tval" != "" ]; then setvar $prefix $tname printyesno_actual $tname "$tval" " (cached)" rc=0 fi return $rc } checkcache () { prefix=$1 tname=$2 getdata tval ${prefix} ${tname} rc=1 if [ "$tval" != "" ]; then setvar $prefix $tname printyesno $tname $tval " (cached)" rc=0 fi return $rc } _loadoptions () { if [ $optionsloaded = F -a -f "${OPTIONFILE}" ]; then exec 6<&0 < ${OPTIONFILE} while read o; do case $o in "") continue ;; \#*) continue ;; esac topt=`puts "$o" | sed 's/=.*//'` tval=`puts "$o" | sed 's/.*=//'` eval "_mkc_opt_${topt}=\"${tval}\"" done exec <&6 6<&- optionsloaded=T fi } check_command () { name=$1 shift ccmd=$1 locnm=_cmd_loc_${ccmd} printlabel $name "command: ${ccmd}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi trc=0 val="" while test $# -gt 0; do ccmd=$1 shift locatecmd tval $ccmd if [ "$tval" != "" ]; then val=$tval trc=1 fi done printyesno_val $name $val setdata ${_MKCONFIG_PREFIX} ${name} ${trc} if [ $trc -eq 1 ]; then setdata ${_MKCONFIG_PREFIX} ${locnm} ${val} fi } check_grep () { name=$1; shift tag=$1; shift pat=$1; shift fn=$1; shift locnm=_grep_${name} printlabel $name "grep: ${tag}" checkcache ${_MKCONFIG_PREFIX} $name if [ $rc -eq 0 ]; then return; fi grep -l ${pat} ${fn} > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then trc=1; else trc=0; fi printyesno $name $trc setdata ${_MKCONFIG_PREFIX} ${name} ${trc} } check_ifoption () { ifdispcount=$1 type=$2 name=$3 oopt=$4 printlabel $name "$type ($ifdispcount): ${oopt}" _loadoptions trc=0 # if option is not set, it's false found=F if [ $optionsloaded = T ]; then eval tval=\$_mkc_opt_${oopt} # override the option value with the environment variable eval tenvval=\$${oopt} if [ "$tenvval" != "" ]; then tval=$tenvval fi if [ "$tval" != "" ]; then found=T trc=$tval tolower trc puts " found option: $oopt $trc" >&9 if [ "$trc" = t ]; then trc=1; fi if [ "$trc" = f ]; then trc=0; fi if [ "$trc" = enable ]; then trc=1; fi if [ "$trc" = disable ]; then trc=0; fi if [ "$trc" = true ]; then trc=1; fi if [ "$trc" = false ]; then trc=0; fi if [ "$trc" = yes ]; then trc=1; fi if [ "$trc" = no ]; then trc=0; fi fi fi # these must be set before ifnotoption processing if [ $optionsloaded = F ]; then trc=0 elif [ "$found" = F ]; then trc=0 fi if [ $type = ifnotoption ]; then if [ $trc -eq 0 ]; then trc=1; else trc=0; fi fi if [ $optionsloaded = F ]; then printyesno_actual $name "no options file" elif [ "$found" = F ]; then printyesno_actual $name "option not found" else printyesno $name $trc fi return $trc } check_if () { iflabel=$1 ifdispcount=$2 ifline=$3 name=$iflabel printlabel $name, "if ($ifdispcount): $iflabel"; boolclean ifline puts "## ifline: $ifline" >&9 trc=0 # if option is not set, it's false nline="test " ineq=0 qtoken="" quoted=0 for token in $ifline; do puts "## token: $token" >&9 case $token in \'*\') token=`puts $token | sed -e s,\',,g` puts "## begin/end quoted token" >&9 ;; \'*) qtoken=$token puts "## begin qtoken: $qtoken" >&9 quoted=1 continue ;; esac if [ $quoted -eq 1 ]; then case $token in *\') token="${qtoken} $token" token=`puts $token | sed -e s,\',,g` puts "## end qtoken: $token" >&9 quoted=0 ;; *) qtoken="$qtoken $token" puts "## in qtoken: $qtoken" >&9 continue ;; esac fi if [ $ineq -eq 1 ]; then ineq=2 getdata tvar ${_MKCONFIG_PREFIX} $token elif [ $ineq -eq 2 ]; then doappend nline " ( '$tvar' = '$token' )" ineq=0 else case $token in ==) ineq=1 ;; \(|\)|-a|-o|!) doappend nline " $token" ;; *) getdata tvar ${_MKCONFIG_PREFIX} $token if [ "$tvar" != 0 -a "$tvar" != "" ]; then tvar=1; else tvar=0; fi tvar="( $tvar = 1 )" doappend nline " $tvar" ;; esac fi done if [ "$ifline" != "" ]; then dosubst nline '(' '\\\\\\(' ')' '\\\\\\)' puts "## nline: $nline" >&9 eval $nline trc=$? puts "## eval nline: $trc" >&9 # replace w/ shell return if [ $trc -eq 0 ]; then trc=1; else trc=0; fi puts "## eval nline final: $trc" >&9 fi texp=$_MKCONFIG_EXPORT _MKCONFIG_EXPORT=F printyesno "$name" $trc _MKCONFIG_EXPORT=$texp return $trc } check_set () { nm=$1 type=$2 sval=$3 name=$type tnm=$1 dosubst tnm '_setint_' '' '_setstr' '' printlabel $name "${type}: ${tnm}" if [ "$type" = set ]; then getdata tval ${prefix} ${nm} if [ "$tval" != "" ]; then printyesno $nm "${sval}" setdata ${_MKCONFIG_PREFIX} ${nm} "${sval}" else printyesno_actual $nm "no such variable" fi elif [ "$type" = setint ]; then printyesno_actual $nm "${sval}" setdata ${_MKCONFIG_PREFIX} ${nm} "${sval}" else printyesno_actual $nm "${sval}" setdata ${_MKCONFIG_PREFIX} ${nm} "${sval}" fi } _read_option () { onm=$1 def=$2 _loadoptions oval=$def if [ $optionsloaded = T ]; then eval tval=\$_mkc_opt_${onm} if [ "$tval" != "" ]; then found=T puts " found option: $onm $tval" >&9 oval="$tval" fi fi } check_option () { nm=$1 onm=$2 def=$3 name=$nm printlabel $name "option: ${onm}" _read_option $onm "$def" printyesno_actual $nm "$oval" setdata ${_MKCONFIG_PREFIX} ${nm} "${oval}" } check_echo () { val=$1 puts "## echo: $val" >&9 puts "$val" >&1 } check_exit () { puts "## exit" >&9 _exitmkconfig 5 } check_substitute () { nm=$1 sub1=$2 sub2=$3 printlabel $nm "substitute: ${sub1} ${sub2}" doappend allchglist " -e 's~${sub1}~${sub2}~g'" printyesno $nm 1 } _doloadunit () { lu=$1 dep=$2 if [ "$dep" = Y ]; then slu=${lu} tag=" (dependency)" fi if [ -f ${_MKCONFIG_DIR}/units/${lu}.sh ]; then puts "load-unit: ${lu} ${tag}" >&1 puts " found ${lu} ${tag}" >&9 . ${_MKCONFIG_DIR}/units/${lu}.sh tlu=$lu dosubst tlu '-' '_' eval "_MKCONFIG_UNIT_${tlu}=Y" fi if [ "$dep" = Y ]; then lu=$slu tag="" fi } require_unit () { units=$@ for rqu in $units; do trqu=$rqu dosubst trqu '-' '_' cmd="val=\$_MKCONFIG_UNIT_${trqu}" eval $cmd if [ "$val" = Y ]; then puts " required unit ${rqu} already loaded" >&9 continue fi puts " required unit ${rqu} needed" >&9 _doloadunit $rqu Y done } _create_output () { if [ ${CONFH} != none ]; then confdir=`puts ${CONFH} | sed -e 's,/[^/]*$,,'` test -d $confdir || mkdir -p $confdir > ${CONFH} exec 8>>${CONFH} preconfigfile ${CONFH} ${configfile} >&8 if [ -f $VARSFILE ]; then exec 6<&0 < $VARSFILE while read cfgvar; do getdata val ${_MKCONFIG_PREFIX} $cfgvar output_item ${CONFH} ${cfgvar} "${val}" >&8 done exec <&6 6<&- fi stdconfigfile ${CONFH} >&8 cat $INC >&8 postconfigfile ${CONFH} >&8 exec 8>&- if [ "$allchglist" != "" ]; then cmd="sed ${allchglist} ${CONFH} > ${CONFH}.tmp;mv ${CONFH}.tmp ${CONFH}" eval $cmd fi fi } main_process () { configfile=$1 reqlibs="" if [ -f "$CACHEFILE" ]; then . $CACHEFILE fi reqhdr="" inproc=0 ininclude=0 doproclist="" doproc=1 linenumber=0 ifstmtcount=0 ifleveldisp="" iflevels="" ifcurrlvl=0 doif=$ifcurrlvl initifs > $INC case ${configfile} in /*) ;; *) configfile="../${configfile}" ;; esac # save stdin in fd 7. # and reset stdin to get from the configfile. # this allows us to run the while loop in the # current shell rather than a subshell. # default varsfile. # a main loadunit will override this. # but don't open it unless it is needed. varsfileopen=F if [ "$VARSFILE" = "" -a "${_MKCONFIG_PREFIX}" != "" ]; then VARSFILE="../mkc_none_${_MKCONFIG_PREFIX}.vars" fi # ksh93 93u 'read' changed. Need the raw read for 'include'. # Unfortunately, this affects other shells. # shellfuncs tests for the necessity. rawarg= # save stdin in fd 7; open stdin exec 7<&0 < ${configfile} while read ${rawarg} tdatline; do resetifs domath linenumber "$linenumber + 1" puts "#### ${linenumber}: ${tdatline}" >&9 if [ $ininclude -eq 1 ]; then if [ "${tdatline}" = endinclude ]; then ininclude=0 rawarg= resetifs else if [ $shreqreadraw -eq 1 ]; then # have to do our own backslash processing. # backquotes suck. tdatline=`puts "${tdatline}" | sed -e 's/\\\\\\([^\\\\]\\)/\\1/g' -e 's/\\\\\\\\/\\\\/g'` fi puts "${tdatline}" >> $INC fi else case ${tdatline} in "") continue ;; \#*) continue ;; *) puts "#### ${linenumber}: ${tdatline}" >&9 ;; esac fi if [ $ininclude -eq 0 ]; then case ${tdatline} in "else") if [ $ifcurrlvl -eq $doif ]; then if [ $doproc -eq 0 ]; then doproc=1; else doproc=0; fi set -- $iflevels shift iflevels=$@ iflevels="-$ifstmtcount $iflevels" _setifleveldisp puts "## else: ifcurrlvl: $ifcurrlvl doif: $doif doproc:$doproc" >&9 puts "## else: iflevels: $iflevels" >&9 else puts "## else: ifcurrlvl: $ifcurrlvl doif: $doif doproc:$doproc" >&9 fi ;; "if "*|"ifoption"*|"ifnotoption"*) if [ $doproc -eq 0 ]; then domath ifcurrlvl "$ifcurrlvl + 1" puts "## if: ifcurrlvl: $ifcurrlvl doif: $doif" >&9 fi ;; "endif") puts "## endifA: ifcurrlvl: $ifcurrlvl doif: $doif" >&9 if [ $ifcurrlvl -eq $doif ]; then set $doproclist c=$# if [ $c -gt 0 ]; then puts "## doproclist: $doproclist" >&9 doproc=$1 shift doproclist=$@ puts "## doproc: $doproc doproclist: $doproclist" >&9 set -- $iflevels shift iflevels=$@ _setifleveldisp puts "## endif iflevels: $iflevels" >&9 else doproc=1 ifleveldisp="" iflevels="" fi domath doif "$doif - 1" fi domath ifcurrlvl "$ifcurrlvl - 1" puts "## endifB: ifcurrlvl: $ifcurrlvl doif: $doif" >&9 ;; esac if [ $doproc -eq 1 ]; then case ${tdatline} in command*) _chkconfigfname set $tdatline cmd=$2 shift nm="_command_${cmd}" check_command ${nm} $@ ;; grep*) _chkconfigfname set $tdatline tag=$2 shift nm="_grep_${tag}" check_grep ${nm} $@ ;; "echo"*) _chkconfigfname set $tdatline shift val=$@ check_echo "${val}" ;; "exit") check_exit ;; substitute) check_substitute $@ ;; endinclude) ;; ifoption*|ifnotoption*) _chkconfigfname set $tdatline type=$1 opt=$2 nm="_${type}_${opt}" puts "## if: ifcurrlvl: $ifcurrlvl" >&9 domath ifstmtcount "$ifstmtcount + 1" check_ifoption $ifstmtcount $type ${nm} ${opt} rc=$? iflevels="+$ifstmtcount $iflevels" _setifleveldisp puts "## ifopt iflevels: $iflevels" >&9 doproclist="$doproc $doproclist" doproc=$rc puts "## doproc: $doproc doproclist: $doproclist" >&9 ;; "if "*) _chkconfigfname set $tdatline shift label=$1 shift ifline=$@ domath ifcurrlvl "$ifcurrlvl + 1" puts "## if: ifcurrlvl: $ifcurrlvl" >&9 domath ifstmtcount "$ifstmtcount + 1" check_if $label $ifstmtcount "$ifline" rc=$? iflevels="+$ifstmtcount $iflevels" _setifleveldisp puts "## if iflevels: $iflevels" >&9 doproclist="$doproc $doproclist" doproc=$rc doif=$ifcurrlvl puts "## doproc: $doproc doproclist: $doproclist" >&9 ;; "else") ;; "endif") ;; include) _chkconfigfname ininclude=1 if [ $shreqreadraw -eq 1 ]; then rawarg=-r fi ;; loadunit*) set $tdatline type=$1 file=$2 _doloadunit ${file} N if [ $varsfileopen = T ]; then exec 8>&- varsfileopen=F fi if [ "${_MKCONFIG_PREFIX}" != "" ]; then VARSFILE="../mkc_${CONFHTAG}_${_MKCONFIG_PREFIX}.vars" fi ;; option-file*) set $tdatline type=$1 file=$2 case ${file} in /*) OPTIONFILE=${file} ;; *) OPTIONFILE="../${file}" ;; esac puts "option-file: ${file}" >&1 puts " option file name: ${OPTIONFILE}" >&9 ;; option*) _chkconfigfname set $tdatline optnm=$2 shift; shift tval=$@ nm="_opt_${optnm}" check_option ${nm} $optnm "${tval}" ;; output*) newout=F if [ $varsfileopen = T ]; then exec 8>&- varsfileopen=F newout=T fi if [ $inproc -eq 1 ]; then _create_output CONFH=none CONFHTAG=none CONFHTAGUC=NONE fi if [ $newout = T ]; then new_output_file > $INC # restart include fi set $tdatline type=$1 file=$2 case ${file} in none) CONFH=${file} ;; /*) CONFH=${file} ;; *) CONFH="../${file}" ;; esac puts "output-file: ${file}" >&1 puts " config file name: ${CONFH}" >&9 file=`puts $file | sed -e 's,.*/,,'` file=`puts $file | sed -e 's/\..*//'` CONFHTAG=$file CONFHTAGUC=$file toupper CONFHTAGUC if [ "${_MKCONFIG_PREFIX}" != "" ]; then VARSFILE="../mkc_${CONFHTAG}_${_MKCONFIG_PREFIX}.vars" fi inproc=1 ;; standard) _chkconfigfname standard_checks ;; "set "*|setint*|setstr*) _chkconfigfname set $tdatline type=$1 nm=$2 if [ "$type" = setint -o "$type" = setstr ]; then nm="_${type}_$2" fi shift; shift tval=$@ check_set ${nm} $type "${tval}" ;; *) _chkconfigfname set $tdatline type=$1 chk="check_${type}" cmd="$chk $@" eval $cmd ;; esac fi # doproc fi # ininclude if [ $ininclude -eq 1 ]; then setifs fi done # reset the file descriptors back to the norm. # set stdin to saved fd 7; close fd 7 exec <&7 7<&- if [ $varsfileopen = T ]; then exec 8>&- varsfileopen=F fi _savecache # save the cache file. _create_output } usage () { puts "Usage: $0 [-C] [-c ] [-o ] [-L ] -C : clear cache-file defaults: : mkconfig.cache : mkconfig.log" } # main mkconfigversion unset GREP_OPTIONS unset ENV unalias sed > /dev/null 2>&1 unalias grep > /dev/null 2>&1 unalias ls > /dev/null 2>&1 unalias rm > /dev/null 2>&1 LC_ALL=C export LC_ALL clearcache=0 while test $# -gt 1; do case $1 in -C) shift clearcache=1 ;; -c) shift CACHEFILE=$1 shift ;; -L) shift LOG=$1 shift ;; -o) shift OPTIONFILE=$1 shift ;; esac done configfile=$1 if [ $# -ne 1 ] || [ ! -f $configfile ]; then puts "No configuration file specified or not found." usage exit 1 fi if [ -d $_MKCONFIG_TMP -a $_MKCONFIG_TMP != _tmp_mkconfig ]; then puts "$_MKCONFIG_TMP must not exist." usage exit 1 fi test -d $_MKCONFIG_TMP && rm -rf $_MKCONFIG_TMP > /dev/null 2>&1 mkdir $_MKCONFIG_TMP cd $_MKCONFIG_TMP LOG="../$LOG" REQLIB="../$REQLIB" CACHEFILE="../$CACHEFILE" VARSFILE="../$VARSFILE" OPTIONFILE="../$OPTIONFILE" CONFH=none CONFHTAG=none CONFHTAGUC=NONE if [ $clearcache -eq 1 ]; then rm -f $CACHEFILE > /dev/null 2>&1 rm -f ../mkconfig_*.vars > /dev/null 2>&1 fi dt=`date` exec 9>>$LOG puts "#### " >&9 puts "# Start: $dt " >&9 puts "# $0 ($shell) using $configfile " >&9 puts "#### " >&9 puts "shell: $shell" >&9 puts "has append: ${shhasappend}" >&9 puts "has math: ${shhasmath}" >&9 puts "has upper: ${shhasupper}" >&9 locatecmd awkcmd awk locatecmd nawkcmd nawk locatecmd gawkcmd gawk locatecmd mawkcmd mawk if [ "$nawkcmd" != "" ]; then awkcmd=$nawkcmd fi if [ "$mawkcmd" != "" ]; then awkcmd=$mawkcmd fi if [ "$gawkcmd" != "" ]; then awkcmd=$gawkcmd fi puts "awk: $awkcmd" >&9 puts "$0 ($shell) using $configfile" main_process $configfile dt=`date` puts "#### " >&9 puts "# End: $dt " >&9 puts "#### " >&9 exec 9>&- cd .. if [ "$MKC_KEEP_TMP" = "" ]; then test -d $_MKCONFIG_TMP && rm -rf $_MKCONFIG_TMP > /dev/null 2>&1 fi exit 0 di-4.47/mkconfig/examples/0000755000175000017500000000000013334050206013557 5ustar bllblldi-4.47/mkconfig/examples/dtcltk/0000755000175000017500000000000013334050206015044 5ustar bllblldi-4.47/mkconfig/examples/dtcltk/Makefile0000644000175000017500000000271713334050206016513 0ustar bllbll TCLPATH = /usr TCLVER = 8.5 TCLCONFIG = $(TCLPATH)/lib/tcl$(TCLVER)/tclConfig.sh TCLINCLUDE = $(TCLPATH)/include/tcl$(TCLVER) CC = cc DC = dmd MKCONFIGPATH = ../.. .PHONY: all all: tcl/tcl.d tk/tk.d x11/x.d x11/xlib.d .PHONY: clean clean: -rm -rf hw_tk_d1 hw_tk_d2 *.o \ *.log *.vars *.cache _tmp_mkconfig distclean: @$(MAKE) clean -rm -rf tcl.env tcl tk x11 tcl.env: env.dat CC=$(CC) DC=$(DC) CFLAGS="-I$(TCLINCLUDE) -I$(TCLINCLUDE)/generic" \ TCLVER=$(TCLVER) TCLPATH=$(TCLPATH) \ $(MKCONFIGPATH)/mkconfig.sh env.dat tcl/tcl.d: tcl.dat tcl.env . ./tcl.env; \ CFLAGS="$${TCL_DEFS} $${CFLAGS} " \ LIBS="$${TCL_LIB_FLAG} $${TCL_LIBS}" \ $(MKCONFIGPATH)/mkconfig.sh tcl.dat tk/tk.d: tk.dat tcl.env . ./tcl.env; \ CFLAGS="$${TK_INCLUDE_SPEC} $${TK_DEFS} $${CFLAGS} " \ LIBS="$${TK_LIB_FLAG} $${TK_LIBS}" \ $(MKCONFIGPATH)/mkconfig.sh tk.dat x11/x.d x11/xlib.d: x.dat tcl.env . ./tcl.env; \ CFLAGS="$${CFLAGS} " LIBS="$${LIBS} " \ $(MKCONFIGPATH)/mkconfig.sh x.dat TKFILES=tcl/tcl.d tk/tk.d x11/x.d x11/xlib.d hw_tk_d1: hw_tk_d1.d $(TKFILES) . ./tcl.env; \ $(MKCONFIGPATH)/mkc.sh -complink -c $(DC) -o hw_tk_d1 -- \ $(DFLAGS) $(LDFLAGS) \ $${TK_LIB_SPEC} $${TK_LIBS} \ $${TCL_LIB_SPEC} $${TCL_LIBS} hw_tk_d1.d $(TKFILES) hw_tk_d2: hw_tk_d2.d $(TKFILES) . ./tcl.env; \ $(MKCONFIGPATH)/mkc.sh -complink -c $(DC) -o hw_tk_d2 -- \ $(DFLAGS) $(LDFLAGS) \ $${TK_LIB_SPEC} $${TK_LIBS} \ $${TCL_LIB_SPEC} $${TCL_LIBS} hw_tk_d2.d $(TKFILES) di-4.47/mkconfig/examples/dtcltk/hw_tk_d1.d0000644000175000017500000000126113334050206016711 0ustar bllbllimport std.c.stdio; import std.c.stdlib; import tcl.tcl; import tk.tk; int main(char[][] args) { Tcl_Interp *tcl_interp; Tk_Window mainWindow; tcl_interp = Tcl_CreateInterp(); if(Tcl_Init(tcl_interp) != TCL_OK || Tk_Init(tcl_interp) != TCL_OK) { if(*tcl_interp.result) { fprintf(stderr,"%s: Tcl/Tk_Init: %s\n", args[0] ~ "\0", tcl_interp.result); } exit(1); } mainWindow = Tk_MainWindow(tcl_interp); if (mainWindow == null) { fprintf(stderr, "%s: Tk_MainWindow: %s\n", args[0] ~ "\0", tcl_interp.result); exit(1); } Tcl_Eval(tcl_interp, "label .w -text \"Hello World\""); Tcl_Eval(tcl_interp, "pack .w"); Tk_MainLoop(); return 0; } di-4.47/mkconfig/examples/dtcltk/tcl.dat0000644000175000017500000014215013334050206016323 0ustar bllbllloadunit d-main noprefix output tcl/tcl.d module tcl.tcl standard chdr tcl.h chdr tclDecls.h tcl.h chdr tclPlatDecls.h tcl.h chdr tclTomMathDecls.h tcl.h chdr tclTomMath.h tcl.h chdr utime.h chdr stdarg.h csys stat.h chdr tchar.h csizes cstruct timespec ctype int __dev_t ctype int fflags_t ctype int ino_t ctype int __ino_t ctype int __ino64_t ctype int mode_t ctype int __mode_t ctype int nlink_t ctype int __nlink_t ctype int off_t ctype int __off_t ctype int __off64_t ctype int blksize_t ctype int __blksize_t ctype int blkcnt_t ctype int __blkcnt_t ctype int __blkcnt64_t ctype int uid_t ctype int __uid_t ctype int gid_t ctype int __gid_t ctype int time_t ctype int __time_t ctype int int32_t ctype int __int32_t ctype int uint32_t ctype int __uint32_t cstruct stat cstruct stat64 cdefine int TCL_ALPHA_RELEASE cdefine int TCL_BETA_RELEASE cdefine int TCL_FINAL_RELEASE cdefine int TCL_MAJOR_VERSION cdefine int TCL_MINOR_VERSION cdefine int TCL_RELEASE_LEVEL cdefine int TCL_RELEASE_SERIAL cdefine string TCL_VERSION cdefine string TCL_PATCH_LEVEL ctypedef ClientData ctype int Tcl_WideInt ctype int Tcl_WideUInt ctypedef Tcl_StatBuf cstruct Tcl_Interp ctypedef Tcl_ThreadCreateProc cdefine int TCL_THREAD_STACK_DEFAULT cdefine int TCL_THREAD_NOFLAGS cdefine int TCL_THREAD_JOINABLE cdefine int TCL_MATCH_NOCASE cdefine int TCL_REG_BASIC cdefine int TCL_REG_EXTENDED cdefine int TCL_REG_ADVF cdefine int TCL_REG_ADVANCED cdefine int TCL_REG_QUOTE cdefine int TCL_REG_NOCASE cdefine int TCL_REG_NOSUB cdefine int TCL_REG_EXPANDED cdefine int TCL_REG_NLSTOP cdefine int TCL_REG_NLANCH cdefine int TCL_REG_NEWLINE cdefine int TCL_REG_CANMATCH cdefine int TCL_REG_NOTBOL cdefine int TCL_REG_NOTEOL cstruct Tcl_RegExpIndices cstruct Tcl_RegExpInfo ctypedef Tcl_Stat_ ctypedef Tcl_OldStat_ cdefine int TCL_OK cdefine int TCL_ERROR cdefine int TCL_RETURN cdefine int TCL_BREAK cdefine int TCL_CONTINUE cdefine int TCL_RESULT_SIZE cdefine int TCL_SUBST_COMMANDS cdefine int TCL_SUBST_VARIABLES cdefine int TCL_SUBST_BACKSLASHES cdefine int TCL_SUBST_ALL cenum Tcl_ValueType cstruct Tcl_Value cstruct Tcl_DString ctypedef Tcl_AppInitProc ctypedef Tcl_AsyncProc ctypedef Tcl_ChannelProc ctypedef Tcl_CloseProc ctypedef Tcl_CmdDeleteProc ctypedef Tcl_CmdProc ctypedef Tcl_CmdTraceProc ctypedef Tcl_CmdObjTraceProc ctypedef Tcl_CmdObjTraceDeleteProc ctypedef Tcl_DupInternalRepProc ctypedef Tcl_EncodingConvertProc ctypedef Tcl_EncodingFreeProc ctypedef Tcl_EventProc ctypedef Tcl_EventCheckProc ctypedef Tcl_EventDeleteProc ctypedef Tcl_EventSetupProc ctypedef Tcl_ExitProc ctypedef Tcl_FileProc ctypedef Tcl_FileFreeProc ctypedef Tcl_FreeInternalRepProc ctypedef Tcl_FreeProc ctypedef Tcl_IdleProc ctypedef Tcl_InterpDeleteProc ctypedef Tcl_MathProc ctypedef Tcl_NamespaceDeleteProc ctypedef Tcl_ObjCmdProc ctypedef Tcl_PackageInitProc ctypedef Tcl_PackageUnloadProc ctypedef Tcl_PanicProc ctypedef Tcl_TcpAcceptProc ctypedef Tcl_TimerProc ctypedef Tcl_SetFromAnyProc ctypedef Tcl_UpdateStringProc ctypedef Tcl_VarTraceProc ctypedef Tcl_CommandTraceProc ctypedef Tcl_CreateFileHandlerProc ctypedef Tcl_DeleteFileHandlerProc ctypedef Tcl_AlertNotifierProc ctypedef Tcl_ServiceModeHookProc ctypedef Tcl_InitNotifierProc ctypedef Tcl_FinalizeNotifierProc ctypedef Tcl_MainLoopProc cstruct Tcl_ObjType cstruct Tcl_Obj cmacro ckalloc tcl.h 'char *' uint cmacro ckfree tcl.h void 'char *' cmacro ckrealloc tcl.h 'char *' 'char *' uint cmacro attemptckalloc tcl.h 'char *' uint cmacro attemptckrealloc tcl.h 'char *' 'char *' uint cmacro Tcl_InitMemory tcl.h void 'Tcl_Interp *' cmacro Tcl_DumpActiveMemory tcl.h void 'char *' cmacro Tcl_ValidateAllMemory tcl.h void 'char *' int cdcl Tcl_IncrRefCount clib Tcl_IncrRefCount if lib_Tcl_IncrRefCount ! _clib_Tcl_IncrRefCount cmacro Tcl_IncrRefCount tcl.h void 'Tcl_Obj *' endif cdcl Tcl_DecrRefCount clib Tcl_DecrRefCount if lib_Tcl_DecrRefCount ! _clib_Tcl_DecrRefCount cmacro Tcl_DecrRefCount tcl.h void 'Tcl_Obj *' endif cdcl Tcl_IsShared clib Tcl_IsShared if lib_Tcl_IsShared ! _clib_Tcl_IsShared cmacro Tcl_IsShared tcl.h int 'Tcl_Obj *' endif cstruct Tcl_SavedResult cstruct Tcl_Namespace cstruct Tcl_CallFrame cstruct Tcl_CmdInfo cdefine int TCL_DSTRING_STATIC_SIZE cmacro Tcl_DStringLength tcl.h int 'Tcl_DString *' cmacro Tcl_DStringValue tcl.h 'char *' 'Tcl_DString *' cdefine int TCL_MAX_PREC cdefine int TCL_DOUBLE_SPACE cdefine int TCL_INTEGER_SPACE cdefine int TCL_DONT_USE_BRACES cdefine int TCL_DONT_QUOTE_HASH cdefine int TCL_EXACT cdefine hex TCL_NO_EVAL cdefine hex TCL_EVAL_GLOBAL cdefine hex TCL_EVAL_DIRECT cdefine hex TCL_EVAL_INVOKE cmacro TCL_VOLATILE tcl.h 'Tcl_FreeProc *' cmacro TCL_STATIC tcl.h 'Tcl_FreeProc *' cmacro TCL_DYNAMIC tcl.h 'Tcl_FreeProc *' cdefine int TCL_GLOBAL_ONLY cdefine int TCL_NAMESPACE_ONLY cdefine int TCL_APPEND_VALUE cdefine int TCL_LIST_ELEMENT cdefine hex TCL_TRACE_READS cdefine hex TCL_TRACE_WRITES cdefine hex TCL_TRACE_UNSETS cdefine hex TCL_TRACE_DESTROYED cdefine hex TCL_INTERP_DESTROYED cdefine hex TCL_LEAVE_ERR_MSG cdefine hex TCL_TRACE_ARRAY cdefine hex TCL_TRACE_OLD_STYLE cdefine hex TCL_TRACE_RESULT_DYNAMIC cdefine hex TCL_TRACE_RESULT_OBJECT cdefine hex TCL_ENSEMBLE_PREFIX cdefine hex TCL_TRACE_RENAME cdefine hex TCL_TRACE_DELETE cdefine hex TCL_ALLOW_INLINE_COMPILATION cdefine int TCL_LINK_INT cdefine int TCL_LINK_DOUBLE cdefine int TCL_LINK_BOOLEAN cdefine int TCL_LINK_STRING cdefine int TCL_LINK_WIDE_INT cdefine int TCL_LINK_CHAR cdefine int TCL_LINK_UCHAR cdefine int TCL_LINK_SHORT cdefine int TCL_LINK_USHORT cdefine int TCL_LINK_UINT cdefine int TCL_LINK_LONG cdefine int TCL_LINK_ULONG cdefine int TCL_LINK_FLOAT cdefine int TCL_LINK_WIDE_UINT cdefine hex TCL_LINK_READ_ONLY ctypedef Tcl_HashKeyProc ctypedef Tcl_CompareHashKeysProc ctypedef Tcl_AllocHashEntryProc ctypedef Tcl_FreeHashEntryProc cdefine int TCL_HASH_KEY_STORE_HASH cstruct Tcl_HashEntry ctypedef Tcl_HashEntry cdefine hex TCL_HASH_KEY_RANDOMIZE_HASH cdefine hex TCL_HASH_KEY_SYSTEM_HASH cdefine hex TCL_HASH_KEY_TYPE_VERSION cstruct Tcl_HashKeyType ctypedef Tcl_HashKeyType cdefine int TCL_SMALL_HASH_TABLE cstruct Tcl_HashTable ctypedef Tcl_HashTable cstruct Tcl_HashSearch cdefine int TCL_STRING_KEYS cdefine int TCL_ONE_WORD_KEYS cdefine int TCL_CUSTOM_TYPE_KEYS cdefine int TCL_CUSTOM_PTR_KEYS cstruct Tcl_DictSearch cdefine int TCL_DONT_WAIT cdefine int TCL_WINDOW_EVENTS cdefine int TCL_FILE_EVENTS cdefine int TCL_TIMER_EVENTS cdefine int TCL_IDLE_EVENTS cdefine int TCL_ALL_EVENTS cstruct Tcl_Event ctypedef Tcl_Event cenum Tcl_QueuePosition cdefine int TCL_SERVICE_NONE cdefine int TCL_SERVICE_ALL cstruct Tcl_Time ctypedef Tcl_SetTimerProc ctypedef Tcl_WaitForEventProc ctypedef Tcl_GetTimeProc ctypedef Tcl_ScaleTimeProc cdefine int TCL_READABLE cdefine int TCL_WRITABLE cdefine int TCL_EXCEPTION cdefine int TCL_STDIN cdefine int TCL_STDOUT cdefine int TCL_STDERR cdefine int TCL_ENFORCE_MODE cdefine int TCL_CLOSE_READ cdefine int TCL_CLOSE_WRITE cmacro TCL_CLOSE2PROC tcl.h 'Tcl_DriverCloseProc *' cdefine int TCL_CHANNEL_VERSION_1 cdefine int TCL_CHANNEL_VERSION_2 cdefine int TCL_CHANNEL_VERSION_3 cdefine int TCL_CHANNEL_VERSION_4 cdefine int TCL_CHANNEL_VERSION_5 cdefine int TCL_CHANNEL_THREAD_INSERT cdefine int TCL_CHANNEL_THREAD_REMOVE ctypedef Tcl_DriverBlockModeProc ctypedef Tcl_DriverCloseProc ctypedef Tcl_DriverClose2Proc ctypedef Tcl_DriverInputProc ctypedef Tcl_DriverOutputProc ctypedef Tcl_DriverSeekProc ctypedef Tcl_DriverSetOptionProc ctypedef Tcl_DriverGetOptionProc ctypedef Tcl_DriverWatchProc ctypedef Tcl_DriverGetHandleProc ctypedef Tcl_DriverFlushProc ctypedef Tcl_DriverHandlerProc ctypedef Tcl_DriverWideSeekProc ctypedef Tcl_DriverThreadActionProc ctypedef Tcl_DriverTruncateProc cstruct Tcl_ChannelType cdefine int TCL_MODE_BLOCKING cdefine int TCL_MODE_NONBLOCKING cenum Tcl_PathType cstruct Tcl_GlobTypeData cdefine int TCL_GLOB_TYPE_BLOCK cdefine int TCL_GLOB_TYPE_CHAR cdefine int TCL_GLOB_TYPE_DIR cdefine int TCL_GLOB_TYPE_PIPE cdefine int TCL_GLOB_TYPE_FILE cdefine int TCL_GLOB_TYPE_LINK cdefine int TCL_GLOB_TYPE_SOCK cdefine int TCL_GLOB_TYPE_MOUNT cdefine int TCL_GLOB_PERM_RONLY cdefine int TCL_GLOB_PERM_HIDDEN cdefine int TCL_GLOB_PERM_R cdefine int TCL_GLOB_PERM_W cdefine int TCL_GLOB_PERM_X cdefine int TCL_UNLOAD_DETACH_FROM_INTERPRETER cdefine int TCL_UNLOAD_DETACH_FROM_PROCESS ctypedef Tcl_FSStatProc ctypedef Tcl_FSAccessProc ctypedef Tcl_FSOpenFileChannelProc ctypedef Tcl_FSMatchInDirectoryProc ctypedef Tcl_FSGetCwdProc ctypedef Tcl_FSChdirProc ctypedef Tcl_FSLstatProc ctypedef Tcl_FSCreateDirectoryProc ctypedef Tcl_FSDeleteFileProc ctypedef Tcl_FSCopyDirectoryProc ctypedef Tcl_FSCopyFileProc ctypedef Tcl_FSRemoveDirectoryProc ctypedef Tcl_FSRenameFileProc ctypedef Tcl_FSUnloadFileProc ctypedef Tcl_FSListVolumesProc cstruct utimbuf ctypedef Tcl_FSUtimeProc ctypedef Tcl_FSNormalizePathProc ctypedef Tcl_FSFileAttrsGetProc ctypedef Tcl_FSFileAttrStringsProc ctypedef Tcl_FSFileAttrsSetProc ctypedef Tcl_FSLinkProc ctypedef Tcl_FSLoadFileProc ctypedef Tcl_FSPathInFilesystemProc ctypedef Tcl_FSFilesystemPathTypeProc ctypedef Tcl_FSFilesystemSeparatorProc ctypedef Tcl_FSFreeInternalRepProc ctypedef Tcl_FSDupInternalRepProc ctypedef Tcl_FSInternalToNormalizedProc ctypedef Tcl_FSCreateInternalRepProc cdefine int TCL_FILESYSTEM_VERSION_1 cstruct Tcl_Filesystem cdefine hex TCL_CREATE_SYMBOLIC_LINK cdefine hex TCL_CREATE_HARD_LINK cstruct Tcl_NotifierProcs cstruct Tcl_EncodingType cdefine hex TCL_ENCODING_START cdefine hex TCL_ENCODING_END cdefine hex TCL_ENCODING_STOPONERROR cstruct Tcl_Token cdefine int TCL_TOKEN_WORD cdefine int TCL_TOKEN_SIMPLE_WORD cdefine int TCL_TOKEN_TEXT cdefine int TCL_TOKEN_BS cdefine int TCL_TOKEN_COMMAND cdefine int TCL_TOKEN_VARIABLE cdefine int TCL_TOKEN_SUB_EXPR cdefine int TCL_TOKEN_OPERATOR cdefine int TCL_TOKEN_EXPAND_WORD cdefine int TCL_PARSE_SUCCESS cdefine int TCL_PARSE_QUOTE_EXTRA cdefine int TCL_PARSE_BRACE_EXTRA cdefine int TCL_PARSE_MISSING_BRACE cdefine int TCL_PARSE_MISSING_BRACKET cdefine int TCL_PARSE_MISSING_PAREN cdefine int TCL_PARSE_MISSING_QUOTE cdefine int TCL_PARSE_MISSING_VAR_BRACE cdefine int TCL_PARSE_SYNTAX cdefine int TCL_PARSE_BAD_NUMBER cdefine int NUM_STATIC_TOKENS cstruct Tcl_Parse cdefine int TCL_CONVERT_MULTIBYTE cdefine int TCL_CONVERT_SYNTAX cdefine int TCL_CONVERT_UNKNOWN cdefine int TCL_CONVERT_NOSPACE cdefine int TCL_UTF_MAX ctypedef Tcl_UniChar cstruct Tcl_Config cdefine hex TCL_LIMIT_COMMANDS cdefine hex TCL_LIMIT_TIME ctypedef Tcl_LimitHandlerProc ctypedef Tcl_LimitHandlerDeleteProc cdefine hex TCL_STUB_MAGIC cdcl Tcl_InitStubs clib Tcl_InitStubs cdcl TclTomMathInitializeStubs clib TclTomMathInitializeStubs if lib_TclInitStubs ! _lib_Tcl_InitStubs cmacro Tcl_InitStubs tcl.h 'char *' 'Tcl_Interp *' 'char *' int endif if lib_TclTomMathInitializeStubs ! _lib_TclTomMathInitializeStubs cmacro TclTomMathInitializeStubs tcl.h 'char *' 'Tcl_Interp *' 'char *' int int endif cdcl Tcl_Main clib Tcl_Main cdcl Tcl_PkgInitStubsCheck clib Tcl_PkgInitStubsCheck cdcl Tcl_GetMemoryInfo clib Tcl_GetMemoryInfo cmacro Tcl_GetHashValue tcl.h ClientData 'Tcl_HashEntry *' cmacro Tcl_SetHashValue tcl.h ClientData 'Tcl_HashEntry *' ClientData ClientData cmacro Tcl_GetHashKey tcl.h 'void *' 'Tcl_HashTable' 'Tcl_HashEntry *' cmacro Tcl_FindHashEntry tcl.h 'Tcl_HashEntry *' 'Tcl_HashTable *' 'char *' cmacro Tcl_CreateHashEntry tcl.h 'Tcl_HashEntry *' 'Tcl_HashTable *' 'char *' 'int *' # for Tcl_GetHashKey substitute h.string 'cast(void *)h.string' substitute h.oneWordValue 'cast(void *)h.oneWordValue' include alias void * Tcl_AsyncHandler; alias void * Tcl_Channel; alias void * Tcl_ChannelTypeVersion; alias void * Tcl_Command; alias void * Tcl_Condition; alias void * Tcl_Dict; alias void * Tcl_EncodingState; alias void * Tcl_Encoding; alias void * Tcl_InterpState; alias void * Tcl_LoadHandle; alias void * Tcl_Mutex; alias void * Tcl_Pid; alias void * Tcl_RegExp; alias void * Tcl_ThreadDataKey; alias void * Tcl_ThreadId; alias void * Tcl_TimerToken; alias void * Tcl_Trace; alias void * Tcl_Var; alias void * Tcl_FSVersion; alias Tcl_DStringSetLength Tcl_DStringTrunc; endinclude cdcl Tcl_PkgProvideEx clib Tcl_PkgProvideEx cdcl Tcl_PkgRequireEx clib Tcl_PkgRequireEx cdcl Tcl_Panic clib Tcl_Panic cdcl Tcl_Alloc clib Tcl_Alloc cdcl Tcl_Free clib Tcl_Free cdcl Tcl_Realloc clib Tcl_Realloc cdcl Tcl_DbCkalloc clib Tcl_DbCkalloc cdcl Tcl_DbCkfree clib Tcl_DbCkfree cdcl Tcl_DbCkrealloc clib Tcl_DbCkrealloc cdcl Tcl_CreateFileHandler clib Tcl_CreateFileHandler cdcl Tcl_DeleteFileHandler clib Tcl_DeleteFileHandler cdcl Tcl_SetTimer clib Tcl_SetTimer cdcl Tcl_Sleep clib Tcl_Sleep cdcl Tcl_WaitForEvent clib Tcl_WaitForEvent cdcl Tcl_AppendAllObjTypes clib Tcl_AppendAllObjTypes cdcl Tcl_AppendStringsToObj clib Tcl_AppendStringsToObj cdcl Tcl_AppendToObj clib Tcl_AppendToObj cdcl Tcl_ConcatObj clib Tcl_ConcatObj cdcl Tcl_ConvertToType clib Tcl_ConvertToType cdcl Tcl_DbDecrRefCount clib Tcl_DbDecrRefCount cdcl Tcl_DbIncrRefCount clib Tcl_DbIncrRefCount cdcl Tcl_DbIsShared clib Tcl_DbIsShared cdcl Tcl_DbNewBooleanObj clib Tcl_DbNewBooleanObj cdcl Tcl_DbNewByteArrayObj clib Tcl_DbNewByteArrayObj cdcl Tcl_DbNewDoubleObj clib Tcl_DbNewDoubleObj cdcl Tcl_DbNewListObj clib Tcl_DbNewListObj cdcl Tcl_DbNewLongObj clib Tcl_DbNewLongObj cdcl Tcl_DbNewObj clib Tcl_DbNewObj cdcl Tcl_DbNewStringObj clib Tcl_DbNewStringObj cdcl Tcl_DuplicateObj clib Tcl_DuplicateObj cdcl TclFreeObj clib TclFreeObj cdcl Tcl_GetBoolean clib Tcl_GetBoolean cdcl Tcl_GetBooleanFromObj clib Tcl_GetBooleanFromObj cdcl Tcl_GetByteArrayFromObj clib Tcl_GetByteArrayFromObj cdcl Tcl_GetDouble clib Tcl_GetDouble cdcl Tcl_GetDoubleFromObj clib Tcl_GetDoubleFromObj cdcl Tcl_GetIndexFromObj clib Tcl_GetIndexFromObj cdcl Tcl_GetInt clib Tcl_GetInt cdcl Tcl_GetIntFromObj clib Tcl_GetIntFromObj cdcl Tcl_GetLongFromObj clib Tcl_GetLongFromObj cdcl Tcl_GetObjType clib Tcl_GetObjType cdcl Tcl_GetStringFromObj clib Tcl_GetStringFromObj cdcl Tcl_InvalidateStringRep clib Tcl_InvalidateStringRep cdcl Tcl_ListObjAppendList clib Tcl_ListObjAppendList cdcl Tcl_ListObjAppendElement clib Tcl_ListObjAppendElement cdcl Tcl_ListObjGetElements clib Tcl_ListObjGetElements cdcl Tcl_ListObjIndex clib Tcl_ListObjIndex cdcl Tcl_ListObjLength clib Tcl_ListObjLength cdcl Tcl_ListObjReplace clib Tcl_ListObjReplace cdcl Tcl_NewBooleanObj clib Tcl_NewBooleanObj cdcl Tcl_NewByteArrayObj clib Tcl_NewByteArrayObj cdcl Tcl_NewDoubleObj clib Tcl_NewDoubleObj cdcl Tcl_NewIntObj clib Tcl_NewIntObj cdcl Tcl_NewListObj clib Tcl_NewListObj cdcl Tcl_NewLongObj clib Tcl_NewLongObj cdcl Tcl_NewObj clib Tcl_NewObj cdcl Tcl_NewStringObj clib Tcl_NewStringObj cdcl Tcl_SetBooleanObj clib Tcl_SetBooleanObj cdcl Tcl_SetByteArrayLength clib Tcl_SetByteArrayLength cdcl Tcl_SetByteArrayObj clib Tcl_SetByteArrayObj cdcl Tcl_SetDoubleObj clib Tcl_SetDoubleObj cdcl Tcl_SetIntObj clib Tcl_SetIntObj cdcl Tcl_SetListObj clib Tcl_SetListObj cdcl Tcl_SetLongObj clib Tcl_SetLongObj cdcl Tcl_SetObjLength clib Tcl_SetObjLength cdcl Tcl_SetStringObj clib Tcl_SetStringObj cdcl Tcl_AddErrorInfo clib Tcl_AddErrorInfo cdcl Tcl_AddObjErrorInfo clib Tcl_AddObjErrorInfo cdcl Tcl_AllowExceptions clib Tcl_AllowExceptions cdcl Tcl_AppendElement clib Tcl_AppendElement cdcl Tcl_AppendResult clib Tcl_AppendResult cdcl Tcl_AsyncCreate clib Tcl_AsyncCreate cdcl Tcl_AsyncDelete clib Tcl_AsyncDelete cdcl Tcl_AsyncInvoke clib Tcl_AsyncInvoke cdcl Tcl_AsyncMark clib Tcl_AsyncMark cdcl Tcl_AsyncReady clib Tcl_AsyncReady cdcl Tcl_BackgroundError clib Tcl_BackgroundError cdcl Tcl_Backslash clib Tcl_Backslash cdcl Tcl_BadChannelOption clib Tcl_BadChannelOption cdcl Tcl_CallWhenDeleted clib Tcl_CallWhenDeleted cdcl Tcl_CancelIdleCall clib Tcl_CancelIdleCall cdcl Tcl_Close clib Tcl_Close cdcl Tcl_CommandComplete clib Tcl_CommandComplete cdcl Tcl_Concat clib Tcl_Concat cdcl Tcl_ConvertElement clib Tcl_ConvertElement cdcl Tcl_ConvertCountedElement clib Tcl_ConvertCountedElement cdcl Tcl_CreateAlias clib Tcl_CreateAlias cdcl Tcl_CreateAliasObj clib Tcl_CreateAliasObj cdcl Tcl_CreateChannel clib Tcl_CreateChannel cdcl Tcl_CreateChannelHandler clib Tcl_CreateChannelHandler cdcl Tcl_CreateCloseHandler clib Tcl_CreateCloseHandler cdcl Tcl_CreateCommand clib Tcl_CreateCommand cdcl Tcl_CreateEventSource clib Tcl_CreateEventSource cdcl Tcl_CreateExitHandler clib Tcl_CreateExitHandler cdcl Tcl_CreateInterp clib Tcl_CreateInterp cdcl Tcl_CreateMathFunc clib Tcl_CreateMathFunc cdcl Tcl_CreateObjCommand clib Tcl_CreateObjCommand cdcl Tcl_CreateSlave clib Tcl_CreateSlave cdcl Tcl_CreateTimerHandler clib Tcl_CreateTimerHandler cdcl Tcl_CreateTrace clib Tcl_CreateTrace cdcl Tcl_DeleteAssocData clib Tcl_DeleteAssocData cdcl Tcl_DeleteChannelHandler clib Tcl_DeleteChannelHandler cdcl Tcl_DeleteCloseHandler clib Tcl_DeleteCloseHandler cdcl Tcl_DeleteCommand clib Tcl_DeleteCommand cdcl Tcl_DeleteCommandFromToken clib Tcl_DeleteCommandFromToken cdcl Tcl_DeleteEvents clib Tcl_DeleteEvents cdcl Tcl_DeleteEventSource clib Tcl_DeleteEventSource cdcl Tcl_DeleteExitHandler clib Tcl_DeleteExitHandler cdcl Tcl_DeleteHashEntry clib Tcl_DeleteHashEntry cdcl Tcl_DeleteHashTable clib Tcl_DeleteHashTable cdcl Tcl_DeleteInterp clib Tcl_DeleteInterp cdcl Tcl_DetachPids clib Tcl_DetachPids cdcl Tcl_DeleteTimerHandler clib Tcl_DeleteTimerHandler cdcl Tcl_DeleteTrace clib Tcl_DeleteTrace cdcl Tcl_DontCallWhenDeleted clib Tcl_DontCallWhenDeleted cdcl Tcl_DoOneEvent clib Tcl_DoOneEvent cdcl Tcl_DoWhenIdle clib Tcl_DoWhenIdle cdcl Tcl_DStringAppend clib Tcl_DStringAppend cdcl Tcl_DStringAppendElement clib Tcl_DStringAppendElement cdcl Tcl_DStringEndSublist clib Tcl_DStringEndSublist cdcl Tcl_DStringFree clib Tcl_DStringFree cdcl Tcl_DStringGetResult clib Tcl_DStringGetResult cdcl Tcl_DStringInit clib Tcl_DStringInit cdcl Tcl_DStringResult clib Tcl_DStringResult cdcl Tcl_DStringSetLength clib Tcl_DStringSetLength cdcl Tcl_DStringStartSublist clib Tcl_DStringStartSublist cdcl Tcl_Eof clib Tcl_Eof cdcl Tcl_ErrnoId clib Tcl_ErrnoId cdcl Tcl_ErrnoMsg clib Tcl_ErrnoMsg cdcl Tcl_Eval clib Tcl_Eval cdcl Tcl_EvalFile clib Tcl_EvalFile cdcl Tcl_EvalObj clib Tcl_EvalObj cdcl Tcl_EventuallyFree clib Tcl_EventuallyFree cdcl Tcl_Exit clib Tcl_Exit cdcl Tcl_ExposeCommand clib Tcl_ExposeCommand cdcl Tcl_ExprBoolean clib Tcl_ExprBoolean cdcl Tcl_ExprBooleanObj clib Tcl_ExprBooleanObj cdcl Tcl_ExprDouble clib Tcl_ExprDouble cdcl Tcl_ExprDoubleObj clib Tcl_ExprDoubleObj cdcl Tcl_ExprLong clib Tcl_ExprLong cdcl Tcl_ExprLongObj clib Tcl_ExprLongObj cdcl Tcl_ExprObj clib Tcl_ExprObj cdcl Tcl_ExprString clib Tcl_ExprString cdcl Tcl_Finalize clib Tcl_Finalize cdcl Tcl_FindExecutable clib Tcl_FindExecutable cdcl Tcl_FirstHashEntry clib Tcl_FirstHashEntry cdcl Tcl_Flush clib Tcl_Flush cdcl Tcl_FreeResult clib Tcl_FreeResult cdcl Tcl_GetAlias clib Tcl_GetAlias cdcl Tcl_GetAliasObj clib Tcl_GetAliasObj cdcl Tcl_GetAssocData clib Tcl_GetAssocData cdcl Tcl_GetChannel clib Tcl_GetChannel cdcl Tcl_GetChannelBufferSize clib Tcl_GetChannelBufferSize cdcl Tcl_GetChannelHandle clib Tcl_GetChannelHandle cdcl Tcl_GetChannelInstanceData clib Tcl_GetChannelInstanceData cdcl Tcl_GetChannelMode clib Tcl_GetChannelMode cdcl Tcl_GetChannelName clib Tcl_GetChannelName cdcl Tcl_GetChannelOption clib Tcl_GetChannelOption cdcl Tcl_GetChannelType clib Tcl_GetChannelType cdcl Tcl_GetCommandInfo clib Tcl_GetCommandInfo cdcl Tcl_GetCommandName clib Tcl_GetCommandName cdcl Tcl_GetErrno clib Tcl_GetErrno cdcl Tcl_GetHostName clib Tcl_GetHostName cdcl Tcl_GetInterpPath clib Tcl_GetInterpPath cdcl Tcl_GetMaster clib Tcl_GetMaster cdcl Tcl_GetNameOfExecutable clib Tcl_GetNameOfExecutable cdcl Tcl_GetObjResult clib Tcl_GetObjResult cdcl Tcl_GetOpenFile clib Tcl_GetOpenFile cdcl Tcl_GetPathType clib Tcl_GetPathType cdcl Tcl_Gets clib Tcl_Gets cdcl Tcl_GetsObj clib Tcl_GetsObj cdcl Tcl_GetServiceMode clib Tcl_GetServiceMode cdcl Tcl_GetSlave clib Tcl_GetSlave cdcl Tcl_GetStdChannel clib Tcl_GetStdChannel cdcl Tcl_GetStringResult clib Tcl_GetStringResult cdcl Tcl_GetVar clib Tcl_GetVar cdcl Tcl_GetVar2 clib Tcl_GetVar2 cdcl Tcl_GlobalEval clib Tcl_GlobalEval cdcl Tcl_GlobalEvalObj clib Tcl_GlobalEvalObj cdcl Tcl_HideCommand clib Tcl_HideCommand cdcl Tcl_Init clib Tcl_Init cdcl Tcl_InitHashTable clib Tcl_InitHashTable cdcl Tcl_InputBlocked clib Tcl_InputBlocked cdcl Tcl_InputBuffered clib Tcl_InputBuffered cdcl Tcl_InterpDeleted clib Tcl_InterpDeleted cdcl Tcl_IsSafe clib Tcl_IsSafe cdcl Tcl_JoinPath clib Tcl_JoinPath cdcl Tcl_LinkVar clib Tcl_LinkVar cdcl Tcl_MakeFileChannel clib Tcl_MakeFileChannel cdcl Tcl_MakeSafe clib Tcl_MakeSafe cdcl Tcl_MakeTcpClientChannel clib Tcl_MakeTcpClientChannel cdcl Tcl_Merge clib Tcl_Merge cdcl Tcl_NextHashEntry clib Tcl_NextHashEntry cdcl Tcl_NotifyChannel clib Tcl_NotifyChannel cdcl Tcl_ObjGetVar2 clib Tcl_ObjGetVar2 cdcl Tcl_ObjSetVar2 clib Tcl_ObjSetVar2 cdcl Tcl_OpenCommandChannel clib Tcl_OpenCommandChannel cdcl Tcl_OpenFileChannel clib Tcl_OpenFileChannel cdcl Tcl_OpenTcpClient clib Tcl_OpenTcpClient cdcl Tcl_OpenTcpServer clib Tcl_OpenTcpServer cdcl Tcl_Preserve clib Tcl_Preserve cdcl Tcl_PrintDouble clib Tcl_PrintDouble cdcl Tcl_PutEnv clib Tcl_PutEnv cdcl Tcl_PosixError clib Tcl_PosixError cdcl Tcl_QueueEvent clib Tcl_QueueEvent cdcl Tcl_Read clib Tcl_Read cdcl Tcl_ReapDetachedProcs clib Tcl_ReapDetachedProcs cdcl Tcl_RecordAndEval clib Tcl_RecordAndEval cdcl Tcl_RecordAndEvalObj clib Tcl_RecordAndEvalObj cdcl Tcl_RegisterChannel clib Tcl_RegisterChannel cdcl Tcl_RegisterObjType clib Tcl_RegisterObjType cdcl Tcl_RegExpCompile clib Tcl_RegExpCompile cdcl Tcl_RegExpExec clib Tcl_RegExpExec cdcl Tcl_RegExpMatch clib Tcl_RegExpMatch cdcl Tcl_RegExpRange clib Tcl_RegExpRange cdcl Tcl_Release clib Tcl_Release cdcl Tcl_ResetResult clib Tcl_ResetResult cdcl Tcl_ScanElement clib Tcl_ScanElement cdcl Tcl_ScanCountedElement clib Tcl_ScanCountedElement cdcl Tcl_SeekOld clib Tcl_SeekOld cdcl Tcl_ServiceAll clib Tcl_ServiceAll cdcl Tcl_ServiceEvent clib Tcl_ServiceEvent cdcl Tcl_SetAssocData clib Tcl_SetAssocData cdcl Tcl_SetChannelBufferSize clib Tcl_SetChannelBufferSize cdcl Tcl_SetChannelOption clib Tcl_SetChannelOption cdcl Tcl_SetCommandInfo clib Tcl_SetCommandInfo cdcl Tcl_SetErrno clib Tcl_SetErrno cdcl Tcl_SetErrorCode clib Tcl_SetErrorCode cdcl Tcl_SetMaxBlockTime clib Tcl_SetMaxBlockTime cdcl Tcl_SetPanicProc clib Tcl_SetPanicProc cdcl Tcl_SetRecursionLimit clib Tcl_SetRecursionLimit cdcl Tcl_SetResult clib Tcl_SetResult cdcl Tcl_SetServiceMode clib Tcl_SetServiceMode cdcl Tcl_SetObjErrorCode clib Tcl_SetObjErrorCode cdcl Tcl_SetObjResult clib Tcl_SetObjResult cdcl Tcl_SetStdChannel clib Tcl_SetStdChannel cdcl Tcl_SetVar clib Tcl_SetVar cdcl Tcl_SetVar2 clib Tcl_SetVar2 cdcl Tcl_SignalId clib Tcl_SignalId cdcl Tcl_SignalMsg clib Tcl_SignalMsg cdcl Tcl_SourceRCFile clib Tcl_SourceRCFile cdcl Tcl_SplitList clib Tcl_SplitList cdcl Tcl_SplitPath clib Tcl_SplitPath cdcl Tcl_StaticPackage clib Tcl_StaticPackage cdcl Tcl_StringMatch clib Tcl_StringMatch cdcl Tcl_TellOld clib Tcl_TellOld cdcl Tcl_TraceVar clib Tcl_TraceVar cdcl Tcl_TraceVar2 clib Tcl_TraceVar2 cdcl Tcl_TranslateFileName clib Tcl_TranslateFileName cdcl Tcl_Ungets clib Tcl_Ungets cdcl Tcl_UnlinkVar clib Tcl_UnlinkVar cdcl Tcl_UnregisterChannel clib Tcl_UnregisterChannel cdcl Tcl_UnsetVar clib Tcl_UnsetVar cdcl Tcl_UnsetVar2 clib Tcl_UnsetVar2 cdcl Tcl_UntraceVar clib Tcl_UntraceVar cdcl Tcl_UntraceVar2 clib Tcl_UntraceVar2 cdcl Tcl_UpdateLinkedVar clib Tcl_UpdateLinkedVar cdcl Tcl_UpVar clib Tcl_UpVar cdcl Tcl_UpVar2 clib Tcl_UpVar2 cdcl Tcl_VarEval clib Tcl_VarEval cdcl Tcl_VarTraceInfo clib Tcl_VarTraceInfo cdcl Tcl_VarTraceInfo2 clib Tcl_VarTraceInfo2 cdcl Tcl_Write clib Tcl_Write cdcl Tcl_WrongNumArgs clib Tcl_WrongNumArgs cdcl Tcl_DumpActiveMemory clib Tcl_DumpActiveMemory cdcl Tcl_ValidateAllMemory clib Tcl_ValidateAllMemory cdcl Tcl_AppendResultVA clib Tcl_AppendResultVA cdcl Tcl_AppendStringsToObjVA clib Tcl_AppendStringsToObjVA cdcl Tcl_HashStats clib Tcl_HashStats cdcl Tcl_ParseVar clib Tcl_ParseVar cdcl Tcl_PkgPresent clib Tcl_PkgPresent cdcl Tcl_PkgPresentEx clib Tcl_PkgPresentEx cdcl Tcl_PkgProvide clib Tcl_PkgProvide cdcl Tcl_PkgRequire clib Tcl_PkgRequire cdcl Tcl_SetErrorCodeVA clib Tcl_SetErrorCodeVA cdcl Tcl_VarEvalVA clib Tcl_VarEvalVA cdcl Tcl_WaitPid clib Tcl_WaitPid cdcl Tcl_PanicVA clib Tcl_PanicVA cdcl Tcl_GetVersion clib Tcl_GetVersion cdcl Tcl_InitMemory clib Tcl_InitMemory cdcl Tcl_StackChannel clib Tcl_StackChannel cdcl Tcl_UnstackChannel clib Tcl_UnstackChannel cdcl Tcl_GetStackedChannel clib Tcl_GetStackedChannel cdcl Tcl_SetMainLoop clib Tcl_SetMainLoop cdcl Tcl_AppendObjToObj clib Tcl_AppendObjToObj cdcl Tcl_CreateEncoding clib Tcl_CreateEncoding cdcl Tcl_CreateThreadExitHandler clib Tcl_CreateThreadExitHandler cdcl Tcl_DeleteThreadExitHandler clib Tcl_DeleteThreadExitHandler cdcl Tcl_DiscardResult clib Tcl_DiscardResult cdcl Tcl_EvalEx clib Tcl_EvalEx cdcl Tcl_EvalObjv clib Tcl_EvalObjv cdcl Tcl_EvalObjEx clib Tcl_EvalObjEx cdcl Tcl_ExitThread clib Tcl_ExitThread cdcl Tcl_ExternalToUtf clib Tcl_ExternalToUtf cdcl Tcl_ExternalToUtfDString clib Tcl_ExternalToUtfDString cdcl Tcl_FinalizeThread clib Tcl_FinalizeThread cdcl Tcl_FinalizeNotifier clib Tcl_FinalizeNotifier cdcl Tcl_FreeEncoding clib Tcl_FreeEncoding cdcl Tcl_GetCurrentThread clib Tcl_GetCurrentThread cdcl Tcl_GetEncoding clib Tcl_GetEncoding cdcl Tcl_GetEncodingName clib Tcl_GetEncodingName cdcl Tcl_GetEncodingNames clib Tcl_GetEncodingNames cdcl Tcl_GetIndexFromObjStruct clib Tcl_GetIndexFromObjStruct cdcl Tcl_GetThreadData clib Tcl_GetThreadData cdcl Tcl_GetVar2Ex clib Tcl_GetVar2Ex cdcl Tcl_InitNotifier clib Tcl_InitNotifier cdcl Tcl_MutexLock clib Tcl_MutexLock cdcl Tcl_MutexUnlock clib Tcl_MutexUnlock cdcl Tcl_ConditionNotify clib Tcl_ConditionNotify cdcl Tcl_ConditionWait clib Tcl_ConditionWait cdcl Tcl_NumUtfChars clib Tcl_NumUtfChars cdcl Tcl_ReadChars clib Tcl_ReadChars cdcl Tcl_RestoreResult clib Tcl_RestoreResult cdcl Tcl_SaveResult clib Tcl_SaveResult cdcl Tcl_SetSystemEncoding clib Tcl_SetSystemEncoding cdcl Tcl_SetVar2Ex clib Tcl_SetVar2Ex cdcl Tcl_ThreadAlert clib Tcl_ThreadAlert cdcl Tcl_ThreadQueueEvent clib Tcl_ThreadQueueEvent cdcl Tcl_UniCharAtIndex clib Tcl_UniCharAtIndex cdcl Tcl_UniCharToLower clib Tcl_UniCharToLower cdcl Tcl_UniCharToTitle clib Tcl_UniCharToTitle cdcl Tcl_UniCharToUpper clib Tcl_UniCharToUpper cdcl Tcl_UniCharToUtf clib Tcl_UniCharToUtf cdcl Tcl_UtfAtIndex clib Tcl_UtfAtIndex cdcl Tcl_UtfCharComplete clib Tcl_UtfCharComplete cdcl Tcl_UtfBackslash clib Tcl_UtfBackslash cdcl Tcl_UtfFindFirst clib Tcl_UtfFindFirst cdcl Tcl_UtfFindLast clib Tcl_UtfFindLast cdcl Tcl_UtfNext clib Tcl_UtfNext cdcl Tcl_UtfPrev clib Tcl_UtfPrev cdcl Tcl_UtfToExternal clib Tcl_UtfToExternal cdcl Tcl_UtfToExternalDString clib Tcl_UtfToExternalDString cdcl Tcl_UtfToLower clib Tcl_UtfToLower cdcl Tcl_UtfToTitle clib Tcl_UtfToTitle cdcl Tcl_UtfToUniChar clib Tcl_UtfToUniChar cdcl Tcl_UtfToUpper clib Tcl_UtfToUpper cdcl Tcl_WriteChars clib Tcl_WriteChars cdcl Tcl_WriteObj clib Tcl_WriteObj cdcl Tcl_GetString clib Tcl_GetString cdcl Tcl_GetDefaultEncodingDir clib Tcl_GetDefaultEncodingDir cdcl Tcl_SetDefaultEncodingDir clib Tcl_SetDefaultEncodingDir cdcl Tcl_AlertNotifier clib Tcl_AlertNotifier cdcl Tcl_ServiceModeHook clib Tcl_ServiceModeHook cdcl Tcl_UniCharIsAlnum clib Tcl_UniCharIsAlnum cdcl Tcl_UniCharIsAlpha clib Tcl_UniCharIsAlpha cdcl Tcl_UniCharIsDigit clib Tcl_UniCharIsDigit cdcl Tcl_UniCharIsLower clib Tcl_UniCharIsLower cdcl Tcl_UniCharIsSpace clib Tcl_UniCharIsSpace cdcl Tcl_UniCharIsUpper clib Tcl_UniCharIsUpper cdcl Tcl_UniCharIsWordChar clib Tcl_UniCharIsWordChar cdcl Tcl_UniCharLen clib Tcl_UniCharLen cdcl Tcl_UniCharNcmp clib Tcl_UniCharNcmp cdcl Tcl_UniCharToUtfDString clib Tcl_UniCharToUtfDString cdcl Tcl_UtfToUniCharDString clib Tcl_UtfToUniCharDString cdcl Tcl_GetRegExpFromObj clib Tcl_GetRegExpFromObj cdcl Tcl_EvalTokens clib Tcl_EvalTokens cdcl Tcl_FreeParse clib Tcl_FreeParse cdcl Tcl_LogCommandInfo clib Tcl_LogCommandInfo cdcl Tcl_ParseBraces clib Tcl_ParseBraces cdcl Tcl_ParseCommand clib Tcl_ParseCommand cdcl Tcl_ParseExpr clib Tcl_ParseExpr cdcl Tcl_ParseQuotedString clib Tcl_ParseQuotedString cdcl Tcl_ParseVarName clib Tcl_ParseVarName cdcl Tcl_GetCwd clib Tcl_GetCwd cdcl Tcl_Chdir clib Tcl_Chdir cdcl Tcl_Access clib Tcl_Access cdcl Tcl_Stat clib Tcl_Stat cdcl Tcl_UtfNcmp clib Tcl_UtfNcmp cdcl Tcl_UtfNcasecmp clib Tcl_UtfNcasecmp cdcl Tcl_StringCaseMatch clib Tcl_StringCaseMatch cdcl Tcl_UniCharIsControl clib Tcl_UniCharIsControl cdcl Tcl_UniCharIsGraph clib Tcl_UniCharIsGraph cdcl Tcl_UniCharIsPrint clib Tcl_UniCharIsPrint cdcl Tcl_UniCharIsPunct clib Tcl_UniCharIsPunct cdcl Tcl_RegExpExecObj clib Tcl_RegExpExecObj cdcl Tcl_RegExpGetInfo clib Tcl_RegExpGetInfo cdcl Tcl_NewUnicodeObj clib Tcl_NewUnicodeObj cdcl Tcl_SetUnicodeObj clib Tcl_SetUnicodeObj cdcl Tcl_GetCharLength clib Tcl_GetCharLength cdcl Tcl_GetUniChar clib Tcl_GetUniChar cdcl Tcl_GetUnicode clib Tcl_GetUnicode cdcl Tcl_GetRange clib Tcl_GetRange cdcl Tcl_AppendUnicodeToObj clib Tcl_AppendUnicodeToObj cdcl Tcl_RegExpMatchObj clib Tcl_RegExpMatchObj cdcl Tcl_SetNotifier clib Tcl_SetNotifier cdcl Tcl_GetAllocMutex clib Tcl_GetAllocMutex cdcl Tcl_GetChannelNames clib Tcl_GetChannelNames cdcl Tcl_GetChannelNamesEx clib Tcl_GetChannelNamesEx cdcl Tcl_ProcObjCmd clib Tcl_ProcObjCmd cdcl Tcl_ConditionFinalize clib Tcl_ConditionFinalize cdcl Tcl_MutexFinalize clib Tcl_MutexFinalize cdcl Tcl_CreateThread clib Tcl_CreateThread cdcl Tcl_ReadRaw clib Tcl_ReadRaw cdcl Tcl_WriteRaw clib Tcl_WriteRaw cdcl Tcl_GetTopChannel clib Tcl_GetTopChannel cdcl Tcl_ChannelBuffered clib Tcl_ChannelBuffered cdcl Tcl_ChannelName clib Tcl_ChannelName cdcl Tcl_ChannelVersion clib Tcl_ChannelVersion cdcl Tcl_ChannelBlockModeProc clib Tcl_ChannelBlockModeProc cdcl Tcl_ChannelCloseProc clib Tcl_ChannelCloseProc cdcl Tcl_ChannelClose2Proc clib Tcl_ChannelClose2Proc cdcl Tcl_ChannelInputProc clib Tcl_ChannelInputProc cdcl Tcl_ChannelOutputProc clib Tcl_ChannelOutputProc cdcl Tcl_ChannelSeekProc clib Tcl_ChannelSeekProc cdcl Tcl_ChannelSetOptionProc clib Tcl_ChannelSetOptionProc cdcl Tcl_ChannelGetOptionProc clib Tcl_ChannelGetOptionProc cdcl Tcl_ChannelWatchProc clib Tcl_ChannelWatchProc cdcl Tcl_ChannelGetHandleProc clib Tcl_ChannelGetHandleProc cdcl Tcl_ChannelFlushProc clib Tcl_ChannelFlushProc cdcl Tcl_ChannelHandlerProc clib Tcl_ChannelHandlerProc cdcl Tcl_JoinThread clib Tcl_JoinThread cdcl Tcl_IsChannelShared clib Tcl_IsChannelShared cdcl Tcl_IsChannelRegistered clib Tcl_IsChannelRegistered cdcl Tcl_CutChannel clib Tcl_CutChannel cdcl Tcl_SpliceChannel clib Tcl_SpliceChannel cdcl Tcl_ClearChannelHandlers clib Tcl_ClearChannelHandlers cdcl Tcl_IsChannelExisting clib Tcl_IsChannelExisting cdcl Tcl_UniCharNcasecmp clib Tcl_UniCharNcasecmp cdcl Tcl_UniCharCaseMatch clib Tcl_UniCharCaseMatch cdcl Tcl_FindHashEntry clib Tcl_FindHashEntry cdcl Tcl_CreateHashEntry clib Tcl_CreateHashEntry cdcl Tcl_InitCustomHashTable clib Tcl_InitCustomHashTable cdcl Tcl_InitObjHashTable clib Tcl_InitObjHashTable cdcl Tcl_CommandTraceInfo clib Tcl_CommandTraceInfo cdcl Tcl_TraceCommand clib Tcl_TraceCommand cdcl Tcl_UntraceCommand clib Tcl_UntraceCommand cdcl Tcl_AttemptAlloc clib Tcl_AttemptAlloc cdcl Tcl_AttemptDbCkalloc clib Tcl_AttemptDbCkalloc cdcl Tcl_AttemptRealloc clib Tcl_AttemptRealloc cdcl Tcl_AttemptDbCkrealloc clib Tcl_AttemptDbCkrealloc cdcl Tcl_AttemptSetObjLength clib Tcl_AttemptSetObjLength cdcl Tcl_GetChannelThread clib Tcl_GetChannelThread cdcl Tcl_GetUnicodeFromObj clib Tcl_GetUnicodeFromObj cdcl Tcl_GetMathFuncInfo clib Tcl_GetMathFuncInfo cdcl Tcl_ListMathFuncs clib Tcl_ListMathFuncs cdcl Tcl_SubstObj clib Tcl_SubstObj cdcl Tcl_DetachChannel clib Tcl_DetachChannel cdcl Tcl_IsStandardChannel clib Tcl_IsStandardChannel cdcl Tcl_FSCopyFile clib Tcl_FSCopyFile cdcl Tcl_FSCopyDirectory clib Tcl_FSCopyDirectory cdcl Tcl_FSCreateDirectory clib Tcl_FSCreateDirectory cdcl Tcl_FSDeleteFile clib Tcl_FSDeleteFile cdcl Tcl_FSLoadFile clib Tcl_FSLoadFile cdcl Tcl_FSMatchInDirectory clib Tcl_FSMatchInDirectory cdcl Tcl_FSLink clib Tcl_FSLink cdcl Tcl_FSRemoveDirectory clib Tcl_FSRemoveDirectory cdcl Tcl_FSRenameFile clib Tcl_FSRenameFile cdcl Tcl_FSLstat clib Tcl_FSLstat cdcl Tcl_FSUtime clib Tcl_FSUtime cdcl Tcl_FSFileAttrsGet clib Tcl_FSFileAttrsGet cdcl Tcl_FSFileAttrsSet clib Tcl_FSFileAttrsSet cdcl Tcl_FSFileAttrStrings clib Tcl_FSFileAttrStrings cdcl Tcl_FSStat clib Tcl_FSStat cdcl Tcl_FSAccess clib Tcl_FSAccess cdcl Tcl_FSOpenFileChannel clib Tcl_FSOpenFileChannel cdcl Tcl_FSGetCwd clib Tcl_FSGetCwd cdcl Tcl_FSChdir clib Tcl_FSChdir cdcl Tcl_FSConvertToPathType clib Tcl_FSConvertToPathType cdcl Tcl_FSJoinPath clib Tcl_FSJoinPath cdcl Tcl_FSSplitPath clib Tcl_FSSplitPath cdcl Tcl_FSEqualPaths clib Tcl_FSEqualPaths cdcl Tcl_FSGetNormalizedPath clib Tcl_FSGetNormalizedPath cdcl Tcl_FSJoinToPath clib Tcl_FSJoinToPath cdcl Tcl_FSGetInternalRep clib Tcl_FSGetInternalRep cdcl Tcl_FSGetTranslatedPath clib Tcl_FSGetTranslatedPath cdcl Tcl_FSEvalFile clib Tcl_FSEvalFile cdcl Tcl_FSNewNativePath clib Tcl_FSNewNativePath cdcl Tcl_FSGetNativePath clib Tcl_FSGetNativePath cdcl Tcl_FSFileSystemInfo clib Tcl_FSFileSystemInfo cdcl Tcl_FSPathSeparator clib Tcl_FSPathSeparator cdcl Tcl_FSListVolumes clib Tcl_FSListVolumes cdcl Tcl_FSRegister clib Tcl_FSRegister cdcl Tcl_FSUnregister clib Tcl_FSUnregister cdcl Tcl_FSData clib Tcl_FSData cdcl Tcl_FSGetTranslatedStringPath clib Tcl_FSGetTranslatedStringPath cdcl Tcl_FSGetFileSystemForPath clib Tcl_FSGetFileSystemForPath cdcl Tcl_FSGetPathType clib Tcl_FSGetPathType cdcl Tcl_OutputBuffered clib Tcl_OutputBuffered cdcl Tcl_FSMountsChanged clib Tcl_FSMountsChanged cdcl Tcl_EvalTokensStandard clib Tcl_EvalTokensStandard cdcl Tcl_GetTime clib Tcl_GetTime cdcl Tcl_CreateObjTrace clib Tcl_CreateObjTrace cdcl Tcl_GetCommandInfoFromToken clib Tcl_GetCommandInfoFromToken cdcl Tcl_SetCommandInfoFromToken clib Tcl_SetCommandInfoFromToken cdcl Tcl_DbNewWideIntObj clib Tcl_DbNewWideIntObj cdcl Tcl_GetWideIntFromObj clib Tcl_GetWideIntFromObj cdcl Tcl_NewWideIntObj clib Tcl_NewWideIntObj cdcl Tcl_SetWideIntObj clib Tcl_SetWideIntObj cdcl Tcl_AllocStatBuf clib Tcl_AllocStatBuf cdcl Tcl_Seek clib Tcl_Seek cdcl Tcl_Tell clib Tcl_Tell cdcl Tcl_ChannelWideSeekProc clib Tcl_ChannelWideSeekProc cdcl Tcl_DictObjPut clib Tcl_DictObjPut cdcl Tcl_DictObjGet clib Tcl_DictObjGet cdcl Tcl_DictObjRemove clib Tcl_DictObjRemove cdcl Tcl_DictObjSize clib Tcl_DictObjSize cdcl Tcl_DictObjFirst clib Tcl_DictObjFirst cdcl Tcl_DictObjNext clib Tcl_DictObjNext cdcl Tcl_DictObjDone clib Tcl_DictObjDone cdcl Tcl_DictObjPutKeyList clib Tcl_DictObjPutKeyList cdcl Tcl_DictObjRemoveKeyList clib Tcl_DictObjRemoveKeyList cdcl Tcl_NewDictObj clib Tcl_NewDictObj cdcl Tcl_DbNewDictObj clib Tcl_DbNewDictObj cdcl Tcl_RegisterConfig clib Tcl_RegisterConfig cdcl Tcl_CreateNamespace clib Tcl_CreateNamespace cdcl Tcl_DeleteNamespace clib Tcl_DeleteNamespace cdcl Tcl_AppendExportList clib Tcl_AppendExportList cdcl Tcl_Export clib Tcl_Export cdcl Tcl_Import clib Tcl_Import cdcl Tcl_ForgetImport clib Tcl_ForgetImport cdcl Tcl_GetCurrentNamespace clib Tcl_GetCurrentNamespace cdcl Tcl_GetGlobalNamespace clib Tcl_GetGlobalNamespace cdcl Tcl_FindNamespace clib Tcl_FindNamespace cdcl Tcl_FindCommand clib Tcl_FindCommand cdcl Tcl_GetCommandFromObj clib Tcl_GetCommandFromObj cdcl Tcl_GetCommandFullName clib Tcl_GetCommandFullName cdcl Tcl_FSEvalFileEx clib Tcl_FSEvalFileEx cdcl Tcl_SetExitProc clib Tcl_SetExitProc cdcl Tcl_LimitAddHandler clib Tcl_LimitAddHandler cdcl Tcl_LimitRemoveHandler clib Tcl_LimitRemoveHandler cdcl Tcl_LimitReady clib Tcl_LimitReady cdcl Tcl_LimitCheck clib Tcl_LimitCheck cdcl Tcl_LimitExceeded clib Tcl_LimitExceeded cdcl Tcl_LimitSetCommands clib Tcl_LimitSetCommands cdcl Tcl_LimitSetTime clib Tcl_LimitSetTime cdcl Tcl_LimitSetGranularity clib Tcl_LimitSetGranularity cdcl Tcl_LimitTypeEnabled clib Tcl_LimitTypeEnabled cdcl Tcl_LimitTypeExceeded clib Tcl_LimitTypeExceeded cdcl Tcl_LimitTypeSet clib Tcl_LimitTypeSet cdcl Tcl_LimitTypeReset clib Tcl_LimitTypeReset cdcl Tcl_LimitGetCommands clib Tcl_LimitGetCommands cdcl Tcl_LimitGetTime clib Tcl_LimitGetTime cdcl Tcl_LimitGetGranularity clib Tcl_LimitGetGranularity cdcl Tcl_SaveInterpState clib Tcl_SaveInterpState cdcl Tcl_RestoreInterpState clib Tcl_RestoreInterpState cdcl Tcl_DiscardInterpState clib Tcl_DiscardInterpState cdcl Tcl_SetReturnOptions clib Tcl_SetReturnOptions cdcl Tcl_GetReturnOptions clib Tcl_GetReturnOptions cdcl Tcl_IsEnsemble clib Tcl_IsEnsemble cdcl Tcl_CreateEnsemble clib Tcl_CreateEnsemble cdcl Tcl_FindEnsemble clib Tcl_FindEnsemble cdcl Tcl_SetEnsembleSubcommandList clib Tcl_SetEnsembleSubcommandList cdcl Tcl_SetEnsembleMappingDict clib Tcl_SetEnsembleMappingDict cdcl Tcl_SetEnsembleUnknownHandler clib Tcl_SetEnsembleUnknownHandler cdcl Tcl_SetEnsembleFlags clib Tcl_SetEnsembleFlags cdcl Tcl_GetEnsembleSubcommandList clib Tcl_GetEnsembleSubcommandList cdcl Tcl_GetEnsembleMappingDict clib Tcl_GetEnsembleMappingDict cdcl Tcl_GetEnsembleUnknownHandler clib Tcl_GetEnsembleUnknownHandler cdcl Tcl_GetEnsembleFlags clib Tcl_GetEnsembleFlags cdcl Tcl_GetEnsembleNamespace clib Tcl_GetEnsembleNamespace cdcl Tcl_SetTimeProc clib Tcl_SetTimeProc cdcl Tcl_QueryTimeProc clib Tcl_QueryTimeProc cdcl Tcl_ChannelThreadActionProc clib Tcl_ChannelThreadActionProc cdcl Tcl_NewBignumObj clib Tcl_NewBignumObj cdcl Tcl_DbNewBignumObj clib Tcl_DbNewBignumObj cdcl Tcl_SetBignumObj clib Tcl_SetBignumObj cdcl Tcl_GetBignumFromObj clib Tcl_GetBignumFromObj cdcl Tcl_TakeBignumFromObj clib Tcl_TakeBignumFromObj cdcl Tcl_TruncateChannel clib Tcl_TruncateChannel cdcl Tcl_ChannelTruncateProc clib Tcl_ChannelTruncateProc cdcl Tcl_SetChannelErrorInterp clib Tcl_SetChannelErrorInterp cdcl Tcl_GetChannelErrorInterp clib Tcl_GetChannelErrorInterp cdcl Tcl_SetChannelError clib Tcl_SetChannelError cdcl Tcl_GetChannelError clib Tcl_GetChannelError cdcl Tcl_InitBignumFromDouble clib Tcl_InitBignumFromDouble cdcl Tcl_GetNamespaceUnknownHandler clib Tcl_GetNamespaceUnknownHandler cdcl Tcl_SetNamespaceUnknownHandler clib Tcl_SetNamespaceUnknownHandler cdcl Tcl_GetEncodingFromObj clib Tcl_GetEncodingFromObj cdcl Tcl_GetEncodingSearchPath clib Tcl_GetEncodingSearchPath cdcl Tcl_SetEncodingSearchPath clib Tcl_SetEncodingSearchPath cdcl Tcl_GetEncodingNameFromEnvironment clib Tcl_GetEncodingNameFromEnvironment cdcl Tcl_PkgRequireProc clib Tcl_PkgRequireProc cdcl Tcl_AppendObjToErrorInfo clib Tcl_AppendObjToErrorInfo cdcl Tcl_AppendLimitedToObj clib Tcl_AppendLimitedToObj cdcl Tcl_Format clib Tcl_Format cdcl Tcl_AppendFormatToObj clib Tcl_AppendFormatToObj cdcl Tcl_ObjPrintf clib Tcl_ObjPrintf cdcl Tcl_AppendPrintfToObj clib Tcl_AppendPrintfToObj cstruct TclStubHooks cstruct TclStubs # from tclPlatDecls... cstruct TclPlatStubs # these structures are not declared... substitute 'struct TclPlatStubHooks' TclPlatStubHooks substitute 'struct TclIntStubs' TclIntStubs substitute 'struct TclIntPlatStubs' TclIntPlatStubs include alias void * TclPlatStubHooks; alias void * TclIntStubs; alias void * TclIntPlatStubs; endinclude if dversion == _setint_D_VERSION 1 include import std.stdarg; endinclude else include import core.vararg; endinclude endif ctypedef TCHAR cdcl Tcl_WinUtfToTChar clib Tcl_WinUtfToTChar cdcl Tcl_WinTCharToUtf clib Tcl_WinTCharToUtf cdcl Tcl_MacOSXOpenBundleResources clib Tcl_MacOSXOpenBundleResources cdcl Tcl_MacOSXOpenVersionedBundleResources clib Tcl_MacOSXOpenVersionedBundleResources include alias TclPlatStubs *tclPlatStubsPtr; endinclude if tom_math _hdr_tclTomMath cstruct mp_int ctypedef mp_int ctype int mp_digit ctype int mp_word ctype int long64 ctype int ulong64 ctype int mp_err cdefine hex DIGIT_BIT cdefine hex MP_DIGIT_BIT cdefine hex MP_MASK cdefine int MP_LT cdefine int MP_EQ cdefine int MP_GT cdefine int MP_ZPOS cdefine int MP_NEG cdefine int MP_OKAY cdefine int MP_MEM cdefine int MP_VAL cdefine int MP_RANGE cdefine int MP_YES cdefine int MP_NO cdefine hex LTM_PRIME_BBS cdefine hex LTM_PRIME_SAFE cdefine hex LTM_PRIME_2MSB_ON cdefine int MP_PREC cdefine int MP_WARRAY cmacro USED tclTomMath.h int mp_int cmacro DIGIT tclTomMath.h mp_digit mp_int int cmacro SIGN tclTomMath.h int mp_int cmacro mp_iszero tclTomMath.h int mp_int cmacro mp_iseven tclTomMath.h int mp_int cmacro mp_isodd tclTomMath.h int mp_int cdefine int PRIME_SIZE include alias MP_MASK MP_DIGIT_MASK; endinclude endif if tom_math_decls _hdr_tclTomMathDecls cdefine int TCLTOMMATH_EPOCH cdefine int TCLTOMMATH_REVISION cmacro Tcl_TomMath_InitStubs tclTomMathDecls.h 'char *' 'Tcl_Interp *' 'char *' cmacro TclBNAlloc tclTomMathDecls.h 'char *' uint cmacro TclBNRealloc tclTomMathDecls.h 'char *' 'char *' uint cmacro TclBNFree tclTomMathDecls.h void 'char *' cdcl TclBN_epoch clib TclBN_epoch cdcl TclBN_revision clib TclBN_revision cdcl TclBN_mp_add clib TclBN_mp_add cdcl TclBN_mp_add_d clib TclBN_mp_add_d cdcl TclBN_mp_and clib TclBN_mp_and cdcl TclBN_mp_clamp clib TclBN_mp_clamp cdcl TclBN_mp_clear clib TclBN_mp_clear cdcl TclBN_mp_clear_multi clib TclBN_mp_clear_multi cdcl TclBN_mp_cmp clib TclBN_mp_cmp cdcl TclBN_mp_cmp_d clib TclBN_mp_cmp_d cdcl TclBN_mp_cmp_mag clib TclBN_mp_cmp_mag cdcl TclBN_mp_copy clib TclBN_mp_copy cdcl TclBN_mp_count_bits clib TclBN_mp_count_bits cdcl TclBN_mp_div clib TclBN_mp_div cdcl TclBN_mp_div_d clib TclBN_mp_div_d cdcl TclBN_mp_div_2 clib TclBN_mp_div_2 cdcl TclBN_mp_div_2d clib TclBN_mp_div_2d cdcl TclBN_mp_div_3 clib TclBN_mp_div_3 cdcl TclBN_mp_exch clib TclBN_mp_exch cdcl TclBN_mp_expt_d clib TclBN_mp_expt_d cdcl TclBN_mp_grow clib TclBN_mp_grow cdcl TclBN_mp_init clib TclBN_mp_init cdcl TclBN_mp_init_copy clib TclBN_mp_init_copy cdcl TclBN_mp_init_multi clib TclBN_mp_init_multi cdcl TclBN_mp_init_set clib TclBN_mp_init_set cdcl TclBN_mp_init_size clib TclBN_mp_init_size cdcl TclBN_mp_lshd clib TclBN_mp_lshd cdcl TclBN_mp_mod clib TclBN_mp_mod cdcl TclBN_mp_mod_2d clib TclBN_mp_mod_2d cdcl TclBN_mp_mul clib TclBN_mp_mul cdcl TclBN_mp_mul_d clib TclBN_mp_mul_d cdcl TclBN_mp_mul_2 clib TclBN_mp_mul_2 cdcl TclBN_mp_mul_2d clib TclBN_mp_mul_2d cdcl TclBN_mp_neg clib TclBN_mp_neg cdcl TclBN_mp_or clib TclBN_mp_or cdcl TclBN_mp_radix_size clib TclBN_mp_radix_size cdcl TclBN_mp_read_radix clib TclBN_mp_read_radix cdcl TclBN_mp_rshd clib TclBN_mp_rshd cdcl TclBN_mp_shrink clib TclBN_mp_shrink cdcl TclBN_mp_set clib TclBN_mp_set cdcl TclBN_mp_sqr clib TclBN_mp_sqr cdcl TclBN_mp_sqrt clib TclBN_mp_sqrt cdcl TclBN_mp_sub clib TclBN_mp_sub cdcl TclBN_mp_sub_d clib TclBN_mp_sub_d cdcl TclBN_mp_to_unsigned_bin clib TclBN_mp_to_unsigned_bin cdcl TclBN_mp_to_unsigned_bin_n clib TclBN_mp_to_unsigned_bin_n cdcl TclBN_mp_toradix_n clib TclBN_mp_toradix_n cdcl TclBN_mp_unsigned_bin_size clib TclBN_mp_unsigned_bin_size cdcl TclBN_mp_xor clib TclBN_mp_xor cdcl TclBN_mp_zero clib TclBN_mp_zero cdcl TclBN_reverse clib TclBN_reverse cdcl TclBN_fast_s_mp_mul_digs clib TclBN_fast_s_mp_mul_digs cdcl TclBN_fast_s_mp_sqr clib TclBN_fast_s_mp_sqr cdcl TclBN_mp_karatsuba_mul clib TclBN_mp_karatsuba_mul cdcl TclBN_mp_karatsuba_sqr clib TclBN_mp_karatsuba_sqr cdcl TclBN_mp_toom_mul clib TclBN_mp_toom_mul cdcl TclBN_mp_toom_sqr clib TclBN_mp_toom_sqr cdcl TclBN_s_mp_add clib TclBN_s_mp_add cdcl TclBN_s_mp_mul_digs clib TclBN_s_mp_mul_digs cdcl TclBN_s_mp_sqr clib TclBN_s_mp_sqr cdcl TclBN_s_mp_sub clib TclBN_s_mp_sub cdcl TclBN_mp_init_set_int clib TclBN_mp_init_set_int cdcl TclBN_mp_set_int clib TclBN_mp_set_int cdcl TclBN_mp_cnt_lsb clib TclBN_mp_cnt_lsb cstruct TclTomMathStubs ctypedef tclTomMathStubsPtr substitute 'struct TclTomMathStubHooks' TclTomMathStubHooks # fix decls in tclTomMathDecls.h to match allocs elsewhere substitute 'cast(void.)' 'cast(char*)' include alias void * TclTomMathStubHooks; //alias TclBNAlloc XMALLOC; //alias TclBNFree XFREE; //alias TclBNRealloc XREALLOC; /* alias TclBNKaratsubaMulCutoff KARATSUBA_MUL_CUTOFF; alias TclBNKaratsubaSqrCutoff KARATSUBA_SQR_CUTOFF; alias TclBNToomMulCutoff TOOM_MUL_CUTOFF; alias TclBNToomSqrCutoff TOOM_SQR_CUTOFF; */ alias TclBN_reverse bn_reverse; alias TclBN_fast_s_mp_mul_digs fast_s_mp_mul_digs; alias TclBN_fast_s_mp_sqr fast_s_mp_sqr; alias TclBN_mp_add mp_add; alias TclBN_mp_add_d mp_add_d; alias TclBN_mp_and mp_and; alias TclBN_mp_clamp mp_clamp; alias TclBN_mp_clear mp_clear; alias TclBN_mp_clear_multi mp_clear_multi; alias TclBN_mp_cmp mp_cmp; alias TclBN_mp_cmp_d mp_cmp_d; alias TclBN_mp_cmp_mag mp_cmp_mag; alias TclBN_mp_copy mp_copy; alias TclBN_mp_count_bits mp_count_bits; alias TclBN_mp_div mp_div; alias TclBN_mp_div_2 mp_div_2; alias TclBN_mp_div_2d mp_div_2d; alias TclBN_mp_div_3 mp_div_3; alias TclBN_mp_div_d mp_div_d; alias TclBN_mp_exch mp_exch; alias TclBN_mp_expt_d mp_expt_d; alias TclBN_mp_grow mp_grow; alias TclBN_mp_init mp_init; alias TclBN_mp_init_copy mp_init_copy; alias TclBN_mp_init_multi mp_init_multi; alias TclBN_mp_init_set mp_init_set; alias TclBN_mp_init_size mp_init_size; alias TclBN_mp_karatsuba_mul mp_karatsuba_mul; alias TclBN_mp_karatsuba_sqr mp_karatsuba_sqr; alias TclBN_mp_lshd mp_lshd; alias TclBN_mp_mod mp_mod; alias TclBN_mp_mod_2d mp_mod_2d; alias TclBN_mp_mul mp_mul; alias TclBN_mp_mul_2 mp_mul_2; alias TclBN_mp_mul_2d mp_mul_2d; alias TclBN_mp_mul_d mp_mul_d; alias TclBN_mp_neg mp_neg; alias TclBN_mp_or mp_or; alias TclBN_mp_radix_size mp_radix_size; alias TclBN_mp_read_radix mp_read_radix; alias TclBN_mp_rshd mp_rshd; /* alias TclBNMpSRmap mp_s_rmap; */ alias TclBN_mp_set mp_set; alias TclBN_mp_shrink mp_shrink; alias TclBN_mp_sqr mp_sqr; alias TclBN_mp_sqrt mp_sqrt; alias TclBN_mp_sub mp_sub; alias TclBN_mp_sub_d mp_sub_d; alias TclBN_mp_to_unsigned_bin mp_to_unsigned_bin; alias TclBN_mp_to_unsigned_bin_n mp_to_unsigned_bin_n; alias TclBN_mp_toom_mul mp_toom_mul; alias TclBN_mp_toom_sqr mp_toom_sqr; alias TclBN_mp_toradix_n mp_toradix_n; alias TclBN_mp_unsigned_bin_size mp_unsigned_bin_size; alias TclBN_mp_xor mp_xor; alias TclBN_mp_zero mp_zero; alias TclBN_s_mp_add s_mp_add; alias TclBN_s_mp_mul_digs s_mp_mul_digs; alias TclBN_s_mp_sqr s_mp_sqr; alias TclBN_s_mp_sub s_mp_sub; endinclude if mpcntlsb _hdr_tclTomMathDecls && _cdcl_TclBN_mp_cnt_lsb include alias TclBN_mp_cnt_lsb mp_cnt_lsb; endinclude endif if mpinitsetint _hdr_tclTomMathDecls && _cdcl_TclBN_mp_init_set_int include alias TclBN_mp_init_set_int mp_init_set_int; endinclude endif if mpsetint _hdr_tclTomMathDecls && _cdcl_TclBN_mp_set_int include alias TclBN_mp_set_int mp_set_int; endinclude endif di-4.47/mkconfig/examples/dtcltk/env.dat0000644000175000017500000000047013334050206016327 0ustar bllbllloadunit env-main loadunit env-systype loadunit env-dc loadunit env-cc loadunit env-extension output tcl.env source ${TCLPATH}/lib/tcl${TCLVER}/tclConfig.sh source ${TCLPATH}/lib/tk${TCLVER}/tkConfig.sh system type system rev system arch dc using_gdc dflags cc cflags ldflags libs extension obj extension exe di-4.47/mkconfig/examples/dtcltk/hw_tk_c.c0000644000175000017500000000120313334050206016622 0ustar bllbll#include #include #include #include int main(int argc, char *argv[]) { Tcl_Interp *tcl_interp; Tk_Window mainWindow; tcl_interp = Tcl_CreateInterp(); if(Tcl_Init(tcl_interp) != TCL_OK || Tk_Init(tcl_interp) != TCL_OK) { if(*tcl_interp->result) fprintf(stderr,"%s: %s\n", argv[0], tcl_interp->result); exit(1); } mainWindow = Tk_MainWindow(tcl_interp); if (mainWindow == NULL) { fprintf(stderr, "%s\n", tcl_interp->result); exit(1); } Tcl_Eval(tcl_interp, "label .w -text \"Hello World\""); Tcl_Eval(tcl_interp, "pack .w"); Tk_MainLoop(); return 0; } di-4.47/mkconfig/examples/dtcltk/tk.dat0000644000175000017500000005411113334050206016156 0ustar bllbllloadunit d-main output tk/tk.d noprefix standard csizes module tk.tk chdr tk.h chdr tkDecls.h tk.h chdr tkPlatDecls.h tk.h cdefine int TK_MAJOR_VERSION cdefine int TK_MINOR_VERSION cdefine int TK_RELEASE_LEVEL cdefine int TK_RELEASE_SERIAL cdefine string TK_VERSION cdefine string TK_PATCH_LEVEL ctypedef Tk_Uid cenum Tk_OptionType cstruct Tk_OptionSpec cdefine int TK_OPTION_NULL_OK cdefine int TK_OPTION_DONT_SET_DEFAULT ctypedef Tk_CustomOptionSetProc ctypedef Tk_CustomOptionGetProc ctypedef Tk_CustomOptionRestoreProc ctypedef Tk_CustomOptionFreeProc cstruct Tk_ObjCustomOption ### FIX #cmacro Tk_Offset tk.h int int int cstruct Tk_SavedOption cdefine int TK_NUM_SAVED_OPTIONS cstruct Tk_SavedOptions ctypedef Tk_OptionParseProc ctypedef Tk_OptionPrintProc cstruct Tk_CustomOption cstruct Tk_ConfigSpec cenum Tk_ConfigTypes cdefine int TK_CONFIG_ARGV_ONLY cdefine hex TK_CONFIG_OBJS cdefine hex TK_CONFIG_NULL_OK cdefine hex TK_CONFIG_COLOR_ONLY cdefine hex TK_CONFIG_MONO_ONLY cdefine hex TK_CONFIG_DONT_SET_DEFAULT cdefine hex TK_CONFIG_OPTION_SPECIFIED cdefine hex TK_CONFIG_USER_BIT cstruct Tk_ArgvInfo cdefine int TK_ARGV_CONSTANT cdefine int TK_ARGV_INT cdefine int TK_ARGV_STRING cdefine int TK_ARGV_UID cdefine int TK_ARGV_REST cdefine int TK_ARGV_FLOAT cdefine int TK_ARGV_FUNC cdefine int TK_ARGV_GENFUNC cdefine int TK_ARGV_HELP cdefine int TK_ARGV_CONST_OPTION cdefine int TK_ARGV_OPTION_VALUE cdefine int TK_ARGV_OPTION_NAME_VALUE cdefine int TK_ARGV_END cdefine hex TK_ARGV_NO_DEFAULTS cdefine hex TK_ARGV_NO_LEFTOVERS cdefine hex TK_ARGV_NO_ABBREV cdefine hex TK_ARGV_DONT_SKIP_FIRST_ARG cenum Tk_RestrictAction cdefine int TK_WIDGET_DEFAULT_PRIO cdefine int TK_STARTUP_FILE_PRIO cdefine int TK_USER_DEFAULT_PRIO cdefine int TK_INTERACTIVE_PRIO cdefine int TK_MAX_PRIO cdefine int TK_RELIEF_NULL cdefine int TK_RELIEF_FLAT cdefine int TK_RELIEF_GROOVE cdefine int TK_RELIEF_RAISED cdefine int TK_RELIEF_RIDGE cdefine int TK_RELIEF_SOLID cdefine int TK_RELIEF_SUNKEN cdefine int TK_3D_FLAT_GC cdefine int TK_3D_LIGHT_GC cdefine int TK_3D_DARK_GC cdefine int TK_NOTIFY_SHARE cenum Tk_Anchor cenum Tk_Justify cstruct Tk_FontMetrics cdefine int TK_WHOLE_WORDS cdefine int TK_AT_LEAST_ONE cdefine int TK_PARTIAL_OK cdefine int TK_IGNORE_TABS cdefine int TK_IGNORE_NEWLINES ctypedef Tk_ClassCreateProc ctypedef Tk_ClassWorldChangedProc ctypedef Tk_ClassModalProc cstruct Tk_ClassProcs #cmacro Tk_GetClassProc ctypedef Tk_GeomRequestProc ctypedef Tk_GeomLostSlaveProc cstruct Tk_GeomMgr cdefine int TK_SCROLL_MOVETO cdefine int TK_SCROLL_PAGES cdefine int TK_SCROLL_UNITS cdefine int TK_SCROLL_ERROR cdefine int VirtualEvent cdefine int ActivateNotify cdefine int DeactivateNotify cdefine int MouseWheelEvent cdefine int TK_LASTEVENT cdefine hex MouseWheelMask cdefine hex ActivateMask cdefine hex VirtualEventMask cstruct XVirtualEvent cstruct XActivateDeactivateEvent ctypedef XActivateEvent ctypedef XDeactivateEvent cmacro Tk_Display tk.h 'Display *' 'Tk_Window *' cmacro Tk_ScreenNumber tk.h int 'Tk_Window *' cmacro Tk_Screen tk.h 'Screen *' 'Tk_Window *' cmacro Tk_Depth tk.h int 'Tk_Window *' cmacro Tk_Visual tk.h 'Visual *' 'Tk_Window *' cmacro Tk_WindowId tk.h Window 'Tk_Window *' cmacro Tk_PathName tk.h 'char *' 'Tk_Window *' cmacro Tk_Name tk.h Tk_Uid 'Tk_Window *' cmacro Tk_Class tk.h Tk_Uid 'Tk_Window *' cmacro Tk_X tk.h int 'Tk_Window *' cmacro Tk_Y tk.h int 'Tk_Window *' cmacro Tk_Width tk.h int 'Tk_Window *' cmacro Tk_Height tk.h int 'Tk_Window *' cmacro Tk_Changes tk.h 'XWindowChanges *' 'Tk_Window *' cmacro Tk_Attributes tk.h 'XSetWindowAttributes *' 'Tk_Window *' cmacro Tk_IsEmbedded tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_IsContainer tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_IsMapped tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_IsTopLevel tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_HasWrapper tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_WinManaged tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_TopWinHierarchy tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_IsManageable tk.h C_NATIVE_unsigned_int 'Tk_Window *' cmacro Tk_ReqWidth tk.h int 'Tk_Window *' cmacro Tk_ReqHeight tk.h int 'Tk_Window *' cmacro Tk_InternalBorderLeft tk.h int 'Tk_Window *' cmacro Tk_InternalBorderRight tk.h int 'Tk_Window *' cmacro Tk_InternalBorderTop tk.h int 'Tk_Window *' cmacro Tk_InternalBorderBottom tk.h int 'Tk_Window *' cmacro Tk_MinReqWidth tk.h int 'Tk_Window *' cmacro Tk_MinReqHeight tk.h int 'Tk_Window *' cmacro Tk_Parent tk.h Tk_Window 'Tk_Window *' # check this cmacro Tk_ColorMap tk.h int 'Tk_Window *' cstruct Tk_FakeWin cdefine hex TK_MAPPED cdefine hex TK_TOP_LEVEL cdefine hex TK_ALREADY_DEAD cdefine hex TK_NEED_CONFIG_NOTIFY cdefine hex TK_GRAB_FLAG cdefine hex TK_CHECKED_IC cdefine hex TK_DONT_DESTROY_WINDOW cdefine hex TK_WM_COLORMAP_WINDOW cdefine hex TK_EMBEDDED cdefine hex TK_CONTAINER cdefine hex TK_BOTH_HALVES cdefine hex TK_DEFER_MODAL cdefine hex TK_WRAPPER cdefine hex TK_REPARENTED cdefine hex TK_ANONYMOUS_WINDOW cdefine hex TK_HAS_WRAPPER cdefine hex TK_WIN_MANAGED cdefine hex TK_TOP_HIERARCHY cdefine hex TK_PROP_PROPCHANGE cdefine hex TK_WM_MANAGEABLE cenum Tk_State cstruct Tk_SmoothMethod cdefine int TK_TAG_SPACE cstruct Tk_Item cdefine hex TK_ITEM_STATE_DEPENDANT cdefine hex TK_ITEM_DONT_REDRAW ctypedef Tk_ItemCreateProc ctypedef Tk_ItemConfigureProc ctypedef Tk_ItemCoordProc ctypedef Tk_ItemDeleteProc ctypedef Tk_ItemDisplayProc ctypedef Tk_ItemPointProc ctypedef Tk_ItemAreaProc ctypedef Tk_ItemPostscriptProc ctypedef Tk_ItemScaleProc ctypedef Tk_ItemTranslateProc ctypedef Tk_ItemIndexProc ctypedef Tk_ItemCursorProc ctypedef Tk_ItemSelectionProc ctypedef Tk_ItemInsertProc ctypedef Tk_ItemDCharsProc cstruct Tk_ItemType cstruct Tk_CanvasTextInfo cstruct Tk_Dash cstruct Tk_TSOffset cdefine hex TK_OFFSET_INDEX cdefine hex TK_OFFSET_RELATIVE cdefine hex TK_OFFSET_LEFT cdefine hex TK_OFFSET_CENTER cdefine hex TK_OFFSET_RIGHT cdefine hex TK_OFFSET_TOP cdefine hex TK_OFFSET_MIDDLE cdefine hex TK_OFFSET_BOTTOM cstruct Tk_Outline ctypedef Tk_ImageCreateProc ctypedef Tk_ImageGetProc ctypedef Tk_ImageDisplayProc ctypedef Tk_ImageFreeProc ctypedef Tk_ImageDeleteProc ctypedef Tk_ImageChangedProc ctypedef Tk_ImagePostscriptProc cstruct Tk_ImageType ctypedef Tk_PhotoHandle cstruct Tk_PhotoImageBlock cdefine int TK_PHOTO_COMPOSITE_OVERLAY cdefine int TK_PHOTO_COMPOSITE_SET ctypedef Tk_ImageFileMatchProc ctypedef Tk_ImageStringMatchProc ctypedef Tk_ImageFileReadProc ctypedef Tk_ImageStringReadProc ctypedef Tk_ImageFileWriteProc ctypedef Tk_ImageStringWriteProc cstruct Tk_PhotoImageFormat cdefine int TK_STYLE_VERSION_1 cdefine int TK_STYLE_VERSION ctypedef Tk_GetElementSizeProc ctypedef Tk_GetElementBoxProc ctypedef Tk_GetElementBorderWidthProc ctypedef Tk_DrawElementProc cstruct Tk_ElementOptionSpec cstruct Tk_ElementSpec cdefine hex TK_ELEMENT_STATE_ACTIVE cdefine hex TK_ELEMENT_STATE_DISABLED cdefine hex TK_ELEMENT_STATE_FOCUS cdefine hex TK_ELEMENT_STATE_PRESSED cdefine int TK_READABLE cdefine int TK_WRITABLE cdefine int TK_EXCEPTION cdefine int TK_DONT_WAIT cdefine int TK_X_EVENTS cdefine int TK_WINDOW_EVENTS cdefine int TK_FILE_EVENTS cdefine int TK_TIMER_EVENTS cdefine int TK_IDLE_EVENTS cdefine int TK_ALL_EVENTS cmacro Tk_Main tk.h void int 'char **' 'Tcl_AppInitProc *' cdcl Tk_InitStubs clib Tk_InitStubs cdcl Tk_PkgInitStubsCheck clib Tk_PkgInitStubsCheck ctypedef Tk_ErrorProc ctypedef Tk_EventProc ctypedef Tk_GenericProc ctypedef Tk_ClientMessageProc ctypedef Tk_GetSelProc ctypedef Tk_LostSelProc ctypedef Tk_RestrictProc ctypedef Tk_SelectionProc cdcl Tk_MainLoop clib Tk_MainLoop cdcl Tk_3DBorderColor clib Tk_3DBorderColor cdcl Tk_3DBorderGC clib Tk_3DBorderGC cdcl Tk_3DHorizontalBevel clib Tk_3DHorizontalBevel cdcl Tk_3DVerticalBevel clib Tk_3DVerticalBevel cdcl Tk_AddOption clib Tk_AddOption cdcl Tk_BindEvent clib Tk_BindEvent cdcl Tk_CanvasDrawableCoords clib Tk_CanvasDrawableCoords cdcl Tk_CanvasEventuallyRedraw clib Tk_CanvasEventuallyRedraw cdcl Tk_CanvasGetCoord clib Tk_CanvasGetCoord cdcl Tk_CanvasGetTextInfo clib Tk_CanvasGetTextInfo cdcl Tk_CanvasPsBitmap clib Tk_CanvasPsBitmap cdcl Tk_CanvasPsColor clib Tk_CanvasPsColor cdcl Tk_CanvasPsFont clib Tk_CanvasPsFont cdcl Tk_CanvasPsPath clib Tk_CanvasPsPath cdcl Tk_CanvasPsStipple clib Tk_CanvasPsStipple cdcl Tk_CanvasPsY clib Tk_CanvasPsY cdcl Tk_CanvasSetStippleOrigin clib Tk_CanvasSetStippleOrigin cdcl Tk_CanvasTagsParseProc clib Tk_CanvasTagsParseProc cdcl Tk_CanvasTagsPrintProc clib Tk_CanvasTagsPrintProc cdcl Tk_CanvasTkwin clib Tk_CanvasTkwin cdcl Tk_CanvasWindowCoords clib Tk_CanvasWindowCoords cdcl Tk_ChangeWindowAttributes clib Tk_ChangeWindowAttributes cdcl Tk_CharBbox clib Tk_CharBbox cdcl Tk_ClearSelection clib Tk_ClearSelection cdcl Tk_ClipboardAppend clib Tk_ClipboardAppend cdcl Tk_ClipboardClear clib Tk_ClipboardClear cdcl Tk_ConfigureInfo clib Tk_ConfigureInfo cdcl Tk_ConfigureValue clib Tk_ConfigureValue cdcl Tk_ConfigureWidget clib Tk_ConfigureWidget cdcl Tk_ConfigureWindow clib Tk_ConfigureWindow cdcl Tk_ComputeTextLayout clib Tk_ComputeTextLayout cdcl Tk_CoordsToWindow clib Tk_CoordsToWindow cdcl Tk_CreateBinding clib Tk_CreateBinding cdcl Tk_CreateBindingTable clib Tk_CreateBindingTable cdcl Tk_CreateErrorHandler clib Tk_CreateErrorHandler cdcl Tk_CreateEventHandler clib Tk_CreateEventHandler cdcl Tk_CreateGenericHandler clib Tk_CreateGenericHandler cdcl Tk_CreateImageType clib Tk_CreateImageType cdcl Tk_CreateItemType clib Tk_CreateItemType cdcl Tk_CreatePhotoImageFormat clib Tk_CreatePhotoImageFormat cdcl Tk_CreateSelHandler clib Tk_CreateSelHandler cdcl Tk_CreateWindow clib Tk_CreateWindow cdcl Tk_CreateWindowFromPath clib Tk_CreateWindowFromPath cdcl Tk_DefineBitmap clib Tk_DefineBitmap cdcl Tk_DefineCursor clib Tk_DefineCursor cdcl Tk_DeleteAllBindings clib Tk_DeleteAllBindings cdcl Tk_DeleteBinding clib Tk_DeleteBinding cdcl Tk_DeleteBindingTable clib Tk_DeleteBindingTable cdcl Tk_DeleteErrorHandler clib Tk_DeleteErrorHandler cdcl Tk_DeleteEventHandler clib Tk_DeleteEventHandler cdcl Tk_DeleteGenericHandler clib Tk_DeleteGenericHandler cdcl Tk_DeleteImage clib Tk_DeleteImage cdcl Tk_DeleteSelHandler clib Tk_DeleteSelHandler cdcl Tk_DestroyWindow clib Tk_DestroyWindow cdcl Tk_DisplayName clib Tk_DisplayName cdcl Tk_DistanceToTextLayout clib Tk_DistanceToTextLayout cdcl Tk_Draw3DPolygon clib Tk_Draw3DPolygon cdcl Tk_Draw3DRectangle clib Tk_Draw3DRectangle cdcl Tk_DrawChars clib Tk_DrawChars cdcl Tk_DrawFocusHighlight clib Tk_DrawFocusHighlight cdcl Tk_DrawTextLayout clib Tk_DrawTextLayout cdcl Tk_Fill3DPolygon clib Tk_Fill3DPolygon cdcl Tk_Fill3DRectangle clib Tk_Fill3DRectangle cdcl Tk_FindPhoto clib Tk_FindPhoto cdcl Tk_FontId clib Tk_FontId cdcl Tk_Free3DBorder clib Tk_Free3DBorder cdcl Tk_FreeBitmap clib Tk_FreeBitmap cdcl Tk_FreeColor clib Tk_FreeColor cdcl Tk_FreeColormap clib Tk_FreeColormap cdcl Tk_FreeCursor clib Tk_FreeCursor cdcl Tk_FreeFont clib Tk_FreeFont cdcl Tk_FreeGC clib Tk_FreeGC cdcl Tk_FreeImage clib Tk_FreeImage cdcl Tk_FreeOptions clib Tk_FreeOptions cdcl Tk_FreePixmap clib Tk_FreePixmap cdcl Tk_FreeTextLayout clib Tk_FreeTextLayout cdcl Tk_FreeXId clib Tk_FreeXId cdcl Tk_GCForColor clib Tk_GCForColor cdcl Tk_GeometryRequest clib Tk_GeometryRequest cdcl Tk_Get3DBorder clib Tk_Get3DBorder cdcl Tk_GetAllBindings clib Tk_GetAllBindings cdcl Tk_GetAnchor clib Tk_GetAnchor cdcl Tk_GetAtomName clib Tk_GetAtomName cdcl Tk_GetBinding clib Tk_GetBinding cdcl Tk_GetBitmap clib Tk_GetBitmap cdcl Tk_GetBitmapFromData clib Tk_GetBitmapFromData cdcl Tk_GetCapStyle clib Tk_GetCapStyle cdcl Tk_GetColor clib Tk_GetColor cdcl Tk_GetColorByValue clib Tk_GetColorByValue cdcl Tk_GetColormap clib Tk_GetColormap cdcl Tk_GetCursor clib Tk_GetCursor cdcl Tk_GetCursorFromData clib Tk_GetCursorFromData cdcl Tk_GetFont clib Tk_GetFont cdcl Tk_GetFontFromObj clib Tk_GetFontFromObj cdcl Tk_GetFontMetrics clib Tk_GetFontMetrics cdcl Tk_GetGC clib Tk_GetGC cdcl Tk_GetImage clib Tk_GetImage cdcl Tk_GetImageMasterData clib Tk_GetImageMasterData cdcl Tk_GetItemTypes clib Tk_GetItemTypes cdcl Tk_GetJoinStyle clib Tk_GetJoinStyle cdcl Tk_GetJustify clib Tk_GetJustify cdcl Tk_GetNumMainWindows clib Tk_GetNumMainWindows cdcl Tk_GetOption clib Tk_GetOption cdcl Tk_GetPixels clib Tk_GetPixels cdcl Tk_GetPixmap clib Tk_GetPixmap cdcl Tk_GetRelief clib Tk_GetRelief cdcl Tk_GetRootCoords clib Tk_GetRootCoords cdcl Tk_GetScrollInfo clib Tk_GetScrollInfo cdcl Tk_GetScreenMM clib Tk_GetScreenMM cdcl Tk_GetSelection clib Tk_GetSelection cdcl Tk_GetUid clib Tk_GetUid cdcl Tk_GetVisual clib Tk_GetVisual cdcl Tk_GetVRootGeometry clib Tk_GetVRootGeometry cdcl Tk_Grab clib Tk_Grab cdcl Tk_HandleEvent clib Tk_HandleEvent cdcl Tk_IdToWindow clib Tk_IdToWindow cdcl Tk_ImageChanged clib Tk_ImageChanged cdcl Tk_Init clib Tk_Init cdcl Tk_InternAtom clib Tk_InternAtom cdcl Tk_IntersectTextLayout clib Tk_IntersectTextLayout cdcl Tk_MaintainGeometry clib Tk_MaintainGeometry cdcl Tk_MainWindow clib Tk_MainWindow cdcl Tk_MakeWindowExist clib Tk_MakeWindowExist cdcl Tk_ManageGeometry clib Tk_ManageGeometry cdcl Tk_MapWindow clib Tk_MapWindow cdcl Tk_MeasureChars clib Tk_MeasureChars cdcl Tk_MoveResizeWindow clib Tk_MoveResizeWindow cdcl Tk_MoveWindow clib Tk_MoveWindow cdcl Tk_MoveToplevelWindow clib Tk_MoveToplevelWindow cdcl Tk_NameOf3DBorder clib Tk_NameOf3DBorder cdcl Tk_NameOfAnchor clib Tk_NameOfAnchor cdcl Tk_NameOfBitmap clib Tk_NameOfBitmap cdcl Tk_NameOfCapStyle clib Tk_NameOfCapStyle cdcl Tk_NameOfColor clib Tk_NameOfColor cdcl Tk_NameOfCursor clib Tk_NameOfCursor cdcl Tk_NameOfFont clib Tk_NameOfFont cdcl Tk_NameOfImage clib Tk_NameOfImage cdcl Tk_NameOfJoinStyle clib Tk_NameOfJoinStyle cdcl Tk_NameOfJustify clib Tk_NameOfJustify cdcl Tk_NameOfRelief clib Tk_NameOfRelief cdcl Tk_NameToWindow clib Tk_NameToWindow cdcl Tk_OwnSelection clib Tk_OwnSelection cdcl Tk_ParseArgv clib Tk_ParseArgv cdcl Tk_PhotoPutBlock_NoComposite clib Tk_PhotoPutBlock_NoComposite cdcl Tk_PhotoPutZoomedBlock_NoComposite clib Tk_PhotoPutZoomedBlock_NoComposite cdcl Tk_PhotoGetImage clib Tk_PhotoGetImage cdcl Tk_PhotoBlank clib Tk_PhotoBlank cdcl Tk_PhotoExpand_Panic clib Tk_PhotoExpand_Panic cdcl Tk_PhotoGetSize clib Tk_PhotoGetSize cdcl Tk_PhotoSetSize_Panic clib Tk_PhotoSetSize_Panic cdcl Tk_PointToChar clib Tk_PointToChar cdcl Tk_PostscriptFontName clib Tk_PostscriptFontName cdcl Tk_PreserveColormap clib Tk_PreserveColormap cdcl Tk_QueueWindowEvent clib Tk_QueueWindowEvent cdcl Tk_RedrawImage clib Tk_RedrawImage cdcl Tk_ResizeWindow clib Tk_ResizeWindow cdcl Tk_RestackWindow clib Tk_RestackWindow cdcl Tk_RestrictEvents clib Tk_RestrictEvents cdcl Tk_SafeInit clib Tk_SafeInit cdcl Tk_SetAppName clib Tk_SetAppName cdcl Tk_SetBackgroundFromBorder clib Tk_SetBackgroundFromBorder cdcl Tk_SetClass clib Tk_SetClass cdcl Tk_SetGrid clib Tk_SetGrid cdcl Tk_SetInternalBorder clib Tk_SetInternalBorder cdcl Tk_SetWindowBackground clib Tk_SetWindowBackground cdcl Tk_SetWindowBackgroundPixmap clib Tk_SetWindowBackgroundPixmap cdcl Tk_SetWindowBorder clib Tk_SetWindowBorder cdcl Tk_SetWindowBorderWidth clib Tk_SetWindowBorderWidth cdcl Tk_SetWindowBorderPixmap clib Tk_SetWindowBorderPixmap cdcl Tk_SetWindowColormap clib Tk_SetWindowColormap cdcl Tk_SetWindowVisual clib Tk_SetWindowVisual cdcl Tk_SizeOfBitmap clib Tk_SizeOfBitmap cdcl Tk_SizeOfImage clib Tk_SizeOfImage cdcl Tk_StrictMotif clib Tk_StrictMotif cdcl Tk_TextLayoutToPostscript clib Tk_TextLayoutToPostscript cdcl Tk_TextWidth clib Tk_TextWidth cdcl Tk_UndefineCursor clib Tk_UndefineCursor cdcl Tk_UnderlineChars clib Tk_UnderlineChars cdcl Tk_UnderlineTextLayout clib Tk_UnderlineTextLayout cdcl Tk_Ungrab clib Tk_Ungrab cdcl Tk_UnmaintainGeometry clib Tk_UnmaintainGeometry cdcl Tk_UnmapWindow clib Tk_UnmapWindow cdcl Tk_UnsetGrid clib Tk_UnsetGrid cdcl Tk_UpdatePointer clib Tk_UpdatePointer cdcl Tk_AllocBitmapFromObj clib Tk_AllocBitmapFromObj cdcl Tk_Alloc3DBorderFromObj clib Tk_Alloc3DBorderFromObj cdcl Tk_AllocColorFromObj clib Tk_AllocColorFromObj cdcl Tk_AllocCursorFromObj clib Tk_AllocCursorFromObj cdcl Tk_AllocFontFromObj clib Tk_AllocFontFromObj cdcl Tk_CreateOptionTable clib Tk_CreateOptionTable cdcl Tk_DeleteOptionTable clib Tk_DeleteOptionTable cdcl Tk_Free3DBorderFromObj clib Tk_Free3DBorderFromObj cdcl Tk_FreeBitmapFromObj clib Tk_FreeBitmapFromObj cdcl Tk_FreeColorFromObj clib Tk_FreeColorFromObj cdcl Tk_FreeConfigOptions clib Tk_FreeConfigOptions cdcl Tk_FreeSavedOptions clib Tk_FreeSavedOptions cdcl Tk_FreeCursorFromObj clib Tk_FreeCursorFromObj cdcl Tk_FreeFontFromObj clib Tk_FreeFontFromObj cdcl Tk_Get3DBorderFromObj clib Tk_Get3DBorderFromObj cdcl Tk_GetAnchorFromObj clib Tk_GetAnchorFromObj cdcl Tk_GetBitmapFromObj clib Tk_GetBitmapFromObj cdcl Tk_GetColorFromObj clib Tk_GetColorFromObj cdcl Tk_GetCursorFromObj clib Tk_GetCursorFromObj cdcl Tk_GetOptionInfo clib Tk_GetOptionInfo cdcl Tk_GetOptionValue clib Tk_GetOptionValue cdcl Tk_GetJustifyFromObj clib Tk_GetJustifyFromObj cdcl Tk_GetMMFromObj clib Tk_GetMMFromObj cdcl Tk_GetPixelsFromObj clib Tk_GetPixelsFromObj cdcl Tk_GetReliefFromObj clib Tk_GetReliefFromObj cdcl Tk_GetScrollInfoObj clib Tk_GetScrollInfoObj cdcl Tk_InitOptions clib Tk_InitOptions cdcl Tk_MainEx clib Tk_MainEx cdcl Tk_RestoreSavedOptions clib Tk_RestoreSavedOptions cdcl Tk_SetOptions clib Tk_SetOptions cdcl Tk_InitConsoleChannels clib Tk_InitConsoleChannels cdcl Tk_CreateConsoleWindow clib Tk_CreateConsoleWindow cdcl Tk_CreateSmoothMethod clib Tk_CreateSmoothMethod cdcl Tk_GetDash clib Tk_GetDash cdcl Tk_CreateOutline clib Tk_CreateOutline cdcl Tk_DeleteOutline clib Tk_DeleteOutline cdcl Tk_ConfigOutlineGC clib Tk_ConfigOutlineGC cdcl Tk_ChangeOutlineGC clib Tk_ChangeOutlineGC cdcl Tk_ResetOutlineGC clib Tk_ResetOutlineGC cdcl Tk_CanvasPsOutline clib Tk_CanvasPsOutline cdcl Tk_SetTSOrigin clib Tk_SetTSOrigin cdcl Tk_CanvasGetCoordFromObj clib Tk_CanvasGetCoordFromObj cdcl Tk_CanvasSetOffset clib Tk_CanvasSetOffset cdcl Tk_DitherPhoto clib Tk_DitherPhoto cdcl Tk_PostscriptBitmap clib Tk_PostscriptBitmap cdcl Tk_PostscriptColor clib Tk_PostscriptColor cdcl Tk_PostscriptFont clib Tk_PostscriptFont cdcl Tk_PostscriptImage clib Tk_PostscriptImage cdcl Tk_PostscriptPath clib Tk_PostscriptPath cdcl Tk_PostscriptStipple clib Tk_PostscriptStipple cdcl Tk_PostscriptY clib Tk_PostscriptY cdcl Tk_PostscriptPhoto clib Tk_PostscriptPhoto cdcl Tk_CreateClientMessageHandler clib Tk_CreateClientMessageHandler cdcl Tk_DeleteClientMessageHandler clib Tk_DeleteClientMessageHandler cdcl Tk_CreateAnonymousWindow clib Tk_CreateAnonymousWindow cdcl Tk_SetClassProcs clib Tk_SetClassProcs cdcl Tk_SetInternalBorderEx clib Tk_SetInternalBorderEx cdcl Tk_SetMinimumRequestSize clib Tk_SetMinimumRequestSize cdcl Tk_SetCaretPos clib Tk_SetCaretPos cdcl Tk_PhotoPutBlock_Panic clib Tk_PhotoPutBlock_Panic cdcl Tk_PhotoPutZoomedBlock_Panic clib Tk_PhotoPutZoomedBlock_Panic cdcl Tk_CollapseMotionEvents clib Tk_CollapseMotionEvents cdcl Tk_RegisterStyleEngine clib Tk_RegisterStyleEngine cdcl Tk_GetStyleEngine clib Tk_GetStyleEngine cdcl Tk_RegisterStyledElement clib Tk_RegisterStyledElement cdcl Tk_GetElementId clib Tk_GetElementId cdcl Tk_CreateStyle clib Tk_CreateStyle cdcl Tk_GetStyle clib Tk_GetStyle cdcl Tk_FreeStyle clib Tk_FreeStyle cdcl Tk_NameOfStyle clib Tk_NameOfStyle cdcl Tk_AllocStyleFromObj clib Tk_AllocStyleFromObj cdcl Tk_GetStyleFromObj clib Tk_GetStyleFromObj cdcl Tk_FreeStyleFromObj clib Tk_FreeStyleFromObj cdcl Tk_GetStyledElement clib Tk_GetStyledElement cdcl Tk_GetElementSize clib Tk_GetElementSize cdcl Tk_GetElementBox clib Tk_GetElementBox cdcl Tk_GetElementBorderWidth clib Tk_GetElementBorderWidth cdcl Tk_DrawElement clib Tk_DrawElement cdcl Tk_PhotoExpand clib Tk_PhotoExpand cdcl Tk_PhotoPutBlock clib Tk_PhotoPutBlock cdcl Tk_PhotoPutZoomedBlock clib Tk_PhotoPutZoomedBlock cdcl Tk_PhotoSetSize clib Tk_PhotoSetSize cdcl Tk_GetUserInactiveTime clib Tk_GetUserInactiveTime cdcl Tk_ResetUserInactiveTime clib Tk_ResetUserInactiveTime cdcl Tk_Interp clib Tk_Interp cdcl Tk_CreateOldImageType clib Tk_CreateOldImageType cdcl Tk_CreateOldPhotoImageFormat clib Tk_CreateOldPhotoImageFormat include import tcl.tcl; import x11.x; import x11.xlib; alias void * Tk_BindingTable; alias void * Tk_Canvas; alias void * Tk_Cursor; alias void * Tk_ErrorHandler; alias void * Tk_Font; alias void * Tk_Image; alias void * Tk_ImageMaster; alias void * Tk_OptionTable; alias void * Tk_PostscriptInfo; alias void * Tk_TextLayout; alias void * Tk_Window; alias void * Tk_3DBorder; alias void * Tk_Style; alias void * Tk_StyleEngine; alias void * Tk_StyledElement; alias void * TkOption; alias Tcl_IdleProc Tk_IdleProc; alias Tcl_FileProc Tk_FileProc; alias Tcl_TimerProc Tk_TimerProc; alias Tcl_TimerToken Tk_TimerToken; alias Tcl_BackgroundError Tk_BackgroundError; alias Tcl_CancelIdleCall Tk_CancelIdleCall; alias Tcl_CreateFileHandler Tk_CreateFileHandler; alias Tcl_CreateTimerHandler Tk_CreateTimerHandler; alias Tcl_DeleteFileHandler Tk_DeleteFileHandler; alias Tcl_DeleteTimerHandler Tk_DeleteTimerHandler; alias Tcl_DoOneEvent Tk_DoOneEvent; alias Tcl_DoWhenIdle Tk_DoWhenIdle; alias Tcl_Sleep Tk_Sleep; alias Tcl_EventuallyFree Tk_EventuallyFree; alias Tcl_FreeProc Tk_FreeProc; alias Tcl_Preserve Tk_Preserve; alias Tcl_Release Tk_Release; // unknown... alias XID XIC; endinclude substitute 'struct TkOption' TkOption # tkPlatDecls.h cdcl Tk_AttachHWND clib Tk_AttachHWND cdcl Tk_GetHINSTANCE clib Tk_GetHINSTANCE cdcl Tk_GetHWND clib Tk_GetHWND cdcl Tk_HWNDToWindow clib Tk_HWNDToWindow cdcl Tk_PointerEvent clib Tk_PointerEvent cdcl Tk_TranslateWinEvent clib Tk_TranslateWinEvent cdcl Tk_MacOSXSetEmbedHandler clib Tk_MacOSXSetEmbedHandler cdcl Tk_MacOSXTurnOffMenus clib Tk_MacOSXTurnOffMenus cdcl Tk_MacOSXTkOwnsCursor clib Tk_MacOSXTkOwnsCursor cdcl TkMacOSXInitMenus clib TkMacOSXInitMenus cdcl TkMacOSXInitAppleEvents clib TkMacOSXInitAppleEvents cdcl TkGenWMConfigureEvent clib TkGenWMConfigureEvent cdcl TkMacOSXInvalClipRgns clib TkMacOSXInvalClipRgns cdcl TkMacOSXGetDrawablePort clib TkMacOSXGetDrawablePort cdcl TkMacOSXGetRootControl clib TkMacOSXGetRootControl cdcl Tk_MacOSXSetupTkNotifier clib Tk_MacOSXSetupTkNotifier cdcl Tk_MacOSXIsAppInFront clib Tk_MacOSXIsAppInFront if tk_attachhwnd _cdcl_Tk_AttachHWND cmacro Tk_AttachHWND tkPlatDecls.h Window Tk_Window HWND endif cstruct TkPlatStubs ctypedef tkPlatStubsPtr substitute 'struct TkPlatStubHooks' TkPlatStubHooks include alias void * TkPlatStubHooks; endinclude di-4.47/mkconfig/examples/dtcltk/x.dat0000644000175000017500000002535213334050206016014 0ustar bllbllloadunit d-main noprefix output x11/x.d module x11.x standard chdr X11/X.h chdr X11/Xlib.h csizes cdefine int X_PROTOCOL cdefine int X_PROTOCOL_REVISION ctype int XID ctype int Mask ctype int Atom ctype int VisualID ctype int Time ctype int Window ctype int Drawable ctype int Font ctype int Pixmap ctype int Cursor ctype int Colormap ctype int GContext ctype int KeySym ctypedef KeyCode cdefine long None cdefine long ParentRelative cdefine long CopyFromParent cdefine long PointerWindow cdefine long InputFocus cdefine long PointerRoot cdefine long AnyPropertyType cdefine long AnyKey cdefine long AnyButton cdefine long AllTemporary cdefine long CurrentTime cdefine long NoSymbol cdefine long NoEventMask cdefine long KeyPressMask cdefine long KeyReleaseMask cdefine long ButtonPressMask cdefine long ButtonReleaseMask cdefine long EnterWindowMask cdefine long LeaveWindowMask cdefine long PointerMotionMask cdefine long PointerMotionHintMask cdefine long Button1MotionMask cdefine long Button2MotionMask cdefine long Button3MotionMask cdefine long Button4MotionMask cdefine long Button5MotionMask cdefine long ButtonMotionMask cdefine long KeymapStateMask cdefine long ExposureMask cdefine long VisibilityChangeMask cdefine long StructureNotifyMask cdefine long ResizeRedirectMask cdefine long SubstructureNotifyMask cdefine long SubstructureRedirectMask cdefine long FocusChangeMask cdefine long PropertyChangeMask cdefine long ColormapChangeMask cdefine long OwnerGrabButtonMask cdefine int KeyPress cdefine int KeyRelease cdefine int ButtonPress cdefine int ButtonRelease cdefine int MotionNotify cdefine int EnterNotify cdefine int LeaveNotify cdefine int FocusIn cdefine int FocusOut cdefine int KeymapNotify cdefine int Expose cdefine int GraphicsExpose cdefine int NoExpose cdefine int VisibilityNotify cdefine int CreateNotify cdefine int DestroyNotify cdefine int UnmapNotify cdefine int MapNotify cdefine int MapRequest cdefine int ReparentNotify cdefine int ConfigureNotify cdefine int ConfigureRequest cdefine int GravityNotify cdefine int ResizeRequest cdefine int CirculateNotify cdefine int CirculateRequest cdefine int PropertyNotify cdefine int SelectionClear cdefine int SelectionRequest cdefine int SelectionNotify cdefine int ColormapNotify cdefine int ClientMessage cdefine int MappingNotify cdefine int GenericEvent cdefine int LASTEvent cdefine int ShiftMask cdefine int LockMask cdefine int ControlMask cdefine int Mod1Mask cdefine int Mod2Mask cdefine int Mod3Mask cdefine int Mod4Mask cdefine int Mod5Mask cdefine int ShiftMapIndex cdefine int LockMapIndex cdefine int ControlMapIndex cdefine int Mod1MapIndex cdefine int Mod2MapIndex cdefine int Mod3MapIndex cdefine int Mod4MapIndex cdefine int Mod5MapIndex cdefine int Button1Mask cdefine int Button2Mask cdefine int Button3Mask cdefine int Button4Mask cdefine int Button5Mask cdefine int AnyModifier cdefine int Button1 cdefine int Button2 cdefine int Button3 cdefine int Button4 cdefine int Button5 cdefine int NotifyNormal cdefine int NotifyGrab cdefine int NotifyUngrab cdefine int NotifyWhileGrabbed cdefine int NotifyHint cdefine int NotifyAncestor cdefine int NotifyVirtual cdefine int NotifyInferior cdefine int NotifyNonlinear cdefine int NotifyNonlinearVirtual cdefine int NotifyPointer cdefine int NotifyPointerRoot cdefine int NotifyDetailNone cdefine int VisibilityUnobscured cdefine int VisibilityPartiallyObscured cdefine int VisibilityFullyObscured cdefine int PlaceOnTop cdefine int PlaceOnBottom cdefine int FamilyInternet cdefine int FamilyDECnet cdefine int FamilyChaos cdefine int FamilyInternet6 cdefine int FamilyServerInterpreted cdefine int PropertyNewValue cdefine int PropertyDelete cdefine int ColormapUninstalled cdefine int ColormapInstalled cdefine int GrabModeSync cdefine int GrabModeAsync cdefine int GrabSuccess cdefine int AlreadyGrabbed cdefine int GrabInvalidTime cdefine int GrabNotViewable cdefine int GrabFrozen cdefine int AsyncPointer cdefine int SyncPointer cdefine int ReplayPointer cdefine int AsyncKeyboard cdefine int SyncKeyboard cdefine int ReplayKeyboard cdefine int AsyncBoth cdefine int SyncBoth cdefine int RevertToNone cdefine int RevertToPointerRoot cdefine int RevertToParent cdefine int Success cdefine int BadRequest cdefine int BadValue cdefine int BadWindow cdefine int BadPixmap cdefine int BadAtom cdefine int BadCursor cdefine int BadFont cdefine int BadMatch cdefine int BadDrawable cdefine int BadAccess cdefine int BadAlloc cdefine int BadColor cdefine int BadGC cdefine int BadIDChoice cdefine int BadName cdefine int BadLength cdefine int BadImplementation cdefine int FirstExtensionError cdefine int LastExtensionError cdefine int InputOutput cdefine int InputOnly cdefine long CWBackPixmap cdefine long CWBackPixel cdefine long CWBorderPixmap cdefine long CWBorderPixel cdefine long CWBitGravity cdefine long CWWinGravity cdefine long CWBackingStore cdefine long CWBackingPlanes cdefine long CWBackingPixel cdefine long CWOverrideRedirect cdefine long CWSaveUnder cdefine long CWEventMask cdefine long CWDontPropagate cdefine long CWColormap cdefine long CWCursor cdefine int CWX cdefine int CWY cdefine int CWWidth cdefine int CWHeight cdefine int CWBorderWidth cdefine int CWSibling cdefine int CWStackMode cdefine int ForgetGravity cdefine int NorthWestGravity cdefine int NorthGravity cdefine int NorthEastGravity cdefine int WestGravity cdefine int CenterGravity cdefine int EastGravity cdefine int SouthWestGravity cdefine int SouthGravity cdefine int SouthEastGravity cdefine int StaticGravity cdefine int UnmapGravity cdefine int NotUseful cdefine int WhenMapped cdefine int Always cdefine int IsUnmapped cdefine int IsUnviewable cdefine int IsViewable cdefine int SetModeInsert cdefine int SetModeDelete cdefine int DestroyAll cdefine int RetainPermanent cdefine int RetainTemporary cdefine int Above cdefine int Below cdefine int TopIf cdefine int BottomIf cdefine int Opposite cdefine int RaiseLowest cdefine int LowerHighest cdefine int PropModeReplace cdefine int PropModePrepend cdefine int PropModeAppend cdefine int GXclear cdefine int GXand cdefine int GXandReverse cdefine int GXcopy cdefine int GXandInverted cdefine int GXnoop cdefine int GXxor cdefine int GXor cdefine int GXnor cdefine int GXequiv cdefine int GXinvert cdefine int GXorReverse cdefine int GXcopyInverted cdefine int GXorInverted cdefine int GXnand cdefine int GXset cdefine int LineSolid cdefine int LineOnOffDash cdefine int LineDoubleDash cdefine int CapNotLast cdefine int CapButt cdefine int CapRound cdefine int CapProjecting cdefine int JoinMiter cdefine int JoinRound cdefine int JoinBevel cdefine int FillSolid cdefine int FillTiled cdefine int FillStippled cdefine int FillOpaqueStippled cdefine int EvenOddRule cdefine int WindingRule cdefine int ClipByChildren cdefine int IncludeInferiors cdefine int Unsorted cdefine int YSorted cdefine int YXSorted cdefine int YXBanded cdefine int CoordModeOrigin cdefine int CoordModePrevious cdefine int Complex cdefine int Nonconvex cdefine int Convex cdefine int ArcChord cdefine int ArcPieSlice cdefine long GCFunction cdefine long GCPlaneMask cdefine long GCForeground cdefine long GCBackground cdefine long GCLineWidth cdefine long GCLineStyle cdefine long GCCapStyle cdefine long GCJoinStyle cdefine long GCFillStyle cdefine long GCFillRule cdefine long GCTile cdefine long GCStipple cdefine long GCTileStipXOrigin cdefine long GCTileStipYOrigin cdefine long GCFont cdefine long GCSubwindowMode cdefine long GCGraphicsExposures cdefine long GCClipXOrigin cdefine long GCClipYOrigin cdefine long GCClipMask cdefine long GCDashOffset cdefine long GCDashList cdefine long GCArcMode cdefine int GCLastBit cdefine int FontLeftToRight cdefine int FontRightToLeft cdefine int FontChange cdefine int XYBitmap cdefine int XYPixmap cdefine int ZPixmap cdefine int AllocNone cdefine int AllocAll cdefine int DoRed cdefine int DoGreen cdefine int DoBlue cdefine int CursorShape cdefine int TileShape cdefine int StippleShape cdefine int AutoRepeatModeOff cdefine int AutoRepeatModeOn cdefine int AutoRepeatModeDefault cdefine int LedModeOff cdefine int LedModeOn cdefine long KBKeyClickPercent cdefine long KBBellPercent cdefine long KBBellPitch cdefine long KBBellDuration cdefine long KBLed cdefine long KBLedMode cdefine long KBKey cdefine long KBAutoRepeatMode cdefine int MappingSuccess cdefine int MappingBusy cdefine int MappingFailed cdefine int MappingModifier cdefine int MappingKeyboard cdefine int MappingPointer cdefine int DontPreferBlanking cdefine int PreferBlanking cdefine int DefaultBlanking cdefine int DisableScreenSaver cdefine int DisableScreenInterval cdefine int DontAllowExposures cdefine int AllowExposures cdefine int DefaultExposures cdefine int ScreenSaverReset cdefine int ScreenSaverActive cdefine int HostInsert cdefine int HostDelete cdefine int EnableAccess cdefine int DisableAccess cdefine int StaticGray cdefine int GrayScale cdefine int StaticColor cdefine int PseudoColor cdefine int TrueColor cdefine int DirectColor cdefine int LSBFirst cdefine int MSBFirst output x11/xlib.d module x11.xlib cdefine int XlibSpecificationRelease ctypedef Bool ctypedef Status cdefine int True cdefine int False cdefine int QueuedAlready cdefine int QueuedAfterReading cdefine int QueuedAfterFlush cmacro ScreenOfDisplay X11/Xlib.h 'Screen *' 'Display' int cstruct XAnyEvent cstruct XKeyEvent cstruct XButtonEvent cstruct XMotionEvent cstruct XCrossingEvent cstruct XFocusChangeEvent cstruct XExposeEvent cstruct XGraphicsExposeEvent cstruct XNoExposeEvent cstruct XVisibilityEvent cstruct XCreateWindowEvent cstruct XDestroyWindowEvent cstruct XUnmapEvent cstruct XMapEvent cstruct XMapRequestEvent cstruct XReparentEvent cstruct XConfigureEvent cstruct XGravityEvent cstruct XResizeRequestEvent cstruct XConfigureRequestEvent cstruct XCirculateEvent cstruct XCirculateRequestEvent cstruct XPropertyEvent cstruct XSelectionClearEvent cstruct XSelectionRequestEvent cstruct XSelectionEvent cstruct XColormapEvent cstruct XClientMessageEvent cstruct XMappingEvent cstruct XKeymapEvent cstruct XGenericEvent cstruct XGenericEventCookie cstruct GC cstruct Visual cstruct Display cstruct Screen cstruct Depth cstruct ScreenFormat cunion XEvent cstruct XErrorEvent ctypedef XPointer cstruct XExtData cstruct XColor cstruct XPoint cstruct XWindowChanges cstruct XGCValues cstruct XSetWindowAttributes cstruct _XPrivDisplay # various reserved words are renamed... substitute new new_ substitute class class_ substitute 'function;' 'function_;' # These are not declared substitute 'struct _XDisplay' _XDisplay substitute 'struct _XPrivate' _XPrivate substitute 'struct _XrmHashBucketRec' _XrmHashBucketRec # not valid D code. substitute '_XPrivate .private9, .private10;' '_XPrivate * private9, private10;' include import x11.x; alias void * GC; alias void * Display; alias void * _XDisplay; alias void * _XPrivate; alias void * _XrmHashBucketRec; endinclude di-4.47/mkconfig/examples/dtcltk/hw_tk_d2.d0000644000175000017500000000124213334050206016711 0ustar bllbllimport std.stdio; import std.string; import tcl.tcl; import tk.tk; int main(string[] args) { Tcl_Interp *tcl_interp; Tk_Window mainWindow; tcl_interp = Tcl_CreateInterp(); if (Tcl_Init(tcl_interp) != TCL_OK || Tk_Init(tcl_interp) != TCL_OK) { if(*tcl_interp.result) { printf("%s: Tcl/Tk_Init: %s\n", args[0] ~ "\0", tcl_interp.result); } return 1; } mainWindow = Tk_MainWindow(tcl_interp); if (mainWindow == null) { printf("%s: Tk_MainWindow: %s\n", args[0] ~ "\0", tcl_interp.result); return 1; } Tcl_Eval (tcl_interp, "label .w -text \"Hello World\""); Tcl_Eval (tcl_interp, "pack .w"); Tk_MainLoop (); return 0; } di-4.47/mkconfig/runtests.sh0000755000175000017500000002673313334050206014202 0ustar bllbll#!/bin/sh # # Copyright 1994-2018 Brad Lanam, Walnut Creek, CA # # # speed at the cost of maintainability... # File Descriptors: # 9 - $TSTRUNLOG # 8 - $MAINLOG # 7 - $TMPORDER # 5 - stdout (as 1 is directed to the log) # set -f # global DOPERL=T TESTORDER=test_order SUBDIR=F # this is a workaround for ksh93 on solaris if [ "$1" = -d ]; then cd $2 shift shift fi unset CDPATH if [ "$1" = -s ]; then SUBDIR=T shift CC="$1" DC="$2" shelllist="$3" _pthlist="$4" TMPOUT="$5" shift; shift; shift; shift; shift fi if [ $# -lt 1 ]; then echo "Usage: $0 [ ...]" exit 1 fi unset GREP_OPTIONS unset ENV unalias sed > /dev/null 2>&1 unalias grep > /dev/null 2>&1 unalias ls > /dev/null 2>&1 unalias rm > /dev/null 2>&1 LC_ALL=C export LC_ALL # this is used for regression testing. getlistofshells () { getpaths echo "## PATH: $PATH" >&8 echo "## paths: $_pthlist" >&8 tshelllist="" inodelist="" for d in $_pthlist; do for s in $tryshell ; do rs=$d/$s if [ -x $rs ]; then while [ -h $rs ]; do ors=$rs rs="`ls -l $rs | sed 's/.* //'`" case $rs in /*) ;; *) rs="$d/$rs" ;; esac # /etc/alternatives/xxx has some weird names w/dots. # all ksh* are ksh # anything not ksh/bash/zsh is sh # if the name is sh->bash or sh->ksh; don't follow symlink. ts=`echo $rs | sed -e 's,.*[/\.],,' \ -e 's/ksh88/ksh/' -e 's/ksh93/ksh/' ` tts=`echo $s | sed -e 's/ksh88/ksh/' -e 's/ksh93/ksh/' ` if [ $ts != ksh -a $ts != bash -a $ts != zsh ]; then ts=sh fi if [ $ts != ksh -a $tts != bash -a $tts != zsh ]; then tts=sh fi if [ $ts != $tts ]; then rs=$ors break fi rs=`echo $rs | sed 's,/[^/]*/\.\./,/,'` rs=`echo $rs | sed 's,/[^/]*/\.\./,/,'` rs=`echo $rs | sed 's,/[^/]*/\.\./,/,'` rs=`echo $rs | sed 's,/[^/]*/\.\./,/,'` done inode=`ls -i ${rs} | sed -e 's/^ *//' -e 's/ .*//'` inode=${inode}${s} # append shell type also found=F for i in $inodelist; do if [ "$inode" = "${i}" ]; then found=T break fi done if [ $found = T ]; then continue fi if [ -x $rs ]; then cmd="$rs -c \". $_MKCONFIG_DIR/bin/shellfuncs.sh;getshelltype $rs echo\"" set `eval $cmd` dispshell=$1 echo " found: $rs ($dispshell)" >&8 case $dispshell in *) tshelllist="${tshelllist} $rs" if [ "${inode}" != ${s} ]; then inodelist="${inodelist} ${inode}" fi ;; esac fi # if executable fi # if there is a file done done tshelllist=`echo "$tshelllist" | sort -u` systype=`uname -s` shelllist="" for s in $tshelllist; do putsnonl " check $s" >&8 putsnonl " $s" cmd="$s -c \". $_MKCONFIG_DIR/bin/shellfuncs.sh;chkshell echo\"" eval $cmd >&8 2>&1 rc=$? cmd="$s -c \". $_MKCONFIG_DIR/bin/shellfuncs.sh;getshelltype $s echo\"" set `eval $cmd` dispshell=$1 shift shvers=$@ if [ $rc -eq 0 ]; then echo " ok" >&8 shelllist="${shelllist} $s" echo " [$dispshell $shvers] (ok)" else echo " ng" >&8 echo " : $chkmsg" >&8 echo " [$dispshell $shvers] (ng)" fi done } runshelltest () { stag="" if [ "$_MKCONFIG_SHELL" != "" ]; then stag=".${scount}_${dispshell}" fi TSTRUNLOG=${_MKCONFIG_TSTRUNTMPDIR}/${tbase}.log${stag} > $TSTRUNLOG exec 9>>$TSTRUNLOG echo "####" >&9 echo "# Test: $tbase $arg" >&9 if [ "$_MKCONFIG_SHELL" != "" ]; then echo "## testing with ${_MKCONFIG_SHELL} " >&9 fi echo "# $dt" >&9 echo "####" >&9 cd $_MKCONFIG_TSTRUNTMPDIR if [ "$_MKCONFIG_SHELL" != "" ]; then putsnonl " ${dispshell}" fi targ=$arg if [ "$arg" != "" ]; then targ="$_MKCONFIG_DIR/$arg" fi # dup stdout to 5; redirect stdout to 9; redirect stderr to new 1. ${_MKCONFIG_SHELL} $_MKCONFIG_RUNTESTDIR/$tf "$stag" $targ 5>&1 >&9 2>&1 rc=$? cd $_MKCONFIG_RUNTESTDIR dt=`date` echo "####" >&9 echo "# $dt" >&9 echo "# exit $rc" >&9 echo "####" >&9 exec 9>&- if [ $rc -ne 0 -a "$_MKCONFIG_SHELL" != "" ]; then putsnonl "*" fi return $rc } # # main # _MKCONFIG_RUNTOPDIR=`pwd` export _MKCONFIG_RUNTOPDIR mypath=`echo $0 | sed -e 's,/[^/]*$,,' -e 's,^\.,./.,'` if [ "$mypath" = runtests.sh ]; then mypath=. fi _MKCONFIG_DIR=`(cd $mypath;pwd)` export _MKCONFIG_DIR . ${_MKCONFIG_DIR}/bin/shellfuncs.sh _MKC_ONCE=0 export _MKC_ONCE _MKC_SH=1 export _MKC_SH _MKC_PL=2 export _MKC_PL _MKC_SH_PL=3 export _MKC_SH_PL doshelltest $0 $@ if [ $SUBDIR = F ]; then mkconfigversion fi testdir=$1 if [ ! -d $testdir ]; then echo "## Unable to locate $testdir" exit 1 fi shift teststorun=$* cd $testdir if [ $? != 0 ]; then echo "## Unable to cd to $testdir" exit 1 fi _MKCONFIG_RUNTESTDIR=`pwd` export _MKCONFIG_RUNTESTDIR if [ $SUBDIR = F ]; then _MKCONFIG_RUNTMPDIR=$_MKCONFIG_RUNTOPDIR/_mkconfig_runtests export _MKCONFIG_RUNTMPDIR CC=${CC:-cc} export CC DC=${DC:-gdc} export DC else btestdir=`echo $testdir | sed 's,.*/,,'` _MKCONFIG_RUNTMPDIR=$_MKCONFIG_RUNTOPDIR/_mkconfig_runtests/$btestdir export _MKCONFIG_RUNTMPDIR fi TMPORDER=test_order.tmp > $TMPORDER if [ "$teststorun" = "" ]; then if [ ! -f "$TESTORDER" ]; then ls -1d *.d *.sh 2>/dev/null | sed -e 's/\.sh$//' -e 's/^/1/' >> $TMPORDER else sort -n $TESTORDER >> $TMPORDER fi else for t in $teststorun; do echo "1 $t" done >> $TMPORDER fi if [ $SUBDIR = F ]; then test -d $_MKCONFIG_RUNTMPDIR && rm -rf "$_MKCONFIG_RUNTMPDIR" fi test -d $_MKCONFIG_RUNTMPDIR || mkdir $_MKCONFIG_RUNTMPDIR MAINLOG=${_MKCONFIG_RUNTMPDIR}/main.log if [ $SUBDIR = F ]; then > $MAINLOG fi exec 8>>$MAINLOG if [ $SUBDIR = F ]; then echo "## locating valid shells" getlistofshells fi locatecmd awkcmd awk locatecmd nawkcmd nawk locatecmd gawkcmd gawk locatecmd mawkcmd mawk if [ "$nawkcmd" != "" ]; then awkcmd=$nawkcmd fi if [ "$mawkcmd" != "" ]; then awkcmd=$mawkcmd fi if [ "$gawkcmd" != "" ]; then awkcmd=$gawkcmd fi echo "awk: $awkcmd" >&8 export shelllist grc=0 count=0 fcount=0 fpass=0 lastpass="" # save stdin in fd 7 exec 7<&0 < ${TMPORDER} while read tline; do set $tline pass=$1 tbase=$2 if [ "$lastpass" = "" ]; then lastpass=$pass fi if [ $grc -ne 0 -a "$lastpass" != "$pass" ]; then if [ $SUBDIR = F ]; then echo "## stopping tests due to failures in $testdir/ pass $lastpass" else fpass=$lastpass fi echo "## stopping tests due to failures in $testdir/ pass $lastpass" >&8 break fi if [ -d "$tbase" ]; then ocwd=`pwd` cd $_MKCONFIG_DIR TMPOUT=${_MKCONFIG_TSTRUNTMPDIR}/${tbase}.out ${_MKCONFIG_SHELL} ./runtests.sh -s "$CC" "$DC" "$shelllist" "$_pthlist" $TMPOUT $testdir/$tbase retvals=`tail -1 $TMPOUT` rm -f $TMPOUT > /dev/null 2>&1 set $retvals retcount=$1 retfcount=$2 retfpass=$3 domath count "$count + $retcount" domath fcount "$fcount + $retfcount" rc=$retfcount if [ $rc -ne 0 ]; then grc=$rc echo "## stopping tests due to failures in $testdir/$tbase/ pass $retfpass (pass $lastpass) " echo "## stopping tests due to failures in $testdir/$tbase/ pass $retfpass (pass $lastpass)" >&8 break fi cd $ocwd continue fi tprefix=`echo $tbase | sed 's/-.*//'` if [ "${CC}" = "" -a "$tprefix" = c ]; then continue fi if [ "${DC}" = "" -a "$tprefix" = d ]; then continue fi tf="${tbase}.sh" tconfig="${tbase}.config" tconfh="${tbase}.ctmp" ok=T if [ ! -f ./$tf ]; then echo "$tbase ... missing ... failed" echo "$tbase ... missing ... failed" >&8 ok=F elif [ ! -x ./$tf ]; then echo "$tbase ... permission denied ... failed" echo "$tbase ... permission denied ... failed" >&8 ok=F fi if [ $ok = F ]; then domath fcount "$fcount + 1" domath count "$count + 1" continue fi dt=`date` arg="mkconfig.sh" scount="" putsnonl "$tbase ..." putsnonl "$tbase ..." >&8 _MKCONFIG_TSTRUNTMPDIR=$_MKCONFIG_RUNTMPDIR/${tbase} export _MKCONFIG_TSTRUNTMPDIR mkdir ${_MKCONFIG_TSTRUNTMPDIR} if [ -f $tconfig ]; then cp $tconfig $_MKCONFIG_TSTRUNTMPDIR/$tconfh fi tfdisp=`$_MKCONFIG_RUNTESTDIR/$tf -d` putsnonl " ${tfdisp}" putsnonl " ${tfdisp}" >&8 $_MKCONFIG_RUNTESTDIR/$tf -q runshpl=$? if [ $runshpl -eq $_MKC_SH -o $runshpl -eq $_MKC_SH_PL ]; then putsnonl " ..." putsnonl " ..." >&8 src=0 scount=1 for s in $shelllist; do unset _shell unset dispshell cmd="$s -c \". $_MKCONFIG_DIR/bin/shellfuncs.sh;getshelltype $s echo\"" set `eval $cmd` dispshell=$1 _MKCONFIG_SHELL=$s export _MKCONFIG_SHELL runshelltest rc=$? if [ $rc -ne 0 ]; then src=$rc; fi domath scount "$scount + 1" unset _shell unset dispshell unset _MKCONFIG_SHELL done else runshelltest src=$? fi if [ $src -ne 0 ]; then src=1 grc=1 if [ $tbase = c-compiler -a $grc -ne 0 ]; then CC="" grc=0 fi if [ $tbase = d-compiler -a $grc -ne 0 ]; then DC="" grc=0 fi if [ $grc -eq 0 ]; then echo " ... skipping $tprefix compiler tests" echo " skipping $tprefix compiler tests" >&8 else echo " ... failed" echo " failed" >&8 domath fcount "$fcount + 1" fi else echo " ... success" echo " success" >&8 fi domath count "$count + 1" # for some reason, unixware can't handle this if it is split into # multiple lines. if [ "$DOPERL" = T -a \( $runshpl -eq $_MKC_PL -o $runshpl -eq $_MKC_SH_PL \) ]; then _MKCONFIG_TSTRUNTMPDIR=$_MKCONFIG_RUNTMPDIR/${tbase}_pl export _MKCONFIG_TSTRUNTMPDIR mkdir ${_MKCONFIG_TSTRUNTMPDIR} TSTRUNLOG=$_MKCONFIG_TSTRUNTMPDIR/${tbase}.log > $TSTRUNLOG exec 9>>$TSTRUNLOG dt=`date` echo "####" >&9 echo "# Test: $tf mkconfig.pl" >&9 echo "# $dt" >&9 echo "####" >&9 putsnonl "$tbase ..." putsnonl "$tbase ..." >&8 putsnonl " ${tfdisp}" putsnonl " ${tfdisp}" >&8 putsnonl " ... perl" putsnonl " ... perl" >&8 echo "## Using mkconfig.pl " >&9 if [ -f $tconfig ]; then cp $tconfig $_MKCONFIG_TSTRUNTMPDIR/$tconfh fi cd $_MKCONFIG_TSTRUNTMPDIR # dup stdout to 5; redirect stdout to 9; redirect stderr to new 1. $_MKCONFIG_RUNTESTDIR/$tf none $_MKCONFIG_DIR/mkconfig.pl 5>&1 >&9 2>&1 rc=$? cd $_MKCONFIG_RUNTESTDIR dt=`date` echo "####" >&9 echo "# $dt" >&9 echo "# exit $rc" >&9 echo "####" >&9 exec 9>&- if [ $rc -ne 0 ]; then echo " ... failed" echo " failed" >&8 domath fcount "$fcount + 1" grc=1 else echo " ... success" echo " success" >&8 fi domath count "$count + 1" fi lastpass=$pass done # set std to saved fd 7; close 7 exec <&7 7<&- test -f $TMPORDER && rm -f $TMPORDER if [ $count -eq 0 ]; then # this can't be right... $fcount = -1 fi exec 8>&- if [ $SUBDIR = F ]; then echo "$count tests $fcount failures" if [ $fcount -eq 0 ]; then if [ "$MKC_KEEP_RUN_TMP" = "" ]; then test -d "$_MKCONFIG_RUNTMPDIR" && rm -rf "$_MKCONFIG_RUNTMPDIR" fi fi else echo "$count $fcount $fpass" > $TMPOUT fi exit $fcount di-4.47/mkconfig/LICENSE0000644000175000017500000000157413334050206012755 0ustar bllbll Copyright 2010-2018 Brad Lanam, Walnut Creek, CA, USA This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. di-4.47/LICENSE0000644000175000017500000000157413334050206011160 0ustar bllbll Copyright 1994-2018 Brad Lanam, Walnut Creek, CA, USA This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution.