The yahoo protocol is stable enough to be included in the trunk.

This commit is contained in:
barrett 2011-04-19 22:41:39 +00:00
parent ccb2ba04e9
commit 7800069ca2
37 changed files with 20808 additions and 4 deletions

View File

@ -54,10 +54,6 @@ CheckOpenSSL ;
if ! $(HAVE_OPENSSL) {
Echo "** MSN, Jabber, GoogleTalk and Facebook protocols are disabled for lack of OpenSSL" ;
}
CheckLibYahoo2 ;
if ! $(HAVE_LIBYAHOO2) {
Echo "** Yahoo protocol is disabled for lack of libyahoo2" ;
}
# Include jam scripts
include [ FDirName $(JAM_DIR) HelperRules ] ;

View File

@ -4,3 +4,4 @@ SubDir TOP libs ;
SubInclude TOP libs libgloox ;
SubInclude TOP libs libmsn ;
SubInclude TOP libs libsupport ;
SubInclude TOP libs libyahoo2 ;

24
libs/libyahoo2/Jamfile Normal file
View File

@ -0,0 +1,24 @@
SubDir TOP libs libyahoo2 ;
SubDirSysHdrs [ FDirName $(TOP) ] ;
SubDirSysHdrs [ FDirName $(TOP) libs ] ;
SubDirSysHdrs [ FDirName $(TOP) libs libyahoo2 ] ;
#SubDirSysHdrs [ FDirName $(OPENSSL_INCLUDE_DIR) ] ;
#SEARCH_SOURCE += [ FDirName $(TOP) libs ] ;
local sources =
# libyahoo
autoresponder.c
libyahoo2.c
yahoo_fn.c
yahoo_list.c
crypt.c
md5.c
sha1.c
yahoo_httplib.c
yahoo_util.c
;
StaticLibrary libyahoo2.a : $(sources) : be network ;

7
libs/libyahoo2/Makefile Normal file
View File

@ -0,0 +1,7 @@
all:
gcc BeTick.cpp -c -o BeTick.o
gcc TickApp.cpp -c -o TickApp.o
gcc TickCore.cpp -c -o TickCore.o
gcc TickView.cpp -c -o TickView.o
gcc TickWindow.cpp -c -o TickWindow.o
gcc BeTick.o TickApp.o TickCore.o TickView.o TickWindow.o -o BeTick -lgame -lbe

View File

@ -0,0 +1,31 @@
SUBDIRS = windows
lib_LTLIBRARIES = libyahoo2.la
EXTRA_DIST = sample_client.c autoresponder.c
noinst_HEADERS = md5.h yahoo_debug.h yahoo_util.h sha1.h yahoo_fn.h
AM_CFLAGS = $(GLIB_CFLAGS) -g -Wall
LIBS = @LIBS@ $(GLIB_LIBS)
libyahoo2_la_SOURCES = libyahoo2.c crypt.c md5.c sha1.c \
yahoo_httplib.c yahoo_util.c yahoo_list.c yahoo_fn.c
libyahoo2_la_LDFLAGS = -module -version-info $(YAHOO2_VERSION)
pkginclude_HEADERS = yahoo2.h yahoo2_callbacks.h yahoo2_types.h \
yahoo_httplib.h yahoo_list.h yahoo_fn.h
if SAMPLE_CLIENT
noinst_PROGRAMS = yahoo autoresponder
yahoo_SOURCES = sample_client.c
yahoo_LDADD = libyahoo2.la
yahoo_LDFLAGS = -lssl
autoresponder_SOURCES = autoresponder.c
autoresponder_LDADD = libyahoo2.la
autoresponder_LDFLAGS = -lssl
endif

654
libs/libyahoo2/Makefile.in Normal file
View File

