Browse Source
- Removed all backends apart from twitter, template, and libpurple. (why would you want to use any of them?) - Deleted dodgy vendored includes (from swiften, boost) - Replaced all usage of the dodgy SWIFTEN_* macros and HAVE_SWIFTEN_3 define. - Removed spectrum2_manager (it's stupid, just use systemd) - Removed spectrum2 server mode (it's stupid, just use a component) - Removed Jingle File Transfer (only worked on swiften 3, was suuuper hacky) - Moved spectrum/src to src/ (this always pissed me off) - Removed WIN32 and non-Linux platform support (was ugly) - Removed packaging, munin, travis, etc (this is a fork) - Added .clang-format, ran clang-format everywhere (hooray!) - Removed half the flags and crap in CMakeLists.txt (it didn't really help)master
602 changed files with 21896 additions and 70849 deletions
@ -0,0 +1,5 @@
@@ -0,0 +1,5 @@
|
||||
BasedOnStyle: Microsoft |
||||
AlignAfterOpenBracket: Align |
||||
BreakBeforeBraces: Attach |
||||
NamespaceIndentation: None |
||||
UseTab: ForIndentation |
@ -1,42 +0,0 @@
@@ -1,42 +0,0 @@
|
||||
language: cpp |
||||
matrix: |
||||
include: |
||||
- os: linux |
||||
dist: xenial |
||||
- os: osx |
||||
osx_image: xcode10.1 |
||||
addons: |
||||
homebrew: |
||||
packages: |
||||
- cppunit |
||||
- log4cxx |
||||
- popt |
||||
- jsoncpp |
||||
- libswiften |
||||
- protobuf |
||||
update: true |
||||
apt: |
||||
sources: |
||||
- sourceline: 'deb https://packages.spectrum.im/spectrum2/ xenial main' |
||||
key_url: 'https://packages.spectrum.im/packages.key' |
||||
- sourceline: 'deb https://swift.im/packages/ubuntu/xenial release main' |
||||
key_url: 'https://swift.im/keys/packages.key' |
||||
- sourceline: 'deb https://packages.prosody.im/debian xenial main' |
||||
key_url: 'https://prosody.im/files/prosody-debian-packages.key' |
||||
packages: |
||||
- git cmake prosody ngircd python-dateutil python-sleekxmpp libswiften-dev libprotobuf-dev protobuf-compiler libpurple-dev libglib2.0-dev libdbus-glib-1-dev liblog4cxx10-dev libpopt-dev libboost-dev libboost-signals-dev libboost-system-dev libboost-thread-dev libboost-locale-dev libboost-filesystem-dev libboost-program-options-dev libboost-regex-dev libboost-date-time-dev libcppunit-dev libcommuni-dev libminiupnpc-dev libnatpmp-dev libssl-dev libcurl4-openssl-dev libidn11-dev libxml2-dev libsqlite3-dev libqt4-dev libjsoncpp-dev libsasl2-modules-gssapi-mit libpurple-xmpp-carbons1 |
||||
update: true |
||||
before_script: |
||||
sudo systemctl disable prosody; |
||||
sudo service prosody stop; |
||||
sudo rm /usr/include/mysql/plugin.h; |
||||
cmake -DCMAKE_BUILD_TYPE=Debug -DENABLE_TESTS=ON .; |
||||
make; |
||||
script: |
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then |
||||
make test; |
||||
else |
||||
make extended_test; |
||||
fi |
||||
notifications: |
||||
slack: spectrum2:CIlYHtxGMAaxs3qVHfwBzCuy |
@ -1,110 +0,0 @@
@@ -1,110 +0,0 @@
|
||||
FROM fedora:27 |
||||
|
||||
EXPOSE 5222 |
||||
VOLUME ["/etc/spectrum2/transports", "/var/lib/spectrum2"] |
||||
ARG commit=unknown |
||||
RUN echo $commit |
||||
|
||||
# Spectrum 2 |
||||
RUN dnf install ImageMagick protobuf swiften gcc gcc-c++ make libpqxx-devel libpurple-devel protobuf-devel swiften-devel rpm-build avahi-devel boost-devel cmake cppunit-devel expat-devel libcommuni-devel libidn-devel libsqlite3x-devel log4cxx-devel gettext libgcrypt-devel libwebp-devel libpurple-devel zlib-devel json-glib-devel python-pip zlib-devel libjpeg-devel python-devel mysql-devel popt-devel git libev-libevent-devel qt-devel dbus-glib-devel libcurl-devel wget mercurial libtool libgnome-keyring-devel nss-devel jsoncpp-devel purple-hangouts -y && \ |
||||
echo "---> Installing Spectrum 2" && \ |
||||
git clone git://github.com/hanzz/spectrum2.git && \ |
||||
cd spectrum2 && \ |
||||
./packaging/fedora/build_rpm.sh && \ |
||||
rpm -U /root/rpmbuild/RPMS/x86_64/*.rpm && \ |
||||
cp ./packaging/docker/run.sh /run.sh && \ |
||||
cd .. && \ |
||||
rm -rf spectrum2 && \ |
||||
rm -rf ~/rpmbuild && \ |
||||
dnf mark install json-glib |
||||
|
||||
RUN echo "---> Installing purple-instagram" && \ |
||||
git clone https://github.com/EionRobb/purple-instagram.git && \ |
||||
cd purple-instagram && \ |
||||
make && \ |
||||
make install && \ |
||||
cd .. && \ |
||||
rm -rf purple-instagram |
||||
RUN echo "---> Installing icyque" && \ |
||||
git clone git://github.com/EionRobb/icyque.git && \ |
||||
cd icyque && \ |
||||
make && \ |
||||
make install && \ |
||||
cd .. && \ |
||||
rm -rf icyque |
||||
RUN echo "---> Installing purple-facebook" && \ |
||||
wget https://github.com/dequis/purple-facebook/releases/download/v0.9.6/purple-facebook-0.9.6.tar.gz && \ |
||||
tar -xf purple-facebook-0.9.6.tar.gz && \ |
||||
cd purple-facebook-0.9.6 && \ |
||||
./autogen.sh && \ |
||||
./configure && \ |
||||
make && \ |
||||
make install && \ |
||||
cd .. && \ |
||||
rm -rf purple-facebook* |
||||
RUN echo "---> Installing skype4pidgin" && \ |
||||
git clone git://github.com/EionRobb/skype4pidgin.git && \ |
||||
cd skype4pidgin/skypeweb && \ |
||||
make CFLAGS=-DFEDORA=1 && \ |
||||
make install && \ |
||||
cd ../.. && \ |
||||
rm -rf skype4pidgin |
||||
RUN echo "---> Installing transwhat" && \ |
||||
pip install --pre e4u six==1.10 protobuf python-dateutil yowsup Pillow==2.9.0 &&\ |
||||
git clone git://github.com/stv0g/transwhat.git &&\ |
||||
cd transwhat &&\ |
||||
git checkout yowsup-3 &&\ |
||||
python setup.py install &&\ |
||||
cd .. &&\ |
||||
rm -r transwhat |
||||
RUN echo "---> Installing Telegram" && \ |
||||
git clone --recursive https://github.com/majn/telegram-purple && \ |
||||
cd telegram-purple && \ |
||||
./configure && \ |
||||
make && \ |
||||
make install && \ |
||||
cd .. && \ |
||||
rm -rf telegram-purple |
||||
RUN echo "---> Install Discord" && \ |
||||
git clone https://github.com/EionRobb/purple-discord.git && \ |
||||
cd purple-discord && \ |
||||
make && \ |
||||
make install && \ |
||||
cd .. && \ |
||||
rm -rf purple-discord |
||||
RUN echo "---> Install Steam" && \ |
||||
git clone https://github.com/EionRobb/pidgin-opensteamworks.git && \ |
||||
cd pidgin-opensteamworks/steam-mobile && \ |
||||
make && \ |
||||
make install && \ |
||||
cd ../.. && \ |
||||
rm -rf pidgin-opensteamworks |
||||
RUN echo "---> purple-gowhatsapp" && \ |
||||
dnf -y install golang && \ |
||||
git clone https://github.com/hoehermann/purple-gowhatsapp && \ |
||||
cd purple-gowhatsapp && \ |
||||
make && \ |
||||
make install && \ |
||||
cd .. && \ |
||||
rm -rf purple-gowhatsapp && \ |
||||
dnf -y remove golang |
||||
RUN echo "---> cleanup" && \ |
||||
rm -rf /usr/share/locale/* && \ |
||||
rm -rf /usr/share/doc/* && \ |
||||
rm -rf /usr/share/icons/* && \ |
||||
rm -rf /usr/share/cracklib* && \ |
||||
rm -rf /usr/share/hwdata* && \ |
||||
rm -rf /usr/lib64/libQtGui* && \ |
||||
rm -rf /usr/lib64/libQtSvg* && \ |
||||
rm -rf /usr/lib64/libQtDeclarative* && \ |
||||
rm -rf /usr/lib64/libQtOpenGL* && \ |
||||
rm -rf /usr/lib64/libQtScriptTools* && \ |
||||
rm -rf /usr/lib64/libQtMultimedia* && \ |
||||
rm -rf /usr/lib64/libQtHelp* && \ |
||||
rm -rf /usr/lib64/libQtDesigner* && \ |
||||
rm -rf /usr/lib64/libQt3* && \ |
||||
dnf remove protobuf-devel swiften-devel gcc gcc-c++ libpqxx-devel libev-libevent-devel qt-devel dbus-glib-devel libpurple-devel rpm-build avahi-devel boost-devel cmake cppunit-devel expat-devel libcommuni-devel libidn-devel libsqlite3x-devel libgcrypt-devel libwebp-devel libpurple-devel zlib-devel json-glib-devel zlib-devel libjpeg-devel python-devel log4cxx-devel mysql-devel popt-devel libcurl-devel spectrum2-debuginfo wget -y && \ |
||||
dnf clean all -y && \ |
||||
rm -rf /var/lib/rpm/* |
||||
|
||||
CMD "/run.sh" |
@ -1,23 +0,0 @@
@@ -1,23 +0,0 @@
|
||||
version: 1.0.{build} |
||||
image: Visual Studio 2017 |
||||
build_script: |
||||
- cmd: >- |
||||
curl -L -O https://packages.spectrum.im/deps32.zip |
||||
|
||||
7z x deps32.zip |
||||
|
||||
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars32.bat" |
||||
|
||||
set PATH=%PATH%;C:\projects\spectrum2\deps32\bin |
||||
|
||||
set CMAKE_PREFIX_PATH=C:\projects\spectrum2\deps32 |
||||
|
||||
cmake . -G "NMake Makefiles" -DENABLE_PURPLE=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DENABLE_TESTS=ON -DCMAKE_INSTALL_PREFIX=dist |
||||
|
||||
nmake |
||||
|
||||
nmake install |
||||
|
||||
nmake test |
||||
artifacts: |
||||
- path: dist |
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.6) |
||||
|
||||
add_subdirectory(dfrotz) |
||||
|
||||
file(GLOB SRC *.c *.cpp) |
||||
|
||||
add_executable(spectrum2_frotz_backend ${SRC}) |
||||
|
||||
target_link_libraries(spectrum2_frotz_backend transport pthread ${Boost_LIBRARIES} ${SWIFTEN_LIBRARY} ${LOG4CXX_LIBRARIES}) |
||||
|
||||
install(TARGETS spectrum2_frotz_backend RUNTIME DESTINATION bin) |
@ -1,9 +0,0 @@
@@ -1,9 +0,0 @@
|
||||
cmake_minimum_required(VERSION 2.6) |
||||
file(GLOB SRC common/*.c dumb/*.c) |
||||
|
||||
add_executable(dfrotz ${SRC}) |
||||
|
||||
# target_link_libraries(dfrotz) |
||||
|
||||
install(TARGETS dfrotz RUNTIME DESTINATION bin) |
||||
|
@ -1,2 +0,0 @@
@@ -1,2 +0,0 @@
|
||||
This is patched version of dfrotz. frotz_backend won't work with dfrotz from |
||||
your distribution. |
@ -1,154 +0,0 @@
@@ -1,154 +0,0 @@
|
||||
/* buffer.c - Text buffering and word wrapping
|
||||
* Copyright (c) 1995-1997 Stefan Jokisch |
||||
* |
||||
* This file is part of Frotz. |
||||
* |
||||
* Frotz 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. |
||||
* |
||||
* Frotz 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 "frotz.h" |
||||
|
||||
extern void stream_char (zchar); |
||||
extern void stream_word (const zchar *); |
||||
extern void stream_new_line (void); |
||||
|
||||
static zchar buffer[TEXT_BUFFER_SIZE]; |
||||
static int bufpos = 0; |
||||
|
||||
static zchar prev_c = 0; |
||||
|
||||
/*
|
||||
* flush_buffer |
||||
* |
||||
* Copy the contents of the text buffer to the output streams. |
||||
* |
||||
*/ |
||||
|
||||
void flush_buffer (void) |
||||
{ |
||||
static bool locked = FALSE; |
||||
|
||||
/* Make sure we stop when flush_buffer is called from flush_buffer.
|
||||
Note that this is difficult to avoid as we might print a newline |
||||
during flush_buffer, which might cause a newline interrupt, that |
||||
might execute any arbitrary opcode, which might flush the buffer. */ |
||||
|
||||
if (locked || bufpos == 0) |
||||
return; |
||||
|
||||
/* Send the buffer to the output streams */ |
||||
|
||||
buffer[bufpos] = 0; |
||||
|
||||
|
||||
locked = TRUE; |
||||
|
||||
stream_word (buffer); |
||||
|
||||
#ifdef SPEECH_OUTPUT |
||||
os_speech_output(buffer); |
||||
#endif |
||||
|
||||
locked = FALSE; |
||||
|
||||
/* Reset the buffer */ |
||||
|
||||
bufpos = 0; |
||||
prev_c = 0; |
||||
|
||||
}/* flush_buffer */ |
||||
|
||||
/*
|
||||
* print_char |
||||
* |
||||
* High level output function. |
||||
* |
||||
*/ |
||||
|
||||
void print_char (zchar c) |
||||
{ |
||||
static bool flag = FALSE; |
||||
|
||||
if (message || ostream_memory || enable_buffering) { |
||||
|
||||
if (!flag) { |
||||
|
||||
/* Characters 0 and ZC_RETURN are special cases */ |
||||
|
||||
if (c == ZC_RETURN) |
||||
{ new_line (); return; } |
||||
if (c == 0) |
||||
return; |
||||
|
||||
/* Flush the buffer before a whitespace or after a hyphen */ |
||||
|
||||
if (c == ' ' || c == ZC_INDENT || c == ZC_GAP || (prev_c == '-' && c != '-')) |
||||
|
||||
|
||||
flush_buffer (); |
||||
|
||||
/* Set the flag if this is part one of a style or font change */ |
||||
|
||||
if (c == ZC_NEW_FONT || c == ZC_NEW_STYLE) |
||||
flag = TRUE; |
||||
|
||||
/* Remember the current character code */ |
||||
|
||||
prev_c = c; |
||||
|
||||
} else flag = FALSE; |
||||
|
||||
/* Insert the character into the buffer */ |
||||
|
||||
buffer[bufpos++] = c; |
||||
|
||||
if (bufpos == TEXT_BUFFER_SIZE) |
||||
runtime_error (ERR_TEXT_BUF_OVF); |
||||
|
||||
} else stream_char (c); |
||||
|
||||
}/* print_char */ |
||||
|
||||
/*
|
||||
* new_line |
||||
* |
||||
* High level newline function. |
||||
* |
||||
*/ |
||||
|
||||
void new_line (void) |
||||
{ |
||||
|
||||
flush_buffer (); stream_new_line (); |
||||
|
||||
}/* new_line */ |
||||
|
||||
|
||||
/*
|
||||
* init_buffer |
||||
* |
||||
* Initialize buffer variables. |
||||
* |
||||
*/ |
||||
|
||||
void init_buffer(void) |
||||
{ |
||||
memset(buffer, 0, sizeof (zchar) * TEXT_BUFFER_SIZE); |
||||
bufpos = 0; |
||||
prev_c = 0; |
||||
} |
||||
|
@ -1,154 +0,0 @@
@@ -1,154 +0,0 @@
|
||||
/* err.c - Runtime error reporting functions
|
||||
* Written by Jim Dunleavy <jim.dunleavy@erha.ie> |
||||
* |
||||
* This file is part of Frotz. |
||||
* |
||||
* Frotz 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. |
||||
* |
||||
* Frotz 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 "frotz.h" |
||||
|
||||
/* Define stuff for stricter Z-code error checking, for the generic
|
||||
Unix/DOS/etc terminal-window interface. Feel free to change the way |
||||
player prefs are specified, or replace report_zstrict_error() |
||||
completely if you want to change the way errors are reported. */ |
||||
|
||||
/* int err_report_mode = ERR_DEFAULT_REPORT_MODE; */ |
||||
|
||||
static int error_count[ERR_NUM_ERRORS]; |
||||
|
||||
static char *err_messages[] = { |
||||
"Text buffer overflow", |
||||
"Store out of dynamic memory", |
||||
"Division by zero", |
||||
"Illegal object", |
||||
"Illegal attribute", |
||||
"No such property", |
||||
"Stack overflow", |
||||
"Call to illegal address", |
||||
"Call to non-routine", |
||||
"Stack underflow", |
||||
"Illegal opcode", |
||||
"Bad stack frame", |
||||
"Jump to illegal address", |
||||
"Can't save while in interrupt", |
||||
"Nesting stream #3 too deep", |
||||
"Illegal window", |
||||
"Illegal window property", |
||||
"Print at illegal address", |
||||
"@jin called with object 0", |
||||
"@get_child called with object 0", |
||||
"@get_parent called with object 0", |
||||
"@get_sibling called with object 0", |
||||
"@get_prop_addr called with object 0", |
||||
"@get_prop called with object 0", |
||||
"@put_prop called with object 0", |
||||
"@clear_attr called with object 0", |
||||
"@set_attr called with object 0", |
||||
"@test_attr called with object 0", |
||||
"@move_object called moving object 0", |
||||
"@move_object called moving into object 0", |
||||
"@remove_object called with object 0", |
||||
"@get_next_prop called with object 0" |
||||
}; |
||||
|
||||
static void print_long (unsigned long value, int base); |
||||
|
||||
/*
|
||||
* init_err |
||||
* |
||||
* Initialise error reporting. |
||||
* |
||||
*/ |
||||
|
||||
void init_err (void) |
||||
{ |
||||
int i; |
||||
|
||||
/* Initialize the counters. */ |
||||
|
||||
for (i = 0; i < ERR_NUM_ERRORS; i++) |
||||
error_count[i] = 0; |
||||
} |
||||
|
||||
/*
|
||||
* runtime_error |
||||
* |
||||
* An error has occurred. Ignore it, pass it to os_fatal or report |
||||
* it according to err_report_mode. |
||||
* |
||||
* errnum : Numeric code for error (1 to ERR_NUM_ERRORS) |
||||
* |
||||
*/ |
||||
|
||||
void runtime_error (int errnum) |
||||
{ |
||||
int wasfirst; |
||||
|
||||
if (errnum <= 0 || errnum > ERR_NUM_ERRORS) |
||||
return; |
||||
|
||||
if (f_setup.err_report_mode == ERR_REPORT_FATAL |
||||
|| (!f_setup.ignore_errors && errnum <= ERR_MAX_FATAL)) { |
||||
flush_buffer (); |
||||
os_fatal (err_messages[errnum - 1]); |
||||
return; |
||||
} |
||||
|
||||
wasfirst = (error_count[errnum - 1] == 0); |
||||
error_count[errnum - 1]++; |
||||
|
||||
if ((f_setup.err_report_mode == ERR_REPORT_ALWAYS) |
||||
|| (f_setup.err_report_mode == ERR_REPORT_ONCE && wasfirst)) { |
||||
long pc; |
||||
|
||||
GET_PC (pc); |
||||
print_string ("Warning: "); |
||||
print_string (err_messages[errnum - 1]); |
||||
print_string (" (PC = "); |
||||
print_long (pc, 16); |
||||
print_char (')'); |
||||
|
||||
if (f_setup.err_report_mode == ERR_REPORT_ONCE) { |
||||
print_string (" (will ignore further occurrences)"); |
||||
} else { |
||||
print_string (" (occurence "); |
||||
print_long (error_count[errnum - 1], 10); |
||||
print_char (')'); |
||||
} |
||||
new_line (); |
||||
} |
||||
|
||||
} /* report_error */ |
||||
|
||||
/*
|
||||
* print_long |
||||
* |
||||
* Print an unsigned 32bit number in decimal or hex. |
||||
* |
||||
*/ |
||||
|
||||
static void print_long (unsigned long value, int base) |
||||
{ |
||||
unsigned long i; |
||||
char c; |
||||
|
||||
for (i = (base == 10 ? 1000000000 : 0x10000000); i != 0; i /= base) |
||||
if (value >= i || i == 1) { |
||||
c = (value / i) % base; |
||||
print_char (c + (c <= 9 ? '0' : 'a' - 10)); |
||||
} |
||||
|
||||
}/* print_long */ |
File diff suppressed because it is too large
Load Diff
@ -1,566 +0,0 @@
@@ -1,566 +0,0 @@
|
||||
/* files.c - Transscription, recording and playback
|
||||
* Copyright (c) 1995-1997 Stefan Jokisch |
||||
* |
||||
* This file is part of Frotz. |
||||
* |
||||
* Frotz 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. |
||||
* |
||||
* Frotz 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 <stdio.h> |
||||
#include <string.h> |
||||
#include "frotz.h" |
||||
|
||||
#ifndef SEEK_SET |
||||
#define SEEK_SET 0 |
||||
#define SEEK_CUR 1 |
||||
#define SEEK_END 2 |
||||
#endif |
||||
|
||||
extern void set_more_prompts (bool); |
||||
|
||||
extern bool is_terminator (zchar); |
||||
|
||||
extern bool read_yes_or_no (const char *); |
||||
|
||||
char script_name[MAX_FILE_NAME + 1] = DEFAULT_SCRIPT_NAME; |
||||
char command_name[MAX_FILE_NAME + 1] = DEFAULT_COMMAND_NAME; |
||||
|
||||
#ifdef __MSDOS__ |
||||
extern char latin1_to_ibm[]; |
||||
#endif |
||||
|
||||
static int script_width = 0; |
||||
|
||||
static FILE *sfp = NULL; |
||||
static FILE *rfp = NULL; |
||||
static FILE *pfp = NULL; |
||||
|
||||
/*
|
||||
* script_open |
||||
* |
||||
* Open the transscript file. 'AMFV' makes this more complicated as it |
||||
* turns transscription on/off several times to exclude some text from |
||||
* the transscription file. This wasn't a problem for the original V4 |
||||
* interpreters which always sent transscription to the printer, but it |
||||
* means a problem to modern interpreters that offer to open a new file |
||||
* every time transscription is turned on. Our solution is to append to |
||||
* the old transscription file in V1 to V4, and to ask for a new file |
||||
* name in V5+. |
||||
* |
||||
*/ |
||||
|
||||
void script_open (void) |
||||
{ |
||||
static bool script_valid = FALSE; |
||||
|
||||
char new_name[MAX_FILE_NAME + 1]; |
||||
|
||||
h_flags &= ~SCRIPTING_FLAG; |
||||
|
||||
if (h_version >= V5 || !script_valid) { |
||||
|
||||
if (!os_read_file_name (new_name, script_name, FILE_SCRIPT)) |
||||
goto done; |
||||
|
||||
strcpy (script_name, new_name); |
||||
|
||||
} |
||||
|
||||
/* Opening in "at" mode doesn't work for script_erase_input... */ |
||||
|
||||
if ((sfp = fopen (script_name, "r+t")) != NULL || (sfp = fopen (script_name, "w+t")) != NULL) { |
||||
|
||||
fseek (sfp, 0, SEEK_END); |
||||
|
||||
h_flags |= SCRIPTING_FLAG; |
||||
|
||||
script_valid = TRUE; |
||||
ostream_script = TRUE; |
||||
|
||||
script_width = 0; |
||||
|
||||
} else print_string ("Cannot open file\n"); |
||||
|
||||
done: |
||||
|
||||
SET_WORD (H_FLAGS, h_flags) |
||||
|
||||
}/* script_open */ |
||||
|
||||
/*
|
||||
* script_close |
||||
* |
||||
* Stop transscription. |
||||
* |
||||
*/ |
||||
|
||||
void script_close (void) |
||||
{ |
||||
|
||||
h_flags &= ~SCRIPTING_FLAG; |
||||
SET_WORD (H_FLAGS, h_flags) |
||||
|
||||
fclose (sfp); ostream_script = FALSE; |
||||
|
||||
}/* script_close */ |
||||
|
||||
/*
|
||||
* script_new_line |
||||
* |
||||
* Write a newline to the transscript file. |
||||
* |
||||
*/ |
||||
|
||||
void script_new_line (void) |
||||
{ |
||||
|
||||
if (fputc ('\n', sfp) == EOF) |
||||
script_close (); |
||||
|
||||
script_width = 0; |
||||
|
||||
}/* script_new_line */ |
||||
|
||||
/*
|
||||
* script_char |
||||
* |
||||
* Write a single character to the transscript file. |
||||
* |
||||
*/ |
||||
|
||||
void script_char (zchar c) |
||||
{ |
||||
|
||||
if (c == ZC_INDENT && script_width != 0) |
||||
c = ' '; |
||||
|
||||
if (c == ZC_INDENT) |
||||
{ script_char (' '); script_char (' '); script_char (' '); return; } |
||||
if (c == ZC_GAP) |
||||
{ script_char (' '); script_char (' '); return; } |
||||
|
||||
#ifdef __MSDOS__ |
||||
if (c >= ZC_LATIN1_MIN) |
||||
c = latin1_to_ibm[c - ZC_LATIN1_MIN]; |
||||
#endif |
||||
|
||||
fputc (c, sfp); script_width++; |
||||
|
||||
}/* script_char */ |
||||
|
||||
/*
|
||||
* script_word |
||||
* |
||||
* Write a string to the transscript file. |
||||
* |
||||
*/ |
||||
|
||||
void script_word (const zchar *s) |
||||
{ |
||||
int width; |
||||
int i; |
||||
|
||||
if (*s == ZC_INDENT && script_width != 0) |
||||
script_char (*s++); |
||||
|
||||
for (i = 0, width = 0; s[i] != 0; i++) |
||||
|
||||
if (s[i] == ZC_NEW_STYLE || s[i] == ZC_NEW_FONT) |
||||
i++; |
||||
else if (s[i] == ZC_GAP) |
||||
width += 3; |
||||
else if (s[i] == ZC_INDENT) |
||||
width += 2; |
||||
else |
||||
width += 1; |
||||
|
||||
if (f_setup.script_cols != 0 && script_width + width > f_setup.script_cols) { |
||||
|
||||
if (*s == ' ' || *s == ZC_INDENT || *s == ZC_GAP) |
||||
s++; |
||||
|
||||
script_new_line (); |
||||
|
||||
} |
||||
|
||||
for (i = 0; s[i] != 0; i++) |
||||
|
||||
if (s[i] == ZC_NEW_FONT || s[i] == ZC_NEW_STYLE) |
||||
i++; |
||||
else |
||||
script_char (s[i]); |
||||
|
||||
}/* script_word */ |
||||
|
||||
/*
|
||||
* script_write_input |
||||
* |
||||
* Send an input line to the transscript file. |
||||
* |
||||
*/ |
||||
|
||||
void script_write_input (const zchar *buf, zchar key) |
||||
{ |
||||
int width; |
||||
int i; |
||||
|
||||
for (i = 0, width = 0; buf[i] != 0; i++) |
||||
width++; |
||||
|
||||
if (f_setup.script_cols != 0 && script_width + width > f_setup.script_cols) |
||||
script_new_line (); |
||||
|
||||
for (i = 0; buf[i] != 0; i++) |
||||
script_char (buf[i]); |
||||
|
||||
if (key == ZC_RETURN) |
||||
script_new_line (); |
||||
|
||||
}/* script_write_input */ |
||||
|
||||
/*
|
||||
* script_erase_input |
||||
* |
||||
* Remove an input line from the transscript file. |
||||
* |
||||
*/ |
||||
|
||||
void script_erase_input (const zchar *buf) |
||||
{ |
||||
int width; |
||||
int i; |
||||
|
||||
for (i = 0, width = 0; buf[i] != 0; i++) |
||||
width++; |
||||
|
||||
fseek (sfp, -width, SEEK_CUR); script_width -= width; |
||||
|
||||
}/* script_erase_input */ |
||||
|
||||
/*
|
||||
* script_mssg_on |
||||
* |
||||
* Start sending a "debugging" message to the transscript file. |
||||
* |
||||
*/ |
||||
|
||||
void script_mssg_on (void) |
||||
{ |
||||
|
||||
if (script_width != 0) |
||||
script_new_line (); |
||||
|
||||
script_char (ZC_INDENT); |
||||
|
||||
}/* script_mssg_on */ |
||||
|
||||
/*
|
||||
* script_mssg_off |
||||
* |
||||
* Stop writing a "debugging" message. |
||||
* |
||||
*/ |
||||
|
||||
void script_mssg_off (void) |
||||
{ |
||||
|
||||
script_new_line (); |
||||
|
||||
}/* script_mssg_off */ |
||||
|
||||
/*
|
||||
* record_open |
||||
* |
||||
* Open a file to record the player's input. |
||||
* |
||||
*/ |
||||
|
||||
void record_open (void) |
||||
{ |
||||
char new_name[MAX_FILE_NAME + 1]; |
||||
|
||||
if (os_read_file_name (new_name, command_name, FILE_RECORD)) { |
||||
|
||||
strcpy (command_name, new_name); |
||||
|
||||
if ((rfp = fopen (new_name, "wt")) != NULL) |
||||
ostream_record = TRUE; |
||||
else |
||||
print_string ("Cannot open file\n"); |
||||
|
||||
} |
||||
|
||||
}/* record_open */ |
||||
|
||||
/*
|
||||
* record_close |
||||
* |
||||
* Stop recording the player's input. |
||||
* |
||||
*/ |
||||
|
||||
void record_close (void) |
||||
{ |
||||
|
||||
fclose (rfp); ostream_record = FALSE; |
||||
|
||||
}/* record_close */ |
||||
|
||||
/*
|
||||
* record_code |
||||
* |
||||
* Helper function for record_char. |
||||
* |
||||
*/ |
||||
|
||||
static void record_code (int c, bool force_encoding) |
||||
{ |
||||
|
||||
if (force_encoding || c == '[' || c < 0x20 || c > 0x7e) { |
||||
|
||||
int i; |
||||
|
||||
fputc ('[', rfp); |
||||
|
||||
for (i = 10000; i != 0; i /= 10) |
||||
if (c >= i || i == 1) |
||||
fputc ('0' + (c / i) % 10, rfp); |
||||
|
||||
fputc (']', rfp); |
||||
|
||||
} else fputc (c, rfp); |
||||
|
||||
}/* record_code */ |
||||
|
||||
/*
|
||||
* record_char |
||||
* |
||||
* Write a character to the command file. |
||||
* |
||||
*/ |
||||
|
||||
static void record_char (zchar c) |
||||
{ |
||||
|
||||
if (c != ZC_RETURN) { |
||||
if (c < ZC_HKEY_MIN || c > ZC_HKEY_MAX) { |
||||
record_code (translate_to_zscii (c), FALSE); |
||||
if (c == ZC_SINGLE_CLICK || c == ZC_DOUBLE_CLICK) { |
||||
record_code (mouse_x, TRUE); |
||||
record_code (mouse_y, TRUE); |
||||
} |
||||
} else record_code (1000 + c - ZC_HKEY_MIN, TRUE); |
||||
} |
||||
|
||||
}/* record_char */ |
||||
|
||||
/*
|
||||
* record_write_key |
||||
* |
||||
* Copy a keystroke to the command file. |
||||
* |
||||
*/ |
||||
|
||||
void record_write_key (zchar key) |
||||
{ |
||||
|
||||
record_char (key); |
||||
|
||||
if (fputc ('\n', rfp) == EOF) |
||||
record_close (); |
||||
|
||||
}/* record_write_key */ |
||||
|
||||
/*
|
||||
* record_write_input |
||||
* |
||||
* Copy a line of input to a command file. |
||||
* |
||||
*/ |
||||
|
||||
void record_write_input (const zchar *buf, zchar key) |
||||
{ |
||||
zchar c; |
||||
|
||||
while ((c = *buf++) != 0) |
||||
record_char (c); |
||||
|
||||
record_char (key); |
||||
|
||||
if (fputc ('\n', rfp) == EOF) |
||||
record_close (); |
||||
|
||||
}/* record_write_input */ |
||||
|
||||
/*
|
||||
* replay_open |
||||
* |
||||
* Open a file of commands for playback. |
||||
* |
||||
*/ |
||||
|
||||
void replay_open (void) |
||||
{ |
||||
char new_name[MAX_FILE_NAME + 1]; |
||||
|
||||
if (os_read_file_name (new_name, command_name, FILE_PLAYBACK)) { |
||||
|
||||
strcpy (command_name, new_name); |
||||
|
||||
if ((pfp = fopen (new_name, "rt")) != NULL) { |
||||
|
||||
set_more_prompts (read_yes_or_no ("Do you want MORE prompts")); |
||||
|
||||
istream_replay = TRUE; |
||||
|
||||
} else print_string ("Cannot open file\n"); |
||||
|
||||
} |
||||
|
||||
}/* replay_open */ |
||||
|
||||
/*
|
||||
* replay_close |
||||
* |
||||
* Stop playback of commands. |
||||
* |
||||
*/ |
||||
|
||||
void replay_close (void) |
||||
{ |
||||
|
||||
set_more_prompts (TRUE); |
||||
|
||||
fclose (pfp); istream_replay = FALSE; |
||||
|
||||
}/* replay_close */ |
||||
|
||||
/*
|
||||
* replay_code |
||||
* |
||||
* Helper function for replay_key and replay_line. |
||||
* |
||||
*/ |
||||
|
||||
static int replay_code (void) |
||||
{ |
||||
int c; |
||||
|
||||
if ((c = fgetc (pfp)) == '[') { |
||||
|
||||
int c2; |
||||
|
||||
c = 0; |
||||
|
||||
while ((c2 = fgetc (pfp)) != EOF && c2 >= '0' && c2 <= '9') |
||||
c = 10 * c + c2 - '0'; |
||||
|
||||
return (c2 == ']') ? c : EOF; |
||||
|
||||
} else return c; |
||||
|
||||
}/* replay_code */ |
||||
|
||||
/*
|
||||
* replay_char |
||||
* |
||||
* Read a character from the command file. |
||||
* |
||||
*/ |
||||
|
||||
static zchar replay_char (void) |
||||
{ |
||||
int c; |
||||
|
||||
if ((c = replay_code ()) != EOF) { |
||||
|
||||
if (c != '\n') { |
||||
|
||||
if (c < 1000) { |
||||
|
||||
c = translate_from_zscii (c); |
||||
|
||||
if (c == ZC_SINGLE_CLICK || c == ZC_DOUBLE_CLICK) { |
||||
mouse_x = replay_code (); |
||||
mouse_y = replay_code (); |
||||
} |
||||
|
||||
return c; |
||||
|
||||
} else return ZC_HKEY_MIN + c - 1000; |
||||
} |
||||
|
||||
ungetc ('\n', pfp); |
||||
|
||||
return ZC_RETURN; |
||||
|
||||
} else return ZC_BAD; |
||||
|
||||
}/* replay_char */ |
||||
|
||||
/*
|
||||
* replay_read_key |
||||
* |
||||
* Read a keystroke from a command file. |
||||
* |
||||
*/ |
||||
|
||||
zchar replay_read_key (void) |
||||
{ |
||||
zchar key; |
||||
|
||||
key = replay_char (); |
||||
|
||||
if (fgetc (pfp) != '\n') { |
||||
|
||||
replay_close (); |
||||
return ZC_BAD; |
||||
|
||||
} else return key; |
||||
|
||||
}/* replay_read_key */ |
||||
|
||||
/*
|
||||
* replay_read_input |
||||
* |
||||
* Read a line of input from a command file. |
||||
* |
||||
*/ |
||||
|
||||
zchar replay_read_input (zchar *buf) |
||||
{ |
||||
zchar c; |
||||
|
||||
for (;;) { |
||||
|
||||
c = replay_char (); |
||||
|
||||
if (c == ZC_BAD || is_terminator (c)) |
||||
break; |
||||
|
||||
*buf++ = c; |
||||
|
||||
} |
||||
|
||||
*buf = 0; |
||||
|
||||
if (fgetc (pfp) != '\n') { |
||||
|
||||
replay_close (); |
||||
return ZC_BAD; |
||||
|
||||
} else return c; |
||||
|
||||
}/* replay_read_input */ |
@ -1,617 +0,0 @@
@@ -1,617 +0,0 @@
|
||||
/*
|
||||
* frotz.h |
||||
* |
||||
* Global declarations and definitions |
||||
* |
||||
*/ |
||||
|
||||
/* Unfortunately, frotz's bool definition conflicts with that of curses.
|
||||
But since no os_* function uses it, it's safe to let the frotz core see |
||||
this definition, but have the unix port see the curses version. */ |
||||
|
||||
/* #include "../config.h" */ |
||||
|
||||
#ifndef __UNIX_PORT_FILE |
||||
#include <signal.h> |
||||
typedef int bool; |
||||
|
||||
#ifndef TRUE |
||||
#define TRUE 1 |
||||
#endif |
||||
|
||||
#ifndef FALSE |
||||
#define FALSE 0 |
||||
#endif |
||||
|
||||
#endif /* __UNIX_PORT_FILE */ |
||||
|
||||
|
||||
#include <stdio.h> |
||||
|
||||
|
||||