mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-25 08:38:39 +02:00
------------------------------------------------------------------------ r288 | rbd | 2018-09-25 13:47:35 -0500 (Tue, 25 Sep 2018) | 2 lines removed some redundant files that moved to nyquist extensions ------------------------------------------------------------------------ r287 | rbd | 2018-09-25 13:02:34 -0500 (Tue, 25 Sep 2018) | 2 lines Cleaning up: many things in demos have moved to Nyquist extensions ------------------------------------------------------------------------ r286 | rbd | 2018-09-11 08:21:16 -0500 (Tue, 11 Sep 2018) | 2 lines Releasing 3.15 on Mac, finished extension manager update to allow a custom extension list file set in Preferences. Allow text copy of checksum when checksums do not match (so IDE can calculate the checksum for new extensions), describe this in manual. ------------------------------------------------------------------------ r285 | rbd | 2018-09-05 08:00:03 -0500 (Wed, 05 Sep 2018) | 2 lines Changes for 3.15 on Mac and hopefully good for Windows too. ------------------------------------------------------------------------ r284 | rbd | 2018-09-01 21:21:47 -0500 (Sat, 01 Sep 2018) | 2 lines Final change? for v3.14 on Mac ------------------------------------------------------------------------ r283 | rbd | 2018-09-01 21:14:11 -0500 (Sat, 01 Sep 2018) | 2 lines Took out unicode char from fm-voices-chowning, added README to extensions directory ------------------------------------------------------------------------ r282 | rbd | 2018-09-01 21:12:47 -0500 (Sat, 01 Sep 2018) | 1 line fixed some instrument defns for sound browser ------------------------------------------------------------------------ r281 | rbd | 2018-09-01 19:56:55 -0500 (Sat, 01 Sep 2018) | 1 line Small changes for release on Windows: v3.14 ------------------------------------------------------------------------ r280 | rbd | 2018-09-01 19:56:07 -0500 (Sat, 01 Sep 2018) | 2 lines path problems in some extensions and minor changes for mac release ------------------------------------------------------------------------ r279 | rbd | 2018-09-01 15:03:26 -0500 (Sat, 01 Sep 2018) | 2 lines change doc/README.txt to doc/readme-mac.txt in install dmg ------------------------------------------------------------------------ r278 | rbd | 2018-09-01 14:58:10 -0500 (Sat, 01 Sep 2018) | 2 lines minor fix for mac release ------------------------------------------------------------------------ r277 | rbd | 2018-09-01 14:40:10 -0500 (Sat, 01 Sep 2018) | 2 lines Retry release on Mac, minor changes. ------------------------------------------------------------------------ r276 | rbd | 2018-08-31 23:44:45 -0500 (Fri, 31 Aug 2018) | 3 lines Updated documentation; building 3.14 for mac release ------------------------------------------------------------------------ r275 | rbd | 2018-08-31 21:20:41 -0500 (Fri, 31 Aug 2018) | 1 line Fixed extension manager to update installed flags correctly (in Swing thread). Tested browser on Windows. ------------------------------------------------------------------------ r274 | rbd | 2018-08-31 14:35:22 -0500 (Fri, 31 Aug 2018) | 1 line Forgot to add new file. ------------------------------------------------------------------------ r273 | rbd | 2018-08-31 14:33:02 -0500 (Fri, 31 Aug 2018) | 1 line Changes for Windows including making paths look prettier using backslash or slash more consistently, adding some tests for empty lists, setting up nyquist directory using Registry's XLISPPATH. ------------------------------------------------------------------------ r272 | rbd | 2018-08-31 14:12:12 -0500 (Fri, 31 Aug 2018) | 2 lines Everything seems to be working on OS X. Latest fix was to Sound Browser. ------------------------------------------------------------------------ r271 | rbd | 2018-08-31 13:00:54 -0500 (Fri, 31 Aug 2018) | 2 lines Adapting to Java 10, fixing sound browser in the face of unloaded extensions. ------------------------------------------------------------------------ r270 | rbd | 2018-08-30 13:18:11 -0500 (Thu, 30 Aug 2018) | 2 lines Installer code sets registry to user-selected nyquist directory. ------------------------------------------------------------------------ r269 | rbd | 2018-08-30 12:53:21 -0500 (Thu, 30 Aug 2018) | 1 line Getting ready to releasea 3.14. These changes are from Windows. ------------------------------------------------------------------------ r268 | rbd | 2018-08-29 20:06:41 -0500 (Wed, 29 Aug 2018) | 2 lines Changes for simpler installation with nyquist (lib, doc, runtime, demos) in user read/write file space. ------------------------------------------------------------------------ r267 | rbd | 2018-08-26 20:45:14 -0500 (Sun, 26 Aug 2018) | 2 lines Added some documentation, worked on browser #anchor urls. ------------------------------------------------------------------------ r266 | rbd | 2018-08-22 18:27:01 -0500 (Wed, 22 Aug 2018) | 2 lines Fixed some extensions to deal with piano, which now autoloads. ------------------------------------------------------------------------ r265 | rbd | 2018-08-22 12:18:40 -0500 (Wed, 22 Aug 2018) | 2 lines added one more missing file for v3.13 ------------------------------------------------------------------------ r264 | rbd | 2018-08-22 10:54:15 -0500 (Wed, 22 Aug 2018) | 2 lines left out piano/autoload.lsp, needed for v3.13 ------------------------------------------------------------------------ r263 | rbd | 2018-08-22 10:09:16 -0500 (Wed, 22 Aug 2018) | 2 lines More cleanup for 3.13 release ------------------------------------------------------------------------ r262 | rbd | 2018-08-22 09:54:45 -0500 (Wed, 22 Aug 2018) | 2 lines More changes for 3.13 including status dialog while downloading extensions. ------------------------------------------------------------------------ r261 | rbd | 2018-08-19 21:34:23 -0500 (Sun, 19 Aug 2018) | 2 lines Updated documentation for v3.13 ------------------------------------------------------------------------ r260 | rbd | 2018-08-19 11:14:07 -0500 (Sun, 19 Aug 2018) | 2 lines Converted to using Extension Manager ------------------------------------------------------------------------ r259 | rbd | 2018-05-20 19:08:34 -0500 (Sun, 20 May 2018) | 2 lines Forgot to commit this new file ------------------------------------------------------------------------ r258 | rbd | 2018-03-10 12:11:22 -0600 (Sat, 10 Mar 2018) | 2 lines Substantial changes to pattern classes in xm.lsp to fix bug. The problems were obscure and unnoticed for a long time, but this new implementation is a major rewrite. I still need to test online course examples to make sure nothing is broken there. Otherwise, my assumption is there are few users and incompatibilities will not matter, so this is regarded as a minor bug fix. Also in this commit is some work on turning libraries and demos into Nyquist extensions supported by an extension manager within NyquistIDE. ------------------------------------------------------------------------ r257 | rbd | 2018-01-21 14:40:58 -0600 (Sun, 21 Jan 2018) | 2 lines Built nyquist and NyquistIDE on Ubuntu 14.04 LTS and using Oracle Java 9. Minor changes (former build specified Java version 1.7). ------------------------------------------------------------------------ r256 | rbd | 2017-09-24 14:05:06 -0500 (Sun, 24 Sep 2017) | 2 lines Fix type-checking bug in score-voice ------------------------------------------------------------------------ r255 | rbd | 2017-09-24 10:35:08 -0500 (Sun, 24 Sep 2017) | 2 lines Updated nyqrelide.iss for Roger's newer windows laptop ------------------------------------------------------------------------ r254 | rbd | 2017-09-24 10:27:05 -0500 (Sun, 24 Sep 2017) | 2 lines After testing on Windows 7, removed Test button from IDE, made fft_demo not depend so much on XLISPPATH to find pmorales/*.lsp ------------------------------------------------------------------------ r253 | rbd | 2017-09-23 18:44:41 -0500 (Sat, 23 Sep 2017) | 1 line Changes to compile on MSVS Community 2015 ------------------------------------------------------------------------ r252 | rbd | 2017-09-23 17:01:44 -0500 (Sat, 23 Sep 2017) | 2 lines A few adjustments made to allow examples.sal to run even if "demos" is not on the XLISPPATH ------------------------------------------------------------------------ r251 | rbd | 2017-09-23 16:14:27 -0500 (Sat, 23 Sep 2017) | 2 lines Minor changes to make this work on Ubuntu linux (or maybe any other linux) ------------------------------------------------------------------------ r250 | rbd | 2017-09-23 14:32:52 -0500 (Sat, 23 Sep 2017) | 2 lines Fixed version number in IDE About box ------------------------------------------------------------------------ r249 | rbd | 2017-09-23 14:17:16 -0500 (Sat, 23 Sep 2017) | 2 lines More fixes for 3.12. OS X version setting up symbolic links had bugs. ------------------------------------------------------------------------ r248 | rbd | 2017-09-23 00:31:29 -0500 (Sat, 23 Sep 2017) | 2 lines Processed documentation for v3.12 ------------------------------------------------------------------------ r247 | rbd | 2017-09-22 21:59:18 -0500 (Fri, 22 Sep 2017) | 2 lines Preparing v3.12. ------------------------------------------------------------------------ r246 | rbd | 2017-09-05 09:27:29 -0500 (Tue, 05 Sep 2017) | 1 line Fixes for Win10 and many changes to rounding throughout to avoid truncating to 32-bit ints when 64-bits might be available on some architectures. In particular, round() which returns double has been replaced by ROUND32, returning int, and ROUNDBIG returning intptr_t. ------------------------------------------------------------------------ r245 | rbd | 2017-08-24 11:15:22 -0500 (Thu, 24 Aug 2017) | 2 lines Fixed bug affecting Linux: seq-write-smf was trying to close file twice causing nyquist crash. Fixed by adding intermediate helper function in seqinterf.c so SEQ-WRITE-SMF does not directly call seq_write_smf. ------------------------------------------------------------------------ r244 | rbd | 2016-11-02 13:33:49 -0500 (Wed, 02 Nov 2016) | 2 lines Forgot to include this in the repo ------------------------------------------------------------------------ r243 | rbd | 2016-10-11 12:23:21 -0500 (Tue, 11 Oct 2016) | 1 line Prepare for v3.11b ------------------------------------------------------------------------ r242 | rbd | 2016-10-11 12:19:31 -0500 (Tue, 11 Oct 2016) | 2 lines Improved documentation and formatting. This is for version 3.11b (64-bit Windows only) ------------------------------------------------------------------------ r241 | rbd | 2016-10-11 10:59:51 -0500 (Tue, 11 Oct 2016) | 2 lines Fixed bug in fftlib.c which took the negative of an unsigned long. ------------------------------------------------------------------------ r240 | rbd | 2016-10-06 15:49:51 -0500 (Thu, 06 Oct 2016) | 2 lines Fixed spec-plot parameter checking, which was totally broken before. ------------------------------------------------------------------------ r239 | rbd | 2016-10-06 15:23:22 -0500 (Thu, 06 Oct 2016) | 2 lines Better conversion into Latex and pdf manual. Other minor fixes. ------------------------------------------------------------------------ r238 | rbd | 2016-08-25 13:01:45 -0500 (Thu, 25 Aug 2016) | 1 line Adding readme for top level download folder on SourceForge. ------------------------------------------------------------------------ r237 | rbd | 2016-08-25 09:07:08 -0500 (Thu, 25 Aug 2016) | 1 line Install is now for x64 architecture. Fixed cell_aut demo to run in IDE sound browser. Modified NyquistThread to create default XLISPPATH from Nyquist dir instead of cwd. ------------------------------------------------------------------------ r236 | rbd | 2016-08-24 21:25:56 -0500 (Wed, 24 Aug 2016) | 2 lines minor change during release from OS X ------------------------------------------------------------------------ r235 | rbd | 2016-08-24 21:16:55 -0500 (Wed, 24 Aug 2016) | 2 lines Making new release ------------------------------------------------------------------------ r234 | rbd | 2016-08-24 21:05:22 -0500 (Wed, 24 Aug 2016) | 2 lines Adding missing file to repo. ------------------------------------------------------------------------ r233 | rbd | 2016-08-24 09:23:39 -0500 (Wed, 24 Aug 2016) | 1 line Fixed undefined freeimage problem by moving freeimage out of the conditional compilation. freeimage is defined so that when Nyquist shuts down it can free most of the memory it allocated, minimizing (false positive) reports of memory leaks, which are harmless (except that they obscure true positive messages and seem surprising to non-xlisp experts). Undefined SAVERESTORE flag the way it used to be because save and restore functions (other than freeimage) do not work with the Nyquist SOUND type extension to XLISP. ------------------------------------------------------------------------ r232 | rbd | 2016-07-19 09:39:45 -0500 (Tue, 19 Jul 2016) | 2 lines I was going to keep "debug" versions separate because of the runtime overhead, but the code started to diverge and it's hard to maintain two versions, so we're going to make all the type checking standard. If you want an optimized version, you could strip out the calls to ny:typecheck using list processing and it would probably work. You could even write NY:OPTIMIZE that would poke into all the function definitions and destructively edit the code. ------------------------------------------------------------------------ r231 | rbd | 2016-07-19 09:34:16 -0500 (Tue, 19 Jul 2016) | 2 lines moved to test/ ------------------------------------------------------------------------ r230 | rbd | 2016-07-19 09:32:11 -0500 (Tue, 19 Jul 2016) | 2 lines Added extensive type checking to nyquist built-in (but not primitive) functions, and added unit tests for type checking, and incorporated unit tests into regression-test.lsp, a new "grand" test sequence. ------------------------------------------------------------------------ r229 | rbd | 2016-06-23 14:28:03 -0500 (Thu, 23 Jun 2016) | 2 lines New code to build NyquistIDE.app -- the old appbundler stuff is no longer needed ------------------------------------------------------------------------ r228 | rbd | 2016-06-23 06:44:49 -0500 (Thu, 23 Jun 2016) | 2 lines Appbundler is Oracle software used to build NyquistIDE - originally from java.net, but it seems to be not an active project (maybe that is good) so let's keep a copy just in case. ------------------------------------------------------------------------ r227 | rbd | 2016-06-22 16:02:26 -0500 (Wed, 22 Jun 2016) | 2 lines previous change to snd_list_unref was VERY wrong; here is the fix. ------------------------------------------------------------------------ r226 | rbd | 2016-06-22 13:46:44 -0500 (Wed, 22 Jun 2016) | 2 lines inserted some memory-freeing code from upstream (Audacity); made snd_list_unref non-recursive; CMakeLists.txt was not working on Mac 10.11.5 -- still can't build NyquistIDE, so more changes are on the way ------------------------------------------------------------------------ r225 | rbd | 2016-05-11 10:54:16 -0500 (Wed, 11 May 2016) | 2 lines Overhaul of new typechecking and parameter validation and error reporting code. Mostly untested, but tests to be done are in typechecks.sal ------------------------------------------------------------------------ r224 | rbd | 2016-05-06 07:56:11 -0500 (Fri, 06 May 2016) | 2 lines Improved plot in nyqide, progress on validating parameters for SAL, spec-plot defined, autoload spec-plot and piano synthesis functions ------------------------------------------------------------------------ r223 | rbd | 2016-05-03 13:07:14 -0500 (Tue, 03 May 2016) | 2 lines This contains work in progress on validating parameters in many nyquist functions, fixing liblo for win64, and some security (integer overflow) problems - probably does not compile ------------------------------------------------------------------------ r222 | rbd | 2016-03-16 10:34:15 -0500 (Wed, 16 Mar 2016) | 2 lines Updated documentation with minor additions and corrections. ------------------------------------------------------------------------ r221 | rbd | 2016-01-15 18:59:45 -0600 (Fri, 15 Jan 2016) | 2 lines Fixed file name for Browser ------------------------------------------------------------------------ r220 | rbd | 2016-01-15 18:49:15 -0600 (Fri, 15 Jan 2016) | 2 lines Changes to fix compilation on OS X ------------------------------------------------------------------------ r219 | rbd | 2016-01-15 18:31:23 -0600 (Fri, 15 Jan 2016) | 2 lines fixed build code for linux, made some c code more compatible ------------------------------------------------------------------------ r218 | rbd | 2016-01-14 17:08:39 -0600 (Thu, 14 Jan 2016) | 1 line modifications from Windows 7 port (static libraries) and browser files pointed to demos/src new location. ------------------------------------------------------------------------ r217 | rbd | 2016-01-14 13:04:24 -0600 (Thu, 14 Jan 2016) | 2 lines Now that cmake is in use, we do not need old Makefiles ------------------------------------------------------------------------ r216 | rbd | 2016-01-11 02:00:08 -0600 (Mon, 11 Jan 2016) | 1 line fixed to compile on XCode ------------------------------------------------------------------------ r215 | rbd | 2016-01-11 01:32:58 -0600 (Mon, 11 Jan 2016) | 1 line examples tried to play drums, but they may not be installed ------------------------------------------------------------------------ r214 | rbd | 2016-01-11 01:05:00 -0600 (Mon, 11 Jan 2016) | 1 line more win7 fixes ------------------------------------------------------------------------ r213 | rbd | 2016-01-11 00:42:57 -0600 (Mon, 11 Jan 2016) | 2 lines more file and path problems fixed ------------------------------------------------------------------------ r212 | rbd | 2016-01-11 00:19:55 -0600 (Mon, 11 Jan 2016) | 2 lines fixed lpc demo ------------------------------------------------------------------------ r211 | rbd | 2016-01-10 23:45:50 -0600 (Sun, 10 Jan 2016) | 1 line fix read-float, restore pianosyn.lsp ------------------------------------------------------------------------ r210 | rbd | 2016-01-10 23:36:35 -0600 (Sun, 10 Jan 2016) | 1 line fix references to demo-snd.aiff which is in demos/audio now ------------------------------------------------------------------------ r209 | rbd | 2016-01-10 22:32:08 -0600 (Sun, 10 Jan 2016) | 1 line getting 3.10 to run on windows, has temp debug info in pianosyn.lsp ------------------------------------------------------------------------ r208 | rbd | 2016-01-10 20:49:37 -0600 (Sun, 10 Jan 2016) | 2 lines Forgot to add new demo files ------------------------------------------------------------------------ r207 | rbd | 2016-01-10 20:31:40 -0600 (Sun, 10 Jan 2016) | 2 lines fixed downsample.c, other minor release problems ------------------------------------------------------------------------ r206 | rbd | 2016-01-10 14:01:58 -0600 (Sun, 10 Jan 2016) | 2 lines missing files (maybe only cmupvdbg.h is really needed) ------------------------------------------------------------------------ r205 | rbd | 2016-01-10 12:10:01 -0600 (Sun, 10 Jan 2016) | 2 lines No more scribe, so no more auto generation of text-only documentation. Hopefully HTML will suffice. PDF is now done by latex (but I forgot to move it into the doc directory before). ------------------------------------------------------------------------ r204 | rbd | 2016-01-10 12:01:55 -0600 (Sun, 10 Jan 2016) | 2 lines Nearing release of 3.10 -- major changes are phasevocoder, convolution, demo documentation ------------------------------------------------------------------------ r203 | rbd | 2016-01-10 11:38:35 -0600 (Sun, 10 Jan 2016) | 2 lines Made revisions for 3.10. Not quite done yet. ------------------------------------------------------------------------ r202 | rbd | 2015-12-28 22:33:51 -0600 (Mon, 28 Dec 2015) | 2 lines Updating demos to SAL syntax and better "front page". ------------------------------------------------------------------------ r201 | rbd | 2015-05-20 19:46:16 -0500 (Wed, 20 May 2015) | 2 lines Fixed more warnings about types. Still working on convolve though. ------------------------------------------------------------------------ r200 | rbd | 2015-05-20 06:16:32 -0500 (Wed, 20 May 2015) | 2 lines Forgot to move the final pdf of the manual to doc. ------------------------------------------------------------------------ r199 | rbd | 2015-05-20 06:14:25 -0500 (Wed, 20 May 2015) | 2 lines Fixed some documentation -- it might be complete now. Removed extra play command from organ.lsp. ------------------------------------------------------------------------ r198 | rbd | 2015-05-19 21:32:24 -0500 (Tue, 19 May 2015) | 2 lines Fixed some problems and warnings when compiling on Ubuntu Linux ------------------------------------------------------------------------ r197 | rbd | 2015-05-19 20:55:04 -0500 (Tue, 19 May 2015) | 2 lines Merged Win32 changes with OS X, removed some .sln and .vcproj files that are not needed now that we are using CMake ------------------------------------------------------------------------ r196 | rbd | 2015-05-19 20:27:30 -0500 (Tue, 19 May 2015) | 1 line Got nyquist and jnyqide to build on Windows under Visual Studio Express 2013. Many changes to remove some compiler warnings. ------------------------------------------------------------------------ r195 | rbd | 2015-05-14 21:52:33 -0500 (Thu, 14 May 2015) | 2 lines better device selection for ALSA and added cross-platform help to find and select devices; added icon to jny on Linux (should work on Windows) ------------------------------------------------------------------------ r194 | rbd | 2015-05-12 21:08:59 -0500 (Tue, 12 May 2015) | 2 lines still more missing files ------------------------------------------------------------------------ r193 | rbd | 2015-05-12 21:07:41 -0500 (Tue, 12 May 2015) | 2 lines more missing files ------------------------------------------------------------------------ r192 | rbd | 2015-05-12 21:04:50 -0500 (Tue, 12 May 2015) | 2 lines another missing file ------------------------------------------------------------------------ r191 | rbd | 2015-05-12 20:56:39 -0500 (Tue, 12 May 2015) | 2 lines repo missing a file ------------------------------------------------------------------------ r190 | rbd | 2015-05-12 20:28:25 -0500 (Tue, 12 May 2015) | 2 lines repo is missing a file ------------------------------------------------------------------------ r189 | rbd | 2015-05-12 20:16:10 -0500 (Tue, 12 May 2015) | 2 lines cleaned out files we don't use ------------------------------------------------------------------------ r188 | rbd | 2015-05-12 12:42:57 -0500 (Tue, 12 May 2015) | 2 lines Updated liblo to v0.28 and tested that it compiles with nyquist on XCode ------------------------------------------------------------------------ r187 | rbd | 2015-05-12 07:00:06 -0500 (Tue, 12 May 2015) | 2 lines FLAC changes were incomplete. This revision compiles. ------------------------------------------------------------------------ r186 | rbd | 2015-05-12 06:39:06 -0500 (Tue, 12 May 2015) | 2 lines Updated FLAC to 1.3.1, removed unnecessary files from local copy of sources. ------------------------------------------------------------------------ r185 | rbd | 2015-05-11 22:51:11 -0500 (Mon, 11 May 2015) | 2 lines I updated libvorbis from 1.3.5 and deleted unneeded files ------------------------------------------------------------------------ r184 | rbd | 2015-05-11 22:29:41 -0500 (Mon, 11 May 2015) | 2 lines I decided to just keep sources in libraries that are needed to build Nyquist, so I'm removing lots of build and configuration files. So far, portaudio is updated to V19 and libogg is updated to 1.3.2 ------------------------------------------------------------------------ r183 | rbd | 2015-05-11 15:00:14 -0500 (Mon, 11 May 2015) | 2 lines macosxproject/CMakeLists.txt is now in place to generate nyquist.xcodeproj. Since it is generated by CMake, I removed it from the repo. ------------------------------------------------------------------------ r182 | rbd | 2015-05-11 14:03:53 -0500 (Mon, 11 May 2015) | 2 lines Added sliders, documentation is now in latex, new Java build, CMake is used to create project in OS X, many other changes. This is NOT a release! Next step will be to get the CMake-built project into the right name and directory. ------------------------------------------------------------------------ r181 | rbd | 2015-03-19 19:40:00 -0500 (Thu, 19 Mar 2015) | 2 lines This is a failed attempt to use PanDoc to make a Nyquist manual, now that Scribe seems to have died. This is the point where I am changing the code to write directly to Latex. ------------------------------------------------------------------------ r180 | rbd | 2015-03-18 10:17:44 -0500 (Wed, 18 Mar 2015) | 2 lines Update version numbers to 3.10 ------------------------------------------------------------------------ r179 | rbd | 2015-03-17 20:17:35 -0500 (Tue, 17 Mar 2015) | 2 lines minor bug fixes ------------------------------------------------------------------------ r178 | rbd | 2015-03-17 20:05:13 -0500 (Tue, 17 Mar 2015) | 1 line Various changes from Windows version.res
1295 lines
36 KiB
C
1295 lines
36 KiB
C
/* userio.c -- handy user interface functions */
|
||
/* Copyright 1989 Carnegie Mellon University */
|
||
|
||
/*****************************************************************************
|
||
* Change Log
|
||
* Date | Change
|
||
*-----------+-----------------------------------------------------------------
|
||
* 21-May-86 | Created
|
||
* 11-Aug-87 | F.H: Added clear_abort(), stop()
|
||
* May-88 | JCD : AMIGA VERSION
|
||
* 11-Jun-88 | RBD: disable printing of GDEBUG messages
|
||
* 12-Oct-88 | JCD : EXCLUSIVE AMIGA VERSION
|
||
* 13-Apr-89 | JCD : New portable version.
|
||
* 5-Apr | JDW : Further changes
|
||
* 2-Mar-92 | GWL : Little changes to satisfy compiler
|
||
* 19-Nov-92 | JDZ : Mach tty io threads
|
||
* 28-Apr-03 | DM : portability changes. true->TRUE, false->FALSE
|
||
*****************************************************************************/
|
||
|
||
/* Notes on ascii input:
|
||
|
||
Input is complicated because different systems have varying input models,
|
||
especially with regard to handling ^C. The CMT model handles ^C and ^G as
|
||
special characters, and these do not cause software interrupts. Also, the
|
||
lowest level of the CMT model does not support line editing: Every character
|
||
is acted upon immediately. This has two implications:
|
||
(1) CMT must "read ahead" looking for ^C and ^G characters. This is handled
|
||
by the check_aborted() procedure, which reads characters into the
|
||
type_ahead[] array.
|
||
(2) CMT must do its own line editing. This is handled by the ggets() routine.
|
||
|
||
A number of functions support ascii input, only some of which are visible
|
||
to the application programmer. Let's start at the top-level and work down;
|
||
each of the following calls the routine below it:
|
||
|
||
ggets() - gets a string with line editing support. This function is fairly
|
||
machine independent, except for some backspace-and-erase control character
|
||
code sequences.
|
||
|
||
ggetchar() - gets a raw character. This function calls wait_ascii()
|
||
and echoes it. Note that it may return ABORT_CHAR or BREAK_CHAR.
|
||
|
||
wait_ascii() - gets a raw character without echo and without character
|
||
code translation. wait_ascii() either polls get_ascii() or uses some
|
||
kind of system-dependent event waiting. Returns ABORT_CHAR or BREAK_CHAR
|
||
immediately if abort_flag has been set, regardless of whether there is
|
||
new ascii input.
|
||
|
||
get_ascii() - checks to see if a character is available. (Using
|
||
check_aborted().)
|
||
The only dependency here is on the Amiga, we restart input when buffer goes
|
||
from full to non-full.
|
||
|
||
check_aborted() - looks for input by calling ascii_input. If found,
|
||
put the input into the type_ahead[] buffer. Returns abort_flag.
|
||
|
||
ascii_input() - lowest level of input; just gets a character if there is
|
||
one. Does conversion from RETURN (\r) to EOL (\n). The Amiga handles
|
||
this in-line directly in check_aborted().
|
||
|
||
Here's a quick summary:
|
||
|
||
ggets = ggetchar + line editing & string building
|
||
ggetchar = wait_ascii + character echo
|
||
wait_ascii = get_ascii + wait for character
|
||
get_ascii = check_aborted + pull char from buffer
|
||
check_aborted = ascii_input + test for ^C,^G + put in buffer
|
||
ascii_input = poll for char + CR->EOL conversion
|
||
|
||
*/
|
||
|
||
#include "switches.h"
|
||
|
||
#include <stdio.h>
|
||
#include <string.h>
|
||
#if HAS_STDLIB_H
|
||
#include <stdlib.h> /* normal case */
|
||
#endif
|
||
|
||
|
||
#ifdef MACINTOSH
|
||
# include "StandardFile.h"
|
||
/* added for ThinkC 7 */
|
||
# ifdef THINK_C
|
||
# include <pascal.h>
|
||
# endif
|
||
#endif
|
||
|
||
#ifdef AMIGA
|
||
|
||
# ifdef AZTEC
|
||
# include "functions.h"
|
||
# else /* LATTICE */
|
||
# include "amiga.h"
|
||
# include "stdarg.h"
|
||
# endif
|
||
|
||
# include "intuition/intuition.h"
|
||
# include "devices/console.h"
|
||
#endif
|
||
|
||
#include "ctype.h"
|
||
#include "stdio.h"
|
||
#include "cext.h"
|
||
#include "userio.h"
|
||
|
||
#ifdef MICROSOFT
|
||
#include "signal.h"
|
||
#endif
|
||
|
||
#ifdef UNIX_MACH
|
||
#include <varargs.h>
|
||
#include <midistruct.h>
|
||
extern char a_in;
|
||
extern int a_in_flag;
|
||
extern int i_am_running;
|
||
#ifdef RTMach
|
||
extern itc_mutex_t a_mutex;
|
||
extern itc_condition_t a_cond, a_in_cond;
|
||
#define A_LOCK() itc_mutex_lock(&a_mutex)
|
||
#define A_UNLOCK() itc_mutex_unlock(&a_mutex)
|
||
#else /* RTMach */
|
||
extern struct mutex a_mutex;
|
||
extern struct condition a_cond, a_in_cond;
|
||
#define A_LOCK() mutex_lock(&a_mutex)
|
||
#define A_UNLOCK() mutex_unlock(&a_mutex)
|
||
#endif /* RTMach */
|
||
#endif
|
||
|
||
#ifdef DOTS_FOR_ARGS
|
||
#include <stdarg.h>
|
||
#endif
|
||
|
||
#ifdef UNIX
|
||
#include <sys/param.h>
|
||
#include <sys/resource.h>
|
||
#include "cmtio.h"
|
||
#ifdef _IBMR2
|
||
#define NBBY 8
|
||
#define OPEN_MAX 2000
|
||
#endif
|
||
#include <sys/select.h>
|
||
#endif
|
||
|
||
#ifdef linux
|
||
#include <sys/time.h> /* for FD_ZERO / FD_SET */
|
||
#endif
|
||
|
||
extern int debug;
|
||
|
||
#ifdef NYQUIST
|
||
/* get definitions for stdputstr, etc. */
|
||
#include "xlisp.h"
|
||
#endif
|
||
|
||
|
||
/****************************************************************************
|
||
*
|
||
* routines private to this module
|
||
*
|
||
****************************************************************************/
|
||
|
||
int GetReadFileName();
|
||
int GetWriteFileName();
|
||
|
||
#ifdef MACINTOSH
|
||
private void PtoC_StrCopy(char *p1, char *p2);
|
||
#endif
|
||
|
||
#ifdef AMIGA
|
||
char ConGetChar();
|
||
ConMayGetChar();
|
||
private void ConRead();
|
||
private void ConPutStr();
|
||
private void ConPutChar();
|
||
UBYTE ascii_signal();
|
||
UBYTE KeybSig();
|
||
#endif
|
||
|
||
|
||
/****************************************************************************
|
||
*
|
||
* variables shared with other modules
|
||
*
|
||
****************************************************************************/
|
||
|
||
public int abort_flag; /* control C or control G equivalent */
|
||
public int redirect_flag; /* check whether the I/O has been redirected--
|
||
Added by Ning Hu Apr.2001*/
|
||
/* extern void musicterm(); */ /*DMH: from macmidi.c, to allow abort_check*/
|
||
public boolean ascii_input();
|
||
|
||
/****************************************************************************
|
||
*
|
||
* variables private to this module
|
||
*
|
||
****************************************************************************/
|
||
|
||
#ifdef AMIGA
|
||
struct IntuitionBase *IntuitionBase;
|
||
private struct IOStdReq *ConOutReq;
|
||
private struct MsgPort *ConOutPort;
|
||
private struct IOStdReq *ConInReq;
|
||
private struct MsgPort *ConInPort;
|
||
private char KeyBuff[16];
|
||
private struct Window *Window;
|
||
private struct NewWindow NewWindow = {
|
||
0,11,640,189,
|
||
0,1,
|
||
NULL,
|
||
SMART_REFRESH | ACTIVATE | WINDOWDRAG | WINDOWDEPTH |
|
||
WINDOWSIZING,
|
||
NULL,NULL,
|
||
(STRPTR) "Carnegie Mellon University MIDI Toolkit for Commodore AMIGA",
|
||
NULL,NULL,
|
||
100,25,640,200,
|
||
WBENCHSCREEN };
|
||
#endif
|
||
|
||
#ifdef MACINTOSH
|
||
private OSType io_file_type = 0x3F3F3F3F; /* '????' */
|
||
private OSType io_file_creator = 0x3F3F3F3F; /* '????' */
|
||
#endif
|
||
|
||
#define type_ahead_max 100
|
||
char type_ahead[100];
|
||
int type_ahead_head = 0;
|
||
int type_ahead_tail = 0;
|
||
int type_ahead_count = 0;
|
||
|
||
|
||
#ifdef DOS
|
||
#ifdef BORLAND
|
||
int c_break(void)
|
||
{
|
||
gprintf(TRANS, " BREAK ");
|
||
abort_flag = ABORT_LEVEL;
|
||
return 1; /* non-zero means do not exit program */
|
||
}
|
||
#endif
|
||
#ifdef MICROSOFT
|
||
void c_break(int sig)
|
||
{
|
||
abort_flag = ABORT_LEVEL;
|
||
/* The CTRL+C interrupt must be reset to our handler since
|
||
* by default it is reset to the system handler.
|
||
*/
|
||
signal(SIGINT, c_break); /* assume this succeeds */
|
||
}
|
||
#endif
|
||
#endif
|
||
|
||
#ifdef MACINTOSH
|
||
#ifdef NYQUIST
|
||
void FlushOutput (void);
|
||
#endif
|
||
#endif
|
||
|
||
/* gflush -- flush output produced by gprintf, etc. */
|
||
/**/
|
||
void gflush(void)
|
||
{
|
||
#ifdef MACINTOSH
|
||
#ifdef NYQUIST
|
||
FlushOutput();
|
||
#else
|
||
fflush(stdout); /* make sure any prompts or errors have been output */
|
||
fflush(STDERR);
|
||
#endif /* NYQUIST */
|
||
#endif /* MACINTOSH */
|
||
#ifdef UNIX
|
||
fflush(stdout); /* make sure any prompts or errors have been output */
|
||
fflush(STDERR);
|
||
#endif
|
||
}
|
||
|
||
|
||
/****************************************************************************
|
||
* io_init
|
||
*
|
||
* I added this init function for the AMIGA version.
|
||
*
|
||
* io_init : opens a window
|
||
* and exits if initialisation can not be done properly.
|
||
* registers cleanup calls to carefully deallocate resources.
|
||
*
|
||
* io_init is not amiga specific : the simplest version
|
||
* of io_init could be a clear screen statement for example, and a
|
||
* printf("Good bye !\n") on exit.
|
||
*
|
||
* for the Mac, it seems that ascii_input doesn't work unless getchar() is
|
||
* called first. I assume this is because getchar() initializes the ability
|
||
* of the window to process type-in, so there is probably a way to set this
|
||
* directly. If you figure it out, let me know. -RBD
|
||
*
|
||
*****************************************************************************/
|
||
|
||
void
|
||
io_init()
|
||
{
|
||
|
||
#ifdef AMIGA
|
||
int error;
|
||
|
||
/* Window and console initialisation */
|
||
IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library",1L);
|
||
if (IntuitionBase == NULL) EXIT(1);
|
||
cu_register((cu_fn_type) CloseLibrary, IntuitionBase);
|
||
|
||
ConOutPort = CreatePort("conoutport", 0L);
|
||
if (ConOutPort == NULL) EXIT(1);
|
||
cu_register((cu_fn_type) DeletePort, ConOutPort);
|
||
|
||
ConOutReq = CreateStdIO(ConOutPort);
|
||
if (ConOutReq == NULL) EXIT(1);
|
||
cu_register((cu_fn_type) DeleteStdIO, ConOutReq);
|
||
|
||
ConInPort = CreatePort("coninport", 0L);
|
||
if (ConInPort == NULL) EXIT(1);
|
||
cu_register((cu_fn_type) DeletePort, ConInPort);
|
||
|
||
ConInReq = CreateStdIO(ConInPort);
|
||
if (ConInReq == NULL) EXIT(1);
|
||
cu_register((cu_fn_type) DeleteStdIO, ConInReq);
|
||
|
||
Window = OpenWindow(&NewWindow);
|
||
if (Window == NULL) EXIT(1);
|
||
cu_register((cu_fn_type) CloseWindow, Window);
|
||
|
||
ConOutReq->io_Data = (APTR)Window;
|
||
ConOutReq->io_Length = sizeof(*Window);
|
||
error = OpenDevice("console.device", 0L, (struct IORequest *) ConOutReq, 0L);
|
||
ConInReq->io_Device = ConOutReq->io_Device;
|
||
ConInReq->io_Unit = ConOutReq->io_Unit;
|
||
if (error != NULL) EXIT(1);
|
||
cu_register((cu_fn_type) CloseDevice, ConOutReq);
|
||
|
||
ConInReq->io_Command = CMD_READ;
|
||
ConInReq->io_Data = (APTR)KeyBuff;
|
||
ConInReq->io_Length = 1;
|
||
SendIO((struct IORequest *) ConInReq);
|
||
#endif
|
||
|
||
#ifdef UNIX
|
||
#ifndef BUFFERED_SYNCHRONOUS_INPUT
|
||
IOsetup(0 /* standard input */);
|
||
cu_register((cu_fn_type) IOcleanup, NULL);
|
||
#endif
|
||
#endif
|
||
|
||
#ifdef MACINTOSH
|
||
#ifndef NYQUIST /* don't need this if we're in Nyquist */
|
||
char s[100];
|
||
printf("Type <return> to start: ");
|
||
fgets(s, 100, stdin);
|
||
#endif /* NYQUIST */
|
||
#endif
|
||
|
||
#ifdef DOS
|
||
#ifdef MICROSOFT
|
||
if (signal(SIGINT, c_break) == SIG_ERR) {
|
||
gprintf(ERROR, "Couldn't set Ctrl C handler\n");
|
||
EXIT(1);
|
||
}
|
||
#else
|
||
#ifdef BORLAND
|
||
ctrlbrk(c_break);
|
||
#else
|
||
... we are in DOS, but neither MICROSOFT nor BORLAND,
|
||
please set up a control C handler here...
|
||
#endif
|
||
#endif
|
||
#endif
|
||
}
|
||
|
||
#ifdef MACINTOSH
|
||
|
||
/****************************************************************************
|
||
* abort_check
|
||
* Effect:
|
||
* exit nicely if the aborted flag is set
|
||
****************************************************************************/
|
||
|
||
public void abort_check()
|
||
{
|
||
if (abort_flag) clean_exit();
|
||
}
|
||
|
||
|
||
/****************************************************************************
|
||
* clean_exit
|
||
* Effect:
|
||
* clean up and exit
|
||
****************************************************************************/
|
||
|
||
public void clean_exit()
|
||
{
|
||
gprintf(TRANS, "Exiting...\n");
|
||
EXIT(1);
|
||
}
|
||
|
||
#ifdef MPW
|
||
/****************************************************************************
|
||
* cleanup_abort_handler
|
||
* Effect:
|
||
* shuts down abort watcher
|
||
****************************************************************************/
|
||
|
||
public void cleanup_abort_handler()
|
||
{
|
||
(void) sigset(SIGINT, SIG_DFL); /* deactivate abort watcher */
|
||
}
|
||
|
||
|
||
/****************************************************************************
|
||
* init_abort_handler
|
||
* Effect:
|
||
* starts abort watcher
|
||
* aborted flag is set to FALSE
|
||
****************************************************************************/
|
||
|
||
public void init_abort_handler()
|
||
{
|
||
abort_flag = FALSE;
|
||
(void) sigset(SIGINT, abort_watcher); /* activate abort watcher */
|
||
}
|
||
#endif
|
||
|
||
#endif
|
||
|
||
|
||
/****************************************************************************
|
||
* askbool
|
||
* Inputs:
|
||
* char *prompt: string to prompt for user input
|
||
* int deflt: TRUE or FALSE default
|
||
* Returns:
|
||
* boolean: TRUE or FALSE as entered by user
|
||
* Effect:
|
||
* prompts user for yes or no input, returns result
|
||
****************************************************************************/
|
||
|
||
int askbool(prompt, deflt)
|
||
char *prompt;
|
||
int deflt;
|
||
{
|
||
#define undefined -1
|
||
char defchar; /* the default answer */
|
||
char c; /* user input */
|
||
char in_string[100];
|
||
int result = -1; /* the result: -1 = undefined, 0 = FALSE, 1 = TRUE */
|
||
if (deflt) defchar = 'y';
|
||
else defchar = 'n';
|
||
while (result == undefined) {
|
||
gprintf(TRANS, "%s? [%c]: ", prompt, defchar);
|
||
ggets(in_string);
|
||
c = in_string[0];
|
||
if (islower(c)) c = toupper(c);
|
||
if (c == 'Y') result = TRUE;
|
||
else if (c == 'N') result = FALSE;
|
||
else if (c == EOS) result = deflt;
|
||
else if (abort_flag) result = deflt;
|
||
/* space before Please to separate from user's type-in: */
|
||
else gprintf(TRANS, " Please type Y or N.\n");
|
||
}
|
||
if (abort_flag == BREAK_LEVEL) {
|
||
abort_flag = 0;
|
||
result = deflt;
|
||
gprintf(TRANS, "\n");
|
||
}
|
||
return result;
|
||
}
|
||
|
||
|
||
/****************************************************************************
|
||
* fileopen
|
||
* Inputs:
|
||
* char *deflt: the default file name (e.g. from command line)
|
||
* char *extension: default extension
|
||
* char *mode: read ("r") or write ("w")
|
||
* char *prompt: prompt for user
|
||
* Returns:
|
||
* opened file pointer
|
||
* Effect:
|
||
* opens file, prompts for user input if necessary and warns about
|
||
* possible confusion. If deflt is a null string or NULL, the user will
|
||
* be prompted for a name. The routine loops until a file is opened.
|
||
* If the mode is "r", a check is made to see if the file exists
|
||
* with and without the extension. If both exist a warning is given.
|
||
* For mode "w", a check is made to see if the file will be overwritten.
|
||
* The extension is automatically added if the default or user-typed
|
||
* file has no "." At the bottom of the loop body, if no file has
|
||
* been opened, the user is prompted for another file name.
|
||
****************************************************************************/
|
||
|
||
char fileopen_name[100]; /* name of the opened file */
|
||
|
||
FILE *fileopen(deflt, extension, mode, prompt)
|
||
char *deflt;
|
||
char *extension; /* default extension */
|
||
char *mode; /* read "r" or write "w" */
|
||
char *prompt; /* prompt for user */
|
||
{
|
||
char extname[100]; /* trial name with extension added */
|
||
FILE *fp = NULL; /* file corresponding to filename */
|
||
FILE *fpext; /* file corresponding to extname */
|
||
char *problem = NULL; /* tells user why he has to try again */
|
||
|
||
if (!deflt) deflt = ""; /* treat NULL as the empty string */
|
||
strcpy(fileopen_name, deflt);
|
||
/* keep trying until a good file is found: */
|
||
while (fp == NULL) {
|
||
/* avoid null file names: */
|
||
while (strlen(fileopen_name) == 0) {
|
||
#ifndef MACINTOSH
|
||
gprintf(TRANS, "%s : ", prompt);
|
||
ggets(fileopen_name);
|
||
if (abort_flag) {
|
||
if (abort_flag == BREAK_LEVEL) {
|
||
abort_flag = 0;
|
||
/* type return since user didn't... */
|
||
gprintf(TRANS, "\n");
|
||
}
|
||
return NULL;
|
||
}
|
||
#else /* use Macintosh file dialog */
|
||
if (mode[0] == 'r') {
|
||
if (!GetReadFileName(fileopen_name)) return NULL;
|
||
} else if (mode[0] == 'w') {
|
||
if (!(GetWriteFileName(fileopen_name, prompt))) return NULL;
|
||
} else {
|
||
gprintf(ERROR, "(fileopen) internal error: bad mode\n");
|
||
}
|
||
#endif /* MACINTOSH */
|
||
}
|
||
if (mode[0] == 'r') {
|
||
strcpy(extname, fileopen_name);
|
||
strcat(extname, ".");
|
||
strcat(extname, extension);
|
||
fp = NULL;
|
||
fpext = NULL;
|
||
if (ok_to_open(fileopen_name, mode)) {
|
||
fp = fopen(fileopen_name, mode);
|
||
}
|
||
if (ok_to_open(extname, mode)) {
|
||
fpext = fopen(extname, mode);
|
||
}
|
||
if (fp != NULL && fpext != NULL) {
|
||
gprintf(TRANS,
|
||
"warning: both %s and %s exist. %s will be used.\n",
|
||
fileopen_name, extname, fileopen_name);
|
||
fclose(fpext);
|
||
} else if (fpext != NULL) {
|
||
fp = fpext;
|
||
strcpy(fileopen_name, extname); /* remember what was opened */
|
||
}
|
||
if (fp == NULL) problem = "Couldn't find %s.\n";
|
||
} else if (mode[0] == 'w') {
|
||
boolean added_extension = FALSE;
|
||
|
||
/* add the extension if there is no '.' in the file name */
|
||
if (!strchr(fileopen_name, '.')) {
|
||
strcat(fileopen_name, ".");
|
||
strcat(fileopen_name, extension);
|
||
added_extension = TRUE;
|
||
}
|
||
if (TRUE
|
||
#ifdef MACINTOSH
|
||
/* file open dialog already asked user to confirm unless we're
|
||
* adding an extension
|
||
*/
|
||
&& added_extension
|
||
#endif
|
||
) {
|
||
fp = NULL;
|
||
if (ok_to_open(fileopen_name, "r"))
|
||
fp = fopen(fileopen_name, "r");
|
||
if (fp != NULL) {
|
||
char question[100];
|
||
fclose(fp);
|
||
strcpy(question, "OK to overwrite ");
|
||
strcat(question, fileopen_name);
|
||
if (!askbool(question, FALSE)) {
|
||
fp = NULL;
|
||
problem = "\n";
|
||
goto tryagain;
|
||
}
|
||
}
|
||
}
|
||
fp = NULL;
|
||
if (ok_to_open(fileopen_name, mode))
|
||
fp = fopen(fileopen_name, mode);
|
||
if (fp == NULL) problem = "Couldn't create %s.\n";
|
||
}
|
||
tryagain:
|
||
if (fp == NULL) {
|
||
gprintf(TRANS, problem, fileopen_name);
|
||
gprintf(TRANS,"Try again.\n");
|
||
fileopen_name[0] = EOS;
|
||
}
|
||
}
|
||
return fp;
|
||
}
|
||
|
||
#ifdef MACINTOSH
|
||
|
||
static int GetReadFileName(name)
|
||
char *name;
|
||
{
|
||
static Point p = {100,100};
|
||
SFReply loadfile;
|
||
SFTypeList mytypes;
|
||
|
||
mytypes[0] = 0x54455854; /* 'TEXT' */
|
||
mytypes[1] = 0x4D696469; /* 'Midi' */
|
||
mytypes[2] = 0x3F3F3F3F; /* '????' */
|
||
/* could put any filter here (i.e. giofilefileter) */
|
||
SFGetFile(p, "\p", NULL, 3, mytypes, 0L, &loadfile);
|
||
if (loadfile.good) {
|
||
SetVol(0L,loadfile.vRefNum);
|
||
PtoC_StrCopy((char *) &loadfile.fName, name);
|
||
return(true);
|
||
} else return(false);
|
||
}
|
||
|
||
|
||
static int GetWriteFileName(fn, str)
|
||
char *fn, *str;
|
||
{
|
||
static Point SFPwhere = { 106, 104 };
|
||
unsigned char Pstr[100], Pfn[100];
|
||
SFReply reply;
|
||
|
||
strcpy((char *)Pstr, str);
|
||
CtoPstr((char *)Pstr);
|
||
strcpy((char *)Pfn, fn);
|
||
CtoPstr((char *)Pfn);
|
||
|
||
SFPutFile(SFPwhere, (ConstStr255Param) Pstr, (ConstStr255Param) Pfn,
|
||
0L, &reply);
|
||
if (reply.good) {
|
||
SetVol (0L,reply.vRefNum);
|
||
PtoC_StrCopy((char *) &reply.fName, fn);
|
||
return(true);
|
||
}
|
||
else return(false);
|
||
}
|
||
|
||
|
||
void PtoC_StrCopy(p1, p2)
|
||
register char *p1, *p2;
|
||
/* copies a pascal string from p1 to p2 */
|
||
{
|
||
register int len;
|
||
|
||
len = *p1++;
|
||
while (--len>=0) *p2++=*p1++;
|
||
*p2 = '\0';
|
||
}
|
||
|
||
|
||
boolean get_file_info(char *filename, OSType *file_type, OSType *file_creator)
|
||
{
|
||
short rc; /* toolbox return code */
|
||
FInfo fi; /* toolbox file info */
|
||
char fn[101]; /* temporary file name */
|
||
|
||
strcpy(fn, filename);
|
||
CtoPstr(fn);
|
||
if (rc = GetFInfo((byte*)fn, 0, &fi)) {
|
||
gprintf(ERROR, "rc from GetFInfo=%d\n", rc);
|
||
gprintf(ERROR, "unable to get file type\n");
|
||
*file_type = 0x3F3F3F3F; /* '????' */
|
||
*file_creator = 0x3F3F3F3F; /* '????' */
|
||
return FALSE;
|
||
} else /* set file type & creator */ {
|
||
if (debug) gprintf(TRANS, "File Type: '%.4s' File Creator: '%.4s'\n",
|
||
&fi.fdType, &fi.fdCreator );
|
||
*file_type = fi.fdType;
|
||
*file_creator = fi.fdCreator;
|
||
}
|
||
return TRUE;
|
||
}
|
||
|
||
|
||
boolean put_file_info(char *filename, OSType file_type, OSType file_creator)
|
||
{
|
||
short rc; /* toolbox return code */
|
||
FInfo fi; /* toolbox file info */
|
||
char fn[101]; /* temporary file name */
|
||
|
||
if (debug) gprintf(TRANS,"set file %s to become type '%.4s'\n", filename, &file_type);
|
||
strcpy(fn, filename);
|
||
CtoPstr(fn);
|
||
if (rc = GetFInfo((byte*)fn, 0, &fi)) {
|
||
gprintf(TRANS, "rc from GetFInfo=%d\n", rc);
|
||
gprintf(TRANS, "unable to set file type\n");
|
||
} else /* set file type & creator */ {
|
||
if (debug) gprintf(TRANS, "File Type: '%.4s' File Creator: '%.4s'\n",
|
||
&fi.fdType, &fi.fdCreator );
|
||
fi.fdType = file_type;
|
||
fi.fdCreator = file_creator;
|
||
if (rc=SetFInfo((byte*)fn, 0, &fi)) {
|
||
gprintf(TRANS, "rc from SetFInfo=%d\n", rc);
|
||
gprintf(TRANS, "unable to set file type\n");
|
||
} else if (rc=GetFInfo((byte*)fn, 0, &fi)) {
|
||
gprintf(TRANS, "rc from GetFInfo=%d\n", rc);
|
||
gprintf(TRANS, "unable to verify file type\n");
|
||
} else {
|
||
if (debug) gprintf(TRANS, "File Type: '%.4s' File Creator: '%.4s'\n",
|
||
&fi.fdType, &fi.fdCreator );
|
||
}
|
||
}
|
||
}
|
||
#endif /* MACINTOSH */
|
||
|
||
|
||
|
||
#ifdef AMIGA
|
||
/***************************************************************
|
||
* ascii_signal
|
||
*
|
||
* Input : none
|
||
* Ouput : none
|
||
* Return: the signal that will be raised on ascii input
|
||
* Effect: none
|
||
***************************************************************/
|
||
|
||
UBYTE ascii_signal()
|
||
{
|
||
return ConInPort->mp_SigBit;
|
||
}
|
||
#endif
|
||
|
||
/* check_aborted -- see if any characters are available, check for ctrl C */
|
||
|
||
int check_aborted()
|
||
{
|
||
char in_c;
|
||
#ifdef AMIGA
|
||
if (GetMsg(ConInPort)) {
|
||
in_c = KeyBuff[0];
|
||
if (in_c == '\r') in_c = '\n';
|
||
#endif
|
||
#ifndef AMIGA /* DOS or MACINTOSH or UNIX */
|
||
if (type_ahead_count < type_ahead_max && ascii_input(&in_c)) {
|
||
#endif
|
||
type_ahead[type_ahead_tail] = in_c;
|
||
if (in_c == ABORT_CHAR) abort_flag = ABORT_LEVEL;
|
||
else if (!abort_flag && in_c == BREAK_CHAR)
|
||
abort_flag = BREAK_LEVEL;
|
||
|
||
/* go ahead and insert anything into buffer, including ^C, ^G: */
|
||
type_ahead_count++;
|
||
type_ahead_tail++;
|
||
if (type_ahead_tail == type_ahead_max) type_ahead_tail = 0;
|
||
|
||
#ifdef AMIGA
|
||
if (type_ahead_count < type_ahead_max) ConRead();
|
||
#endif
|
||
}
|
||
return abort_flag;
|
||
}
|
||
|
||
|
||
/****************************************************************************
|
||
* readln
|
||
* Inputs:
|
||
* FILE * fp: File to read from
|
||
* Effect:
|
||
* Reads and discards characters until a newline is seen
|
||
****************************************************************************/
|
||
|
||
void readln(fp)
|
||
register FILE *fp;
|
||
{
|
||
register int c;
|
||
while (((c = getc(fp)) != '\n') && (c != EOF)) ;
|
||
}
|
||
|
||
|
||
/****************************************************************************
|
||
* gprintf
|
||
* Inputs:
|
||
* int * handler: pointer to output handler (say, a window)
|
||
* or one of {TRANS, ERROR, FATAL, GDEBUG} from userio.h
|
||
* char * format: a null-terminated printf style format string
|
||
* int arg0 through arg14: a variable number of arguments for printf
|
||
* Effect:
|
||
* formats and outputs the specified information to an output handler.
|
||
* this is a system-independent approach to output. On
|
||
* a simple machine, it is like printf. on a more complex machine,
|
||
* output is directed to the appropriate window.
|
||
* Implementation
|
||
* Note that to handle the variable argument list, a number of different
|
||
* approaches are implemented. The first part of the implementation selects
|
||
* one of 4 ways to build temp1, a formatted string. The 4 ways arise from
|
||
* use or non-use of vsnprintf, and use or non-use of ... in the arg list.
|
||
* After building temp1, non-Amiga systems write to stdout or stderr,
|
||
* whereas AMIGA writes to a special console. Why? Because the Amiga
|
||
* needs a new console so we can set up a signal upon character typein.
|
||
****************************************************************************/
|
||
|
||
#ifndef gprintf
|
||
#define GPRINTF_MESSAGE_LEN 512
|
||
#ifdef HAVE_VSNPRINTF
|
||
#ifdef DOTS_FOR_ARGS
|
||
|
||
/* define with ... in arg list and use vsnprintf to get temp1 */
|
||
public void gprintf(long where, char *format, ...)
|
||
{
|
||
char temp1[GPRINTF_MESSAGE_LEN];
|
||
#ifdef AMIGA
|
||
char temp2[GPRINTF_MESSAGE_LEN];
|
||
#endif
|
||
va_list ap;
|
||
|
||
va_start(ap, format);
|
||
vsnprintf(temp1, GPRINTF_MESSAGE_LEN, format, ap);
|
||
va_end(ap);
|
||
|
||
#else /* !DOTS_FOR_ARGS */
|
||
|
||
/* define with va_alist and use vsnprintf to get temp1 */
|
||
public void gprintf(where, format, va_alist)
|
||
long where;
|
||
char *format;
|
||
va_dcl
|
||
{
|
||
char temp1[GPRINTF_MESSAGE_LEN];
|
||
va_list pvar;
|
||
/* this is a syntax error - if you don't have to remove this, */
|
||
/* then this whole section of code is unnecessary. */
|
||
va_start(pvar);
|
||
vsnprintf(temp1, GPRINTF_MESSAGE_LEN, format, pvar);
|
||
va_end(pvar);
|
||
|
||
#endif /* DOTS_FOR_ARGS */
|
||
|
||
#else /* !HAVE_VSNPRINTF */
|
||
#define MAX_GPRINTF_ARGS 10
|
||
typedef struct gp_args_struct {
|
||
long arg[MAX_GPRINTF_ARGS];
|
||
} gp_args_node;
|
||
|
||
#ifdef DOTS_FOR_ARGS
|
||
/* use ... but not vsnprintf */
|
||
public void gprintf(long where, char *format, ...)
|
||
{
|
||
char temp1[GPRINTF_MESSAGE_LEN];
|
||
#ifdef AMIGA
|
||
char temp2[GPRINTF_MESSAGE_LEN];
|
||
#endif
|
||
va_list ap;
|
||
gp_args_node args;
|
||
va_start(ap, format);
|
||
args = va_arg(ap, gp_args_node);
|
||
va_end(ap);
|
||
#else /* !DOTS_FOR_ARGS */
|
||
/* don't use ... and don't use vsnprintf */
|
||
public void gprintf(where, format, args)
|
||
long where;
|
||
char *format;
|
||
gp_args_node args;
|
||
{
|
||
char temp1[GPRINTF_MESSAGE_LEN];
|
||
#ifdef AMIGA
|
||
char temp2[GPRINTF_MESSAGE_LEN];
|
||
#endif /* AMIGA*/
|
||
#endif /* DOTS_FOR_ARGS */
|
||
|
||
snprintf(temp1, GPRINTF_MESSAGE_LEN, format, args);
|
||
|
||
#endif /* HAVE_VSNPRINTF */
|
||
|
||
/*
|
||
* Now we've got formatted output in temp1. Write it out.
|
||
*/
|
||
#ifdef NYQUIST
|
||
switch ((long) where) {
|
||
case TRANS:
|
||
stdputstr(temp1);
|
||
break;
|
||
case ERROR:
|
||
errputstr(temp1);
|
||
break;
|
||
case FATAL:
|
||
errputstr("FATAL: ");
|
||
errputstr(temp1);
|
||
break;
|
||
case GDEBUG:
|
||
errputstr("DEBUG: ");
|
||
errputstr(temp1);
|
||
break;
|
||
default:
|
||
errputstr("UNKNOWN: ");
|
||
errputstr(temp1);
|
||
break;
|
||
}
|
||
gflush();
|
||
#else /* not NYQUIST */
|
||
#ifdef AMIGA
|
||
|
||
switch((long) where) {
|
||
case TRANS:
|
||
strcpy(temp2, temp1);
|
||
break;
|
||
case ERROR:
|
||
strcpy(temp2, temp1);
|
||
break;
|
||
case FATAL:
|
||
strcpy(temp2, "FATAL: ");
|
||
strcat(temp2, temp1);
|
||
break;
|
||
case GDEBUG:
|
||
strcpy(temp2,"DEBUG: ");
|
||
strcat(temp2, temp1);
|
||
break;
|
||
default:
|
||
strcpy(temp2, "UNKNOWN: ");
|
||
strcat(temp2, temp1);
|
||
break;
|
||
}
|
||
ConOutReq->io_Command = CMD_WRITE;
|
||
ConOutReq->io_Data = (APTR)temp2;
|
||
ConOutReq->io_Length = -1; /* NULL terminated string */
|
||
DoIO((struct IORequest *) ConOutReq);
|
||
#else /* not NYQUIST or AMIGA */
|
||
switch(where) {
|
||
case TRANS:
|
||
printf("%s", temp1);
|
||
break;
|
||
case ERROR:
|
||
fprintf(STDERR, "%s", temp1);
|
||
break;
|
||
case GDEBUG:
|
||
fprintf(STDERR, "DEBUG %s", temp1);
|
||
break;
|
||
case FATAL:
|
||
fprintf(STDERR, "FATAL %s", temp1);
|
||
break;
|
||
default:
|
||
fprintf(STDERR, "UNKNOWN %s", temp1);
|
||
break;
|
||
}
|
||
#endif /* AMIGA */
|
||
#endif /* NYQUIST */
|
||
}
|
||
|
||
#endif /* ifndef gprintf */
|
||
|
||
|
||
/**************************************************************************
|
||
* gputchar
|
||
* General putchar
|
||
**************************************************************************/
|
||
|
||
#ifndef gputchar
|
||
|
||
#ifdef AMIGA
|
||
public int gputchar(c)
|
||
int c;
|
||
{
|
||
ConPutChar((char)c);
|
||
return(c);
|
||
}
|
||
#else
|
||
public int gputchar(c)
|
||
int c;
|
||
{
|
||
putchar((char)c);
|
||
return(c);
|
||
}
|
||
#endif
|
||
|
||
#endif /* ifndef gputchar */
|
||
|
||
/**************************************************************************
|
||
* ggetchar
|
||
* General getchar
|
||
**************************************************************************/
|
||
|
||
public int ggetchar()
|
||
{
|
||
#ifdef BUFFERED_SYNCHRONOUS_INPUT
|
||
return getchar();
|
||
#else
|
||
int key = wait_ascii();
|
||
if (key != ABORT_CHAR && key != '\b') gputchar((char)key);
|
||
return(key);
|
||
#endif
|
||
}
|
||
|
||
|
||
/**************************************************************************
|
||
* ggets
|
||
* General gets
|
||
**************************************************************************/
|
||
|
||
|
||
#ifndef ggets
|
||
|
||
public char *ggets(str)
|
||
char *str;
|
||
{
|
||
char *s = str;
|
||
int c;
|
||
|
||
do {
|
||
c = ggetchar();
|
||
if (c == '\b' /* backspace */) {
|
||
if (s != str) {
|
||
gputchar('\b');
|
||
gputchar((int)' ');
|
||
gputchar('\b');
|
||
s--;
|
||
} else {
|
||
#ifdef AMIGA
|
||
gputchar((int)0x9b);
|
||
gputchar((int)0x43);
|
||
#else
|
||
/* gputchar((int)' '); */
|
||
#endif
|
||
gputchar((int)0x07);
|
||
}
|
||
} else *s++ = (char) c;
|
||
} while (c != (int) '\n' && !abort_flag);
|
||
|
||
*(s-1) = EOS;
|
||
if (abort_flag) *str = EOS;
|
||
return str;
|
||
}
|
||
|
||
#endif /* ifndef ggets */
|
||
|
||
|
||
/****************************************************************************
|
||
* get_ascii
|
||
* Returns:
|
||
* boolean: TRUE if a character was found
|
||
* int * c: pointer to int into which to store the character, if any
|
||
* Effect:
|
||
* polls (doesn't wait) for an ascii character and says if it got one
|
||
* the character is returned in *c.
|
||
****************************************************************************/
|
||
|
||
public boolean get_ascii(c)
|
||
char *c;
|
||
{
|
||
check_aborted(); /* input buffer check */
|
||
if (type_ahead_count == 0) return FALSE;
|
||
#ifdef AMIGA
|
||
/* if the buffer is full, then there is no outstanding read, restart it: */
|
||
if (type_ahead_count == type_ahead_max) ConRead();
|
||
#endif
|
||
type_ahead_count--;
|
||
*c = type_ahead[type_ahead_head++];
|
||
if (type_ahead_head == type_ahead_max) type_ahead_head = 0;
|
||
return TRUE;
|
||
}
|
||
|
||
#ifdef MACINTOSH /** Macintosh direct ascii input**/
|
||
public boolean ascii_input(c)
|
||
char *c;
|
||
{
|
||
EventRecord theEvent;
|
||
|
||
(void) GetNextEvent((keyDownMask | autoKeyMask), &theEvent);
|
||
if ((theEvent.what == keyDown) || (theEvent.what == autoKey)) {
|
||
*c = theEvent.message & charCodeMask;
|
||
if (*c == '\r') *c = '\n';
|
||
return(true);
|
||
}
|
||
else {
|
||
return(false);
|
||
}
|
||
}
|
||
#endif
|
||
|
||
#ifdef WINDOWS
|
||
#include "conio.h"
|
||
#define kbhit _kbhit
|
||
#define getch _getch
|
||
#endif
|
||
|
||
#ifdef DOS
|
||
public boolean ascii_input(c)
|
||
char *c;
|
||
{
|
||
if (abort_flag == ABORT_LEVEL) {
|
||
*c=ABORT_CHAR;
|
||
return((boolean)TRUE);
|
||
}
|
||
if (kbhit()) { /* If the keyboard was hit */
|
||
*c = getch(); /* Don't echo it */
|
||
// printf("now break");
|
||
if (*c == '\r') *c = '\n';
|
||
return((boolean)TRUE);
|
||
}
|
||
return((boolean)FALSE); /* Keeps Lattice compiler happy */
|
||
}
|
||
#endif
|
||
|
||
#ifdef UNIX
|
||
public boolean ascii_input(c)
|
||
char *c;
|
||
{
|
||
#ifdef UNIX_MACH
|
||
/*
|
||
* we can't read from stdin directly, because the ascii
|
||
* input thread is already doing so, so instead we'll
|
||
* wait for that thread to read a character and then take
|
||
* it
|
||
*/
|
||
boolean ret = FALSE;
|
||
|
||
A_LOCK();
|
||
if (a_in_flag) {
|
||
(*c) = a_in;
|
||
a_in_flag = 0;
|
||
ret = TRUE;
|
||
}
|
||
A_UNLOCK();
|
||
if (ret) {
|
||
#ifdef RTMach
|
||
itc_condition_signal(&a_cond);
|
||
#else /* RTMach */
|
||
condition_signal(&a_cond);
|
||
#endif /* RTMach */
|
||
}
|
||
if ((*c) == '\r')
|
||
(*c) = '\n';
|
||
return(ret);
|
||
#else /* __APPLE__ */
|
||
#ifndef BUFFERED_SYNCHRONOUS_INPUT
|
||
int input = IOgetchar();
|
||
if (input != IOnochar) {
|
||
*c = input;
|
||
if (*c == '\r') *c = '\n';
|
||
return TRUE;
|
||
}
|
||
#endif /* BUFFERED_SYNCHRONOUS_INPUT */
|
||
return FALSE;
|
||
#endif /* __APPLE__ */
|
||
}
|
||
#endif
|
||
|
||
#ifndef AMIGA /*DOS and MAC and UNIX */
|
||
public void unget_ascii(char c)
|
||
{
|
||
if (type_ahead_head == 0) type_ahead_head = type_ahead_max;
|
||
type_ahead_head--;
|
||
type_ahead[type_ahead_head] = c;
|
||
type_ahead_count++;
|
||
}
|
||
|
||
|
||
public boolean check_ascii()
|
||
{
|
||
char c;
|
||
|
||
if(get_ascii(&c)) {
|
||
unget_ascii(c);
|
||
return TRUE;
|
||
}
|
||
else return FALSE;
|
||
}
|
||
#endif
|
||
|
||
|
||
/****************************************************************************
|
||
* wait_ascii
|
||
* Returns:
|
||
* int: character for key pressed
|
||
* Effect:
|
||
* waits for the user to type a key on the terminal keyboard
|
||
* (versus the synthesizer keyboard) and returns the key typed
|
||
****************************************************************************/
|
||
|
||
#ifdef MACINTOSH
|
||
public int wait_ascii()
|
||
{
|
||
char key ; /* key typed */
|
||
|
||
if (abort_flag == ABORT_LEVEL) return ABORT_CHAR;
|
||
if (abort_flag == BREAK_LEVEL) return BREAK_CHAR;
|
||
gflush();
|
||
while (!get_ascii(&key)) ;
|
||
return(key);
|
||
}
|
||
#endif
|
||
|
||
#ifdef DOS
|
||
public int wait_ascii()
|
||
{
|
||
char key ; /* key typed */
|
||
|
||
if (abort_flag == ABORT_LEVEL) return ABORT_CHAR;
|
||
if (abort_flag == BREAK_LEVEL) return BREAK_CHAR;
|
||
if (!get_ascii(&key)) {
|
||
key = _getch(); // block until we get an input
|
||
}
|
||
/* GWL - check for abort on previos line */
|
||
return (int)key;
|
||
}
|
||
#endif
|
||
|
||
#ifndef MACINTOSH
|
||
#ifndef DOS
|
||
public int wait_ascii()
|
||
{
|
||
#ifdef UNIX /* was defined (UNIX) || defined(ITC) */
|
||
#ifndef UNIX_MACH
|
||
fd_set readfds;
|
||
#endif /* !UNIX_MACH */
|
||
#endif
|
||
char c;
|
||
struct rlimit file_limit;
|
||
|
||
if (abort_flag == ABORT_LEVEL) return ABORT_CHAR;
|
||
if (abort_flag == BREAK_LEVEL) return BREAK_CHAR;
|
||
while (!get_ascii(&c)) {
|
||
#ifdef AMIGA
|
||
WaitPort(ConInPort);
|
||
#endif
|
||
#ifdef UNIX
|
||
fflush(stdout);
|
||
#ifdef UNIX_MACH
|
||
/*
|
||
* we can't select, since another thread is reading
|
||
* from stdin, and we don't want to have an input war
|
||
* so instead, the ascii input thread will signal
|
||
* a_in_cond when it gets input, so we just wait
|
||
* for that to happen
|
||
*/
|
||
A_LOCK();
|
||
#ifdef RTMach
|
||
itc_condition_wait(&a_in_cond, &a_mutex);
|
||
#else /* RTMach */
|
||
condition_wait(&a_in_cond, &a_mutex);
|
||
#endif /* RTMach */
|
||
A_UNLOCK();
|
||
#else /* UNIX_MACH */
|
||
FD_ZERO(&readfds);
|
||
FD_SET(IOinputfd, &readfds);
|
||
gflush();
|
||
getrlimit(RLIMIT_NOFILE, &file_limit);
|
||
select(file_limit.rlim_max+1, &readfds, 0, 0, NULL);
|
||
#endif /* !__APPLE__ */
|
||
#endif /* ifdef UNIX */
|
||
}
|
||
return (int) c;
|
||
}
|
||
#endif
|
||
#endif
|
||
|
||
#ifdef AMIGA
|
||
/******************************************************************
|
||
AMIGA 2000.
|
||
Console IO Functions
|
||
JCD 25-Apr-88
|
||
*******************************************************************/
|
||
|
||
UBYTE KeybSig()
|
||
{
|
||
return ConInPort->mp_SigBit;
|
||
}
|
||
|
||
private void ConPutChar(c)
|
||
char c;
|
||
{
|
||
ConOutReq->io_Command = CMD_WRITE;
|
||
ConOutReq->io_Data = (APTR)&c;
|
||
ConOutReq->io_Length = 1;
|
||
DoIO((struct IORequest *) ConOutReq);
|
||
}
|
||
|
||
private void ConPutStr(str)
|
||
char *str;
|
||
{
|
||
ConOutReq->io_Command = CMD_WRITE;
|
||
ConOutReq->io_Data = (APTR)str;
|
||
ConOutReq->io_Length = -1;
|
||
DoIO((struct IORequest *) ConOutReq);
|
||
}
|
||
|
||
private void ConRead()
|
||
{
|
||
ConInReq->io_Command = CMD_READ;
|
||
ConInReq->io_Data = (APTR)KeyBuff;
|
||
ConInReq->io_Length = 1;
|
||
SendIO((struct IORequest *) ConInReq);
|
||
}
|
||
#endif
|