@ -0,0 +1,654 @@
# Makefile.in generated by automake 1.9.6 from Makefile.am.
# @configure_input@
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
# 2003, 2004, 2005 Free Software Foundation, Inc.
# This Makefile.in is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
@SET_MAKE@
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@
pkglibdir = $(libdir)/@PACKAGE@
pkgincludedir = $(includedir)/@PACKAGE@
top_builddir = ..
am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
INSTALL = @INSTALL@
install_sh_DATA = $(install_sh) -c -m 644
install_sh_PROGRAM = $(install_sh) -c
install_sh_SCRIPT = $(install_sh) -c
INSTALL_HEADER = $(INSTALL_DATA)
transform = $(program_transform_name)
NORMAL_INSTALL = :
PRE_INSTALL = :
POST_INSTALL = :
NORMAL_UNINSTALL = :
PRE_UNINSTALL = :
POST_UNINSTALL = :
build_triplet = @build@
host_triplet = @host@
@SAMPLE_CLIENT_TRUE@noinst_PROGRAMS = yahoo$(EXEEXT) \
@SAMPLE_CLIENT_TRUE@ autoresponder$(EXEEXT)
subdir = src
DIST_COMMON = $(noinst_HEADERS) $(pkginclude_HEADERS) \
$(srcdir)/Makefile.am $(srcdir)/Makefile.in
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
$(top_srcdir)/configure.ac
am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
$(ACLOCAL_M4)
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = $(top_builddir)/config.h
CONFIG_CLEAN_FILES =
am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
am__vpath_adj = case $$p in \
$(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
*) f=$$p;; \
esac;
am__strip_dir = `echo $$p | sed -e 's|^.*/||'`;
am__installdirs = "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgincludedir)"
libLTLIBRARIES_INSTALL = $(INSTALL)
LTLIBRARIES = $(lib_LTLIBRARIES)
libyahoo2_la_LIBADD =
am_libyahoo2_la_OBJECTS = libyahoo2.lo crypt.lo md5.lo sha1.lo \
yahoo_httplib.lo yahoo_util.lo yahoo_list.lo yahoo_fn.lo
libyahoo2_la_OBJECTS = $(am_libyahoo2_la_OBJECTS)
PROGRAMS = $(noinst_PROGRAMS)
am__autoresponder_SOURCES_DIST = autoresponder.c
@SAMPLE_CLIENT_TRUE@am_autoresponder_OBJECTS = \
@SAMPLE_CLIENT_TRUE@ autoresponder.$(OBJEXT)
autoresponder_OBJECTS = $(am_autoresponder_OBJECTS)
@SAMPLE_CLIENT_TRUE@autoresponder_DEPENDENCIES = libyahoo2.la
am__yahoo_SOURCES_DIST = sample_client.c
@SAMPLE_CLIENT_TRUE@am_yahoo_OBJECTS = sample_client.$(OBJEXT)
yahoo_OBJECTS = $(am_yahoo_OBJECTS)
@SAMPLE_CLIENT_TRUE@yahoo_DEPENDENCIES = libyahoo2.la
DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir)
depcomp = $(SHELL) $(top_srcdir)/depcomp
am__depfiles_maybe = depfiles
COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
$(AM_CFLAGS) $(CFLAGS)
CCLD = $(CC)
LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
$(AM_LDFLAGS) $(LDFLAGS) -o $@
SOURCES = $(libyahoo2_la_SOURCES) $(autoresponder_SOURCES) \
$(yahoo_SOURCES)
DIST_SOURCES = $(libyahoo2_la_SOURCES) \
$(am__autoresponder_SOURCES_DIST) $(am__yahoo_SOURCES_DIST)
RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
html-recursive info-recursive install-data-recursive \
install-exec-recursive install-info-recursive \
install-recursive installcheck-recursive installdirs-recursive \
pdf-recursive ps-recursive uninstall-info-recursive \
uninstall-recursive
pkgincludeHEADERS_INSTALL = $(INSTALL_HEADER)
HEADERS = $(noinst_HEADERS) $(pkginclude_HEADERS)
ETAGS = etags
CTAGS = ctags
DIST_SUBDIRS = $(SUBDIRS)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
AMDEP_FALSE = @AMDEP_FALSE@
AMDEP_TRUE = @AMDEP_TRUE@
AMTAR = @AMTAR@
AR = @AR@
AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CC = @CC@
CCDEPMODE = @CCDEPMODE@
CFLAGS = @CFLAGS@
CPP = @CPP@
CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DATE = @DATE@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
ECHO = @ECHO@
ECHO_C = @ECHO_C@
ECHO_N = @ECHO_N@
ECHO_T = @ECHO_T@
EGREP = @EGREP@
EXEEXT = @EXEEXT@
F77 = @F77@
FFLAGS = @FFLAGS@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_CONFIG = @GLIB_CONFIG@
GLIB_GENMARSHAL = @GLIB_GENMARSHAL@
GLIB_LIBS = @GLIB_LIBS@
GLIB_MKENUMS = @GLIB_MKENUMS@
GOBJECT_QUERY = @GOBJECT_QUERY@
INSTALL_DATA = @INSTALL_DATA@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
INSTALL_SCRIPT = @INSTALL_SCRIPT@
INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
LDFLAGS = @LDFLAGS@
LIBOBJS = @LIBOBJS@
LIBS = @LIBS@ $(GLIB_LIBS)
LIBTOOL = @LIBTOOL@
LN_S = @LN_S@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAINTAINER_MODE_FALSE = @MAINTAINER_MODE_FALSE@
MAINTAINER_MODE_TRUE = @MAINTAINER_MODE_TRUE@
MAKEINFO = @MAKEINFO@
OBJEXT = @OBJEXT@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
PACKAGE_NAME = @PACKAGE_NAME@
PACKAGE_STRING = @PACKAGE_STRING@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PKG_CONFIG = @PKG_CONFIG@
RANLIB = @RANLIB@
SAMPLE_CLIENT_FALSE = @SAMPLE_CLIENT_FALSE@
SAMPLE_CLIENT_TRUE = @SAMPLE_CLIENT_TRUE@
SED = @SED@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
VERSION = @VERSION@
YAHOO2_VERSION = @YAHOO2_VERSION@
YAHOOPKGREQ = @YAHOOPKGREQ@
ac_ct_AR = @ac_ct_AR@
ac_ct_CC = @ac_ct_CC@
ac_ct_CXX = @ac_ct_CXX@
ac_ct_F77 = @ac_ct_F77@
ac_ct_RANLIB = @ac_ct_RANLIB@
ac_ct_STRIP = @ac_ct_STRIP@
am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
am__include = @am__include@
am__leading_dot = @am__leading_dot@
am__quote = @am__quote@
am__tar = @am__tar@
am__untar = @am__untar@
bindir = @bindir@
build = @build@
build_alias = @build_alias@
build_cpu = @build_cpu@
build_os = @build_os@
build_vendor = @build_vendor@
datadir = @datadir@
exec_prefix = @exec_prefix@
host = @host@
host_alias = @host_alias@
host_cpu = @host_cpu@
host_os = @host_os@
host_vendor = @host_vendor@
includedir = @includedir@
infodir = @infodir@
install_sh = @install_sh@
libdir = @libdir@
libexecdir = @libexecdir@
localstatedir = @localstatedir@
mandir = @mandir@
mkdir_p = @mkdir_p@
oldincludedir = @oldincludedir@
prefix = @prefix@
program_transform_name = @program_transform_name@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
sysconfdir = @sysconfdir@
target_alias = @target_alias@
SUBDIRS = windows
lib_LTLIBRARIES = libyahoo2.la
EXTRA_DIST = sample_client.c autoresponder.c
noinst_HEADERS = md5.h yahoo_debug.h yahoo_util.h sha1.h yahoo_fn.h
AM_CFLAGS = $(GLIB_CFLAGS) -g -Wall
libyahoo2_la_SOURCES = libyahoo2.c crypt.c md5.c sha1.c \
yahoo_httplib.c yahoo_util.c yahoo_list.c yahoo_fn.c
libyahoo2_la_LDFLAGS = -module -version-info $(YAHOO2_VERSION)
pkginclude_HEADERS = yahoo2.h yahoo2_callbacks.h yahoo2_types.h \
yahoo_httplib.h yahoo_list.h yahoo_fn.h
@SAMPLE_CLIENT_TRUE@yahoo_SOURCES = sample_client.c
@SAMPLE_CLIENT_TRUE@yahoo_LDADD = libyahoo2.la
@SAMPLE_CLIENT_TRUE@yahoo_LDFLAGS = -lssl
@SAMPLE_CLIENT_TRUE@autoresponder_SOURCES = autoresponder.c
@SAMPLE_CLIENT_TRUE@autoresponder_LDADD = libyahoo2.la
@SAMPLE_CLIENT_TRUE@autoresponder_LDFLAGS = -lssl
all: all-recursive
.SUFFIXES:
.SUFFIXES: .c .lo .o .obj
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ $(srcdir)/Makefile.am $(am__configure_deps)
@for dep in $?; do \
case '$(am__configure_deps)' in \
*$$dep*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
&& exit 0; \
exit 1;; \
esac; \
done; \
echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \
cd $(top_srcdir) && \
$(AUTOMAKE) --gnu src/Makefile
.PRECIOUS: Makefile
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
@case '$?' in \
*config.status*) \
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
*) \
echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
esac;
$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(top_srcdir)/configure: @MAINTAINER_MODE_TRUE@ $(am__configure_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
$(ACLOCAL_M4): @MAINTAINER_MODE_TRUE@ $(am__aclocal_m4_deps)
cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
install-libLTLIBRARIES: $(lib_LTLIBRARIES)
@$(NORMAL_INSTALL)
test -z "$(libdir)" || $(mkdir_p) "$(DESTDIR)$(libdir)"
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
if test -f $$p; then \
f=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) '$$p' '$(DESTDIR)$(libdir)/$$f'"; \
$(LIBTOOL) --mode=install $(libLTLIBRARIES_INSTALL) $(INSTALL_STRIP_FLAG) "$$p" "$(DESTDIR)$(libdir)/$$f"; \
else :; fi; \
done
uninstall-libLTLIBRARIES:
@$(NORMAL_UNINSTALL)
@set -x; list='$(lib_LTLIBRARIES)'; for p in $$list; do \
p=$(am__strip_dir) \
echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$p'"; \
$(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$p"; \
done
clean-libLTLIBRARIES:
-test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
@list='$(lib_LTLIBRARIES)'; for p in $$list; do \
dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
test "$$dir" != "$$p" || dir=.; \
echo "rm -f \"$${dir}/so_locations\""; \
rm -f "$${dir}/so_locations"; \
done
libyahoo2.la: $(libyahoo2_la_OBJECTS) $(libyahoo2_la_DEPENDENCIES)
$(LINK) -rpath $(libdir) $(libyahoo2_la_LDFLAGS) $(libyahoo2_la_OBJECTS) $(libyahoo2_la_LIBADD) $(LIBS)
clean-noinstPROGRAMS:
@list='$(noinst_PROGRAMS)'; for p in $$list; do \
f=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
echo " rm -f $$p $$f"; \
rm -f $$p $$f ; \
done
autoresponder$(EXEEXT): $(autoresponder_OBJECTS) $(autoresponder_DEPENDENCIES)
@rm -f autoresponder$(EXEEXT)
$(LINK) $(autoresponder_LDFLAGS) $(autoresponder_OBJECTS) $(autoresponder_LDADD) $(LIBS)
yahoo$(EXEEXT): $(yahoo_OBJECTS) $(yahoo_DEPENDENCIES)
@rm -f yahoo$(EXEEXT)
$(LINK) $(yahoo_LDFLAGS) $(yahoo_OBJECTS) $(yahoo_LDADD) $(LIBS)
mostlyclean-compile:
-rm -f *.$(OBJEXT)
distclean-compile:
-rm -f *.tab.c
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/autoresponder.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libyahoo2.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/md5.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sample_client.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sha1.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yahoo_fn.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yahoo_httplib.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yahoo_list.Plo@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/yahoo_util.Plo@am__quote@
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c $<
.c.obj:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(COMPILE) -c `$(CYGPATH_W) '$<'`
.c.lo:
@am__fastdepCC_TRUE@ if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
@AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
@AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCC_FALSE@ $(LTCOMPILE) -c -o $@ $<
mostlyclean-libtool:
-rm -f *.lo
clean-libtool:
-rm -rf .libs _libs
distclean-libtool:
-rm -f libtool
uninstall-info-am:
install-pkgincludeHEADERS: $(pkginclude_HEADERS)
@$(NORMAL_INSTALL)
test -z "$(pkgincludedir)" || $(mkdir_p) "$(DESTDIR)$(pkgincludedir)"
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
f=$(am__strip_dir) \
echo " $(pkgincludeHEADERS_INSTALL) '$$d$$p' '$(DESTDIR)$(pkgincludedir)/$$f'"; \
$(pkgincludeHEADERS_INSTALL) "$$d$$p" "$(DESTDIR)$(pkgincludedir)/$$f"; \
done
uninstall-pkgincludeHEADERS:
@$(NORMAL_UNINSTALL)
@list='$(pkginclude_HEADERS)'; for p in $$list; do \
f=$(am__strip_dir) \
echo " rm -f '$(DESTDIR)$(pkgincludedir)/$$f'"; \
rm -f "$(DESTDIR)$(pkgincludedir)/$$f"; \
done
# This directory's subdirectories are mostly independent; you can cd
# into them and run `make' without going through this Makefile.
# To change the values of `make' variables: instead of editing Makefiles,
# (1) if the variable is set in `config.status', edit `config.status'
# (which will cause the Makefiles to be regenerated when you run `make');
# (2) otherwise, pass the desired values on the `make' command line.
$(RECURSIVE_TARGETS):
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
target=`echo $@ | sed s/-recursive//`; \
list='$(SUBDIRS)'; for subdir in $$list; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
dot_seen=yes; \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done; \
if test "$$dot_seen" = "no"; then \
$(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
fi; test -z "$$fail"
mostlyclean-recursive clean-recursive distclean-recursive \
maintainer-clean-recursive:
@failcom='exit 1'; \
for f in x $$MAKEFLAGS; do \
case $$f in \
*=* | --[!k]*);; \
*k*) failcom='fail=yes';; \
esac; \
done; \
dot_seen=no; \
case "$@" in \
distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
*) list='$(SUBDIRS)' ;; \
esac; \
rev=''; for subdir in $$list; do \
if test "$$subdir" = "."; then :; else \
rev="$$subdir $$rev"; \
fi; \
done; \
rev="$$rev ."; \
target=`echo $@ | sed s/-recursive//`; \
for subdir in $$rev; do \
echo "Making $$target in $$subdir"; \
if test "$$subdir" = "."; then \
local_target="$$target-am"; \
else \
local_target="$$target"; \
fi; \
(cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
|| eval $$failcom; \
done && test -z "$$fail"
tags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
done
ctags-recursive:
list='$(SUBDIRS)'; for subdir in $$list; do \
test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
done
ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
mkid -fID $$unique
tags: TAGS
TAGS: tags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
include_option=--etags-include; \
empty_fix=.; \
else \
include_option=--include; \
empty_fix=; \
fi; \
list='$(SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test ! -f $$subdir/TAGS || \
tags="$$tags $$include_option=$$here/$$subdir/TAGS"; \
fi; \
done; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
test -n "$$unique" || unique=$$empty_fix; \
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
$$tags $$unique; \
fi
ctags: CTAGS
CTAGS: ctags-recursive $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \
$(TAGS_FILES) $(LISP)
tags=; \
here=`pwd`; \
list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
unique=`for i in $$list; do \
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
done | \
$(AWK) ' { files[$$0] = 1; } \
END { for (i in files) print i; }'`; \
test -z "$(CTAGS_ARGS)$$tags$$unique" \
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
$$tags $$unique
GTAGS:
here=`$(am__cd) $(top_builddir) && pwd` \
&& cd $(top_srcdir) \
&& gtags -i $(GTAGS_ARGS) $$here
distclean-tags:
-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
distdir: $(DISTFILES)
@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
list='$(DISTFILES)'; for file in $$list; do \
case $$file in \
$(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
$(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
esac; \
if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
if test "$$dir" != "$$file" && test "$$dir" != "."; then \
dir="/$$dir"; \
$(mkdir_p) "$(distdir)$$dir"; \
else \
dir=''; \
fi; \
if test -d $$d/$$file; then \
if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
fi; \
cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
else \
test -f $(distdir)/$$file \
|| cp -p $$d/$$file $(distdir)/$$file \
|| exit 1; \
fi; \
done
list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
if test "$$subdir" = .; then :; else \
test -d "$(distdir)/$$subdir" \
|| $(mkdir_p) "$(distdir)/$$subdir" \
|| exit 1; \
distdir=`$(am__cd) $(distdir) && pwd`; \
top_distdir=`$(am__cd) $(top_distdir) && pwd`; \
(cd $$subdir && \
$(MAKE) $(AM_MAKEFLAGS) \
top_distdir="$$top_distdir" \
distdir="$$distdir/$$subdir" \
distdir) \
|| exit 1; \
fi; \
done
check-am: all-am
check: check-recursive
all-am: Makefile $(LTLIBRARIES) $(PROGRAMS) $(HEADERS)
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(libdir)" "$(DESTDIR)$(pkgincludedir)"; do \
test -z "$$dir" || $(mkdir_p) "$$dir"; \
done
install: install-recursive
install-exec: install-exec-recursive
install-data: install-data-recursive
uninstall: uninstall-recursive
install-am: all-am
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
installcheck: installcheck-recursive
install-strip:
$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
`test -z '$(STRIP)' || \
echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
mostlyclean-generic:
clean-generic:
distclean-generic:
-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
maintainer-clean-generic:
@echo "This command is intended for maintainers to use"
@echo "it deletes files that may require special tools to rebuild."
clean: clean-recursive
clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
clean-noinstPROGRAMS mostlyclean-am
distclean: distclean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
distclean-am: clean-am distclean-compile distclean-generic \
distclean-libtool distclean-tags
dvi: dvi-recursive
dvi-am:
html: html-recursive
info: info-recursive
info-am:
install-data-am: install-pkgincludeHEADERS
install-exec-am: install-libLTLIBRARIES
install-info: install-info-recursive
install-man:
installcheck-am:
maintainer-clean: maintainer-clean-recursive
-rm -rf ./$(DEPDIR)
-rm -f Makefile
maintainer-clean-am: distclean-am maintainer-clean-generic
mostlyclean: mostlyclean-recursive
mostlyclean-am: mostlyclean-compile mostlyclean-generic \
mostlyclean-libtool
pdf: pdf-recursive
pdf-am:
ps: ps-recursive
ps-am:
uninstall-am: uninstall-info-am uninstall-libLTLIBRARIES \
uninstall-pkgincludeHEADERS
uninstall-info: uninstall-info-recursive
.PHONY: $(RECURSIVE_TARGETS) CTAGS GTAGS all all-am check check-am \
clean clean-generic clean-libLTLIBRARIES clean-libtool \
clean-noinstPROGRAMS clean-recursive ctags ctags-recursive \
distclean distclean-compile distclean-generic \
distclean-libtool distclean-recursive distclean-tags distdir \
dvi dvi-am html html-am info info-am install install-am \
install-data install-data-am install-exec install-exec-am \
install-info install-info-am install-libLTLIBRARIES \
install-man install-pkgincludeHEADERS install-strip \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic \
maintainer-clean-recursive mostlyclean mostlyclean-compile \
mostlyclean-generic mostlyclean-libtool mostlyclean-recursive \
pdf pdf-am ps ps-am tags tags-recursive uninstall uninstall-am \
uninstall-info-am uninstall-libLTLIBRARIES \
uninstall-pkgincludeHEADERS
# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:

File diff suppressed because it is too large Load Diff

208
libs/libyahoo2/crypt.c Normal file
View File

@ -0,0 +1,208 @@
/* One way encryption based on MD5 sum.
Copyright (C) 1996, 1997, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, write to the Free
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */
/* warmenhoven took this file and made it work with the md5.[ch] we
* already had. isn't that lovely. people should just use linux or
* freebsd, crypt works properly on those systems. i hate solaris */
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_STRING_H
# include <string.h>
#elif HAVE_STRINGS_H
# include <strings.h>
#endif
#include <stdlib.h>
#include "yahoo_util.h"
#include "md5.h"
/* Define our magic string to mark salt for MD5 "encryption"
replacement. This is meant to be the same as for other MD5 based
encryption implementations. */
static const char md5_salt_prefix[] = "$1$";
/* Table with characters for base64 transformation. */
static const char b64t[64] =
"./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
char *yahoo_crypt(char *key, char *salt)
{
char *buffer = NULL;
int buflen = 0;
int needed = 3 + strlen(salt) + 1 + 26 + 1;
md5_byte_t alt_result[16];
md5_state_t ctx;
md5_state_t alt_ctx;
size_t salt_len;
size_t key_len;
size_t cnt;
char *cp;
if (buflen < needed) {
buflen = needed;
if ((buffer = realloc(buffer, buflen)) == NULL)
return NULL;
}
/* Find beginning of salt string. The prefix should normally always
be present. Just in case it is not. */
if (strncmp(md5_salt_prefix, salt, sizeof(md5_salt_prefix) - 1) == 0)
/* Skip salt prefix. */
salt += sizeof(md5_salt_prefix) - 1;
salt_len = MIN(strcspn(salt, "$"), 8);
key_len = strlen(key);
/* Prepare for the real work. */
md5_init(&ctx);
/* Add the key string. */
md5_append(&ctx, (md5_byte_t *)key, key_len);
/* Because the SALT argument need not always have the salt prefix we
add it separately. */
md5_append(&ctx, (md5_byte_t *)md5_salt_prefix,
sizeof(md5_salt_prefix) - 1);
/* The last part is the salt string. This must be at most 8
characters and it ends at the first `$' character (for
compatibility which existing solutions). */
md5_append(&ctx, (md5_byte_t *)salt, salt_len);
/* Compute alternate MD5 sum with input KEY, SALT, and KEY. The
final result will be added to the first context. */
md5_init(&alt_ctx);
/* Add key. */
md5_append(&alt_ctx, (md5_byte_t *)key, key_len);
/* Add salt. */
md5_append(&alt_ctx, (md5_byte_t *)salt, salt_len);
/* Add key again. */
md5_append(&alt_ctx, (md5_byte_t *)key, key_len);
/* Now get result of this (16 bytes) and add it to the other
context. */
md5_finish(&alt_ctx, alt_result);
/* Add for any character in the key one byte of the alternate sum. */
for (cnt = key_len; cnt > 16; cnt -= 16)
md5_append(&ctx, alt_result, 16);
md5_append(&ctx, alt_result, cnt);
/* For the following code we need a NUL byte. */
alt_result[0] = '\0';
/* The original implementation now does something weird: for every 1
bit in the key the first 0 is added to the buffer, for every 0
bit the first character of the key. This does not seem to be
what was intended but we have to follow this to be compatible. */
for (cnt = key_len; cnt > 0; cnt >>= 1)
md5_append(&ctx,
(cnt & 1) != 0 ? alt_result : (md5_byte_t *)key, 1);
/* Create intermediate result. */
md5_finish(&ctx, alt_result);
/* Now comes another weirdness. In fear of password crackers here
comes a quite long loop which just processes the output of the
previous round again. We cannot ignore this here. */
for (cnt = 0; cnt < 1000; ++cnt) {
/* New context. */
md5_init(&ctx);
/* Add key or last result. */
if ((cnt & 1) != 0)
md5_append(&ctx, (md5_byte_t *)key, key_len);
else
md5_append(&ctx, alt_result, 16);
/* Add salt for numbers not divisible by 3. */
if (cnt % 3 != 0)
md5_append(&ctx, (md5_byte_t *)salt, salt_len);
/* Add key for numbers not divisible by 7. */
if (cnt % 7 != 0)
md5_append(&ctx, (md5_byte_t *)key, key_len);
/* Add key or last result. */
if ((cnt & 1) != 0)
md5_append(&ctx, alt_result, 16);
else
md5_append(&ctx, (md5_byte_t *)key, key_len);
/* Create intermediate result. */
md5_finish(&ctx, alt_result);
}
/* Now we can construct the result string. It consists of three
parts. */
strncpy(buffer, md5_salt_prefix, MAX(0, buflen));
cp = buffer + strlen(buffer);
buflen -= sizeof(md5_salt_prefix);
strncpy(cp, salt, MIN((size_t) buflen, salt_len));
cp = cp + strlen(cp);
buflen -= MIN((size_t) buflen, salt_len);
if (buflen > 0) {
*cp++ = '$';
--buflen;
}
#define b64_from_24bit(B2, B1, B0, N) \
do { \
unsigned int w = ((B2) << 16) | ((B1) << 8) | (B0); \
int n = (N); \
while (n-- > 0 && buflen > 0) { \
*cp++ = b64t[w & 0x3f]; \
--buflen; \
w >>= 6; \
}\
} while (0)
b64_from_24bit(alt_result[0], alt_result[6], alt_result[12], 4);
b64_from_24bit(alt_result[1], alt_result[7], alt_result[13], 4);
b64_from_24bit(alt_result[2], alt_result[8], alt_result[14], 4);
b64_from_24bit(alt_result[3], alt_result[9], alt_result[15], 4);
b64_from_24bit(alt_result[4], alt_result[10], alt_result[5], 4);
b64_from_24bit(0, 0, alt_result[11], 2);
if (buflen <= 0) {
FREE(buffer);
} else
*cp = '\0'; /* Terminate the string. */
/* Clear the buffer for the intermediate result so that people
attaching to processes or reading core dumps cannot get any
information. We do it in this way to clear correct_words[]
inside the MD5 implementation as well. */
md5_init(&ctx);
md5_finish(&ctx, alt_result);
memset(&ctx, '\0', sizeof(ctx));
memset(&alt_ctx, '\0', sizeof(alt_ctx));
return buffer;
}

5520
libs/libyahoo2/libyahoo2.c Normal file

File diff suppressed because it is too large Load Diff

405
libs/libyahoo2/md5.c Normal file
View File

@ -0,0 +1,405 @@
/*
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321.
It is derived directly from the text of the RFC and not from the
reference implementation.
The original and principal author of md5.c is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5).
1999-05-03 lpd Original version.
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include "md5.h"
#if STDC_HEADERS
# include <string.h>
#else
# if !HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
char *strchr(), *strrchr();
# if !HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#ifdef TEST
/*
* Compile with -DTEST to create a self-contained executable test program.
* The test program should print out the same values as given in section
* A.5 of RFC 1321, reproduced below.
*/
main()
{
static const char *const test[7] = {
"", /*d41d8cd98f00b204e9800998ecf8427e */
"945399884.61923487334tuvga", /*0cc175b9c0f1b6a831c399e269772661 */
"abc", /*900150983cd24fb0d6963f7d28e17f72 */
"message digest", /*f96b697d7cb7938d525a2f31aaf161d0 */
"abcdefghijklmnopqrstuvwxyz", /*c3fcd3d76192e4007dfb496cca67e13b */
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",
/*d174ab98d277d9f5a5611c2c9f419d9f */
"12345678901234567890123456789012345678901234567890123456789012345678901234567890" /*57edf4a22be3c955ac49da2e2107b67a */
};
int i;
for (i = 0; i < 7; ++i) {
md5_state_t state;
md5_byte_t digest[16];
int di;
md5_init(&state);
md5_append(&state, (const md5_byte_t *)test[i],
strlen(test[i]));
md5_finish(&state, digest);
printf("MD5 (\"%s\") = ", test[i]);
for (di = 0; di < 16; ++di)
printf("%02x", digest[di]);
printf("\n");
}
return 0;
}
#endif /* TEST */
/*
* For reference, here is the program that computed the T values.
*/
#if 0
#include <math.h>
main()
{
int i;
for (i = 1; i <= 64; ++i) {
unsigned long v =
(unsigned long)(4294967296.0 * fabs(sin((double)i)));
printf("#define T%d 0x%08lx\n", i, v);
}
return 0;
}
#endif
/*
* End of T computation program.
*/
#define T1 0xd76aa478
#define T2 0xe8c7b756
#define T3 0x242070db
#define T4 0xc1bdceee
#define T5 0xf57c0faf
#define T6 0x4787c62a
#define T7 0xa8304613
#define T8 0xfd469501
#define T9 0x698098d8
#define T10 0x8b44f7af
#define T11 0xffff5bb1
#define T12 0x895cd7be
#define T13 0x6b901122
#define T14 0xfd987193
#define T15 0xa679438e
#define T16 0x49b40821
#define T17 0xf61e2562
#define T18 0xc040b340
#define T19 0x265e5a51
#define T20 0xe9b6c7aa
#define T21 0xd62f105d
#define T22 0x02441453
#define T23 0xd8a1e681
#define T24 0xe7d3fbc8
#define T25 0x21e1cde6
#define T26 0xc33707d6
#define T27 0xf4d50d87
#define T28 0x455a14ed
#define T29 0xa9e3e905
#define T30 0xfcefa3f8
#define T31 0x676f02d9
#define T32 0x8d2a4c8a
#define T33 0xfffa3942
#define T34 0x8771f681
#define T35 0x6d9d6122
#define T36 0xfde5380c
#define T37 0xa4beea44
#define T38 0x4bdecfa9
#define T39 0xf6bb4b60
#define T40 0xbebfbc70
#define T41 0x289b7ec6
#define T42 0xeaa127fa
#define T43 0xd4ef3085
#define T44 0x04881d05
#define T45 0xd9d4d039
#define T46 0xe6db99e5
#define T47 0x1fa27cf8
#define T48 0xc4ac5665
#define T49 0xf4292244
#define T50 0x432aff97
#define T51 0xab9423a7
#define T52 0xfc93a039
#define T53 0x655b59c3
#define T54 0x8f0ccc92
#define T55 0xffeff47d
#define T56 0x85845dd1
#define T57 0x6fa87e4f
#define T58 0xfe2ce6e0
#define T59 0xa3014314
#define T60 0x4e0811a1
#define T61 0xf7537e82
#define T62 0xbd3af235
#define T63 0x2ad7d2bb
#define T64 0xeb86d391
static void md5_process(md5_state_t *pms, const md5_byte_t *data /*[64] */ )
{
md5_word_t
a = pms->abcd[0], b = pms->abcd[1],
c = pms->abcd[2], d = pms->abcd[3];
md5_word_t t;
#ifndef ARCH_IS_BIG_ENDIAN
# define ARCH_IS_BIG_ENDIAN 1 /* slower, default implementation */
#endif
#if ARCH_IS_BIG_ENDIAN
/*
* On big-endian machines, we must arrange the bytes in the right
* order. (This also works on machines of unknown byte order.)
*/
md5_word_t X[16];
const md5_byte_t *xp = data;
int i;
for (i = 0; i < 16; ++i, xp += 4)
X[i] = xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24);
#else /* !ARCH_IS_BIG_ENDIAN */
/*
* On little-endian machines, we can process properly aligned data
* without copying it.
*/
md5_word_t xbuf[16];
const md5_word_t *X;
if (!((data - (const md5_byte_t *)0) & 3)) {
/* data are properly aligned */
X = (const md5_word_t *)data;
} else {
/* not aligned */
memcpy(xbuf, data, 64);
X = xbuf;
}
#endif
#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
/* Round 1. */
/* Let [abcd k s i] denote the operation
a = b + ((a + F(b,c,d) + X[k] + T[i]) <<< s). */
#define F(x, y, z) (((x) & (y)) | (~(x) & (z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + F(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 7, T1);
SET(d, a, b, c, 1, 12, T2);
SET(c, d, a, b, 2, 17, T3);
SET(b, c, d, a, 3, 22, T4);
SET(a, b, c, d, 4, 7, T5);
SET(d, a, b, c, 5, 12, T6);
SET(c, d, a, b, 6, 17, T7);
SET(b, c, d, a, 7, 22, T8);
SET(a, b, c, d, 8, 7, T9);
SET(d, a, b, c, 9, 12, T10);
SET(c, d, a, b, 10, 17, T11);
SET(b, c, d, a, 11, 22, T12);
SET(a, b, c, d, 12, 7, T13);
SET(d, a, b, c, 13, 12, T14);
SET(c, d, a, b, 14, 17, T15);
SET(b, c, d, a, 15, 22, T16);
#undef SET
/* Round 2. */
/* Let [abcd k s i] denote the operation
a = b + ((a + G(b,c,d) + X[k] + T[i]) <<< s). */
#define G(x, y, z) (((x) & (z)) | ((y) & ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + G(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 1, 5, T17);
SET(d, a, b, c, 6, 9, T18);
SET(c, d, a, b, 11, 14, T19);
SET(b, c, d, a, 0, 20, T20);
SET(a, b, c, d, 5, 5, T21);
SET(d, a, b, c, 10, 9, T22);
SET(c, d, a, b, 15, 14, T23);
SET(b, c, d, a, 4, 20, T24);
SET(a, b, c, d, 9, 5, T25);
SET(d, a, b, c, 14, 9, T26);
SET(c, d, a, b, 3, 14, T27);
SET(b, c, d, a, 8, 20, T28);
SET(a, b, c, d, 13, 5, T29);
SET(d, a, b, c, 2, 9, T30);
SET(c, d, a, b, 7, 14, T31);
SET(b, c, d, a, 12, 20, T32);
#undef SET
/* Round 3. */
/* Let [abcd k s t] denote the operation
a = b + ((a + H(b,c,d) + X[k] + T[i]) <<< s). */
#define H(x, y, z) ((x) ^ (y) ^ (z))
#define SET(a, b, c, d, k, s, Ti)\
t = a + H(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 5, 4, T33);
SET(d, a, b, c, 8, 11, T34);
SET(c, d, a, b, 11, 16, T35);
SET(b, c, d, a, 14, 23, T36);
SET(a, b, c, d, 1, 4, T37);
SET(d, a, b, c, 4, 11, T38);
SET(c, d, a, b, 7, 16, T39);
SET(b, c, d, a, 10, 23, T40);
SET(a, b, c, d, 13, 4, T41);
SET(d, a, b, c, 0, 11, T42);
SET(c, d, a, b, 3, 16, T43);
SET(b, c, d, a, 6, 23, T44);
SET(a, b, c, d, 9, 4, T45);
SET(d, a, b, c, 12, 11, T46);
SET(c, d, a, b, 15, 16, T47);
SET(b, c, d, a, 2, 23, T48);
#undef SET
/* Round 4. */
/* Let [abcd k s t] denote the operation
a = b + ((a + I(b,c,d) + X[k] + T[i]) <<< s). */
#define I(x, y, z) ((y) ^ ((x) | ~(z)))
#define SET(a, b, c, d, k, s, Ti)\
t = a + I(b,c,d) + X[k] + Ti;\
a = ROTATE_LEFT(t, s) + b
/* Do the following 16 operations. */
SET(a, b, c, d, 0, 6, T49);
SET(d, a, b, c, 7, 10, T50);
SET(c, d, a, b, 14, 15, T51);
SET(b, c, d, a, 5, 21, T52);
SET(a, b, c, d, 12, 6, T53);
SET(d, a, b, c, 3, 10, T54);
SET(c, d, a, b, 10, 15, T55);
SET(b, c, d, a, 1, 21, T56);
SET(a, b, c, d, 8, 6, T57);
SET(d, a, b, c, 15, 10, T58);
SET(c, d, a, b, 6, 15, T59);
SET(b, c, d, a, 13, 21, T60);
SET(a, b, c, d, 4, 6, T61);
SET(d, a, b, c, 11, 10, T62);
SET(c, d, a, b, 2, 15, T63);
SET(b, c, d, a, 9, 21, T64);
#undef SET
/* Then perform the following additions. (That is increment each
of the four registers by the value it had before this block
was started.) */
pms->abcd[0] += a;
pms->abcd[1] += b;
pms->abcd[2] += c;
pms->abcd[3] += d;
}
void md5_init(md5_state_t *pms)
{
pms->count[0] = pms->count[1] = 0;
pms->abcd[0] = 0x67452301;
pms->abcd[1] = 0xefcdab89;
pms->abcd[2] = 0x98badcfe;
pms->abcd[3] = 0x10325476;
}
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes)
{
const md5_byte_t *p = data;
int left = nbytes;
int offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t) (nbytes << 3);
if (nbytes <= 0)
return;
/* Update the message length. */
pms->count[1] += nbytes >> 29;
pms->count[0] += nbits;
if (pms->count[0] < nbits)
pms->count[1]++;
/* Process an initial partial block. */
if (offset) {
int copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
if (offset + copy < 64)
return;
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
for (; left >= 64; p += 64, left -= 64)
md5_process(pms, p);
/* Process a final partial block. */
if (left)
memcpy(pms->buf, p, left);
}
void md5_finish(md5_state_t *pms, md5_byte_t digest[16])
{
static const md5_byte_t pad[64] = {
0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
md5_byte_t data[8];
int i;
/* Save the length before padding. */
for (i = 0; i < 8; ++i)
data[i] = (md5_byte_t) (pms->count[i >> 2] >> ((i & 3) << 3));
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
for (i = 0; i < 16; ++i)
digest[i] = (md5_byte_t) (pms->abcd[i >> 2] >> ((i & 3) << 3));
}

92
libs/libyahoo2/md5.h Normal file
View File

@ -0,0 +1,92 @@
/*
Copyright (C) 1999 Aladdin Enterprises. All rights reserved.
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
L. Peter Deutsch
ghost@aladdin.com
*/
/*
Independent implementation of MD5 (RFC 1321).
This code implements the MD5 Algorithm defined in RFC 1321.
It is derived directly from the text of the RFC and not from the
reference implementation.
The original and principal author of md5.h is L. Peter Deutsch
<ghost@aladdin.com>. Other authors are noted in the change history
that follows (in reverse chronological order):
1999-11-04 lpd Edited comments slightly for automatic TOC extraction.
1999-10-18 lpd Fixed typo in header comment (ansi2knr rather than md5);
added conditionalization for C++ compilation from Martin
Purschke <purschke@bnl.gov>.
1999-05-03 lpd Original version.
*/
#ifndef md5_INCLUDED
# define md5_INCLUDED
/*
* This code has some adaptations for the Ghostscript environment, but it
* will compile and run correctly in any environment with 8-bit chars and
* 32-bit ints. Specifically, it assumes that if the following are
* defined, they have the same meaning as in Ghostscript: P1, P2, P3,
* ARCH_IS_BIG_ENDIAN.
*/
typedef unsigned char md5_byte_t; /* 8-bit byte */
typedef unsigned int md5_word_t; /* 32-bit word */
/* Define the state of the MD5 Algorithm. */
typedef struct md5_state_s {
md5_word_t count[2]; /* message length in bits, lsw first */
md5_word_t abcd[4]; /* digest buffer */
md5_byte_t buf[64]; /* accumulate block */
} md5_state_t;
#ifdef __cplusplus
extern "C" {
#endif
/* Initialize the algorithm. */
#ifdef P1
void md5_init(P1(md5_state_t *pms));
#else
void md5_init(md5_state_t *pms);
#endif
/* Append a string to the message. */
#ifdef P3
void md5_append(P3(md5_state_t *pms, const md5_byte_t *data,
int nbytes));
#else
void md5_append(md5_state_t *pms, const md5_byte_t *data, int nbytes);
#endif
/* Finish the message and return the digest. */
#ifdef P2
void md5_finish(P2(md5_state_t *pms, md5_byte_t digest[16]));
#else
void md5_finish(md5_state_t *pms, md5_byte_t digest[16]);
#endif
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* md5_INCLUDED */

File diff suppressed because it is too large Load Diff

613
libs/libyahoo2/sha1.c Normal file
View File

@ -0,0 +1,613 @@
/*-
* Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* Define WORDS_BIGENDIAN if compiling on a big-endian architecture.
*
* Define SHA1_TEST to test the implementation using the NIST's
* sample messages. The output should be:
*
* a9993e36 4706816a ba3e2571 7850c26c 9cd0d89d
* 84983e44 1c3bd26e baae4aa1 f95129e5 e54670f1
* 34aa973c d4c4daa4 f61eeb2b dbad2731 6534016f
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif /* HAVE_CONFIG_H */
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#include <string.h>
#include "sha1.h"
#define ROTL(x, n) (((x) << (n)) | ((x) >> (32 - (n))))
#define ROTR(x, n) (((x) >> (n)) | ((x) << (32 - (n))))
#define F_0_19(x, y, z) ((z) ^ ((x) & ((y) ^ (z))))
#define F_20_39(x, y, z) ((x) ^ (y) ^ (z))
#define F_40_59(x, y, z) (((x) & ((y) | (z))) | ((y) & (z)))
#define F_60_79(x, y, z) ((x) ^ (y) ^ (z))
#define DO_ROUND(F, K) { \
temp = ROTL(a, 5) + F(b, c, d) + e + *(W++) + K; \
e = d; \
d = c; \
c = ROTL(b, 30); \
b = a; \
a = temp; \
}
#define K_0_19 0x5a827999L
#define K_20_39 0x6ed9eba1L
#define K_40_59 0x8f1bbcdcL
#define K_60_79 0xca62c1d6L
#ifndef RUNTIME_ENDIAN
#ifdef WORDS_BIGENDIAN
#define BYTESWAP(x) (x)
#define BYTESWAP64(x) (x)
#else /* WORDS_BIGENDIAN */
#define BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | (ROTL((x), 8) & 0x00ff00ffL))
static uint64_t _byteswap64(uint64_t x)
{
uint32_t a = x >> 32;
uint32_t b = (uint32_t) x;
return ((uint64_t) BYTESWAP(b) << 32) | (uint64_t) BYTESWAP(a);
}
#define BYTESWAP64(x) _byteswap64(x)
#endif /* WORDS_BIGENDIAN */
#else /* !RUNTIME_ENDIAN */
#define BYTESWAP(x) _byteswap(sc->littleEndian, x)
#define BYTESWAP64(x) _byteswap64(sc->littleEndian, x)
#define _BYTESWAP(x) ((ROTR((x), 8) & 0xff00ff00L) | \
(ROTL((x), 8) & 0x00ff00ffL))
#define _BYTESWAP64(x) __byteswap64(x)
static uint64_t __byteswap64(uint64_t x)
{
uint32_t a = x >> 32;
uint32_t b = (uint32_t) x;
return ((uint64_t) _BYTESWAP(b) << 32) | (uint64_t) _BYTESWAP(a);
}
static uint32_t _byteswap(int littleEndian, uint32_t x)
{
if (!littleEndian)
return x;
else
return _BYTESWAP(x);
}
static uint64_t _byteswap64(int littleEndian, uint64_t x)
{
if (!littleEndian)
return x;
else
return _BYTESWAP64(x);
}
static void setEndian(int *littleEndianp)
{
union {
uint32_t w;
uint8_t b[4];
} endian;
endian.w = 1L;
*littleEndianp = endian.b[0] != 0;
}
#endif /* !RUNTIME_ENDIAN */
static const uint8_t padding[64] = {
0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
void SHA1Init(SHA1Context *sc)
{
#ifdef RUNTIME_ENDIAN
setEndian(&sc->littleEndian);
#endif /* RUNTIME_ENDIAN */
sc->totalLength = 0LL;
sc->hash[0] = 0x67452301L;
sc->hash[1] = 0xefcdab89L;
sc->hash[2] = 0x98badcfeL;
sc->hash[3] = 0x10325476L;
sc->hash[4] = 0xc3d2e1f0L;
sc->bufferLength = 0L;
}
static void burnStack(int size)
{
char buf[128];
memset(buf, 0, sizeof(buf));
size -= sizeof(buf);
if (size > 0)
burnStack(size);
}
static void SHA1Guts(SHA1Context *sc, const uint32_t *cbuf)
{
uint32_t buf[80];
uint32_t *W, *W3, *W8, *W14, *W16;
uint32_t a, b, c, d, e, temp;
int i;
W = buf;
for (i = 15; i >= 0; i--) {
*(W++) = BYTESWAP(*cbuf);
cbuf++;
}
W16 = &buf[0];
W14 = &buf[2];
W8 = &buf[8];
W3 = &buf[13];
for (i = 63; i >= 0; i--) {
*W = *(W3++) ^ *(W8++) ^ *(W14++) ^ *(W16++);
*W = ROTL(*W, 1);
W++;
}
a = sc->hash[0];
b = sc->hash[1];
c = sc->hash[2];
d = sc->hash[3];
e = sc->hash[4];
W = buf;
#ifndef SHA1_UNROLL
#define SHA1_UNROLL 20
#endif /* !SHA1_UNROLL */
#if SHA1_UNROLL == 1
for (i = 19; i >= 0; i--)
DO_ROUND(F_0_19, K_0_19);
for (i = 19; i >= 0; i--)
DO_ROUND(F_20_39, K_20_39);
for (i = 19; i >= 0; i--)
DO_ROUND(F_40_59, K_40_59);
for (i = 19; i >= 0; i--)
DO_ROUND(F_60_79, K_60_79);
#elif SHA1_UNROLL == 2
for (i = 9; i >= 0; i--) {
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
}
for (i = 9; i >= 0; i--) {
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
}
for (i = 9; i >= 0; i--) {
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
}
for (i = 9; i >= 0; i--) {
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
}
#elif SHA1_UNROLL == 4
for (i = 4; i >= 0; i--) {
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
}
for (i = 4; i >= 0; i--) {
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
}
for (i = 4; i >= 0; i--) {
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
}
for (i = 4; i >= 0; i--) {
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
}
#elif SHA1_UNROLL == 5
for (i = 3; i >= 0; i--) {
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
}
for (i = 3; i >= 0; i--) {
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
}
for (i = 3; i >= 0; i--) {
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
}
for (i = 3; i >= 0; i--) {
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
}
#elif SHA1_UNROLL == 10
for (i = 1; i >= 0; i--) {
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
}
for (i = 1; i >= 0; i--) {
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
}
for (i = 1; i >= 0; i--) {
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
}
for (i = 1; i >= 0; i--) {
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
}
#elif SHA1_UNROLL == 20
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_0_19, K_0_19);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_20_39, K_20_39);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_40_59, K_40_59);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
DO_ROUND(F_60_79, K_60_79);
#else /* SHA1_UNROLL */
#error SHA1_UNROLL must be 1, 2, 4, 5, 10 or 20!
#endif
sc->hash[0] += a;
sc->hash[1] += b;
sc->hash[2] += c;
sc->hash[3] += d;
sc->hash[4] += e;
}
void SHA1Update(SHA1Context *sc, const void *vdata, uint32_t len)
{
const uint8_t *data = vdata;
uint32_t bufferBytesLeft;
uint32_t bytesToCopy;
int needBurn = 0;
#ifdef SHA1_FAST_COPY
if (sc->bufferLength) {
bufferBytesLeft = 64L - sc->bufferLength;
bytesToCopy = bufferBytesLeft;
if (bytesToCopy > len)
bytesToCopy = len;
memcpy(&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy);
sc->totalLength += bytesToCopy * 8L;
sc->bufferLength += bytesToCopy;
data += bytesToCopy;
len -= bytesToCopy;
if (sc->bufferLength == 64L) {
SHA1Guts(sc, sc->buffer.words);
needBurn = 1;
sc->bufferLength = 0L;
}
}
while (len > 63) {
sc->totalLength += 512L;
SHA1Guts(sc, data);
needBurn = 1;
data += 64L;
len -= 64L;
}
if (len) {
memcpy(&sc->buffer.bytes[sc->bufferLength], data, len);
sc->totalLength += len * 8L;
sc->bufferLength += len;
}
#else /* SHA1_FAST_COPY */
while (len) {
bufferBytesLeft = 64L - sc->bufferLength;
bytesToCopy = bufferBytesLeft;
if (bytesToCopy > len)
bytesToCopy = len;
memcpy(&sc->buffer.bytes[sc->bufferLength], data, bytesToCopy);
sc->totalLength += bytesToCopy * 8L;
sc->bufferLength += bytesToCopy;
data += bytesToCopy;
len -= bytesToCopy;
if (sc->bufferLength == 64L) {
SHA1Guts(sc, sc->buffer.words);
needBurn = 1;
sc->bufferLength = 0L;
}
}
#endif /* SHA1_FAST_COPY */
if (needBurn)
burnStack(sizeof(uint32_t[86]) + sizeof(uint32_t *[5]) +
sizeof(int));
}
void SHA1Final(SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE])
{
uint32_t bytesToPad;
uint64_t lengthPad;
int i;
bytesToPad = 120L - sc->bufferLength;
if (bytesToPad > 64L)
bytesToPad -= 64L;
lengthPad = BYTESWAP64(sc->totalLength);
SHA1Update(sc, padding, bytesToPad);
SHA1Update(sc, &lengthPad, 8L);
if (hash) {
for (i = 0; i < SHA1_HASH_WORDS; i++) {
#ifdef SHA1_FAST_COPY
*((uint32_t *)hash) = BYTESWAP(sc->hash[i]);
#else /* SHA1_FAST_COPY */
hash[0] = (uint8_t) (sc->hash[i] >> 24);
hash[1] = (uint8_t) (sc->hash[i] >> 16);
hash[2] = (uint8_t) (sc->hash[i] >> 8);
hash[3] = (uint8_t) sc->hash[i];
#endif /* SHA1_FAST_COPY */
hash += 4;
}
}
}
#ifdef SHA1_TEST
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
SHA1Context foo;
uint8_t hash[SHA1_HASH_SIZE];
char buf[1000];
int i;
SHA1Init(&foo);
SHA1Update(&foo, "abc", 3);
SHA1Final(&foo, hash);
for (i = 0; i < SHA1_HASH_SIZE;) {
printf("%02x", hash[i++]);
if (!(i % 4))
printf(" ");
}
printf("\n");
SHA1Init(&foo);
SHA1Update(&foo,
"abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq", 56);
SHA1Final(&foo, hash);
for (i = 0; i < SHA1_HASH_SIZE;) {
printf("%02x", hash[i++]);
if (!(i % 4))
printf(" ");
}
printf("\n");
SHA1Init(&foo);
memset(buf, 'a', sizeof(buf));
for (i = 0; i < 1000; i++)
SHA1Update(&foo, buf, sizeof(buf));
SHA1Final(&foo, hash);
for (i = 0; i < SHA1_HASH_SIZE;) {
printf("%02x", hash[i++]);
if (!(i % 4))
printf(" ");
}
printf("\n");
exit(0);
}
#endif /* SHA1_TEST */

