From dad78a8c803a334d606077aaa91600eb88f1fb62 Mon Sep 17 00:00:00 2001 From: Karl Chen Date: Sat, 29 Nov 2003 07:56:53 +0000 Subject: [PATCH] base64 svn path=/trunk/boinc/; revision=2717 --- checkin_notes | 9 +++ lib/Makefile.am | 7 +- lib/Makefile.in | 121 +++++++++++++++++---------------- lib/base64.C | 176 ++++++++++++++++++++++++++++++++++++++++++++++++ lib/parse.h | 7 ++ 5 files changed, 258 insertions(+), 62 deletions(-) create mode 100644 lib/base64.C diff --git a/checkin_notes b/checkin_notes index 5296a0bad1..dba9ae64bb 100755 --- a/checkin_notes +++ b/checkin_notes @@ -7955,3 +7955,12 @@ David 28 Nov 2003 client/ cs_files.C + +Karl 2003-11-28 + - new base64_encode() and base64_decode() functions. + - small fixes to Makefiles + + lib/ + parse.h + base64.C (new) + Makefile.am diff --git a/lib/Makefile.am b/lib/Makefile.am index b76927cd6b..3e08a16bcb 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -2,8 +2,8 @@ include $(top_srcdir)/Makefile.incl -bin_PROGRAMS = md5_test shmem_test crypt_prog -EXTRA_PROGRAMS = msg_test synch_test +bin_PROGRAMS = crypt_prog +EXTRA_PROGRAMS = md5_test shmem_test msg_test synch_test noinst_LIBRARIES = libboinc.a #libboinc_graphics.a EXTRA_DIST = result_state.h @@ -13,7 +13,8 @@ libboinc_a_SOURCES = \ ../api/mfile.C \ app_ipc.C \ parse.C \ - xml_util.C \ + base64.C \ + xml_util.C \ filesys.C \ language.C \ util.C \ diff --git a/lib/Makefile.in b/lib/Makefile.in index 59795d5dab..aea3ea6b38 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,7 +1,7 @@ -# Makefile.in generated by automake 1.7 from Makefile.am. +# Makefile.in generated by automake 1.7.9 from Makefile.am. # @configure_input@ -# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002 +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003 # Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, @@ -113,6 +113,7 @@ 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@ bindir = @bindir@ build = @build@ @@ -170,8 +171,8 @@ AM_CPPFLAGS = \ # programs linking to it: LIBRSA = $(top_builddir)/RSAEuro/source/librsaeuro.a -bin_PROGRAMS = md5_test shmem_test crypt_prog -EXTRA_PROGRAMS = msg_test synch_test +bin_PROGRAMS = crypt_prog +EXTRA_PROGRAMS = md5_test shmem_test msg_test synch_test noinst_LIBRARIES = libboinc.a #libboinc_graphics.a EXTRA_DIST = result_state.h @@ -181,7 +182,8 @@ libboinc_a_SOURCES = \ ../api/mfile.C \ app_ipc.C \ parse.C \ - xml_util.C \ + base64.C \ + xml_util.C \ filesys.C \ language.C \ util.C \ @@ -215,6 +217,7 @@ crypt_prog_SOURCES = crypt_prog.C crypt.C md5.c md5_file.C crypt_prog_DEPENDENCIES = $(LIBRSA) crypt_prog_LDADD = $(RSA_LIBS) subdir = lib +ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = @@ -223,12 +226,13 @@ LIBRARIES = $(noinst_LIBRARIES) libboinc_a_AR = $(AR) cru libboinc_a_LIBADD = am_libboinc_a_OBJECTS = boinc_api.$(OBJEXT) mfile.$(OBJEXT) \ - app_ipc.$(OBJEXT) parse.$(OBJEXT) xml_util.$(OBJEXT) \ - filesys.$(OBJEXT) language.$(OBJEXT) util.$(OBJEXT) \ - md5.$(OBJEXT) md5_file.$(OBJEXT) shmem.$(OBJEXT) + app_ipc.$(OBJEXT) parse.$(OBJEXT) base64.$(OBJEXT) \ + xml_util.$(OBJEXT) filesys.$(OBJEXT) language.$(OBJEXT) \ + util.$(OBJEXT) md5.$(OBJEXT) md5_file.$(OBJEXT) shmem.$(OBJEXT) libboinc_a_OBJECTS = $(am_libboinc_a_OBJECTS) -EXTRA_PROGRAMS = msg_test$(EXEEXT) synch_test$(EXEEXT) -bin_PROGRAMS = md5_test$(EXEEXT) shmem_test$(EXEEXT) crypt_prog$(EXEEXT) +EXTRA_PROGRAMS = md5_test$(EXEEXT) shmem_test$(EXEEXT) msg_test$(EXEEXT) \ + synch_test$(EXEEXT) +bin_PROGRAMS = crypt_prog$(EXEEXT) PROGRAMS = $(bin_PROGRAMS) am_crypt_prog_OBJECTS = crypt_prog.$(OBJEXT) crypt.$(OBJEXT) \ @@ -260,16 +264,16 @@ synch_test_LDFLAGS = DEFAULT_INCLUDES = -I. -I$(srcdir) -I$(top_builddir) depcomp = $(SHELL) $(top_srcdir)/depcomp am__depfiles_maybe = depfiles -@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/app_ipc.Po ./$(DEPDIR)/boinc_api.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/crypt.Po ./$(DEPDIR)/crypt_prog.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/filesys.Po ./$(DEPDIR)/language.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/md5.Po ./$(DEPDIR)/md5_file.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/md5_test.Po ./$(DEPDIR)/mfile.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/msg_queue.Po ./$(DEPDIR)/msg_test.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/parse.Po ./$(DEPDIR)/shmem.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/shmem_test.Po ./$(DEPDIR)/synch.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/synch_test.Po ./$(DEPDIR)/util.Po \ -@AMDEP_TRUE@ ./$(DEPDIR)/xml_util.Po +@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/app_ipc.Po ./$(DEPDIR)/base64.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/boinc_api.Po ./$(DEPDIR)/crypt.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/crypt_prog.Po ./$(DEPDIR)/filesys.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/language.Po ./$(DEPDIR)/md5.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/md5_file.Po ./$(DEPDIR)/md5_test.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/mfile.Po ./$(DEPDIR)/msg_queue.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/msg_test.Po ./$(DEPDIR)/parse.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/shmem.Po ./$(DEPDIR)/shmem_test.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/synch.Po ./$(DEPDIR)/synch_test.Po \ +@AMDEP_TRUE@ ./$(DEPDIR)/util.Po ./$(DEPDIR)/xml_util.Po CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \ $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) CXXLD = $(CXX) @@ -282,7 +286,8 @@ LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ DIST_SOURCES = $(libboinc_a_SOURCES) $(crypt_prog_SOURCES) \ $(md5_test_SOURCES) $(msg_test_SOURCES) $(shmem_test_SOURCES) \ $(synch_test_SOURCES) -DIST_COMMON = $(top_srcdir)/Makefile.incl Makefile.am Makefile.in +DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/Makefile.incl \ + Makefile.am SOURCES = $(libboinc_a_SOURCES) $(crypt_prog_SOURCES) $(md5_test_SOURCES) $(msg_test_SOURCES) $(shmem_test_SOURCES) $(synch_test_SOURCES) all: all-am @@ -299,8 +304,6 @@ AR = ar clean-noinstLIBRARIES: -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES) -boinc_api.$(OBJEXT): ../api/boinc_api.C -mfile.$(OBJEXT): ../api/mfile.C libboinc.a: $(libboinc_a_OBJECTS) $(libboinc_a_DEPENDENCIES) -rm -f libboinc.a $(libboinc_a_AR) libboinc.a $(libboinc_a_OBJECTS) $(libboinc_a_LIBADD) @@ -352,6 +355,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/app_ipc.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/base64.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_api.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crypt_prog.Po@am__quote@ @@ -371,13 +375,10 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/util.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xml_util.Po@am__quote@ -distclean-depend: - -rm -rf ./$(DEPDIR) - .C.o: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ @am__fastdepCXX_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @@ -387,19 +388,19 @@ distclean-depend: .C.obj: @am__fastdepCXX_TRUE@ if $(CXXCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ -@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'`; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCXX_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'` +@am__fastdepCXX_FALSE@ $(CXXCOMPILE) -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` boinc_api.o: ../api/boinc_api.C @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_api.o -MD -MP -MF "$(DEPDIR)/boinc_api.Tpo" \ @am__fastdepCXX_TRUE@ -c -o boinc_api.o `test -f '../api/boinc_api.C' || echo '$(srcdir)/'`../api/boinc_api.C; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_api.Tpo" "$(DEPDIR)/boinc_api.Po"; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/boinc_api.Tpo" "$(DEPDIR)/boinc_api.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_api.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../api/boinc_api.C' object='boinc_api.o' libtool=no @AMDEPBACKSLASH@ @@ -409,19 +410,19 @@ boinc_api.o: ../api/boinc_api.C boinc_api.obj: ../api/boinc_api.C @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_api.obj -MD -MP -MF "$(DEPDIR)/boinc_api.Tpo" \ -@am__fastdepCXX_TRUE@ -c -o boinc_api.obj `if test -f '../api/boinc_api.C'; then $(CYGPATH_W) '../api/boinc_api.C'; else $(CYGPATH_W) '$(srcdir)/../api/boinc_api.C'`; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_api.Tpo" "$(DEPDIR)/boinc_api.Po"; \ +@am__fastdepCXX_TRUE@ -c -o boinc_api.obj `if test -f '../api/boinc_api.C'; then $(CYGPATH_W) '../api/boinc_api.C'; else $(CYGPATH_W) '$(srcdir)/../api/boinc_api.C'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/boinc_api.Tpo" "$(DEPDIR)/boinc_api.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_api.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../api/boinc_api.C' object='boinc_api.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_api.Po' tmpdepfile='$(DEPDIR)/boinc_api.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_api.obj `if test -f '../api/boinc_api.C'; then $(CYGPATH_W) '../api/boinc_api.C'; else $(CYGPATH_W) '$(srcdir)/../api/boinc_api.C'` +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_api.obj `if test -f '../api/boinc_api.C'; then $(CYGPATH_W) '../api/boinc_api.C'; else $(CYGPATH_W) '$(srcdir)/../api/boinc_api.C'; fi` mfile.o: ../api/mfile.C @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mfile.o -MD -MP -MF "$(DEPDIR)/mfile.Tpo" \ @am__fastdepCXX_TRUE@ -c -o mfile.o `test -f '../api/mfile.C' || echo '$(srcdir)/'`../api/mfile.C; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/mfile.Tpo" "$(DEPDIR)/mfile.Po"; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/mfile.Tpo" "$(DEPDIR)/mfile.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/mfile.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../api/mfile.C' object='mfile.o' libtool=no @AMDEPBACKSLASH@ @@ -431,19 +432,19 @@ mfile.o: ../api/mfile.C mfile.obj: ../api/mfile.C @am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT mfile.obj -MD -MP -MF "$(DEPDIR)/mfile.Tpo" \ -@am__fastdepCXX_TRUE@ -c -o mfile.obj `if test -f '../api/mfile.C'; then $(CYGPATH_W) '../api/mfile.C'; else $(CYGPATH_W) '$(srcdir)/../api/mfile.C'`; \ -@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/mfile.Tpo" "$(DEPDIR)/mfile.Po"; \ +@am__fastdepCXX_TRUE@ -c -o mfile.obj `if test -f '../api/mfile.C'; then $(CYGPATH_W) '../api/mfile.C'; else $(CYGPATH_W) '$(srcdir)/../api/mfile.C'; fi`; \ +@am__fastdepCXX_TRUE@ then mv -f "$(DEPDIR)/mfile.Tpo" "$(DEPDIR)/mfile.Po"; \ @am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/mfile.Tpo"; exit 1; \ @am__fastdepCXX_TRUE@ fi @AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../api/mfile.C' object='mfile.obj' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/mfile.Po' tmpdepfile='$(DEPDIR)/mfile.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mfile.obj `if test -f '../api/mfile.C'; then $(CYGPATH_W) '../api/mfile.C'; else $(CYGPATH_W) '$(srcdir)/../api/mfile.C'` +@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o mfile.obj `if test -f '../api/mfile.C'; then $(CYGPATH_W) '../api/mfile.C'; else $(CYGPATH_W) '$(srcdir)/../api/mfile.C'; fi` .c.o: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ @am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \ -@am__fastdepCC_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCC_TRUE@ fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @@ -453,14 +454,14 @@ mfile.obj: ../api/mfile.C .c.obj: @am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \ -@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'`; \ -@am__fastdepCC_TRUE@ then mv "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ +@am__fastdepCC_TRUE@ -c -o $@ `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi`; \ +@am__fastdepCC_TRUE@ then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; \ @am__fastdepCC_TRUE@ else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; \ @am__fastdepCC_TRUE@ fi @AMDEP_TRUE@@am__fastdepCC_FALSE@ source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ depfile='$(DEPDIR)/$*.Po' tmpdepfile='$(DEPDIR)/$*.TPo' @AMDEPBACKSLASH@ @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ -@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'` +@am__fastdepCC_FALSE@ $(COMPILE) -c `if test -f '$<'; then $(CYGPATH_W) '$<'; else $(CYGPATH_W) '$(srcdir)/$<'; fi` uninstall-info-am: ETAGS = etags @@ -522,11 +523,13 @@ top_distdir = .. distdir = $(top_distdir)/$(PACKAGE)-$(VERSION) distdir: $(DISTFILES) - $(mkinstalldirs) $(distdir)/$(top_srcdir) + $(mkinstalldirs) $(distdir)/.. @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,/[^/]*$$,,'`; \ @@ -553,7 +556,6 @@ all-am: Makefile $(LIBRARIES) $(PROGRAMS) installdirs: $(mkinstalldirs) $(DESTDIR)$(bindir) - install: install-am install-exec: install-exec-am install-data: install-data-am @@ -565,7 +567,7 @@ install-am: all-am installcheck: installcheck-am install-strip: $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ - INSTALL_STRIP_FLAG=-s \ + install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ `test -z '$(STRIP)' || \ echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install mostlyclean-generic: @@ -573,7 +575,7 @@ mostlyclean-generic: clean-generic: distclean-generic: - -rm -f Makefile $(CONFIG_CLEAN_FILES) + -rm -f $(CONFIG_CLEAN_FILES) maintainer-clean-generic: @echo "This command is intended for maintainers to use" @@ -584,9 +586,10 @@ clean-am: clean-binPROGRAMS clean-generic clean-noinstLIBRARIES \ mostlyclean-am distclean: distclean-am - -distclean-am: clean-am distclean-compile distclean-depend \ - distclean-generic distclean-tags + -rm -rf ./$(DEPDIR) + -rm -f Makefile +distclean-am: clean-am distclean-compile distclean-generic \ + distclean-tags dvi: dvi-am @@ -607,7 +610,8 @@ install-man: installcheck-am: maintainer-clean: maintainer-clean-am - + -rm -rf ./$(DEPDIR) + -rm -f Makefile maintainer-clean-am: distclean-am maintainer-clean-generic mostlyclean: mostlyclean-am @@ -626,15 +630,14 @@ uninstall-am: uninstall-binPROGRAMS uninstall-info-am .PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \ clean-generic clean-noinstLIBRARIES ctags distclean \ - distclean-compile distclean-depend distclean-generic \ - distclean-tags distdir dvi dvi-am info info-am install \ - install-am install-binPROGRAMS install-data install-data-am \ - install-exec install-exec-am install-info install-info-am \ - install-man install-strip installcheck installcheck-am \ - installdirs maintainer-clean maintainer-clean-generic \ - mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ - ps ps-am tags uninstall uninstall-am uninstall-binPROGRAMS \ - uninstall-info-am + distclean-compile distclean-generic distclean-tags distdir dvi \ + dvi-am info info-am install install-am install-binPROGRAMS \ + install-data install-data-am install-exec install-exec-am \ + install-info install-info-am install-man install-strip \ + installcheck installcheck-am installdirs maintainer-clean \ + maintainer-clean-generic mostlyclean mostlyclean-compile \ + mostlyclean-generic pdf pdf-am ps ps-am tags uninstall \ + uninstall-am uninstall-binPROGRAMS uninstall-info-am $(LIBRSA): diff --git a/lib/base64.C b/lib/base64.C new file mode 100644 index 0000000000..213abd57cd --- /dev/null +++ b/lib/base64.C @@ -0,0 +1,176 @@ +// Copyright 2003 Regents of the University of California + +#include "parse.h" + +// Table of characters coding the 64 values. +static char base64_value_to_char[64] = +{ + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', // 0- 9 + 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', // 10-19 + 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', // 20-29 + 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 30-39 + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', // 40-49 + 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', // 50-59 + '8', '9', '+', '/' // 60-63 +}; + +// Table of base64 values for first 128 characters. +static short base64_char_to_value[128] = +{ + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 0- 9 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10- 19 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 20- 29 + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 30- 39 + -1, -1, -1, 62, -1, -1, -1, 63, 52, 53, // 40- 49 + 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, // 50- 59 + -1, -1, -1, -1, -1, 0, 1, 2, 3, 4, // 60- 69 + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 70- 79 + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, // 80- 89 + 25, -1, -1, -1, -1, -1, -1, 26, 27, 28, // 90- 99 + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, // 100-109 + 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, // 110-119 + 49, 50, 51, -1, -1, -1, -1, -1 // 120-127 +}; + +/* The following diagram shows the logical steps by which three octets + get transformed into four base64 characters. + + .--------. .--------. .--------. + |aaaaaabb| |bbbbcccc| |ccdddddd| + `--------' `--------' `--------' + 6 2 4 4 2 6 + .--------+--------+--------+--------. + |00aaaaaa|00bbbbbb|00cccccc|00dddddd| + `--------+--------+--------+--------' + + .--------+--------+--------+--------. + |AAAAAAAA|BBBBBBBB|CCCCCCCC|DDDDDDDD| + `--------+--------+--------+--------' + + The octets are divided into 6 bit chunks, which are then encoded into + base64 characters. */ + +string base64_encode (const char* from, size_t length) throw(InvalidBase64Exception) +{ + string result; + result.reserve(length + length/3 + 1); + size_t i = 0; + int c; + unsigned int value; + + while (i < length) + { + c = from[i++]; + + // Process first byte of a triplet. + result += base64_value_to_char[0x3f & c >> 2]; + value = (0x03 & c) << 4; + + // Process second byte of a triplet. + if (i == length) + { + result += base64_value_to_char[value]; + result += '='; + result += '='; + break; + } + + c = from[i++]; + + result += base64_value_to_char[value | (0x0f & c >> 4)]; + value = (0x0f & c) << 2; + + // Process third byte of a triplet. + if (i == length) + { + result += base64_value_to_char[value]; + result += '='; + break; + } + + c = from[i++]; + + result += base64_value_to_char[value | (0x03 & c >> 6)]; + result += base64_value_to_char[0x3f & c]; + } + + return result; +} + +#define IS_ASCII(Character) \ + ((Character) < 128) +#define IS_BASE64(Character) \ + (IS_ASCII (Character) && base64_char_to_value[Character] >= 0) +#define IS_BASE64_IGNORABLE(Character) \ + ((Character) == ' ' || (Character) == '\t' || (Character) == '\n' \ + || (Character) == '\f' || (Character) == '\r') + +#define READ_QUADRUPLET_BYTE(retval) \ + do { \ + if (i == length) return result; \ + c = from[i++]; \ + } \ + while (IS_BASE64_IGNORABLE (c)) + +string base64_decode (const char* from, size_t length) throw(InvalidBase64Exception) +{ + size_t i = 0; + string result; + unsigned char c; + unsigned long value; + + while (true) + { + // Process first byte of a quadruplet. + + READ_QUADRUPLET_BYTE(); + + if (!IS_BASE64 (c)) + throw InvalidBase64Exception(); + value = base64_char_to_value[c] << 18; + + // Process second byte of a quadruplet. + + READ_QUADRUPLET_BYTE(); + + if (!IS_BASE64 (c)) + throw InvalidBase64Exception(); + value |= base64_char_to_value[c] << 12; + + c = (unsigned char) (value >> 16); + result += c; + + // Process third byte of a quadruplet. + + READ_QUADRUPLET_BYTE(); + if (c == '=') + { + READ_QUADRUPLET_BYTE(); + + if (c != '=') + throw InvalidBase64Exception(); + continue; + } + + if (!IS_BASE64 (c)) + throw InvalidBase64Exception(); + value |= base64_char_to_value[c] << 6; + + c = (unsigned char) (0xff & value >> 8); + result += c; + + // Process fourth byte of a quadruplet. + + READ_QUADRUPLET_BYTE(); + + if (c == '=') + continue; + + if (!IS_BASE64 (c)) + throw InvalidBase64Exception(); + value |= base64_char_to_value[c]; + + c = (unsigned char) (0xff & value); + result += c; + } +} diff --git a/lib/parse.h b/lib/parse.h index e3be309f7d..4acc2aa168 100644 --- a/lib/parse.h +++ b/lib/parse.h @@ -42,3 +42,10 @@ extern void replace_element(char* buf, char* start, char* end, char* replacement extern char* sgets(char* buf, int len, char* &in); extern bool extract_xml_record(const std::string &field, const char *tag, std::string &record); +class InvalidBase64Exception +{ +}; + +string base64_encode (const char* from, size_t length) throw(InvalidBase64Exception); +string base64_decode (const char* from, size_t length) throw(InvalidBase64Exception); +