mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-21 23:00:06 +02:00
------------------------------------------------------------------------ r331 | rbd | 2020-10-13 12:40:12 -0500 (Tue, 13 Oct 2020) | 2 lines Also forgot to install NyquistWords.txt ------------------------------------------------------------------------ r330 | rbd | 2020-10-13 12:34:06 -0500 (Tue, 13 Oct 2020) | 2 lines Forgot to move nyquistman.pdf from docsrc/s2h to release ------------------------------------------------------------------------ r329 | rbd | 2020-10-13 11:32:33 -0500 (Tue, 13 Oct 2020) | 2 lines Updated some version numbers for 3.16. ------------------------------------------------------------------------ r328 | rbd | 2020-10-13 11:20:52 -0500 (Tue, 13 Oct 2020) | 2 lines Fixed NyquistIDE antialiasing for plot text, fix format of message. ------------------------------------------------------------------------ r327 | rbd | 2020-10-12 21:01:53 -0500 (Mon, 12 Oct 2020) | 2 lines Fixed a couple of format problems in manual. This version of Nyquist has been tested wtih macOS, Linux, 32&64-bit Windows. ------------------------------------------------------------------------ r326 | rbd | 2020-10-12 20:21:38 -0500 (Mon, 12 Oct 2020) | 1 line Modified WIN32 32-bit XLisp to use 64-bit FIXNUMs. This allows XLisp and Nyquist to handle big sounds even on 32-bit machines. Probably at some cost, but inner loops are mostly float and int32, and the Nyquist release is 64-bit anyway. Maybe we'll have to run some benchmarks on Audacity, which is still 32-bit on Windows. ------------------------------------------------------------------------ r325 | rbd | 2020-10-12 13:16:57 -0500 (Mon, 12 Oct 2020) | 1 line Win64 passes bigfiletest.lsp now. This version should work on all 64-bit systems now. These changes untested on Linux and macOS. ------------------------------------------------------------------------ r324 | rbd | 2020-10-11 21:31:53 -0500 (Sun, 11 Oct 2020) | 2 lines I couldn't free enough space on my linux box, so I adjusted the bigfiletest to write 8-bit ulaw. It's still >4GB and >4G samples. Works on Linux. ------------------------------------------------------------------------ r323 | rbd | 2020-10-11 19:41:25 -0500 (Sun, 11 Oct 2020) | 2 lines Missing file from last commit. ------------------------------------------------------------------------ r322 | rbd | 2020-10-11 19:36:08 -0500 (Sun, 11 Oct 2020) | 1 line Found another case where WIN64 needs int64_t instead of long for sample count. ------------------------------------------------------------------------ r321 | rbd | 2020-10-11 19:33:25 -0500 (Sun, 11 Oct 2020) | 3 lines Fixed s-save to handle optional and keyword parameters (which should never have been mixed in the first place). Documentation cleanup - should be final for this version. ------------------------------------------------------------------------ r320 | rbd | 2020-10-11 14:44:37 -0500 (Sun, 11 Oct 2020) | 2 lines Fixes to handle IRCAM sound format and tests for big file io working on macOS. ------------------------------------------------------------------------ r319 | rbd | 2020-10-10 21:31:58 -0500 (Sat, 10 Oct 2020) | 2 lines Changes for linux and to avoid compiler warnings on linux. ------------------------------------------------------------------------ r318 | rbd | 2020-10-10 20:50:23 -0500 (Sat, 10 Oct 2020) | 1 line This is the test used for Win64 version. ------------------------------------------------------------------------ r317 | rbd | 2020-10-10 20:34:34 -0500 (Sat, 10 Oct 2020) | 1 line This version works on Win64. Need to test changes on macOS and linux. ------------------------------------------------------------------------ r316 | rbd | 2020-10-10 19:59:15 -0500 (Sat, 10 Oct 2020) | 2 lines PWL changes to avoid compiler warning. ------------------------------------------------------------------------ r315 | rbd | 2020-10-10 19:34:04 -0500 (Sat, 10 Oct 2020) | 2 lines A few more changes for 64-bit sample counts on Win64 ------------------------------------------------------------------------ r314 | rbd | 2020-10-10 13:19:42 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed int64_t declaration in gate.alg ------------------------------------------------------------------------ r313 | rbd | 2020-10-10 12:07:40 -0500 (Sat, 10 Oct 2020) | 2 lines Fixes to gate for long sounds ------------------------------------------------------------------------ r312 | rbd | 2020-10-10 11:47:29 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed sound_save types for intgen ------------------------------------------------------------------------ r311 | rbd | 2020-10-10 11:09:01 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed a 64-bit sample count problem in siosc.alg ------------------------------------------------------------------------ r310 | rbd | 2020-10-10 11:03:12 -0500 (Sat, 10 Oct 2020) | 2 lines Fixed sndmax to handle 64-bit sample counts. ------------------------------------------------------------------------ r309 | rbd | 2020-10-10 10:57:04 -0500 (Sat, 10 Oct 2020) | 2 lines Forgot to re-translate all tran/*.alg files with fix for int64 cast to int32. This version compiles on macOS and ready for test on Win64. ------------------------------------------------------------------------ r308 | rbd | 2020-10-10 10:16:05 -0500 (Sat, 10 Oct 2020) | 2 lines Everything seems to compile and run on macOS now. Moving changes to Windows for test. ------------------------------------------------------------------------ r307 | rbd | 2020-10-10 09:23:45 -0500 (Sat, 10 Oct 2020) | 1 line Added casts to avoid compiler warnings and to review changes to support 64-bit sample counts on Windows. Still not complete, and waiting to regenerate and compile tran directory code after updates to translation code that will insert more casts. ------------------------------------------------------------------------ r306 | rbd | 2020-10-09 21:55:15 -0500 (Fri, 09 Oct 2020) | 2 lines Rebuilt seqfnint.c from header files. ------------------------------------------------------------------------ r305 | rbd | 2020-10-09 21:53:33 -0500 (Fri, 09 Oct 2020) | 1 line Changed some FIXNUMS to LONG to avoid compiler warnings in seqfnint.c ------------------------------------------------------------------------ r304 | rbd | 2020-10-09 21:44:03 -0500 (Fri, 09 Oct 2020) | 2 lines I discovered forgotten regression-test.lsp and added test that requires 64-bit sample counts to pass. Fixed a few bugs revealed by running the type-checking regression tests. ------------------------------------------------------------------------ r303 | rbd | 2020-10-09 12:28:58 -0500 (Fri, 09 Oct 2020) | 2 lines Changes for 64-bit sample counts broke mult-channel s-save. Fixed in the commit for macOS. ------------------------------------------------------------------------ r302 | rbd | 2020-10-09 10:03:39 -0500 (Fri, 09 Oct 2020) | 2 lines Changed snd-play to return samples computed and used that to make a test for computing long sounds that would overflow 32-bit length counts. ------------------------------------------------------------------------ r301 | rbd | 2020-10-09 09:11:26 -0500 (Fri, 09 Oct 2020) | 2 lines corrected mistake in delaycv.alg and re-translated ------------------------------------------------------------------------ r300 | rbd | 2020-10-09 09:09:06 -0500 (Fri, 09 Oct 2020) | 2 lines Fix to delaycv.alg -- "s" changed to "input" to avoid matching "s" in "sample_type". ------------------------------------------------------------------------ r299 | rbd | 2020-10-09 09:03:33 -0500 (Fri, 09 Oct 2020) | 4 lines To avoid compiler warnings, XLisp interfaces to C int and long are now specified as LONG rather than FIXNUM, and the stubs that call the C functions cast FIXNUMs from XLisp into longs before calling C functions. ------------------------------------------------------------------------ r298 | rbd | 2020-10-08 22:20:26 -0500 (Thu, 08 Oct 2020) | 2 lines This commit has many more fixes to handle long (64-bit) sounds, including a lot of fixes for warnings by Visual Studio assigning int64_t to long (works on macOS, doesn't work on VS). This was compiled and tested on macOS, and even computed a 27.1-hour sound using OSC, LP, SUM and MULT (haven't tested I/O yet). ------------------------------------------------------------------------ r297 | rbd | 2020-10-07 13:04:02 -0500 (Wed, 07 Oct 2020) | 2 lines This is a major cleanup. It started with the goal of changing long to int64_t for sample counts so that on 64-bit windows, where long is only 32-bits, the sample counts would nevertheless be 64-bit allowing long sounds, which was a limitation for long recordings in Audacity. Since I was using compiler warnings to track possible loss-of-precision conversions from 64-bit sample counts, and there were *many* warnings, I started cleaning up *all* the warnings and ended up with a very large set of changes, including "modernizing" C declarations that date back to XLisp and CMU MIDI Toolkit code and were never changed. This version runs all the examples.sal code on macOS, but will surely have problems on Windows and Linux given the number of changes. ------------------------------------------------------------------------ r296 | rbd | 2020-10-06 13:34:20 -0500 (Tue, 06 Oct 2020) | 2 lines More changes from long to int64_t for sample counts. ------------------------------------------------------------------------ r295 | rbd | 2020-10-06 11:53:49 -0500 (Tue, 06 Oct 2020) | 2 lines More work on using 64-bit sample counts. Changed MAX_STOP from 32-bit to 64-bit limit. ------------------------------------------------------------------------ r294 | rbd | 2020-10-06 11:48:05 -0500 (Tue, 06 Oct 2020) | 2 lines Made some changes so that sample counts are int64_t (for windows) instead of long to support sample counts above 31 bits. ------------------------------------------------------------------------ r293 | rbd | 2020-10-04 21:30:55 -0500 (Sun, 04 Oct 2020) | 2 lines Fixed a few minor things for Linux and tested on Linux. ------------------------------------------------------------------------ r292 | rbd | 2020-10-04 21:00:28 -0500 (Sun, 04 Oct 2020) | 2 lines Update extensions: all are minor changes. ------------------------------------------------------------------------ r291 | rbd | 2020-09-24 13:59:31 -0500 (Thu, 24 Sep 2020) | 2 lines New implementation of seq and seqrep, added get-real-time, documented get-real-time, fixed examples.sal and examples.lsp which are now in lib rather than extensions (so they are now back in the basic installation), other cleanup. ------------------------------------------------------------------------ r290 | rbd | 2020-08-16 16:24:52 -0500 (Sun, 16 Aug 2020) | 2 lines Fixed bug in snd-gate, revised GATE and NOISE-GATE to handle multi-channel sound. RMS now handles multi-channel input. S-AVG added to take multichannel input (but not used, because RMS could not be written without making SND-SRATE convert multichannel sound to vector of floats. That seems to be going toward a fully vectorized model. Not going there for now. ------------------------------------------------------------------------ r289 | rbd | 2020-07-09 16:27:45 -0500 (Thu, 09 Jul 2020) | 2 lines Added GET-REAL-TIME function to XLISP. May not work yet on Windows. Various fixes for compiler warnings. I noticed FLAC doesn't work (I guess it never did) and I cannot figure out how this even links because flac_min seems to be undefined. Something to look at later.
442 lines
14 KiB
C
442 lines
14 KiB
C
/* winstuff.c - windows interface routines for xlisp */
|
|
/* Written by Chris Tchou. */
|
|
/* This file contains the stuff that the other xlisp files call directly. */
|
|
|
|
/* Changes by Roger Dannenberg, Jan 2006:
|
|
Previously, the input thread would block on input, so if a command line
|
|
instantiation of Nyquist called (EXIT), the process would still block
|
|
in getchar() until the user typed a newline. Now, I only start the
|
|
input thread if ostgetc is called (input is really needed). This will
|
|
still read ahead and block, but only in cases where you are already
|
|
interactive.
|
|
|
|
/* Changes by Roger Dannenberg, April 2004:
|
|
To support interrupts to Lisp processing, XLISP call oscheck frequently to
|
|
test for an abort or break condition. This condition can be activated by
|
|
special handlers, e.g. if a software interrupt is generated by Ctrl-C.
|
|
Alternatively, the application can read ahead and look for break characters
|
|
in the input stream. A third approach, implemented by Ning Hu for her
|
|
Delphi-based IDE, is to send a Windows message to the process. Unfortunately,
|
|
the Java IDE does not support sending a Windows message, nor can console
|
|
IO be used to read ahead (console IO does not work because, when started by
|
|
Java, Nyquist standard IO is redirected through pipes). The two solutions
|
|
to enable break character prcessing seem to be:
|
|
1) extend Java with C code to find the process and send Windows messages
|
|
2) add a thread to perform read ahead and break character processing
|
|
Option 2 contains the ugliness to Nyquist IO, which is already big and ugly,
|
|
and leaves Java alone, which is something I don't know much about anyway,
|
|
so I have chosen option 2: create a thread and read ahead. This uses only
|
|
about 50 lines of code.
|
|
|
|
A shortcoming of this approach is that, except for Ctrl-C, break characters
|
|
like ^P, ^B, and ^U require the user to type RETURN to end the input line
|
|
and allow the character to be processed.
|
|
|
|
The thread will set a signal whenever a line of input is delivered so that
|
|
Nyquist can block waiting for input. The signal will also be set when a
|
|
^C or ^G is detected.
|
|
|
|
For flexibility, compatibility with the Delphi IDE (NyqIDE) is retained by
|
|
continuing to check for Windows process messages.
|
|
*/
|
|
|
|
#include <windows.h> /* Added by Ning Hu Apr.2001 */
|
|
#include <process.h> /* Added by Dannenberg Apr 2004 */
|
|
#include <signal.h> /* Added by Dannneberg, Apr 2004 */
|
|
#include "exitpa.h" /* Added by Dannneberg, Apr 2004 */
|
|
|
|
#if OSC
|
|
#include "nyq-osc-server.h"
|
|
#endif
|
|
|
|
|
|
const char os_pathchar = '\\';
|
|
const char os_sepchar = ',';
|
|
|
|
|
|
#undef ERROR
|
|
#include <stdio.h>
|
|
//#include <QuickDraw.h> /* for Random */
|
|
#include <memory.h> /* for DisposPtr */
|
|
#include <string.h>
|
|
//#include <SegLoad.h> /* for ExitToShell */
|
|
#include "xlisp.h"
|
|
#include "cext.h"
|
|
#include "userio.h"
|
|
#include "sliderdata.h"
|
|
#include "sound.h" /* define nosc_enabled */
|
|
#include "falloc.h" /* define table_memory */
|
|
|
|
/* externals */
|
|
extern FILE *tfp; /* transcript file pointer */
|
|
extern int cursorPos;
|
|
extern char *macgets (void);
|
|
//Added by Ning Hu Apr.2001
|
|
extern int _isatty(int);
|
|
extern int redirect_flag;
|
|
//Add end
|
|
|
|
/* local variables */
|
|
int lposition;
|
|
static char *linebuf = NULL, *lineptr;
|
|
static int numChars;
|
|
|
|
/* input thread */
|
|
static uintptr_t input_thread_handle = -1;
|
|
#define NEED_INPUT if (input_thread_handle == -1) start_input_thread();
|
|
#define input_buffer_max 1024
|
|
#define input_buffer_mask (input_buffer_max - 1)
|
|
char input_buffer[1024];
|
|
volatile int input_buffer_head = 0;
|
|
volatile int input_buffer_tail = 0;
|
|
volatile int buffer_eof = 0;
|
|
HANDLE input_buffer_ready = NULL;
|
|
|
|
BOOL WINAPI ctrl_c_handler(DWORD dwCtrlType)
|
|
{
|
|
if (dwCtrlType == CTRL_C_EVENT) {
|
|
abort_flag = ABORT_LEVEL;
|
|
return TRUE;
|
|
}
|
|
return FALSE;
|
|
}
|
|
|
|
#ifdef DEBUG_INPUT
|
|
extern FILE *to_input_buffer;
|
|
#endif
|
|
|
|
void input_thread_run(void *args)
|
|
{
|
|
int c;
|
|
/* this gets called, possible later, in io_init() in userio.c, but
|
|
* that doesn't seem to prevent this thread from being killed by
|
|
* CTRL-C, so call it here to be safe.
|
|
*/
|
|
SetConsoleCtrlHandler(ctrl_c_handler, TRUE);
|
|
/* printf("input_thread_run\n"); */
|
|
|
|
while (!buffer_eof) {
|
|
int head;
|
|
c = getchar();
|
|
if (c == EOF && abort_flag) {
|
|
// when user types ^C, an EOF is generated for some reason.
|
|
// Ignore it...
|
|
if (abort_flag == ABORT_LEVEL) c = ABORT_CHAR;
|
|
else c = BREAK_CHAR;
|
|
} else if (c == ABORT_CHAR) {
|
|
abort_flag = ABORT_LEVEL;
|
|
} else if (!abort_flag && c == BREAK_CHAR) {
|
|
// notice that a break will be ignored until XLISP
|
|
// handles the ABORT_LEVEL
|
|
abort_flag = BREAK_LEVEL;
|
|
} else if (c == BREAK_CHAR) {
|
|
; // ignore this because abort_flag is set to ABORT_LEVEL
|
|
} else if (c == '\005' || c == '\006') { // control-e or control-f
|
|
; // ignore these. IDE will send control-f to turn off echo, but
|
|
// under Windows, echo is already turned off. We filter control-f
|
|
// here to avoid generating an error message. Maybe the IDE should
|
|
// not send control-f in the first place, but the IDE is cross-platform
|
|
// and does not know it's running under Windows, whereas this file
|
|
// is platform dependent.
|
|
} else if (c == '\016') { // begin hidden message
|
|
#define MSGBUF_MAX 64
|
|
char msgbuf[MSGBUF_MAX];
|
|
int msgbufx = 0;
|
|
char type_char = getchar(); // read message type character
|
|
printf("begin hidden message: %c\n", type_char);
|
|
if (type_char == EOF) buffer_eof = TRUE;
|
|
else {
|
|
// message is terminated by '\021'
|
|
while ((c = getchar()) != '\021' &&
|
|
c != EOF &&
|
|
msgbufx < MSGBUF_MAX - 1) {
|
|
msgbuf[msgbufx++] = c;
|
|
}
|
|
msgbuf[msgbufx++] = 0;
|
|
printf("message: %s\n", msgbuf);
|
|
if (c == EOF) buffer_eof = TRUE;
|
|
else if (msgbufx < MSGBUF_MAX) {
|
|
if (type_char == 'S') { // slider change message
|
|
// message format is index<space>value
|
|
int index;
|
|
float value;
|
|
if (sscanf(msgbuf, "%d %g", &index, &value) == 2) {
|
|
set_slider(index, value);
|
|
printf("set_slider %d %g\n", index, value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (c == EOF) {
|
|
buffer_eof = TRUE;
|
|
} else {
|
|
// insert character into the FIFO
|
|
head = (input_buffer_head + 1) & input_buffer_mask;
|
|
while (head == input_buffer_tail) Sleep(100);
|
|
input_buffer[input_buffer_head] = c;
|
|
#ifdef DEBUG_INPUT
|
|
if (to_input_buffer) putc(c, to_input_buffer);
|
|
#endif
|
|
input_buffer_head = head;
|
|
}
|
|
if (c == '\n' || abort_flag || buffer_eof) {
|
|
SetEvent(input_buffer_ready);
|
|
// wake up Nyquist if it is waiting for input
|
|
}
|
|
}
|
|
// printf("Input thread exiting\n");
|
|
}
|
|
|
|
//int isascii (char c) { return 1; } /* every char is an ascii char, isn't it? */
|
|
|
|
void start_input_thread()
|
|
{
|
|
// create thread to process input
|
|
input_thread_handle = _beginthread(input_thread_run, 0, NULL);
|
|
if (input_thread_handle == -1) {
|
|
printf("Unable to create input thread, errno = %d\n", errno);
|
|
EXIT(1);
|
|
}
|
|
}
|
|
|
|
void osinit(const char *banner)
|
|
{
|
|
printf("%s\n", banner);
|
|
if (_isatty( _fileno( stdin ) ) ){
|
|
redirect_flag = 0;
|
|
#ifdef DEBUG
|
|
printf( "stdout has not been redirected to a file\n" ); //for debugging use
|
|
#endif
|
|
} else {
|
|
redirect_flag = 1;
|
|
#ifdef DEBUG
|
|
printf( "stdout has been redirected to a file\n"); //for debugging use
|
|
#endif
|
|
}
|
|
// signal when input is ready
|
|
input_buffer_ready = CreateEvent(NULL, FALSE, FALSE, NULL);
|
|
if (input_buffer_ready == NULL) {
|
|
printf("Unable to create Event object\n");
|
|
EXIT(1);
|
|
}
|
|
}
|
|
|
|
FILE *osaopen(const char *name, const char *mode) {
|
|
FILE *fp = NULL;
|
|
#ifdef SAFE_NYQUIST
|
|
if (ok_to_open(name, mode))
|
|
#endif
|
|
fp = fopen(name, mode);
|
|
return fp;
|
|
}
|
|
|
|
FILE *osbopen(const char *name, const char *mode) {
|
|
FILE *fp = NULL;
|
|
char nmode[4];
|
|
strcpy (nmode, mode); strcat (nmode, "b");
|
|
#ifdef SAFE_NYQUIST
|
|
if (ok_to_open(name, nmode))
|
|
#endif
|
|
fp = fopen (name, nmode);
|
|
return fp;
|
|
}
|
|
|
|
int osclose(FILE *fp) { return (fclose (fp)); }
|
|
int osaputc(int ch, FILE *fp) { return (putc (ch, fp)); }
|
|
int osbputc(int ch, FILE *fp) { return (putc (ch, fp)); }
|
|
void osoutflush(FILE *fp) { fflush(fp); }
|
|
|
|
/* osagetc - get a character from an ascii file */
|
|
int osagetc(fp)
|
|
FILE *fp;
|
|
{
|
|
return (getc(fp));
|
|
}
|
|
|
|
extern int abort_flag;
|
|
extern int redirect_flag; //Added by Ning Hu Apr.2001
|
|
int ostgetc(void)
|
|
{
|
|
int c;
|
|
NEED_INPUT;
|
|
while (!buffer_eof && (input_buffer_tail == input_buffer_head)) {
|
|
oscheck();
|
|
WaitForSingleObject(input_buffer_ready, INFINITE);
|
|
}
|
|
if (buffer_eof) c = EOF;
|
|
else {
|
|
c = input_buffer[input_buffer_tail];
|
|
input_buffer_tail = (input_buffer_tail + 1) & input_buffer_mask;
|
|
}
|
|
if (c == '\025') { // control-u
|
|
xlcleanup();
|
|
} else if (c == '\020') { // control-p
|
|
xlcontinue();
|
|
} else if (c == '\024') { // control-t
|
|
xinfo();
|
|
}
|
|
return c;
|
|
}
|
|
|
|
|
|
void ostputc(int ch) {
|
|
// macputc (ch);
|
|
putchar(ch); // console
|
|
|
|
if (tfp) osaputc (ch, tfp);
|
|
}
|
|
|
|
void ostoutflush()
|
|
{
|
|
if (tfp) fflush(tfp);
|
|
fflush(stdout);
|
|
}
|
|
|
|
|
|
void osflush(void) {
|
|
lineptr = linebuf;
|
|
numChars = 0;
|
|
lposition = 0;
|
|
}
|
|
|
|
|
|
void oscheck(void) {
|
|
MSG lpMsg;
|
|
|
|
#if OSC
|
|
if (nosc_enabled) nosc_poll();
|
|
#endif
|
|
|
|
// check_aborted(); -- call to userio.c superceded by code here in winstuff.c
|
|
// printf("Current Thread: %d\n", GetCurrentThreadId()); //for debugging use
|
|
// look for Windows messages from NyqIDE (a Delphi program)
|
|
if ((redirect_flag) && (PeekMessage(&lpMsg, NULL, 0, 0, PM_REMOVE)!=0)) {
|
|
if (lpMsg.message == WM_CHAR) {
|
|
switch (lpMsg.wParam) {
|
|
case ABORT_CHAR: abort_flag = ABORT_LEVEL;
|
|
break;
|
|
case BREAK_CHAR: // for nyquist, defined to be 2
|
|
case 7: // NyqIDE sends 7 (BEL) as break character
|
|
abort_flag = BREAK_LEVEL;
|
|
break;
|
|
}
|
|
// printf("Get message: %d %d %d\n", lpMsg.wParam, BREAK_CHAR, abort_flag); //for debugging use
|
|
}
|
|
}
|
|
if (abort_flag == ABORT_LEVEL) {
|
|
abort_flag = 0;
|
|
osflush();
|
|
xltoplevel();
|
|
} else if (abort_flag == BREAK_LEVEL) {
|
|
abort_flag = 0;
|
|
osflush();
|
|
xlbreak("BREAK", s_unbound);
|
|
}
|
|
|
|
if (run_time % 30 == 0) {
|
|
// maybe we should call fflush here like in Unix; I'm not sure if this is
|
|
// a bug or it is not necessary for Windows - RBD
|
|
if (run_time_limit > 0 && run_time > run_time_limit) {
|
|
xlfatal("Run time limit exceeded");
|
|
}
|
|
if (memory_limit > 0 &&
|
|
npools * MAXPOOLSIZE + table_memory + total >
|
|
memory_limit * 1000000) {
|
|
xlfatal("Memory limit exceeded");
|
|
}
|
|
}
|
|
}
|
|
//Update end
|
|
|
|
void oserror(const char *msg) {
|
|
char line[100], *p;
|
|
sprintf (line, "error: %s\n", msg);
|
|
for (p = line; *p != '\0'; ++p) ostputc (*p);
|
|
}
|
|
|
|
void osfinish(void) {
|
|
portaudio_exit();
|
|
/* dispose of everything... */
|
|
// if (linebuf) DisposPtr (linebuf);
|
|
// MacWrapUp ();
|
|
// ExitToShell ();
|
|
}
|
|
|
|
int renamebackup(char *filename) { return 0; }
|
|
|
|
|
|
|
|
|
|
static WIN32_FIND_DATA FindFileData;
|
|
static HANDLE hFind = INVALID_HANDLE_VALUE;
|
|
#define OSDIR_LIST_READY 0
|
|
#define OSDIR_LIST_STARTED 1
|
|
#define OSDIR_LIST_DONE 2
|
|
static int osdir_list_status = OSDIR_LIST_READY;
|
|
#define OSDIR_MAX_PATH 256
|
|
static char osdir_path[OSDIR_MAX_PATH];
|
|
|
|
// osdir_list_start -- prepare to list a directory
|
|
int osdir_list_start(const char *path)
|
|
{
|
|
if (!ok_to_open(path, "r")) return FALSE;
|
|
if (strlen(path) >= OSDIR_MAX_PATH - 2) {
|
|
xlcerror("LISTDIR path too big", "return nil", NULL);
|
|
return FALSE;
|
|
}
|
|
strcpy(osdir_path, path);
|
|
strcat(osdir_path, "/*"); // make a pattern to match all files
|
|
if (osdir_list_status != OSDIR_LIST_READY) {
|
|
osdir_list_finish(); // close previously interrupted listing
|
|
}
|
|
hFind = FindFirstFile(osdir_path, &FindFileData); // get the "."
|
|
if (hFind == INVALID_HANDLE_VALUE) return FALSE;
|
|
if (FindNextFile(hFind, &FindFileData) == 0) return FALSE; // get the ".."
|
|
osdir_list_status = OSDIR_LIST_STARTED;
|
|
return TRUE;
|
|
}
|
|
|
|
|
|
const char *osdir_list_next()
|
|
{
|
|
if (FindNextFile(hFind, &FindFileData) == 0) {
|
|
osdir_list_status = OSDIR_LIST_DONE;
|
|
return NULL;
|
|
}
|
|
return FindFileData.cFileName;
|
|
}
|
|
|
|
void osdir_list_finish()
|
|
{
|
|
if (osdir_list_status != OSDIR_LIST_READY) {
|
|
FindClose(hFind);
|
|
}
|
|
osdir_list_status = OSDIR_LIST_READY;
|
|
}
|
|
|
|
|
|
/* xechoenabled -- set/clear echo_enabled flag (unix only) */
|
|
LVAL xechoenabled()
|
|
{
|
|
int flag = (xlgetarg() != NULL);
|
|
xllastarg();
|
|
// echo_enabled = flag; -- do nothing in Windows
|
|
return NULL;
|
|
}
|
|
|
|
|
|
/* xgetrealtime - get current time in seconds */
|
|
LVAL xgetrealtime()
|
|
{
|
|
static const uint64_t EPOCH = ((uint64_t)116444736000000000ULL);
|
|
SYSTEMTIME system_time;
|
|
FILETIME file_time;
|
|
uint64_t time;
|
|
GetSystemTime(&system_time);
|
|
SystemTimeToFileTime(&system_time, &file_time);
|
|
time = (uint64_t) file_time.dwLowDateTime;
|
|
time += ((uint64_t) file_time.dwHighDateTime) << 32;
|
|
time -= EPOCH;
|
|
time /= 10000000L;
|
|
return cvflonum((double) time + system_time.wMilliseconds * 0.001);
|
|
} |