71
libs/libyahoo2/sha1.h Normal file
View File

@ -0,0 +1,71 @@
/*-
* Copyright (c) 2001-2003 Allan Saddi <allan@saddi.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY ALLAN SADDI AND HIS CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL ALLAN SADDI OR HIS CONTRIBUTORS BE
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _SHA1_H
#define _SHA1_H
#define HAVE_INTTYPES_H 1
#if HAVE_INTTYPES_H
# include <inttypes.h>
#else
# if HAVE_STDINT_H
# include <stdint.h>
# endif
#endif
#define SHA1_HASH_SIZE 20
/* Hash size in 32-bit words */
#define SHA1_HASH_WORDS 5
struct _SHA1Context {
uint64_t totalLength;
uint32_t hash[SHA1_HASH_WORDS];
uint32_t bufferLength;
union {
uint32_t words[16];
uint8_t bytes[64];
} buffer;
#ifdef RUNTIME_ENDIAN
int littleEndian;
#endif /* RUNTIME_ENDIAN */
};
typedef struct _SHA1Context SHA1Context;
#ifdef __cplusplus
extern "C" {
#endif
void SHA1Init(SHA1Context *sc);
void SHA1Update(SHA1Context *sc, const void *data, uint32_t len);
void SHA1Final(SHA1Context *sc, uint8_t hash[SHA1_HASH_SIZE]);
#ifdef __cplusplus
}
#endif
#endif /* _SHA1_H */

225
libs/libyahoo2/yahoo2.h Normal file
View File

