From 0727bfcaf2bd48bf501a7fa95515c400a1996902 Mon Sep 17 00:00:00 2001 From: Bryan Jurish Date: Thu, 2 Feb 2006 12:49:19 +0000 Subject: initial cvs import svn path=/trunk/externals/moocow/; revision=4536 --- readdir/COPYING | 290 ++++++++++++++++++++++++++++++++++++++++++++ readdir/Changes | 7 ++ readdir/Makefile.am | 98 +++++++++++++++ readdir/README.cvs | 13 ++ readdir/README.pod | 46 +++++++ readdir/autogen.sh | 48 ++++++++ readdir/config/Makefile.am | 66 ++++++++++ readdir/configure.in | 197 ++++++++++++++++++++++++++++++ readdir/src/Makefile.am | 135 +++++++++++++++++++++ readdir/src/readdir-help.pd | 41 +++++++ readdir/src/readdir-test.pd | 28 +++++ readdir/src/readdir.c | 278 ++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 1247 insertions(+) create mode 100644 readdir/COPYING create mode 100644 readdir/Changes create mode 100644 readdir/Makefile.am create mode 100644 readdir/README.cvs create mode 100644 readdir/README.pod create mode 100755 readdir/autogen.sh create mode 100644 readdir/config/Makefile.am create mode 100644 readdir/configure.in create mode 100644 readdir/src/Makefile.am create mode 100644 readdir/src/readdir-help.pd create mode 100644 readdir/src/readdir-test.pd create mode 100644 readdir/src/readdir.c (limited to 'readdir') diff --git a/readdir/COPYING b/readdir/COPYING new file mode 100644 index 0000000..fa0bef4 --- /dev/null +++ b/readdir/COPYING @@ -0,0 +1,290 @@ +GNU GENERAL PUBLIC LICENSE + +Version 2, June 1991 + +Copyright (C) 1989, 1991 Free Software Foundation, Inc. +59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + +Everyone is permitted to copy and distribute verbatim copies +of this license document, but changing it is not allowed. + +Preamble + +The licenses for most software are designed to take away your freedom +to share and change it. By contrast, the GNU General Public License is +intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This General +Public License applies to most of the Free Software Foundation's +software and to any other program whose authors commit to using it. +(Some other Free Software Foundation software is covered by the +GNU Library General Public License instead.) You can apply it to your +programs, too. + +When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new free +programs; and that you know you can do these things. + +To protect your rights, we need to make restrictions that forbid anyone +to deny you these rights or to ask you to surrender the rights. These +restrictions translate to certain responsibilities for you if you distribute +copies of the software, or if you modify it. + +For example, if you distribute copies of such a program, whether gratis +or for a fee, you must give the recipients all the rights that you have. You +must make sure that they, too, receive or can get the source code. And +you must show them these terms so they know their rights. + +We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + +Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, +we want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + +Finally, any free program is threatened constantly by software patents. +We wish to avoid the danger that redistributors of a free program will +individually obtain patent licenses, in effect making the program +proprietary. To prevent this, we have made it clear that any patent must +be licensed for everyone's free use or not licensed at all. + +The precise terms and conditions for copying, distribution and +modification follow. + +TERMS AND CONDITIONS FOR +COPYING, DISTRIBUTION AND +MODIFICATION + +0. This License applies to any program or other work which contains a +notice placed by the copyright holder saying it may be distributed under +the terms of this General Public License. The "Program", below, refers +to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, either +verbatim or with modifications and/or translated into another language. +(Hereinafter, translation is included without limitation in the term +"modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of running +the Program is not restricted, and the output from the Program is +covered only if its contents constitute a work based on the Program +(independent of having been made by running the Program). Whether +that is true depends on what the Program does. + +1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the notices +that refer to this License and to the absence of any warranty; and give +any other recipients of the Program a copy of this License along with the +Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + +2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide a + warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but does + not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, and +can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based on +the Program, the distribution of the whole must be on the terms of this +License, whose permissions for other licensees extend to the entire +whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest your +rights to work written entirely by you; rather, the intent is to exercise the +right to control the distribution of derivative or collective works based +on the Program. + +In addition, mere aggregation of another work not based on the +Program with the Program (or with a work based on the Program) on a +volume of a storage or distribution medium does not bring the other +work under the scope of this License. + +3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding + machine-readable source code, which must be distributed under + the terms of Sections 1 and 2 above on a medium customarily + used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your cost + of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a + medium customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with + such an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to control +compilation and installation of the executable. However, as a special +exception, the source code distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies the +executable. + +If distribution of executable or object code is made by offering access to +copy from a designated place, then offering equivalent access to copy +the source code from the same place counts as distribution of the source +code, even though third parties are not compelled to copy the source +along with the object code. + +4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt otherwise +to copy, modify, sublicense or distribute the Program is void, and will +automatically terminate your rights under this License. However, parties +who have received copies, or rights, from you under this License will not +have their licenses terminated so long as such parties remain in full +compliance. + +5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and all +its terms and conditions for copying, distributing or modifying the +Program or works based on it. + +6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the original +licensor to copy, distribute or modify the Program subject to these terms +and conditions. You may not impose any further restrictions on the +recipients' exercise of the rights granted herein. You are not responsible +for enforcing compliance by third parties to this License. + +7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot distribute +so as to satisfy simultaneously your obligations under this License and +any other pertinent obligations, then as a consequence you may not +distribute the Program at all. For example, if a patent license would not +permit royalty-free redistribution of the Program by all those who +receive copies directly or indirectly through you, then the only way you +could satisfy both it and this License would be to refrain entirely from +distribution of the Program. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any patents +or other property right claims or to contest validity of any such claims; +this section has the sole purpose of protecting the integrity of the free +software distribution system, which is implemented by public license +practices. Many people have made generous contributions to the wide +range of software distributed through that system in reliance on +consistent application of that system; it is up to the author/donor to +decide if he or she is willing to distribute software through any other +system and a licensee cannot impose that choice. + +This section is intended to make thoroughly clear what is believed to be +a consequence of the rest of this License. + +8. If the distribution and/or use of the Program is restricted in certain +countries either by patents or by copyrighted interfaces, the original +copyright holder who places the Program under this License may add an +explicit geographical distribution limitation excluding those countries, so +that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + +9. The Free Software Foundation may publish revised and/or new +versions of the General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may differ in +detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number +of this License, you may choose any version ever published by the Free +Software Foundation. + +10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we +sometimes make exceptions for this. Our decision will be guided by the +two goals of preserving the free status of all derivatives of our free +software and of promoting the sharing and reuse of software generally. + +NO WARRANTY + +11. BECAUSE THE PROGRAM IS LICENSED FREE OF +CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, +TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT +WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE +PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, +EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND +PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD +THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE +COST OF ALL NECESSARY SERVICING, REPAIR OR +CORRECTION. + +12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW +OR AGREED TO IN WRITING WILL ANY COPYRIGHT +HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED +ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING +ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR +INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT +LIMITED TO LOSS OF DATA OR DATA BEING RENDERED +INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE +WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR +OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY +OF SUCH DAMAGES. + +END OF TERMS AND CONDITIONS diff --git a/readdir/Changes b/readdir/Changes new file mode 100644 index 0000000..c124f80 --- /dev/null +++ b/readdir/Changes @@ -0,0 +1,7 @@ +Change log for PD external 'readdir' + +v0.02 Thu, 02 Feb 2006 12:52:35 +0100 + + automake-ified + +v0.01 Sun, 26 Oct 2003 14:06:29 +0100 + + initial version diff --git a/readdir/Makefile.am b/readdir/Makefile.am new file mode 100644 index 0000000..5e5d148 --- /dev/null +++ b/readdir/Makefile.am @@ -0,0 +1,98 @@ +# File: ./Makefile.am +# Package: readdir +# Description: +# + top-level automake file +# +# Process this file with Automake to create Makefile.in. +#----------------------------------------------------------------------- + +#----------------------------------------------------------------------- +# Options & Subdirectories +#----------------------------------------------------------------------- + +## --- automake options +#AUTOMAKE_OPTIONS = foreign dist-bzip2 dist-zip +AUTOMAKE_OPTIONS = foreign + +## --- recursion subdirectories +SUBDIRS = config src + +## --- pseudo-deps for '.SUFFIXES' +SUFFIXES = .pod .txt + +#----------------------------------------------------------------------- +# Variables: cleanup +#----------------------------------------------------------------------- +## --- mostlyclean: built by 'make' & commonly rebuilt +#MOSTLYCLEANFILES = + +## --- clean: built by 'make' +#CLEANFILES = + +## --- distclean: built by 'configure' +DISTCLEANFILES = \ + config.log \ + config.cache \ + config.status + +## -- maintainerclean: built by maintainer / by hand +MAINTAINERCLEANFILES = *~ \ + $(PODS:.pod=.txt) \ + Makefile Makefile.in \ + aclocal.m4 \ + configure \ + install-sh \ + stamp-h.in \ + config.h.in + +maintainer-clean-local: + rm -rf autom4te.cache + +#CVSCLEAN_SUBDIRS = $(SUBDIRS) + +#CVSCLEANFILES = Makefile.in Makefile + + +#----------------------------------------------------------------------- +# Additional Variables & Rules: PODS +#----------------------------------------------------------------------- +PODS = README.pod + +.pod.txt: + pod2text $< $@ + +all-local: $(PODS:.pod=.txt) + +#----------------------------------------------------------------------- +# Variables: distribution +#----------------------------------------------------------------------- + +## --- extra distribution files +EXTRA_DIST = \ + $(PODS:.pod=.txt) autogen.sh configure \ + README.cvs COPYING + +## --- recursion subdirectories for 'make dist' +#DIST_SUBDIRS = $(SUBDIRS) + +## --- dist-hook: when another 'Makefile.am' is overkill +#DISTHOOK_DIRS = foo +#DISTHOOK_FILES = foo/bar.txt foo/baz.txt +#dist-hook: +# for d in $(DISTHOOK_DIRS); do\ +# mkdir -p $(distdir)/$$d ;\ +# done +# for f in $(DISTHOOK_FILES); do\ +# cp -p $(srcdir)/$$f $(distdir)/$$f ;\ +# done + +#dist-bz2: dist-bzip2 ; + + +#----------------------------------------------------------------------- +# Rules: cleanup +#----------------------------------------------------------------------- +.PHONY: cvsclean cvsclean-hook + +cvsclean: maintainer-clean ; + diff --git a/readdir/README.cvs b/readdir/README.cvs new file mode 100644 index 0000000..2a0ee0c --- /dev/null +++ b/readdir/README.cvs @@ -0,0 +1,13 @@ +To build from cvs, do the following: + + ./autogen.sh + ./configure + make + make install + +NOTE: The README.txt file in the distribution +is auto-generated from perl ".pod" format by +the "pod2text" included in most perl distributions. + +marmosets, + Bryan diff --git a/readdir/README.pod b/readdir/README.pod new file mode 100644 index 0000000..cfcb4ab --- /dev/null +++ b/readdir/README.pod @@ -0,0 +1,46 @@ +=pod + +README for pd external 'readdir' + +Last updated for readdir v0.02 + +=head1 DESCRIPTION + +The 'readdir' object lets you read the contents of a directory. + +=head1 INSTALLATION + +Issue the following commands to the shell: + + cd readdir-X.YY (or wherever you extracted the distribution) + ./configure + make + make install + +=head1 BUILD OPTIONS + +The 'configure' script supports the following options, among others: + +=over 4 + +=item * --enable-debug , --disable-debug + +Whether to enable verbose debugging messages. +Default=no. + +=back + +=head1 ACKNOWLEDGEMENTS + +PD by Miller Puckette and others. + +Ideas, black magic, and other nuggets of information drawn +from code by Guenter Geiger, Larry Troxler, and iohannes m zmoelnig. + +=head1 KNOWN BUGS + +None known. + +=head1 AUTHOR + +Bryan Jurish Emoocow@ling.uni-potsdam.deE diff --git a/readdir/autogen.sh b/readdir/autogen.sh new file mode 100755 index 0000000..845f276 --- /dev/null +++ b/readdir/autogen.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +#----------------------------------------------------------------------- +# File: autogen.sh +# Description: +# + wrapper for m4 black-magic +#----------------------------------------------------------------------- + +MY_ALDIRS="." +MY_AHDIRS="." +MY_AMDIRS="." +MY_ACDIRS="." + +test -z "$ACLOCAL" && ACLOCAL=aclocal +test -z "$AUTOHEADER" && AUTOHEADER=autoheader +test -z "$AUTOMAKE" && AUTOMAKE=automake +test -z "$AUTOCONF" && AUTOCONF=autoconf + +if test -n "$MY_ALDIRS"; then + for d in $MY_ALDIRS ; do + echo "(cd $d ; $ACLOCAL)" + (cd $d ; $ACLOCAL) + done +fi + +if test -n "$MY_AHDIRS"; then + for d in $MY_AHDIRS ; do + echo "(cd $d ; $AUTOHEADER)" + (cd $d ; $AUTOHEADER) + done +fi + +if test -n "$MY_AMDIRS"; then + for d in $MY_AMDIRS ; do + echo "(cd $d ; $AUTOMAKE -a)" + (cd $d ; $AUTOMAKE -a) + done +fi + +if test -n "$MY_ACDIRS"; then + for d in $MY_ACDIRS ; do + echo "(cd $d ; $AUTOCONF)" + (cd $d ; $AUTOCONF) + done +fi + +#echo "(./configure)" +#./configure $* diff --git a/readdir/config/Makefile.am b/readdir/config/Makefile.am new file mode 100644 index 0000000..0ab0c12 --- /dev/null +++ b/readdir/config/Makefile.am @@ -0,0 +1,66 @@ +## File: config/Makefile.am +## Package: readdir +## Description: +## + automake file for 'config' package-subdir +## +## Process this file with Automake to create Makefile.in. +##----------------------------------------------------------------------- + +##----------------------------------------------------------------------- +## Variables: options +##----------------------------------------------------------------------- + +##----------------------------------------------------------------------- +## Variables: cleanup +##----------------------------------------------------------------------- + +## --- mostlyclean: built by 'make' & commonly rebuilt +#MOSTLYCLEANFILES = + +## --- clean: built by 'make' +#CLEANFILES = + +## --- distclean: built by 'configure' +#DISTCLEANFILES = + +## -- maintainerclean: built by maintainer / by hand +MAINTAINERCLEANFILES = \ + *~ .*~ \ + compile Makefile Makefile.in \ + config.guess \ + config.sub \ + depcomp \ + install-sh \ + ltmain.sh \ + missing \ + mkinstalldirs \ + texinfo.tex \ + ylwrap + + +##----------------------------------------------------------------------- +## Variables: distribution +##----------------------------------------------------------------------- + +## --- extra distribution files +EXTRA_DIST = \ + Makefile.in \ + depcomp \ + install-sh \ + mkinstalldirs \ + missing + +# config.guess +# config.sub +# ltmain.sh +# texinfo.tex + +## --- recursion subdirectories for 'make dist' +#DIST_SUBDIRS = $(SUBDIRS) + +#----------------------------------------------------------------------- +# Rules: cleanup +#----------------------------------------------------------------------- +.PHONY: cvsclean cvsclean-hook + +cvsclean: maintainer-clean ; diff --git a/readdir/configure.in b/readdir/configure.in new file mode 100644 index 0000000..466924a --- /dev/null +++ b/readdir/configure.in @@ -0,0 +1,197 @@ +dnl Process this file with autoconf to produce a configure script. +dnl -- for a clean build, run: aclocal && autoheader && automake -a && autoconf +AC_PREREQ(2.5) + +dnl Some handy macros +define([THE_PACKAGE_NAME], [readdir]) +define([THE_PACKAGE_VERSION], [0.02]) +define([THE_PACKAGE_AUTHOR], [moocow@ling.uni-potsdam.de]) + +AC_INIT(THE_PACKAGE_NAME, THE_PACKAGE_VERSION, THE_PACKAGE_AUTHOR) + +dnl +dnl source & aux +dnl +AC_CONFIG_AUX_DIR(config) + +dnl +dnl save user's CFLAGS,CPPFLAGS +dnl +UCPPFLAGS="$CPPFLAGS" +UCFLAGS="$CFLAGS" + +dnl +dnl use automake +dnl +AM_INIT_AUTOMAKE(THE_PACKAGE_NAME, THE_PACKAGE_VERSION) + +dnl +dnl use autoheader +dnl +AM_CONFIG_HEADER(src/config.h) + + +dnl +dnl Programs, prefix +dnl +AC_PROG_CC +AC_PROG_INSTALL +AC_PREFIX_DEFAULT(/usr/local) + +dnl +dnl Substitutions +dnl +AC_SUBST(DEFS) +AC_SUBST(AFLAGS) +AC_SUBST(DFLAGS) +AC_SUBST(IFLAGS) +AC_SUBST(LFLAGS) +AC_SUBST(OFLAGS) +AC_SUBST(WFLAGS) +AC_SUBST(LD) + +AC_SUBST(PDEXT) + +dnl version stuff (automatically exported?) +AC_SUBST(PACKAGE_VERSION) +AC_SUBST(PACKAGE_NAME) +AC_SUBST(BUGREPORT) + +dnl other flags +dnl AC_ISC_POSIX + +dnl Checks for header files. +dnl AC_HEADER_STDC +AC_CHECK_HEADERS([dirent.h fcntl.h string.h errno.h], + [], + AC_MSG_WARN([-----------------------------------------------------------------]) + AC_MSG_WARN([could not find standard C headers -- things may get ugly]) + AC_MSG_WARN([-----------------------------------------------------------------]), + [/* nonempty includes: compile only */]) + + +dnl PD externals +PD_OBJECT_EXTERNALS="readdir\$(EXEEXT)" +AC_SUBST(PD_OBJECT_EXTERNALS) + + +dnl +dnl pd-directory/ies +dnl +AC_ARG_WITH(pd-dir, + AC_HELP_STRING([--with-pd-dir=DIR], [PD base directory (default=PREFIX/pd)]), + [pddir="$withval"], + [pddir="\${prefix}/pd"]) +pddocdir="${pddir}/doc/5.reference" +AC_SUBST(pddir) +AC_SUBST(pddocdir) + + + +AC_ARG_WITH(pd-include, + AC_HELP_STRING([--with-pd-include=DIR], [PD include directory (default=NONE)]), + [pdincludedir="$withval"], + [pdincludedir=""]) +if test -n "$pdincludedir" ; then + IFLAGS="$IFLAGS -I$pdincludedir" +fi +AC_SUBST(pdincludedir) + +AC_ARG_WITH(pd-extdir, + AC_HELP_STRING([--with-pd-extdir=DIR], [Directory for PD externals (default=PDDIR/externs)]), + [pdexternsdir="$withval"], + [pdexternsdir="$pddir/externs"]) +AC_SUBST(pdexternsdir) + +dnl +dnl Check for m_pd.h +dnl +CPPFLAGS="$CPPFLAGS $IFLAGS" +AC_CHECK_HEADER(m_pd.h,[], + AC_MSG_WARN([-----------------------------------------------------------------]) + AC_MSG_WARN([could not find PD header file 'm_pd.h' -- things might get ugly.]) + AC_MSG_WARN([-----------------------------------------------------------------]), + [/* nonempty includes: compile only */]) + + +dnl +dnl debug version? +dnl +AC_MSG_CHECKING([whether we are building a debug version]) +AC_ARG_ENABLE([debug], + AC_HELP_STRING([--enable-debug],[build debug version (default=no)])) +if test "$enable_debug" == "yes" ; then + AC_MSG_RESULT(yes) + DEBUG="yes" + AC_DEFINE(READDIR_DEBUG,1, + [Define this to include debugging code for the 'readdir' external.]) +else + AC_MSG_RESULT(no) + DEBUG="no" +fi +AC_SUBST(DEBUG) + + + +dnl +dnl machine-dependent variables +dnl +LD=ld +if test `uname -s` = Linux; +then + LFLAGS="-export_dynamic -shared" + if test "$DEBUG" == "no"; then + #OFLAGS="-O6 -funroll-loops -fomit-frame-pointer -finline-limit-10000000" + OFLAGS="-O6 -funroll-loops -fomit-frame-pointer" + else + OFLAGS="-g" + fi + PDEXT=pd_linux +fi + +if test `uname -m` = alpha; +then + AFLAGS="-mieee -mcpu=ev56"; + OFLAGS="$CFLAGS" +fi + +if test `uname -s` = IRIX64; +then + LFLAGS="-n32 -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \ + -OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \ + -shared -rdata_shared" + OFLAGS="$CFLAGS" + PDEXT=pd_irix6 +fi + +if test `uname -s` = IRIX32; +then + LFLAGS="-o32 -DUNIX -DIRIX -O2 -shared -rdata_shared" + OFLAGS="$CFLAGS" + PDEXT=pd_irix5 +fi + +dnl +dnl Flags for MacOSX, borrowed from pd-0.35-test16 +dnl +if test `uname -s` = Darwin; +then + LD=cc + LFLAGS="-bundle -undefined suppress -flat_namespace" + PDEXT=pd_darwin + DFLAGS="$DFLAGS -DMACOSX" + + if test "$DEBUG" == "no"; then + OFLAGS="-O2" + else + OFLAGS="-g" + fi +fi + +dnl +dnl restore user's CFLAGS +dnl +CFLAGS="$UCFLAGS" +CPPFLAGS="$UCPPFLAGS" + +AC_OUTPUT(config/Makefile src/Makefile Makefile) diff --git a/readdir/src/Makefile.am b/readdir/src/Makefile.am new file mode 100644 index 0000000..53f09c0 --- /dev/null +++ b/readdir/src/Makefile.am @@ -0,0 +1,135 @@ +# File: ./src/Makefile.am +# Package: readdir +# Description: +# + src-level automake file +# +# Process this file with Automake to create Makefile.in. +#----------------------------------------------------------------------- + +#----------------------------------------------------------------------- +# Options & Subdirectories +#----------------------------------------------------------------------- + +## --- recursion subdirectories +#SUBDIRS = + +## --- pseudo-deps for '.SUFFIXES' +SUFFIXES = .@PDEXT@ + +#----------------------------------------------------------------------- +# Flags and variables +#----------------------------------------------------------------------- +PDEXT = @PDEXT@ +EXEEXT = .@PDEXT@ + +#----------------------------------------------------------------------- +# pd externals (hacked _PROGRAMS target) +#----------------------------------------------------------------------- + +## --- externals +pdexterns_PROGRAMS = @PD_OBJECT_EXTERNALS@ + +## --- possible externals +EXTRA_PROGRAMS = \ + readdir + +## --- patches +pdexterns_DATA = + +## --- documentation +pddoc_DATA = readdir-help.pd + + +#----------------------------------------------------------------------- +# sources +#----------------------------------------------------------------------- + +readdir_SOURCES = \ + readdir.c + +#----------------------------------------------------------------------- +# external compilation : flags +#----------------------------------------------------------------------- +DEFS = @DEFS@ +AFLAGS = @AFLAGS@ +DFLAGS = @DFLAGS@ +IFLAGS = @IFLAGS@ +LFLAGS = @LFLAGS@ +OFLAGS = @OFLAGS@ +WFLAGS = -Wall -Winline + +#GLIB_IFLAGS = @GLIB_IFLAGS@ +#GLIB_LFLAGS = @GLIB_LFLAGS@ + +AM_CPPFLAGS = $(IFLAGS) $(GLIB_IFLAGS) $(DFLAGS) +AM_CFLAGS = $(OFLAGS) $(WFLAGS) $(AFLAGS) + +readdir_LDFLAGS = $(LFLAGS) +readdir_LDADD = $(GLIB_LFLAGS) + +#----------------------------------------------------------------------- +# Variables: cleanup +#----------------------------------------------------------------------- +## --- mostlyclean: built by 'make' & commonly rebuilt +#MOSTLYCLEANFILES = + +## --- clean: built by 'make' +CLEANFILES = *$(EXEEXT) + +## --- distclean: built by 'configure' +DISTCLEANFILES = \ + config.log \ + config.cache \ + config.status + +## -- maintainerclean: built by maintainer / by hand +MAINTAINERCLEANFILES = *~ \ + $(PODS:.pod=.txt) \ + Makefile Makefile.in \ + aclocal.m4 \ + configure \ + install-sh \ + stamp-h.in \ + config.h.in + +maintainer-clean-local: + rm -rf autom4te.cache + +#CVSCLEAN_SUBDIRS = $(SUBDIRS) + +#CVSCLEANFILES = Makefile.in Makefile + + +#----------------------------------------------------------------------- +# Variables: distribution +#----------------------------------------------------------------------- + +## --- extra distribution files +EXTRA_DIST = \ + $(pddoc_DATA) \ + $(pdexterns_DATA) + +## --- recursion subdirectories for 'make dist' +DIST_SUBDIRS = $(SUBDIRS) + +## --- dist-hook: when another 'Makefile.am' is overkill +#DISTHOOK_DIRS = foo +#DISTHOOK_FILES = foo/bar.txt foo/baz.txt +#dist-hook: +# for d in $(DISTHOOK_DIRS); do\ +# mkdir -p $(distdir)/$$d ;\ +# done +# for f in $(DISTHOOK_FILES); do\ +# cp -p $(srcdir)/$$f $(distdir)/$$f ;\ +# done + +#dist-bz2: dist-bzip2 ; + + +#----------------------------------------------------------------------- +# Rules: cleanup +#----------------------------------------------------------------------- +.PHONY: cvsclean cvsclean-hook + +cvsclean: maintainer-clean ; + diff --git a/readdir/src/readdir-help.pd b/readdir/src/readdir-help.pd new file mode 100644 index 0000000..c3e752c --- /dev/null +++ b/readdir/src/readdir-help.pd @@ -0,0 +1,41 @@ +#N canvas 356 19 535 566 10; +#X msg 89 227 close; +#X msg 52 79 bang; +#X msg 83 160 tell; +#X obj 38 322 print dir-entry; +#X obj 82 294 print end-of-directory; +#X text 130 8 readdir : simple directory accessor; +#X text 231 543 Bryan Jurish ; +#X text 157 46 open DIR : opens the directory DIR; +#X text 185 75 bang : outlet next directory entry; +#X text 185 91 next : ditto; +#X msg 59 101 next; +#X msg 71 137 rewind; +#X text 173 137 rewind : return to beginning of directory; +#X text 188 158 tell : output current position; +#X text 146 182 seek FLOAT : goto position FLOAT; +#X msg 86 184 seek 0; +#X text 181 223 close : close directory; +#X text 258 295 2nd outlet bangs at end of directory; +#X text 260 325 Directory entries go to 1st outlet; +#X text 39 370 Directory entries appear as messages of the form TYPE +NAME \, where NAME is the name of the entry \, and TYPE is one of the +following:; +#X text 65 515 unknown : something else; +#X text 87 419 file : regular file; +#X text 93 434 dir : subdirectory; +#X text 86 450 fifo : named pipe; +#X text 85 466 sock : local-domain socket; +#X text 71 482 chrdev : character device; +#X text 71 498 blkdev : block device; +#X obj 38 267 readdir; +#X msg 39 47 open /tmp; +#X connect 0 0 27 0; +#X connect 1 0 27 0; +#X connect 2 0 27 0; +#X connect 10 0 27 0; +#X connect 11 0 27 0; +#X connect 15 0 27 0; +#X connect 27 0 3 0; +#X connect 27 1 4 0; +#X connect 28 0 27 0; diff --git a/readdir/src/readdir-test.pd b/readdir/src/readdir-test.pd new file mode 100644 index 0000000..dbfc3a7 --- /dev/null +++ b/readdir/src/readdir-test.pd @@ -0,0 +1,28 @@ +#N canvas 468 56 337 420 10; +#X obj 64 274 readdir; +#X msg 141 236 close; +#X obj 108 301 print end-of-directory; +#X msg 85 119 bang; +#X msg 64 93 open \$1; +#X msg 64 37 .; +#X msg 101 37 test; +#X msg 144 37 foo; +#X obj 64 69 symbol; +#X obj 64 328 print entry; +#X msg 109 166 tell; +#X msg 105 142 rewind; +#X msg 148 202 seek \$1; +#X floatatom 147 183 5 0 0; +#X connect 0 0 9 0; +#X connect 0 1 2 0; +#X connect 1 0 0 0; +#X connect 3 0 0 0; +#X connect 4 0 0 0; +#X connect 5 0 8 0; +#X connect 6 0 8 0; +#X connect 7 0 8 0; +#X connect 8 0 4 0; +#X connect 10 0 0 0; +#X connect 11 0 0 0; +#X connect 12 0 0 0; +#X connect 13 0 12 0; diff --git a/readdir/src/readdir.c b/readdir/src/readdir.c new file mode 100644 index 0000000..5500408 --- /dev/null +++ b/readdir/src/readdir.c @@ -0,0 +1,278 @@ +/* -*- Mode: C -*- */ +/*=============================================================================*\ + * File: readdir.c + * Author: Bryan Jurish + * Description: general directory access object + * + * Copyright (c) 2003 Bryan Jurish. + * + * For information on usage and redistribution, and for a DISCLAIMER OF ALL + * WARRANTIES, see the file, "LICENSE.txt," in this distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * See file LICENSE for further informations on licensing terms. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + *=============================================================================*/ + +#include +#include +#include +#include + +#include + +/* black magic */ +#ifdef NT +#pragma warning( disable : 4244 ) +#pragma warning( disable : 4305 ) +#endif + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +/*-------------------------------------------------------------------- + * DEBUG + *--------------------------------------------------------------------*/ +//#define READDIR_DEBUG 1 + + +/*===================================================================== + * Constants + *=====================================================================*/ +#ifdef READDIR_DEBUG +// error-message buffer +#define EBUFSIZE 256 +static char readdir_errbuf[EBUFSIZE]; +#endif + +/*===================================================================== + * Structures and Types + *=====================================================================*/ + +static char *readdir_banner = "\nreaddir version %s by Bryan Jurish : simple directory accessor"; + +static t_class *readdir_class; + +typedef struct _readdir +{ + t_object x_obj; + DIR *x_dir; //-- current directory + t_symbol *x_dirname; //-- current directory name + //struct dirent *x_dirent; //-- current entry of current directory + t_atom x_eatom; //-- current output atom (symbol) + t_outlet *x_ent_outlet; //-- entry outlet + t_outlet *x_eod_outlet; //-- end-of-directory outlet +} t_readdir; + +/*===================================================================== + * Constants + *=====================================================================*/ +static t_symbol *sp_none; +static t_symbol *sp_unknown; +static t_symbol *sp_file; +static t_symbol *sp_dir; +static t_symbol *sp_fifo; +static t_symbol *sp_sock; +static t_symbol *sp_chrdev; +static t_symbol *sp_blkdev; + +/*-------------------------------------------------------------------- + * close + */ +static void readdir_close(t_readdir *x) +{ + if (!x->x_dir) return; + if (0 != closedir(x->x_dir)) { + error("readdir: cannot close %s: %s", x->x_dirname->s_name, strerror(errno)); + return; + } + x->x_dir = NULL; + x->x_dirname = sp_none; +} + +/*-------------------------------------------------------------------- + * open DIR + */ +static void readdir_open(t_readdir *x, t_symbol *dirname) +{ +#ifdef READDIR_DEBUG + post("readdir: got message: open %s", dirname->s_name); +#endif + + if (x->x_dir) readdir_close(x); + if ( !(x->x_dir = opendir(dirname->s_name)) ) { + error("readdir: cannot open %s: %s", dirname->s_name, strerror(errno)); + return; + } + x->x_dirname = dirname; +} + +/*-------------------------------------------------------------------- + * next : get next entry + */ +static void readdir_next(t_readdir *x) +{ + t_symbol *sel = sp_unknown; + struct dirent *result = NULL; + if ( !x->x_dir || !(result = readdir(x->x_dir)) ) { + if (errno == EBADF) { + //-- real error + error("readdir: cannot read from %s: %s", x->x_dirname->s_name, strerror(errno)); + } + else { + //-- end of directory + outlet_bang(x->x_eod_outlet); + } + return; + } + + //-- get type + switch (result->d_type) + { + case DT_REG: + sel = sp_file; + break; + + case DT_DIR: + sel = sp_dir; + break; + + case DT_FIFO: + sel = sp_fifo; + break; + + case DT_SOCK: + sel = sp_sock; + break; + + case DT_CHR: + sel = sp_chrdev; + break; + + case DT_BLK: + sel = sp_blkdev; + break; + + default: + sel = sp_unknown; + break; + } + + x->x_eatom.a_w.w_symbol = gensym(result->d_name); + outlet_anything(x->x_ent_outlet, sel, 1, &x->x_eatom); +} + +/*-------------------------------------------------------------------- + * rewind + */ +static void readdir_rewind(t_readdir *x) +{ + if (x->x_dir) rewinddir(x->x_dir); +} + +/*-------------------------------------------------------------------- + * tell + */ +static void readdir_tell(t_readdir *x) +{ + off_t off = 0; + if (x->x_dir) off = telldir(x->x_dir); + outlet_float(x->x_ent_outlet, (t_float)off); +} + +/*-------------------------------------------------------------------- + * seek FLOAT + */ +static void readdir_seek(t_readdir *x, t_floatarg pos) +{ + if (!x->x_dir) { + error("readdir: seek %f: no directory opened!", pos); + return; + } + seekdir(x->x_dir, (off_t)pos); +} + + +/*-------------------------------------------------------------------- + * new + */ +static void *readdir_new(void) +{ + t_readdir *x = (t_readdir *)pd_new(readdir_class); + + //-- defaults + x->x_dir = NULL; + x->x_dirname = sp_none; + SETSYMBOL(&x->x_eatom, sp_none); + + //-- outlets + x->x_ent_outlet = outlet_new(&x->x_obj, &s_symbol); + x->x_eod_outlet = outlet_new(&x->x_obj, &s_bang); + + return (void *)x; +} + +/*-------------------------------------------------------------------- + * free + */ +static void readdir_free(t_readdir *x) +{ + readdir_close(x); + outlet_free(x->x_ent_outlet); + outlet_free(x->x_eod_outlet); + return; +} + +/*-------------------------------------------------------------------- + * setup + */ +void readdir_setup(void) +{ + post(readdir_banner, PACKAGE_VERSION); +#ifdef READDIR_DEBUG + post("readdir : debugging enabled"); +#endif + + //-- constants + sp_none = gensym("none"); + sp_unknown = gensym("unknown"); + sp_file = gensym("file"); + sp_dir = gensym("dir"); + sp_fifo = gensym("fifo"); + sp_sock = gensym("sock"); + sp_chrdev = gensym("chrdev"); + sp_blkdev = gensym("blkdev"); + + //-- class + readdir_class = class_new(gensym("readdir"), + (t_newmethod)readdir_new, + (t_method)readdir_free, + sizeof(t_readdir), + CLASS_DEFAULT, + 0); + + //-- methods + class_addmethod(readdir_class, (t_method)readdir_open, gensym("open"), A_DEFSYMBOL, 0); + class_addmethod(readdir_class, (t_method)readdir_close, gensym("close"), 0); + class_addmethod(readdir_class, (t_method)readdir_next, gensym("next"), 0); + class_addbang(readdir_class, (t_method)readdir_next); + class_addmethod(readdir_class, (t_method)readdir_rewind, gensym("rewind"), 0); + class_addmethod(readdir_class, (t_method)readdir_tell, gensym("tell"), 0); + class_addmethod(readdir_class, (t_method)readdir_seek, gensym("seek"), A_DEFFLOAT, 0); + + //-- help symbol + class_sethelpsymbol(readdir_class, gensym("readdir-help.pd")); +} -- cgit v1.2.1