aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBryan Jurish <mukau@users.sourceforge.net>2006-02-02 12:49:19 +0000
committerBryan Jurish <mukau@users.sourceforge.net>2006-02-02 12:49:19 +0000
commitcf40e844031c1035230e62fd88a0c42f7f617365 (patch)
tree0a9208f5fcd6a40f127532fa49441ca000f84e4c
initial cvs importsvn2git-root
svn path=/trunk/externals/moocow/pdstring/; revision=4536
-rw-r--r--COPYING290
-rw-r--r--Changes10
-rw-r--r--Makefile.am98
-rw-r--r--README.cvs13
-rw-r--r--README.pod62
-rwxr-xr-xautogen.sh48
-rw-r--r--config/Makefile.am66
-rw-r--r--configure.in201
-rw-r--r--src/Makefile.am146
-rw-r--r--src/any2string.c210
-rw-r--r--src/pdstring-help.pd59
-rw-r--r--src/pdstring.c99
-rw-r--r--src/string2any.c181
13 files changed, 1483 insertions, 0 deletions
diff --git a/COPYING b/COPYING
new file mode 100644
index 0000000..fa0bef4
--- /dev/null
+++ b/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/Changes b/Changes
new file mode 100644
index 0000000..152925c
--- /dev/null
+++ b/Changes
@@ -0,0 +1,10 @@
+Change log for PD external 'pdstring'
+
+v0.03 Thu, 02 Feb 2006 12:57:43 +0100
+ + automake-ified
+
+v0.02 ?
+ + ?
+
+v0.01 Sun, 26 Oct 2003 14:06:29 +0100
+ + initial version
diff --git a/Makefile.am b/Makefile.am
new file mode 100644
index 0000000..d0318b3
--- /dev/null
+++ b/Makefile.am
@@ -0,0 +1,98 @@
+# File: ./Makefile.am
+# Package: pd-string
+# 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/README.cvs b/README.cvs
new file mode 100644
index 0000000..2a0ee0c
--- /dev/null
+++ b/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/README.pod b/README.pod
new file mode 100644
index 0000000..9f87836
--- /dev/null
+++ b/README.pod
@@ -0,0 +1,62 @@
+=pod
+
+README for pd external package 'pdstring'
+
+Last updated for pdstring v0.02
+
+=head1 DESCRIPTION
+
+The 'pdstring' package contains objects for converting to and
+from (ASCII)-strings, represented as lists of floats.
+
+=head1 INSTALLATION
+
+Issue the following commands to the shell:
+
+ cd PACKAGE-XX.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
+
+=head2 Memory Usage
+
+Encoding each byte of a string as its own float is shamefully
+wasteful: it uses only 1 byte out of at least 3 which could be
+losslessly used given ANSI/IEEE Std 754-1985 floats, not to
+mention the remaining byte(s) (usually 1) of the float itself
+or the (usually 4) bytes used for the a_type flag.
+Unfortunately, Pd trims some floating point
+precision in message boxes and in float atoms, so a truly
+lossless float encoding for Pd would only be possible using
+2 bytes per float (wasting 1/2 the space of the float itself),
+and (to me), the memory saving such an encoding would provide
+is just not worth the lack of transparency and additional
+workload it would involve (but contact me if you want the code
+anyways).
+
+
+=head1 AUTHOR
+
+Bryan Jurish E<lt>moocow@ling.uni-potsdam.deE<gt>
diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 0000000..845f276
--- /dev/null
+++ b/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/config/Makefile.am b/config/Makefile.am
new file mode 100644
index 0000000..3e097e9
--- /dev/null
+++ b/config/Makefile.am
@@ -0,0 +1,66 @@
+## File: config/Makefile.am
+## Package:
+## 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/configure.in b/configure.in
new file mode 100644
index 0000000..337a501
--- /dev/null
+++ b/configure.in
@@ -0,0 +1,201 @@
+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], [pdstring])
+define([THE_PACKAGE_VERSION], [0.03])
+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 ----- begin imported rsynth configuration stuff
+
+dnl other flags
+AC_ISC_POSIX
+
+dnl Checks for header files.
+dnl AC_HEADER_STDC
+AC_CHECK_HEADERS([string.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="pdstring\$(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(ANY2STRING_DEBUG,1,
+ [Define this to include debugging code for the 'string2any' external.])
+ AC_DEFINE(STRING2ANY_DEBUG,1,
+ [Define this to include debugging code for 'the any2string' 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/src/Makefile.am b/src/Makefile.am
new file mode 100644
index 0000000..2ff35cd
--- /dev/null
+++ b/src/Makefile.am
@@ -0,0 +1,146 @@
+# File: ./src/Makefile.am
+# Package: pdstring
+# 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 = \
+ pdstring \
+ any2string \
+ string2any
+
+## --- patches
+pdexterns_DATA =
+
+## --- documentation
+pddoc_DATA = pdstring-help.pd
+
+
+#-----------------------------------------------------------------------
+# sources
+#-----------------------------------------------------------------------
+
+pdstring_SOURCES = \
+ any2string.c \
+ string2any.c \
+ pdstring.c
+
+any2string_SOURCES = any2string.c
+
+string2any_SOURCES = string2any.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)
+
+pdstring_LDFLAGS = $(LFLAGS)
+
+string2any_LDFLAGS = $(LFLAGS)
+
+any2string_LDFLAGS = $(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/src/any2string.c b/src/any2string.c
new file mode 100644
index 0000000..3bcaa3a
--- /dev/null
+++ b/src/any2string.c
@@ -0,0 +1,210 @@
+/* -*- Mode: C -*- */
+/*=============================================================================*\
+ * File: any2string.c
+ * Author: Bryan Jurish <moocow@ling.uni-potsdam.de>
+ * Description: convert pd messages to strings
+ *
+ * Copyright (c) 2004 Bryan Jurish.
+ *
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file "COPYING", 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.
+ *
+ * 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 <string.h>
+
+#include <m_pd.h>
+
+/* black magic */
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/*--------------------------------------------------------------------
+ * DEBUG
+ *--------------------------------------------------------------------*/
+//#define ANY2STRING_DEBUG 1
+
+#ifdef ANY2STRING_DEBUG
+# define A2SDEBUG(x) x
+#else
+# define A2SDEBUG(x)
+#endif
+
+#define ANY2STRING_INITIAL_BUFLEN 32
+
+
+/*=====================================================================
+ * Structures and Types: any2string
+ *=====================================================================*/
+static t_class *any2string_class;
+
+typedef struct _any2string
+{
+ t_object x_obj;
+ int x_alloc;
+ int x_argc;
+ t_atom *x_argv;
+ t_binbuf *x_binbuf;
+ t_outlet *x_outlet;
+} t_any2string;
+
+
+/*=====================================================================
+ * Constants
+ *=====================================================================*/
+
+/*=====================================================================
+ * Methods
+ *=====================================================================*/
+
+/*--------------------------------------------------------------------
+ * anything
+ */
+static void any2string_anything(t_any2string *x, t_symbol *sel, int argc, t_atom *argv)
+{
+ t_atom *a;
+ char *text, *s;
+ int len;
+
+ A2SDEBUG(post("-------any2string_anything()---------"));
+
+ /*-- set up binbuf --*/
+ A2SDEBUG(post("any2string: binbuf_clear()"));
+ binbuf_clear(x->x_binbuf);
+ A2SDEBUG(post("any2string: binbuf_add()"));
+ binbuf_add(x->x_binbuf, argc, argv);
+ A2SDEBUG(binbuf_print(x->x_binbuf));
+
+ A2SDEBUG(post("any2string: binbuf_gettext()"));
+ binbuf_gettext(x->x_binbuf, &text, &len);
+ A2SDEBUG(post("any2string: binbuf_gettext() = \"%s\" ; len=%d", text, len));
+ text[len] = 0;
+
+ /*-- get string length --*/
+ x->x_argc = len+1;
+ if (sel != &s_float && sel != &s_list && sel != &s_) {
+ x->x_argc += strlen(sel->s_name);
+ if (argc > 0) x->x_argc++;
+ }
+ A2SDEBUG(post("any2string: argc=%d", x->x_argc));
+
+ /*-- (re-)allocate --*/
+ if (x->x_alloc < x->x_argc) {
+ A2SDEBUG(post("any2string: reallocate(%d->%d)", x->x_alloc, x->x_argc));
+ freebytes(x->x_argv, x->x_alloc * sizeof(t_atom));
+ x->x_argv = (t_atom *)getbytes(x->x_argc * sizeof(t_atom));
+ x->x_alloc = x->x_argc;
+ }
+
+ /*-- add selector --*/
+ a=x->x_argv;
+ if (sel != &s_float && sel != &s_list && sel != &s_) {
+ A2SDEBUG(post("any2string: for {...} //sel"));
+ for (s=sel->s_name; *s; s++, a++) {
+ A2SDEBUG(post("any2string: for: SETFLOAT(a,'%c'=%d) //sel", *s, *s));
+ SETFLOAT(a,*s);
+ }
+ A2SDEBUG(post("any2string: /for {...} //sel"));
+
+ if (argc > 0) {
+ SETFLOAT(a,' ');
+ a++;
+ }
+ }
+
+ /*-- add binbuf text --*/
+ A2SDEBUG(post("any2string: for {...}"));
+ for (s=text; *s; s++, a++) {
+ A2SDEBUG(post("any2string: for: //SETFLOAT(a,'%c'=%d)", *s, *s));
+ SETFLOAT(a,*s);
+ }
+ A2SDEBUG(post("any2string: /for {...}"));
+
+ /*-- add terminating NUL --*/
+ SETFLOAT(a,0);
+
+ A2SDEBUG(post("any2string: freebytes()"));
+ freebytes(text, strlen(text));
+
+ /*
+ A2SDEBUG(post("any2string: binbuf_free()"));
+ binbuf_free(x->x_binbuf);
+ */
+
+ A2SDEBUG(post("any2string: outlet_list(..., %d, ...)", x->x_argc));
+ outlet_list(x->x_outlet, &s_list, x->x_argc, x->x_argv);
+}
+
+
+/*--------------------------------------------------------------------
+ * new
+ */
+static void *any2string_new(void)
+{
+ t_any2string *x = (t_any2string *)pd_new(any2string_class);
+
+ //-- defaults
+ x->x_alloc = ANY2STRING_INITIAL_BUFLEN;
+ x->x_argc = 0;
+ x->x_argv = (t_atom *)getbytes(x->x_alloc * sizeof(t_atom));
+ x->x_binbuf = binbuf_new();
+
+ //-- outlets
+ x->x_outlet = outlet_new(&x->x_obj, &s_list);
+
+ return (void *)x;
+}
+
+/*--------------------------------------------------------------------
+ * free
+ */
+static void any2string_free(t_any2string *x)
+{
+ if (x->x_argv) {
+ freebytes(x->x_argv, x->x_alloc * sizeof(t_atom));
+ x->x_argv = NULL;
+ }
+ binbuf_free(x->x_binbuf);
+ outlet_free(x->x_outlet);
+ return;
+}
+
+/*--------------------------------------------------------------------
+ * setup
+ */
+void any2string_setup(void)
+{
+ //-- class
+ any2string_class = class_new(gensym("any2string"),
+ (t_newmethod)any2string_new,
+ (t_method)any2string_free,
+ sizeof(t_any2string),
+ CLASS_DEFAULT,
+ 0);
+
+ //-- methods
+ /*class_addmethod(any2string_class, (t_method)any2string_symbol, &s_symbol,
+ A_DEFSYMBOL, 0);
+ */
+ class_addanything(any2string_class,
+ (t_method)any2string_anything);
+
+
+ //-- help symbol
+ class_sethelpsymbol(any2string_class, gensym("pdstring-help.pd"));
+}
diff --git a/src/pdstring-help.pd b/src/pdstring-help.pd
new file mode 100644
index 0000000..e83b9db
--- /dev/null
+++ b/src/pdstring-help.pd
@@ -0,0 +1,59 @@
+#N canvas 381 42 563 311 10;
+#X text 258 284 Bryan Jurish <moocow@ling.uni-potsdam.de>;
+#X floatatom 56 81 8 0 0 0 - - -;
+#X symbolatom 46 59 10 0 0 0 - - -;
+#X text 201 59 ... no special handling for symbols;
+#X text 200 37 anything can be converted to a list...;
+#X obj 383 3 pdstring;
+#X text 54 3 any2string \, string2any : ASCII conversions in;
+#X obj 37 108 any2string;
+#X obj 37 230 string2any;
+#X floatatom 54 178 4 0 0 0 - - -;
+#X text 213 230 string2any converts ASCII lists to Pd messages...;
+#X text 202 81 ... but "float" selector is silently dropped;
+#N canvas 0 0 448 335 ascii-table 0;
+#X obj 162 144 f 0;
+#X obj 134 153 + 1;
+#X obj 161 165 t f f f;
+#X obj 133 198 string2any;
+#X obj 154 243 pack s 0;
+#X obj 162 119 until;
+#X obj 133 218 symbol;
+#X msg 162 84 256;
+#X msg 208 119 0;
+#X obj 162 23 inlet;
+#X obj 162 54 t b b;
+#X obj 154 266 route list;
+#X obj 154 293 print charset;
+#X connect 0 0 2 0;
+#X connect 1 0 0 1;
+#X connect 2 0 1 0;
+#X connect 2 1 3 0;
+#X connect 2 2 4 1;
+#X connect 3 0 6 0;
+#X connect 4 0 11 0;
+#X connect 5 0 0 0;
+#X connect 6 0 4 0;
+#X connect 7 0 5 0;
+#X connect 8 0 0 1;
+#X connect 9 0 10 0;
+#X connect 10 0 7 0;
+#X connect 10 1 8 0;
+#X connect 11 0 12 0;
+#X connect 11 1 12 0;
+#X restore 249 144 pd ascii-table;
+#X msg 249 121 bang;
+#X text 361 143 know your charset;
+#X obj 58 139 print any2string-out;
+#X obj 37 254 print string2any-out;
+#X msg 37 38 A B C;
+#X msg 55 199 list 49 50 51;
+#X connect 1 0 7 0;
+#X connect 2 0 7 0;
+#X connect 7 0 15 0;
+#X connect 7 0 8 0;
+#X connect 8 0 16 0;
+#X connect 9 0 8 0;
+#X connect 13 0 12 0;
+#X connect 17 0 7 0;
+#X connect 18 0 8 0;
diff --git a/src/pdstring.c b/src/pdstring.c
new file mode 100644
index 0000000..c77b68e
--- /dev/null
+++ b/src/pdstring.c
@@ -0,0 +1,99 @@
+/* -*- Mode: C -*- */
+/*=============================================================================*\
+ * File: pdstring.c
+ * Author: Bryan Jurish <moocow@ling.uni-potsdam.de>
+ * Description: pd string conversions : library
+ *
+ * Copyright (c) 2004-2006 Bryan Jurish.
+ *
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file "COPYING", 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.
+ *
+ * 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 <m_pd.h>
+
+/* black magic */
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+/*=====================================================================
+ * Constants
+ *=====================================================================*/
+static char *pdstring_version = "\npdstring version " PACKAGE_VERSION " by Bryan Jurish";
+
+/*=====================================================================
+ * Structures and Types: pdstring [dummy]
+ *=====================================================================*/
+static t_class *pdstring_class;
+
+typedef struct _pdstring
+{
+ t_object x_obj;
+} t_pdstring;
+
+
+/*=====================================================================
+ * External declarations
+ *=====================================================================*/
+extern void any2string_setup(void);
+extern void string2any_setup(void);
+
+/*--------------------------------------------------------------------
+ * new
+ */
+static void *pdstring_new(void)
+{
+ t_pdstring *x = (t_pdstring *)pd_new(pdstring_class);
+ return x;
+}
+
+/*--------------------------------------------------------------------
+ * help
+ */
+static void pdstring_help(t_pdstring *x)
+{
+ post(pdstring_version);
+}
+
+/*=====================================================================
+ * Setup
+ *=====================================================================*/
+void pdstring_setup(void)
+{
+ post(pdstring_version);
+
+ any2string_setup();
+ string2any_setup();
+
+ pdstring_class = class_new(gensym("pdstring"),
+ (t_newmethod)pdstring_new,
+ 0,
+ sizeof(t_pdstring),
+ CLASS_DEFAULT,
+ 0);
+
+ //-- help method
+ class_addmethod(pdstring_class, (t_method)pdstring_help, gensym("help"), A_NULL);
+
+ //-- help symbol
+ class_sethelpsymbol(pdstring_class, gensym("pdstring-help.pd"));
+}
diff --git a/src/string2any.c b/src/string2any.c
new file mode 100644
index 0000000..93756ec
--- /dev/null
+++ b/src/string2any.c
@@ -0,0 +1,181 @@
+/* -*- Mode: C -*- */
+/*=============================================================================*\
+ * File: string2any.c
+ * Author: Bryan Jurish <moocow@ling.uni-potsdam.de>
+ * Description: convert strings to pd messages
+ *
+ * Copyright (c) 2004 Bryan Jurish.
+ *
+ * For information on usage and redistribution, and for a DISCLAIMER OF ALL
+ * WARRANTIES, see the file "COPYING", 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.
+ *
+ * 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 <string.h>
+
+#include <m_pd.h>
+
+/* black magic */
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+/*--------------------------------------------------------------------
+ * DEBUG
+ *--------------------------------------------------------------------*/
+//#define STRING2ANY_DEBUG 1
+
+#ifdef STRING2ANY_DEBUG
+# define S2ADEBUG(x) x
+#else
+# define S2ADEBUG(x)
+#endif
+
+#define STRING2ANY_INITIAL_BUFLEN 32
+
+
+/*=====================================================================
+ * Constants
+ *=====================================================================*/
+
+/*=====================================================================
+ * Structures and Types: any2string
+ *=====================================================================*/
+
+static t_class *string2any_class;
+
+typedef struct _string2any
+{
+ t_object x_obj;
+ size_t x_size;
+ char *x_text;
+ t_binbuf *x_binbuf;
+ t_outlet *x_outlet;
+} t_string2any;
+
+
+/*=====================================================================
+ * Constants
+ *=====================================================================*/
+
+/*=====================================================================
+ * Methods
+ *=====================================================================*/
+
+/*--------------------------------------------------------------------
+ * anything
+ */
+static void string2any_anything(t_string2any *x, t_symbol *sel, int argc, t_atom *argv)
+{
+ char *s;
+ int x_argc;
+ t_atom *x_argv;
+
+ /*-- allocate --*/
+ if (x->x_size <= argc) {
+ freebytes(x->x_text, x->x_size*sizeof(char));
+ x->x_size = argc+1;
+ x->x_text = (char *)getbytes(x->x_size * sizeof(char));
+ }
+
+ /*-- get text --*/
+ for (s=x->x_text; argc > 0; argc--, argv++, s++) {
+ *s = atom_getfloat(argv);
+ }
+ *s = 0;
+ S2ADEBUG(post("string2any: text: \"%s\"", x->x_text));
+
+ /*-- clear and fill binbuf --*/
+ binbuf_clear(x->x_binbuf);
+ binbuf_text(x->x_binbuf, x->x_text, strlen(x->x_text));
+ S2ADEBUG(startpost("string2any: buf: "));
+ S2ADEBUG(binbuf_print(x->x_binbuf));
+
+ /*-- output --*/
+ x_argc = binbuf_getnatom(x->x_binbuf);
+ x_argv = binbuf_getvec(x->x_binbuf);
+ if (x_argc && x_argv->a_type == A_SYMBOL) {
+ outlet_anything(x->x_outlet,
+ x_argv->a_w.w_symbol,
+ x_argc-1,
+ x_argv+1);
+ }
+ else {
+ outlet_anything(x->x_outlet,
+ &s_list,
+ x_argc,
+ x_argv);
+ }
+}
+
+
+/*--------------------------------------------------------------------
+ * new
+ */
+static void *string2any_new(void)
+{
+ t_string2any *x = (t_string2any *)pd_new(string2any_class);
+
+ //-- defaults
+ x->x_binbuf = binbuf_new();
+ x->x_size = STRING2ANY_INITIAL_BUFLEN;
+ x->x_text = (char *)getbytes(x->x_size * sizeof(char));
+
+ //-- outlets
+ x->x_outlet = outlet_new(&x->x_obj, &s_list);
+
+ return (void *)x;
+}
+
+/*--------------------------------------------------------------------
+ * free
+ */
+static void string2any_free(t_string2any *x)
+{
+ if (x->x_text) {
+ freebytes(x->x_text, x->x_size * sizeof(char));
+ x->x_text = NULL;
+ }
+ binbuf_free(x->x_binbuf);
+ outlet_free(x->x_outlet);
+ return;
+}
+
+/*--------------------------------------------------------------------
+ * setup
+ */
+void string2any_setup(void)
+{
+ //-- class
+ string2any_class = class_new(gensym("string2any"),
+ (t_newmethod)string2any_new,
+ (t_method)string2any_free,
+ sizeof(t_string2any),
+ CLASS_DEFAULT,
+ 0);
+
+ //-- methods
+ /*class_addmethod(string2any_class, (t_method)string2any_symbol, &s_symbol,
+ A_DEFSYMBOL, 0);
+ */
+ class_addanything(string2any_class,
+ (t_method)string2any_anything);
+
+
+ //-- help symbol
+ class_sethelpsymbol(string2any_class, gensym("pdstring-help.pd"));
+}