@ -0,0 +1,225 @@
/*
* libyahoo2: yahoo2.h
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef YAHOO2_H
#define YAHOO2_H
#ifdef __cplusplus
extern "C" {
#endif
#include "yahoo2_types.h"
/* returns the socket descriptor object for a given pager connection. shouldn't be needed */
void *yahoo_get_fd(int id);
/* says how much logging to do */
/* see yahoo2_types.h for the different values */
int yahoo_set_log_level(enum yahoo_log_level level);
enum yahoo_log_level yahoo_get_log_level(void);
/* these functions should be self explanatory */
/* who always means the buddy you're acting on */
/* id is the successful value returned by yahoo_init */
/* init returns a connection id used to identify the connection hereon */
/* or 0 on failure */
/* you must call init before calling any other function */
/*
* The optional parameters to init are key/value pairs that specify
* server settings to use. This list must be NULL terminated - even
* if the list is empty. If a parameter isn't set, a default value
* will be used. Parameter keys are strings, parameter values are
* either strings or ints, depending on the key. Values passed in
* are copied, so you can use const/auto/static/pointers/whatever
* you want. Parameters are:
* NAME TYPE DEFAULT
* pager_host char * scs.msg.yahoo.com
* pager_port int 5050
* filetransfer_host char * filetransfer.msg.yahoo.com
* filetransfer_port int 80
* webcam_host char * webcam.yahoo.com
* webcam_port int 5100
* webcam_description char * ""
* local_host char * ""
* conn_type int Y_WCM_DSL
*
* You should set at least local_host if you intend to use webcams
*/
int yahoo_init_with_attributes(const char *username,
const char *password, ...);
/* yahoo_init does the same as yahoo_init_with_attributes, assuming defaults
* for all attributes */
int yahoo_init(const char *username, const char *password);
/* release all resources held by this session */
/* you need to call yahoo_close for a session only if
* yahoo_logoff is never called for it (ie, it was never logged in) */
void yahoo_close(int id);
/* login logs in to the server */
/* initial is of type enum yahoo_status. see yahoo2_types.h */
void yahoo_login(int id, int initial);
void yahoo_logoff(int id);
/* reloads status of all buddies */
void yahoo_refresh(int id);
/* activates/deactivates an identity */
void yahoo_set_identity_status(int id, const char *identity,
int active);
/* regets the entire buddy list from the server */
void yahoo_get_list(int id);
/* download buddy contact information from your yahoo addressbook */
void yahoo_get_yab(int id);
/* add/modify an address book entry. if yab->dbid is set, it will */
/* modify that entry else it creates a new entry */
void yahoo_set_yab(int id, struct yab *yab);
void yahoo_keepalive(int id);
void yahoo_chat_keepalive(int id);
/* from is the identity you're sending from. if NULL, the default is used */
/* utf8 is whether msg is a utf8 string or not. */
void yahoo_send_im(int id, const char *from, const char *who,
const char *msg, int utf8, int picture);
void yahoo_send_buzz(int id, const char *from, const char *who);
/* if type is true, send typing notice, else send stopped typing notice */
void yahoo_send_typing(int id, const char *from, const char *who,
int typ);
/* used to set away/back status. */
/* away says whether the custom message is an away message or a sig */
void yahoo_set_away(int id, enum yahoo_status state, const char *msg,
int away);
void yahoo_add_buddy(int id, const char *who, const char *group,
const char *msg);
void yahoo_remove_buddy(int id, const char *who, const char *group);
void yahoo_confirm_buddy(int id, const char *who, int reject,
const char *msg);
void yahoo_stealth_buddy(int id, const char *who, int unstealth);
/* if unignore is true, unignore, else ignore */
void yahoo_ignore_buddy(int id, const char *who, int unignore);
void yahoo_change_buddy_group(int id, const char *who,
const char *old_group, const char *new_group);
void yahoo_group_rename(int id, const char *old_group,
const char *new_group);
void yahoo_conference_invite(int id, const char *from, YList *who,
const char *room, const char *msg);
void yahoo_conference_addinvite(int id, const char *from,
const char *who, const char *room, const YList *members,
const char *msg);
void yahoo_conference_decline(int id, const char *from, YList *who,
const char *room, const char *msg);
void yahoo_conference_message(int id, const char *from, YList *who,
const char *room, const char *msg, int utf8);
void yahoo_conference_logon(int id, const char *from, YList *who,
const char *room);
void yahoo_conference_logoff(int id, const char *from, YList *who,
const char *room);
/* Get a list of chatrooms */
void yahoo_get_chatrooms(int id, int chatroomid);
/* join room with specified roomname and roomid */
void yahoo_chat_logon(int id, const char *from, const char *room,
const char *roomid);
/* Send message "msg" to room with specified roomname, msgtype is 1-normal message or 2-/me mesage */
void yahoo_chat_message(int id, const char *from, const char *room,
const char *msg, const int msgtype, const int utf8);
/* Log off chat */
void yahoo_chat_logoff(int id, const char *from);
/* requests a webcam feed */
/* who is the person who's webcam you would like to view */
/* if who is null, then you're the broadcaster */
void yahoo_webcam_get_feed(int id, const char *who);
void yahoo_webcam_close_feed(int id, const char *who);
/* sends an image when uploading */
/* image points to a JPEG-2000 image, length is the length of the image */
/* in bytes. The timestamp is the time in milliseconds since we started the */
/* webcam. */
void yahoo_webcam_send_image(int id, unsigned char *image,
unsigned int length, unsigned int timestamp);
/* this function should be called if we want to allow a user to watch the */
/* webcam. Who is the user we want to accept. */
/* Accept user (accept = 1), decline user (accept = 0) */
void yahoo_webcam_accept_viewer(int id, const char *who, int accept);
/* send an invitation to a user to view your webcam */
void yahoo_webcam_invite(int id, const char *who);
/* will set up a connection and initiate file transfer.
* callback will be called with the fd that you should write
* the file data to
*/
void yahoo_send_file(int id, const char *who, const char *msg,
const char *name, unsigned long size,
yahoo_get_fd_callback callback, void *data);
/*
* Respond to a file transfer request. Be sure to provide the callback data
* since that is your only chance to recognize future callbacks
*/
void yahoo_send_file_transfer_response(int client_id, int response,
char *id, void *data);
/* send a search request
*/
void yahoo_search(int id, enum yahoo_search_type t, const char *text,
enum yahoo_search_gender g, enum yahoo_search_agerange ar,
int photo, int yahoo_only);
/* continue last search
* should be called if only (start+found >= total)
*
* where the above three are passed to ext_yahoo_got_search_result
*/
void yahoo_search_again(int id, int start);
/* these should be called when input is available on a fd */
/* registered by ext_yahoo_add_handler */
/* if these return negative values, errno may be set */
int yahoo_read_ready(int id, void *fd, void *data);
int yahoo_write_ready(int id, void *fd, void *data);
/* utility functions. these do not hit the server */
enum yahoo_status yahoo_current_status(int id);
const YList *yahoo_get_buddylist(int id);
const YList *yahoo_get_ignorelist(int id);
const YList *yahoo_get_identities(int id);
/* 'which' could be y, t, c or login. This may change in later versions. */
const char *yahoo_get_cookie(int id, const char *which);
/* returns the url used to get user profiles - you must append the user id */
/* as of now this is http://profiles.yahoo.com/ */
/* You'll have to do urlencoding yourself, but see yahoo_httplib.h first */
const char *yahoo_get_profile_url(void);
void yahoo_buddyicon_request(int id, const char *who);
#include "yahoo_httplib.h"
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,776 @@
/*
* libyahoo2: yahoo2_callbacks.h
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* The functions in this file *must* be defined in your client program
* If you want to use a callback structure instead of direct functions,
* then you must define USE_STRUCT_CALLBACKS in all files that #include
* this one.
*
* Register the callback structure by calling yahoo_register_callbacks -
* declared in this file and defined in libyahoo2.c
*/
#ifndef YAHOO2_CALLBACKS_H
#define YAHOO2_CALLBACKS_H
#ifdef __cplusplus
extern "C" {
#endif
#include "yahoo2_types.h"
/*
* yahoo2_callbacks.h
*
* Callback interface for libyahoo2
*/
typedef enum {
YAHOO_INPUT_READ = 1 << 0,
YAHOO_INPUT_WRITE = 1 << 1,
YAHOO_INPUT_EXCEPTION = 1 << 2
} yahoo_input_condition;
/*
* A callback function called when an asynchronous connect completes.
*
* Params:
* fd - The file descriptor object that has been connected, or NULL on
* error
* error - The value of errno set by the call to connect or 0 if no error
* Set both fd and error to 0 if the connect was cancelled by the
* user
* callback_data - the callback_data passed to the ext_yahoo_connect_async
* function
*/
typedef void (*yahoo_connect_callback) (void *fd, int error,
void *callback_data);
/*
* The following functions need to be implemented in the client
* interface. They will be called by the library when each
* event occurs.
*/
/*
* should we use a callback structure or directly call functions
* if you want the structure, you *must* define USE_STRUCT_CALLBACKS
* both when you compile the library, and when you compile your code
* that uses the library
*/
#define YAHOO_CALLBACK_TYPE(x) (*x)
struct yahoo_callbacks {
/*
* Name: ext_yahoo_login_response
* Called when the login process is complete
* Params:
* id - the id that identifies the server connection
* succ - enum yahoo_login_status
* url - url to reactivate account if locked
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_login_response) (int id, int succ,
const char *url);
/*
* Name: ext_yahoo_got_buddies
* Called when the contact list is got from the server
* Params:
* id - the id that identifies the server connection
* buds - the buddy list
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddies) (int id, YList *buds);
/*
* Name: ext_yahoo_got_ignore
* Called when the ignore list is got from the server
* Params:
* id - the id that identifies the server connection
* igns - the ignore list
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ignore) (int id, YList *igns);
/*
* Name: ext_yahoo_got_identities
* Called when the contact list is got from the server
* Params:
* id - the id that identifies the server connection
* ids - the identity list
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_identities) (int id, YList *ids);
/*
* Name: ext_yahoo_got_cookies
* Called when the cookie list is got from the server
* Params:
* id - the id that identifies the server connection
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_cookies) (int id);
/*
* Name: ext_yahoo_got_ping
* Called when the ping packet is received from the server
* Params:
* id - the id that identifies the server connection
* errormsg - optional error message
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ping) (int id,
const char *errormsg);
/*
* Name: ext_yahoo_status_changed
* Called when remote user's status changes.
* Params:
* id - the id that identifies the server connection
* who - the handle of the remote user
* stat - status code (enum yahoo_status)
* msg - the message if stat == YAHOO_STATUS_CUSTOM
* away - whether the contact is away or not (YAHOO_STATUS_CUSTOM)
* idle - this is the number of seconds he is idle [if he is idle]
* mobile - this is set for mobile users/buddies
* TODO: add support for pager, chat, and game states
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_status_changed) (int id,
const char *who, int stat, const char *msg, int away, int idle,
int mobile);
/*
* Name: ext_yahoo_got_buzz
* Called when remote user sends you a buzz.
* Params:
* id - the id that identifies the server connection
* me - the identity the message was sent to
* who - the handle of the remote user
* tm - timestamp of message if offline
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buzz) (int id, const char *me,
const char *who, long tm);
/*
* Name: ext_yahoo_got_im
* Called when remote user sends you a message.
* Params:
* id - the id that identifies the server connection
* me - the identity the message was sent to
* who - the handle of the remote user
* msg - the message - NULL if stat == 2
* tm - timestamp of message if offline
* stat - message status - 0
* 1
* 2 == error sending message
* 5
* utf8 - whether the message is encoded as utf8 or not
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_im) (int id, const char *me,
const char *who, const char *msg, long tm, int stat, int utf8);
/*
* Name: ext_yahoo_got_conf_invite
* Called when remote user sends you a conference invitation.
* Params:
* id - the id that identifies the server connection
* me - the identity the invitation was sent to
* who - the user inviting you
* room - the room to join
* msg - the message
* members - the initial members of the conference (null terminated list)
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_conf_invite) (int id,
const char *me, const char *who, const char *room,
const char *msg, YList *members);
/*
* Name: ext_yahoo_conf_userdecline
* Called when someone declines to join the conference.
* Params:
* id - the id that identifies the server connection
* me - the identity in the conference
* who - the user who has declined
* room - the room
* msg - the declining message
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userdecline) (int id,
const char *me, const char *who, const char *room,
const char *msg);
/*
* Name: ext_yahoo_conf_userjoin
* Called when someone joins the conference.
* Params:
* id - the id that identifies the server connection
* me - the identity in the conference
* who - the user who has joined
* room - the room joined
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userjoin) (int id,
const char *me, const char *who, const char *room);
/*
* Name: ext_yahoo_conf_userleave
* Called when someone leaves the conference.
* Params:
* id - the id that identifies the server connection
* me - the identity in the conference
* who - the user who has left
* room - the room left
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_userleave) (int id,
const char *me, const char *who, const char *room);
/*
* Name: ext_yahoo_chat_cat_xml
* Called when ?
* Params:
* id - the id that identifies the server connection
* xml - ?
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_cat_xml) (int id,
const char *xml);
/*
* Name: ext_yahoo_chat_join
* Called when joining the chatroom.
* Params:
* id - the id that identifies the server connection
* me - the identity in the chatroom
* room - the room joined, used in all other chat calls, freed by
* library after call
* topic - the topic of the room, freed by library after call
* members - the initial members of the chatroom (null terminated YList
* of yahoo_chat_member's) Must be freed by the client
* fd - the object where the connection is coming from (for tracking)
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_join) (int id, const char *me,
const char *room, const char *topic, YList *members, void *fd);
/*
* Name: ext_yahoo_chat_userjoin
* Called when someone joins the chatroom.
* Params:
* id - the id that identifies the server connection
* me - the identity in the chatroom
* room - the room joined
* who - the user who has joined, Must be freed by the client
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userjoin) (int id,
const char *me, const char *room,
struct yahoo_chat_member *who);
/*
* Name: ext_yahoo_chat_userleave
* Called when someone leaves the chatroom.
* Params:
* id - the id that identifies the server connection
* me - the identity in the chatroom
* room - the room left
* who - the user who has left (Just the User ID)
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_userleave) (int id,
const char *me, const char *room, const char *who);
/*
* Name: ext_yahoo_chat_message
* Called when someone messages in the chatroom.
* Params:
* id - the id that identifies the server connection
* me - the identity in the chatroom
* room - the room
* who - the user who messaged (Just the user id)
* msg - the message
* msgtype - 1 = Normal message
* 2 = /me type message
* utf8 - whether the message is utf8 encoded or not
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_message) (int id,
const char *me, const char *who, const char *room,
const char *msg, int msgtype, int utf8);
/*
*
* Name: ext_yahoo_chat_yahoologout
* called when yahoo disconnects your chat session
* Note this is called whenver a disconnect happens, client or server
* requested. Care should be taken to make sure you know the origin
* of the disconnect request before doing anything here (auto-join's etc)
* Params:
* id - the id that identifies this connection
* me - the identity in the chatroom
* Returns:
* nothing.
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahoologout) (int id,
const char *me);
/*
*
* Name: ext_yahoo_chat_yahooerror
* called when yahoo sends back an error to you
* Note this is called whenver chat message is sent into a room
* in error (fd not connected, room doesn't exists etc)
* Care should be taken to make sure you know the origin
* of the error before doing anything about it.
* Params:
* id - the id that identifies this connection
* me - the identity in the chatroom
* Returns:
* nothing.
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_chat_yahooerror) (int id,
const char *me);
/*
* Name: ext_yahoo_conf_message
* Called when someone messages in the conference.
* Params:
* id - the id that identifies the server connection
* me - the identity the conf message was sent to
* who - the user who messaged
* room - the room
* msg - the message
* utf8 - whether the message is utf8 encoded or not
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_conf_message) (int id,
const char *me, const char *who, const char *room,
const char *msg, int utf8);
/*
* Name: ext_yahoo_got_file
* Called when someone sends you a file
* Params:
* id - the id that identifies the server connection
* me - the identity the file was sent to
* who - the user who sent the file
* msg - the message
* fname- the file name if direct transfer
* fsize- the file size if direct transfer
* trid - transfer id. Unique for this transfer
*
* NOTE: Subsequent callbacks for file transfer do not send all of this
* information again since it is wasteful. Implementations are expected to
* save this information and supply it as callback data when the file or
* confirmation is sent
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_file) (int id, const char *me,
const char *who, const char *msg, const char *fname,
unsigned long fesize, char *trid);
/*
* Name: ext_yahoo_got_ft_data
* Called multiple times when parts of the file are received
* Params:
* id - the id that identifies the server connection
* in - The data
* len - Length of the data
* data - callback data
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_ft_data) (int id,
const unsigned char *in, int len, void *data);
/*
* Name: ext_yahoo_file_transfer_done
* File transfer is done
* Params:
* id - the id that identifies the server connection
* result - To notify if it finished successfully or with a failure
* data - callback data
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_file_transfer_done) (int id,
int result, void *data);
/*
* Name: ext_yahoo_contact_added
* Called when a contact is added to your list
* Params:
* id - the id that identifies the server connection
* myid - the identity he was added to
* who - who was added
* msg - any message sent
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_contact_added) (int id,
const char *myid, const char *who, const char *msg);
/*
* Name: ext_yahoo_rejected
* Called when a contact rejects your add
* Params:
* id - the id that identifies the server connection
* who - who rejected you
* msg - any message sent
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_rejected) (int id, const char *who,
const char *msg);
/*
* Name: ext_yahoo_typing_notify
* Called when remote user starts or stops typing.
* Params:
* id - the id that identifies the server connection
* me - the handle of the identity the notification is sent to
* who - the handle of the remote user
* stat - 1 if typing, 0 if stopped typing
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_typing_notify) (int id,
const char *me, const char *who, int stat);
/*
* Name: ext_yahoo_game_notify
* Called when remote user starts or stops a game.
* Params:
* id - the id that identifies the server connection
* me - the handle of the identity the notification is sent to
* who - the handle of the remote user
* stat - 1 if game, 0 if stopped gaming
* msg - game description and/or other text
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_game_notify) (int id, const char *me,
const char *who, int stat, const char *msg);
/*
* Name: ext_yahoo_mail_notify
* Called when you receive mail, or with number of messages
* Params:
* id - the id that identifies the server connection
* from - who the mail is from - NULL if only mail count
* subj - the subject of the mail - NULL if only mail count
* cnt - mail count - 0 if new mail notification
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_mail_notify) (int id,
const char *from, const char *subj, int cnt);
/*
* Name: ext_yahoo_system_message
* System message
* Params:
* id - the id that identifies the server connection
* me - the handle of the identity the notification is sent to
* who - the source of the system message (there are different types)
* msg - the message
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_system_message) (int id,
const char *me, const char *who, const char *msg);
/*
* Name: ext_yahoo_got_buddyicon
* Buddy icon received
* Params:
* id - the id that identifies the server connection
* me - the handle of the identity the notification is sent to
* who - the person the buddy icon is for
* url - the url to use to load the icon
* checksum - the checksum of the icon content
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon) (int id,
const char *me, const char *who, const char *url, int checksum);
/*
* Name: ext_yahoo_got_buddyicon_checksum
* Buddy icon checksum received
* Params:
* id - the id that identifies the server connection
* me - the handle of the identity the notification is sent to
* who - the yahoo id of the buddy icon checksum is for
* checksum - the checksum of the icon content
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_checksum) (int id,
const char *me, const char *who, int checksum);
/*
* Name: ext_yahoo_got_buddyicon_request
* Buddy icon request received
* Params:
* id - the id that identifies the server connection
* me - the handle of the identity the notification is sent to
* who - the yahoo id of the buddy that requested the buddy icon
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddyicon_request) (int id,
const char *me, const char *who);
/*
* Name: ext_yahoo_got_buddyicon_request
* Buddy icon request received
* Params:
* id - the id that identifies the server connection
* url - remote url, the uploaded buddy icon can be fetched from
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_buddyicon_uploaded) (int id,
const char *url);
/*
* Name: ext_yahoo_got_webcam_image
* Called when you get a webcam update
* An update can either be receiving an image, a part of an image or
* just an update with a timestamp
* Params:
* id - the id that identifies the server connection
* who - the user who's webcam we're viewing
* image - image data
* image_size - length of the image in bytes
* real_size - actual length of image data
* timestamp - milliseconds since the webcam started
*
* If the real_size is smaller then the image_size then only part of
* the image has been read. This function will keep being called till
* the total amount of bytes in image_size has been read. The image
* received is in JPEG-2000 Code Stream Syntax (ISO/IEC 15444-1).
* The size of the image will be either 160x120 or 320x240.
* Each webcam image contains a timestamp. This timestamp should be
* used to keep the image in sync since some images can take longer
* to transport then others. When image_size is 0 we can still receive
* a timestamp to stay in sync
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_webcam_image) (int id,
const char *who, const unsigned char *image,
unsigned int image_size, unsigned int real_size,
unsigned int timestamp);
/*
* Name: ext_yahoo_webcam_invite
* Called when you get a webcam invitation
* Params:
* id - the id that identifies the server connection
* me - identity the invitation is to
* from - who the invitation is from
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite) (int id,
const char *me, const char *from);
/*
* Name: ext_yahoo_webcam_invite_reply
* Called when you get a response to a webcam invitation
* Params:
* id - the id that identifies the server connection
* me - identity the invitation response is to
* from - who the invitation response is from
* accept - 0 (decline), 1 (accept)
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_invite_reply) (int id,
const char *me, const char *from, int accept);
/*
* Name: ext_yahoo_webcam_closed
* Called when the webcam connection closed
* Params:
* id - the id that identifies the server connection
* who - the user who we where connected to
* reason - reason why the connection closed
* 1 = user stopped broadcasting
* 2 = user cancelled viewing permission
* 3 = user declines permission
* 4 = user does not have webcam online
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_closed) (int id,
const char *who, int reason);
/*
* Name: ext_yahoo_got_search_result
* Called when the search result received from server
* Params:
* id - the id that identifies the server connection
* found - total number of results returned in the current result set
* start - offset from where the current result set starts
* total - total number of results available (start + found <= total)
* contacts - the list of results as a YList of yahoo_found_contact
* these will be freed after this function returns, so
* if you need to use the information, make a copy
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_search_result) (int id,
int found, int start, int total, YList *contacts);
/*
* Name: ext_yahoo_error
* Called on error.
* Params:
* id - the id that identifies the server connection
* err - the error message
* fatal- whether this error is fatal to the connection or not
* num - Which error is this
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_error) (int id, const char *err,
int fatal, int num);
/*
* Name: ext_yahoo_webcam_viewer
* Called when a viewer disconnects/connects/requests to connect
* Params:
* id - the id that identifies the server connection
* who - the viewer
* connect - 0=disconnect 1=connect 2=request
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_viewer) (int id,
const char *who, int connect);
/*
* Name: ext_yahoo_webcam_data_request
* Called when you get a request for webcam images
* Params:
* id - the id that identifies the server connection
* send - whether to send images or not
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_webcam_data_request) (int id,
int send);
/*
* Name: ext_yahoo_log
* Called to log a message.
* Params:
* fmt - the printf formatted message
* Returns:
* 0
*/
int YAHOO_CALLBACK_TYPE(ext_yahoo_log) (const char *fmt, ...);
/*
* Name: ext_yahoo_add_handler
* Add a listener for the fd. Must call yahoo_read_ready
* when a YAHOO_INPUT_READ fd is ready and yahoo_write_ready
* when a YAHOO_INPUT_WRITE fd is ready.
* Params:
* id - the id that identifies the server connection
* fd - the fd object on which to listen
* cond - the condition on which to call the callback
* data - callback data to pass to yahoo_*_ready
*
* Returns: a tag to be used when removing the handler
*/
int YAHOO_CALLBACK_TYPE(ext_yahoo_add_handler) (int id, void *fd,
yahoo_input_condition cond, void *data);
/*
* Name: ext_yahoo_remove_handler
* Remove the listener for the fd.
* Params:
* id - the id that identifies the connection
* tag - the handler tag to remove
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_remove_handler) (int id, int tag);
/*
* Name: ext_yahoo_connect
* Connect to a host:port
* Params:
* host - the host to connect to
* port - the port to connect on
* Returns:
* a unix file descriptor to the socket
*/
int YAHOO_CALLBACK_TYPE(ext_yahoo_connect) (const char *host, int port);
/*
* Name: ext_yahoo_connect_async
* Connect to a host:port asynchronously. This function should return
* immediately returing a tag used to identify the connection handler,
* or a pre-connect error (eg: host name lookup failure).
* Once the connect completes (successfully or unsuccessfully), callback
* should be called (see the signature for yahoo_connect_callback).
* The callback may safely be called before this function returns, but
* it should not be called twice.
* Params:
* id - the id that identifies this connection
* host - the host to connect to
* port - the port to connect on
* callback - function to call when connect completes
* callback_data - data to pass to the callback function
* use_ssl - Whether we need an SSL connection
* Returns:
* a tag signifying the connection attempt
*/
int YAHOO_CALLBACK_TYPE(ext_yahoo_connect_async) (int id,
const char *host, int port, yahoo_connect_callback callback,
void *callback_data, int use_ssl);
/*
* Name: ext_yahoo_get_ip_addr
* get IP Address for a domain name
* Params:
* domain - Domain name
* Returns:
* Newly allocated string containing the IP Address in IPv4 notation
*/
char *YAHOO_CALLBACK_TYPE(ext_yahoo_get_ip_addr) (const char *domain);
/*
* Name: ext_yahoo_write
* Write data from the buffer into the socket for the specified connection
* Params:
* fd - the file descriptor object that identifies this connection
* buf - Buffer to write the data from
* len - Length of the data
* Returns:
* Number of bytes written or -1 for error
*/
int YAHOO_CALLBACK_TYPE(ext_yahoo_write) (void *fd, char *buf, int len);
/*
* Name: ext_yahoo_read
* Read data into a buffer from socket for the specified connection
* Params:
* fd - the file descriptor object that identifies this connection
* buf - Buffer to read the data into
* len - Max length to read
* Returns:
* Number of bytes read or -1 for error
*/
int YAHOO_CALLBACK_TYPE(ext_yahoo_read) (void *fd, char *buf, int len);
/*
* Name: ext_yahoo_close
* Close the file descriptor object and free its resources. Libyahoo2 will not
* use this object again.
* Params:
* fd - the file descriptor object that identifies this connection
* Returns:
* Nothing
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_close) (void *fd);
/*
* Name: ext_yahoo_got_buddy_change_group
* Acknowledgement of buddy changing group
* Params:
* id: client id
* me: The user
* who: Buddy name
* old_group: Old group name
* new_group: New group name
* Returns:
* Nothing
*/
void YAHOO_CALLBACK_TYPE(ext_yahoo_got_buddy_change_group) (int id,
const char *me, const char *who, const char *old_group,
const char *new_group);
};
/*
* if using a callback structure, call yahoo_register_callbacks
* before doing anything else
*/
void yahoo_register_callbacks(struct yahoo_callbacks *tyc);
#undef YAHOO_CALLBACK_TYPE
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,396 @@
/*
* libyahoo2: yahoo2_types.h
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef YAHOO2_TYPES_H
#define YAHOO2_TYPES_H
#include "yahoo_list.h"
#ifdef __cplusplus
extern "C" {
#endif
enum yahoo_service { /* these are easier to see in hex */
YAHOO_SERVICE_LOGON = 1,
YAHOO_SERVICE_LOGOFF,
YAHOO_SERVICE_ISAWAY,
YAHOO_SERVICE_ISBACK,
YAHOO_SERVICE_IDLE, /* 5 (placemarker) */
YAHOO_SERVICE_MESSAGE,
YAHOO_SERVICE_IDACT,
YAHOO_SERVICE_IDDEACT,
YAHOO_SERVICE_MAILSTAT,
YAHOO_SERVICE_USERSTAT, /* 0xa */
YAHOO_SERVICE_NEWMAIL,
YAHOO_SERVICE_CHATINVITE,
YAHOO_SERVICE_CALENDAR,
YAHOO_SERVICE_NEWPERSONALMAIL,
YAHOO_SERVICE_NEWCONTACT,
YAHOO_SERVICE_ADDIDENT, /* 0x10 */
YAHOO_SERVICE_ADDIGNORE,
YAHOO_SERVICE_PING,
YAHOO_SERVICE_GOTGROUPRENAME, /* < 1, 36(old), 37(new) */
YAHOO_SERVICE_SYSMESSAGE = 0x14,
YAHOO_SERVICE_SKINNAME = 0x15,
YAHOO_SERVICE_PASSTHROUGH2 = 0x16,
YAHOO_SERVICE_CONFINVITE = 0x18,
YAHOO_SERVICE_CONFLOGON,
YAHOO_SERVICE_CONFDECLINE,
YAHOO_SERVICE_CONFLOGOFF,
YAHOO_SERVICE_CONFADDINVITE,
YAHOO_SERVICE_CONFMSG,
YAHOO_SERVICE_CHATLOGON,
YAHOO_SERVICE_CHATLOGOFF,
YAHOO_SERVICE_CHATMSG = 0x20,
YAHOO_SERVICE_GAMELOGON = 0x28,
YAHOO_SERVICE_GAMELOGOFF,
YAHOO_SERVICE_GAMEMSG = 0x2a,
YAHOO_SERVICE_FILETRANSFER = 0x46,
YAHOO_SERVICE_VOICECHAT = 0x4A,
YAHOO_SERVICE_NOTIFY,
YAHOO_SERVICE_VERIFY,
YAHOO_SERVICE_P2PFILEXFER,
YAHOO_SERVICE_PEERTOPEER = 0x4F, /* Checks if P2P possible */
YAHOO_SERVICE_WEBCAM,
YAHOO_SERVICE_AUTHRESP = 0x54,
YAHOO_SERVICE_LIST,
YAHOO_SERVICE_AUTH = 0x57,
YAHOO_SERVICE_AUTHBUDDY = 0x6d,
YAHOO_SERVICE_ADDBUDDY = 0x83,
YAHOO_SERVICE_REMBUDDY,
YAHOO_SERVICE_IGNORECONTACT, /* > 1, 7, 13 < 1, 66, 13, 0 */
YAHOO_SERVICE_REJECTCONTACT,
YAHOO_SERVICE_GROUPRENAME = 0x89, /* > 1, 65(new), 66(0), 67(old) */
YAHOO_SERVICE_Y7_PING = 0x8A,
YAHOO_SERVICE_CHATONLINE = 0x96, /* > 109(id), 1, 6(abcde) < 0,1 */
YAHOO_SERVICE_CHATGOTO,
YAHOO_SERVICE_CHATJOIN, /* > 1 104-room 129-1600326591 62-2 */
YAHOO_SERVICE_CHATLEAVE,
YAHOO_SERVICE_CHATEXIT = 0x9b,
YAHOO_SERVICE_CHATADDINVITE = 0x9d,
YAHOO_SERVICE_CHATLOGOUT = 0xa0,
YAHOO_SERVICE_CHATPING,
YAHOO_SERVICE_COMMENT = 0xa8,
YAHOO_SERVICE_GAME_INVITE = 0xb7,
YAHOO_SERVICE_STEALTH_PERM = 0xb9,
YAHOO_SERVICE_STEALTH_SESSION = 0xba,
YAHOO_SERVICE_AVATAR = 0xbc,
YAHOO_SERVICE_PICTURE_CHECKSUM = 0xbd,
YAHOO_SERVICE_PICTURE = 0xbe,
YAHOO_SERVICE_PICTURE_UPDATE = 0xc1,
YAHOO_SERVICE_PICTURE_UPLOAD = 0xc2,
YAHOO_SERVICE_YAB_UPDATE = 0xc4,
YAHOO_SERVICE_Y6_VISIBLE_TOGGLE = 0xc5, /* YMSG13, key 13: 2 = invisible, 1 = visible */
YAHOO_SERVICE_Y6_STATUS_UPDATE = 0xc6, /* YMSG13 */
YAHOO_SERVICE_PICTURE_STATUS = 0xc7, /* YMSG13, key 213: 0 = none, 1 = avatar, 2 = picture */
YAHOO_SERVICE_VERIFY_ID_EXISTS = 0xc8,
YAHOO_SERVICE_AUDIBLE = 0xd0,
YAHOO_SERVICE_Y7_PHOTO_SHARING = 0xd2,
YAHOO_SERVICE_Y7_CONTACT_DETAILS = 0xd3, /* YMSG13 */
YAHOO_SERVICE_Y7_CHAT_SESSION = 0xd4,
YAHOO_SERVICE_Y7_AUTHORIZATION = 0xd6, /* YMSG13 */
YAHOO_SERVICE_Y7_FILETRANSFER = 0xdc, /* YMSG13 */
YAHOO_SERVICE_Y7_FILETRANSFERINFO, /* YMSG13 */
YAHOO_SERVICE_Y7_FILETRANSFERACCEPT, /* YMSG13 */
YAHOO_SERVICE_Y7_MINGLE = 0xe1, /* YMSG13 */
YAHOO_SERVICE_Y7_CHANGE_GROUP = 0xe7, /* YMSG13 */
YAHOO_SERVICE_MYSTERY = 0xef, /* Don't know what this is for */
YAHOO_SERVICE_Y8_STATUS = 0xf0, /* YMSG15 */
YAHOO_SERVICE_Y8_LIST = 0Xf1, /* YMSG15 */
YAHOO_SERVICE_MESSAGE_CONFIRM = 0xfb,
YAHOO_SERVICE_WEBLOGIN = 0x0226,
YAHOO_SERVICE_SMS_MSG = 0x02ea
};
enum yahoo_status {
YAHOO_STATUS_AVAILABLE = 0,
YAHOO_STATUS_BRB,
YAHOO_STATUS_BUSY,
YAHOO_STATUS_NOTATHOME,
YAHOO_STATUS_NOTATDESK,
YAHOO_STATUS_NOTINOFFICE,
YAHOO_STATUS_ONPHONE,
YAHOO_STATUS_ONVACATION,
YAHOO_STATUS_OUTTOLUNCH,
YAHOO_STATUS_STEPPEDOUT,
YAHOO_STATUS_INVISIBLE = 12,
YAHOO_STATUS_CUSTOM = 99,
YAHOO_STATUS_IDLE = 999,
YAHOO_STATUS_OFFLINE = 0x5a55aa56 /* don't ask */
};
enum ypacket_status {
YPACKET_STATUS_DISCONNECTED = -1,
YPACKET_STATUS_DEFAULT = 0,
YPACKET_STATUS_SERVERACK = 1,
YPACKET_STATUS_GAME = 0x2,
YPACKET_STATUS_AWAY = 0x4,
YPACKET_STATUS_CONTINUED = 0x5,
YPACKET_STATUS_INVISIBLE = 12,
YPACKET_STATUS_NOTIFY = 0x16, /* TYPING */
YPACKET_STATUS_WEBLOGIN = 0x5a55aa55,
YPACKET_STATUS_OFFLINE = 0x5a55aa56
};
#define YAHOO_STATUS_GAME 0x2 /* Games don't fit into the regular status model */
enum yahoo_login_status {
YAHOO_LOGIN_OK = 0,
YAHOO_LOGIN_LOGOFF = 1,
YAHOO_LOGIN_UNAME = 3,
YAHOO_LOGIN_PASSWD = 13,
YAHOO_LOGIN_LOCK = 14,
YAHOO_LOGIN_DUPL = 99,
YAHOO_LOGIN_SOCK = -1,
YAHOO_LOGIN_UNKNOWN = 999
};
enum yahoo_error {
E_UNKNOWN = -1,
E_CONNECTION = -2,
E_SYSTEM = -3,
E_CUSTOM = 0,
/* responses from ignore buddy */
E_IGNOREDUP = 2,
E_IGNORENONE = 3,
E_IGNORECONF = 12,
/* conference */
E_CONFNOTAVAIL = 20
};
enum yahoo_log_level {
YAHOO_LOG_NONE = 0,
YAHOO_LOG_FATAL,
YAHOO_LOG_ERR,
YAHOO_LOG_WARNING,
YAHOO_LOG_NOTICE,
YAHOO_LOG_INFO,
YAHOO_LOG_DEBUG
};
enum yahoo_file_transfer {
YAHOO_FILE_TRANSFER_INIT = 1,
YAHOO_FILE_TRANSFER_ACCEPT = 3,
YAHOO_FILE_TRANSFER_REJECT = 4,
YAHOO_FILE_TRANSFER_DONE = 5,
YAHOO_FILE_TRANSFER_RELAY,
YAHOO_FILE_TRANSFER_FAILED,
YAHOO_FILE_TRANSFER_UNKNOWN
};
#define YAHOO_PROTO_VER 0x0010
/* Yahoo style/color directives */
#define YAHOO_COLOR_BLACK "\033[30m"
#define YAHOO_COLOR_BLUE "\033[31m"
#define YAHOO_COLOR_LIGHTBLUE "\033[32m"
#define YAHOO_COLOR_GRAY "\033[33m"
#define YAHOO_COLOR_GREEN "\033[34m"
#define YAHOO_COLOR_PINK "\033[35m"
#define YAHOO_COLOR_PURPLE "\033[36m"
#define YAHOO_COLOR_ORANGE "\033[37m"
#define YAHOO_COLOR_RED "\033[38m"
#define YAHOO_COLOR_OLIVE "\033[39m"
#define YAHOO_COLOR_ANY "\033[#"
#define YAHOO_STYLE_ITALICON "\033[2m"
#define YAHOO_STYLE_ITALICOFF "\033[x2m"
#define YAHOO_STYLE_BOLDON "\033[1m"
#define YAHOO_STYLE_BOLDOFF "\033[x1m"
#define YAHOO_STYLE_UNDERLINEON "\033[4m"
#define YAHOO_STYLE_UNDERLINEOFF "\033[x4m"
#define YAHOO_STYLE_URLON "\033[lm"
#define YAHOO_STYLE_URLOFF "\033[xlm"
enum yahoo_connection_type {
YAHOO_CONNECTION_PAGER = 0,
YAHOO_CONNECTION_FT,
YAHOO_CONNECTION_YAB,
YAHOO_CONNECTION_WEBCAM_MASTER,
YAHOO_CONNECTION_WEBCAM,
YAHOO_CONNECTION_CHATCAT,
YAHOO_CONNECTION_SEARCH,
YAHOO_CONNECTION_AUTH
};
enum yahoo_webcam_direction_type {
YAHOO_WEBCAM_DOWNLOAD = 0,
YAHOO_WEBCAM_UPLOAD
};
enum yahoo_stealth_visibility_type {
YAHOO_STEALTH_DEFAULT = 0,
YAHOO_STEALTH_ONLINE,
YAHOO_STEALTH_PERM_OFFLINE
};
/* chat member attribs */
#define YAHOO_CHAT_MALE 0x8000
#define YAHOO_CHAT_FEMALE 0x10000
#define YAHOO_CHAT_FEMALE 0x10000
#define YAHOO_CHAT_DUNNO 0x400
#define YAHOO_CHAT_WEBCAM 0x10
enum yahoo_webcam_conn_type { Y_WCM_DIALUP, Y_WCM_DSL, Y_WCM_T1 };
struct yahoo_webcam {
int direction; /* Uploading or downloading */
int conn_type; /* 0=Dialup, 1=DSL/Cable, 2=T1/Lan */
char *user; /* user we are viewing */
char *server; /* webcam server to connect to */
int port; /* webcam port to connect on */
char *key; /* key to connect to the server with */
char *description; /* webcam description */
char *my_ip; /* own ip number */
};
struct yahoo_webcam_data {
unsigned int data_size;
unsigned int to_read;
unsigned int timestamp;
unsigned char packet_type;
};
struct yahoo_data {
char *user;
char *password;
char *cookie_y;
char *cookie_t;
char *cookie_c;
char *cookie_b;
char *login_cookie;
char *crumb;
char *seed;
YList *buddies;
YList *ignore;
YList *identities;
char *login_id;
int current_status;
int initial_status;
int logged_in;
int session_id;
int client_id;
char *rawbuddylist;
char *ignorelist;
void *server_settings;
struct yahoo_process_status_entry *half_user;
};
struct yab {
int yid;
char *id;
char *fname;
char *lname;
char *nname;
char *email;
char *hphone;
char *wphone;
char *mphone;
int dbid;
};
struct yahoo_buddy {
char *group;
char *id;
char *real_name;
struct yab *yab_entry;
};
enum yahoo_search_type {
YAHOO_SEARCH_KEYWORD = 0,
YAHOO_SEARCH_YID,
YAHOO_SEARCH_NAME
};
enum yahoo_search_gender {
YAHOO_GENDER_NONE = 0,
YAHOO_GENDER_MALE,
YAHOO_GENDER_FEMALE
};
enum yahoo_search_agerange {
YAHOO_AGERANGE_NONE = 0
};
struct yahoo_found_contact {
char *id;
char *gender;
char *location;
int age;
int online;
};
/*
* Function pointer to be passed to http get/post and send file
*/
typedef void (*yahoo_get_fd_callback) (int id, void *fd, int error,
void *data);
/*
* Function pointer to be passed to yahoo_get_url_handle
*/
typedef void (*yahoo_get_url_handle_callback) (int id, void *fd,
int error, const char *filename, unsigned long size,
void *data);
struct yahoo_chat_member {
char *id;
int age;
int attribs;
char *alias;
char *location;
};
struct yahoo_process_status_entry {
char *name; /* 7 name */
int state; /* 10 state */
int flags; /* 13 flags, bit 0 = pager, bit 1 = chat, bit 2 = game */
int mobile; /* 60 mobile */
char *msg; /* 19 custom status message */
int away; /* 47 away (or invisible) */
int buddy_session; /* 11 state */
int f17; /* 17 in chat? then what about flags? */
int idle; /* 137 seconds idle */
int f138; /* 138 state */
char *f184; /* 184 state */
int f192; /* 192 state */
int f10001; /* 10001 state */
int f10002; /* 10002 state */
int f198; /* 198 state */
char *f197; /* 197 state */
char *f205; /* 205 state */
int f213; /* 213 state */
};
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,36 @@
/*
* libyahoo2: yahoo_debug.h
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
extern int yahoo_log_message(char *fmt, ...);
#define NOTICE(x) if(yahoo_get_log_level() >= YAHOO_LOG_NOTICE) { yahoo_log_message x; yahoo_log_message("\n"); }
#define LOG(x) if(yahoo_get_log_level() >= YAHOO_LOG_INFO) { yahoo_log_message("%s:%d: ", __FILE__, __LINE__); \
yahoo_log_message x; \
yahoo_log_message("\n"); }
#define WARNING(x) if(yahoo_get_log_level() >= YAHOO_LOG_WARNING) { yahoo_log_message("%s:%d: warning: ", __FILE__, __LINE__); \
yahoo_log_message x; \
yahoo_log_message("\n"); }
#define DEBUG_MSG(x) if(yahoo_get_log_level() >= YAHOO_LOG_DEBUG) { yahoo_log_message("%s:%d: debug: ", __FILE__, __LINE__); \
yahoo_log_message x; \
yahoo_log_message("\n"); }

4810
libs/libyahoo2/yahoo_fn.c Normal file

File diff suppressed because it is too large Load Diff

32
libs/libyahoo2/yahoo_fn.h Normal file
View File

@ -0,0 +1,32 @@
/*
* libyahoo2 - originally from gaim patches by Amatus
*
* Copyright (C) 2003-2004
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#define IDENT 1 /* identify function */
#define XOR 2 /* xor with arg1 */
#define MULADD 3 /* multipy by arg1 then add arg2 */
#define LOOKUP 4 /* lookup each byte in the table pointed to by arg1 */
#define BITFLD 5 /* reorder bits according to table pointed to by arg1 */
struct yahoo_fn {
int type;
long arg1, arg2;
};
int yahoo_xfrm(int table, int depth, int seed);

