$ git clone http://tcclient.ion.nu/tc_client.git
commit f4de1cef56e258eaa68e55f3f15efdd5768648aa
Author: Alicia <...>
Date: Tue Apr 7 06:49:01 2015 +0200
Version 0.9
diff --git a/ChangeLog b/ChangeLog
index 5079b35..4b17eb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+0.9:
+Added compatibility workarounds for android.
+Keep track of who is a moderator. (contributed by Jade)
+Added crossbuild.sh script to automatically cross-compile tc_client and curl (dependency) for the given host-triplet.
0.8:
irchack: convert tc_client's ANSI codes to IRC color codes.
irchack: convert IRC color codes to '/color <number>' commands for tc_client.
diff --git a/Makefile b/Makefile
index 76be707..7b7cee2 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,4 @@
-VERSION=0.8
+VERSION=0.9
CFLAGS=-g3 -Wall $(shell curl-config --cflags)
LIBS=-g3 $(shell curl-config --libs)
@@ -9,4 +9,4 @@ clean:
rm -f client.o amfparser.o rtmp.o numlist.o amfwriter.o idlist.o colors.o tc_client
tarball:
- tar -cJf tc_client-$(VERSION).tar.xz --transform='s|^|tc_client-$(VERSION)/|' Makefile client.c amfparser.c rtmp.c numlist.c amfwriter.c idlist.c colors.c amfparser.h rtmp.h numlist.h amfwriter.h idlist.h colors.h LICENSE README ChangeLog irchack.c
+ tar -cJf tc_client-$(VERSION).tar.xz --transform='s|^|tc_client-$(VERSION)/|' Makefile client.c amfparser.c rtmp.c numlist.c amfwriter.c idlist.c colors.c amfparser.h rtmp.h numlist.h amfwriter.h idlist.h colors.h LICENSE README ChangeLog crossbuild.sh irchack.c
diff --git a/client.c b/client.c
index 5fddd11..5b60035 100644
--- a/client.c
+++ b/client.c
@@ -403,7 +403,11 @@ int main(int argc, char** argv)
{
wchar_t* msg=fromnumlist(amfin->items[3].string.string);
const char* color=(showcolor?resolvecolor(amfin->items[4].string.string):"0");
+#ifndef __ANDROID__
printf("%s \x1b[%sm%s: %ls\x1b[0m\n", timestamp(), color, amfin->items[5].string.string, msg);
+#else // Wide characters are broken on android
+ printf("%s \x1b[%sm%s: %s\x1b[0m\n", timestamp(), color, amfin->items[5].string.string, msg);
+#endif
free(msg);
fflush(stdout);
}
@@ -480,6 +484,13 @@ int main(int argc, char** argv)
fflush(stdout);
}
}
+ // oper, identifies mods
+ else if(amfin->itemcount==4 && amfin->items[0].type==AMF_STRING && amf_comparestrings_c(&amfin->items[0].string, "oper") && amfin->items[3].type==AMF_STRING)
+ {
+ idlist_set_op(amfin->items[3].string.string);
+ printf("%s is a moderator.\n", amfin->items[3].string.string);
+ fflush(stdout);
+ }
// else{printf("Unknown command...\n"); printamf(amfin);} // (Debugging)
amf_free(amfin);
}
diff --git a/crossbuild.sh b/crossbuild.sh
index 84893a4..7ff352e 100755
--- a/crossbuild.sh
+++ b/crossbuild.sh
@@ -6,60 +6,25 @@ if [ "$host" = "" ]; then
echo "No target host specified (argv[1]), defaulting to ${host}"
fi
here="`pwd`"
-export PATH="${here}/curlprefix/bin:${here}/ncursesprefix/bin:${PATH}"
-if [ ! -e ncursesprefix ]; then
- wget -c http://ftp.gnu.org/gnu/ncurses/ncurses-5.9.tar.gz
- tar -xzf ncurses-5.9.tar.gz
- cd ncurses-5.9
- mkdir build
- cd build
- # Some hackery to build ncursesw5-config, which seems to get disabled along with --disable-database
- ../configure --prefix="${here}/ncursesprefix" --host="${host}" --enable-static --disable-shared --with-termlib --enable-widec --without-cxx ac_cv_header_locale_h=no
- mv Makefile Makefile.tmp
- ../configure --prefix="${here}/ncursesprefix" --host="${host}" --enable-static --disable-shared --with-termlib --enable-widec --without-cxx --disable-database --with-fallbacks=linux ac_cv_header_locale_h=no
- mv Makefile.tmp Makefile
- make
- make install
- cd "$here"
- cp ncursesprefix/lib/libtinfow.a ncursesprefix/lib/libtinfo.a
-fi
-if [ ! -e readlineprefix ]; then
- wget -c http://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz
- tar -xzf readline-6.3.tar.gz
- cd readline-6.3
- mkdir build
- cd build
- ../configure --prefix="${here}/readlineprefix" --host="${host}" --enable-static --disable-shared bash_cv_wcwidth_broken=no
- make
- make install
- cd "$here"
-fi
-if [ ! -e curlprefix ]; then
- wget -c http://curl.haxx.se/download/curl-7.40.0.tar.bz2
- tar -xjf curl-7.40.0.tar.bz2
- cd curl-7.40.0
- mkdir -p build
- cd build
- ../configure --prefix="${here}/curlprefix" --host="$host" --enable-static --disable-shared --disable-gopher --disable-ftp --disable-tftp --disable-ssh --disable-telnet --disable-dict --disable-file --disable-imap --disable-pop3 --disable-smtp --disable-ldap --without-librtmp --disable-rtsp --without-ssl --disable-sspi --without-nss --without-gnutls --without-libidn
- make
- make install
- cd "$here"
+if false; then
+wget -c http://curl.haxx.se/download/curl-7.39.0.tar.bz2
+tar -xjf curl-7.39.0.tar.bz2
+cd curl-7.39.0
+mkdir -p build
+cd build
+../configure --prefix="${here}/curlprefix" --host="$host" --enable-static --disable-shared --disable-gopher --disable-ftp --disable-tftp --disable-ssh --disable-telnet --disable-dict --disable-file --disable-imap --disable-pop3 --disable-smtp --disable-ldap --without-librtmp --disable-rtsp --without-ssl --disable-sspi --without-nss --without-gnutls --without-libidn
+make
+make install
+cd "$here"
fi
-./configure --host="$host" > config.log 2>&1
-if grep -q 'LIBS+=-liconv' config.mk && [ ! -e iconvprefix ]; then
- wget -c http://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
- tar -xzf libiconv-1.14.tar.gz
- cd libiconv-1.14
- mkdir -p build
- cd build
- ../configure --prefix="${here}/iconvprefix" --host="`echo "$host" | sed -e 's/android/gnu/'`" --enable-static --disable-shared CC="${host}-gcc" # libiconv does not handle android well, so we pretend it's GNU and specify the compiler
- make
- make install
- cd "$here"
+export PATH="${here}/curlprefix/bin:${PATH}"
+# Select a crosscompiler (if we can find one)
+if which "${host}-gcc" > /dev/null 2> /dev/null && [ "`which "${host}-gcc" 2> /dev/null`" != "" ]; then
+ export CC="${host}-gcc"
+elif which "${host}-clang" > /dev/null 2> /dev/null && [ "`which "${host}-clang" 2> /dev/null`" != "" ]; then
+ export CC="${host}-clang"
+elif which "${host}-cc" > /dev/null 2> /dev/null && [ "`which "${host}-cc" 2> /dev/null`" != "" ]; then
+ export CC="${host}-cc"
fi
-echo "CFLAGS+=-I${here}/iconvprefix/include" >> config.mk
-echo "LDFLAGS+=-L${here}/iconvprefix/lib" >> config.mk
-echo "READLINE_CFLAGS=-I${here}/readlineprefix/include" >> config.mk
-echo "READLINE_LIBS=-L${here}/readlineprefix/lib -lreadline" >> config.mk
make
-make utils
+make irchack
diff --git a/idlist.c b/idlist.c
index da7a400..c7fe7a3 100644
--- a/idlist.c
+++ b/idlist.c
@@ -73,3 +73,29 @@ int idlist_get(const char* name)
}
return -1;
}
+
+void idlist_set_op(const char* name)
+{
+ int i;
+ for(i=0; i<idlistlen; ++i)
+ {
+ if(!strcmp(name, idlist[i].name))
+ {
+ idlist[i].op=1;
+ return;
+ }
+ }
+}
+
+char idlist_is_op(const char* name)
+{
+ int i;
+ for(i=0; i<idlistlen; ++i)
+ {
+ if(!strcmp(name, idlist[i].name))
+ {
+ return idlist[i].op;
+ }
+ }
+ return 0;
+}
diff --git a/idlist.h b/idlist.h
index 3a04b6a..c08ab8d 100644
--- a/idlist.h
+++ b/idlist.h
@@ -16,8 +16,9 @@
*/
struct idmap
{
- int id;
const char* name;
+ int id;
+ char op;
};
extern struct idmap* idlist;
@@ -27,3 +28,5 @@ extern void idlist_add(int id, const char* name);
extern void idlist_remove(const char* name);
extern void idlist_rename(const char* oldname, const char* newname);
extern int idlist_get(const char* name);
+extern void idlist_set_op(const char* name);
+extern char idlist_is_op(const char* name);
diff --git a/irchack.c b/irchack.c
index 92ce025..95484cb 100644
--- a/irchack.c
+++ b/irchack.c
@@ -23,6 +23,25 @@
#include <sys/socket.h>
#include <ctype.h>
+#ifdef __ANDROID__
+// Android has no dprintf, so we make our own
+#include <stdarg.h>
+size_t dprintf(int fd, const char* fmt, ...)
+{
+ va_list va;
+ va_start(va, fmt);
+ int len=vsnprintf(0, 0, fmt, va);
+ va_end(va);
+ char buf[len+1];
+ va_start(va, fmt);
+ vsnprintf(buf, len+1, fmt, va);
+ va_end(va);
+ buf[len]=0;
+ write(fd, buf, len);
+ return len;
+}
+#endif
+
// ANSI colors and their IRC equivalents
struct color{const char* ansi; const char* irc;};
struct color colortable[]={
@@ -200,6 +219,13 @@ printf("Got from tc_client: '%s'\n", buf);
dprintf(sock, ":irchack 366 %s #%s :End of /NAMES list.\n", nick, channel);
continue;
}
+ char* space=strchr(buf, ' ');
+ if(space && !strcmp(space, " is a moderator."))
+ {
+ space[0]=0;
+ dprintf(sock, ":irchack MODE #%s +o %s\n", channel, buf);
+ continue;
+ }
if(buf[0]!='['){continue;} // Beyond this we only care about timestamped lines
// Translate ANSI escape codes to IRC color code instead
char* ansi;
diff --git a/numlist.h b/numlist.h
index 115206e..963daff 100644
--- a/numlist.h
+++ b/numlist.h
@@ -14,5 +14,12 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#ifdef __ANDROID__ // Compatibility hacks for android
+ #define wchar_t char
+ #define mbstowcs(dst,src,len) ((dst)?(int)strncpy(dst,src,len):strlen(src))
+ #define wcstombs strncpy
+ #define wcslen strlen
+#endif
+
extern wchar_t* fromnumlist(char* in);
extern char* tonumlist(const wchar_t* in);