di-4.34/0000755000175000017500000000000012076642270010152 5ustar bllblldi-4.34/di.10000444000175000017500000002774612076642270010646 0ustar bllbll.\" .\" $Id: di.1,v 1.56 2013-01-17 12:46:04-08 bll Exp $ .\" $Revision: 1.56 $ .\" .\" di.1 .\" .\" Copyright 1994-2013 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 .NXA "di command" "dumpfs command" .NXA "di command" "df command" .NXR "disk" "displaying free space" \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 \-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: m \- by mount point (default); n \- leave unsorted (as it appears in the mount table); s \- by special device name; t \- by filesystem type; r \- reverse the sort order. .IP These sort options may be combined in any order. e.g.: di \-stsrm \- by type, special, reversed mount; di \-strsrm \- by type, reversed special, mount. .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 .SH Website http://www.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.34/Makefile0000444000175000017500000001273012076642270011613 0ustar bllbll# # di makefile - top level # # Copyright 2001-2011 Brad Lanam Walnut Creek CA, USA # # $Id: Makefile,v 1.13 2012-11-07 16:10:34-08 bll Exp $ # 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) -e all .PHONY: all-c all-c: $(MAKE) checkbuild cd C >/dev/null && $(MAKE) -e all .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) -e all-perl .PHONY: windows-gcc windows-gcc: cd C >/dev/null && $(MAKE) -e windows-gcc .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 $(MKCONFIGPATH)/*.tar.gz \ di-[0-9].[0-9][0-9][a-z].tar.gz > /dev/null 2>&1 cd $(MKCONFIGPATH) && $(MAKE) tar ./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 @-(cd C >/dev/null && $(MAKE) clean > /dev/null 2>&1) @-(cd mkconfig >/dev/null && $(MAKE) clean > /dev/null 2>&1) @-(cd D >/dev/null && $(MAKE) clean > /dev/null 2>&1) # 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 @-(cd C >/dev/null && $(MAKE) realclean > /dev/null 2>&1) @-(cd mkconfig >/dev/null && $(MAKE) realclean > /dev/null 2>&1) @-(cd D >/dev/null && $(MAKE) realclean > /dev/null 2>&1) # leaves: # dioptions.dat .PHONY: distclean distclean: @-rm -rf mkconfig.cache mkc*.vars mkconfig.log \ _mkconfig_runtests checkbuild checkperlbuild checkinstall \ tests.done _tmp_mkconfig > /dev/null 2>&1 @-(cd C >/dev/null && $(MAKE) distclean > /dev/null 2>&1) @-(cd mkconfig >/dev/null && $(MAKE) distclean > /dev/null 2>&1) @-(cd D >/dev/null && $(MAKE) distclean > /dev/null 2>&1) ### # dioptions.dat dioptions.dat: features/dioptions.dat @$(CP) features/dioptions.dat dioptions.dat @$(CHMOD) u+w dioptions.dat ### # 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.34/features/0000755000175000017500000000000012076642270011770 5ustar bllblldi-4.34/features/checkinstall.dat0000444000175000017500000000100012076642270015113 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.34/features/checkbuild.dat0000444000175000017500000000121712076642270014556 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 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_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.34/features/checkperlbuild.dat0000444000175000017500000000126712076642270015446 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.34/features/dioptions.dat0000444000175000017500000000155412076642270014475 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.34/di.spec0000555000175000017500000000302712076642270011425 0ustar bllbllName: di Version: 4.33 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: http://www.gentoo.com/di/ Source0: http://www.gentoo.com/di/di-%{version}.tar.gz Source1: 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.34/D/0000755000175000017500000000000012076642270010335 5ustar bllblldi-4.34/D/digetoptn.d0000444000175000017500000007062612076642270012510 0ustar bllbll// written in the D programming language /* $Id: digetoptn.d,v 1.24 2012-01-26 19:23:42-08 bll Exp $ $Source: /home/bll/DI/di/D/RCS/digetoptn.d,v $ */ 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.34/D/dihelp.d0000444000175000017500000000412512076642270011747 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.34/D/Makefile0000444000175000017500000001131112076642270011770 0ustar bllbll# # di makefile - D # # Copyright 2011 Brad Lanam Walnut Creek CA, USA # # $Id: Makefile,v 1.25 2012-01-26 19:21:23-08 bll Exp $ # SHELL = /bin/sh OBJ_EXT = .o EXE_EXT = MAKE = make 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.34/D/d.README0000444000175000017500000000222712076642270011440 0ustar bllblldi - disk information utility (version 4.32) 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.34/D/options.d0000444000175000017500000003554712076642270012211 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.34/D/dispopts.d0000444000175000017500000000107312076642270012346 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.34/D/diskpart.d0000444000175000017500000003141212076642270012322 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.34/D/diquota.d0000444000175000017500000003702612076642270012156 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.34/D/features/0000755000175000017500000000000012076642270012153 5ustar bllblldi-4.34/D/features/env.dat0000444000175000017500000000042612076642270013435 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.34/D/features/mkconfig.dat0000444000175000017500000001763712076642270014456 0ustar bllbll# # $Id: mkconfig.dat,v 1.23 2012-01-26 19:25:42-08 bll Exp $ # $Source: /home/bll/DI/di/D/features/RCS/mkconfig.dat,v $ # 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.34/D/dilocale.d0000444000175000017500000000131412076642270012253 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.34/D/di.d0000444000175000017500000001332412076642270011077 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.34/D/display.d0000444000175000017500000006360712076642270012161 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.34/LICENSE0000444000175000017500000000157412076642270011164 0ustar bllbll Copyright 1994-2011 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.34/mkconfig/0000755000175000017500000000000012076642270011747 5ustar bllblldi-4.34/mkconfig/examples/0000755000175000017500000000000012076642270013565 5ustar bllblldi-4.34/mkconfig/examples/dtcltk/0000755000175000017500000000000012076642270015052 5ustar bllblldi-4.34/mkconfig/examples/dtcltk/Makefile0000444000175000017500000000271712076642270016517 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.34/mkconfig/examples/dtcltk/x.dat0000444000175000017500000002535212076642270016020 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.34/mkconfig/examples/dtcltk/hw_tk_d2.d0000444000175000017500000000124212076642270016715 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.34/mkconfig/examples/dtcltk/tcl.dat0000444000175000017500000014215012076642270016327 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.34/mkconfig/examples/dtcltk/tk.dat0000444000175000017500000005411112076642270016162 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.34/mkconfig/examples/dtcltk/hw_tk_d1.d0000444000175000017500000000126112076642270016715 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.34/mkconfig/examples/dtcltk/hw_tk_c.c0000444000175000017500000000120312076642270016626 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.34/mkconfig/examples/dtcltk/env.dat0000444000175000017500000000047012076642270016333 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.34/mkconfig/mkconfig.sh0000555000175000017500000005314112076642270014105 0ustar bllbll#!/bin/sh # # $Id: mkconfig.sh,v 1.105 2012-11-10 18:57:45-08 bll Exp $ # # Copyright 2009-2010 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 doshelltest $0 $@ setechovars 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 echo "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. set | grep "^mkc_" | \ sed -e "s/=/='/" -e "s/$/'/" -e "s/''/'/g" \ -e "s/='$/=''/" -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 echo ${svname} >&8 fi cmd="mkv_${prefix}_${svname}=T" eval $cmd echo " 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 echo " 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 echo " $ifleveldisp[${tname}] ${tlabel} ... " >&9 echo ${EN} "${ifleveldisp}${tlabel} ... ${EC}" >&1 } _doexport () { var=$1 val=$2 cmd="${var}=\"${val}\"" eval $cmd cmd="export ${var}" eval $cmd } printyesno_actual () { ynname=$1 ynval=$2 yntag=${3:-} echo " [${ynname}] $ynval ${yntag}" >&9 echo "$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=`echo $o | sed 's/=.*//'` tval=`echo $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=F # if option is not set, it's false found=F if [ $optionsloaded = T ]; then eval tval=\$_mkc_opt_${oopt} if [ "$tval" != "" ]; then found=T trc=$tval tolower trc echo " found option: $oopt $trc" >&9 if [ "$trc" = t ]; then trc=T; fi if [ "$trc" = enable ]; then trc=T; fi if [ "$trc" = f ]; then trc=F; fi if [ "$trc" = disable ]; then trc=F; fi if [ "$trc" = true ]; then trc=T; fi if [ "$trc" = false ]; then trc=F; fi fi fi if [ "$trc" = T ]; then trc=1; fi if [ "$trc" = 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 trc=0 printyesno_actual $name "no options file" elif [ "$found" = F ]; then trc=0 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 echo "## 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 echo "## token: $token" >&9 case $token in \'*\') token=`echo $token | sed -e s,\',,g` echo "## begin/end quoted token" >&9 ;; \'*) qtoken=$token echo "## begin qtoken: $qtoken" >&9 quoted=1 continue ;; esac if [ $quoted -eq 1 ]; then case $token in *\') token="${qtoken} $token" token=`echo $token | sed -e s,\',,g` echo "## end qtoken: $token" >&9 quoted=0 ;; *) qtoken="$qtoken $token" echo "## 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 '(' '\\\\\\(' ')' '\\\\\\)' echo "## nline: $nline" >&9 eval $nline trc=$? echo "## eval nline: $trc" >&9 # replace w/ shell return if [ $trc -eq 0 ]; then trc=1; else trc=0; fi echo "## 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 echo " 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 echo "## echo: $val" >&9 echo "$val" >&1 } check_exit () { echo "## 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 echo "load-unit: ${lu} ${tag}" >&1 echo " 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 echo " required unit ${rqu} already loaded" >&9 continue fi echo " required unit ${rqu} needed" >&9 _doloadunit $rqu Y done } _create_output () { if [ ${CONFH} != none ]; then confdir=`echo ${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" echo "#### ${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=`echo "${tdatline}" | sed -e 's/\\\\\\([^\\\\]\\)/\\1/g' -e 's/\\\\\\\\/\\\\/g'` fi echo "${tdatline}" >> $INC fi else case ${tdatline} in "") continue ;; \#*) continue ;; *) echo "#### ${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 echo "## else iflevels: $iflevels" >&9 else echo "## else: ifcurrlvl: $ifcurrlvl doif: $doif" >&9 fi ;; "if "*) if [ $doproc -eq 0 ]; then domath ifcurrlvl "$ifcurrlvl + 1" echo "## if: ifcurrlvl: $ifcurrlvl doif: $doif" >&9 fi ;; "endif") echo "## endifA: ifcurrlvl: $ifcurrlvl doif: $doif" >&9 if [ $ifcurrlvl -eq $doif ]; then set $doproclist c=$# if [ $c -gt 0 ]; then echo "## doproclist: $doproclist" >&9 doproc=$1 shift doproclist=$@ echo "## doproc: $doproc doproclist: $doproclist" >&9 set -- $iflevels shift iflevels=$@ _setifleveldisp echo "## endif iflevels: $iflevels" >&9 else doproc=1 ifleveldisp="" iflevels="" fi domath doif "$doif - 1" fi domath ifcurrlvl "$ifcurrlvl - 1" echo "## 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}" domath ifstmtcount "$ifstmtcount + 1" check_ifoption $ifstmtcount $type ${nm} ${opt} rc=$? iflevels="+$ifstmtcount $iflevels" _setifleveldisp echo "## ifopt iflevels: $iflevels" >&9 doproclist="$doproc $doproclist" doproc=$rc echo "## doproc: $doproc doproclist: $doproclist" >&9 ;; "if "*) _chkconfigfname set $tdatline shift label=$1 shift ifline=$@ domath ifcurrlvl "$ifcurrlvl + 1" echo "## if: ifcurrlvl: $ifcurrlvl" >&9 domath ifstmtcount "$ifstmtcount + 1" check_if $label $ifstmtcount "$ifline" rc=$? iflevels="+$ifstmtcount $iflevels" _setifleveldisp echo "## if iflevels: $iflevels" >&9 doproclist="$doproc $doproclist" doproc=$rc doif=$ifcurrlvl echo "## 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 echo "option-file: ${file}" >&1 echo " 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 echo "output-file: ${file}" >&1 echo " config file name: ${CONFH}" >&9 file=`echo $file | sed -e 's,.*/,,'` file=`echo $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 () { echo "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 echo "No configuration file specified or not found." usage exit 1 fi if [ -d $_MKCONFIG_TMP -a $_MKCONFIG_TMP != _tmp_mkconfig ]; then echo "$_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 echo "#### " >&9 echo "# Start: $dt " >&9 echo "# $0 ($shell) using $configfile " >&9 echo "#### " >&9 echo "shell: $shell" >&9 echo "has append: ${shhasappend}" >&9 echo "has math: ${shhasmath}" >&9 echo "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 echo "awk: $awkcmd" >&9 echo "$0 ($shell) using $configfile" main_process $configfile dt=`date` echo "#### " >&9 echo "# End: $dt " >&9 echo "#### " >&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.34/mkconfig/Makefile0000444000175000017500000000140212076642270013402 0ustar bllbll# # # RM = rm DC = gdc SHELL = /bin/sh ### # .PHONY: test test: tests.done # leaves _tmp_mkconfig, _mkconfig_runtests, checktests .PHONY: clean clean: @-$(RM) -rf tests.done tests.d/chksh* tests.d/c.d/chksh* \ tests.d/d.d/chksh* mkconfig.cache mkconfig.log \ mkc*.vars > /dev/null 2>&1 .PHONY: realclean realclean: @$(MAKE) clean > /dev/null 2>&1 @-$(RM) -rf checktests _tmp_mkconfig _mkconfig_runtests \ > /dev/null 2>&1 .PHONY: distclean distclean: @$(MAKE) realclean > /dev/null 2>&1 ### checktests: $(_MKCONFIG_SHELL) ./mkconfig.sh features/checktests.dat touch checktests tests.done: runtests.sh @echo "## running mkconfig tests" CC=$(CC) DC=$(DC) $(_MKCONFIG_SHELL) ./runtests.sh tests.d touch tests.done .PHONY: tar tar: ./util/mktar.sh di-4.34/mkconfig/VERSION0000444000175000017500000000000512076642270013010 0ustar bllbll1.23 di-4.34/mkconfig/units/0000755000175000017500000000000012076642270013111 5ustar bllblldi-4.34/mkconfig/units/d-support.sh0000555000175000017500000001012212076642270015377 0ustar bllbll#!/bin/sh # # Copyright 2010-2012 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 echo "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 echo "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=$? echo "## run test: link: $rc" >&9 rval=0 if [ $rc -eq 0 ]; then rval=`./${drname}.exe` rc=$? echo "## 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 echo "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- dlibs="" otherlibs="" _d_chk_link $dllname rc=$? echo "## 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=$? echo "## 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 " echo "## _link test (compile): $cmd" >&9 cat ${dlname}.d >&9 eval ${cmd} >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi echo "## _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 echo "## _link test (link): $cmd" >&9 cat ${dlname}.d >&9 eval $cmd >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi echo "## _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 echo "${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} " echo "## compile test: $cmd" >&9 cat ${dfname}.d >&9 eval ${cmd} >&9 2>&9 rc=$? echo "## 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.34/mkconfig/units/env-cc.sh0000555000175000017500000003121212076642270014620 0ustar bllbll#!/bin/sh # # $Id: env-cc.sh,v 1.41 2013-01-17 17:11:13-08 bll Exp $ # $Source: /home/bll/DI/di/mkconfig/units/RCS/env-cc.sh,v $ # # Copyright 2001-2012 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 env_dohpflags=F _MKCONFIG_32BIT_FLAGS=F _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 [ "${xgetconf}" != "" ] then echo "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 } _dohpflags () { if [ "$env_dohpflags" = T ]; then return fi hpccincludes="" hpldflags="" # check for libintl in other places... if [ -d /usr/local/include -a \ -d /usr/local/lib ]; then hpccincludes="-I/usr/local/include" hpldflags="-L/usr/local/lib" if [ -d /usr/local/lib/hpux32 ]; then hpldflags="$hpldflags -L/usr/local/lib/hpux32" fi fi env_dohpflags=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 echo "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 echo "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 gcc... ${CC} -v 2>&1 | grep 'clang version' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then echo "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 gcc... ${CC} -v 2>&1 | grep 'GNU ld' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then echo "found gnu ld" >&9 usinggnuld="Y" fi printyesno_val _MKCONFIG_USING_GNU_LD "${usinggnuld}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_USING_GNU_LD "${usinggnuld}" } check_cflags () { _read_option CFLAGS "" ccflags="${CFLAGS:-${oval}}" _read_option CINCLUDES "" ccincludes="${CINCLUDES:-${oval}}" printlabel CFLAGS "C flags" _dogetconf gccflags="" if [ "${_MKCONFIG_USING_GCC}" = Y ]; then echo "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 fi if [ "${_MKCONFIG_USING_CLANG}" = Y ]; then ccflags="-Wno-unknown-warning-option -Weverything -Wno-padded -Wno-format-nonliteral -Wno-cast-align -Wno-system-headers $ccflags" fi TCC=${CC} if [ "${_MKCONFIG_USING_GCC}" = Y ]; then TCC=gcc fi case ${_MKCONFIG_SYSTYPE} in AIX) if [ "${_MKCONFIG_USING_GCC}" = N ]; then ccflags="-qhalt=e $ccflags" ccflags="$ccflags -qmaxmem=-1" case ${_MKCONFIG_SYSREV} in 4.*) ccflags="-DUSE_ETC_FILESYSTEMS=1 $ccflags" ;; esac fi ;; FreeBSD) # FreeBSD has many packages that get installed in /usr/local ccincludes="-I/usr/local/include $ccincludes" ;; HP-UX) if [ "${lfccflags}" = "" -a "${_MKCONFIG_32BIT_FLAGS}" = F ]; then ccflags="-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 $ccflags" fi case ${TCC} in cc) case ${_MKCONFIG_SYSREV} in *.10.*) ccflags="+DAportable $ccflags" ;; esac cc -v 2>&1 | grep -l Bundled > /dev/null 2>&1 rc=$? if [ $rc -ne 0 ]; then ccflags="-Ae $ccflags" fi _MKCONFIG_USING_GCC="N" ;; esac _dohpflags ccincludes="$hpccincludes $ccincludes" ;; 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. ccflags="-Xa -v $ccflags" # optimization; -xO3 is good. -xO4 must be set by user. ccflags="`echo $ccflags | sed 's,-xO. *,-xO3 ,'`" ccflags="`echo $ccflags | sed 's,-O *,-xO3 ,'`" echo $ccflags | grep -- '-xO3' >/dev/null 2>&1 case $rc in 0) ldflags="-fast $ldflags" ;; esac ;; esac ;; esac ;; esac case ${CC} in g++|c++) if [ "${_MKCONFIG_USING_GCC}" = Y ]; then echo "set g++ flags" >&9 gccflags="-Wall -Waggregate-return -Wconversion -Wformat -Wpointer-arith -Wshadow -Wunused" fi ;; esac ccflags="$gccflags $ccflags" # largefile flags ccflags="$ccflags $lfccflags" echo "ccflags:${ccflags}" >&9 printyesno_val CFLAGS "$ccflags $ccincludes" setdata ${_MKCONFIG_PREFIX} CFLAGS "$ccflags $ccincludes" } check_addcflag () { name=$1 flag=$2 ccflags="${CFLAGS:-}" printlabel CFLAGS "Add C flag: ${flag}" echo "#include main () { return 0; }" > t.c echo "# test ${flag}" >&9 # need to set w/all cflags; gcc doesn't always error out otherwise TMPF=t$$.txt ${CC} ${ccflags} ${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 flag="" fi setdata ${_MKCONFIG_PREFIX} CFLAGS "$ccflags ${flag}" } check_ldflags () { _read_option LDFLAGS "" ldflags="${LDFLAGS:-${oval}}" printlabel LDFLAGS "C Load flags" _dogetconf TCC=${CC} if [ "${_MKCONFIG_USING_GCC}" = Y ]; then TCC=gcc fi case ${_MKCONFIG_SYSTYPE} in FreeBSD) # FreeBSD has many packages that get installed in /usr/local ldflags="-L/usr/local/lib $ldflags" ;; HP-UX) _dohpflags ldflags="$hpldflags $ldflags" case ${TCC} in cc) ldflags="-Wl,+s $ldflags" ;; esac ;; OS/2) ldflags="-Zexe" ;; SunOS) case ${_MKCONFIG_SYSREV} in 5.*) case ${TCC} in cc) echo $CFLAGS | grep -- '-xO3' >/dev/null 2>&1 case $rc in 0) ldflags="-fast $ldflags" ;; esac ;; esac ;; esac ;; esac ldflags="$ldflags $lfldflags" echo "ldflags:${ldflags}" >&9 printyesno_val LDFLAGS "$ldflags" setdata ${_MKCONFIG_PREFIX} LDFLAGS "$ldflags" } check_libs () { _read_option LIBS "" libs="${LIBS:-${oval}}" printlabel LIBS "C Libraries" _dogetconf gccflags="" TCC=${CC} if [ "${_MKCONFIG_USING_GCC}" = Y ]; then TCC=gcc fi case ${_MKCONFIG_SYSTYPE} in BeOS|Haiku) # uname -m does not reflect actual architecture libs="-lroot -lbe $libs" ;; esac # largefile flags libs="$libs $lflibs" echo "libs:${libs}" >&9 printyesno_val LIBS "$libs" setdata ${_MKCONFIG_PREFIX} LIBS "$libs" } check_shcflags () { _read_option SHCFLAGS "" shcflags="${SHCFLAGS:-${oval}}" printlabel SHCFLAGS "shared library cflags" shcflags="-fPIC $SHCFLAGS" if [ "$_MKCONFIG_USING_GCC" != Y ]; then case ${_MKCONFIG_SYSTYPE} in CYGWIN*) shcflags="$SHCFLAGS" ;; Darwin) shcflags="-fno-common $SHCFLAGS" ;; HP-UX) shcflags="+Z $SHCFLAGS" ;; Irix) shcflags="-KPIC $SHCFLAGS" ;; OSF1) # none ;; SCO_SV) shcflags="-KPIC $SHCFLAGS" ;; SunOS) shcflags="-KPIC $SHCFLAGS" ;; UnixWare) shcflags="-KPIC $SHCFLAGS" ;; esac fi printyesno_val SHCFLAGS "$shcflags" setdata ${_MKCONFIG_PREFIX} SHCFLAGS "$shcflags" } check_shldflags () { _read_option SHLDFLAGS "" shldflags="${SHLDFLAGS:-${oval}}" printlabel SHLDFLAGS "shared library ldflags" shldflags="$SHLDFLAGS -shared" if [ "$_MKCONFIG_USING_GCC" != Y ]; then case ${_MKCONFIG_SYSTYPE} in AIX) shldflags="$SHLDFLAGS -G" ;; HP-UX) shldflags="$SHLDFLAGS -b" ;; Irix) # "-shared" ;; OSF1) shldflags="-shared -msym -no_archive" ;; SCO_SV) shldflags="$SHLDFLAGS -G" ;; SunOS) shldflags="$SHLDFLAGS -G" ;; UnixWare) shldflags="$SHLDFLAGS -G" ;; esac fi case ${_MKCONFIG_SYSTYPE} in Darwin) shldflags="$SHLDFLAGS -dynamiclib" ;; esac printyesno_val SHLDFLAGS "$shldflags" setdata ${_MKCONFIG_PREFIX} SHLDFLAGS "$shldflags" } 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 SHEXECLINK "shared executable link flag " SHEXECLINK="-Bdynamic " if [ "$_MKCONFIG_USING_GCC" != Y ]; then case ${_MKCONFIG_SYSTYPE} in AIX) SHEXECLINK="-brtl -bdynamic " ;; Darwin) SHEXECLINK="" ;; HP-UX) SHEXECLINK="+Z" ;; OSF1) SHEXECLINK="-msym -no_archive " ;; SCO_SV) SHEXECLINK="" ;; SunOS) # -Bdynamic ;; UnixWare) SHEXECLINK="" ;; esac fi printyesno_val SHEXECLINK "$SHEXECLINK" setdata ${_MKCONFIG_PREFIX} SHEXECLINK "$SHEXECLINK" } check_sharerunpathflag () { printlabel SHRUNPATH "shared run path flag " SHRUNPATH="-Wl,-rpath=" if [ "$_MKCONFIG_USING_GNU_LD" != Y ]; then case ${_MKCONFIG_SYSTYPE} in AIX) SHRUNPATH="" ;; Darwin) SHRUNPATH="" ;; HP-UX) SHRUNPATH="-Wl,+b " ;; OSF1) SHRUNPATH="-rpath " ;; SCO_SV) SHRUNPATH="-Wl,-R " ;; SunOS) SHRUNPATH="-Wl,-R" ;; UnixWare) SHRUNPATH="-Wl,-R " ;; esac fi printyesno_val SHRUNPATH "$SHRUNPATH" setdata ${_MKCONFIG_PREFIX} SHRUNPATH "$SHRUNPATH" } di-4.34/mkconfig/units/env-msgfmt.sh0000555000175000017500000000222012076642270015525 0ustar bllbll#!/bin/sh # # $Id: env-msgfmt.sh,v 1.8 2010-03-21 00:50:31-07 bll Exp $ # $Source: /home/bll/DI/mkconfig/units/RCS/env-msgfmt.sh,v $ # # Copyright 2010 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.34/mkconfig/units/c-include-conflict.sh0000555000175000017500000000312112076642270017105 0ustar bllbll#!/bin/sh # # Copyright 2010 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 echo "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.34/mkconfig/units/c-support.sh0000555000175000017500000001253412076642270015407 0ustar bllbll#!/bin/sh # # Copyright 2010-2012 Brad Lanam Walnut Creek CA USA # # CPPCOUNTER=1 _c_print_headers () { incheaders=$1 out="${PH_PREFIX}${incheaders}" if [ -f $out ]; then cat $out return fi if [ "$PH_STD" = "T" -a "$incheaders" = "std" ]; then _c_print_hdrs std > $out cat $out return fi if [ "$PH_ALL" = "T" -a "$incheaders" = "all" ]; then _c_print_hdrs all > $out cat $out return fi # until PH_STD/PH_ALL becomes true, just do normal processing. _c_print_hdrs $incheaders } _c_print_hdrs () { incheaders=$1 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 echo "#include <${tval}>" 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 echo "#include <${hdval}>" fi fi ;; _sys_time) if [ "${hdval}" != "0" ]; then getdata itval ${_MKCONFIG_PREFIX} '_inc_conflict__hdr_time__sys_time' if [ "${itval}" = "1" ]; then echo "#include <${hdval}>" fi fi ;; _hdr_*|_sys_*) if [ "${hdval}" != "0" -a "${hdval}" != "" ]; then echo "#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=$? echo "## run test: link: $rc" >&9 rval=0 if [ $rc -eq 0 ]; then rval=`./${crname}.exe` rc=$? echo "## 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} echo "${precc}" >&4 _c_print_headers $inc >&4 echo "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- dlibs="" otherlibs="" _c_chk_link $cllname rc=$? echo "## 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=$? echo "## 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 echo "## _cpp test: reusing $tcppout" >&9 rc=0 return $rc fi fi # $cppname should be unique exec 4>>${tcppfile} echo "${precc}" >&4 _c_print_headers $inc >&4 echo "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- cmd="${CC} ${CFLAGS} ${CPPFLAGS} -E ${tcppfile} > ${tcppout} " echo "## _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 echo "## _cpp test: $rc" >&9 return $rc } _c_chk_link () { clname=$1 cmd="${CC} ${CFLAGS} ${CPPFLAGS} -o ${clname}.exe ${clname}.c " cmd="${cmd} ${LDFLAGS} ${LIBS} " _clotherlibs=$otherlibs if [ "${_clotherlibs}" != "" ]; then cmd="${cmd} ${_clotherlibs} " fi echo "## _link test: $cmd" >&9 cat ${clname}.c >&9 eval $cmd >&9 2>&9 rc=$? if [ $rc -lt 0 ]; then _exitmkconfig $rc fi echo "## _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} echo "${precc}" >&4 _c_print_headers $inc >&4 echo "${code}" | sed 's/_dollar_/$/g' >&4 exec 4>&- cmd="${CC} ${CFLAGS} ${CPPFLAGS} -c ${tcfile}" echo "## compile test: $cmd" >&9 cat ${ccname}.c >&9 eval ${cmd} >&9 2>&9 rc=$? echo "## 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.34/mkconfig/units/env-dc.sh0000555000175000017500000001042712076642270014626 0ustar bllbll#!/bin/sh # # $Id: env-dc.sh,v 1.17 2012-01-18 15:49:40-08 bll Exp $ # $Source: /home/bll/DI/mkconfig/units/RCS/env-dc.sh,v $ # # Copyright 2010-2012 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" echo "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 echo ' 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 echo "## 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 echo "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 echo "set gdc flags" >&9 gdcflags="" fi TDC=${DC} if [ "${_MKCONFIG_USING_GDC}" = "Y" ] then TDC=gdc fi dflags="$gdcflags $dflags" echo "dflags:${dflags}" >&9 printyesno_val DFLAGS "$dflags" setdata ${_MKCONFIG_PREFIX} DFLAGS "$dflags" } di-4.34/mkconfig/units/env-main.sh0000555000175000017500000000332012076642270015156 0ustar bllbll#!/bin/sh # # Copyright 2010-2012 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 echo "#!/bin/sh" echo "# Created on: `date`" echo "# From: ${configfile}" echo "# 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 echo ". ${val}" fi ;; _setint*|_setstr*|_opt_*) tname=$name dosubst tname '_setint_' '' '_setstr_' '' '_opt_' '' echo "${tname}=\"${val}\"" echo "export ${tname}" ;; *) echo "${name}=\"${val}\"" echo "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.34/mkconfig/units/env-extension.sh0000555000175000017500000000432712076642270016256 0ustar bllbll#!/bin/sh # # $Id: env-extension.sh,v 1.14 2012-01-18 14:21:44-08 bll Exp $ # $Source: /home/bll/DI/mkconfig/units/RCS/env-extension.sh,v $ # # Copyright 2001-2012 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 TMP=objext CC=${CC:-cc} > $TMP.c echo ' #include main () { printf ("hello\n"); return 0; } ' ${CC} ${CFLAGS} ${CPPFLAGS} -c $TMP.c > /dev/null 2>&1 # don't care about warnings... OBJ_EXT=".o" if [ -f "$TMP.obj" ]; then echo "object extension is .obj" >&9 OBJ_EXT=".obj" else echo "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 TMP=exeext CC=${CC:-cc} > $TMP.c echo ' #include main () { printf ("hello\n"); return 0; } ' ${CC} ${CFLAGS} ${CPPFLAGS} -o $TMP $TMP.c > /dev/null 2>&1 # don't care about warnings EXE_EXT="" if [ -f "$TMP.exe" ] then echo "executable extension is .exe" >&9 EXE_EXT=".exe" else echo "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*) SHLIB_EXT=".dll" ;; esac printyesno_val $name "$SHLIB_EXT" setdata ${_MKCONFIG_PREFIX} $name "$SHLIB_EXT" } di-4.34/mkconfig/units/env-systype.sh0000555000175000017500000000725012076642270015760 0ustar bllbll#!/bin/sh # # $Id: env-systype.sh,v 1.11 2010-03-21 00:50:35-07 bll Exp $ # $Revision: 1.11 $ # # Copyright 2010 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 echo "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 echo "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 echo "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 || echo "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 echo "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=`echo $rev | sed 's/^[^0-9]*\([0-9]\)\([0-9]\).*/\1.\2/'` _MKCONFIG_SYSREV="$rev" fi fi fi echo "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 echo "no uname, try some guessing" >&9 # no uname...we'll have to do some guessing. _MKCONFIG_SYSARCH="unknown" locatecmd xarch arch echo "arch located: ${xarch}" >&9 if [ "${xarch}" != "" ]; then _MKCONFIG_SYSARCH=`arch` fi fi echo "arch: ${_MKCONFIG_SYSARCH}" >&9 printyesno_val _MKCONFIG_SYSARCH "${_MKCONFIG_SYSARCH}" setdata ${_MKCONFIG_PREFIX} _MKCONFIG_SYSARCH "${_MKCONFIG_SYSARCH}" fi } di-4.34/mkconfig/units/d-main.sh0000555000175000017500000012373212076642270014623 0ustar bllbll#!/bin/sh # # Copyright 2011-2012 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 echo $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' " echo "##### modify_ctypes" >&9 # echo "##### modify_ctypes: before" >&9 # echo "$tcode1" >&9 # echo "##### modify_ctypes: end before" >&9 # echo "##### modify_ctypes: $cmd" >&9 eval "${tmcnm1}=\`echo \"\${tcode1}\" | ${cmd}\`" >&9 2>&9 # echo "#### modify_ctypes: after" >&9 # eval "echo \"\$${tmcnm1}\"" >&9 # echo "#### modify_ctypes: end after" >&9 } modify_cchglist () { tmcnm2=$1 tcode2=$2 echo "##### modify_cchglist" >&9 # echo "##### modify_cchglist: before" >&9 # echo "$tcode2" >&9 # echo "##### modify_cchglist: end before" >&9 cmd="sed ${cchglist2} -e 's/a/a/;# could be empty'" # echo "##### modify_cchglist: $cmd" >&9 eval "tcode2=\`echo \"\${tcode2}\" | ${cmd}\`" >&9 2>&9 cmd="sed ${cchglist1} -e 's/a/a/;# could be empty'" # echo "##### modify_cchglist: $cmd" >&9 eval "tcode2=\`echo \"\${tcode2}\" | ${cmd}\`" >&9 2>&9 # echo "#### modify_cchglist: after" >&9 # echo "${tcode2}" >&9 # echo "#### modify_cchglist: end after" >&9 eval "${tmcnm2}=\"\${tcode2}\"" } modify_ccode () { tmcnm3=$1 tcode3=$2 echo "##### modify_ccode" >&9 # echo "##### modify_ccode: before" >&9 # echo "$tcode3" >&9 # echo "##### 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/;' \ " # echo "##### modify_ccode: ${cmd}" >&9 eval "tcode3=\`echo \"\${tcode3}\" | ${cmd} \`" >&9 2>&9 # echo "#### modify_ccode: after A" >&9 # echo "${tcode3}" >&9 # echo "#### 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' " # echo "##### modify_ccode: ${cmd}" >&9 # add _END_; as workaround for sed N above eval "tcode3=\`echo \"\${tcode3} _END_;\" | ${cmd} \`" >&9 2>&9 if [ "$DVERSION" = 1 ]; then cmd="sed -e 's/const *//g; # remove all const'" eval "tcode3=\`echo \"\${tcode3}\" | ${cmd} \`" >&9 2>&9 fi # echo "#### modify_ccode: after B" >&9 # echo "${tcode3}" >&9 # echo "#### 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 echo "" modify_ccode ccode "${ccode}" echo "${ccode}" fi if [ "${daliases}" != "" ]; then echo "${daliases}" fi if [ "${dasserts}" != "" ]; then echo "${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 echo "DC: ${DC}" >&9 echo "DVERSION: ${DVERSION}" >&9 echo "DFLAGS: ${DFLAGS}" >&9 echo "LDFLAGS: ${LDFLAGS}" >&9 echo "LIBS: ${LIBS}" >&9 echo "DC_OF: ${DC_OF}" >&9 echo "// Created on: `date`" echo "// From: ${configfile}" echo "// Using: mkconfig-${_MKCONFIG_VERSION}" if [ "$modname" != "" ]; then echo '' echo "module $modname;" fi if [ "$DVERSION" = 2 ]; then getdata tval ${_MKCONFIG_PREFIX} '_import_std_string' if [ "$tval" != "0" -a "$tval" != "" ]; then echo '' echo "import std.string;" fi fi getdata tval ${_MKCONFIG_PREFIX} '_type_string' if [ "$tval" = "0" ]; then echo "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 echo "No compiler specified" >&2 return fi } stdconfigfile () { pc_configfile=$1 } postconfigfile () { pc_configfile=$1 } standard_checks () { if [ "${DC}" = "" ]; then echo "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=`echo ${imp} | sed -e 's,/.*,,'` nm2="_`echo $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 echo "## chk:got:$tval: for $name" >&9 if [ "$tval" != 0 -a "$tval" != 1 -a "$tval" != "" ]; then getdata ttval ${_MKCONFIG_PREFIX} _cstruct_$tval echo "## chk:got:$ttval: for _cstruct_$tval" >&9 if [ "$ttval" = 1 ]; then echo "## 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=`echo $tdata` # make single line. echo "## tdata(0): ${tdata}" >&9 if [ "$tdata" != "" ]; then trc=1 tdata=`echo $tdata | sed -e \ 's/^\(.*\)([ *]*\([a-zA-Z0-9_][a-zA-Z0-9_]*\)[ ]*)[ ]*(\(.*\))[ ]*;/\1 function(\3) \2;/' \ -e 's/[ ]*;/;/'` echo "## tdata(B): ${tdata}" >&9 dosubst tdata typedef alias echo "## tdata(c): ${tdata}" >&9 tta=a ttb=b if [ $noprefix = T ]; then ttl=`echo $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 echo " checking $thdr : $nhdr : $vhdr " >&9 if [ "${vhdr}" != "0" -a "${vhdr}" != "" ]; then for p in $cmpaths; do echo " 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 echo " 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_]" $@ echo " \$@:$@" >&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}` echo " extracted macro: $macro" >&9 macro=`echo ${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 /'` echo " 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=`echo ${macro} | sed -e "s/return//"` fi if [ "$DVERSION" = 1 -a $rc -eq 0 -a $trc -eq 1 ]; then macro=`echo ${macro} | sed -e "s/^auto/${type}/"` echo " 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=`echo ${macro} | sed -e "s/(/(${type} /" ` echo " macroD: $macro" >&9 tfirst=0 ttype=`echo $type | sed 's/\*/\\\\*/g'` tmp="($ttype [a-zA-Z0-9_]*" else echo " tmp: $tmp" >&9 cmd="macro=\`echo \${macro} | sed -e 's/\(${tmp}\) *, */\\\\1, ${type} /'\`" echo " cmdE: $cmd" >&9 eval $cmd echo " macroE: $macro" >&9 ttype=`echo $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=`echo $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} ` echo "#### initial ${ctype}" >&9 echo "${st}" >&9 echo "#### end initial ${ctype}" >&9 if [ "${st}" != "" ]; then havest=T tst=`echo ${st} | sed -e 's/{.*}/ = /' -e 's/[ ]/ /g' -e 's/ / /g' \ -e 's/^ *//' -e 's/[ ;]*\$//'` echo "### ${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 echo "#### stnm=${stnm}" >&9 otdnm=$tdnm dosubst otdnm '\*' '' ttdnm=$tdnm dosubst ttdnm '\*' '\\*' echo "#### 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=`echo "${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=`echo "${st}" | sed -e "s/${ctype} *${stnm}\\([^a-zA-Z0-9_]\\)/${lab}${stnm}\\1/"` fi echo "#### modified ${ctype} (A)" >&9 echo ":${st}:" >&9 echo "#### end modified ${ctype} (A)" >&9 else trc=0 fi fi if [ $havest = T ]; then echo "### 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*{) echo "### found: ${tsline}" >&9 ttype=`echo ${tsline} | sed -e 's/^[ const]*\([sue][trucniom]*\) *.*/\1/'` tl=`echo ${tsline} | sed -e "s/^.*${ttype} *\([a-zA-Z0-9_]*\) *{.*/\1/"` tlab=`echo ${tl} | sed 's/^\(C_[STUNEM]*_\).*/\1/'` tl=`echo ${tl} | sed -e "s/^${tlab}//"` echo "### ttype: ${ttype}" >&9 echo "### tlab: ${tlab}" >&9 echo "### tl: ${tl}" >&9 if [ "$tl" != "" ]; then st=`echo "${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=`echo ${tsline} | sed -e 's/.*}[ *]*\([^; ]*\) *;/\1/'` # doesn't handle } w/no semi right. if [ "$tnname" != "" -a "$tnname" != "}" ]; then echo "### tnname:${tnname}:" >&9 doappend cchglist1 "-e 's/->${tnname}\././g' " doappend cchglist1 "-e 's/\.${tnname}\././g' " st=`echo "${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=`echo $tsline | sed 's/.*://'` echo $tline | grep sizeof > /dev/null 2>&1 rc=$? while test $rc -eq 0; do ttval=`echo $tline | sed -e 's/.*sizeof *( *\([^)]*\) *).*/\1/'` tnm="_csiz_${ttval}" dosubst tnm ' ' '_' getdata tval ${_MKCONFIG_PREFIX} $tnm if [ "$tval" = "" ]; then tval=0 fi tline=`echo $tline | sed -e "s/\(.*\)sizeof *([^)]*)\(.*\)/\1 ${tval} \2/"` echo $tline | grep sizeof > /dev/null 2>&1 rc=$? done # remove casts tline=`echo $tline | \ sed -e 's/([a-z ]*)//g' -e 's/ *;//' -e 's// /g' -e 's/ / /g'` domath tval " $tline " domath bftsiz "$bftsiz + $tval" echo "## 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" echo "## 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_ echo "## old st:$st:" >&9 st=$nst echo "## new st:$st:" >&9 fi ts=$s if [ "$stnm" = "" -a "$tdnm" != "$otdnm" ]; then ts=${s}_ fi st=`( echo "${ctype} ${lab}${ts} "; echo "${st}" )` echo "#### modified ${ctype} (B)" >&9 echo "${st}" >&9 echo "#### end modified ${ctype} (B)" >&9 # save this for possible later use (cmembertype, cmemberxdr) cmd="CST_${s}=\${st}" eval $cmd echo " 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 echo "#### 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 echo "#### 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 echo "## 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' " echo "## 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 echo "## 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' " echo "## 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 echo "## 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 echo "## 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}}" echo " get: ${cmd}" >&9 eval $cmd if [ "$st" != "" ]; then echo " struct ${struct}: ${st}" >&9 tmem=`echo "$st" | grep "${member} *;\$"` rc=$? echo " found: ${tmem}" >&9 if [ $rc -eq 0 ]; then mtype=`echo $tmem | sed -e "s/ *${member} *;$//" -e 's/^ *//'` echo " type:${mtype}:" >&9 echo " 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}}" echo " get: ${cmd}" >&9 eval $cmd if [ "$st" != "" ]; then echo " struct ${struct}: ${st}" >&9 tmem=`echo "$st" | grep "${member} *;\$"` rc=$? echo " found: ${tmem}" >&9 if [ $rc -eq 0 ]; then mtype=`echo $tmem | sed -e "s/ *${member} *;$//" -e 's/^ *//'` echo " 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=`echo $dcl` # make single line. echo "## dcl(0): ${dcl}" >&9 # extern will be replaced # ; may or may not be present, so remove it. cmd="dcl=\`echo \"\$dcl\" | sed -e 's/extern *//' -e 's/;//' \`" eval $cmd if [ "$DVERSION" = 1 ]; then dosubst dcl 'const' '' fi echo "## dcl(A): ${dcl}" >&9 echo $dcl | grep __asm__ > /dev/null 2>&1 rc=$? dclren="" if [ $rc -eq 0 ]; then dclren=`echo $dcl | sed -e 's/.*__asm__[ ]*("" "\([a-z0-9A-Z_]*\)")/\1/'` fi echo "## dclren: ${dclren}" >&9 if [ "$dclren" != "" ]; then doappend daliases "alias ${dclren} ${dname}; " cmd="dcl=\`echo \"\$dcl\" | \ sed -e 's/[ ]*__asm__[ ]*([^)]*)[ ]*//' \ -e 's/\([ \*]\)${dname}\([ (]\)/\1${dclren}\2/' \`" eval $cmd echo "## dcl(B): ${dcl}" >&9 fi cmd="dcl=\`echo \"\$dcl\" | sed -e 's/( *void *)/()/' \`" eval $cmd echo "## dcl(C): ${dcl}" >&9 tdcl=$dcl modify_ctypes tdcl "${tdcl}" modify_cchglist tdcl "${tdcl}" # need any struct renames for args echo "## tdcl(D): ${tdcl}" >&9 if [ $argflag = 1 ]; then c=`echo ${tdcl} | sed 's/[^,]*//g'` ccount=`echo ${EN} "$c${EC}" | wc -c` domath ccount "$ccount + 1" # 0==1 also, unfortunately c=`echo ${tdcl} | sed 's/^[^(]*(//'` c=`echo ${c} | sed 's/)[^)]*$//'` echo "## c(E): ${c}" >&9 val=1 while test "${c}" != ""; do tmp=$c tmp=`echo ${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 echo ${tmp} | grep ' ' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then tmp=`echo ${tmp} | sed -e 's/ *[A-Za-z0-9_]*$//'` fi dosubst tmp 'struct#' 'struct ' 'union#' 'union ' 'enum#' 'enum ' if [ $noconst = T ]; then tmp=`echo ${tmp} | sed -e 's/const *//'` fi echo "## 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=`echo ${c} | sed -e 's/^[^,]*//' -e 's/^[ ,]*//'` done tname=${dclren:-$dname} echo "## tname(G): ${tname} ($dname - $dclren)" >&9 c=`echo ${tdcl} | sed -e 's/[ ]/ /g' \ -e "s/\([ \*]\)${tname}[ (].*/\1/" \ -e 's/^ *//' \ -e 's/ *$//'` if [ $noconst = T ]; then c=`echo ${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.34/mkconfig/units/c-main.sh0000555000175000017500000003600312076642270014614 0ustar bllbll#!/bin/sh # # Copyright 2010-2012 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: # # #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 # # # 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 echo "CC: ${CC}" >&9 echo "CFLAGS: ${CFLAGS}" >&9 echo "CPPFLAGS: ${CPPFLAGS}" >&9 echo "LDFLAGS: ${LDFLAGS}" >&9 echo "LIBS: ${LIBS}" >&9 if [ "${CC}" = "" ]; then echo "No compiler specified" >&2 return fi echo "/* Created on: `date`" echo " From: ${configfile}" echo " Using: mkconfig-${_MKCONFIG_VERSION} */" echo '' echo "#ifndef __INC_${CONFHTAGUC}_H #define __INC_${CONFHTAGUC}_H 1 " } stdconfigfile () { pc_configfile=$1 echo ' #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 ' } postconfigfile () { pc_configfile=$1 echo " #endif /* __INC_${CONFHTAGUC}_H */" } standard_checks () { if [ "${CC}" = "" ]; then echo "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=`echo ${hdr} | sed -e 's,/.*,,'` nm2="_`echo $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_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 echo " ${struct}: ${st}" >&9 tmem=`echo "$st" | grep "${member} *;\$"` rc=$? echo " found: ${tmem}" >&9 if [ $rc -eq 0 ]; then mtype=`echo $tmem | sed -e "s/ *${member} *;$//" -e 's/^ *//'` echo " 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=$* nm="_siz_${type}" dosubst nm ' ' '_' name=$nm printlabel $name "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_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}" doappend precc "/* get rid of most gcc-isms */ #define __asm__(a) #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=$? 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}` dcl=`echo $dcl` # make single line # extern will be replaced # ; may or may not be present, so remove it. cmd="dcl=\`echo \"\$dcl\" | sed -e 's/extern *//' -e 's/;//' \`" eval $cmd echo "## dcl(A): ${dcl}" >&9 cmd="dcl=\`echo \"\$dcl\" | sed -e 's/( *void *)/()/' \`" eval $cmd echo "## dcl(C): ${dcl}" >&9 c=`echo ${dcl} | sed 's/[^,]*//g'` ccount=`echo ${EN} "$c${EC}" | wc -c` domath ccount "$ccount + 1" # 0==1 also, unfortunately c=`echo ${dcl} | sed 's/^[^(]*(//'` c=`echo ${c} | sed 's/)[^)]*$//'` echo "## c(E): ${c}" >&9 val=1 while test "${c}" != ""; do tmp=$c tmp=`echo ${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 echo ${tmp} | grep ' ' > /dev/null 2>&1 rc=$? if [ $rc -eq 0 ]; then tmp=`echo ${tmp} | sed -e 's/ *[A-Za-z0-9_]*$//'` fi dosubst tmp 'struct#' 'struct ' 'union#' 'union ' 'enum#' 'enum ' if [ $noconst = T ]; then tmp=`echo ${tmp} | sed -e 's/const *//'` fi echo "## tmp(F): ${tmp}" >&9 nm="_c_arg_${val}_${funcnm}" setdata ${_MKCONFIG_PREFIX} ${nm} "${tmp}" domath val "$val + 1" c=`echo ${c} | sed -e 's/^[^,]*//' -e 's/^[ ,]*//'` echo "## c(G): ${c}" >&9 done c=`echo ${dcl} | sed -e 's/[ ]/ /g' \ -e "s/\([ \*]\)${funcnm}[ (].*/\1/" \ -e 's/^ *//' \ -e 's/ *$//'` echo "## c(T0): ${c}" >&9 if [ $noconst = T ]; then c=`echo ${c} | sed -e 's/const *//'` fi echo "## 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 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 # 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 printyesno $name $trc "$tag" setdata ${_MKCONFIG_PREFIX} ${name} ${trc} return $trc } check_class () { class=$2 shift;shift libs=$* nm="_class_${class}" dosubst nm '/' '_' ':' '_' otherlibs=${libs} 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 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_' '' echo "#define ${tname} ${val}" ;; _setstr_*|_opt_*|_cmd_loc_*) tname=$name dosubst tname '_setstr_' '' '_opt_' '' echo "#define ${tname} \"${val}\"" ;; _hdr_*|_sys_*|_command_*) echo "#define ${name} ${tval}" ;; *) # _c_arg, _c_type go here also echo "#define ${name} ${val}" ;; esac } new_output_file () { return 0 } di-4.34/mkconfig/bin/0000755000175000017500000000000012076642270012517 5ustar bllblldi-4.34/mkconfig/bin/mkcl.sh0000555000175000017500000001014512076642270014003 0ustar bllbll#!/bin/sh # # $Id: mkcl.sh,v 1.11 2012-10-19 12:09:46-07 bll Exp $ # # Copyright 2010-2012 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 } doecho=F comp=${CC} reqlibfile= c=T d=F while test $# -gt 0; do case $1 in -c) shift comp=$1 shift case ${comp} in *gdc*|*ldc*|*dmd*) d=T c=F ;; esac ;; -e) doecho=T shift ;; -o) shift outfile=$1 shift ;; -r) shift reqlibfile=$1 shift ;; --) shift break ;; *) break ;; esac done # 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 files= objects= libnames= libpathnames= islib=0 ispath=0 olibs= componly=F havesource=F if [ "$reqlibfile" != "" ]; then olibs=`cat $reqlibfile` fi grc=0 for f in $@ $olibs; do case $f in "-L") ispath=1 ;; "-L"*) tf=$f dosubst tf '-L' '' if [ ! -d "$tf" ]; then echo "## 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 echo "## unable to locate $f" grc=1 else doappend objects " $f" fi ;; *.c|*.d) if [ ! -f "$f" ]; then echo "## unable to locate $f" grc=1 else doappend files " $f" havesource=T fi ;; "-"*) doappend flags " $f" if [ $f = "-c" ]; then componly=T fi ;; *) if [ $islib -eq 1 ]; then addlib "-l$f" elif [ $ispath -eq 1 ]; then if [ ! -d "$f" ]; then echo "## 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 '^:' '' if [ "$outfile" = "" ]; then flags="${flags} -c" componly=T else case ${outfile} in *.o|*.obj) flags="${flags} -c" componly=T ;; esac fi shrunpath= shlibpath= shexeclink= ldflags= if [ $componly = F ]; then shrunpath="" if [ "${libs}" != "" -a "${SHRUNPATH}" != "" ]; then dosubst libpath '^:' '' shrunpath="${SHRUNPATH}${libpath}" fi shlibpath="" if [ "${libs}" != "" -a "${libpath}" != "" ]; then shlibpath="${DC_LINK}-L${libpath}" fi shexeclink="" if [ "${SHEXECLINK}" != "" ]; then shexeclink="${SHEXECLINK}" fi if [ "${DC_LINK}" != "" ]; then ldflags="" for flag in ${LDFLAGS}; do doappend ldflags " ${DC_LINK}${flag}" done else doappend ldflags " ${LDFLAGS}" fi fi allflags= if [ $havesource = T ]; then if [ $c = T ];then doappend allflags " ${CPPFLAGS}" doappend allflags " ${CFLAGS}" doappend allflags " ${SHCFLAGS}" fi if [ $d = T ];then doappend allflags " ${DFLAGS}" fi fi cmd="${comp} ${allflags} ${flags} ${ldflags} ${shexeclink} \ ${OUTFLAG}$outfile $objects \ ${files} ${shrunpath} ${shlibpath} $libs" if [ $doecho = T ]; then echo $cmd fi eval $cmd rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi exit $grc di-4.34/mkconfig/bin/mkstaticlib.sh0000555000175000017500000000264512076642270015371 0ustar bllbll#!/bin/sh # # $Id: mkstaticlib.sh,v 1.6 2012-01-18 14:23:51-08 bll Exp $ # # Copyright 2010-2012 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 for f in $@; do case $f in "-e") doecho=T ;; "--") ;; *${OBJ_EXT}) if [ ! -f "$f" ]; then echo "## unable to locate $f" grc=1 else doappend objects " $f" fi ;; *) if [ "$libnm" = "" ]; then libnm=$f continue fi ;; esac done locatecmd ranlibcmd ranlib locatecmd arcmd ar locatecmd lordercmd lorder locatecmd tsortcmd tsort if [ "$arcmd" = "" ]; then echo "## Unable to locate 'ar' command" grc=1 fi if [ $grc -eq 0 ]; then dosubst libnm '${SHLIB_EXT}$' '' '^lib' '' libfnm=lib${libnm}.a # 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}" if [ $doecho = "T" ]; then echo $cmd fi eval $cmd rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi if [ "$ranlibcmd" != "" ]; then cmd="$ranlibcmd $libfnm" echo $cmd eval $cmd rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi fi fi exit $grc di-4.34/mkconfig/bin/mksharedlib.sh0000555000175000017500000000407212076642270015344 0ustar bllbll#!/bin/sh # # $Id: mksharedlib.sh,v 1.7 2012-01-18 14:23:49-08 bll Exp $ # # Copyright 2010-2012 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="" libs="" libpath="" islib=0 ispath=0 grc=0 doecho=F comp=${CC} for f in $@; do case $f in "-e") doecho=T ;; "-c") shift comp=$1 shift ;; "--") ;; "-L") ispath=1 ;; "-L"*) tf=$f dosubst tf '-L' '' if [ ! -d "$tf" ]; then echo "## unable to locate dir $tf" grc=1 else doappend libpath ":$tf" fi ;; "-l") islib=1 ;; "-l"*) tf=$f dosubst tf '-l' '' doappend libs " -l$tf" ;; *${OBJ_EXT}) if [ ! -f "$f" ]; then echo "## unable to locate $f" grc=1 else doappend objects " $f" fi ;; *) if [ "$libnm" = "" ]; then libnm=$f continue fi if [ $islib -eq 1 ]; then doappend libs " -l$f" fi if [ $ispath -eq 1 ]; then if [ ! -d "$f" ]; then echo "## unable to locate dir $f" grc=1 fi doappend libpath ":$f" fi islib=0 ispath=0 ;; esac done # not working #if [ "${SHLDNAMEFLAG}" != "" ]; then # SHLDFLAGS="${SHLDFLAGS} ${SHLDNAMEFLAG}${libnm}" #fi if [ $grc -eq 0 ]; then dosubst libnm '${SHLIB_EXT}$' '' '^lib' '' libfnm=lib${libnm}${SHLIB_EXT} shrunpath="" if [ "${libs}" != "" -a "${SHRUNPATH}" != "" ]; then shrunpath=${libpath} dosubst shrunpath '^:' "${SHRUNPATH}" fi shlibpath="" if [ "${libs}" != "" -a "${libpath}" != "" ]; then shlibpath=${libpath} dosubst shlibpath '^:' '-L' fi cmd="${comp} ${LDFLAGS} ${SHLDFLAGS} -o $libfnm ${shrunpath} ${shlibpath} ${objects} ${libs}" if [ "$doecho" = "T" ]; then echo $cmd fi eval $cmd rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi fi exit $grc di-4.34/mkconfig/bin/mkcsetopt.sh0000555000175000017500000000156612076642270015075 0ustar bllbll#!/bin/sh # # $Id: mkcsetopt.sh,v 1.7 2012-01-18 14:23:42-08 bll Exp $ # # Copyright 2010-2012 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.34/mkconfig/bin/mkreqlib.sh0000555000175000017500000000411312076642270014661 0ustar bllbll#!/bin/sh # # $Id: mkreqlib.sh,v 1.23 2012-01-18 14:23:44-08 bll Exp $ # # Copyright 2009-2012 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.34/mkconfig/bin/shellfuncs.sh0000555000175000017500000001776712076642270015244 0ustar bllbll#!/bin/sh # # $Id: shellfuncs.sh,v 1.92 2012-10-19 12:09:57-07 bll Exp $ # $Revision: 1.92 $ # # Copyright 2010-2012 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}" } setechovars () { EN='-n' EC='' if [ "`echo -n test`" = "-n test" ]; then EN='' EC='\c' fi export EN export EC } 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_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_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 TMP=chksh$$ 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.34/mkconfig/bin/testfuncs.sh0000555000175000017500000000570312076642270015077 0ustar bllbll#!/bin/sh # # $Id: testfuncs.sh,v 1.9 2012-01-23 18:23:56-08 bll Exp $ # $Revision: 1.9 $ # # Copyright 2011-2012 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 ${EN} " no C compiler; skipped${EC}" >&5 exit 0 fi } chkdcompiler () { if [ "${DC}" = "" ]; then echo ${EN} " no D compiler; skipped${EC}" >&5 exit 0 fi } getsname () { tsnm=$1 tsnm=`echo $tsnm | sed -e 's,.*/,,' -e 's,\.sh$,,'` scriptnm=${tsnm} } dosetup () { grc=0 stag=$1 shift 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 ${CPPFLAGS} ${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.34/mkconfig/features/0000755000175000017500000000000012076642270013565 5ustar bllblldi-4.34/mkconfig/features/checktests.dat0000444000175000017500000000157612076642270016426 0ustar bllblloutput none command awk nawk mawk gawk command cat command chmod command date command diff command grep command ls command mkdir command mv command perl command pwd command rm command sed command sleep command sort command tail command uname command wc setint test_commands 0 if test_cmds _command_awk && _command_cat && _command_chmod && \ _command_date && _command_diff && _command_grep && _command_ls && \ _command_mkdir && _command_mv && _command_perl && _command_pwd && \ _command_rm && _command_sed && _command_sleep && \ _command_sort && _command_tail && _command_uname && _command_wc setint test_commands 1 endif if chk_test_cmds ! _setint_test_commands echo echo ** ERROR: mkconfig tests requires the following commands: echo ** awk, cat, chmod, date, diff, grep, ls, mkdir, mv, perl, pwd echo ** rm, sed, sleep, sort, tail, uname and wc echo exit endif di-4.34/mkconfig/runtests.sh0000555000175000017500000002731712076642270014205 0ustar bllbll#!/bin/sh # # $Id: runtests.sh,v 1.79 2012-10-19 12:11:40-07 bll Exp $ # $Source: /home/bll/DI/di/mkconfig/RCS/runtests.sh,v $ # # Copyright 1994-2010 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 echo ${EN} " check $s${EC}" >&8 echo ${EN} " $s${EC}" 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 echo ${EN} " ${dispshell}${EC}" 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 echo ${EN} "*${EC}" 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 setechovars 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="" echo ${EN} "$tbase ...${EC}" echo ${EN} "$tbase ...${EC}" >&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` echo ${EN} " ${tfdisp}${EC}" echo ${EN} " ${tfdisp}${EC}" >&8 $_MKCONFIG_RUNTESTDIR/$tf -q runshpl=$? if [ $runshpl -eq $_MKC_SH -o $runshpl -eq $_MKC_SH_PL ]; then echo ${EN} " ...${EC}" echo ${EN} " ...${EC}" >&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 echo ${EN} "$tbase ...${EC}" echo ${EN} "$tbase ...${EC}" >&8 echo ${EN} " ${tfdisp}${EC}" echo ${EN} " ${tfdisp}${EC}" >&8 echo ${EN} " ... perl${EC}" echo ${EN} " ... perl${EC}" >&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.34/mkconfig/LICENSE0000444000175000017500000000157412076642270012761 0ustar bllbll Copyright 2010-2012 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.34/mkconfig/mkconfig.pl0000555000175000017500000013310312076642270014103 0ustar bllbll#!/usr/bin/perl # # $Id: mkconfig.pl,v 1.110 2012-11-10 18:57:50-08 bll Exp $ # # Copyright 2006-2010 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 $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 print_headers { my ($r_a, $r_clist, $r_config) = @_; 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"; } } } 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); 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) = @_; my $cmd = "$ENV{'CC'} $ENV{'CFLAGS'} $ENV{'CPPFLAGS'} "; 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); print CCFH $hdrs; print CCFH $code; close CCFH; my $cmd = "$ENV{'CC'} $ENV{'CFLAGS'} $ENV{'CPPFLAGS'} "; 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); print CCFH $hdrs; print CCFH $code; close CCFH; my $cmd = "$ENV{'CC'} $ENV{'CFLAGS'} $ENV{'CPPFLAGS'} -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 = 'F'; 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 = 'T'; } if ($trc eq 'enable') { $trc = 'T'; } if ($trc eq 'f') { $trc = 'F'; } if ($trc eq 'disable') { $trc = 'F'; } if ($trc eq 'true') { $trc = 'T'; } if ($trc eq 'false') { $trc = 'F'; } } if ($trc eq 'T') { $trc = 1; } if ($trc eq 'F') { $trc = 0; } if ($type eq 'ifnotoption') { $trc = $trc == 0 ? 1 : 0; } if (! $optionsloaded) { $trc = 0; printyesno_actual $name, "no options file"; } elsif ($found eq 'F') { $trc = 0; 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/\|\|/ || /og; $ifline =~ s/ and / && /og; $ifline =~ s/ or / || /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_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 __attribute__(a) #define __nonnull__(a,b) #define __restrict #define __restrict__ #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]/ /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) { $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 __INC_${CONFHTAGUC}_H #define __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_'; #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 _HERE_ print CCOFH $include; print CCOFH <<"_HERE_"; #endif /* __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*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'}; print LOGFH "CC: $ENV{'CC'}\n"; print LOGFH "CFLAGS: $ENV{'CFLAGS'}\n"; print LOGFH "CPPFLAGS: $ENV{'CPPFLAGS'}\n"; print LOGFH "LDFLAGS: $ENV{'LDFLAGS'}\n"; print LOGFH "LIBS: $ENV{'LIBS'}\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.34/mkconfig/util/0000755000175000017500000000000012076642270012724 5ustar bllblldi-4.34/mkconfig/util/mkcexttypedef.awk0000555000175000017500000000232312076642270016305 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2012 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.34/mkconfig/util/mkcextstruct.awk0000555000175000017500000001732412076642270016200 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2012 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.34/mkconfig/util/mktar.sh0000555000175000017500000000062712076642270014404 0ustar bllbll#!/bin/sh ver=`cat VERSION` PKG=mkconfig 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 chmod -R a+r ${dir} tar cf - ${dir} | gzip -9 > ${dir}.tar.gz rm -rf ${dir} > /dev/null 2>&1 exit 0 di-4.34/mkconfig/util/mkcextmacro.awk0000555000175000017500000000702312076642270015750 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2012 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.34/mkconfig/util/mkcextdcl.awk0000555000175000017500000000325312076642270015412 0ustar bllbll#!/usr/bin/awk # # Copyright 2010-2012 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.34/mkconfig/tests.d/0000755000175000017500000000000012076642270013333 5ustar bllblldi-4.34/mkconfig/tests.d/command.sh0000555000175000017500000000110212076642270015300 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 command maindoquery $1 $_MKC_SH_PL getsname $0 dosetup $@ dorunmkc chkouth '^#define _command_xblah 0$' chkouth '^#define _command_sed 1$' chkouth '^#define _cmd_loc_sed "/.*/sed"$' chkouth '^#define _command_grep 1$' chkouth '^#define _cmd_loc_grep "/.*/grep"$' chkouth '^#define _command_awk 1$' chkouth '^#define _cmd_loc_awk "/.*/grep"$' chkcache "^mkc_c__command_xblah='0'$" chkcache "^mkc_c__command_awk='1'$" chkcache "^mkc_c__command_grep='1'$" chkcache "^mkc_c__command_sed='1'$" testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/0000755000175000017500000000000012076642270013777 5ustar bllblldi-4.34/mkconfig/tests.d/c.d/c-set.sh0000555000175000017500000000105012076642270015343 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 set maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _define_EOF 0$" chkouth "^#define _lib_something" neg chkouth "^#define _test1 1$" wc 1 chkouth "^#define _test2 \"a b c\"$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-keyword.dat0000444000175000017500000000007112076642270016371 0ustar bllblloutput out.h loadunit c-main standard key long key xyzzy di-4.34/mkconfig/tests.d/c.d/c-const.dat0000444000175000017500000000013212076642270016031 0ustar bllblloutput out.h loadunit c-main standard sys types.h hdr fcntl.h hdr unistd.h const O_RDONLY di-4.34/mkconfig/tests.d/c.d/c-nooption.dat0000444000175000017500000000031412076642270016552 0ustar bllbll# test when no options file output out.h option-file opts loadunit c-main standard setint _test_a 0 setint _test_b 0 ifoption TEST_A setint _test_a 1 endif ifnotoption TEST_B setint _test_b 1 endif di-4.34/mkconfig/tests.d/c.d/c-size.dat0000444000175000017500000000006012076642270015655 0ustar bllblloutput out.h loadunit c-main standard size long di-4.34/mkconfig/tests.d/c.d/c-option.sh0000555000175000017500000000116212076642270016064 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 option maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ TMP=opts > $TMP echo ' TEST_OPT_SET=abc123 TEST_OPT_SET_SPACE=abc 123 ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define TEST_OPT_DEF \"default\"$" chkouth "^#define TEST_OPT_SET \"abc123\"$" chkouth "^#define TEST_OPT_SET_SPACE \"abc 123\"$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-mkexeclibsh.sh0000555000175000017500000000426012076642270017054 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'create exec with shared libs' maindoquery $1 $_MKC_SH chkccompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` -C $_MKCONFIG_RUNTESTDIR/c-shared.env.dat . ./c.env if [ "${_MKCONFIG_SYSTYPE}" = "BSD" ]; then echo ${EN} " bsd; skipped${EC}" >&5 exit 0 fi if [ "${_MKCONFIG_USING_GCC}" = "N" -a \ "${_MKCONFIG_SYSTYPE}" = "HP-UX" ]; then ${CC} -v 2>&1 | grep 'Bundled' rc=$? if [ $rc -eq 0 ]; then echo ${EN} " bundled cc; skipped${EC}" >&5 exit 0 fi fi for i in 1 2 3 4; do > mkct${i}.c echo " #include #include int mkct${i} () { return ${i}; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -o mkct${i}${OBJ_EXT} -e mkct${i}.c done i=5 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct1 _((void)); extern int mkct2 _((void)); extern int mkct3 _((void)); extern int mkct4 _((void)); int mkct${i} () { int i; i = 0; i += mkct1(); i += mkct2(); i += mkct3(); i += mkct4(); return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=6 > mkct${i}.c echo ' #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct5 _((void)); main () { int i, j; i = mkct5(); j = 1; if (i == 10) { j = 0; } return j; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c grc=0 set +f ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct mkct[51234]${OBJ_EXT} set -f rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -link -e -c ${CC} \ -o mkct6a.exe -- mkct6${OBJ_EXT} -L. -lmkct rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ./mkct6a.exe rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi testcleanup mkct6a.exe mkct1.o mkct2.o mkct3.o mkct4.o mkct5.o mkct6.o \ mkct1.c mkct2.c mkct3.c mkct4.c mkct5.c mkct6.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-args.sh0000555000175000017500000000776512076642270015527 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 arguments maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > cargshdr.h echo ' #ifndef _INC_cargshdr_H_ #define _INC_cargshdr_H_ /* modified from linux sys/statvfs.h */ # if __GNUC__ # define __THROW extern int a (__const char *__restrict __file, long *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))); # endif int b (int); extern int c (long); extern int d (int, int, char *); extern int e (char **, int *); extern int f (int, char * const [], const char *); extern char *g (const char *); # if __GNUC__ extern int h (__const char *__restrict __file, long *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))); extern char *i (__const char *__domainname, __const char *__dirname) __THROW; extern char *j (__const char *__domainname, __const char *__dirname) __THROW; # endif extern int k (int, int, char *); extern int l (int, int); extern int m (int); extern int n (int, int, char *, int); # if __GNUC__ extern int o (int, int, char *, int) __asm__ ("" "o"); # endif /* w/var names */ extern char *p (int a, int b, char *c, int d); /* w/var names and lots of spaces */ extern int q ( int a , int b , char * c , int d ); /* w/no var names and lots of spaces */ extern int r ( int , int , char * , int ); /* struct names */ struct x_t { int a; }; union y_t { int a; int b; }; extern int s ( struct x_t x , union y_t y , char * , int ); #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env if [ "${_MKCONFIG_SYSTYPE}" = "BSD" ]; then echo ${EN} " bsd; skipped${EC}" >&5 exit 0 fi if [ "${_MKCONFIG_USING_GCC}" = "N" -a \ "${_MKCONFIG_SYSTYPE}" = "HP-UX" ]; then ${CC} -v 2>&1 | grep 'Bundled' rc=$? if [ $rc -eq 0 ]; then echo ${EN} " bundled cc; skipped${EC}" >&5 exit 0 fi fi dorunmkc if [ "${_MKCONFIG_USING_GCC}" = "Y" ]; then set 2 2 2 2 4 for x in a h i j o; do val=$1 shift chkouth "^#define _args_${x} ${val}$" done # int check set 1 2 4 for x in o o o; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} int$" done # char * check set 1 1 1 2 1 2 3 for x in a h i i j j o; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} char \*$" done # long * check set 2 2 for x in a h; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} long \*$" done # int type check for x in a h o; do chkouth "^#define _c_type_${x} int$" done # char * type check for x in i j; do chkouth "^#define _c_type_${x} char \*$" done fi # arguments set 1 1 3 2 3 1 3 2 1 4 4 4 4 4 for x in b c d e f g k l m n p q r s; do val=$1 shift chkouth "^#define _args_${x} ${val}$" done # int check set 1 1 2 1 1 2 1 2 1 1 2 4 1 2 4 1 2 4 1 2 4 4 for x in b d d f k k l l m n n n p p p q q q r r r s; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} int$" done # long check set 1 for x in c; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} long$" done # 'char *' check set 3 3 1 3 3 3 3 3 3 for x in d f g k n p q r s; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} char \*$" done # 'char **' check set 1 for x in e; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} char \*\*$" done # 'char * []' check set 2 for x in f; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} char \* \[\]$" done # 'struct x_t' check set 1 for x in s; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} struct x_t$" done # 'union y_t' check set 2 for x in s; do val=$1 shift chkouth "^#define _c_arg_${val}_${x} union y_t$" done # int type check for x in b c d e k l m n q r s; do chkouth "^#define _c_type_${x} int$" done # char * type check for x in g p; do chkouth "^#define _c_type_${x} char \*$" done chkouthcompile testcleanup cargs.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-substitute.sh0000555000175000017500000000105412076642270016767 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 substitute maindoquery $1 $_MKC_SH chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _define_EOF 0$" chkouth "^#define _lib_something" neg chkouth "^#define _testA 1$" wc 1 chkouth "^#define _test2 \"d e f\"$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-multlib.reqlibs0000444000175000017500000000002612076642270017246 0ustar bllbll-ltst2libb -ltst2libc di-4.34/mkconfig/tests.d/c.d/c-option.dat0000444000175000017500000000022212076642270016213 0ustar bllblloutput out.h option-file opts loadunit c-main standard option TEST_OPT_DEF default option TEST_OPT_SET default option TEST_OPT_SET_SPACE default di-4.34/mkconfig/tests.d/c.d/c-mksharedlib.sh0000555000175000017500000000436612076642270017052 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'create shared library' maindoquery $1 $_MKC_SH chkccompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` -C $_MKCONFIG_RUNTESTDIR/c-shared.env.dat . ./c.env if [ "${_MKCONFIG_SYSTYPE}" = "BSD" ]; then echo ${EN} " bsd; skipped${EC}" >&5 exit 0 fi if [ "${_MKCONFIG_USING_GCC}" = "N" -a \ "${_MKCONFIG_SYSTYPE}" = "HP-UX" ]; then ${CC} -v 2>&1 | grep 'Bundled' rc=$? if [ $rc -eq 0 ]; then echo ${EN} " bundled cc; skipped${EC}" >&5 exit 0 fi fi for i in 1 2 3 4; do > mkct${i}.c echo " #include #include int mkct${i} () { return ${i}; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c done i=5 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct1 _((void)); extern int mkct2 _((void)); extern int mkct3 _((void)); extern int mkct4 _((void)); int mkct${i} () { int i; i = 0; i += mkct1(); i += mkct2(); i += mkct3(); i += mkct4(); return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=6 > mkct${i}.c echo ' #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct5 _((void)); main () { int i, j; i = mkct5(); j = 1; if (i == 10) { j = 0; } return j; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c grc=0 set +f ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct mkct[51234]${OBJ_EXT} set -f rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -link -e -c ${CC} \ -o mkct6a${EXE_EXT} mkct6${OBJ_EXT} -L. -lmkct rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ./mkct6a${EXE_EXT} rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi testcleanup mkct6a${EXE_EXT} \ mkct1${OBJ_EXT} mkct2${OBJ_EXT} mkct3${OBJ_EXT} \ mkct4${OBJ_EXT} mkct5${OBJ_EXT} mkct6${OBJ_EXT} \ mkct1.c mkct2.c mkct3.c mkct4.c mkct5.c mkct6.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-compiler.sh0000555000175000017500000000071112076642270016365 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'C compiler works' maindoquery $1 $_MKC_ONCE chkccompiler getsname $0 dosetup $@ > c_compiler.c echo ' main () { exit (0); } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp \ -e -o c_compiler.exe c_compiler.c rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi if [ ! -x c_compiler.exe ]; then grc=1; fi ./c_compiler.exe rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-singlelib.sh0000555000175000017500000000236212076642270016527 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'w/single lib' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > tst1lib.h echo ' #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int tst1lib (); ' > tst1lib.c echo ' #include #include #include int tst1lib () { printf ("hello world\\n"); return 0; } ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o tst1lib${OBJ_EXT} tst1lib.c if [ $? -ne 0 ]; then echo "compile tst1lib.c failed" exit 1 fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` \ -staticlib libtst1lib tst1lib${OBJ_EXT} dorunmkc reqlibs out.h chkouthcompile sed -e '/^#define _key_/d' \ -e '/^#define _proto_/d' \ -e '/^#define _param_/d' \ -e '/Created on: /,/Using: mkc/ d' \ out.h > out.h.n chkdiff c-singlelib.ctmp out.h.n chkdiff ${_MKCONFIG_RUNTESTDIR}/c-singlelib.reqlibs mkconfig.reqlibs testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-cache.dat0000444000175000017500000000044412076642270015754 0ustar bllbll# test mkconfig caching output out.h loadunit c-main standard hdr ctype.h hdr errno.h hdr fcntl.h hdr fshelp.h hdr getopt.h hdr kernel/fs_info.h hdr limits.h hdr libintl.h hdr locale.h hdr malloc.h hdr memory.h hdr mntent.h hdr mnttab.h di-4.34/mkconfig/tests.d/c.d/c-nooptfile.sh0000555000175000017500000000102412076642270016550 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'ifoption - no options file' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc for t in _test_a _test_b; do chkoutfile "^#define ${t} 0$" chkoutfile "^#define ${t} 1$" done chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-memberxdr.sh0000555000175000017500000000127412076642270016545 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 c-memberxdr maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > mxdr.h echo ' #ifndef _INC_mxdr_H #define _INC_mxdr_H typedef unsigned int uu_int; struct aa { uu_int bb; int cc; }; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth '^#define xdr_bb xdr_uu_int$' chkouth '^#define xdr_cc xdr_int$' for x in bb cc; do chkouth "^#define _memberxdr_aa_${x} 1$" done chkouthcompile testcleanup mxdr.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-substitute.dat0000444000175000017500000000031612076642270017122 0ustar bllbll# test set output out.h loadunit c-main standard define EOF set _define_EOF 0 set _lib_something 1 setint _test1 0 setint _test1 1 setstr _test2 a b c substitute 'a b c' 'd e f' substitute _test1 _testA di-4.34/mkconfig/tests.d/c.d/c-syshdr.dat0000444000175000017500000000006312076642270016222 0ustar bllblloutput out.h loadunit c-main standard sys types.h di-4.34/mkconfig/tests.d/c.d/c-size.sh0000555000175000017500000000103612076642270015526 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 size maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc v=`grep "^#define _siz_long [0-9]*$" out.h | sed 's/.* //'` grc=1 if [ "$v" != "" ]; then if [ $v -ge 4 ]; then grc=0 fi fi chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-memberxdr.dat0000444000175000017500000000012612076642270016673 0ustar bllblloutput out.h loadunit c-main standard hdr mxdr.h memberxdr aa bb memberxdr aa cc di-4.34/mkconfig/tests.d/c.d/c-syshdr.sh0000555000175000017500000000070412076642270016071 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'sys/ header' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _sys_types 1$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-include.sh0000555000175000017500000000055112076642270016200 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 include maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ dorunmkc sed -e '/^#define _key_/d' \ -e '/^#define _proto_/d' \ -e '/^#define _param_/d' \ -e '/Created on: /,/Using: mkc/ d' \ out.h > out.h.n chkdiff c-include.ctmp out.h.n testcleanup out.h.n exit $grc di-4.34/mkconfig/tests.d/c.d/c-multlib.sh0000555000175000017500000000266212076642270016232 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'w/multiple libs' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env > tst2libb.h echo ' extern int tst2libb (); ' > tst2libc.h echo ' extern int tst2libc (); ' > tst2libb.c echo ' #include #include #include #include int tst2libb () { tst2libc(); return 0; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o tst2libb${OBJ_EXT} tst2libb.c ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -staticlib -e \ libtst2libb tst2libb${OBJ_EXT} > tst2libc.c echo ' #include #include #include int tst2libc () { printf ("hello world\\n"); return 0; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o tst2libc${OBJ_EXT} tst2libc.c ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -staticlib -e \ libtst2libc tst2libc${OBJ_EXT} dorunmkc reqlibs out.h sed -e '/^#define _key_/d' \ -e '/^#define _proto_/d' \ -e '/^#define _param_/d' \ -e '/Created on: /,/Using: mkc/ d' \ out.h > out.h.n chkdiff c-multlib.ctmp out.h.n chkdiff ${_MKCONFIG_RUNTESTDIR}/c-multlib.reqlibs mkconfig.reqlibs testcleanup out.h.n exit $grc di-4.34/mkconfig/tests.d/c.d/c-declare.sh0000555000175000017500000000112112076642270016146 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 declare maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > dcltst.h echo ' int a; int *b; int *c; int d; ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _dcl_a 1$" chkoutfile "^#define _dcl_b 1$" chkoutfile "^#define _dcl_c [01]$" chkoutfile "^#define _dcl_d [01]$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-cache.sh0000555000175000017500000000253012076642270015617 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'build from cache' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ . $_MKCONFIG_DIR/bin/shellfuncs.sh testshcapability ccclear="-nc" ccache_count=1 # this has to be a unique variable if [ -f ${_MKCONFIG_RUNTMPDIR}/c-cache.out.h ]; then domath ccache_count "${ccache_count} + 1" fi while test -f out.h.${ccache_count}; do domath ccache_count "${ccache_count} + 1" done echo "ccc:${ccache_count}" dorunmkc ${ccclear} # cache creation if [ ${ccache_count} -eq 1 ]; then ccclear="" sed -e '/Created on:/d' out.h > ${_MKCONFIG_RUNTMPDIR}/c-cache.out.h cp -f mkconfig.cache ${_MKCONFIG_RUNTMPDIR}/c-cache.mkconfig_c.cache mv -f mkc_out_c.vars ${_MKCONFIG_RUNTMPDIR}/c-cache.mkc_out_c.vars # keep mkconfig.cache ${_MKCONFIG_SHELL} $0 $stag $script # re-run this script for this shell exit $? fi sed -e '/Created on:/d' out.h > out.h.${ccache_count} mv -f mkc_out_c.vars mkc_out_c.vars.${ccache_count} c=2 while test $c -lt $ccache_count; do chkdiff ${_MKCONFIG_RUNTMPDIR}/c-cache.out.h out.h.${c} chkdiff ${_MKCONFIG_RUNTMPDIR}/c-cache.mkc_out_c.vars mkc_out_c.vars.${c} domath c "$c + 1" done # reset cache cp -f ${_MKCONFIG_RUNTMPDIR}/c-cache.mkconfig_c.cache mkconfig_c.cache # keep mkc_out_c.cache mv -f mkconfig.log mkconfig.log.${ccache_count} exit $grc di-4.34/mkconfig/tests.d/c.d/c-singlelib.dat0000444000175000017500000000011212076642270016651 0ustar bllblloutput out.h loadunit c-main standard hdr tst1lib.h lib tst1lib -ltst1lib di-4.34/mkconfig/tests.d/c.d/c-args.dat0000444000175000017500000000052412076642270015644 0ustar bllblloutput out.h loadunit c-main standard hdr cargshdr.h args noconst a args noconst b args noconst c args noconst d args noconst e args noconst f args noconst g args noconst h args noconst i args noconst j args noconst k args noconst l args noconst m args noconst n args noconst o args noconst p args noconst q args noconst r args noconst s di-4.34/mkconfig/tests.d/c.d/c-mkexeclibst.sh0000555000175000017500000000365512076642270017077 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'create exec with static lib' maindoquery $1 $_MKC_SH chkccompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env for i in 1 2 3 4; do > mkct${i}.c echo " #include #include int mkct${i} () { return ${i}; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c done i=5 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct1 _((void)); extern int mkct2 _((void)); extern int mkct3 _((void)); extern int mkct4 _((void)); int mkct${i} () { int i; i = 0; i += mkct1(); i += mkct2(); i += mkct3(); i += mkct4(); return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=6 > mkct${i}.c echo ' #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct5 _((void)); main () { int i, j; i = mkct5(); j = 1; if (i == 10) { j = 0; } return j; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c grc=0 set +f ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -staticlib \ -e mkct mkct[51234]${OBJ_EXT} set -f rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -link -e -c ${CC} \ -o mkct6a.exe -- mkct6${OBJ_EXT} -L. -lmkct rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ./mkct6a.exe rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi testcleanup mkct6a.exe \ mkct1${OBJ_EXT} mkct2${OBJ_EXT} mkct3${OBJ_EXT} \ mkct4${OBJ_EXT} mkct5${OBJ_EXT} mkct6${OBJ_EXT} \ mkct1.c mkct2.c mkct3.c mkct4.c mkct5.c mkct6.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-incconflict.dat0000444000175000017500000000026412076642270017204 0ustar bllblloutput out.h loadunit c-main loadunit c-include-conflict hdr incconf1.h hdr incconf2.h hdr incconf3.h include_conflict incconf1.h incconf2.h include_conflict incconf1.h incconf3.h di-4.34/mkconfig/tests.d/c.d/c.env.dat0000444000175000017500000000027512076642270015504 0ustar bllbllloadunit env-main loadunit env-systype loadunit env-extension loadunit env-cc output c.env system type system rev system arch extension obj extension exe cc using_gcc cflags ldflags libs di-4.34/mkconfig/tests.d/c.d/c-ifoption.dat0000444000175000017500000000310012076642270016530 0ustar bllbll# test ifoption, ifnotoption output out.h option-file opts loadunit c-main standard setint _test_enable 0 setint _test_disable 0 setint _test_assign_t 0 setint _test_assign_f 0 setint _test_else_enable 1 setint _test_else_disable 1 setint _test_else_assign_t 1 setint _test_else_assign_f 1 setint _test_neg_enable 1 setint _test_neg_disable 1 setint _test_neg_assign_t 1 setint _test_neg_assign_f 1 setint _test_else_neg_enable 0 setint _test_else_neg_disable 0 setint _test_else_neg_assign_t 0 setint _test_else_neg_assign_f 0 setint _test_h 1 setint _test_i 1 setint _test_j 1 ifoption TEST_ENABLE setint _test_enable 1 else setint _test_else_enable 0 endif setint _test_k 1 ifnotoption TEST_DISABLE setint _test_disable 1 else setint _test_else_disable 0 endif setint _test_l 1 ifoption TEST_ASSIGN_T setint _test_assign_t 1 else setint _test_else_assign_t 0 endif setint _test_m 1 ifnotoption TEST_ASSIGN_F setint _test_assign_f 1 else setint _test_else_assign_f 0 endif setint _test_n 1 # none of these setint statements in the if..option blocks should be active setint _test_a 1 setint _test_b 1 setint _test_c 1 ifnotoption TEST_ENABLE setint _test_neg_enable 0 else setint _test_else_neg_enable 1 endif setint _test_d 1 ifoption TEST_DISABLE setint _test_neg_disable 0 else setint _test_else_neg_disable 1 endif setint _test_e 1 ifnotoption TEST_ASSIGN_T setint _test_neg_assign_t 0 else setint _test_else_neg_assign_t 1 endif setint _test_f 1 ifoption TEST_ASSIGN_F setint _test_neg_assign_f 0 else setint _test_else_neg_assign_f 1 endif setint _test_g 1 di-4.34/mkconfig/tests.d/c.d/c-incconflict.sh0000555000175000017500000000211212076642270017043 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'include conflict' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > incconf1.h echo ' #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int incconf1 (); ' > incconf2.h echo ' #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern char *incconf1 (); ' > incconf3.h echo ' #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int incconf1 (); ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _inc_conflict__hdr_incconf1__hdr_incconf2 0$" chkouth "^#define _inc_conflict__hdr_incconf1__hdr_incconf3 1$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-mkshlibmult.sh0000555000175000017500000000773412076642270017122 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'create shared libs w/deps' maindoquery $1 $_MKC_SH chkccompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` -C $_MKCONFIG_RUNTESTDIR/c-shared.env.dat . ./c.env if [ "${_MKCONFIG_SYSTYPE}" = "BSD" ]; then echo ${EN} " bsd; skipped${EC}" >&5 exit 0 fi if [ "${_MKCONFIG_USING_GCC}" = "N" -a \ "${_MKCONFIG_SYSTYPE}" = "HP-UX" ]; then ${CC} -v 2>&1 | grep 'Bundled' rc=$? if [ $rc -eq 0 ]; then echo ${EN} " bundled cc; skipped${EC}" >&5 exit 0 fi fi i=1 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif int mkct${i} () { return 1; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=2 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct1 _((void)); int mkct${i} () { int i; i = 0; i += mkct1(); i += 2; return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=3 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct2 _((void)); int mkct${i} () { int i; i = 0; i += mkct2(); i += 3; return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=4 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct3 _((void)); int mkct${i} () { int i; i = 0; i += mkct3(); i += 4; return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=5 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct4 _((void)); int mkct${i} () { int i; i = 0; i += mkct4(); return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} -- mkct${i}.c i=6 > mkct${i}.c echo ' #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct5 _((void)); main () { int i, j; i = mkct5(); j = 1; if (i == 10) { j = 0; } return j; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c grc=0 ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct1 mkct1${OBJ_EXT} rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct2 mkct2${OBJ_EXT} -L. -lmkct1 rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct3 mkct3${OBJ_EXT} -L. -lmkct2 rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct4 mkct4${OBJ_EXT} -L. -lmkct3 rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -sharedlib \ -e mkct5 mkct5${OBJ_EXT} -L. -lmkct4 rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -link -e -c ${CC} \ -o mkct6a${EXE_EXT} -- mkct6${OBJ_EXT} -L. -lmkct5 eval $cmd rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ./mkct6a${EXE_EXT} rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi testcleanup mkct6a${EXE_EXT} \ mkct1${OBJ_EXT} mkct2${OBJ_EXT} mkct3${OBJ_EXT} \ mkct4${OBJ_EXT} mkct5${OBJ_EXT} mkct6${OBJ_EXT} \ mkct1.c mkct2.c mkct3.c mkct4.c mkct5.c mkct6.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-if.dat0000444000175000017500000000713612076642270015314 0ustar bllbll# test if output out.h loadunit c-main standard setint _var_a 1 setint _var_b 1 setint _var_c 0 setint _var_d 0 setint _test_b1_ok 0 setint _test_b2_ok 0 setint _test_b3_ok 0 setint _test_b4_ok 0 setint _test_b5_ok 0 setint _test_b6_ok 0 # basic if vara _setint__var_a setint _test_b1_ok 1 endif if notvarc ! _setint__var_c setint _test_b2_ok 1 endif if pvara ( _setint__var_a ) setint _test_b3_ok 1 endif if p2vara ((_setint__var_a)) setint _test_b4_ok 1 endif if unkvar ! (_setint__var_unk) setint _test_b5_ok 1 endif if unkvar2 (_setint__var_unk) setint _test_b6_ok 1 endif setint _test_a1_ok 0 setint _test_a2_ok 0 setint _test_a3_ok 0 setint _test_a4_ok 0 setint _test_a5_ok 0 # && if andab _setint__var_a && _setint__var_b setint _test_a1_ok 1 endif if pandab ( _setint__var_a && _setint__var_b ) setint _test_a2_ok 1 endif if p2andab ( _setint__var_a && ( _setint__var_b ) ) setint _test_a3_ok 1 endif if p3andab (_setint__var_a&&(_setint__var_b)) setint _test_a4_ok 1 endif if notpac ! ( _setint__var_a && _setint__var_c ) setint _test_a5_ok 1 endif setint _test_o1_ok 0 setint _test_o2_ok 0 setint _test_o3_ok 0 setint _test_o4_ok 0 setint _test_o5_ok 0 setint _test_o6_ok 0 # || if orab _setint__var_a || _setint__var_b setint _test_o1_ok 1 endif if orac _setint__var_a || _setint__var_c setint _test_o2_ok 1 endif if orca _setint__var_c || _setint__var_a setint _test_o3_ok 1 endif if porca ( _setint__var_c || _setint__var_a ) setint _test_o4_ok 1 endif if notpcd ! ( _setint__var_c || _setint__var_d ) setint _test_o5_ok 1 endif if notpcd2 !(_setint__var_c||_setint__var_d) setint _test_o6_ok 1 endif setint _test_m1_ok 0 setint _test_m2_ok 0 setint _test_m3_ok 0 setint _test_m4_ok 0 if andaorbc (_setint__var_a && (_setint__var_b||_setint__var_d)) setint _test_m1_ok 1 endif if notandcorbd !(_setint__var_c && (_setint__var_b||_setint__var_d)) setint _test_m2_ok 1 endif if andaorbcalpha (_setint__var_a and (_setint__var_b or _setint__var_d)) setint _test_m3_ok 1 endif if notandcorbdalpha ! (_setint__var_c and (_setint__var_b or _setint__var_d)) setint _test_m4_ok 1 endif # nested setint _test_n1_ok 1 setint _test_n2_ok 0 setint _test_n3_ok 0 setint _test_n4_ok 0 setint _test_n5_ok 0 if nvara _setint__var_a setint _test_n2_ok 1 if nvarb _setint__var_b setint _test_n3_ok 1 if nvarc _setint__var_c setint _test_n4_ok 0 else setint _test_n4_ok 1 if nvard _setint__var_d setint _test_n5_ok 0 else setint _test_n5_ok 1 endif endif else setint _test_n3_ok 0 endif else setint _test_n2_ok 0 endif setint _test_n6_ok 1 setint _test_nb1_ok 1 setint _test_nb2_ok 1 setint _test_nb3_ok 1 setint _test_nb4_ok 0 setint _test_nb5_ok 1 if nbvarc _setint__var_c setint _test_nb1_ok 0 if nbvara _setint__var_a setint _test_nb2_ok 0 else setint _test_nb3_ok 0 endif else setint _test_nb4_ok 1 endif setint _test_nb5_ok 1 setint _test_p1_ok 0 setint _test_p2_ok 0 setint _test_p3_ok 0 setint _test_p4_ok 0 setint _test_p5_ok 0 setint _test_p6_ok 0 setint _test_p7_ok 0 setstr _var_e abc setstr _var_f abc def setstr _var_g abc def ghi # == if eqa == _setint__var_a 1 setint _test_p1_ok 1 endif # == if noteqa ! == _setint__var_a 0 setint _test_p2_ok 1 endif # == if eqe == _setstr__var_e abc setint _test_p3_ok 1 endif # == if noteqe ! == _setstr__var_e def setint _test_p4_ok 1 endif # == if quote_eqf == _setstr__var_f 'abc def' setint _test_p5_ok 1 endif # == if quote_noteqf ! == _setstr__var_f 'abc' setint _test_p6_ok 1 endif # == if quote_eqg == _setstr__var_g 'abc def ghi' setint _test_p7_ok 1 endif di-4.34/mkconfig/tests.d/c.d/c-type.dat0000444000175000017500000000010112076642270015660 0ustar bllblloutput out.h loadunit c-main standard hdr typtst.h typ my_type_t di-4.34/mkconfig/tests.d/c.d/c-multlib.dat0000444000175000017500000000017712076642270016364 0ustar bllblloutput out.h loadunit c-main standard hdr tst2libb.h hdr tst2libc.h lib tst2libb -ltst2libb, -ltst2libc, -ltst2libb -ltst2libc di-4.34/mkconfig/tests.d/c.d/c-singlelib.config0000444000175000017500000000073412076642270017360 0ustar bllbll #ifndef __INC_OUT_H #define __INC_OUT_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _hdr_tst1lib 1 #define _lib_tst1lib 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 /* __INC_OUT_H */ di-4.34/mkconfig/tests.d/c.d/c-define.dat0000444000175000017500000000011112076642270016132 0ustar bllbll# test define output out.h loadunit c-main hdr deftst.h define MYDEFINE di-4.34/mkconfig/tests.d/c.d/c-singlelib.reqlibs0000444000175000017500000000001212076642270017541 0ustar bllbll-ltst1lib di-4.34/mkconfig/tests.d/c.d/c-ifoption.sh0000555000175000017500000000203612076642270016404 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 c-ifoption maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ TMP=opts > $TMP echo ' TEST_ENABLE=enable TEST_DISABLE=disable TEST_ASSIGN_T=t TEST_ASSIGN_F=f ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc for t in \ _test_enable _test_disable \ _test_assign_t _test_assign_f \ _test_else_enable _test_else_disable \ _test_else_assign_t _test_else_assign_f \ _test_neg_enable _test_neg_disable \ _test_neg_assign_t _test_neg_assign_f \ _test_else_neg_enable _test_else_neg_disable \ _test_else_neg_assign_t _test_else_neg_assign_f \ _test_a _test_b _test_c _test_d _test_e _test_f _test_g \ _test_h _test_i _test_j _test_k _test_l _test_m _test_n; do echo "chk: $t (1)" chkouth "^#define ${t} 1$" done chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-mkstaticlib.sh0000555000175000017500000000435412076642270017070 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'create static library' maindoquery $1 $_MKC_SH chkccompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env for i in 1 2 3 4; do > mkct${i}.c echo " #include #include int mkct${i} () { return ${i}; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c done i=5 > mkct${i}.c echo " #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct1 _((void)); extern int mkct2 _((void)); extern int mkct3 _((void)); extern int mkct4 _((void)); int mkct${i} () { int i; i = 0; i += mkct1(); i += mkct2(); i += mkct3(); i += mkct4(); return i; } " ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c i=6 > mkct${i}.c echo ' #include #include #if defined(__STDC__) || defined(__cplusplus) || defined(c_plusplus) # define _(x) x #else # define _(x) () # define void char #endif extern int mkct5 _((void)); main () { int i, j; i = mkct5(); j = 1; if (i == 10) { j = 0; } return j; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -e -o mkct${i}${OBJ_EXT} mkct${i}.c grc=0 set +f ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -staticlib \ -e mkct mkct[51234]${OBJ_EXT} set -f rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ar t libmkct.a rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -link -e -c ${CC} \ -o mkct6a${EXE_EXT} -- mkct6${OBJ_EXT} libmkct.a rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ./mkct6a${EXE_EXT} rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -link -e -c ${CC} \ -o mkct6b${EXE_EXT} -- mkct6${OBJ_EXT} -L. -lmkct rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi ./mkct6b${EXE_EXT} rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi testcleanup mkct6a${EXE_EXT} mkct6b${EXE_EXT} \ mkct1${OBJ_EXT} mkct2${OBJ_EXT} mkct3${OBJ_EXT} \ mkct4${OBJ_EXT} mkct5${OBJ_EXT} mkct6${OBJ_EXT} \ mkct1.c mkct2.c mkct3.c mkct4.c mkct5.c mkct6.c exit $grc di-4.34/mkconfig/tests.d/c.d/c-npt.dat0000444000175000017500000000011312076642270015503 0ustar bllblloutput out.h loadunit c-main standard hdr nptlib.h npt npt1lib npt npt2lib di-4.34/mkconfig/tests.d/c.d/c-include.config0000444000175000017500000000124312076642270017027 0ustar bllbll #ifndef __INC_OUT_H #define __INC_OUT_H 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 /* test comment */ /* test comment 2 */ /* TEST 1 */ /* a \ b ' " ' " */ /* TEST 2 */ #if _lib_bindtextdomain && \ _lib_gettext && \ _lib_setlocale && \ _lib_textdomain && \ _hdr_libintl && \ _hdr_locale && \ (_command_msgfmt || _command_gmsgfmt) # define _enable_nls 1 #else # define _enable_nls 0 #endif #endif /* __INC_OUT_H */ di-4.34/mkconfig/tests.d/c.d/c-if.sh0000555000175000017500000000250012076642270015147 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 if maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc for t in \ _var_a _var_b \ _test_b1_ok _test_b2_ok _test_b3_ok _test_b4_ok _test_b5_ok \ _test_a1_ok _test_a2_ok _test_a3_ok _test_a4_ok _test_a5_ok \ _test_o1_ok _test_o2_ok _test_o3_ok _test_o4_ok \ _test_o5_ok _test_o6_ok \ _test_m1_ok _test_m2_ok _test_m3_ok _test_m4_ok \ _test_n1_ok _test_n2_ok _test_n3_ok _test_n4_ok \ _test_n5_ok _test_n6_ok \ _test_nb1_ok _test_nb2_ok _test_nb3_ok _test_nb4_ok _test_nb5_ok \ _test_p1_ok _test_p2_ok _test_p3_ok _test_p4_ok \ _test_p5_ok _test_p6_ok _test_p7_ok \ ; do echo "chk: $t (1)" chkouth "^#define ${t} 1$" done for t in _var_c _var_d _test_b6_ok; do echo "chk: $t (0)" chkouth "^#define ${t} 0$" done t=_var_e echo "chk: $t (abc)" chkouth "^#define ${t} \"abc\"$" t=_var_f echo "chk: $t (abc def)" chkouth "^#define ${t} \"abc def\"$" t=_var_g echo "chk: $t (abc def ghi)" chkouth "^#define ${t} \"abc def ghi\"$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-set.dat0000444000175000017500000000023212076642270015477 0ustar bllbll# test set output out.h loadunit c-main standard define EOF set _define_EOF 0 set _lib_something 1 setint _test1 0 setint _test1 1 setstr _test2 a b c di-4.34/mkconfig/tests.d/c.d/c-keyword.sh0000555000175000017500000000073612076642270016246 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 keyword maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _key_long 1$" chkouth "^#define _key_xyzzy 0$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-nooptfile.dat0000444000175000017500000000027312076642270016710 0ustar bllbll# test when no options file output out.h loadunit c-main standard setint _test_a 0 setint _test_b 0 ifoption TEST_A setint _test_a 1 endif ifnotoption TEST_B setint _test_b 1 endif di-4.34/mkconfig/tests.d/c.d/c-declare.dat0000444000175000017500000000013312076642270016303 0ustar bllblloutput out.h loadunit c-main standard hdr dcltst.h dcl int a dcl ptr b dcl int c dcl ptr d di-4.34/mkconfig/tests.d/c.d/c-header.sh0000555000175000017500000000073412076642270016010 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 header maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _sys_types 1$" chkouth "^#define _hdr_ctype 1$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-outfile.dat0000444000175000017500000000050512076642270016356 0ustar bllbllloadunit c-main output out1.h standard setint _test1 0 setint _test1 1 setstr _test2 a b c output out2.h standard setint _test3 0 setint _test3 2 setstr _test4 d e f output out3.h standard setint _test1 0 setint _test1 1 setstr _test2 a b c output out4.h standard setint _test3 0 setint _test3 2 setstr _test4 d e f di-4.34/mkconfig/tests.d/c.d/test_order0000444000175000017500000000060112076642270016067 0ustar bllbll1 c-compiler 2 c-outfile 3 c-option 3 c-set 3 c-substitute 4 c-if 6 c-ifoption 6 c-nooption 6 c-nooptfile 7 c-include 7 c-keyword 7 c-size 8 c-header 8 c-syshdr 9 c-args 9 c-const 9 c-declare 9 c-define 9 c-member 9 c-memberxdr 9 c-type 9 c-npt 9 c-incconflict 10 c-cache 11 c-singlelib 12 c-multlib 13 c-mkstaticlib 14 c-mkexeclibst 15 c-mksharedlib 16 c-mkexeclibsh 17 c-mkshlibmult di-4.34/mkconfig/tests.d/c.d/c-member.dat0000444000175000017500000000065012076642270016157 0ustar bllblloutput out.h loadunit c-main standard hdr memtst.h member my_struct_t a member my_struct_t b member my_struct_t c member my_struct_t d member my_struct_t e member my_struct_t f member my_struct_t g member my_union_t g member struct my_struct a member struct my_struct b member struct my_struct c member struct my_struct d member struct my_struct e member struct my_struct f member struct my_struct g member union my_union g di-4.34/mkconfig/tests.d/c.d/c-header.dat0000444000175000017500000000006312076642270016136 0ustar bllblloutput out.h loadunit c-main standard hdr ctype.h di-4.34/mkconfig/tests.d/c.d/c-npt.sh0000555000175000017500000000235312076642270015360 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'need prototype' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > nptlib.h echo ' #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 CPP_EXTERNS_BEG /* extern int npt1lib (); */ extern int npt2lib _((void)); CPP_EXTERNS_END ' > nptlib.c echo ' #include #include #include int npt1lib () { printf ("hello world\\n"); return 0; } int npt2lib () { printf ("hello world\\n"); return 0; } ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env chkccompile nptlib.c ar cq libnptlib.a nptlib.o dorunmkc chkouth "^#define _npt_npt1lib 1$" chkouth "^#define _npt_npt2lib 0$" chkouthcompile testcleanup nptlib.c nptlib.h libnptlib.a exit $grc di-4.34/mkconfig/tests.d/c.d/c-define.sh0000555000175000017500000000075212076642270016012 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 define maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > deftst.h echo ' #define MYDEFINE 20 ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _define_MYDEFINE 1$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-shared.env.dat0000444000175000017500000000044012076642270016742 0ustar bllbllloadunit env-main loadunit env-systype loadunit env-extension loadunit env-cc output c.env system type system rev system arch extension obj extension exe cc using_gcc cflags ldflags libs using_gnu_ld shcflags shldflags sharednameflag shareexeclinkflag sharerunpathflag extension shlib di-4.34/mkconfig/tests.d/c.d/c-nooption.sh0000555000175000017500000000115612076642270016424 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'ifoption - no option' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ TMP=opts > $TMP echo ' TEST_ENABLE=enable TEST_DISABLE=disable TEST_ASSIGN_T=t TEST_ASSIGN_F=f ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc for t in _test_a _test_b; do chkouth "^#define ${t} 0$" chkouth "^#define ${t} 1$" neg done chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-outfile.sh0000555000175000017500000000107112076642270016222 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'multiple output files' maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ dorunmkc for i in 1 2 3 4; do sed -e '/Created on:/d' -e "s/OUT${i}/OUT/" out${i}.h > out${i}.h.n done chkdiff out1.h.n out3.h.n chkdiff out2.h.n out4.h.n chkdiff mkc_out1_c.vars mkc_out3_c.vars chkdiff mkc_out2_c.vars mkc_out4_c.vars #testcleanup out1.h out2.h out3.h out4.h \ # out1.h.n out2.h.n out3.h.n out4.h.n \ # mkc_out1_c.vars mkc_out2_c.vars mkc_out3_c.vars mkc_out4_c.vars testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-multlib.config0000444000175000017500000000076612076642270017065 0ustar bllbll #ifndef __INC_OUT_H #define __INC_OUT_H 1 #define _hdr_stdio 1 #define _hdr_stdlib 1 #define _sys_types 1 #define _sys_param 1 #define _hdr_tst2libb 1 #define _hdr_tst2libc 1 #define _lib_tst2libb 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 /* __INC_OUT_H */ di-4.34/mkconfig/tests.d/c.d/c-const.sh0000555000175000017500000000067712076642270015714 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 const maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _const_O_RDONLY 1$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-type.sh0000555000175000017500000000075612076642270015545 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 typedef maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > typtst.h echo ' typedef int my_type_t; ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc chkouth "^#define _typ_my_type_t 1$" chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/c.d/c-include.dat0000444000175000017500000000071012076642270016330 0ustar bllbll# test mkconfig include quoting, backslashes, indentation, comments output out.h loadunit c-main include /* test comment */ /* test comment 2 */ /* TEST 1 */ /* a \\ b \' \" ' " */ /* TEST 2 */ #if _lib_bindtextdomain && \\ _lib_gettext && \\ _lib_setlocale && \\ _lib_textdomain && \\ _hdr_libintl && \\ _hdr_locale && \\ (_command_msgfmt || _command_gmsgfmt) # define _enable_nls 1 #else # define _enable_nls 0 #endif endinclude di-4.34/mkconfig/tests.d/c.d/c-member.sh0000555000175000017500000000200612076642270016021 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 member maindoquery $1 $_MKC_SH_PL chkccompiler getsname $0 dosetup $@ > memtst.h echo ' typedef struct xyzzy { int a; } xyzzy_t; typedef struct my_struct { int a; char *b; void *c; long d; long *e; xyzzy_t f; struct xyzzy g; } my_struct_t; typedef union my_union { int a; char *b; void *c; long d; long *e; xyzzy_t f; struct xyzzy g; } my_union_t; ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/c.env.dat . ./c.env dorunmkc for n in a b c d e f g; do chkouth "^#define _mem_my_struct_t_${n} 1$" chkouth "^#define _mem_struct_my_struct_${n} 1$" done for n in g; do chkouth "^#define _mem_my_union_t_${n} 1$" chkouth "^#define _mem_union_my_union_${n} 1$" done chkouthcompile testcleanup exit $grc di-4.34/mkconfig/tests.d/multword.sh0000555000175000017500000000043712076642270015551 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'output multiple words' maindoquery $1 $_MKC_SH getsname $0 dosetup $@ dorunmkc chkcache "^mkc_env_test_multword='word1 word2'$" chkenv '^test_multword="word1 word2"$' chkenv '^export test_multword$' testcleanup exit $grc di-4.34/mkconfig/tests.d/env.d/0000755000175000017500000000000012076642270014345 5ustar bllblldi-4.34/mkconfig/tests.d/env.d/env-set.sh0000555000175000017500000000031512076642270016262 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 set maindoquery $1 $_MKC_SH getsname $0 dosetup $@ dorunmkc chkenv "^_test1=\"1\"$" wc 1 chkenv "^_test2=\"a b c\"$" testcleanup exit $grc di-4.34/mkconfig/tests.d/env.d/env-source.sh0000555000175000017500000000053412076642270016772 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 source maindoquery $1 $_MKC_SH getsname $0 dosetup $@ > stest.sh echo ' COOKIE=oatmeal ' dorunmkc grc=1 if [ -f test.env ];then . ./test.env if [ "$COOKIE" = oatmeal ]; then grc=0 fi fi chkenv "^. /.*/stest.sh$" chkenv "^. /.*/stest-unk.sh$" neg testcleanup exit $grc di-4.34/mkconfig/tests.d/env.d/env-option.sh0000555000175000017500000000052212076642270016777 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 option maindoquery $1 $_MKC_SH getsname $0 dosetup $@ TMP=opts > $TMP echo ' TEST_OPT_SET=abc123 TEST_OPT_SET_SPACE=abc 123 ' dorunmkc chkenv "^TEST_OPT_DEF=\"default\"$" chkenv "^TEST_OPT_SET=\"abc123\"$" chkenv "^TEST_OPT_SET_SPACE=\"abc 123\"$" testcleanup exit $grc di-4.34/mkconfig/tests.d/env.d/env-set.dat0000444000175000017500000000015312076642270016415 0ustar bllbll# test set output test.env loadunit env-main standard setint _test1 0 setint _test1 1 setstr _test2 a b c di-4.34/mkconfig/tests.d/env.d/env-option.dat0000444000175000017500000000022712076642270017134 0ustar bllblloutput test.env option-file opts loadunit env-main standard option TEST_OPT_DEF default option TEST_OPT_SET default option TEST_OPT_SET_SPACE default di-4.34/mkconfig/tests.d/env.d/env-outfile.sh0000555000175000017500000000063112076642270017137 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'multiple output files' maindoquery $1 $_MKC_SH getsname $0 dosetup $@ dorunmkc for i in 1 2 3 4; do sed -e '/^# Created on:/d'test${i}.env > test${i}.env.n done chkdiff test1.env.n test3.env.n chkdiff test2.env.n test4.env.n chkdiff mkc_test1_env.vars mkc_test3_env.vars chkdiff mkc_test2_env.vars mkc_test4_env.vars testcleanup exit $grc di-4.34/mkconfig/tests.d/env.d/env-outfile.dat0000444000175000017500000000052212076642270017271 0ustar bllbllloadunit env-main output test1.env standard setint _test1 0 setint _test1 1 setstr _test2 a b c output test2.env standard setint _test3 0 setint _test3 2 setstr _test4 d e f output test3.env standard setint _test1 0 setint _test1 1 setstr _test2 a b c output test4.env standard setint _test3 0 setint _test3 2 setstr _test4 d e f di-4.34/mkconfig/tests.d/env.d/test_order0000444000175000017500000000006212076642270016436 0ustar bllbll1 env-outfile 2 env-option 2 env-set 2 env-source di-4.34/mkconfig/tests.d/env.d/env-source.dat0000444000175000017500000000021712076642270017123 0ustar bllbll# test set output test.env loadunit env-main standard source ${_MKCONFIG_TSTRUNTMPDIR}/stest.sh source ${_MKCONFIG_TSTRUNTMPDIR}/stest-unk.sh di-4.34/mkconfig/tests.d/grep.sh0000555000175000017500000000065112076642270014627 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 grep maindoquery $1 $_MKC_SH_PL getsname $0 dosetup $@ > ${_MKCONFIG_TSTRUNTMPDIR}/gfile echo ' test1a="blah" ' dorunmkc chkouth '^#define _grep_test1a 1$' chkouth '^#define _grep_test1b 0$' chkouth '^#define _grep_test1c 1$' chkcache "^mkc_c__grep_test1a='1'$" chkcache "^mkc_c__grep_test1b='0'$" chkcache "^mkc_c__grep_test1c='1'$" testcleanup exit $grc di-4.34/mkconfig/tests.d/compperl.sh0000555000175000017500000000043712076642270015515 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'compile perl scripts' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ # need globbing on. set +f cd $_MKCONFIG_DIR for i in *.pl; do perl -cw $i rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done testcleanup exit $grc di-4.34/mkconfig/tests.d/grep.dat0000444000175000017500000000016512076642270014762 0ustar bllblloutput out.h loadunit c-main grep test1a test1a ../gfile grep test1b test1b ../gfile grep test1c ^t.*1[ab] ../gfile di-4.34/mkconfig/tests.d/d.d/0000755000175000017500000000000012076642270014000 5ustar bllblldi-4.34/mkconfig/tests.d/d.d/d-set.dat0000444000175000017500000000017512076642270015507 0ustar bllbll# test set output out.d loadunit d-main standard set _lib_something 1 setint _test1 0 setint _test1 1 setstr _test2 a b c di-4.34/mkconfig/tests.d/d.d/d-multlib.reqlibs0000444000175000017500000000002012076642270017242 0ustar bllbll-lmlib1 -lmlib2 di-4.34/mkconfig/tests.d/d.d/d-member.sh0000555000175000017500000000132212076642270016023 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 member maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export DFLAGS LDFLAGS > memtst.d echo ' struct xyzzy { int a; } struct my_struct { int a; char * b; void * c; long d; long * e; xyzzy f; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc for n in a b c d e f; do chkoutd "^enum (: )?bool ({ )?_mem_my_struct_${n} = true( })?;$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-option.sh0000555000175000017500000000106612076642270016071 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 option maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ TMP=opts > $TMP echo ' TEST_OPT_SET=abc123 TEST_OPT_SET_SPACE=abc 123 ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^(enum )?string TEST_OPT_DEF = \"default\";$" chkoutd "^(enum )?string TEST_OPT_SET = \"abc123\";$" chkoutd "^(enum )?string TEST_OPT_SET_SPACE = \"abc 123\";$" if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-import.dat0000444000175000017500000000016712076642270016227 0ustar bllblloutput out.d loadunit d-main standard if hastangolib _d_tango_lib import tango.io.Stdout else import std.conv endif di-4.34/mkconfig/tests.d/d.d/d-cdefine.sh0000555000175000017500000000372312076642270016160 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-define' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > cdefine.h echo ' #ifndef _INC_CDEFINE_H_ #define _INC_CDEFINE_H_ #define a 1 #define b 2 #define d "d" #define e "abc" #define g 255 #define h 1024 #define i 0x255 #define j 0xa1bc #define k 00100 #define l 00200 #define pi 3.14159 #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^enum (: )?bool ({ )?_cdefine_a = true( })?;$" chkoutd "^enum (: )?int ({ )?a = 1( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_b = true( })?;$" chkoutd "^enum (: )?int ({ )?b = 2( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_c = false( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_d = true( })?;$" chkoutd "^(enum )?string d = \"d\"( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_e = true( })?;$" chkoutd "^(enum )?string e = \"abc\"( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_g = true( })?;$" chkoutd "^enum (: )?int ({ )?g = 0xff( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_h = true( })?;$" chkoutd "^enum (: )?int ({ )?h = 0x400( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_i = true( })?;$" chkoutd "^enum (: )?int ({ )?i = 0x255( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_j = true( })?;$" chkoutd "^enum (: )?int ({ )?j = 0xa1bc( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_k = true( })?;$" chkoutd "^enum (: )?int ({ )?k = 64( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_l = true( })?;$" chkoutd "^enum (: )?int ({ )?l = 128( })?;$" chkoutd "^enum (: )?bool ({ )?_cdefine_pi = true( })?;$" if [ "$DVERSION" = 1 ]; then chkoutd "^double pi = 3.14159;$" else chkoutd "^enum (: )?double ({ )?pi = 3.14159( })?;$" fi if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cstruct.dat0000444000175000017500000000150612076642270016402 0ustar bllblloutput out.d loadunit d-main standard csizes chdr cstructhdr.h cstruct sa cstruct sb cstruct sc cstruct sd cstruct se cstruct sf cstruct sg cstruct sh cstruct si cstruct sj cstruct sk cstruct sl cstruct sm cstruct sn cstruct so cstruct sp cstruct sq cstruct sr cstruct ss cstruct st cstruct su cstruct sv cstruct sw cstruct sx cstruct sy cstruct sz cstruct saa cstruct sbb cstruct scc cenum xdr_op cstruct sdd cstruct see cstruct SFF cstruct sgg cstruct shh cstruct sii cstruct sjj # inline nested structure isn't handled #cstruct skk cstruct sll cstruct smm cstruct snn cstruct _soo cstruct sppX cstruct spp cstruct sqq cunion ua cunion ub cunion uc cunion ud cunion ue cunion uf cunion ug cunion uh cunion ui cunion uj cunion uk cunion ul cunion um cunion un cunion uo cunion up cunion uq cunion ur cunion us cunion ut cunion uu di-4.34/mkconfig/tests.d/d.d/d-multlib.dat0000444000175000017500000000015612076642270016363 0ustar bllblloutput out.d loadunit d-main standard import mlib1 import mlib2 lib mlib1_f -lmlib1, -lmlib2, -lmlib1 -lmlib2 di-4.34/mkconfig/tests.d/d.d/d-module.sh0000555000175000017500000000054112076642270016043 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 module maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^module test.test;$" if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cmember.dat0000444000175000017500000000022312076642270016320 0ustar bllblloutput out.d loadunit d-main standard csizes chdr cmemhdr.h cstruct a cmember a d cmember a ld cmember a lli cmember a carr cmember a xyzzy di-4.34/mkconfig/tests.d/d.d/d-option.dat0000444000175000017500000000022312076642270016216 0ustar bllblloutput out.d option-file opts loadunit d-main standard option TEST_OPT_DEF default option TEST_OPT_SET default option TEST_OPT_SET_SPACE default di-4.34/mkconfig/tests.d/d.d/d-import.sh0000555000175000017500000000115212076642270016067 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 import maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc # check which library tangolib=`egrep "^enum (: )?bool ({ )?_d_tango_lib = " out.d | sed 's/.*= \([^ ;]*\).*/\1/'` if [ "$tangolib" = "false" ]; then chkoutd "^enum (: )?bool ({ )?_import_std_conv = true( })?;$" else chkoutd "^enum (: )?bool ({ )?_import_tango_io_Stdout = true( })?;$" fi if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cstruct.sh0000555000175000017500000001734612076642270016260 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-struct extraction' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > cstructhdr.h echo ' #ifndef _INC_cstructhdr_H_ #define _INC_cstructhdr_H_ struct sa { long double ld; double d; long long ll; signed long long sgll; long long int lli; signed long long int sglli; unsigned long long ull; unsigned long long int ulli; float f; long l; signed long sgl; unsigned long ul; long int li; signed long int sgli; unsigned long int uli; int i; signed int sgi; unsigned int ui; unsigned ui2; short s; signed short sgs; short int si; signed short int sgsi; unsigned short us; unsigned short int usi; char c; signed char sgc; unsigned char uc; char carr [20]; }; struct sb { long double b; float b1; double b2; long double b3; }; typedef struct { double c; } sc_t; typedef struct sd { float d; } sd_t; struct se { long long e; } ; struct sf { long f; }; /* this is here to confuse the extractor */ enum xdr_op { A = 1, B = 2, C = 3 }; extern void xdrmem_create(int *, const int, const int, const enum xdr_op); struct sg { // stuff int g; }; struct sh { /* stuff */ short h; }; struct si { char i; }; struct sj { int j; }; typedef struct sk { int k; } sk_t; typedef struct { int l; } sl_t; struct sm { int m; union { int a; long b; }; } m_t; struct { int n; union { int a; long b; }; int n2; } sn_t; /* forward dcl */ struct so; struct so { int o; }; /* forward dcl */ struct sp; /* forward dcl */ struct sq; struct sq { int q; struct sq *qq; }; /* named union */ struct sr { int r; union { int a; long b; } sr_named ; } sr_t; /* named struct */ struct ss { int s; struct { int a; long b; } ss_named ; } ss_t; typedef struct st { double t; } st_t; typedef struct { double u; } su_t; typedef struct sv { double c; } sv; /* anonymous struct */ struct sw { double c; struct sww { double d; } sw2; }; /* named struct */ struct sx { double c; struct sxx { double d; } _sxx; }; /* pointer to struct */ struct sy { double c; struct syy { double d; } * _syy; }; /* pointer to struct B */ struct sz { double c; struct szz { double d; } * _szz; }; /* named struct B */ struct saa { double c; struct saaa { double d; } _saaa; }; /* typedef named struct - from freebsd rpc/xdr.h (XDR) */ typedef struct sbb { int op; const struct __rpc_xdr { int (*x_getlong)(struct __rpc_xdr *, long *); int (*x_putlong)(struct __rpc_xdr *, const long *); void (*x_destroy)(struct __rpc_xdr *); } *x_ops; void *x_private; char *x_base; int x_handy; } tXDR; /* typedef named struct - from freebsd rpc/xdr.h (XDR) */ typedef struct _tscc { int op; const struct tscc { int (*x_getlong)(struct tscc *, long *); int *(*x_inline)(struct tscc *, int); void (*x_destroy)(struct tscc *); } *x_ops; void *x_private; char *x_base; int x_handy; } scc; /* modified from rpc/clnt.h: CLIENT */ struct sdd { long *cl_auth; struct clnt_ops { enum xdr_op (*cl_call) (struct sdd *, long, int, char *, int, char *, int); void (*cl_abort) (void); void (*cl_geterr) (struct sdd *, int *); int (*cl_freeres) (struct sdd *, long, char *); } *cl_ops; char *cl_private; }; /* uses struct name in functions */ typedef struct see { int op; struct see *next; struct seestuff { int (*x_getlong)(struct see *, long *); int (*x_putlong)(struct see *, const long *); void (*x_destroy)(struct see *); } *see_stuff; void *morestuff; } SEE; /* uses struct name in functions */ typedef struct __sff { int op; struct __sff *next; struct sffstuff { int (*x_getlong)(struct __sff *, long *); int (*x_putlong)(struct __sff *, const long *); void (*x_destroy)(struct __sff *); } *sff_stuff; void *moreffstuff; } SFF; /* typedef of struct; same name */ typedef struct sgg { double c; struct sgg1 { double d; } _sgg1; } sgg; /* typedef of struct; diff name; use struct name */ typedef struct shh { double c; struct shh1 { double d; } _shh1; } shh_t; /* typedef of struct; diff name; use typedef name */ typedef struct sii_s { double c; struct sii1 { double d; } _sii1; } sii; /* non-typedef same name */ struct sjj { double c; struct sjj1 { double d; } _sjj1; } sjj; struct skk { struct SKKB { int skka; } *skkb; }; typedef struct sllstuff_ *sllstuff; struct sll { int sll_a; int sll_b; }; struct smm { int smm_b; int *(*smm_a) (int *tablePtr, char *key); }; typedef struct snn { int snn_a; int (*private15)( struct snn* ); int snn_b; } snn; typedef struct { int *ext_data; int *private1; int fd; int private19; char *xdefaults; } *_soo; struct sppX { long sppXa; long sppXb; }; // bitfields with sizeof struct spp { int sppa; int sppb; int sppc; struct sppX sppd; unsigned int :(8 / 2) * (16 - (int)sizeof(struct sppX)); unsigned int :(8 / 2) * (16 - (int)sizeof(struct sppX)); }; struct sqq { int sqq1; int sqqa : 1; int sqqb : 3; int sqqc : 4; int sqq2; int sqqd : 4; int sqqe : 6; int sqqf : 6; int sqq3; }; union ua { long double ld; double d; long long ll; signed long long sgll; long long int lli; signed long long int sglli; unsigned long long ull; unsigned long long int ulli; float f; long l; signed long sgl; unsigned long ul; long int li; signed long int sgli; unsigned long int uli; int i; signed int sgi; unsigned int ui; short s; signed short sgs; short int si; signed short int sgsi; unsigned short us; unsigned short int usi; char c; signed char sgc; unsigned char uc; char carr [20]; }; union ub { long double b; float b1; double b2; long double b3; }; typedef union { double c; } uc_t; typedef union ud { float d; } ud_t; union ue { long long e; } ; union uf { long f; }; union ug { // stuff int g; }; union uh { /* stuff */ short h; }; union ui { char i; }; union uj { int j; }; typedef union uk { int k; } uk_t; typedef union { int l; } ul_t; union um { int m; union { int a; long b; }; } um_t; union { int n; union { int a; long b; }; int n2; } un_t; /* forward dcl */ union uo; union uo { int o; }; /* forward dcl */ union up; /* forward dcl */ union uq; union uq { int q; union uq *qq; }; /* named union */ union ur { int r; union { int a; long b; } ur_named ; } ur_t; /* named struct */ union us { int s; struct { int a; long b; } us_named ; } us_t; typedef union { double c; } ut; typedef union uu { double c; } uu; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc for x in sa sb sc sd se sf sg sh si sj sk sl sm sn so sq sr \ ss st su sv sw sx sy sz saa sbb scc sdd see SFF sgg \ shh sii sjj sll smm snn _soo sppX spp; do chkoutd "^enum (: )?bool ({ )?_cstruct_${x} = true( })?;$" done for x in sc_t sd_t sk_t sl_t st_t su_t sv tXDR scc SEE SFF sgg shh_t \ sii snn _soo uc_t ud_t uk_t ul_t ut uu; do chkoutd "^enum (: )?bool ({ )?_ctypedef_${x} = true( })?;$" done for x in sp; do chkoutd "^enum (: )?bool ({ )?_cstruct_${x} = false( })?;$" done for x in ua ub uc ud ue uf ug uh ui uj uk ul um un uo uq ur us ut uu; do chkoutd "^enum (: )?bool ({ )?_cunion_${x} = true( })?;$" done for x in up; do chkoutd "^enum (: )?bool ({ )?_cunion_${x} = false( })?;$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-singlelib.dat0000444000175000017500000000010712076642270016657 0ustar bllblloutput out.d loadunit d-main standard import slib1 lib slib1_f -lslib1 di-4.34/mkconfig/tests.d/d.d/d-set.sh0000555000175000017500000000104212076642270015346 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 set maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^enum (: )?bool ({ )?_lib_something" neg chkoutd "^enum (: )?int ({ )?_test1 = 1( })?;$" wc 1 if [ "$DVERSION" = 1 ]; then chkoutd "^string _test2 = \"a b c\";$" else chkoutd "^enum string _test2 = \"a b c\";$" fi if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-outfile.sh0000555000175000017500000000125112076642270016224 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'multiple output files' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc for i in 1 2 3 4; do sed -e '/^\/\/ Created on:/d' -e "s/OUT${i}/OUT/" out${i}.d > out${i}.d.n done chkdiff out1.d.n out3.d.n chkdiff out2.d.n out4.d.n chkdiff mkc_out1_d.vars mkc_out3_d.vars chkdiff mkc_out2_d.vars mkc_out4_d.vars #testcleanup out1.d out2.d out3.d out4.d \ # out1.d.n out2.d.n out3.d.n out4.d.n \ # mkc_out1_d.vars mkc_out2_d.vars mkc_out3_d.vars mkc_out4_d.vars testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-size.sh0000555000175000017500000000071212076642270015530 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 size maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc v=`egrep "^enum (: )?int ({ )?_siz_long = 8( })?;$" out.d | sed -e 's/.*= //' -e 's/[ }]*;$//'` grc=1 if [ "$v" = "8" ]; then grc=0 fi if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-outfile.dat0000444000175000017500000000050512076642270016360 0ustar bllbllloadunit d-main output out1.d standard setint _test1 0 setint _test1 1 setstr _test2 a b c output out2.d standard setint _test3 0 setint _test3 2 setstr _test4 d e f output out3.d standard setint _test1 0 setint _test1 1 setstr _test2 a b c output out4.d standard setint _test3 0 setint _test3 2 setstr _test4 d e f di-4.34/mkconfig/tests.d/d.d/d-cmember.sh0000555000175000017500000000247412076642270016177 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-member' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > cmemhdr.h echo ' #ifndef _INC_cmemhdr_H_ #define _INC_cmemhdr_H_ struct a { long double ld; double d; long long ll; signed long long sgll; long long int lli; signed long long int sglli; unsigned long long ull; unsigned long long int ulli; float f; long l; signed long sgl; unsigned long ul; long int li; signed long int sgli; unsigned long int uli; int i; signed int sgi; unsigned int ui; unsigned ui2; short s; signed short sgs; short int si; signed short int sgsi; unsigned short us; unsigned short int usi; char c; signed char sgc; unsigned char uc; char carr [20]; }; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc for x in d ld lli carr; do chkoutd "^enum (: )?bool ({ )?_cmem_a_${x} = true( })?;$" done for x in xyzzy; do chkoutd "^enum (: )?bool ({ )?_cmem_a_${x} = false( })?;$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-member.dat0000444000175000017500000000024612076642270016162 0ustar bllblloutput out.d loadunit d-main standard import memtst member my_struct a member my_struct b member my_struct c member my_struct d member my_struct e member my_struct f di-4.34/mkconfig/tests.d/d.d/d-noprefix.sh0000555000175000017500000000264012076642270016412 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 noprefix maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > noprefixhdr.h echo ' #ifndef _INC_NOPREFIXHDR_H_ #define _INC_NOPREFIXHDR_H_ struct b { int a; int b; }; #define T3(a,b,c) ((a)+(b)+(c)) union ub { long double b; float b1; double b2; long double b3; }; typedef enum { TCL_INT, TCL_DOUBLE, TCL_EITHER, TCL_WIDE_INT } Tcl_ValueType; typedef enum Tcl_PathType { TCL_PATH_ABSOLUTE, TCL_PATH_RELATIVE, TCL_PATH_VOLUME_RELATIVE } Tcl_PathType; typedef long int o; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^struct b *$" chkoutd "^struct C_ST_b *$" neg chkoutd "^union ub *$" chkoutd "^union C_UN_ub *$" neg chkoutd "^enum Tcl_ValueType *$" chkoutd "^enum C_ENUM_Tcl_ValueType *$" neg chkoutd "^enum Tcl_PathType *$" chkoutd "^enum C_ENUM_Tcl_PathType *$" neg chkoutd "^alias Tcl_ValueType" neg chkoutd "^alias Tcl_PathType" neg chkoutd "^enum (: )?bool ({ )?_cmacro_T3 = true( })?; *$" chkoutd "^(auto|int) T3\(int a, int b, int c\) { return .*; } *$" chkoutd "^alias (int|long) o;$" if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-ctype.sh0000555000175000017500000000662012076642270015706 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-type size' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > typehdr.h echo ' #ifndef _INC_TYPEHDR_H_ #define _INC_TYPEHDR_H_ typedef unsigned char a; typedef unsigned short int b; typedef unsigned int c; typedef unsigned long int d; typedef signed char e; typedef unsigned char f; typedef signed short int g; typedef unsigned short int h; typedef signed int i; typedef long int o; typedef float q; typedef double r; typedef unsigned int _t; typedef _t t; #endif ' > typehdr_ll.h echo ' #ifndef _INC_TYPEHDR_LL_H_ #define _INC_TYPEHDR_LL_H_ /* long long may not be supported */ __extension__ typedef signed long long int j; __extension__ typedef unsigned long long int k; #endif ' > typehdr_ld.h echo ' #ifndef _INC_TYPEHDR_LD_H_ #define _INC_TYPEHDR_LD_H_ /* long double may not be supported */ typedef long double s; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc csiz=`egrep "^enum (: )?int ({ )?_csiz_char = " out.d | sed 's/.*= //;s/[ }]*;//'` ssiz=`egrep "^enum (: )?int ({ )?_csiz_short = " out.d | sed 's/.*= //;s/[ }]*;//'` isiz=`egrep "^enum (: )?int ({ )?_csiz_int = " out.d | sed 's/.*= //;s/[ }]*;//'` lsiz=`egrep "^enum (: )?int ({ )?_csiz_long = " out.d | sed 's/.*= //;s/[ }]*;//'` llsiz=`egrep "^enum (: )?int ({ )?_csiz_long_long = " out.d | sed 's/.*= //;s/[ }]*;//'` fsiz=`egrep "^enum (: )?int ({ )?_csiz_float = " out.d | sed 's/.*= //;s/[ }]*;//'` dsiz=`egrep "^enum (: )?int ({ )?_csiz_double = " out.d | sed 's/.*= //;s/[ }]*;//'` ldsiz=`egrep "^enum (: )?int ({ )?_csiz_long_double = " out.d | sed 's/.*= //;s/[ }]*;//'` for x in a e f; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${csiz}( })?;$" done for x in e; do chkoutd "^alias byte C_TYP_${x};$" done for x in a f; do chkoutd "^alias ubyte C_TYP_${x};$" done for x in b g h; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${ssiz}( })?;$" done for x in g; do chkoutd "^alias short C_TYP_${x};$" done for x in b h; do chkoutd "^alias ushort C_TYP_${x};$" done for x in c i t; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${isiz}( })?;$" done for x in i; do chkoutd "^alias int C_TYP_${x};$" done for x in c t; do chkoutd "^alias uint C_TYP_${x};$" done for x in d o; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${lsiz}( })?;$" done tt=int if [ $lsiz -eq 8 ]; then tt=long fi for x in d; do chkoutd "^alias u${tt} C_TYP_${x};$" done for x in o; do chkoutd "^alias ${tt} C_TYP_${x};$" done if [ $llsiz -gt 0 ]; then for x in j k; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${llsiz}( })?;$" done for x in j; do chkoutd "^alias long C_TYP_${x};$" done for x in k; do chkoutd "^alias ulong C_TYP_${x};$" done fi for x in q; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${fsiz}( })?;$" chkoutd "^alias float C_TYP_${x};$" done for x in r; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${dsiz}( })?;$" chkoutd "^alias double C_TYP_${x};$" done if [ $ldsiz -gt 0 ]; then for x in s; do chkoutd "^enum (: )?int ({ )?_ctype_${x} = ${ldsiz}( })?;$" chkoutd "^alias real C_TYP_${x};$" done fi if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-singlelib.config0000444000175000017500000000007712076642270017362 0ustar bllbllenum bool _import_slib1 = true; enum bool _lib_slib1_f = true; di-4.34/mkconfig/tests.d/d.d/d-clib.config0000444000175000017500000000007712076642270016323 0ustar bllbllenum bool _clib_printf = true; enum bool _clib_prinft = false; di-4.34/mkconfig/tests.d/d.d/d-csyshdr.sh0000555000175000017500000000060412076642270016235 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'C sys/ header' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^enum (: )?bool ({ )?_sys_types = true( })?;$" if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-class.sh0000555000175000017500000000120212076642270015656 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 class maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > classtst.d echo ' module classtst; class a { int a; } ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env chkdcompile classtst.d dorunmkc chkoutd "^enum (: )?bool ({ )?_class_a = true( })?;$" if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-chdr.sh0000555000175000017500000000057712076642270015507 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'C header' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd "^enum (: )?bool ({ )?_hdr_ctype = true( })?;$" if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-multlib.sh0000555000175000017500000000320412076642270016225 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'w/multiple libs' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env > mlib2.d echo ' int mlib2_f () { return 0; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -c ${DC} -o mlib2${OBJ_EXT} mlib2.d >&9 if [ $? -ne 0 ]; then echo "## compile mlib2.d failed" exit 1 fi test -f libmlib2.a && rm -f libmlib2.a ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` \ -staticlib libmlib2 mlib2${OBJ_EXT} >&9 > mlib1.d echo ' import mlib2; int mlib1_f () { mlib2_f(); return 0; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -o mlib1${OBJ_EXT} -c ${DC} mlib1.d >&9 if [ $? -ne 0 ]; then echo "compile mlib1.d failed" exit 1 fi test -f libmlib1.a && rm -f libmlib1.a ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` \ -staticlib libmlib1 mlib1${OBJ_EXT} >&9 dorunmkc reqlibs out.d grep -v SYSTYPE out.d | grep -v '^//' | grep -v 'D_VERSION' | grep -v '_d_tango_lib' | grep -v 'alias char.. string;' | grep -v '_type_string' | grep -v '^import std.*string' | grep -v '_import_std.*string' | grep -v '^$' | sed -e 's/: //' -e 's/{ //' -e 's/ }//' > out.d.n chkdiff d-multlib.ctmp out.d.n chkdiff ${_MKCONFIG_RUNTESTDIR}/d-multlib.reqlibs mkconfig.reqlibs if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup out.d.n exit $grc di-4.34/mkconfig/tests.d/d.d/d-cmemberxdr.sh0000555000175000017500000000142312076642270016706 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-memberxdr' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > h.h echo ' #ifndef _INC_H_H_ #define _INC_H_H_ typedef unsigned int uu_int; struct a { uu_int a; int b; }; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd '^alias xdr_uu_int xdr_a;$' chkoutd '^alias xdr_int xdr_b;$' for x in a b; do chkoutd "^enum (: )?bool ({ )?_cmemberxdr_a_${x} = true( })?;$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cmacro.dat0000444000175000017500000000200512076642270016152 0ustar bllblloutput out.d loadunit d-main standard chdr macrohdr.h csizes cstruct b cstruct CL ctypedef CL cstruct DP ctypedef DP cmacro T0 macrohdr.h int cmacro T1 macrohdr.h int int cmacro T2 macrohdr.h int int int cmacro T3 macrohdr.h int int int int cmacro T4 macrohdr.h string string cmacro T5 macrohdr.h int cmacro T6 macrohdr.h uint uint uint uint cmacro T7 macrohdr.h int 'CL *' int int int int int 'struct b' cmacro T8 macrohdr.h uint uint uint uint cmacro T9 macrohdr.h int int int cmacro T10 macrohdr.h int 'CL *' int int int int int 'struct b' cmacro T_11 macrohdr.h int 'DP *' cmacro T12 macrohdr.h 'DP *' cmacro T13 macrohdr.h int cmacro T14 macrohdr.h int cmacro T15 macrohdr.h int cmacro T16 macrohdr.h int cmacro T17 macrohdr.h int cmacro T18 macrohdr.h int cmacro T19 macrohdr.h int cmacro T20 macrohdr.h int cmacro T21 macrohdr.h int cmacro T22 macrohdr.h int cmacro T23 macrohdr.h int cmacro T24 macrohdr.h int cmacro T25 macrohdr.h int cmacro T26 macrohdr.h int cmacro T27 macrohdr.h int cmacro T28 macrohdr.h int di-4.34/mkconfig/tests.d/d.d/d-chdr.dat0000444000175000017500000000006412076642270015631 0ustar bllblloutput out.d loadunit d-main standard chdr ctype.h di-4.34/mkconfig/tests.d/d.d/d-cmembertype.dat0000444000175000017500000000024112076642270017222 0ustar bllblloutput out.d loadunit d-main standard chdr memtypehdr.h csizes cstruct getquota_args cmembertype getquota_args gqa_pathp cmembertype getquota_args gqa_uid di-4.34/mkconfig/tests.d/d.d/d-module.dat0000444000175000017500000000007012076642270016173 0ustar bllblloutput out.d loadunit d-main standard module test.test di-4.34/mkconfig/tests.d/d.d/d-clib.dat0000444000175000017500000000015212076642270015620 0ustar bllblloutput out.d loadunit d-main standard import std.string import stdc.string csizes clib printf clib prinft di-4.34/mkconfig/tests.d/d.d/d-multlib.config0000444000175000017500000000013712076642270017057 0ustar bllbllenum bool _import_mlib1 = true; enum bool _import_mlib2 = true; enum bool _lib_mlib1_f = true; di-4.34/mkconfig/tests.d/d.d/d-singlelib.sh0000555000175000017500000000233712076642270016533 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'w/single lib' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env > slib1.d echo ' int slib1_f () { return 0; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` -comp -c ${DC} -o slib1${OBJ_EXT} slib1.d >&9 if [ $? -ne 0 ]; then echo "## compile slib1.d failed" exit 1 fi test -f libslib1.a && rm -f libslib1.a ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -d `pwd` \ -staticlib libslib1 slib1${OBJ_EXT} >&9 dorunmkc reqlibs out.d grep -v 'SYSTYPE' out.d | grep -v '^//' | grep -v 'D_VERSION' | grep -v '_d_tango_lib' | grep -v 'alias char.. string;' | grep -v '_type_string' | grep -v '^import std.*string' | grep -v '_import_std.*string' | grep -v '^$' | sed -e 's/: //' -e 's/{ //' -e 's/ }//' > out.d.n chkdiff d-singlelib.ctmp out.d.n chkdiff ${_MKCONFIG_RUNTESTDIR}/d-singlelib.reqlibs mkconfig.reqlibs testcleanup out.d.n exit $grc di-4.34/mkconfig/tests.d/d.d/d-compiler.sh0000555000175000017500000000154012076642270016370 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'D compiler works' maindoquery $1 $_MKC_ONCE chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env case $DVERSION in 1|2|3|4) ;; *) grc=1 ;; esac if [ $grc -ne 0 ]; then echo "## invalid D version" fi if [ $grc -eq 0 ]; then > d_compiler.d echo ' int main (char[][] args) { return 0; } ' ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkc.sh -comp -e -c ${DC} \ -o d_compiler.exe d_compiler.d >&9 rc=$? if [ $rc -ne 0 ]; then grc=$rc; echo "## compilation failed" fi if [ -x d_compiler.exe ]; then ./d_compiler.exe rc=$? if [ $rc -ne 0 ]; then grc=$rc; fi else echo "## unable to locate executable" ls -l >&9 grc=1 fi fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cmemberxdr.dat0000444000175000017500000000032712076642270017043 0ustar bllblloutput out.d loadunit d-main standard chdr h.h csizes ctypedef uu_int cstruct a cmemberxdr a a cmemberxdr a b include uu_int xdr_uu_int (uu_int a) { return a; } int xdr_int (int a) { return a; } endinclude di-4.34/mkconfig/tests.d/d.d/d-csyshdr.dat0000444000175000017500000000006412076642270016370 0ustar bllblloutput out.d loadunit d-main standard csys types.h di-4.34/mkconfig/tests.d/d.d/d-class.dat0000444000175000017500000000011512076642270016013 0ustar bllblloutput out.d loadunit d-main standard import classtst class a ../classtst.o di-4.34/mkconfig/tests.d/d.d/d-size.dat0000444000175000017500000000006112076642270015660 0ustar bllblloutput out.d loadunit d-main standard size long di-4.34/mkconfig/tests.d/d.d/d-cmacro.sh0000555000175000017500000000640512076642270016027 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 c-macro maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > macrohdr.h echo ' #ifndef _INC_MACROHDR_H_ #define _INC_MACROHDR_H_ struct b { int a; int b; }; typedef struct CL CL; struct CL { struct clnt_ops { int (*cl_call)(CL *, int, int, int, int, int, struct b); } *cl_ops; }; typedef struct DP DP; struct DP { int length; }; #define T0 2 #define T1(a) ((a)+1) #define T2(a, b) ((a)+(b)+1) #define T3(a,b,c) ((a)+(b)+(c)) # define T4(args) (args) #define T5 (3) # define T6(a , b , c) ((a)*(b)*(c)) /* tabs, ->, multi-line (was clnt_call) */ #define T7(rh, proc, xargs, argsp, xres, resp, secs) \ ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, argsp, xres, resp, secs)) # define T8( a , b , c ) ((a)*(b)*(c)) #define T9(cmd, type) (((cmd) << 8) | ((type) & 0x0f)) #define T10(rh, proc, xargs, argsp, xres, resp, secs) \ ((*(rh)->cl_ops->cl_call)(rh, proc, xargs, \ argsp, xres, resp, secs)) #define T_11(dp) ((dp)->length) #define T12 ((DP *) 1) // test with cast of non basic type #if 0 # define T13 1 #else # define T13 2 #endif #if 1 # define T14 1 #else # define T14 2 #endif #define BLAH 1 #if BLAH # define T15 1 #else # define T15 2 #endif #define BAR 0 #if BAR # define T16 1 #else # define T16 2 #endif #if AA // from cflags # define T17 1 #else # define T17 2 #endif #if BB // from cflags # define T18 1 #else # define T18 2 #endif #if CC // from cflags # define T19 1 #else # define T19 2 #endif #define DD1 1 #define DD2 1 #define DD3 0 #define DD4 0 #if DD1 && DD2 # define T20 1 #else # define T20 2 #endif #if DD1 && DD3 # define T21 1 #else # define T21 2 #endif #if DD1 || DD2 # define T22 1 #else # define T22 2 #endif #if DD1 || DD3 # define T23 1 #else # define T23 2 #endif #if ! DD1 # define T24 1 #else # define T24 2 #endif #if ! DD3 # define T25 1 #else # define T25 2 #endif #if DD1 && DD2 || DD3 // no precedence, should be true # define T26 1 #else # define T26 2 #endif #if DD1 && DD3 || DD2 # define T27 1 #else # define T27 2 #endif #if DD1 && DD3 || DD4 // no precedence, should be false # define T28 1 #else # define T28 2 #endif #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS} -DAA -DBB=1 -DCC=0 " DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc for x in T0 T1 T2 T3 T4 T5 T6 T7 T8 T9 T10 T_11 T12 \ T13 T14 T15 T16 T17 T18 T19 T20 T21 T22 T23 T24 T25 T26 T27 T28; do chkoutd "^enum (: )?bool ({ )?_cmacro_${x} = true( })?;$" done for x in T0 T1 T2 T3 T5 T7 T9 T10 T_11; do chkoutd "^(auto|int) C_MACRO_${x}" done for x in T12; do chkoutd "^.* C_MACRO_${x}" done for x in T14 T15 T17 T18 T20 T22 T23 T25 T26 T27; do chkoutd "^(auto|int) C_MACRO_${x} \(\) { return 1; }" done for x in T13 T16 T19 T21 T24 T28; do chkoutd "^(auto|int) C_MACRO_${x} \(\) { return 2; }" done for x in T4 ; do chkoutd "^(auto|string) C_MACRO_${x}" done for x in T6 T8 ; do chkoutd "^(auto|uint) C_MACRO_${x}" done for x in T12 ; do chkoutd "^(auto|DP [*]) C_MACRO_${x}" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/test_order0000444000175000017500000000042612076642270016075 0ustar bllbll1 d-compiler 2 d-outfile 3 d-module 3 d-set 3 d-option 4 d-import 4 d-member 4 d-size 4 d-class 5 d-chdr 5 d-csyshdr 6 d-clib 6 d-ctype 7 d-cstruct 7 d-cdefine 8 d-ctypedef 8 d-cmember 8 d-cmembertype 8 d-cdcl 9 d-cmacro 9 d-cmemberxdr 10 d-noprefix 11 d-singlelib 12 d-multlib di-4.34/mkconfig/tests.d/d.d/d-ctype.dat0000444000175000017500000000057312076642270016042 0ustar bllblloutput out.d loadunit d-main standard csizes chdr typehdr.h chdr typehdr_ll.h chdr typehdr_ld.h ctype int a ctype int b ctype int c ctype int d ctype int e ctype int f ctype int g ctype int h ctype int i if longlong _hdr_typehdr_ll ctype int j ctype int k endif ctype int o ctype float q ctype float r if longdouble _hdr_typehdr_ld ctype float s endif ctype int t di-4.34/mkconfig/tests.d/d.d/d-cdcl.dat0000444000175000017500000000072212076642270015617 0ustar bllblloutput out.d loadunit d-main standard csizes chdr cdclhdr.h cdcl args noconst a cdcl args noconst b cdcl args noconst c cdcl args noconst d cdcl args noconst e cdcl args noconst f cdcl args noconst g cdcl args noconst h cdcl args noconst i cdcl args noconst j cdcl args noconst k cdcl args noconst l cdcl args noconst m cdcl args noconst n cdcl args noconst o cdcl args noconst p cdcl args noconst q cdcl args noconst r cstruct x_t cunion y_t cdcl args noconst s di-4.34/mkconfig/tests.d/d.d/d-singlelib.reqlibs0000444000175000017500000000001012076642270017541 0ustar bllbll-lslib1 di-4.34/mkconfig/tests.d/d.d/d-cdcl.sh0000555000175000017500000001070612076642270015467 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-dcl extraction' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > cdclhdr.h echo ' #ifndef _INC_cdclhdr_H_ #define _INC_cdclhdr_H_ /* modified from linux sys/statvfs.h */ #if __GNUC__ extern int a (__const char *__restrict __file, long *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))); #endif int b (int); extern int c (long); extern int d (int, int, char *); extern int e (char **, int *); extern int f (int, char * const [], const char *); extern char *g (const char *); #if __GNUC__ extern int h (__const char *__restrict __file, long *__restrict __buf) __attribute__ ((__nothrow__)) __attribute__ ((__nonnull__ (1, 2))); extern char *i (__const char *__domainname, __const char *__dirname); extern char *j (__const char *__domainname, __const char *__dirname); #endif extern int k (int, int, char *); extern int l (int, int); extern int m (int); extern int n (int, int, char *, int); #if __GNUC__ extern int o (int, int, char *, int) __asm__ ("" "o64"); #endif /* w/var names */ extern char *p (int a, int b, char *c, int d); /* w/var names and lots of spaces */ extern int q ( int a , int b , char * c , int d ); /* w/no var names and lots of spaces */ extern int r ( int , int , char * , int ); /* struct names */ struct x_t { int a; }; union y_t { int a; int b; }; extern int s ( struct x_t x , union y_t y , char * , int ); #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc lsiz=`egrep "^enum (: )?int ({ )?_csiz_long = " out.d | sed 's/.*= //;s/[ }]*;//'` if [ "${_MKCONFIG_USING_GCC}" = "Y" ]; then for x in a h i j o; do chkoutd "^enum (: )?bool ({ )?_cdcl_${x} = true( })?;$" done set 2 2 2 2 4 for x in a h i j o; do val=$1 shift chkoutd "^enum (: )?int ({ )?_c_args_${x} = ${val}( })?;$" done for x in o64; do xx=`echo $x | sed 's/64$//'` chkoutd "^alias ${x} ${xx};$" done set 1 2 4 for x in o o o; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"int\";$" done # char * check set 1 1 1 2 1 2 3 for x in a h i i j j o; do val=$1 shift set -f chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"char \*\";$" done tt=int if [ $lsiz -eq 8 ]; then tt=long fi # long * check set 2 2 for x in a h; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"${tt} \*\";$" done # int type check for x in a h o; do chkoutd "^(enum (: )?)?string _c_type_${x} = \"int\";$" done # char * type check for x in i j; do chkoutd "^(enum (: )?)?string _c_type_${x} = \"char \*\";$" done fi for x in b c d e f g k l m n p q r s; do chkoutd "^enum (: )?bool ({ )?_cdcl_${x} = true( })?;$" done # arguments set 1 1 3 2 3 1 3 2 1 4 4 4 4 4 for x in b c d e f g k l m n p q r s; do val=$1 shift chkoutd "^enum (: )?int ({ )?_c_args_${x} = ${val}( })?;$" done # int check set 1 1 2 1 1 2 1 2 1 1 2 4 1 2 4 1 2 4 1 2 4 4 for x in b d d f k k l l m n n n p p p q q q r r r s; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"int\";$" done # long check set 1 for x in c; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"long\";$" done # 'char *' check set 3 3 1 3 3 3 3 3 3 for x in d f g k n p q r s; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"char \*\";$" done # 'char **' check set 1 for x in e; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"char \*\*\";$" done # 'char * []' check set 2 for x in f; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"char \* \[\]\";$" done # 'C_ST_x_t' check set 1 for x in s; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"C_ST_x_t\";$" done # 'C_UN_y_t' check set 2 for x in s; do val=$1 shift chkoutd "^(enum (: )?)?string _c_arg_${val}_${x} = \"C_UN_y_t\";$" done # int type check for x in b c d e k l m n q r s; do chkoutd "^(enum (: )?)?string _c_type_${x} = \"int\";$" done # char * type check for x in g p; do chkoutd "^(enum (: )?)?string _c_type_${x} = \"char \*\";$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-noprefix.dat0000444000175000017500000000027712076642270016551 0ustar bllblloutput out.d loadunit d-main standard noprefix chdr noprefixhdr.h csizes cstruct b cmacro T3 noprefixhdr.h int int int int cunion ub cenum Tcl_ValueType cenum Tcl_PathType ctype int o di-4.34/mkconfig/tests.d/d.d/d.env.dat0000444000175000017500000000034112076642270015500 0ustar bllbllloadunit env-main loadunit env-systype loadunit env-extension loadunit env-dc loadunit env-cc output d.env system type system rev system arch extension obj extension exe dc using_gdc dflags cc using_gcc cflags ldflags libs di-4.34/mkconfig/tests.d/d.d/d-ctypedef.sh0000555000175000017500000000405312076642270016363 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 c-typedef maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > typedefhdr.h echo ' #ifndef _INC_TYPEDEFHDR_H_ #define _INC_TYPEDEFHDR_H_ typedef unsigned char a; typedef unsigned short int b; typedef unsigned int c; typedef unsigned long int d; typedef signed char e; typedef unsigned char f; typedef signed short int g; typedef unsigned short int h; typedef signed int i; #if __GNUC__ __extension__ typedef signed long long int j; __extension__ typedef unsigned long long int k; __extension__ typedef void * l; #endif typedef void *m; struct ns { int n; }; typedef struct ns n; typedef struct { int o; } o_t; typedef o_t o; // typedef of typedef typedef o p; // typedef of typedef typedef void *q; // with semi ; in comment typedef int *r; /* semi ; in comment */ typedef int * (s) (int s1); typedef struct ns *t; typedef void (u)(int u1); typedef int*(v) (int v1); // multiline typedef int (w) (int w1, int *w2, int w3); typedef int (*x) (int *, void *,...); // multiline typedef int yyy (int *a, int b, int *c, int d, int *const e[]); // multiline typedef int (zz) (int clientData); typedef struct aa1 { int aa1_a; } aa1; struct aa2 { int aa2_a; }; typedef struct aa2 aa2; typedef struct aa3 aa3; struct aa3 { int aa3_a; }; typedef struct aa4 { int aa4_a; } aa4; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc if [ "${_MKCONFIG_USING_GCC}" = "Y" ]; then for x in j k l; do chkoutd "^enum (: )?bool ({ )?_ctypedef_${x} = true( })?;$" chkoutd "alias.*[ \*]${x};$" done fi for x in a b c d e f g h i m n o p q r t u v w x yyy zz aa1 aa2 aa3; do chkoutd "^enum (: )?bool ({ )?_ctypedef_${x} = true( })?;$" chkoutd "alias.*[ \*]${x};$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cmembertype.sh0000555000175000017500000000152012076642270017070 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c-membertype' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ > memtypehdr.h echo ' #ifndef _INC_MEMTYPEHDR_H_ #define _INC_MEMTYPEHDR_H_ struct getquota_args { char *gqa_pathp; int gqa_uid; }; #endif ' CFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${CFLAGS}" DFLAGS="-I${_MKCONFIG_TSTRUNTMPDIR} ${DFLAGS}" LDFLAGS="-L${_MKCONFIG_TSTRUNTMPDIR} ${LDFLAGS}" export CFLAGS DFLAGS LDFLAGS ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc chkoutd '^alias char \* C_TYP_gqa_pathp;$' chkoutd '^alias int C_TYP_gqa_uid;$' for x in gqa_pathp gqa_uid; do chkoutd "^enum (: )?bool ({ )?_cmembertype_getquota_args_${x} = true( })?;$" done if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup exit $grc di-4.34/mkconfig/tests.d/d.d/d-cdefine.dat0000444000175000017500000000037012076642270016306 0ustar bllblloutput out.d loadunit d-main standard csizes chdr cdefine.h cdefine int a cdefine int b cdefine int c cdefine string d cdefine string e cdefine hex g cdefine hex h cdefine hex i cdefine hex j cdefine int k cdefine int l cdefine float pi di-4.34/mkconfig/tests.d/d.d/d-ctypedef.dat0000444000175000017500000000074012076642270016515 0ustar bllblloutput out.d loadunit d-main standard csizes chdr typedefhdr.h cstruct ns cstruct o ctypedef a ctypedef b ctypedef c ctypedef d ctypedef e ctypedef f ctypedef g ctypedef h ctypedef i ctypedef j ctypedef k ctypedef l ctypedef m ctypedef n ctypedef o ctypedef p ctypedef q ctypedef r ctypedef s ctypedef t ctypedef u ctypedef v ctypedef w ctypedef x ctypedef yyy ctypedef zz cstruct aa1 ctypedef aa1 cstruct aa2 ctypedef aa2 cstruct aa3 ctypedef aa3 cstruct aa4 ctypedef aa4 di-4.34/mkconfig/tests.d/d.d/d-clib.sh0000555000175000017500000000135012076642270015466 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'c library' maindoquery $1 $_MKC_SH chkdcompiler getsname $0 dosetup $@ ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/mkconfig.sh -d `pwd` \ -C $_MKCONFIG_RUNTESTDIR/d.env.dat . ./d.env dorunmkc grep -v SYSTYPE out.d | grep -v '^//' | grep -v 'D_VERSION' | grep -v '_d_tango_lib' | grep -v '_csiz_' | grep -v 'alias [a-z]* C_NATIVE_[a-z_]*;' | grep -v 'alias char.. string;' | grep -v '_type_string' | grep -v '^import std.*string' | grep -v '_import_std.*string' | grep -v '^$' | sed -e 's/: //' -e 's/{ //' -e 's/ }//' > out.d.n chkdiff d-clib.ctmp out.d.n if [ $grc -eq 0 ]; then chkdcompile out.d fi testcleanup out.d.n exit $grc di-4.34/mkconfig/tests.d/test_order0000444000175000017500000000010412076642270015421 0ustar bllbll1 compperl 1 compsh 2 multword 2 command 2 grep 3 env.d 4 c.d 5 d.d di-4.34/mkconfig/tests.d/command.dat0000444000175000017500000000013212076642270015435 0ustar bllblloutput out.h loadunit c-main command xblah command sed command grep command awk sed grep di-4.34/mkconfig/tests.d/compsh.sh0000555000175000017500000000345412076642270015167 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'compile shell scripts' maindoquery $1 $_MKC_SH getsname $0 dosetup $@ if [ "$_MKCONFIG_SHELL" = "" ]; then _MKCONFIG_SHELL=$SHELL fi if [ "$_MKCONFIG_SHELL" = "" ]; then _MKCONFIG_SHELL=/bin/sh fi DASH_N_SUPPORTED=T # test for -n not supported. ( TMP=chkdashn$$ rm -f $TMP $TMP.out > /dev/null 2>&1 echo 'while test $# -gt 1; do echo $1; shift; done; exit 1' > $TMP chmod a+rx $TMP cmd="$_MKCONFIG_SHELL -n $TMP;echo \$? > $TMP.out" eval $cmd & job=$! sleep 1 rc=1 if [ ! -f $TMP.out ]; then kill $job else rc=`cat $TMP.out` fi rm -f $TMP $TMP.out > /dev/null 2>&1 exit $rc ) rc=$? if [ $rc -ne 0 ]; then DASH_N_SUPPORTED=F fi if [ "$DASH_N_SUPPORTED" = F ]; then echo ${EN} "(skip)${EC}" >&5 exit 0 fi # need globbing on. set +f cd $_MKCONFIG_DIR for f in mkc.sh mkconfig.sh runtests.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/bin for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/units for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/util for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/tests.d for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/tests.d/c.d for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/tests.d/d.d for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done cd $_MKCONFIG_DIR/tests.d/env.d for f in *.sh; do $_MKCONFIG_SHELL -n $f rc=$? if [ $rc -ne 0 ];then grc=$rc; fi done testcleanup exit $grc di-4.34/mkconfig/tests.d/multword.dat0000444000175000017500000000006012076642270015674 0ustar bllblloutput test.env loadunit env-main test_multword di-4.34/mkconfig/MANIFEST0000444000175000017500000001172212076642270013101 0ustar bllbllLICENSE LICENSE MANIFEST MANIFEST Makefile README README VERSION version bin/ bin/mkcsetopt.sh set options in options file bin/mkcl.sh compile or link bin/mkreqlib.sh required link libraries bin/mksharedlib.sh create a shared library bin/mkstaticlib.sh create a static library bin/shellfuncs.sh mkconfig functions bin/testfuncs.sh test suite functions features/ features/checktests.dat man/ man/mkconfig.7 manual page man/mkconfig_c.7 manual page man/mkconfig_d.7 manual page man/mkconfig_env.7 manual page mkc.sh compile/link/library/other tool mkconfig.pl perl config program mkconfig.sh shell config program runtests.sh runs regression tests tests.d/ regression tests tests.d/c.d/ regression tests for C language tests.d/c.d/c-args.dat tests.d/c.d/c-args.sh tests.d/c.d/c-cache.dat tests.d/c.d/c-cache.sh tests.d/c.d/c-compiler.sh tests.d/c.d/c-const.dat tests.d/c.d/c-const.sh tests.d/c.d/c-declare.dat tests.d/c.d/c-declare.sh tests.d/c.d/c-define.dat tests.d/c.d/c-define.sh tests.d/c.d/c-header.dat tests.d/c.d/c-header.sh tests.d/c.d/c-if.dat tests.d/c.d/c-if.sh tests.d/c.d/c-ifoption.dat tests.d/c.d/c-ifoption.sh tests.d/c.d/c-incconflict.dat tests.d/c.d/c-incconflict.sh tests.d/c.d/c-include.config tests.d/c.d/c-include.dat tests.d/c.d/c-include.sh tests.d/c.d/c-keyword.dat tests.d/c.d/c-keyword.sh tests.d/c.d/c-member.dat tests.d/c.d/c-member.sh tests.d/c.d/c-memberxdr.dat tests.d/c.d/c-memberxdr.sh tests.d/c.d/c-mkexeclibsh.sh tests.d/c.d/c-mkexeclibst.sh tests.d/c.d/c-mksharedlib.sh tests.d/c.d/c-mkshlibmult.sh tests.d/c.d/c-mkstaticlib.sh tests.d/c.d/c-multlib.config tests.d/c.d/c-multlib.dat tests.d/c.d/c-multlib.reqlibs tests.d/c.d/c-multlib.sh tests.d/c.d/c-nooptfile.dat tests.d/c.d/c-nooptfile.sh tests.d/c.d/c-nooption.dat tests.d/c.d/c-nooption.sh tests.d/c.d/c-npt.dat tests.d/c.d/c-npt.sh tests.d/c.d/c-option.dat tests.d/c.d/c-option.sh tests.d/c.d/c-outfile.dat tests.d/c.d/c-outfile.sh tests.d/c.d/c-set.dat tests.d/c.d/c-set.sh tests.d/c.d/c-shared.env.dat tests.d/c.d/c-singlelib.config tests.d/c.d/c-singlelib.dat tests.d/c.d/c-singlelib.reqlibs tests.d/c.d/c-singlelib.sh tests.d/c.d/c-size.dat tests.d/c.d/c-size.sh tests.d/c.d/c-substitute.dat tests.d/c.d/c-substitute.sh tests.d/c.d/c-syshdr.dat tests.d/c.d/c-syshdr.sh tests.d/c.d/c-type.dat tests.d/c.d/c-type.sh tests.d/c.d/c.env.dat tests.d/c.d/test_order tests.d/command.dat tests.d/command.sh tests.d/compperl.sh tests.d/compsh.sh tests.d/d.d/ regression tests for D language tests.d/d.d/d-cdcl.dat tests.d/d.d/d-cdcl.sh tests.d/d.d/d-cdefine.dat tests.d/d.d/d-cdefine.sh tests.d/d.d/d-chdr.dat tests.d/d.d/d-chdr.sh tests.d/d.d/d-class.dat tests.d/d.d/d-class.sh tests.d/d.d/d-clib.config tests.d/d.d/d-clib.dat tests.d/d.d/d-clib.sh tests.d/d.d/d-cmacro.dat tests.d/d.d/d-cmacro.sh tests.d/d.d/d-cmember.dat tests.d/d.d/d-cmember.sh tests.d/d.d/d-cmembertype.dat tests.d/d.d/d-cmembertype.sh tests.d/d.d/d-cmemberxdr.dat tests.d/d.d/d-cmemberxdr.sh tests.d/d.d/d-compiler.sh tests.d/d.d/d-cstruct.dat tests.d/d.d/d-cstruct.sh tests.d/d.d/d-csyshdr.dat tests.d/d.d/d-csyshdr.sh tests.d/d.d/d-ctype.dat tests.d/d.d/d-ctype.sh tests.d/d.d/d-ctypedef.dat tests.d/d.d/d-ctypedef.sh tests.d/d.d/d-import.dat tests.d/d.d/d-import.sh tests.d/d.d/d-member.dat tests.d/d.d/d-member.sh tests.d/d.d/d-module.dat tests.d/d.d/d-module.sh tests.d/d.d/d-multlib.config tests.d/d.d/d-multlib.dat tests.d/d.d/d-multlib.reqlibs tests.d/d.d/d-multlib.sh tests.d/d.d/d-noprefix.dat tests.d/d.d/d-noprefix.sh tests.d/d.d/d-option.dat tests.d/d.d/d-option.sh tests.d/d.d/d-outfile.dat tests.d/d.d/d-outfile.sh tests.d/d.d/d-set.dat tests.d/d.d/d-set.sh tests.d/d.d/d-singlelib.config tests.d/d.d/d-singlelib.dat tests.d/d.d/d-singlelib.reqlibs tests.d/d.d/d-singlelib.sh tests.d/d.d/d-size.dat tests.d/d.d/d-size.sh tests.d/d.d/d.env.dat tests.d/d.d/test_order tests.d/env.d/ regression tests for shell tests.d/env.d/env-option.dat tests.d/env.d/env-option.sh tests.d/env.d/env-outfile.dat tests.d/env.d/env-outfile.sh tests.d/env.d/env-set.dat tests.d/env.d/env-set.sh tests.d/env.d/env-source.dat tests.d/env.d/env-source.sh tests.d/env.d/test_order tests.d/grep.dat tests.d/grep.sh tests.d/multword.dat tests.d/multword.sh tests.d/test_order units/ units for mkconfig.sh units/c-include-conflict.sh units/c-main.sh units/c-support.sh units/d-main.sh units/d-support.sh units/env-cc.sh units/env-dc.sh units/env-extension.sh units/env-main.sh units/env-msgfmt.sh units/env-systype.sh util/ util/mkcextdcl.awk script to extract C language declarations util/mkcextmacro.awk script to extract C language macros util/mkcextstruct.awk script to extract C language structures util/mkcexttypedef.awk script to extract C language typedefs util/mktar.sh creates tar file examples/ examples examples/dtcltk/ example c-d code conversion examples/dtcltk/Makefile examples/dtcltk/env.dat examples/dtcltk/hw_tk_c.c examples/dtcltk/hw_tk_d1.d examples/dtcltk/hw_tk_d2.d examples/dtcltk/tcl.dat examples/dtcltk/tk.dat examples/dtcltk/x.dat di-4.34/mkconfig/README0000444000175000017500000002472012076642270012632 0ustar bllbllmkconfig - configuration tool (version 1.23) Please e-mail any configuration units and the corresponding manual page entry to brad.lanam.di_at_gmail.com. They will be included in the next release. TESTING Version 1.20 D has been tested on: FreeBSD 8.2 (dmd2, gdc2, dmd1) LinuxMint 11 (dmd2, gdc2, ldc2, dmd1, gdc1) Debian 6 [64bit] (dmd2) ISSUES - D Compiler bugs: ldc2 has structure size problems on 64bit (issue #28). gdc 4.6.3 (LinuxMint) has structure size problems on 64bit. CHANGES 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.34/mkconfig/man/0000755000175000017500000000000012076642270012522 5ustar bllblldi-4.34/mkconfig/man/mkconfig.70000444000175000017500000004171412076642270014414 0ustar bllbll.\" .\" $Id: mkconfig.7,v 1.26 2012-11-10 19:02:37-08 bll Exp $ .\" $Revision: 1.26 $ .\" .\" mkconfig.7 .\" .\" Copyright 2011-2012 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 -complink -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] libname objectfile ... .\" mkc.sh -sharedlib [-e] libname objectfile ... [-L ] [-l ] .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 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 option\-file defaults to 'options.dat'. .PP .B mkc.sh \-staticlib [-e] lib\-name object\-file [...] .PP The -e option echos the command line. .PP .B mkc.sh \-sharedlib [-e] lib\-name object\-file [...] [-L lib\-path ...] [-l lib ...] .PP The -e option echos the command line. .PP .B mkc.sh \-complink \-c [\-e] [\-o |\-o ] [\-r required\-lib\-file] \-\- [ ...] [ ...] [ ...] [\-L ] [\-l ] .PP The -e option echos the command line. .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. .PP \fImkc.sh \-setopt\fP is used to change the value of the options in the option file. .PP \fImkc.sh \-complink\fP 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 \fImkc.sh \-reqlib\fP 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 \fImkc.sh \-link\fP .PP \fImkc.sh \-staticlib\fP creates a static library given a library name and a list of object files. .PP \fImkc.sh \-sharedlib\fP creates a shared library given a library name, a list of object files, a list of library paths and libraries. .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.34/mkconfig/man/mkconfig_env.70000444000175000017500000001433612076642270015264 0ustar bllbll.\" .\" $Id: mkconfig_env.7,v 1.8 2013-01-17 12:38:41-08 bll Exp $ .\" $Revision: 1.8 $ .\" .\" mkconfig_env.7 .\" .\" Copyright 2011-2013 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, SHCFLAGS, and SHLDFLAGS 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 environment variable according to the 'getconf' program and appropriate to the operating system and compiler. .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 \fBldflags\fP .RS Sets the LDFLAGS environment variable according to the 'getconf' program and appropriate to the operating system and compiler. .RE .TP \fBlibs\fP .RS Sets the LIBS environment variable according to the 'getconf' program and appropriate to the operating system and compiler. .RE .TP \fBshcflags\fP .RS Sets the SHCFLAGS environment variable for building position independent code as appropriate to the operating system and compiler. .RE .TP \fBshldflags\fP .RS Sets the SHLDFLAGS environment variable for building a shared library as appropriate to the operating system and compiler. .RE .TP \fBshareexeclinkflag\fP .RS Sets the SHEXECLINK environment variable for building an executable against shared libraries as appropriate to the operating system and compiler. .RE .TP \fBsharerunpathflag\fP .RS Sets the SHRUNPATH 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.34/mkconfig/man/mkconfig_c.70000444000175000017500000001711512076642270014714 0ustar bllbll.\" .\" $Id: mkconfig_c.7,v 1.7 2011-11-20 12:55:27-08 bll Exp $ .\" $Revision: 1.7 $ .\" .\" mkconfig_c.7 .\" .\" Copyright 2011 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.34/mkconfig/man/mkconfig_d.70000444000175000017500000002746512076642270014726 0ustar bllbll.\" .\" $Id: mkconfig_d.7,v 1.19 2012-01-20 11:58:12-08 bll Exp $ .\" $Revision: 1.19 $ .\" .\" mkconfig_d.7 .\" .\" Copyright 2011-2012 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.34/mkconfig/mkc.sh0000555000175000017500000000222312076642270013055 0ustar bllbll#!/bin/sh # # $Id: mkc.sh,v 1.3 2012-10-18 11:29:05-07 bll Exp $ # # Copyright 2009-2010 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 doshelltest $0 $@ setechovars rc=0 args=$@ found=T case $1 in -compile|-comp|-link|-complink) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkcl.sh -d `pwd` $@ rc=$? ;; -staticlib) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkstaticlib.sh -d `pwd` $@ rc=$? ;; -sharedlib) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mksharedlib.sh -d `pwd` $@ rc=$? ;; -setopt) shift ${_MKCONFIG_SHELL} ${_MKCONFIG_DIR}/bin/mkcsetopt.sh -d `pwd` $@ rc=$? ;; -reqlib|-reqlibs) 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.34/C/0000755000175000017500000000000012076642270010334 5ustar bllblldi-4.34/C/di.h0000444000175000017500000002446012076642270011105 0ustar bllbll/* * $Id: di.h,v 1.66 2013-01-18 08:32:14-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/di.h,v $ * Copyright 1994-2013 Brad Lanam, Walnut Creek, CA */ #ifndef _INC_DI_H #define _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 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 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 excludeLoopback; unsigned int printTotals; unsigned int printDebugHeader; unsigned int printHeader; unsigned int displayAll; unsigned int localOnly; unsigned int dontResolveSymlink; } 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; 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 _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 /* _INC_DI_H */ di-4.34/C/configs/0000755000175000017500000000000012076642270011764 5ustar bllblldi-4.34/C/configs/config.mingw0000444000175000017500000001422312076642270014274 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 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_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 _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 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_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 1 #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 _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 0 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.bsd43.cc0000444000175000017500000001535412076642270014464 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_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_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 _has_std_quotas 1 #define _enable_nls 0 #define _has_std_nfs_quotas 1 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.win0000444000175000017500000001476112076642270013757 0ustar bllbll/* Created on: Fri Oct 19 12:40:55 PDT 2012 From: ../features/mkconfig.dat Using: mkconfig-1.21 */ #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_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 0 #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 0 #define _define_S_ISLNK 1 #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 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_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 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 _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 _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 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 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 12 #define _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _enable_nls 1 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.vms0000444000175000017500000001422412076642270013761 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_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_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 _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.ultrix.cc0000444000175000017500000001511112076642270015063 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_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_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 _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.hpux.bcc0000444000175000017500000001537612076642270014677 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_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_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 _has_std_quotas 1 #define _has_std_nfs_quotas 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.vms.b0000444000175000017500000001422312076642270014200 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_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_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 _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _enable_nls 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.ultrix.gcc0000444000175000017500000001511112076642270015232 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_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_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 _has_std_quotas 0 #define _has_std_nfs_quotas 0 #define _enable_nls 1 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/config.bsd43.gcc0000444000175000017500000001535312076642270014632 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_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_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 _has_std_quotas 1 #define _enable_nls 0 #define _has_std_nfs_quotas 1 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/configs/conf.xenix.cc0000444000175000017500000001544712076642270014363 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_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_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 _has_std_quotas 0 #define _enable_nls 0 #define _has_std_nfs_quotas 0 #define DI_DEFAULT_FORMAT "smbuvpT" #define DI_DEFAULT_DISP_SIZE "H" #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 #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.34/C/Makefile0000444000175000017500000002327412076642270012002 0ustar bllbll# # di makefile - C # # Copyright 2001-2011 Brad Lanam Walnut Creek CA, USA # # $Id: Makefile,v 1.135 2013-01-18 08:31:44-08 bll Exp $ # CC = cc # for tests.done DC = gdc SHELL = /bin/sh 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_CPPFLAGS = -DDI_LOCALE_DIR=\"$(LOCALEDIR)\" ### # mkconfig variables MKC_DIR = ../mkconfig MKCONFIG_TYPE = sh MKC_REQLIB = di.reqlibs ### # 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 .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 ### # specific builds # This was tested using vc++ 5.0. (many years ago) # seriously out of date; config.win 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.win 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.win 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 .PHONY: windows-mingw windows-mingw: 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) \ CC=mingw32-gcc LD=mingw32-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 di.reqlibs # ../dioptions.dat, tests.done, test_di, di.env .PHONY: clean clean: @-$(RM) -rf di mi \ di.exe mingw-di.exe mi.exe \ *.o *.obj mkconfig.log \ tests.done _tmp_mkconfig tests.d/chksh* \ mkconfig.cache mkc*.vars \ getoptn_test* gconfig.h getoptn.reqlibs \ mkconfig.reqlibs \ >/dev/null 2>&1 # leaves: # _mkconfig_runtests, _tmp_mkconfig, ../dioptions.dat # tests.done, test_di .PHONY: realclean realclean: @$(MAKE) clean > /dev/null 2>&1 @-$(RM) -rf config.h gconfig.h di.env $(MKC_REQLIB) \ >/dev/null 2>&1 # leaves: # ../dioptions.dat .PHONY: distclean distclean: @$(MAKE) realclean > /dev/null 2>&1 @-$(RM) -rf tests.done test_di \ _mkconfig_runtests _tmp_mkconfig \ >/dev/null 2>&1 ### # installation .PHONY: install install: di-programs di.env . ./di.env;cd ..;$(MAKE) -e prefix=$(prefix) LOCALEDIR=$(LOCALEDIR) FROMDIR=C install ### # programs .PHONY: di-programs di-programs: di$(EXE_EXT) ### # 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 $(MKC_REQLIB): di.env config.h $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -reqlib \ -o $(MKC_REQLIB) config.h ### # executables OBJECTS = di$(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) di$(EXE_EXT): $(MKC_REQLIB) $(OBJECTS) @echo "*** Using libs: `$(CAT) $(MKC_REQLIB)`" $(CC) -o di$(EXE_EXT) \ $(LDFLAGS) $(OBJECTS) $(LIBS) \ `$(CAT) $(MKC_REQLIB)` mingw-di$(EXE_EXT): $(OBJECTS) $(CC) -o mingw-di$(EXE_EXT) \ $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(LIBS) ### # objects di$(OBJ_EXT): di.c config.h di.h display.h getoptn.h \ options.h version.h $(CC) -c $(CFLAGS) $(CPPFLAGS) $(DI_CPPFLAGS) di.c digetinfo$(OBJ_EXT): digetinfo.c config.h di.h dimntopt.h $(CC) -c $(CFLAGS) $(CPPFLAGS) digetinfo.c didiskutil$(OBJ_EXT): didiskutil.c config.h di.h dimntopt.h $(CC) -c $(CFLAGS) $(CPPFLAGS) didiskutil.c digetentries$(OBJ_EXT): digetentries.c config.h di.h dimntopt.h $(CC) -c $(CFLAGS) $(CPPFLAGS) digetentries.c diquota$(OBJ_EXT): diquota.c config.h di.h $(CC) -c $(CFLAGS) $(CPPFLAGS) diquota.c display$(OBJ_EXT): display.c config.h di.h display.h options.h version.h $(CC) -c $(CFLAGS) $(CPPFLAGS) display.c getoptn$(OBJ_EXT): getoptn.c config.h getoptn.h $(CC) -c $(CFLAGS) $(CPPFLAGS) getoptn.c options$(OBJ_EXT): options.c config.h di.h options.h $(CC) -c $(CFLAGS) $(CPPFLAGS) options.c realloc$(OBJ_EXT): realloc.c config.h di.h $(CC) -c $(CFLAGS) $(CPPFLAGS) realloc.c strdup$(OBJ_EXT): strdup.c config.h di.h $(CC) -c $(CFLAGS) $(CPPFLAGS) strdup.c strstr$(OBJ_EXT): strstr.c config.h di.h $(CC) -c $(CFLAGS) $(CPPFLAGS) strstr.c trimchar$(OBJ_EXT): trimchar.c config.h di.h $(CC) -c $(CFLAGS) $(CPPFLAGS) trimchar.c ### # 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)" @echo "$(LDFLAGS)" @echo "$(LIBS)" @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 $(CC) -o getoptn_test$(OBJ_EXT) -DTEST_GETOPTN=1 -c getoptn.c getoptn.reqlibs: di.env gconfig.h $(_MKCONFIG_SHELL) $(MKC_DIR)/mkc.sh -reqlib \ -o getoptn.reqlibs gconfig.h getoptn_test.exe: getoptn_test$(OBJ_EXT) getoptn.reqlibs $(CC) -o getoptn_test.exe $(LDFLAGS) getoptn_test$(OBJ_EXT) \ `$(CAT) getoptn.reqlibs` di-4.34/C/display.c0000444000175000017500000010226612076642270012152 0ustar bllbll/* * $Id: display.c,v 1.8 2013-01-18 08:33:26-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/display.c,v $ * * Copyright 1994-2013 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 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_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 */ char *format; 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 void printInfo _((diDiskInfo_t *, diOptions_t *, diOutput_t *)); static void printSpace _((const diOptions_t *, const diOutput_t *, _fs_size_t, int)); static void processTitles _((diOptions_t *, diOutput_t *)); static void printPerc _((_fs_size_t, _fs_size_t, const char *)); static void initSizeTable _((diOptions_t *, diOutput_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. * */ void #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; 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); processTitles (diopts, diout); if (diopts->dispBlockSize == DI_DISP_HR || diopts->dispBlockSize == DI_DISP_HR_2) { --diout->width; } if (diopts->dispBlockSize != DI_DISP_HR && diopts->dispBlockSize != DI_DISP_HR_2 && (diopts->dispBlockSize > 0 && diopts->dispBlockSize <= 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); 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 == DI_DISP_HR || diopts->dispBlockSize == 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) { int allocated; allocated = FALSE; 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, sizeof (lastpool)); 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; } printInfo (dinfo, diopts, diout); } if (diopts->printTotals) { printInfo (&totals, diopts, diout); } } /* * 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"; } /* * printInfo * * Print the information for a single partition. Loop through the * format string and print the particular items wanted. * */ static void #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; 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 = 0.0; /* gcc compile warning */ if (diopts->dispBlockSize == 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) { printf (","); } first = FALSE; } switch (*ptr) { case DI_FMT_MOUNT: case DI_FMT_MOUNT_FULL: { printf (diout->mountFormat, diskInfo->name); break; } case DI_FMT_BTOT: { printSpace (diopts, diout, diskInfo->totalSpace, idx); break; } case DI_FMT_BTOT_AVAIL: { printSpace (diopts, diout, diskInfo->totalSpace - (diskInfo->freeSpace - diskInfo->availSpace), idx); break; } case DI_FMT_BUSED: { printSpace (diopts, diout, diskInfo->totalSpace - diskInfo->freeSpace, idx); break; } case DI_FMT_BCUSED: { printSpace (diopts, diout, diskInfo->totalSpace - diskInfo->availSpace, idx); break; } case DI_FMT_BFREE: { printSpace (diopts, diout, diskInfo->freeSpace, idx); break; } case DI_FMT_BAVAIL: { printSpace (diopts, diout, diskInfo->availSpace, idx); break; } case DI_FMT_BPERC_NAVAIL: { used = diskInfo->totalSpace - diskInfo->availSpace; totAvail = diskInfo->totalSpace; printPerc (used, totAvail, percFormat); break; } case DI_FMT_BPERC_USED: { used = diskInfo->totalSpace - diskInfo->freeSpace; totAvail = diskInfo->totalSpace; printPerc (used, totAvail, percFormat); break; } case DI_FMT_BPERC_BSD: { used = diskInfo->totalSpace - diskInfo->freeSpace; totAvail = diskInfo->totalSpace - (diskInfo->freeSpace - diskInfo->availSpace); printPerc (used, totAvail, percFormat); break; } case DI_FMT_BPERC_AVAIL: { _fs_size_t bfree; bfree = diskInfo->availSpace; totAvail = diskInfo->totalSpace; printPerc (bfree, totAvail, percFormat); break; } case DI_FMT_BPERC_FREE: { _fs_size_t bfree; bfree = diskInfo->freeSpace; totAvail = diskInfo->totalSpace; printPerc (bfree, totAvail, percFormat); break; } case DI_FMT_ITOT: { printf (diout->inodeFormat, diskInfo->totalInodes); break; } case DI_FMT_IUSED: { printf (diout->inodeFormat, diskInfo->totalInodes - diskInfo->freeInodes); break; } case DI_FMT_IFREE: { printf (diout->inodeFormat, diskInfo->freeInodes); break; } case DI_FMT_IPERC: { used = diskInfo->totalInodes - diskInfo->availInodes; totAvail = diskInfo->totalInodes; printPerc (used, totAvail, percFormat); break; } case DI_FMT_SPECIAL: case DI_FMT_SPECIAL_FULL: { printf (diout->specialFormat, diskInfo->special); break; } case DI_FMT_TYPE: case DI_FMT_TYPE_FULL: { printf (diout->typeFormat, diskInfo->fsType); break; } case DI_FMT_MOUNT_OPTIONS: { if (diopts->csv_output) { printf ("\""); } printf (diout->optFormat, diskInfo->options); if (diopts->csv_output) { printf ("\""); } break; } case DI_FMT_MOUNT_TIME: { break; } default: { printf ("%c", *ptr); break; } } ++ptr; if (! diopts->csv_output && *ptr && valid) { printf (" "); } } printf ("\n"); } static void #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; char *suffix; const char *format; suffix = ""; format = diout->blockFormat; tdbs = diopts->dispBlockSize; if (diopts->dispBlockSize == DI_DISP_HR) { temp = (_print_size_t) usage; idx = findDispSize (temp); } if (diopts->dispBlockSize == DI_DISP_HR || diopts->dispBlockSize == 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 = 1.0 / tdbs; printf (format, (_print_size_t) usage * mult, suffix); } 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 void #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; char *pstr = { "" }; char *fstr; Size_t maxsize; char tformat [30]; char ttitle [2]; int first; 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); break; } case DI_FMT_MOUNT_FULL: { wlen = diout->maxMountString; if (wlen <= 0) { wlen = 7; } wlenptr = &diout->maxMountString; fstr = diout->mountFormat; maxsize = sizeof (diout->mountFormat); 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); pstr = "Inodes"; break; } case DI_FMT_IUSED: { justification = DI_JUST_RIGHT; wlen = diout->inodeWidth; wlenptr = &diout->inodeWidth; fstr = diout->inodeLabelFormat; maxsize = sizeof (diout->inodeLabelFormat); pstr = "IUsed"; break; } case DI_FMT_IFREE: { justification = DI_JUST_RIGHT; wlen = diout->inodeWidth; wlenptr = &diout->inodeWidth; fstr = diout->inodeLabelFormat; maxsize = sizeof (diout->inodeLabelFormat); 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); pstr = "Filesystem"; break; } case DI_FMT_SPECIAL_FULL: { wlen = diout->maxSpecialString; wlenptr = &diout->maxSpecialString; fstr = diout->specialFormat; maxsize = sizeof (diout->specialFormat); pstr = "Filesystem"; break; } case DI_FMT_TYPE: { wlen = 7; wlenptr = &diout->maxTypeString; fstr = diout->typeFormat; maxsize = sizeof (diout->typeFormat); pstr = "fsType"; break; } case DI_FMT_TYPE_FULL: { wlen = diout->maxTypeString; wlenptr = &diout->maxTypeString; fstr = diout->typeFormat; maxsize = sizeof (diout->typeFormat); pstr = "fs Type"; break; } case DI_FMT_MOUNT_OPTIONS: { wlen = diout->maxOptString; wlenptr = &diout->maxOptString; fstr = diout->optFormat; maxsize = sizeof (diout->optFormat); pstr = "Options"; break; } case DI_FMT_MOUNT_TIME: { break; } default: { if (diopts->printHeader) { printf ("%c", *ptr); } 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->printHeader) { if (diopts->csv_output) { if (! first) { printf (","); } first = FALSE; } if (diopts->csv_output) { ttitle[0] = *ptr; ttitle[1] = '\0'; printf ("%s", ttitle); } else { printf (tformat, pstr); } } if (fstr != (char *) NULL) { if (diopts->csv_output) { strncpy (tformat, "\"%s\"", sizeof (tformat)); } if (tlen != len) { if (! diopts->csv_output) { Snprintf3 (tformat, sizeof (tformat), "%%%s%d.%ds", jstr, (int) len, (int) len); } } strncpy (fstr, tformat, maxsize); } if (wlenptr != (Size_t *) NULL) { *wlenptr = wlen; } } ++ptr; if (diopts->printHeader) { if (! diopts->csv_output && *ptr && valid) { printf (" "); } } } if (diopts->printHeader) { printf ("\n"); } } /* * printPerc * * Calculate and print a percentage using the values and format passed. * */ static void #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; if (totAvail > 0L) { perc = (_print_size_t) used / (_print_size_t) totAvail; perc *= 100.0; } else { perc = 0.0; } printf (format, perc); } 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: { _fs_size_t temp; temp = (d1->availSpace - d2->availSpace); if (temp == 0) { rc = 0; } else { rc = temp > 0 ? 1 : -1; } 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.34/C/diquota.c0000444000175000017500000005610612076642270012154 0ustar bllbll/* * $Id: diquota.c,v 1.38 2013-01-19 09:23:37-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/diquota.c,v $ * * Copyright 2011-2013 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 _((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; # 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 need name rather than special */ rc = quotactl (cmd, diqinfo->name, (int) id, (caddr_t) &(qdata->qinfo)); # else rc = quotactl (cmd, 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; int gcmd; #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 (char *tag, diQuota_t *diqinfo, int rc, int xfsflag, qdata_t *qdata) # else di_process_quotas (tag, diqinfo, rc, xfsflag, qdata) 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); } 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.34/C/digetentries.c0000444000175000017500000017214212076642270013173 0ustar bllbll/* * $Id: digetentries.c,v 1.44 2013-01-18 08:32:35-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/digetentries.c,v $ * Copyright 1994-2011 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * *diCount); 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 # define DI_UNKNOWN_FSTYPE "(%.2d)?" 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); 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 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 # define DI_UNKNOWN_FSTYPE "(%.2d)?" /* * 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 /* 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); 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 *) calloc (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 *) calloc (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'; 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); 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * *diCount); 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * *diCount); 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)); memset (itemList, 0, sizeof(VMS_ITMLST) * (devInfoListCount)); returnBuffers = (char **) malloc (sizeof (char *) * devInfoListCount); returnLengths = malloc (sizeof(short) * devInfoListCount); for (i = 0; i < devInfoListCount; i++) { returnBuffers[i] = malloc (devInfoList[i].bufferLen + 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 *) _realloc ((char *) *diskInfo, sizeof (diDiskInfo_t) * (Size_t) *diCount); 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.34/C/getoptn.h0000444000175000017500000000270012076642270012162 0ustar bllbll/* * $Id: getoptn.h,v 1.5 2013-01-18 08:33:42-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/getoptn.h,v $ * Copyright 2011-2013 Brad Lanam, Walnut Creek, CA */ #ifndef __INC_GETOPTN_H_ #define __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 [])); #endif /*__INC_GETOPTN_H_ */ di-4.34/C/features/0000755000175000017500000000000012076642270012152 5ustar bllblldi-4.34/C/features/env.dat0000444000175000017500000000063212076642270013433 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_clang cflags addcflag -Wextra addcflag -Wno-unused-but-set-variable addcflag -Wno-unused-parameter addcflag -Wno-float-equal addcflag -Wno-shift-sign-overflow ldflags libs extension obj extension exe cmd_msgfmt di-4.34/C/features/getoptn.dat0000444000175000017500000000064112076642270014323 0ustar bllbll# # $Id: getoptn.dat,v 1.2 2011-10-05 18:28:21-07 bll Exp $ # $Source: /home/bll/DI/di/C/features/RCS/getoptn.dat,v $ # Copyright 2006-2011 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.34/C/features/mkconfig.dat0000444000175000017500000001707112076642270014445 0ustar bllbll# # $Id: mkconfig.dat,v 1.80 2013-01-18 08:34:07-08 bll Exp $ # $Source: /home/bll/DI/di/C/features/RCS/mkconfig.dat,v $ # Copyright 2006-2011 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 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 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 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 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 # 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 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.34/C/dimntopt.h0000444000175000017500000000704012076642270012342 0ustar bllbll/* * $Id: dimntopt.h,v 1.11 2013-01-18 08:32:56-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/dimntopt.h,v $ * Copyright 2011 Brad Lanam, Walnut Creek, CA */ #ifndef __INC_DIMNTOPT_H_ #define __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 /* __INC_DIMNTOPT_H_ */ di-4.34/C/getoptn.c0000444000175000017500000007615512076642270012174 0ustar bllbll/* * $Id: getoptn.c,v 1.12 2013-01-19 16:52:02-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/getoptn.c,v $ * Copyright 2011-2013 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 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, char *tag, Size_t sz) #else dooptchecks (info, opt, optinfo, tag, sz) getoptn_info_t *info; getoptn_opt_t *opt; getoptn_optinfo_t *optinfo; 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 void #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; } } if (opt->option_type == GETOPTN_BOOL) { int *v; if (dooptchecks (info, opt, optinfo, "bool", sizeof(int)) != 0) { return; } 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; } 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; } 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; } 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; } 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; } 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; } v = (const char **) opt->valptr; *v = ptr; } 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; } 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; } 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); } } int #if _proto_stdc getoptn (int style, int argc, const char * const argv [], Size_t optcount, getoptn_opt_t opts []) #else getoptn (style, argc, argv, optcount, opts) int style; int argc; const char * const argv []; Size_t optcount; getoptn_opt_t opts []; #endif { int i; 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; 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); } continue; } opt = &opts[i]; process_opt (&info, opt, &info.optinfo[i]); } 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 optidx; int ac; const char *av[10]; int rc; 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abc123") != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 1 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 1 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 13 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 14 || optidx != 3) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 15 || j != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 16 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || j != 5 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 17 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 7 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (l != 19 || optidx != 3) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 1 || j != 1 || optidx != 3) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 1 || j != 1 || k != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || j != 0 || k != 1 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abc") != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (fabs(d - 1.2) > 0.00001 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abcd") != 0 || i != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abcde") != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abcdef") != 0 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (sp, "0123") != 0 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (sp, "01234") != 0 || optidx != 2) { 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] = "-p012345"; av[2] = NULL; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (sp, "012345") != 0 || optidx != 2) { 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] = "-S"; av[2] = NULL; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (sp, "abc1234") != 0 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 25 */ ++testno; sp = ""; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-p=0123456"; av[2] = NULL; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (sp, "0123456") != 0 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 26 */ ++testno; memset (s, '\0', sizeof (s)); i = 0; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-sabcd"; av[2] = NULL; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "") != 0 || i != 1 || optidx != 2) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 28 */ ++testno; i = 1; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "--b"; av[2] = NULL; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 29 */ ++testno; i = 1; j = 1; ac = 3; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-b"; av[2] = "-c"; av[3] = NULL; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || j != 0 || optidx != 3) { fprintf (stderr, "fail test %d\n", testno); 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || j != 0 || k != 1 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 31 */ ++testno; i = 1; j = 1; k = 1; ac = 2; sprintf (tmp, "test %d", testno); av[0] = tmp; av[1] = "-bc"; av[2] = NULL; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 1 || j != 1 || k != 0 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } /* test 32 - 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || optidx != 2) { fprintf (stderr, "fail test %d\n", testno); 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; fprintf (stderr, "** expect argument missing\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || optidx != 2) { 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; fprintf (stderr, "** expect invalid size\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || l != 0 || optidx != 2) { 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; fprintf (stderr, "** expect invalid size\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || l != 0 || optidx != 2) { 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; fprintf (stderr, "** expect invalid size\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || l != 0 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 7 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 7 || optidx != 2) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "-s") != 0 || optidx != 3) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abc") != 0 || i != 1 || j != 1 || optidx != 5) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s, "abc") != 0 || i != 1 || j != 1 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "abc") != 0 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "abcd") != 0 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "abcd") != 0 || optidx != 3) { 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; optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "abcd") != 0 || optidx != 3) { 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; fprintf (stderr, "** expect invalid pointer\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "") != 0) { 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; fprintf (stderr, "** expect invalid pointer\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "") != 0) { 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; fprintf (stderr, "** expect invalid pointer\n"); optidx = getoptn (GETOPTN_MODERN, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (strcmp (s2, "") != 0) { 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0 || j != 1) { fprintf (stderr, "fail test %d\n"); 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; optidx = getoptn (GETOPTN_LEGACY, ac, av, sizeof (opts) / sizeof (getoptn_opt_t), opts); if (i != 0) { fprintf (stderr, "fail test %d\n", testno); grc = 1; } return grc; } #endif /* TEST_GETOPTN */ di-4.34/C/realloc.c0000444000175000017500000000141412076642270012117 0ustar bllbll/* * $Id: realloc.c,v 1.8 2010-07-14 01:54:55-07 bll Exp $ * $Source: /home/bll/DI/di/RCS/realloc.c,v $ * Copyright 1994-2010 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 /* * * portable realloc * some variants don't accept a null pointer for initial allocation. * */ _pvoid #if _proto_stdc _realloc (_pvoid ptr, Size_t size) #else _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.34/C/display.h0000444000175000017500000000067712076642270012162 0ustar bllbll#ifndef _INC_DISPLAY_H #define _INC_DISPLAY_H #include "config.h" #include "di.h" # if defined (__cplusplus) || defined (c_plusplus) extern "C" { # endif /* display.c */ extern void 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 /* _INC_DISPLAY_H */ di-4.34/C/strdup.c0000444000175000017500000000152612076642270012023 0ustar bllbll/* * $Id: strdup.c,v 1.5 2010-07-14 01:55:00-07 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/strdup.c,v $ * Copyright 1994-2010 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 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.34/C/trimchar.c0000444000175000017500000000124212076642270012306 0ustar bllbll/* * $Id: trimchar.c,v 1.9 2011-09-26 17:50:45-07 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/trimchar.c,v $ * Copyright 1994-2011 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.34/C/didiskutil.c0000444000175000017500000003205112076642270012644 0ustar bllbll/* * $Id: didiskutil.c,v 1.18 2013-01-18 08:32:21-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/didiskutil.c,v $ * Copyright 1994-2011 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 /********************************************************/ /* 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 (strcmp (diskInfo->fsType, "nfs") == 0 || strcmp (diskInfo->fsType, "nfs3") == 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.34/C/options.c0000444000175000017500000005760712076642270012210 0ustar bllbll/* * $Id: options.c,v 1.9 2013-01-18 08:33:48-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/options.c,v $ * * Copyright 1994-2013 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 struct pa_tmp { diData_t *diData; diOptions_t *diopts; diOutput_t *diout; char *dbsstr; Size_t dbsstr_sz; }; typedef struct { _print_size_t size; char *disp[2]; } dispTable_t; static dispTable_t dispTable [] = { { 0.0, { "KBytes", "KBytes" } }, { 0.0, { "Megs", "Mebis" } }, { 0.0, { "Gigs", "Gibis" } }, { 0.0, { "Teras", "Tebis" } }, { 0.0, { "Petas", "Pebis" } }, { 0.0, { "Exas", "Exbis" } }, { 0.0, { "Zettas", "Zebis" } }, { 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 void 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 *)); # 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]; if (ptr == (char *) NULL || strcmp (ptr, "") == 0) { return; } dptr = (char *) NULL; dptr = strdup (ptr); if (dptr == (char *) NULL) { fprintf (stderr, "strdup failed in main() (1). errno %d\n", errno); exit (1); } 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); /* ### legal here? */ } } 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; diOptions_t *diopts; diOutput_t *diout; diopts = &diData->options; diout = &diData->output; strncpy (dbsstr, DI_DEFAULT_DISP_SIZE, sizeof (dbsstr)); /* default */ 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)); } /* gnu df */ if ((ptr = getenv ("DF_BLOCK_SIZE")) != (char *) NULL) { strncpy (dbsstr, ptr, sizeof (dbsstr)); } 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; 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 }, { "--csv-output", GETOPTN_ALIAS, (void *) "-c", 0, NULL }, { "-d", GETOPTN_STRING, NULL /*dbsstr*/, 0 /*dbsstr_sz*/, NULL }, { "--display-size", GETOPTN_ALIAS, (void *) "-d", 0, NULL }, { "--dont-resolve-symlink", GETOPTN_ALIAS, /* 10 */ (void *) "-R", 0, NULL }, { "-f", GETOPTN_STRPTR, /* 11 */ 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, /* 15 */ NULL /*dbsstr*/, 0 /*dbsstr_sz*/, (void *) "h" }, { "-H", GETOPTN_STRING, /* 16 */ 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, /* 20 */ (void *) "-x", 0, NULL }, { "-I", GETOPTN_FUNC_VALUE, /* 21 */ 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, /* 25 */ (void *) "-l", 0, NULL }, { "-L", GETOPTN_BOOL, /* 26 */ 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, /* 30 */ NULL /*&padata*/, 0, NULL /*processOptions*/ }, { "--portability", GETOPTN_ALIAS, /* 31 */ (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, /* 35 */ NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "--si", GETOPTN_FUNC_BOOL, /* 36 */ NULL /*&padata*/, 0, NULL /*processOptions*/ }, { "--sync", GETOPTN_IGNORE, /* 37 */ NULL, 0, NULL }, { "-t", GETOPTN_BOOL, NULL /*&diopts->printTotals*/, 0 /*sizeof (diopts->printTotals)*/, NULL }, { "--total",GETOPTN_ALIAS, (void *) "-t", 0, NULL }, { "--type", GETOPTN_ALIAS, /* 40 */ (void *) "-I", 0, NULL }, { "-v", GETOPTN_IGNORE, /* 41 */ NULL, 0, NULL }, { "--version", GETOPTN_FUNC_BOOL, /* 42 */ 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, /* 46 */ (void *) "-x", 0, NULL }, { "-X", GETOPTN_FUNC_VALUE, NULL /*&padata*/, 0, NULL /*processOptionsVal*/ }, { "-z", GETOPTN_STRING, /* 48 */ 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[] = { 8, 14, 15, 16, 23, 27 }; static int paidb[] = { 1, 17, 19, 30, 36, 42, }; static int paidv[] = { 3, 21, 35, 45, 47 }; 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[11].valptr = (void *) &diopts->formatString; /* -f */ opts[24].valptr = (void *) &diopts->localOnly; /* -l */ opts[24].valsiz = sizeof (diopts->localOnly); opts[26].valptr = (void *) &diopts->excludeLoopback; /* -L */ opts[26].valsiz = sizeof (diopts->excludeLoopback); opts[28].valptr = (void *) &diopts->printHeader; /* -n */ opts[28].valsiz = sizeof (diopts->printHeader); opts[33].valptr = (void *) &diopts->quota_check; /* -q */ opts[33].valsiz = sizeof (diopts->quota_check); opts[34].valptr = (void *) &diopts->dontResolveSymlink; /* -R */ opts[34].valsiz = sizeof (diopts->dontResolveSymlink); opts[38].valptr = (void *) &diopts->printTotals; /* -t */ opts[38].valsiz = sizeof (diopts->printTotals); opts[43].valptr = (void *) &diout->width; /* -w */ opts[43].valsiz = sizeof (diout->width); opts[44].valptr = (void *) &diout->inodeWidth; /* -W */ opts[44].valsiz = sizeof (diout->inodeWidth); opts[48].valptr = (void *) diData->zoneInfo.zoneDisplay; /* -z */ opts[48].valsiz = sizeof (diData->zoneInfo.zoneDisplay); opts[49].valptr = (void *) diData->zoneInfo.zoneDisplay; /* -Z */ opts[49].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; } for (i = 0; i < (int) (sizeof (paidv) / sizeof (int)); ++i) { opts[paidv[i]].valptr = (void *) &padata; opts[paidv[i]].value2 = (void *) processOptionsVal; } 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); 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(); exit (0); } 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 = 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); exit (0); } 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; padata = (struct pa_tmp *) valptr; if (strcmp (arg, "-B") == 0) { if (isdigit ((int) (*value))) { padata->diopts->baseDispSize = atof (value); padata->diopts->baseDispIdx = DI_DISP_1000_IDX; /* unknown, really */ if (padata->diopts->baseDispSize == DI_VAL_1024) { padata->diopts->baseDispIdx = DI_DISP_1024_IDX; } } else if (strcmp (value, "k") == 0) { padata->diopts->baseDispSize = DI_VAL_1024; padata->diopts->baseDispIdx = DI_DISP_1024_IDX; } else if (strcmp (value, "d") == 0 || strcmp (value, "si") == 0) { padata->diopts->baseDispSize = DI_VAL_1000; padata->diopts->baseDispIdx = DI_DISP_1000_IDX; } } else if (strcmp (arg, "-I") == 0) { parseList (&padata->diData->includeList, value); } else if (strcmp (arg, "-s") == 0) { strncpy (padata->diopts->sortType, value, sizeof (padata->diopts->sortType)); /* 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 void #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); exit (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 **) _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); exit (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); exit (1); } strncpy (lptr, ptr, (Size_t) len); lptr[len] = '\0'; list->list [i] = lptr; ptr += len + 1; } free ((char *) dstr); } /* * 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 = atof (ptr); } else { val = 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 = DI_DISP_HR; diout->dispBlockLabel = "Size"; break; } case 'H': { val = DI_DISP_HR_2; diout->dispBlockLabel = "Size"; break; } default: { if (strncmp (ptr, "HUMAN", (Size_t) 5) == 0) { val = 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 = DI_VAL_1000; diopts->baseDispIdx = DI_DISP_1000_IDX; } } if (val == 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 == DI_VAL_512) { diout->dispBlockLabel = "512-blocks"; } if (diopts->posix_compat && val == 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; } } di-4.34/C/options.h0000444000175000017500000000162312076642270012200 0ustar bllbll#ifndef _INC_OPTIONS_H #define _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 /* _INC_OPTIONS_H */ di-4.34/C/digetinfo.c0000444000175000017500000004062112076642270012451 0ustar bllbll/* * $Id: digetinfo.c,v 1.23 2013-01-18 14:12:59-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/digetinfo.c,v $ * Copyright 1994-2011 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.34/C/strstr.c0000444000175000017500000000154012076642270012037 0ustar bllbll/* * $Id: strstr.c,v 1.5 2010-07-14 01:55:05-07 bll Exp $ * $Source: /home/bll/DI/di/RCS/strstr.c,v $ * Copyright 1994-2010 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.34/C/di.c0000444000175000017500000010755112076642270011103 0ustar bllbll/* * $Id: di.c,v 2.128 2013-01-18 08:32:05-08 bll Exp $ * $Source: /home/bll/DI/di/C/RCS/di.c,v $ * * Copyright 1994-2013 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 "di.h" #include "version.h" #include "display.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 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 int debug = { 0 }; #if defined (__cplusplus) || defined (c_plusplus) extern "C" { #endif static void checkDiskInfo _((diData_t *, int)); static void checkDiskQuotas _((diData_t *)); static int checkFileInfo _((diData_t *, int, int, const char *const[])); #if _lib_zone_list && _lib_getzoneid && _lib_zone_getattr static void checkZone _((diDiskInfo_t *, zoneInfo_t *, unsigned int)); #endif static void cleanup _((diData_t *)); static int getDiskSpecialInfo _((diData_t *, unsigned int)); static void getDiskStatInfo _((diData_t *)); static void preCheckDiskInfo _((diData_t *)); static void checkIgnoreList _((diDiskInfo_t *, iList_t *)); static void checkIncludeList _((diDiskInfo_t *, iList_t *)); static void initLocale _((void)); static void initZones _((diData_t *)); static int isIgnoreFSType _((char *)); static int checkForUUID _((char *)); #if defined (__cplusplus) || defined (c_plusplus) } #endif int #if _proto_stdc main (int argc, const char * argv []) #else main (argc, argv) int argc; const char * argv []; #endif { diData_t diData; diOptions_t *diopts; diOutput_t *diout; int hasLoop; int optidx; /* initialization */ 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 = 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 = DI_VAL_1024; diopts->baseDispIdx = DI_DISP_1024_IDX; diopts->quota_check = TRUE; diopts->csv_output = FALSE; 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; initLocale (); /* first argument is defaults */ optidx = getDIOptions (argc, argv, &diData); initZones (&diData); if (debug > 0) { printf ("di version %s\n", DI_VERSION); } /* main processing */ if (di_getDiskEntries (&diData.diskInfo, &diData.count) < 0) { cleanup (&diData); exit (1); } 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); exit (1); } } di_getDiskInfo (&diData.diskInfo, &diData.count); checkDiskInfo (&diData, hasLoop); if (diopts->quota_check == TRUE) { checkDiskQuotas (&diData); } printDiskInfo (&diData); cleanup (&diData); return 0; } /* * cleanup * * free up allocated memory * */ static 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); } } static 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; int foundval = { 0 }; diDiskInfo_t *found_dinfo = { (diDiskInfo_t *) NULL }; 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 ispooled; int startpool; int poolmain; ispooled = FALSE; 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)) { ispooled = TRUE; if (lastpoollen == 0 || strncmp (lastpool, dinfo->special, lastpoollen) != 0) { strncpy (lastpool, dinfo->special, sizeof (lastpool)); 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 > foundval) { foundval = foundnew; found_dinfo = dinfo; } 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; } } /* for each file specified on command line */ /* turn everything else off */ for (j = 0; j < diData->count; ++j) { diDiskInfo_t *dinfo; dinfo = &diData->diskInfo[j]; if (dinfo == found_dinfo) { dinfo->printFlag = DI_PRNT_FORCE; } else if (dinfo->printFlag == DI_PRNT_OK && ! diopts->displayAll) { dinfo->printFlag = DI_PRNT_IGNORE; } } return rc; } /* * getDiskStatInfo * * gets the disk device number for each entry. * */ static 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. * */ static 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; 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; lstat (dinfo->special, &tstatBuf); if (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. * */ static 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 < 0L) { dinfo->freeSpace = 0L; } if ((_s_fs_size_t) dinfo->availSpace < 0L) { 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); } } if ((_s_fs_size_t) dinfo->totalSpace <= 0L) { 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 */ } static 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) * */ static 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 static void initLocale () { #if _enable_nls || (_lib_setlocale && defined (LC_ALL)) char *ptr; #endif #if _enable_nls char *localeptr; #endif #if _lib_setlocale && defined (LC_ALL) ptr = setlocale (LC_ALL, ""); #endif #if _enable_nls if ((localeptr = getenv ("DI_LOCALE_DIR")) == (char *) NULL) { localeptr = DI_LOCALE_DIR; } ptr = bindtextdomain ("di", localeptr); ptr = textdomain ("di"); #endif } static 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); exit (1); } 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); exit (1); } } } 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; } 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; } di-4.34/C/version.h0000444000175000017500000000012212076642270012163 0ustar bllbll#ifndef _INC_VERSION_H #define _INC_VERSION_H # define DI_VERSION "4.34" #endif di-4.34/C/tests.d/0000755000175000017500000000000012076642270011720 5ustar bllblldi-4.34/C/tests.d/rpmbuild.sh0000555000175000017500000000175212076642270014100 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 rpmbuild maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ . $_MKCONFIG_DIR/bin/shellfuncs.sh locatecmd locrpmbuild rpmbuild if [ "${locrpmbuild}" = "" ];then echo ${EN} " skipped${EC}" >&5 exit 0 fi rvers=`rpmbuild --version | tr -cd '0-9' | sed 's/^\(...\).*/\1/'` if [ $rvers -lt 470 ]; then echo ${EN} " old version skipped${EC}" >&5 exit 0 fi march=`rpmbuild --showrc | grep '^build arch' | sed 's/.*: *//'` echo "## 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.34/C/tests.d/env.sh0000555000175000017500000000215112076642270013044 0ustar bllbll#!/bin/sh . $_MKCONFIG_DIR/bin/testfuncs.sh maindodisplay $1 'check environment in make' maindoquery $1 $_MKC_ONCE getsname $0 dosetup $@ cd ${_MKCONFIG_RUNTOPDIR} rc=$? if [ $rc -ne 0 ]; then echo "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 echo "ERROR: Unable to cd to ${_MKCONFIG_TSTRUNTMPDIR}" exit $rc fi echo "${_MKCONFIG_SYSTYPE} ${_MKCONFIG_SYSREV} ${_MKCONFIG_SYSARCH} ${CC} ${_MKCONFIG_USING_GCC} ${CFLAGS} ${LDFLAGS} ${LIBS} ${OBJ_EXT} ${EXE_EXT} ${XMSGFMT}" | sed -e 's/^ *//' -e 's/ *$//' > e1 chkdiff e1 e2 testcleanup e1 e2 env.log exit $grc di-4.34/C/tests.d/compshpl.sh0000555000175000017500000000266512076642270014113 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.34/C/tests.d/getoptn.txt0000444000175000017500000000071112076642270014136 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.34/C/tests.d/getoptn.sh0000555000175000017500000000111512076642270013733 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 chkdiff ${_MKCONFIG_RUNTESTDIR}/getoptn.txt \ ${_MKCONFIG_TSTRUNTMPDIR}/getoptn_test.out fi exit $grc di-4.34/C/tests.d/test_order0000444000175000017500000000006012076642270014007 0ustar bllbll1 env 2 getoptn 3 buildpl 4 compshpl 5 rpmbuild di-4.34/C/tests.d/buildpl.sh0000555000175000017500000000072312076642270013712 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.34/mktar.sh0000555000175000017500000000102512076642270011623 0ustar bllbll#!/bin/sh ver=`grep DI_VERSION C/version.h | sed -e 's/"$//' -e 's/.*"//'` PKG=di 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 chmod -R a+r ${dir} cwd=$(pwd) (cd $dir;tar xfz $cwd/mkconfig/mkconfig-*.tar.gz;mv mkconfig-* mkconfig) tar cf - ${dir} | gzip -9 > ${dir}.tar.gz rm -rf ${dir} > /dev/null 2>&1 exit 0 di-4.34/tests.d/0000755000175000017500000000000012076642270011536 5ustar bllblldi-4.34/tests.d/diinst.sh0000555000175000017500000000215312076642270013366 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 echo ${EN} " ${d}${EC}" >&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 echo ${EN} "*${EC}" >&5 fi else if [ $d = C ]; then echo "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.34/tests.d/buildsh.sh0000555000175000017500000001033412076642270013526 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 echo ${EN} " ${d}${EC}" >&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. # 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 # SCO_SV: warning: `/*' within comment # clang: 'warning: unknown warning option' # clang: X warnings? generated. # many: unrecognized #pragma ignored # 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 '^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 [^ ]*.c:[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 FLAGS= | grep -v -- '--' | cat > make_extra.log extra=`cat make_extra.log | wc -l | sed -e 's/^ *//'` if [ $extra -ne 0 ]; then echo "## 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.34/tests.d/ditot.sh0000555000175000017500000000237412076642270013224 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 echo ${EN} " ${d}${EC}" >&5 for format in $FORMATS; do echo "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 echo ${EN} "*${EC}" >&5 echo "## format: $format failed" grc=1 fi done else if [ $d = C ]; then echo "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.34/tests.d/dinls.sh0000555000175000017500000000371412076642270013211 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 echo ${EN} " ${d}${EC}" >&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 echo ${EN} " skipped${EC}" >&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 echo ${EN} " de/es not installed?${EC}" >&5 grc=0 fi else if [ $d = C ]; then echo "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.34/tests.d/diexec.sh0000555000175000017500000000165212076642270013340 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 echo ${EN} " ${d}${EC}" >&5 ${tdir}/di grc=$? if [ $grc -ne 0 ]; then echo ${EN} "*${EC}" >&5 else # look for invalid floating point numbers ${tdir}/di -n | egrep '(inf|nan)' rc=$? if [ $rc -eq 0 ]; then echo ${EN} "*${EC}" >&5 grc=1 fi fi else if [ $d = C ]; then echo "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.34/tests.d/disort.sh0000555000175000017500000000566712076642270013415 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 echo ${EN} " ${d}${EC}" >&5 echo "## regular sort first, then di sort" echo "by special" ${tdir}/di -n -a -f S | sort > s1 ${tdir}/di -n -a -f S -ss > s2 dotest echo "by special reverse" ${tdir}/di -n -a -f S | sort -r > s1 ${tdir}/di -n -a -f S -srs > s2 dotest echo "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 echo "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 echo "by mount" ${tdir}/di -n -a -f M | sort -t'~' > s1 ${tdir}/di -n -a -f M -sm > s2 dotest echo "by mount reverse" ${tdir}/di -n -a -f M | sort -r > s1 ${tdir}/di -n -a -f M -srm > s2 dotest echo "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 echo "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 echo "by type" ${tdir}/di -n -a -f T | sort > s1 ${tdir}/di -n -a -f T -st > s2 dotest echo "by type reverse" ${tdir}/di -n -a -f T | sort -r > s1 ${tdir}/di -n -a -f T -srt > s2 dotest echo "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 echo "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 echo "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 echo "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 echo ${EN} "*${EC}" >&5 fi else if [ $d = C ]; then echo "## no di executable found for dir $d" echo ${EN} "*${EC}" >&5 grc=1 fi fi done exit $grc di-4.34/tests.d/diarg.sh0000555000175000017500000000703112076642270013162 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 echo "## $cmd failed with output:" echo $o lrc=1 else echo "## $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 \ -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 --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 echo ${EN} " ${d}${EC}" >&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 echo "## 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 echo ${EN} "*${EC}" >&5 grc=1 fi else if [ $d = C ]; then echo "## no di executable found for dir $d" grc=1 fi fi done exit $grc di-4.34/tests.d/test_order0000444000175000017500000000007512076642270013633 0ustar bllbll1 buildsh 2 diexec 3 diarg 3 disort 3 ditot 4 diinst 5 dinls di-4.34/MANIFEST0000444000175000017500000000555312076642270011311 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.win config.h for windows C/configs/conf.xenix.cc config.h for XENIX C/di.c di source C/di.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/getoptn.dat getoptn test configuration C/features/mkconfig.dat mkconfig 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/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.34/README0000444000175000017500000007052512076642270011041 0ustar bllblldi - disk information utility (version 4.34) CONTENTS Description Installation 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 config.win or config.mingw Cygwin gcc: cd C;make -e windows-gcc MinGW: cd C;mingw32-make MAKE=mingw32-make CC=mingw32-gcc windows-mingw Alternative 2 - builds a new config.h file (Cygwin). make -e config.h make -e 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. 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 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, Irix, 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. 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.34 has been tested on the following platforms: AIX 7.1 (64-bit) CentOS 3.9, 4.8, 5.2, 5.3, 5.4, 5.5, 6.3 Debian 4.0, 5.0, 6.0, 6-kFreeBSD 8.1 DragonflyBSD 2.10.1, 3.2.1 Fedora 7, 12, 13, 14, 16 FreeBSD 4.9, 5.1, 6.0, 7.0, 7.1, 7.2, 8.0, 8.1, 8.2, 9.0, 9.1 Gentoo 20120710 Haiku r1a3 HP-UX 11.11 LinuxMint 11 (32-bit, 64-bit) Mandrake 9.2 Mandriva 2011 NetBSD 1.6.2, 2.0.2, 3.0.1, 4.0.1, 5.0.1, 5.1, 6.0 Nexenta 1.0.1_b85, 2.0_b104 OpenBSD 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0 OpenSolaris 200805, 200906 QNX 6.3 RedHat 7.1, 7.3 SCO OpenServer 6.0.0 SCO Xenix Solaris 2.6, 8, 9, 10, 11 Tru64 5.1B ULTRIX 4.5 UnixWare 7.1.4 Windows - Cygwin Windows - MinGW 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, 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.34 [19 Jan 2013] 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 [15 Nov 2012] 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 [21 Oct 2012] 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 [20 Nov 2011] 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 [8 Oct 2011] 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 [30 Sep 2011] 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 [11 Sep 2011] 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 [29 Dec 2010] 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 [25 Jul 2010] Fix FreeBSD 5 panic when trying to get quotas on devfs. Updated build system to mkconfig-1.10. 4.25 [4 Jul 2010] 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 [14 May 2010] 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 [10 May 2010] 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 [2 May 2010] Updated to use mkconfig 1.3. Fixes problem with linking in unneeded libraries. Replaced hasnls program with a shell script. 4.21 [11 Apr 2010] Fixed features/turnoffnls.sh. Makefile cleanup (Mike Frysinger). 4.20 [7 mar 2010] 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 [1 Feb 2010] 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 [29 Nov 2009] 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 [22 Nov 2009] 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 [20 Sep 2009] Fixed a nested macro issue on Mac OS X 10.6. Fixed bugs with filename arguments. 4.15 [17 Sep 2009] Fixed filename argument w/non-printing filesystem. Build now works on Haiku. 4.14 [10 Sep 2009] Code cleanup. Change size labels to match SI standards (1024 vs 1000). Build now works on Debian GNU-kFreeBSD. 4.13 [25 May 2008] 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-2013 Brad Lanam, Walnut Creek, CA, USA brad.lanam.di_at_gmail.com http://www.gentoo.com/di/ di-4.34/po/0000755000175000017500000000000012076642270010570 5ustar bllblldi-4.34/po/de.po0000444000175000017500000001147212076642270011523 0ustar bllbll# $Id: de.po,v 1.10 2012-01-20 15:36:05-08 bll Exp $ msgid "" msgstr "" "Project-Id-Version: di $Revision: 1.10 $\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.34/po/es.po0000444000175000017500000001167012076642270011542 0ustar bllbll# $Id: es.po,v 1.5 2012-01-20 15:36:13-08 bll Exp $ msgid "" msgstr "" "Project-Id-Version: di $Revision: 1.5 $\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.34/po/en.po0000444000175000017500000001137612076642270011540 0ustar bllbll# $Id: en.po,v 1.12 2012-01-20 15:36:10-08 bll Exp $ msgid "" msgstr "" "Project-Id-Version: di $Revision: 1.12 $\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"