408
libs/libyahoo2/yahoo_httplib.c Executable file
View File

@ -0,0 +1,408 @@
/*
* libyahoo2: yahoo_httplib.c
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#define PACKAGE "Caya"
#define VERSION "0.1.0"
#if HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#if STDC_HEADERS
# include <string.h>
#else
# if !HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
char *strchr(), *strrchr();
# if !HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#include <errno.h>
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <ctype.h>
#include "yahoo2.h"
#include "yahoo2_callbacks.h"
#include "yahoo_httplib.h"
#include "yahoo_util.h"
#include "yahoo_debug.h"
#ifdef __MINGW32__
# include <winsock2.h>
# define snprintf _snprintf
#endif
extern struct yahoo_callbacks *yc;
#define YAHOO_CALLBACK(x) yc->x
extern enum yahoo_log_level log_level;
int yahoo_tcp_readline(char *ptr, int maxlen, void *fd)
{
int n, rc;
char c;
for (n = 1; n < maxlen; n++) {
do {
rc = YAHOO_CALLBACK(ext_yahoo_read) (fd, &c, 1);
} while (rc == -1 && (errno == EINTR || errno == EAGAIN)); /* this is bad - it should be done asynchronously */
if (rc == 1) {
if (c == '\r') /* get rid of \r */
continue;
*ptr = c;
if (c == '\n')
break;
ptr++;
} else if (rc == 0) {
if (n == 1)
return (0); /* EOF, no data */
else
break; /* EOF, w/ data */
} else {
return -1;
}
}
*ptr = 0;
return (n);
}
static int url_to_host_port_path(const char *url,
char *host, int *port, char *path, int *ssl)
{
char *urlcopy = NULL;
char *slash = NULL;
char *colon = NULL;
/*
* http://hostname
* http://hostname/
* http://hostname/path
* http://hostname/path:foo
* http://hostname:port
* http://hostname:port/
* http://hostname:port/path
* http://hostname:port/path:foo
* and https:// variants of the above
*/
if (strstr(url, "http://") == url) {
urlcopy = strdup(url + 7);
} else if (strstr(url, "https://") == url) {
urlcopy = strdup(url + 8);
*ssl = 1;
} else {
WARNING(("Weird url - unknown protocol: %s", url));
return 0;
}
slash = strchr(urlcopy, '/');
colon = strchr(urlcopy, ':');
if (!colon || (slash && slash < colon)) {
if (*ssl)
*port = 443;
else
*port = 80;
} else {
*colon = 0;
*port = atoi(colon + 1);
}
if (!slash) {
strcpy(path, "/");
} else {
strcpy(path, slash);
*slash = 0;
}
strcpy(host, urlcopy);
FREE(urlcopy);
return 1;
}
static int isurlchar(unsigned char c)
{
return (isalnum(c));
}
char *yahoo_urlencode(const char *instr)
{
int ipos = 0, bpos = 0;
char *str = NULL;
int len = strlen(instr);
if (!(str = y_new(char, 3 *len + 1)))
return "";
while (instr[ipos]) {
while (isurlchar(instr[ipos]))
str[bpos++] = instr[ipos++];
if (!instr[ipos])
break;
snprintf(&str[bpos], 4, "%%%02x", instr[ipos] & 0xff);
bpos += 3;
ipos++;
}
str[bpos] = '\0';
/* free extra alloc'ed mem. */
len = strlen(str);
str = y_renew(char, str, len + 1);
return (str);
}
char *yahoo_urldecode(const char *instr)
{
int ipos = 0, bpos = 0;
char *str = NULL;
char entity[3] = { 0, 0, 0 };
unsigned dec;
int len = strlen(instr);
if (!(str = y_new(char, len + 1)))
return "";
while (instr[ipos]) {
while (instr[ipos] && instr[ipos] != '%')
if (instr[ipos] == '+') {
str[bpos++] = ' ';
ipos++;
} else
str[bpos++] = instr[ipos++];
if (!instr[ipos])
break;
if (instr[ipos + 1] && instr[ipos + 2]) {
ipos++;
entity[0] = instr[ipos++];
entity[1] = instr[ipos++];
sscanf(entity, "%2x", &dec);
str[bpos++] = (char)dec;
} else {
str[bpos++] = instr[ipos++];
}
}
str[bpos] = '\0';
/* free extra alloc'ed mem. */
len = strlen(str);
str = y_renew(char, str, len + 1);
return (str);
}
char *yahoo_xmldecode(const char *instr)
{
int ipos = 0, bpos = 0, epos = 0;
char *str = NULL;
char entity[4] = { 0, 0, 0, 0 };
char *entitymap[5][2] = {
{"amp;", "&"},
{"quot;", "\""},
{"lt;", "<"},
{"gt;", "<"},
{"nbsp;", " "}
};
unsigned dec;
int len = strlen(instr);
if (!(str = y_new(char, len + 1)))
return "";
while (instr[ipos]) {
while (instr[ipos] && instr[ipos] != '&')
if (instr[ipos] == '+') {
str[bpos++] = ' ';
ipos++;
} else
str[bpos++] = instr[ipos++];
if (!instr[ipos] || !instr[ipos + 1])
break;
ipos++;
if (instr[ipos] == '#') {
ipos++;
epos = 0;
while (instr[ipos] != ';')
entity[epos++] = instr[ipos++];
sscanf(entity, "%u", &dec);
str[bpos++] = (char)dec;
ipos++;
} else {
int i;
for (i = 0; i < 5; i++)
if (!strncmp(instr + ipos, entitymap[i][0],
strlen(entitymap[i][0]))) {
str[bpos++] = entitymap[i][1][0];
ipos += strlen(entitymap[i][0]);
break;
}
}
}
str[bpos] = '\0';
/* free extra alloc'ed mem. */
len = strlen(str);
str = y_renew(char, str, len + 1);
return (str);
}
typedef void (*http_connected) (int id, void *fd, int error);
struct callback_data {
int id;
yahoo_get_fd_callback callback;
char *request;
void *user_data;
};
static void connect_complete(void *fd, int error, void *data)
{
struct callback_data *ccd = data;
if (error == 0)
YAHOO_CALLBACK(ext_yahoo_write) (fd, ccd->request,
strlen(ccd->request));
free(ccd->request);
ccd->callback(ccd->id, fd, error, ccd->user_data);
FREE(ccd);
}
static void yahoo_send_http_request(int id, char *host, int port, char *request,
yahoo_get_fd_callback callback, void *data, int use_ssl)
{
struct callback_data *ccd = y_new0(struct callback_data, 1);
ccd->callback = callback;
ccd->id = id;
ccd->request = strdup(request);
ccd->user_data = data;
YAHOO_CALLBACK(ext_yahoo_connect_async) (id, host, port,
connect_complete, ccd, use_ssl);
}
void yahoo_http_post(int id, const char *url, const char *cookies,
long content_length, yahoo_get_fd_callback callback, void *data)
{
char host[255];
int port = 80;
char path[255];
char buff[1024];
int ssl = 0;
if (!url_to_host_port_path(url, host, &port, path, &ssl))
return;
/* thanks to kopete dumpcap */
snprintf(buff, sizeof(buff),
"POST %s HTTP/1.1\r\n"
"Cookie: %s\r\n"
"User-Agent: Mozilla/5.0\r\n"
"Host: %s\r\n"
"Content-Length: %ld\r\n"
"Cache-Control: no-cache\r\n"
"\r\n", path, cookies, host, content_length);
yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
}
void yahoo_http_get(int id, const char *url, const char *cookies, int http11,
int keepalive, yahoo_get_fd_callback callback, void *data)
{
char host[255];
int port = 80;
char path[255];
char buff[2048];
char cookiebuff[1024];
int ssl = 0;
if (!url_to_host_port_path(url, host, &port, path, &ssl))
return;
/* Allow cases when we don't need to send a cookie */
if (cookies)
snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n",
cookies);
else
cookiebuff[0] = '\0';
snprintf(buff, sizeof(buff),
"GET %s HTTP/1.%s\r\n"
"%sHost: %s\r\n"
"User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
"Accept: */*\r\n"
"%s" "\r\n", path, http11?"1":"0", cookiebuff, host,
keepalive? "Connection: Keep-Alive\r\n":"Connection: close\r\n");
yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
}
void yahoo_http_head(int id, const char *url, const char *cookies, int len,
char *payload, yahoo_get_fd_callback callback, void *data)
{
printf("yahoo_http_read\n");
char host[255];
int port = 80;
char path[255];
char buff[2048];
char cookiebuff[1024];
int ssl = 0;
if (!url_to_host_port_path(url, host, &port, path, &ssl))
return;
/* Allow cases when we don't need to send a cookie */
if (cookies)
snprintf(cookiebuff, sizeof(cookiebuff), "Cookie: %s\r\n",
cookies);
else
cookiebuff[0] = '\0';
snprintf(buff, sizeof(buff),
"HEAD %s HTTP/1.0\r\n"
"Accept: */*\r\n"
"Host: %s:%d\r\n"
"User-Agent: Mozilla/4.5 [en] (" PACKAGE "/" VERSION ")\r\n"
"%s"
"Content-Length: %d\r\n"
"Cache-Control: no-cache\r\n"
"\r\n%s", path, host, port, cookiebuff, len,
payload?payload:"");
yahoo_send_http_request(id, host, port, buff, callback, data, ssl);
}

View File

@ -0,0 +1,48 @@
/*
* libyahoo2: yahoo_httplib.h
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef YAHOO_HTTPLIB_H
#define YAHOO_HTTPLIB_H
#ifdef __cplusplus
extern "C" {
#endif
#include "yahoo2_types.h"
char *yahoo_urlencode(const char *instr);
char *yahoo_urldecode(const char *instr);
char *yahoo_xmldecode(const char *instr);
int yahoo_tcp_readline(char *ptr, int maxlen, void *fd);
void yahoo_http_post(int id, const char *url, const char *cookies,
long size, yahoo_get_fd_callback callback, void *data);
void yahoo_http_get(int id, const char *url, const char *cookies,
int http11, int keepalive, yahoo_get_fd_callback callback,
void *data);
void yahoo_http_head(int id, const char *url, const char *cookies,
int size, char *payload, yahoo_get_fd_callback callback,
void *data);
#ifdef __cplusplus
}
#endif
#endif

233
libs/libyahoo2/yahoo_list.c Normal file
View File

@ -0,0 +1,233 @@
/*
* yahoo_list.c: linked list routines
*
* Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
* Other code copyright Meredydd Luff <meredydd AT everybuddy.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Some of this code was borrowed from elist.c in the eb-lite sources
*
*/
#include <stdlib.h>
#include "yahoo_list.h"
YList *y_list_append(YList *list, void *data)
{
YList *n;
YList *new_list = malloc(sizeof(YList));
YList *attach_to = NULL;
new_list->next = NULL;
new_list->data = data;
for (n = list; n != NULL; n = n->next) {
attach_to = n;
}
if (attach_to == NULL) {
new_list->prev = NULL;
return new_list;
} else {
new_list->prev = attach_to;
attach_to->next = new_list;
return list;
}
}
YList *y_list_prepend(YList *list, void *data)
{
YList *n = malloc(sizeof(YList));
n->next = list;
n->prev = NULL;
n->data = data;
if (list)
list->prev = n;
return n;
}
YList *y_list_concat(YList *list, YList *add)
{
YList *l;
if (!list)
return add;
if (!add)
return list;
for (l = list; l->next; l = l->next) ;
l->next = add;
add->prev = l;
return list;
}
YList *y_list_remove(YList *list, void *data)
{
YList *n;
for (n = list; n != NULL; n = n->next) {
if (n->data == data) {
list = y_list_remove_link(list, n);
y_list_free_1(n);
break;
}
}
return list;
}
/* Warning */
/* link MUST be part of list */
/* caller must free link using y_list_free_1 */
YList *y_list_remove_link(YList *list, const YList *link)
{
if (!link)
return list;
if (link->next)
link->next->prev = link->prev;
if (link->prev)
link->prev->next = link->next;
if (link == list)
list = link->next;
return list;
}
int y_list_length(const YList *list)
{
int retval = 0;
const YList *n = list;
for (n = list; n != NULL; n = n->next) {
retval++;
}
return retval;
}
/* well, you could just check for list == NULL, but that would be
* implementation dependent
*/
int y_list_empty(const YList *list)
{
if (!list)
return 1;
else
return 0;
}
int y_list_singleton(const YList *list)
{
if (!list || list->next)
return 0;
return 1;
}
YList *y_list_copy(YList *list)
{
YList *n;
YList *copy = NULL;
for (n = list; n != NULL; n = n->next) {
copy = y_list_append(copy, n->data);
}
return copy;
}
void y_list_free_1(YList *list)
{
free(list);
}
void y_list_free(YList *list)
{
YList *n = list;
while (n != NULL) {
YList *next = n->next;
free(n);
n = next;
}
}
YList *y_list_find(YList *list, const void *data)
{
YList *l;
for (l = list; l && l->data != data; l = l->next) ;
return l;
}
void y_list_foreach(YList *list, YListFunc fn, void *user_data)
{
for (; list; list = list->next)
fn(list->data, user_data);
}
YList *y_list_find_custom(YList *list, const void *data, YListCompFunc comp)
{
YList *l;
for (l = list; l; l = l->next)
if (comp(l->data, data) == 0)
return l;
return NULL;
}
YList *y_list_nth(YList *list, int n)
{
int i = n;
for (; list && i; list = list->next, i--) ;
return list;
}
YList *y_list_insert_sorted(YList *list, void *data, YListCompFunc comp)
{
YList *l, *n, *prev = NULL;
if (!list)
return y_list_append(list, data);
n = malloc(sizeof(YList));
n->data = data;
for (l = list; l && comp(l->data, n->data) <= 0; l = l->next)
prev = l;
if (l) {
n->prev = l->prev;
l->prev = n;
} else
n->prev = prev;
n->next = l;
if (n->prev) {
n->prev->next = n;
return list;
} else {
return n;
}
}

View File

@ -0,0 +1,76 @@
/*
* yahoo_list.h: linked list routines
*
* Some code copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
* Other code copyright Meredydd Luff <meredydd AT everybuddy.com>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
/*
* This is a replacement for the GList. It only provides functions that
* we use in Ayttm. Thanks to Meredyyd from everybuddy dev for doing
* most of it.
*/
#ifndef __YLIST_H__
#define __YLIST_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct _YList {
struct _YList *next;
struct _YList *prev;
void *data;
} YList;
typedef int (*YListCompFunc) (const void *, const void *);
typedef void (*YListFunc) (void *, void *);
YList *y_list_append(YList *list, void *data);
YList *y_list_prepend(YList *list, void *data);
YList *y_list_remove_link(YList *list, const YList *link);
YList *y_list_remove(YList *list, void *data);
YList *y_list_insert_sorted(YList *list, void *data,
YListCompFunc comp);
YList *y_list_copy(YList *list);
YList *y_list_concat(YList *list, YList *add);
YList *y_list_find(YList *list, const void *data);
YList *y_list_find_custom(YList *list, const void *data,
YListCompFunc comp);
YList *y_list_nth(YList *list, int n);
void y_list_foreach(YList *list, YListFunc fn, void *user_data);
void y_list_free_1(YList *list);
void y_list_free(YList *list);
int y_list_length(const YList *list);
int y_list_empty(const YList *list);
int y_list_singleton(const YList *list);
#define y_list_next(list) list->next
#ifdef __cplusplus
}
#endif
#endif

162
libs/libyahoo2/yahoo_util.c Normal file
View File

@ -0,0 +1,162 @@
/*
* libyahoo2: yahoo_util.c
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if STDC_HEADERS
# include <string.h>
#else
# if !HAVE_STRCHR
# define strchr index
# define strrchr rindex
# endif
char *strchr(), *strrchr();
# if !HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#include "yahoo_util.h"
char *y_string_append(char *string, char *append)
{
int size = strlen(string) + strlen(append) + 1;
char *new_string = y_renew(char, string, size);
if (new_string == NULL) {
new_string = y_new(char, size);
strcpy(new_string, string);
FREE(string);
}
strcat(new_string, append);
return new_string;
}
char *y_str_to_utf8(const char *in)
{
unsigned int n, i = 0;
char *result = NULL;
if (in == NULL || *in == '\0')
return strdup("");
result = y_new(char, strlen(in) * 2 + 1);
/* convert a string to UTF-8 Format */
for (n = 0; n < strlen(in); n++) {
unsigned char c = (unsigned char)in[n];
if (c < 128) {
result[i++] = (char)c;
} else {
result[i++] = (char)((c >> 6) | 192);
result[i++] = (char)((c & 63) | 128);
}
}
result[i] = '\0';
return result;
}
char *y_utf8_to_str(const char *in)
{
int i = 0;
unsigned int n;
char *result = NULL;
if (in == NULL || *in == '\0')
return strdup("");
result = y_new(char, strlen(in) + 1);
/* convert a string from UTF-8 Format */
for (n = 0; n < strlen(in); n++) {
unsigned char c = in[n];
if (c < 128) {
result[i++] = (char)c;
} else {
result[i++] = (c << 6) | (in[++n] & 63);
}
}
result[i] = '\0';
return result;
}
#if !HAVE_GLIB
void y_strfreev(char **vector)
{
char **v;
for (v = vector; *v; v++) {
FREE(*v);
}
FREE(vector);
}
char **y_strsplit(char *str, char *sep, int nelem)
{
char **vector;
char *s, *p;
int i = 0;
int l = strlen(sep);
if (nelem <= 0) {
char *s;
nelem = 0;
if (*str) {
for (s = strstr(str, sep); s;
s = strstr(s + l, sep), nelem++) ;
if (strcmp(str + strlen(str) - l, sep))
nelem++;
}
}
vector = y_new(char *, nelem + 1);
for (p = str, s = strstr(p, sep); i < nelem && s;
p = s + l, s = strstr(p, sep), i++) {
int len = s - p;
vector[i] = y_new(char, len + 1);
strncpy(vector[i], p, len);
vector[i][len] = '\0';
}
if (i < nelem && *str) /* str didn't end with sep, and str isn't empty */
vector[i++] = strdup(p);
vector[i] = NULL;
return vector;
}
void *y_memdup(const void *addr, int n)
{
void *new_chunk = malloc(n);
if (new_chunk)
memcpy(new_chunk, addr, n);
return new_chunk;
}
#endif

103
libs/libyahoo2/yahoo_util.h Normal file
View File

@ -0,0 +1,103 @@
/*
* libyahoo2: yahoo_util.h
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef __YAHOO_UTIL_H__
#define __YAHOO_UTIL_H__
#if HAVE_CONFIG_H
# include <config.h>
#endif
#if HAVE_GLIB
# include <glib.h>
# define FREE(x) if(x) {g_free(x); x=NULL;}
# define y_new g_new
# define y_new0 g_new0
# define y_renew g_renew
# define y_memdup g_memdup
# define y_strsplit g_strsplit
# define y_strfreev g_strfreev
# ifndef strdup
# define strdup g_strdup
# endif
# ifndef strncasecmp
# define strncasecmp g_strncasecmp
# define strcasecmp g_strcasecmp
# endif
# define snprintf g_snprintf
# define vsnprintf g_vsnprintf
#else
# include <stdlib.h>
# include <stdarg.h>
# define FREE(x) if(x) {free(x); x=NULL;}
# define y_new(type, n) (type *)malloc(sizeof(type) * (n))
# define y_new0(type, n) (type *)calloc((n), sizeof(type))
# define y_renew(type, mem, n) (type *)realloc(mem, n)
void *y_memdup(const void *addr, int n);
char **y_strsplit(char *str, char *sep, int nelem);
void y_strfreev(char **vector);
#ifndef _WIN32
int strncasecmp(const char *s1, const char *s2, size_t n);
int strcasecmp(const char *s1, const char *s2);
char *strdup(const char *s);
int snprintf(char *str, size_t size, const char *format, ...);
int vsnprintf(char *str, size_t size, const char *format, va_list ap);
#endif
#endif
#ifndef TRUE
#define TRUE 1
#endif
#ifndef FALSE
#define FALSE 0
#endif
#ifndef MIN
#define MIN(x,y) ((x)<(y)?(x):(y))
#endif
#ifndef MAX
#define MAX(x,y) ((x)>(y)?(x):(y))
#endif
/*
* The following three functions return newly allocated memory.
* You must free it yourself
*/
char *y_string_append(char *str, char *append);
char *y_str_to_utf8(const char *in);
char *y_utf8_to_str(const char *in);
#endif

View File

@ -3,3 +3,4 @@ SubDir TOP protocols ;
# Include all the components.
SubInclude TOP protocols xmpp ;
SubInclude TOP protocols msn ;
SubInclude TOP protocols yahoo ;

21
protocols/yahoo/Jamfile Normal file
View File

@ -0,0 +1,21 @@
SubDir TOP protocols yahoo ;
SubDirSysHdrs [ FDirName $(TOP) ] ;
SubDirSysHdrs [ FDirName $(TOP) libs ] ;
SubDirSysHdrs [ FDirName $(TOP) libs libyahoo2 ] ;
SubDirSysHdrs [ FDirName $(OPENSSL_INCLUDE_DIR) ] ;
SubDirSysHdrs [ FDirName $(CAYA_INCLUDE_DIR) ] ;
AddOn yahoo :
Yahoo.cpp
YahooCallbacks.cpp
YahooConnection.cpp
: be $(TARGET_LIBSTDC++) ssl crypto libyahoo2.a network
: Yahoo.rdef ProtocolTemplate.rdef
;
Depends yahoo : libyahoo2.a ;
LINKFLAGS on yahoo += -L$(OPENSSL_LIBRARY_DIR) ;
InstallBin $(CAYA_DIRECTORY)/protocols : yahoo ;

340
protocols/yahoo/LICENSE Normal file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

View File

@ -0,0 +1,13 @@
resource(1000) message('IMst') {
"setting" = message {
"name" = "yahooID",
"description" = "Yahoo! ID",
int32 "type" = 'CSTR'
},
"setting" = message {
"name" = "password",
"description" = "Password",
int32 "type" = 'CSTR',
"is_secret" = true
}
};

525
protocols/yahoo/Yahoo.cpp Normal file
View File

@ -0,0 +1,525 @@
/*
* This is a plugin ported from im_kit to Caya,
* the code was updated to support libyahoo2.
*
* Copyright (C) 2010-2011, Barrett
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include <DataIO.h>
#include <CayaProtocol.h>
#include <CayaConstants.h>
#include <CayaProtocolMessages.h>
#include "Yahoo.h"
#include "YahooConnection.h"
#define LOG printf
const char * kProtocolSignature = "yahoo";
const char * kProtocolName = "Yahoo";
extern "C" __declspec(dllexport) CayaProtocol* protocol();
extern "C" __declspec(dllexport) const char* signature();
extern "C" __declspec(dllexport) const char* friendly_signature();
extern "C" void register_callbacks();
CayaProtocol*
protocol()
{
return (CayaProtocol*)new Yahoo();
}
const char*
signature()
{
return kProtocolSignature;
}
const char*
friendly_signature()
{
return kProtocolName;
}
Yahoo::Yahoo()
:
fYahooID(""),
fPassword(""),
fYahoo(NULL)
{
register_callbacks();
}
Yahoo::~Yahoo()
{
if (fYahoo)
delete fYahoo;
}
status_t
Yahoo::Init( CayaProtocolMessengerInterface* msgr )
{
fServerMsgr = msgr;
return B_OK;
}
status_t
Yahoo::Shutdown()
{
if (fYahoo) {
YahooConnection * oldYahoo = fYahoo;
fYahoo = NULL;
delete oldYahoo;
}
return B_OK;
}
uint32
Yahoo::Version() const
{
return CAYA_VERSION_1_PRE_ALPHA_1;
}
status_t
Yahoo::Process(BMessage * msg)
{
LOG("Yahoo: Process()\n");
msg->PrintToStream();
switch (msg->what)
{
case IM_MESSAGE:
{
int32 im_what = 0;
msg->FindInt32("im_what", &im_what);
switch (im_what)
{
case IM_SET_OWN_STATUS:
{
LOG("Yahoo: Set own status\n");
int32 status = msg->FindInt32("status");
BString status_msg("");
msg->FindString("message", &status_msg);
//LOG(kProtocolSignature, liMedium, "Set status to %s", status);
switch (status) {
case CAYA_ONLINE:
LOG("Yahoo: Caya online\n");
if (!fYahoo) {
if (fYahooID != "") {
Progress("Yahoo Login", "Yahoo: Connecting..", 0.50);
fYahoo = new YahooConnection(
this,
fYahooID.String(),
fPassword.String()
);
}
} else {
fYahoo->SetAway(YAHOO_STATUS_AVAILABLE, NULL);
}
break;
case CAYA_AWAY:
if (fYahoo) {
fYahoo->SetAway(YAHOO_STATUS_NOTATDESK, NULL);
}
break;
case CAYA_EXTENDED_AWAY:
break;
case CAYA_DO_NOT_DISTURB:
if (fYahoo) {
fYahoo->SetAway(YAHOO_STATUS_BUSY, NULL);
}
break;
case CAYA_OFFLINE:
if (fYahoo) {
YahooConnection * oldYahoo = fYahoo;
fYahoo = NULL;
delete oldYahoo;
}
break;
default:
// Error("Invalid", NULL);
// Log("caya msn plugin :
break;
}
break;
}
break;
case IM_SEND_MESSAGE:
if (fYahoo)
fYahoo->Message( msg->FindString("id"), msg->FindString("body") );
else
return B_ERROR;
break;
/*case IM::REGISTER_CONTACTS:
if ( fYahoo ) {
const char * buddy=NULL;
for (int i=0; msg->FindString("id", i, &buddy) == B_OK; i++)
fYahoo->AddBuddy( buddy );
} else {
return B_ERROR;
}
break;
case IM::UNREGISTER_CONTACTS:
if ( fYahoo ) {
const char * buddy=NULL;
for ( int i=0;
msg->FindString("id", i, &buddy) == B_OK; i++ ) {
fYahoo->RemoveBuddy( buddy );
}
} else
return B_ERROR;
break;*/
case IM_USER_STARTED_TYPING:
if (fYahoo) {
const char *id = msg->FindString("id");
if (!id) return B_ERROR;
fYahoo->Typing(id, 1);
}
break;
case IM_USER_STOPPED_TYPING:
if (fYahoo) {
const char *id = msg->FindString("id");
if (!id) return B_ERROR;
fYahoo->Typing(id, 0);
}
break;
/*case IM_SET_OWN_AVATAR:
if ( fYahoo ) {
}
break;*/
default:
// we don't handle this im_what code
return B_ERROR;
}
} break;
default:
return B_ERROR;
}
return B_OK;
}
const char*
Yahoo::Signature() const
{
return kProtocolSignature;
}
const char*
Yahoo::FriendlySignature() const
{
return kProtocolName;
}
status_t
Yahoo::UpdateSettings( BMessage* msg )
{
msg->PrintToStream();
const char *yahooID = NULL;
const char *password = NULL;
msg->FindString("yahooID", &yahooID);
msg->FindString("password", &password);
LOG("%s %s \n", yahooID, password);
if ((yahooID == NULL) || (password == NULL)) {
Error("Yahoo Protocol: Invalid settings!", NULL);
return B_ERROR;
}
fYahooID = yahooID;
fPassword = password;
BMessage mess(IM_MESSAGE);
mess.AddInt32("im_what", IM_OWN_CONTACT_INFO);
mess.AddString("protocol", kProtocolSignature);
mess.AddString("id", yahooID);
mess.AddString("name", yahooID);
fServerMsgr->SendMessage(&mess);
return B_OK;
}
uint32
Yahoo::GetEncoding()
{
return 0xffff; // No conversion, Yahoo handles UTF-8
}
// YahooManager stuff
void
Yahoo::Error( const char * message, const char * who )
{
BMessage msg(IM_ERROR);
msg.AddString("protocol", kProtocolName);
if (who)
msg.AddString("id", who);
msg.AddString("error", message);
fServerMsgr->SendMessage( &msg );
}
void
Yahoo::GotMessage( const char * from, const char * message )
{
LOG("Yahoo::GotMessage()\n");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_RECEIVED);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", from);
msg.AddString("body", message);
fServerMsgr->SendMessage( &msg );
}
void
Yahoo::MessageSent( const char * to, const char * message )
{
LOG("Yahoo::MessageSent()\n");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_MESSAGE_SENT);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", to);
msg.AddString("body", message);
fServerMsgr->SendMessage( &msg );
}
void
Yahoo::LoggedIn()
{
LOG("Yahoo::LoggedIn()\n");
Progress("Yahoo Login", "Yahoo: Logged in!", 1.00);
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_OWN_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_ONLINE);
fServerMsgr->SendMessage( &msg );
}
void
Yahoo::SetAway(bool away)
{
LOG("Yahoo::SetAway()\n");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_OWN_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
if ( away )
msg.AddInt32("status", CAYA_AWAY);
else
msg.AddInt32("status", CAYA_ONLINE);
fServerMsgr->SendMessage( &msg );
}
void
Yahoo::LoggedOut()
{
LOG("Yahoo::LoggedOut()\n");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_OWN_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
msg.AddInt32("status", CAYA_OFFLINE);
fServerMsgr->SendMessage(&msg);
if (fYahoo) {
YahooConnection * oldYahoo = fYahoo;
fYahoo = NULL;
delete oldYahoo;
}
}
void
Yahoo::GotBuddyList(std::list<std::string>& buddies)
{
LOG("Yahoo::GotBuddyList()\n");
std::list<std::string>::iterator i;
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_CONTACT_LIST);
msg.AddString("protocol", kProtocolSignature);
for (i = buddies.begin(); i != buddies.end(); i++) {
LOG("Got server side buddy %s", i->c_str());
msg.AddString("id", i->c_str());
};
fServerMsgr->SendMessage(&msg);
}
void
Yahoo::GotContactsInfo(std::list<struct yahoo_buddy> & yabs)
{
LOG("Yahoo::GotContactsInfo()\n");
std::list<struct yahoo_buddy>::iterator i;
for (i = yabs.begin(); i != yabs.end(); i++) {
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_CONTACT_INFO);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", i->id);
msg.AddString("name", i->real_name);
fServerMsgr->SendMessage(&msg);
};
}
void
Yahoo::GotBuddyIcon(const char* who, long length, const char *icon)
{
/*
BMessage iconMsg(IM_MESSAGE);
iconMsg.AddInt32("im_what", IM_AVATAR_SET);
iconMsg.AddString("protocol", kProtocolSignature);
iconMsg.AddString("id", who);
//iconMsg.AddData("icondata", B_RAW_TYPE, icon, length);
iconMsg.AddData("avatar", NULL, icon, length);
fServerMsgr->SendMessage(&iconMsg);*/
}
void
Yahoo::BuddyStatusChanged(const char* who, int status, const char* mess, int away, int idle)
{
LOG("Yahoo::BuddyStatusChanged()\n");
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_STATUS_SET);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
switch(status) {
case YAHOO_STATUS_CUSTOM:
msg.AddString("message", mess);
if (away)
msg.AddInt32("status", CAYA_AWAY);
else
msg.AddInt32("status", CAYA_ONLINE);
break;
case YAHOO_STATUS_NOTATDESK:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_NOTINOFFICE:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_ONVACATION:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_BRB:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_OUTTOLUNCH:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_NOTATHOME:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_STEPPEDOUT:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_IDLE:
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_ONPHONE :
msg.AddInt32("status", CAYA_AWAY);
break;
case YAHOO_STATUS_OFFLINE :
msg.AddInt32("status", CAYA_OFFLINE);
break;
case YAHOO_STATUS_AVAILABLE :
msg.AddInt32("status", CAYA_ONLINE);
break;
default:
msg.AddInt32("status", CAYA_ONLINE);
break;
}
fServerMsgr->SendMessage(&msg);
}
void
Yahoo::Progress(const char* id, const char* message, float progress)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", IM_PROGRESS );
msg.AddString("protocol", kProtocolSignature);
msg.AddString("progressID", id);
msg.AddString("message", message);
msg.AddFloat("progress", progress);
msg.AddInt32("state", 11);
fServerMsgr->SendMessage(&msg);
}
void
Yahoo::TypeNotify(const char * who, int state)
{
BMessage msg(IM_MESSAGE);
msg.AddInt32("im_what", state ? IM_CONTACT_STARTED_TYPING : IM_CONTACT_STOPPED_TYPING);
msg.AddString("protocol", kProtocolSignature);
msg.AddString("id", who);
fServerMsgr->SendMessage( &msg );
}

72
protocols/yahoo/Yahoo.h Normal file
View File

@ -0,0 +1,72 @@
#ifndef CAYA_YAHOO_H
#define CAYA_YAHOO_H
#include <String.h>
#include <Messenger.h>
#include <CayaProtocol.h>
#include <CayaConstants.h>
#include <CayaProtocolMessages.h>
#include "YahooManager.h"
class YahooConnection;
class Yahoo : public CayaProtocol, public YahooManager
{
public:
Yahoo();
virtual ~Yahoo();
// Caya Protocol part begins here
// messenger to im_server
virtual status_t Init( CayaProtocolMessengerInterface* );
// called before unloading from memory
virtual status_t Shutdown();
// process message
virtual status_t Process( BMessage * );
// Get name of protocol
virtual const char * Signature() const;
virtual const char * FriendlySignature() const;
// settings changed
virtual status_t UpdateSettings( BMessage * );
// preferred encoding of messages
virtual uint32 GetEncoding();
virtual CayaProtocolMessengerInterface* MessengerInterface() const
{ return fServerMsgr; }
virtual uint32 Version() const;
// Caya Protocol part ends here
void Progress( const char * id, const char * message, float progress );
// YahooManager part begins here
virtual void Error( const char * message, const char * who );
virtual void GotMessage( const char * from, const char * msg );
virtual void MessageSent( const char * to, const char * msg );
virtual void LoggedIn();
virtual void SetAway(bool);
virtual void LoggedOut();
virtual void TypeNotify(const char * who,int stat);
virtual void GotBuddyList( std::list<std::string> & );
virtual void GotContactsInfo( std::list<struct yahoo_buddy> & );
virtual void GotBuddyIcon(const char *who, long size, const char* icon);
virtual void BuddyStatusChanged(const char * who, int status, const char* msg, int away, int idle);
// YahooManager part ends here
private:
CayaProtocolMessengerInterface* fServerMsgr;
BString fYahooID;
BString fPassword;
YahooConnection * fYahoo;
};
#endif

110
protocols/yahoo/Yahoo.rdef Normal file
View File

@ -0,0 +1,110 @@
resource app_signature "application/x-vnd.beclan.im_kit.yahoo.protocol";
resource app_version {
major = 0,
middle = 0,
minor = 0,
variety = B_APPV_ALPHA,
internal = 0,
short_info = "IM Kit Yahoo! protocol",
long_info = "IM Kit © 2003-2008 IM Kit Team"
};
resource app_flags B_EXCLUSIVE_LAUNCH | B_BACKGROUND_APP;
resource file_types message;
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
resource vector_icon {
$"6E6369660F02000602000000BC0FFE3C0FFE0000004A5C0048B00100FF6600FF"
$"CC330002000602000000BC10053C10050000004A5C0348AFF200CC3300FFFF66"
$"00020112023A78263CC6B03E7AF5BC34C94350CE454F63FFFF0000FFD7020006"
$"02000000BC0FFE3C0FFE0000004C05FF48200100FF6600FFCC33000200060200"
$"0000BC0DDA3C0DDA0000004C053048220D00CC3300FFFF660002011202B9C381"
$"3C92AB3A04E436F41D4ACEC641BCF3FFFF0000FFD7020006023B45363B4536BB"
$"45363B4536499D654B994E00FFCB66FFCC9900020006023B17F83B17F8BB17F8"
$"3B17F849B4064B8DFF00FFFF00FFFFCC33020006023A20AE3A20AEBA20AE3A20"
$"AE4A17D34B6FDF00FFCB99FFFF99000500020106033A40E10000000000003A40"
$"E14AA0004B800000FFCCCC74FF3300FF990000020016063B4000000000000000"
$"3B40004AA0004BAC00003319994CCCB2CCE599FF33020016063B57A700000000"
$"00003B57A74A9FFE4BA9E9006619CC4CFFB2FFE5CCFF660200060334C8E23669"
$"5CB6695C34C8E24AC96B4A5E46000066FFAA0066FFFF00FFFF0200120238E187"
$"3A7EB8BA7EB838E187499C094AD2C600FFD6FFFF00080A15422D492D49293A29"
$"3A2D3D2D3933312A352A35252225222A282A333633422C422C46434643423C42"
$"3C360A044C21552350424C4202044A3BBFD43BC7A33BCAB5C4BBCAB5C0D3CAB5"
$"C8A24A5EC7A35EBFD45EBCC3C4BBBCC3C8A2BCC3C0D30204C3B9C3EDC5C0C3EE"
$"C1B1C3EBBE6AC4CCBE91C3C2BE4DC5944AC9E9C022C9E9C755C9E9C90DC4CCC9"
$"2AC59DC8E6C3B802034AC9E9C098C9E9C6DFC9E953C65353C74F53C65341C653"
$"41C65341C7500205BE6AC4CCBE7CC42DBE5FC52FBEB4C61FBE78C5A0BEB4C61F"
$"C8C3C61FC8C3C61FC8FEC5A1C90DC4CCC917C52EC8FCC435C3B6C3EFC80CC3EF"
$"BF60C3EF02044FC059C547C059C62CC05951C18B51C0DF51C2364FC2BDC62CC2"
$"BDC547C2BD4DC18B4DC2364DC0DF02063A4E3AC7193AC17AC455BE5BC07BBE5B"
$"C61ABE5BC8F4C01BC7B9BF04C7ADBEAA4A3BC5CF3BBFE23BBCC3C4BBBCC3C0E1"
$"BCC3C6CEBF1CC9F3BDABC8ACBE05C8B8100A000100000A0101001001157F0004"
$"0A0201001001157E00040A030101000A0401011001157F00040A050101100115"
$"7E00040A0601021001178200040A070102000A0801031001178200040A090103"
$"000A0A0104000A0B01052020210A0C0105000A0D01062016200A0D0106000A0E"
$"010700"
};
#else // HAIKU_TARGET_PLATFORM_HAIKU
resource large_icon array {
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
};
resource mini_icon array {
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
$"FFFFFF00000000FFFFFFFFFFFFFFFFFF"
$"FFFFFF00FAFA0000FFFF0000000000FF"
$"FFFFFF0000FAFA00000000FAFA0000FF"
$"FFFFFFFF00FAFA0000FAFAFA0000FFFF"
$"FFFFFFFF0000FAFAFAFAFA0000FFFFFF"
$"FFFFFFFFFF00FAFAFA0000FFFFFFFFFF"
$"FFFFFFFFFF00FAFA0000FFFFFFFFFFFF"
$"FFFFFFFFFF00FAFA00FFFFFFFFFFFFFF"
$"FFFFFFFFFF00FAFA00FFFFFFFFFFFFFF"
$"FFFFFFFFFF00FAFA00FFFFFFFFFFFFFF"
$"FFFFFFFFFF00FA0000FFFFFFFFFFFFFF"
$"FFFFFFFFFF000000FFFFFFFFFFFFFFFF"
$"FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF"
};
#endif // HAIKU_TARGET_PLATFORM_HAIKU

View File

@ -0,0 +1,824 @@
/*
* Based on the sample client from libyahoo2. This is a plugin ported from im_kit to Caya,
* the code was updated to support libyahoo2.
*
* Copyright (C) 2002-2004, Philip S Tellis <philip.tellis AT gmx.net>
* Copyright (C) 2010-2011, Barrett
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "YahooConnection.h"
#include <netdb.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <termios.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <unistd.h>
#include <time.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include <openssl/ssl.h>
#include <assert.h>
#include "YahooConnection.h"
#include <yahoo2.h>
#include <yahoo2_callbacks.h>
#include <yahoo_util.h>
#include <yahoo2_types.h>
#define LOG printf
int fileno(FILE * stream);
#define MAX_PREF_LEN 255
static time_t curTime = 0;
static time_t pingTimer = 0;
extern "C" void register_callbacks();
typedef struct {
int id;
char *label;
} yahoo_idlabel;
typedef struct {
int id;
char *who;
} yahoo_authorize_data;
static int connection_tags=0;
struct connect_callback_data {
yahoo_connect_callback callback;
void * callback_data;
int id;
int tag;
};
yahoo_idlabel yahoo_status_codes[] = {
{YAHOO_STATUS_AVAILABLE, "Available"},
{YAHOO_STATUS_BRB, "BRB"},
{YAHOO_STATUS_BUSY, "Busy"},
{YAHOO_STATUS_NOTATHOME, "Not Home"},
{YAHOO_STATUS_NOTATDESK, "Not at Desk"},
{YAHOO_STATUS_NOTINOFFICE, "Not in Office"},
{YAHOO_STATUS_ONPHONE, "On Phone"},
{YAHOO_STATUS_ONVACATION, "On Vacation"},
{YAHOO_STATUS_OUTTOLUNCH, "Out to Lunch"},
{YAHOO_STATUS_STEPPEDOUT, "Stepped Out"},
{YAHOO_STATUS_INVISIBLE, "Invisible"},
{YAHOO_STATUS_IDLE, "Idle"},
{YAHOO_STATUS_OFFLINE, "Offline"},
{YAHOO_STATUS_CUSTOM, "[Custom]"},
{YPACKET_STATUS_NOTIFY, "Notify"},
{0, NULL}
};
#define YAHOO_DEBUGLOG ext_yahoo_log
static int expired(time_t timer)
{
if (timer && curTime >= timer)
return 1;
return 0;
}
static void rearm(time_t *timer, int seconds)
{
time(timer);
*timer += seconds;
}
static int yahoo_ping_timeout_callback(int id)
{
yahoo_keepalive(id);
rearm(&pingTimer, 600);
return 1;
}
FILE *popen(const char *command, const char *type);
int pclose(FILE *stream);
int gethostname(char *name, size_t len);
static int yahoo_ping_timeout_callback( int id, time_t & pingTimer )
{
yahoo_keepalive(id);
rearm(&pingTimer, 600);
return 1;
}
extern "C" int ext_yahoo_log(const char *fmt,...)
{
va_list ap;
va_start(ap, fmt);
vfprintf(stderr, fmt, ap);
fflush(stderr);
va_end(ap);
return 0;
}
extern "C" void ext_yahoo_got_conf_invite(int id, const char */*me*/, const char *who, const char *room, const char *msg, YList *members)
{
}
extern "C" void ext_yahoo_conf_userdecline(int /*id*/, const char */*me*/, const char */*who*/, const char */*room*/, const char */*msg*/)
{
}
extern "C" void ext_yahoo_conf_userjoin(int /*id*/, const char */*me*/, const char */*who*/, const char */*room*/)
{
}
extern "C" void ext_yahoo_conf_userleave(int /*id*/, const char */*me*/, const char */*who*/, const char */*room*/)
{
}
extern "C" void ext_yahoo_conf_message(int /*id*/, const char */*me*/, const char */*who*/, const char */*room*/, const char */*msg*/, int /*utf8*/)
{
}
extern "C" void ext_yahoo_chat_cat_xml(int /*id*/, const char */*xml*/)
{
}
extern "C" void ext_yahoo_chat_join(int id, const char *me, const char *room, const char *topic, YList *members, void *fd)
{
}
extern "C" void ext_yahoo_chat_userjoin(int id, const char *me, const char* room, struct yahoo_chat_member */*who*/)
{
}
extern "C" void ext_yahoo_chat_userleave(int id, const char *me, const char *room, const char *who)
{
}
extern "C" void ext_yahoo_chat_message(int /*id*/, const char */*me*/, const char */*who*/, const char */*room*/, const char */*msg*/, int /*msgtype*/, int /*utf8*/)
{
LOG("ext_yahoo_chat_message\n");
}
extern "C" void ext_yahoo_status_changed(int id, const char *who, int stat, const char *msg, int away, int idle, int /*mobile*/)
{
LOG("ext_yahoo_status_changed\n");
assert(gYahooConnections[id] != NULL);
gYahooConnections[id]->cbStatusChanged(who, stat, msg, away, idle);
}
extern "C" void ext_yahoo_got_buddies(int id, YList * buds)
{
LOG("ext_yahoo_got_buddies\n");
assert( gYahooConnections[id] != NULL );
gYahooConnections[id]->cbGotBuddies(buds);
}
extern "C" void ext_yahoo_got_ignore(int /*id*/, YList * /*igns*/)
{
}
extern "C" void ext_yahoo_got_im(int id,const char* /*me*/, const char *who, const char *msg, long tm, int stat, int utf8)
{
LOG("ext_yahoo_got_im\n");
assert( gYahooConnections[id] != NULL );
gYahooConnections[id]->cbGotIM(who,msg,tm,stat,utf8);
}
extern "C" void ext_yahoo_rejected(int /*id*/, const char */*who*/, const char */*msg*/)
{
}
extern "C" void ext_yahoo_contact_added(int id, const char */*myid*/, const char *who, const char *msg)
{
}
extern "C" void ext_yahoo_typing_notify(int id, const char */*me*/, const char *who, int stat)
{
assert( gYahooConnections[id] != NULL );
gYahooConnections[id]->cbTypeNotify(who,stat);
}
extern "C" void ext_yahoo_game_notify(int id, const char *me, const char *who, int stat, const char *msg)
{
}
extern "C" void ext_yahoo_mail_notify(int id, const char *from, const char *subj, int cnt)
{
}
extern "C" void ext_yahoo_got_buddyicon(int id, const char */*me*/, const char *who, const char *url, int checksum)
{
// yahoo_http_get(id,url,NULL, 0 , 0, NULL,(void*)who);
}
extern "C" void ext_yahoo_got_buddyicon_checksum(int id, const char */*me*/,const char *who, int /*checksum*/)
{
//yahoo_buddyicon_request(id,who);
}
extern "C" void ext_yahoo_got_buddyicon_request(int id, const char */*me*/, const char *who)
{
}
extern "C" void ext_yahoo_buddyicon_uploaded(int id, const char *url)
{
}
extern "C" void ext_yahoo_got_webcam_image(int /*id*/, const char */*who*/,
const unsigned char */*image*/, unsigned int /*image_size*/, unsigned int /*real_size*/,
unsigned int /*timestamp*/)
{
}
extern "C" void ext_yahoo_webcam_viewer(int /*id*/, const char */*who*/, int /*connect*/)
{
}
extern "C" void ext_yahoo_webcam_closed(int /*id*/, const char */*who*/, int /*reason*/)
{
}
extern "C" void ext_yahoo_webcam_data_request(int /*id*/, int /*send*/)
{
}
extern "C" void ext_yahoo_webcam_invite(int /*id*/, const char */*me*/, const char */*from*/)
{
}
extern "C" void ext_yahoo_webcam_invite_reply(int /*id*/, const char */*me*/, const char */*from*/, int /*accept*/)
{
}
extern "C" void ext_yahoo_system_message(int id, const char *me, const char *who, const char *msg)
{
LOG("%s\n",msg);
}
extern "C" void ext_yahoo_got_file(int id, const char *me, const char *who, const char *msg, const char *fname, unsigned long fesize, char *trid)
{
}
extern "C" void ext_yahoo_got_identities(int /*id*/, YList * /*ids*/)
{
}
extern "C" void ext_yahoo_chat_yahoologout(int /*id*/, const char */*me*/)
{
}
extern "C" void ext_yahoo_chat_yahooerror(int /*id*/, const char */*me*/)
{
}
extern "C" void ext_yahoo_got_search_result(int /*id*/, int /*found*/, int /*start*/, int /*total*/, YList */*contacts*/)
{
}
extern "C" void ext_yahoo_got_cookies(int id)
{
assert( gYahooConnections[id] != NULL );
yahoo_get_yab(id);
}
extern "C" void ext_yahoo_login_response(int id, int succ, const char *url)
{
LOG("ext_yahoo_login_response %d\n", id);
assert( gYahooConnections[id] != NULL );
gYahooConnections[id]->cbLoginResponse(succ,url);
}
extern "C" void ext_yahoo_error(int id, const char *err, int fatal, int /*num*/)
{
LOG("ext_yahoo_error\n");
assert( gYahooConnections[id] != NULL );
gYahooConnections[id]->cbYahooError(err,fatal);
}
extern "C" void ext_yahoo_got_ping(int /*id*/, const char */*errormsg*/)
{
}
extern "C" int ext_yahoo_add_handler(int id, void *d, yahoo_input_condition cond, void *data)
{
LOG("ext_yahoo_add_handler %d\n", id);
if (id < 0) { // 'connect' connection
struct conn_handler *c = y_new0(struct conn_handler, 1);
c->tag = ++connection_tags;
c->id = id;
c->con = (_conn*) d;
c->cond = cond;
c->data = data;
return c->tag;
}
assert( gYahooConnections[id] != NULL );
struct conn_handler* c = y_new0(struct conn_handler, 1);
c->tag = ++connection_tags;
c->id = id;
c->con = (_conn*) d;
c->cond = cond;
c->data = data;
LOG("Add fd %p for %d, tag %d, cond %d\n", c->con->fd, id, c->tag, c->cond);
gYahooConnections[id]->AddConnection( c );
return c->tag;
}
extern "C" void ext_yahoo_remove_handler(int id, int tag)
{
LOG("ext_yahoo_remove_handler %d\n", id);
if (!tag)
return;
assert(gYahooConnections[id] != NULL);
YahooConnection * conn = gYahooConnections[id];
for (int i=0; i < conn->CountConnections(); i++) {
struct conn_handler *c = conn->ConnectionAt(i);
if(c->tag == tag) {
/* don't actually remove it, just mark it for removal */
/* we'll remove when we start the next poll cycle */
LOG(" Marking id:%d con:%p tag:%d for removal\n", c->id, c->con, c->tag);
c->remove = 1;
return;
}
}
}
extern "C" int ext_yahoo_connect(const char *host, int port)
{
//deprecated
return -1;
}
static int ext_yahoo_write(void *fd, char *buf, int len)
{
LOG("ext_yahoo_write\n");
struct _conn *c = (_conn*)fd;
if (c->use_ssl)
return SSL_write(c->ssl, buf, len);
else
return write(c->fd, buf, len);
}
static int ext_yahoo_read(void *fd, char *buf, int len)
{
LOG("ext_yahoo_read\n");
struct _conn *c = (_conn*)fd;
if (c->use_ssl)
return SSL_read(c->ssl, buf, len);
else
return read(c->fd, buf, len);
}
static void ext_yahoo_close(void *fd)
{
LOG("ext_yahoo_close\n");
struct _conn *c = (_conn*)fd;
if (c->use_ssl)
SSL_free(c->ssl);
close(c->fd);
c->fd = 0;
std::map<int, YahooConnection*>::iterator it;
int h = 0;
for (it = gYahooConnections.begin(); it != gYahooConnections.end(); it++) {
int i = 0;
if (it->second == NULL)
continue;
int count = it->second->CountConnections();
while (i < count) {
if (it->second->ConnectionAt(i)->con == c) {
it->second->ConnectionAt(i)->remove = 1;
}
i++;
}
}
c->remove = 1;
}
static SSL *do_ssl_connect(int fd)
{
SSL *ssl;
SSL_CTX *ctx;
LOG("SSL Handshake\n");
SSL_library_init ();
ctx = SSL_CTX_new(SSLv23_client_method());
ssl = SSL_new(ctx);
SSL_CTX_free(ctx);
SSL_set_fd(ssl, fd);
if (SSL_connect(ssl) == 1)
return ssl;
return NULL;
}
extern "C" int ext_yahoo_connect_async(int id, const char *host, int port,
yahoo_connect_callback callback, void *data, int use_ssl)
{
struct sockaddr_in serv_addr;
static struct hostent *server;
int servfd;
struct connect_callback_data * ccd;
int error;
SSL *ssl = NULL;
struct _conn *c;
LOG("Connecting to %s:%d\n", host, port);
if (!(server = gethostbyname(host))) {
errno=h_errno;
return -1;
}
if ((servfd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
return -1;
}
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
memcpy(&serv_addr.sin_addr.s_addr, *server->h_addr_list, server->h_length);
serv_addr.sin_port = htons(port);
c = y_new0(struct _conn, 1);
c->fd = servfd;
c->use_ssl = use_ssl;
error = connect(servfd, (struct sockaddr *) &serv_addr, sizeof(serv_addr));
LOG("Trying to connect: fd:%d error:%d\n", servfd, error);
if (!error) {
LOG("Connected\n");
if (use_ssl) {
ssl = do_ssl_connect(servfd);
if (!ssl) {
LOG("SSL Handshake Failed!\n");
ext_yahoo_close(c);
callback(NULL, 0, data);
return -1;
}
}
c->ssl = ssl;
fcntl(c->fd, F_SETFL, O_NONBLOCK);
callback(c, 0, data);
return 0;
} else if (error == -1 && errno == EINPROGRESS) {
ccd = (connect_callback_data*) calloc(1, sizeof(struct connect_callback_data));
ccd->callback = callback;
ccd->callback_data = data;
ccd->id = id;
ccd->tag = ext_yahoo_add_handler(-1, c, YAHOO_INPUT_WRITE, ccd);
return ccd->tag;
} else {
if(error == -1)
LOG("Connection failure: %s\n", strerror(errno));
ext_yahoo_close(c);
callback(NULL, errno, data);
return -1;
}
}
/*************************************
* Callback handling code starts here
*/
void cb_yahoo_url_handle(int id, int fd, int error, const char */*filename*/, unsigned long size, void *data)
{
const char *who = (const char*)data;
char byte;
BString buff;
unsigned long count = 0;
while (count <= size) {
read(fd,&byte,1);
count++;
buff << byte;
}
assert( gYahooConnections[id] != NULL );
LOG(buff.String());
gYahooConnections[id]->cbGotBuddyIcon(who,size,buff.String());
}
static void connect_complete(void *data, struct _conn *source, yahoo_input_condition condition)
{
struct connect_callback_data *ccd = (connect_callback_data *)data;
int error, err_size = sizeof(error);
ext_yahoo_remove_handler(0, ccd->tag);
getsockopt(source->fd, SOL_SOCKET, SO_ERROR, &error, (socklen_t *)&err_size);
// TODO remove this
if(error)
goto err;
LOG("Connected fd: %d, error: %d", source->fd, error);
if (source->use_ssl) {
source->ssl = do_ssl_connect(source->fd);
if (!source->ssl) {
err:
LOG("SSL Handshake Failed!\n");
ext_yahoo_close(source);
ccd->callback(NULL, 0, ccd->callback_data);
free(ccd);
return;
}
}
fcntl(source->fd, F_SETFL, O_NONBLOCK);
ccd->callback(source, error, ccd->callback_data);
free(ccd);
}
void yahoo_callback(struct conn_handler *c, yahoo_input_condition cond)
{
LOG("yahoo_callback\n");
int ret=1;
char buff[1024]={0};
if(c->id < 0) {
connect_complete(c->data, c->con, cond);
} else {
if(cond & YAHOO_INPUT_READ)
ret = yahoo_read_ready(c->id, c->con, c->data);
if(ret>0 && cond & YAHOO_INPUT_WRITE)
ret = yahoo_write_ready(c->id, c->con, c->data);
if(ret == -1)
snprintf(buff, sizeof(buff),
"Yahoo read error (%d): %s", errno, strerror(errno));
else if(ret == 0)
snprintf(buff, sizeof(buff),
"Yahoo read error: Server closed socket");
if(buff[0])
LOG((buff));
}
}
static void ext_yahoo_got_buzz(int id, const char *me, const char *who, long tm)
{
LOG("ext_yahoo_got_buzz()\n");
}
static void ext_yahoo_got_ft_data(int id, const unsigned char *in, int count, void *data)
{
LOG("ext_yahoo_got_ft_data\n");
}
static char *ext_yahoo_get_ip_addr(const char *domain)
{
LOG("ext_yahoo_get_ip_addr()\n");
return NULL;
}
static void ext_yahoo_file_transfer_done(int id, int response, void *data)
{
}
static void ext_yahoo_got_buddy_change_group(int id, const char *me, const char *who,
const char *old_group, const char *new_group)
{
}
/*
* Callback handling code ends here
***********************************/
static char * get_local_addresses()
{
static char addresses[1024];
char buff[1024];
struct hostent * hn;
gethostname(buff,sizeof(buff));
hn = gethostbyname(buff);
if(hn)
strncpy(addresses, inet_ntoa( *((struct in_addr*)hn->h_addr)), sizeof(addresses) );
else
addresses[0] = 0;
return addresses;
}
int32
yahoo_io_thread( void * _data )
{
YahooConnection * conn = (YahooConnection*)_data;
register_callbacks();
conn->fID = yahoo_init_with_attributes(conn->fYahooID, conn->fPassword,
"local_host", "95.252.70.62",
"pager_port", 5050, NULL);
LOG("yahoo_io_thread: id: %s, pass: %s\n", conn->fYahooID, conn->fPassword );
gYahooConnections[conn->fID] = conn;
yahoo_login(conn->fID, YAHOO_STATUS_AVAILABLE);
int lfd = 0;
fd_set inp, outp;
struct timeval tv;
while (conn->IsAlive()) {
snooze(10000);
FD_ZERO(&inp);
FD_ZERO(&outp);
tv.tv_sec=3;
tv.tv_usec=1E4;
lfd=0;
int i;
for(i = 0; i < conn->CountConnections(); i++) {
struct conn_handler *c = conn->ConnectionAt(i);
if(c->remove) {
conn->RemoveConnection(c);
c->remove = 0;
free(c);
} else {
if(c->cond & YAHOO_INPUT_READ)
FD_SET(c->con->fd, &inp);
if(c->cond & YAHOO_INPUT_WRITE)
FD_SET(c->con->fd, &outp);
if(lfd < c->con->fd)
lfd = c->con->fd;
}
}
select(lfd + 1, &inp, &outp, NULL, &tv);
time(&curTime);
for(i = 0; i < conn->CountConnections(); i++) {
struct conn_handler *c = conn->ConnectionAt(i);
if(c->con->remove) {
free(c->con);
c->con = NULL;
break;
}
if(c->remove)
continue;
if(FD_ISSET(c->con->fd, &inp))
yahoo_callback(c, YAHOO_INPUT_READ);
if(FD_ISSET(c->con->fd, &outp))
yahoo_callback(c, YAHOO_INPUT_WRITE);
}
if(expired(pingTimer))
yahoo_ping_timeout_callback(conn->fID);
// if(expired(webcamTimer)) yahoo_webcam_timeout_callback(webcam_id);
}
LOG("Exited loop");
for(int i = 0; i < conn->CountConnections(); i++) {
struct conn_handler *c = conn->ConnectionAt(i);
free(c);
conn->RemoveConnection(c);
}
return 0;
}
extern "C" void register_callbacks()
{
static struct yahoo_callbacks yc;
yc.ext_yahoo_login_response = ext_yahoo_login_response;
yc.ext_yahoo_got_buddies = ext_yahoo_got_buddies;
yc.ext_yahoo_got_ignore = ext_yahoo_got_ignore;
yc.ext_yahoo_got_identities = ext_yahoo_got_identities;
yc.ext_yahoo_got_cookies = ext_yahoo_got_cookies;
yc.ext_yahoo_status_changed = ext_yahoo_status_changed;
yc.ext_yahoo_got_im = ext_yahoo_got_im;
yc.ext_yahoo_got_buzz = ext_yahoo_got_buzz;
yc.ext_yahoo_got_conf_invite = ext_yahoo_got_conf_invite;
yc.ext_yahoo_conf_userdecline = ext_yahoo_conf_userdecline;
yc.ext_yahoo_conf_userjoin = ext_yahoo_conf_userjoin;
yc.ext_yahoo_conf_userleave = ext_yahoo_conf_userleave;
yc.ext_yahoo_conf_message = ext_yahoo_conf_message;
yc.ext_yahoo_chat_cat_xml = ext_yahoo_chat_cat_xml;
yc.ext_yahoo_chat_join = ext_yahoo_chat_join;
yc.ext_yahoo_chat_userjoin = ext_yahoo_chat_userjoin;
yc.ext_yahoo_chat_userleave = ext_yahoo_chat_userleave;
yc.ext_yahoo_chat_message = ext_yahoo_chat_message;
yc.ext_yahoo_chat_yahoologout = ext_yahoo_chat_yahoologout;
yc.ext_yahoo_chat_yahooerror = ext_yahoo_chat_yahooerror;
yc.ext_yahoo_got_webcam_image = ext_yahoo_got_webcam_image;
yc.ext_yahoo_webcam_invite = ext_yahoo_webcam_invite;
yc.ext_yahoo_webcam_invite_reply = ext_yahoo_webcam_invite_reply;
yc.ext_yahoo_webcam_closed = ext_yahoo_webcam_closed;
yc.ext_yahoo_webcam_viewer = ext_yahoo_webcam_viewer;
yc.ext_yahoo_webcam_data_request = ext_yahoo_webcam_data_request;
yc.ext_yahoo_got_file = ext_yahoo_got_file;
yc.ext_yahoo_got_ft_data = ext_yahoo_got_ft_data;
yc.ext_yahoo_get_ip_addr = ext_yahoo_get_ip_addr;
yc.ext_yahoo_file_transfer_done = ext_yahoo_file_transfer_done;
yc.ext_yahoo_contact_added = ext_yahoo_contact_added;
yc.ext_yahoo_rejected = ext_yahoo_rejected;
yc.ext_yahoo_typing_notify = ext_yahoo_typing_notify;
yc.ext_yahoo_game_notify = ext_yahoo_game_notify;
yc.ext_yahoo_mail_notify = ext_yahoo_mail_notify;
yc.ext_yahoo_got_search_result = ext_yahoo_got_search_result;
yc.ext_yahoo_system_message = ext_yahoo_system_message;
yc.ext_yahoo_error = ext_yahoo_error;
yc.ext_yahoo_log = ext_yahoo_log;
yc.ext_yahoo_add_handler = ext_yahoo_add_handler;
yc.ext_yahoo_remove_handler = ext_yahoo_remove_handler;
yc.ext_yahoo_connect = ext_yahoo_connect;
yc.ext_yahoo_connect_async = ext_yahoo_connect_async;
yc.ext_yahoo_read = ext_yahoo_read;
yc.ext_yahoo_write = ext_yahoo_write;
yc.ext_yahoo_close = ext_yahoo_close;
yc.ext_yahoo_got_buddyicon = ext_yahoo_got_buddyicon;
yc.ext_yahoo_got_buddyicon_checksum = ext_yahoo_got_buddyicon_checksum;
yc.ext_yahoo_buddyicon_uploaded = ext_yahoo_buddyicon_uploaded;
yc.ext_yahoo_got_buddyicon_request = ext_yahoo_got_buddyicon_request;
yc.ext_yahoo_got_ping = ext_yahoo_got_ping;
yc.ext_yahoo_got_buddy_change_group = ext_yahoo_got_buddy_change_group;
yahoo_register_callbacks(&yc);
}

View File

@ -0,0 +1,292 @@
/*
* This is a plugin ported from im_kit to Caya,
* the code was updated to support libyahoo2.
*
* Copyright (C) 2010-2011, Barrett
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "YahooConnection.h"
#include <stdio.h>
#include <algorithm>
#include "CayaConstants.h"
#include <yahoo2.h>
#include "yahoo_util.h"
std::map<int, YahooConnection*> gYahooConnections;
YahooConnection::YahooConnection(YahooManager* mgr, const char* yahooID, const char* pass)
:
fManager(mgr),
fID(-1),
fYahooID(strdup(yahooID)),
fPassword(strdup(pass)),
fStatus(YAHOO_STATUS_OFFLINE),
fAlive(true),
fGotBuddyList(false)
{
fThread = spawn_thread(
yahoo_io_thread,
"Yahoo IO",
B_NORMAL_PRIORITY,
this
);
resume_thread( fThread );
}
YahooConnection::~YahooConnection()
{
LogOff();
fAlive = false;
int32 thread_res=0;
wait_for_thread(fThread, &thread_res);
free(fYahooID);
free(fPassword);
}
void
YahooConnection::SetAway(enum yahoo_status state, const char *msg)
{
if (fStatus == YAHOO_STATUS_OFFLINE) {
fManager->Error("Calling SetAway() when offline", NULL);
return;
}
yahoo_set_away(fID, state, msg, 1);
//fManager->SetAway(state, msg);
}
void
YahooConnection::LogOff()
{
if (fID < 0)
return;
yahoo_logoff(fID);
fStatus = YAHOO_STATUS_OFFLINE;
fID = -1;
fManager->LoggedOut();
// owner should delete us now to stop the thread and clean up
}
void
YahooConnection::Message(const char* who, const char* msg)
{
if (fStatus == YAHOO_STATUS_OFFLINE) {
fManager->Error( "Can't send message, not connected", who );
return;
}
yahoo_send_im(
fID,
NULL /* default identity */,
who,
msg,
1 /* it's utf-8 */,
0
);
fManager->MessageSent( who, msg );
}
void
YahooConnection::AddBuddy(const char* who)
{
if (!fGotBuddyList) {
fBuddiesToAdd.push_back( who );
return;
}
std::list<std::string>::iterator iter = find( fBuddies.begin(), fBuddies.end(), who );
if (iter == fBuddies.end()) { // not in list, adding
yahoo_add_buddy(fID, who, "Communicator", "");
fBuddies.push_back(who);
printf("Yahoo: Added buddy\n");
}
}
void
YahooConnection::RemoveBuddy( const char* who )
{
if (fStatus == YAHOO_STATUS_OFFLINE) {
fManager->Error("Not connected when calling YahooConnection::RemoveBuddy()", NULL);
return;
}
yahoo_remove_buddy( fID, who, "" );
}
void
YahooConnection::Typing(const char* who, int stat )
{
yahoo_send_typing(fID,NULL,who,stat);
}
void
YahooConnection::GetBuddyIcon(const char* who)
{
yahoo_buddyicon_request(fID, who);
}
void
YahooConnection::cbStatusChanged(const char* who, int stat, const char* msg, int away, int idle)
{
fManager->BuddyStatusChanged(who, stat, msg, away, idle);
}
void
YahooConnection::cbGotBuddies(YList* buds)
{
fGotBuddyList = true;
std::list<struct yahoo_buddy> yabs;
// copy from buds to buddies...
for(; buds; buds = buds->next) {
struct yahoo_buddy* bud = (struct yahoo_buddy* )buds->data;
if (bud->real_name)
yabs.push_back( *bud );
fBuddies.push_back( bud->id );
//yahoo_buddyicon_request(fID, bud->id);
}
printf("id %d\n", fID);
// add waiting buddies
for ( std::list<std::string>::iterator iter=fBuddiesToAdd.begin();
iter != fBuddiesToAdd.end(); iter++) {
AddBuddy( (*iter).c_str() );
}
fBuddiesToAdd.clear();
// Tell the manager!
fManager->GotBuddyList( fBuddies );
fManager->GotContactsInfo( yabs );
}
void
YahooConnection::cbGotIM(const char* who, const char* msg, long /*tm*/, int /*stat*/, int /*utf8*/)
{
//parse_html(msg);
fManager->GotMessage( who, msg );
}
void
YahooConnection::cbTypeNotify(const char* who, int stat)
{
fManager->TypeNotify( who, stat );
}
void
YahooConnection::cbGotBuddyIcon(const char* who, long size, const char* icon)
{
fManager->GotBuddyIcon(who,size,icon);
}
void
YahooConnection::cbLoginResponse(int succ, const char* url)
{
printf("YahooConnection::cbLoginResponse %s\n", url);
if(succ == YAHOO_LOGIN_OK) {
fStatus = yahoo_current_status(fID);
fManager->LoggedIn();
return;
} else if(succ == YAHOO_LOGIN_UNAME) {
fManager->Error("Could not log into Yahoo service - username not recognised. Please verify that your username is correctly typed.", NULL);
} else if(succ == YAHOO_LOGIN_PASSWD) {
fManager->Error("Could not log into Yahoo service - password incorrect. Please verify that your password is correctly typed.", NULL);
} else if(succ == YAHOO_LOGIN_LOCK) {
fManager->Error("Could not log into Yahoo service. Your account has been locked.\nVisit [url] to reactivate it.\n", NULL);
} else if(succ == YAHOO_LOGIN_DUPL) {
fManager->Error("You have been logged out of the yahoo service, possibly due to a duplicate login.", NULL);
} else if(succ == YAHOO_LOGIN_SOCK) {
fManager->Error("The server closed the socket.", NULL);
} else {
fManager->Error("Could not log in, unknown reason.", NULL);
}
fStatus = YAHOO_STATUS_OFFLINE;
LogOff();
}
void
YahooConnection::cbYahooError( const char* err, int fatal)
{
fManager->Error( err, NULL );
if (fatal) {
LogOff();
}
}
void
YahooConnection::AddConnection( conn_handler* c )
{
fConnections.AddItem(c);
}
void
YahooConnection::RemoveConnection( conn_handler* c )
{
fConnections.RemoveItem(c);
}
conn_handler*
YahooConnection::ConnectionAt( int i )
{
return (conn_handler*)fConnections.ItemAt(i);
}
int
YahooConnection::CountConnections()
{
return fConnections.CountItems();
}
bool
YahooConnection::IsAlive()
{
return fAlive;
}

View File

@ -0,0 +1,111 @@
/*
* This is a plugin ported from im_kit to Caya,
* the code was updated to support libyahoo2.
* Copyright (C) 2010-2011, Barrett
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#ifndef YAHOO_CONNECTION_H
#define YAHOO_CONNECTION_H
#include <map>
#include <OS.h>
#include <yahoo2.h>
#include <yahoo2_callbacks.h>
#include <List.h>
#include <String.h>
#include <openssl/ssl.h>
#include "YahooManager.h"
struct _conn {
int fd;
SSL *ssl;
int use_ssl;
int remove;
};
struct conn_handler {
struct _conn *con;
int id;
int tag;
yahoo_input_condition cond;
void *data;
int remove;
};
class YahooConnection
{
public:
YahooConnection(YahooManager *, const char *, const char *);
~YahooConnection();
void SetAway(enum yahoo_status state, const char* msg);
void LogOff();
void Message(const char* who, const char* msg);
// Call this to add new contacts, but only after having received the
// buddy list so we don't double-add contacts
void AddBuddy(const char* who);
void RemoveBuddy( const char * who);
void Typing(const char*, int);
void GetBuddyIcon(const char* who);
// Stuff below this is for use by the yahoo lib interface only.
// I could make it protected and add all them functions as friends,
// but that'd be boring. Will do it 'later'.
void cbStatusChanged(const char* who, int stat,
const char* msg, int away, int idle);
void cbGotBuddies(YList* buds);
void cbGotIM(const char* who, const char* msg, long tm, int stat, int utf8);
void cbLoginResponse(int succ, const char* url);
void cbYahooError(const char* err, int fatal);
void cbTypeNotify(const char* who, int stat);
void cbGotBuddyIcon(const char* who, long size, const char* icon);
void AddConnection(conn_handler*);
void RemoveConnection(conn_handler*);
conn_handler* ConnectionAt(int i);
int CountConnections();
private:
friend int32 yahoo_io_thread(void *);
YahooManager * fManager;
int fID;
char* fYahooID;
char* fPassword;
int fStatus;
thread_id fThread;
bool fAlive;
bool IsAlive();
BList fConnections;
std::list<std::string> fBuddies;
std::list<std::string> fBuddiesToAdd;
bool fGotBuddyList;
};
extern std::map<int, YahooConnection*> gYahooConnections;
extern void cb_yahoo_url_handle(int id, int fd, int error, const char *filename, unsigned long size, void *data);
extern int32 yahoo_io_thread( void * _data );
extern const char * kProtocolName;
#endif

View File

@ -0,0 +1,33 @@
#ifndef YAHOO_MANAGER_H
#define YAHOO_MANAGER_H
#include <list>
#include <string>
#include <yahoo2_types.h>
/**
*/
class YahooManager
{
public:
// who can be NULL if it's a general message
virtual void Error(const char * message, const char * who)=0;
virtual void GotMessage(const char * from, const char * msg)=0;
virtual void MessageSent(const char * to, const char * msg)=0;
virtual void LoggedIn()=0;
virtual void SetAway(bool)=0;
virtual void LoggedOut()=0;
virtual void TypeNotify(const char * who,int stat)=0;
virtual void GotBuddyList(std::list<std::string> &)=0;
virtual void GotContactsInfo(std::list<struct yahoo_buddy> &)=0;
virtual void GotBuddyIcon(const char *who, long size, const char* icon)=0;
virtual void BuddyStatusChanged(const char * who, int status, const char* msg, int away, int idle)=0;
};
#endif