diff --git a/Makefile.incl b/Makefile.incl
index 77a2d5a39c..3819bd730a 100644
--- a/Makefile.incl
+++ b/Makefile.incl
@@ -11,7 +11,7 @@ RSA_LIBS = \
-lrsaeuro
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
diff --git a/aclocal.m4 b/aclocal.m4
index 05c2f19eb0..c9d1305177 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -1104,7 +1104,7 @@ AC_DEFUN([SAH_HEADER_STDCXX],[
#
# Revision Log:
# $Log$
-# Revision 1.100 2004/06/09 20:04:02 davea
+# Revision 1.101 2004/06/12 04:45:15 davea
# *** empty log message ***
#
# Revision 1.1 2003/12/11 18:38:24 korpela
diff --git a/api/Makefile.am b/api/Makefile.am
index 2c4e05edc0..c0e24edd71 100644
--- a/api/Makefile.am
+++ b/api/Makefile.am
@@ -7,7 +7,6 @@ noinst_LIBRARIES = libboinc_api.a
libboinc_api_a_SOURCES = \
boinc_api.C \
boinc_api.h \
- mfile.C \
reduce.h \
../lib/app_ipc.C \
../lib/base64.C \
@@ -36,7 +35,7 @@ nographics:
EXTRA_PROGRAMS = api_app api_test
-api_app_SOURCES = api_app.C mfile.C boinc_api.C ../lib/parse.C ../lib/synch.C
+api_app_SOURCES = api_app.C boinc_api.C ../lib/parse.C ../lib/synch.C
api_test_SOURCES = boinc_api.C api_test.C ../lib/parse.C
all = libboinc_api.a
diff --git a/api/Makefile.in b/api/Makefile.in
index f30977b90d..803d23dd65 100644
--- a/api/Makefile.in
+++ b/api/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
@@ -175,7 +175,6 @@ noinst_LIBRARIES = libboinc_api.a
libboinc_api_a_SOURCES = \
boinc_api.C \
boinc_api.h \
- mfile.C \
reduce.h \
../lib/app_ipc.C \
../lib/base64.C \
@@ -202,7 +201,7 @@ libboinc_graphics_api_a_SOURCES = \
EXTRA_PROGRAMS = api_app api_test
-api_app_SOURCES = api_app.C mfile.C boinc_api.C ../lib/parse.C ../lib/synch.C
+api_app_SOURCES = api_app.C boinc_api.C ../lib/parse.C ../lib/synch.C
api_test_SOURCES = boinc_api.C api_test.C ../lib/parse.C
all = libboinc_api.a
@@ -214,14 +213,13 @@ LIBRARIES = $(noinst_LIBRARIES)
libboinc_api_a_AR = $(AR) cru
libboinc_api_a_LIBADD =
-am_libboinc_api_a_OBJECTS = boinc_api.$(OBJEXT) mfile.$(OBJEXT) \
- app_ipc.$(OBJEXT) base64.$(OBJEXT) diagnostics.$(OBJEXT) \
- exception.$(OBJEXT) parse.$(OBJEXT) shmem.$(OBJEXT) \
- synch.$(OBJEXT) util.$(OBJEXT)
+am_libboinc_api_a_OBJECTS = boinc_api.$(OBJEXT) app_ipc.$(OBJEXT) \
+ base64.$(OBJEXT) diagnostics.$(OBJEXT) exception.$(OBJEXT) \
+ parse.$(OBJEXT) shmem.$(OBJEXT) synch.$(OBJEXT) util.$(OBJEXT)
libboinc_api_a_OBJECTS = $(am_libboinc_api_a_OBJECTS)
EXTRA_PROGRAMS = api_app$(EXEEXT) api_test$(EXEEXT)
-am_api_app_OBJECTS = api_app.$(OBJEXT) mfile.$(OBJEXT) \
- boinc_api.$(OBJEXT) parse.$(OBJEXT) synch.$(OBJEXT)
+am_api_app_OBJECTS = api_app.$(OBJEXT) boinc_api.$(OBJEXT) \
+ parse.$(OBJEXT) synch.$(OBJEXT)
api_app_OBJECTS = $(am_api_app_OBJECTS)
api_app_LDADD = $(LDADD)
api_app_DEPENDENCIES =
@@ -239,9 +237,9 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/api_app.Po ./$(DEPDIR)/api_test.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/app_ipc.Po ./$(DEPDIR)/base64.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_api.Po ./$(DEPDIR)/diagnostics.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/exception.Po ./$(DEPDIR)/mfile.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/parse.Po ./$(DEPDIR)/shmem.Po \
-@AMDEP_TRUE@ ./$(DEPDIR)/synch.Po ./$(DEPDIR)/util.Po
+@AMDEP_TRUE@ ./$(DEPDIR)/exception.Po ./$(DEPDIR)/parse.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/shmem.Po ./$(DEPDIR)/synch.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/util.Po
CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
@@ -302,7 +300,6 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_api.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/diagnostics.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/exception.Po@am__quote@
-@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shmem.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/synch.Po@am__quote@
diff --git a/apps/Makefile.in b/apps/Makefile.in
index 0b56e12248..873a2657ca 100644
--- a/apps/Makefile.in
+++ b/apps/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
diff --git a/checkin_notes b/checkin_notes
index 1f33dc0627..fb2637ec22 100755
--- a/checkin_notes
+++ b/checkin_notes
@@ -13332,3 +13332,49 @@ Daniel 11 June 2004
client/
cs_prefs.C
+David 11 June 2004
+ - Windows sockets can't be used in fdopen() (thank you MS),
+ and we wanted all the standard XML output functions
+ to be able to write to either disk or socket (for GUI RPC).
+ So we added a class MIOFILE, with printf() and fgets() member funcs,
+ that can be implemented with either a FILE* or a memory buffer
+ under the hood.
+ - Moved MFILE from api/ to lib/ since it's used in the implementation
+ of MIOFILE
+ - Changed all XML write and parse functions to take MIOFILE&
+ instead of FILE*
+ - Changed GUI RPC client code to use MIOFILEs
+ - Changed GUI RPC protocol so that every reply message
+ ends with a \003 delimiter
+ (to make it unambiguous where reply ends)
+ - removed version number header from GUI RPC (rethink this later)
+
+ Got this all to work on Unix; will try Windows next
+
+ api/
+ Makefile.am
+ mfile.C,h (moved from here)
+ client/
+ Makefile.am
+ app.C,h
+ client_state.h
+ client_types.C,h
+ cs_scheduler.C
+ cs_statefile.C
+ gui_rpc_client.C,h
+ gui_rpc_server.C,h
+ gui_test.C
+ hostinfo.C,h
+ makefile.gui_test
+ miofile.C,h (new)
+ net_stats.C,h
+ net_xfer.h
+ pers_file_xfer.h
+ proxy.C,y
+ scheduler_op.C
+ time_stats.C,h
+ doc/
+ client_sched.php (new)
+ lib/
+ Makefile.am
+ mfile.C,h (moved to here)
diff --git a/client/Makefile.am b/client/Makefile.am
index f11db5a942..88a1f0ff70 100644
--- a/client/Makefile.am
+++ b/client/Makefile.am
@@ -9,8 +9,6 @@ bin_PROGRAMS = boinc_client
EXTRA_PROGRAMS = cpu_benchmark
-CXXFLAGS = -g -Wall -O6
-
boinc_client_SOURCES = \
app.C \
check_state.C \
@@ -36,6 +34,7 @@ boinc_client_SOURCES = \
http.C \
log_flags.C \
main.C \
+ miofile.C \
net_stats.C \
net_xfer.C \
pers_file_xfer.C \
@@ -53,6 +52,7 @@ boinc_client_SOURCES = \
../lib/language.C \
../lib/md5_file.C \
../lib/md5.c \
+ ../lib/mfile.C \
../lib/msg_log.C \
../lib/parse.C \
../lib/shmem.C \
diff --git a/client/Makefile.in b/client/Makefile.in
index 6a83d57967..14c01797b0 100644
--- a/client/Makefile.in
+++ b/client/Makefile.in
@@ -57,8 +57,7 @@ CPPFLAGS = @CPPFLAGS@
CXX = @CXX@
CXXCPP = @CXXCPP@
CXXDEPMODE = @CXXDEPMODE@
-
-CXXFLAGS = -g -Wall -O6
+CXXFLAGS = @CXXFLAGS@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
DEPDIR = @DEPDIR@
@@ -153,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
@@ -203,6 +202,7 @@ boinc_client_SOURCES = \
http.C \
log_flags.C \
main.C \
+ miofile.C \
net_stats.C \
net_xfer.C \
pers_file_xfer.C \
@@ -220,6 +220,7 @@ boinc_client_SOURCES = \
../lib/language.C \
../lib/md5_file.C \
../lib/md5.c \
+ ../lib/mfile.C \
../lib/msg_log.C \
../lib/parse.C \
../lib/shmem.C \
@@ -271,7 +272,8 @@ am_boinc_client_OBJECTS = boinc_client-app.$(OBJEXT) \
boinc_client-hostinfo.$(OBJEXT) \
boinc_client-hostinfo_unix.$(OBJEXT) \
boinc_client-http.$(OBJEXT) boinc_client-log_flags.$(OBJEXT) \
- boinc_client-main.$(OBJEXT) boinc_client-net_stats.$(OBJEXT) \
+ boinc_client-main.$(OBJEXT) boinc_client-miofile.$(OBJEXT) \
+ boinc_client-net_stats.$(OBJEXT) \
boinc_client-net_xfer.$(OBJEXT) \
boinc_client-pers_file_xfer.$(OBJEXT) \
boinc_client-prefs.$(OBJEXT) boinc_client-proxy.$(OBJEXT) \
@@ -282,9 +284,9 @@ am_boinc_client_OBJECTS = boinc_client-app.$(OBJEXT) \
boinc_client-crypt.$(OBJEXT) boinc_client-diagnostics.$(OBJEXT) \
boinc_client-exception.$(OBJEXT) boinc_client-filesys.$(OBJEXT) \
boinc_client-language.$(OBJEXT) boinc_client-md5_file.$(OBJEXT) \
- boinc_client-md5.$(OBJEXT) boinc_client-msg_log.$(OBJEXT) \
- boinc_client-parse.$(OBJEXT) boinc_client-shmem.$(OBJEXT) \
- boinc_client-util.$(OBJEXT)
+ boinc_client-md5.$(OBJEXT) boinc_client-mfile.$(OBJEXT) \
+ boinc_client-msg_log.$(OBJEXT) boinc_client-parse.$(OBJEXT) \
+ boinc_client-shmem.$(OBJEXT) boinc_client-util.$(OBJEXT)
boinc_client_OBJECTS = $(am_boinc_client_OBJECTS)
boinc_client_LDFLAGS =
am_cpu_benchmark_OBJECTS = cpu_benchmark.$(OBJEXT) whetstone.$(OBJEXT) \
@@ -329,6 +331,8 @@ am__depfiles_maybe = depfiles
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-main.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-md5.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-md5_file.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-mfile.Po \
+@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-miofile.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-msg_log.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-net_stats.Po \
@AMDEP_TRUE@ ./$(DEPDIR)/boinc_client-net_xfer.Po \
@@ -415,6 +419,7 @@ boinc_client-hostinfo_unix.$(OBJEXT): hostinfo_unix.C
boinc_client-http.$(OBJEXT): http.C
boinc_client-log_flags.$(OBJEXT): log_flags.C
boinc_client-main.$(OBJEXT): main.C
+boinc_client-miofile.$(OBJEXT): miofile.C
boinc_client-net_stats.$(OBJEXT): net_stats.C
boinc_client-net_xfer.$(OBJEXT): net_xfer.C
boinc_client-pers_file_xfer.$(OBJEXT): pers_file_xfer.C
@@ -432,6 +437,7 @@ boinc_client-filesys.$(OBJEXT): ../lib/filesys.C
boinc_client-language.$(OBJEXT): ../lib/language.C
boinc_client-md5_file.$(OBJEXT): ../lib/md5_file.C
boinc_client-md5.$(OBJEXT): ../lib/md5.c
+boinc_client-mfile.$(OBJEXT): ../lib/mfile.C
boinc_client-msg_log.$(OBJEXT): ../lib/msg_log.C
boinc_client-parse.$(OBJEXT): ../lib/parse.C
boinc_client-shmem.$(OBJEXT): ../lib/shmem.C
@@ -481,6 +487,8 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-main.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-md5.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-md5_file.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-mfile.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-miofile.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-msg_log.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-net_stats.Po@am__quote@
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/boinc_client-net_xfer.Po@am__quote@
@@ -1051,6 +1059,28 @@ boinc_client-main.obj: main.C
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-main.obj `if test -f 'main.C'; then $(CYGPATH_W) 'main.C'; else $(CYGPATH_W) '$(srcdir)/main.C'`
+boinc_client-miofile.o: miofile.C
+@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-miofile.o -MD -MP -MF "$(DEPDIR)/boinc_client-miofile.Tpo" \
+@am__fastdepCXX_TRUE@ -c -o boinc_client-miofile.o `test -f 'miofile.C' || echo '$(srcdir)/'`miofile.C; \
+@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-miofile.Tpo" "$(DEPDIR)/boinc_client-miofile.Po"; \
+@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-miofile.Tpo"; exit 1; \
+@am__fastdepCXX_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='miofile.C' object='boinc_client-miofile.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-miofile.Po' tmpdepfile='$(DEPDIR)/boinc_client-miofile.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-miofile.o `test -f 'miofile.C' || echo '$(srcdir)/'`miofile.C
+
+boinc_client-miofile.obj: miofile.C
+@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-miofile.obj -MD -MP -MF "$(DEPDIR)/boinc_client-miofile.Tpo" \
+@am__fastdepCXX_TRUE@ -c -o boinc_client-miofile.obj `if test -f 'miofile.C'; then $(CYGPATH_W) 'miofile.C'; else $(CYGPATH_W) '$(srcdir)/miofile.C'`; \
+@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-miofile.Tpo" "$(DEPDIR)/boinc_client-miofile.Po"; \
+@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-miofile.Tpo"; exit 1; \
+@am__fastdepCXX_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='miofile.C' object='boinc_client-miofile.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-miofile.Po' tmpdepfile='$(DEPDIR)/boinc_client-miofile.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-miofile.obj `if test -f 'miofile.C'; then $(CYGPATH_W) 'miofile.C'; else $(CYGPATH_W) '$(srcdir)/miofile.C'`
+
boinc_client-net_stats.o: net_stats.C
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-net_stats.o -MD -MP -MF "$(DEPDIR)/boinc_client-net_stats.Tpo" \
@am__fastdepCXX_TRUE@ -c -o boinc_client-net_stats.o `test -f 'net_stats.C' || echo '$(srcdir)/'`net_stats.C; \
@@ -1403,6 +1433,28 @@ boinc_client-md5_file.obj: ../lib/md5_file.C
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-md5_file.obj `if test -f '../lib/md5_file.C'; then $(CYGPATH_W) '../lib/md5_file.C'; else $(CYGPATH_W) '$(srcdir)/../lib/md5_file.C'`
+boinc_client-mfile.o: ../lib/mfile.C
+@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-mfile.o -MD -MP -MF "$(DEPDIR)/boinc_client-mfile.Tpo" \
+@am__fastdepCXX_TRUE@ -c -o boinc_client-mfile.o `test -f '../lib/mfile.C' || echo '$(srcdir)/'`../lib/mfile.C; \
+@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-mfile.Tpo" "$(DEPDIR)/boinc_client-mfile.Po"; \
+@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-mfile.Tpo"; exit 1; \
+@am__fastdepCXX_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/mfile.C' object='boinc_client-mfile.o' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-mfile.Po' tmpdepfile='$(DEPDIR)/boinc_client-mfile.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-mfile.o `test -f '../lib/mfile.C' || echo '$(srcdir)/'`../lib/mfile.C
+
+boinc_client-mfile.obj: ../lib/mfile.C
+@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-mfile.obj -MD -MP -MF "$(DEPDIR)/boinc_client-mfile.Tpo" \
+@am__fastdepCXX_TRUE@ -c -o boinc_client-mfile.obj `if test -f '../lib/mfile.C'; then $(CYGPATH_W) '../lib/mfile.C'; else $(CYGPATH_W) '$(srcdir)/../lib/mfile.C'`; \
+@am__fastdepCXX_TRUE@ then mv "$(DEPDIR)/boinc_client-mfile.Tpo" "$(DEPDIR)/boinc_client-mfile.Po"; \
+@am__fastdepCXX_TRUE@ else rm -f "$(DEPDIR)/boinc_client-mfile.Tpo"; exit 1; \
+@am__fastdepCXX_TRUE@ fi
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ source='../lib/mfile.C' object='boinc_client-mfile.obj' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ depfile='$(DEPDIR)/boinc_client-mfile.Po' tmpdepfile='$(DEPDIR)/boinc_client-mfile.TPo' @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCXX_FALSE@ $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -c -o boinc_client-mfile.obj `if test -f '../lib/mfile.C'; then $(CYGPATH_W) '../lib/mfile.C'; else $(CYGPATH_W) '$(srcdir)/../lib/mfile.C'`
+
boinc_client-msg_log.o: ../lib/msg_log.C
@am__fastdepCXX_TRUE@ if $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(boinc_client_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS) -MT boinc_client-msg_log.o -MD -MP -MF "$(DEPDIR)/boinc_client-msg_log.Tpo" \
@am__fastdepCXX_TRUE@ -c -o boinc_client-msg_log.o `test -f '../lib/msg_log.C' || echo '$(srcdir)/'`../lib/msg_log.C; \
diff --git a/client/app.C b/client/app.C
index 3930e1d818..c1a93d0ca6 100644
--- a/client/app.C
+++ b/client/app.C
@@ -1374,8 +1374,8 @@ int ACTIVE_TASK_SET::get_free_slot(int total_slots) {
return -1;
}
-int ACTIVE_TASK::write(FILE* fout) {
- fprintf(fout,
+int ACTIVE_TASK::write(MIOFILE& fout) {
+ fout.printf(
"\n"
" %s\n"
" %s\n"
@@ -1396,7 +1396,7 @@ int ACTIVE_TASK::write(FILE* fout) {
return 0;
}
-int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
+int ACTIVE_TASK::parse(MIOFILE& fin) {
char buf[256], result_name[256], project_master_url[256];
int app_version_num=0;
PROJECT* project;
@@ -1405,9 +1405,9 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
strcpy(result_name, "");
strcpy(project_master_url, "");
- while (fgets(buf, 256, fin)) {
+ while (fin.fgets(buf, 256)) {
if (match_tag(buf, "")) {
- project = cs->lookup_project(project_master_url);
+ project = gstate.lookup_project(project_master_url);
if (!project) {
msg_printf(
NULL, MSG_ERROR,
@@ -1416,7 +1416,7 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
);
return ERR_NULL;
}
- result = cs->lookup_result(project, result_name);
+ result = gstate.lookup_result(project, result_name);
if (!result) {
msg_printf(
project, MSG_ERROR, "ACTIVE_TASK::parse(): result not found\n"
@@ -1437,7 +1437,7 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
}
wup = result->wup;
- app_version = cs->lookup_app_version(
+ app_version = gstate.lookup_app_version(
result->app, app_version_num
);
if (!app_version) {
@@ -1463,33 +1463,33 @@ int ACTIVE_TASK::parse(FILE* fin, CLIENT_STATE* cs) {
// Write XML information about this active task set
//
-int ACTIVE_TASK_SET::write(FILE* fout) {
+int ACTIVE_TASK_SET::write(MIOFILE& fout) {
unsigned int i;
int retval;
- fprintf(fout, "\n");
+ fout.printf("\n");
for (i=0; iwrite(fout);
if (retval) return retval;
}
- fprintf(fout, "\n");
+ fout.printf("\n");
return 0;
}
// Parse XML information about an active task set
//
-int ACTIVE_TASK_SET::parse(FILE* fin, CLIENT_STATE* cs) {
+int ACTIVE_TASK_SET::parse(MIOFILE& fin) {
ACTIVE_TASK* atp;
char buf[256];
int retval;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_TASK);
- while (fgets(buf, 256, fin)) {
+ while (fin.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (match_tag(buf, "")) {
atp = new ACTIVE_TASK;
- retval = atp->parse(fin, cs);
+ retval = atp->parse(fin);
if (!retval) active_tasks.push_back(atp);
else delete atp;
} else scope_messages.printf("ACTIVE_TASK_SET::parse(): unrecognized %s\n", buf);
diff --git a/client/app.h b/client/app.h
index 8f845b72cb..c00ff2b72a 100644
--- a/client/app.h
+++ b/client/app.h
@@ -140,8 +140,8 @@ public:
int write_app_init_file(APP_INIT_DATA&);
int move_trickle_file();
- int write(FILE*);
- int parse(FILE*, CLIENT_STATE*);
+ int write(MIOFILE&);
+ int parse(MIOFILE&);
};
class ACTIVE_TASK_SET {
@@ -175,8 +175,8 @@ public:
void check_graphics_mode_ack();
void request_reread_prefs(PROJECT*);
- int write(FILE*);
- int parse(FILE*, CLIENT_STATE*);
+ int write(MIOFILE&);
+ int parse(MIOFILE&);
};
#endif
diff --git a/client/client_state.h b/client/client_state.h
index e39dd2fd42..649d453a08 100644
--- a/client/client_state.h
+++ b/client/client_state.h
@@ -32,7 +32,7 @@
#include "hostinfo.h"
#include "http.h"
#include "language.h"
-//#include "message.h"
+#include "miofile.h"
#include "net_stats.h"
#include "net_xfer.h"
#include "pers_file_xfer.h"
@@ -257,7 +257,7 @@ private:
public:
void set_client_state_dirty(char*);
int parse_state_file();
- int write_state(FILE*);
+ int write_state(MIOFILE&);
int write_state_file();
int write_state_file_if_needed();
int parse_venue();
diff --git a/client/client_types.C b/client/client_types.C
index 6fb89807fa..23ed013fa2 100644
--- a/client/client_types.C
+++ b/client/client_types.C
@@ -264,7 +264,7 @@ int PROJECT::parse_account(FILE* in) {
// parse project fields from client_state.xml
//
-int PROJECT::parse_state(FILE* in) {
+int PROJECT::parse_state(MIOFILE& in) {
char buf[256];
STRING256 sched_url;
string str1, str2;
@@ -285,7 +285,7 @@ int PROJECT::parse_state(FILE* in) {
master_url_fetch_pending = false;
sched_rpc_pending = false;
scheduler_urls.clear();
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", sched_url.text, sizeof(sched_url.text))) {
scheduler_urls.push_back(sched_url);
@@ -327,15 +327,15 @@ int PROJECT::parse_state(FILE* in) {
// Write the project information to client state file
//
-int PROJECT::write_state(FILE* out) {
+int PROJECT::write_state(MIOFILE& out) {
unsigned int i;
string u1, u2, t1, t2;
- fprintf(out,
+ out.printf(
"\n"
);
for (i=0; i%s\n",
scheduler_urls[i].text
);
@@ -344,7 +344,7 @@ int PROJECT::write_state(FILE* out) {
xml_escape(u1, u2);
t1 = team_name;
xml_escape(t1, t2);
- fprintf(out,
+ out.printf(
" %s\n"
" %s\n"
" %s\n"
@@ -388,11 +388,11 @@ int PROJECT::write_state(FILE* out) {
sched_rpc_pending?" \n":""
);
if (strlen(code_sign_key)) {
- fprintf(out,
+ out.printf(
" \n%s\n", code_sign_key
);
}
- fprintf(out,
+ out.printf(
"\n"
);
return 0;
@@ -433,14 +433,14 @@ char* PROJECT::get_project_name() {
}
}
-int APP::parse(FILE* in) {
+int APP::parse(MIOFILE& in) {
char buf[256];
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
strcpy(name, "");
project = NULL;
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", name, sizeof(name))) continue;
else scope_messages.printf("APP::parse(): unrecognized: %s\n", buf);
@@ -448,8 +448,8 @@ int APP::parse(FILE* in) {
return ERR_XML_PARSE;
}
-int APP::write(FILE* out) {
- fprintf(out,
+int APP::write(MIOFILE& out) {
+ out.printf(
"\n"
" %s\n"
"\n",
@@ -535,7 +535,7 @@ bool FILE_INFO::verify_existing_file() {
// If from server, make an exact copy of everything
// except the start/end tags and the element.
//
-int FILE_INFO::parse(FILE* in, bool from_server) {
+int FILE_INFO::parse(MIOFILE& in, bool from_server) {
char buf[256], buf2[1024];
STRING256 url;
PERS_FILE_XFER *pfxp;
@@ -543,7 +543,7 @@ int FILE_INFO::parse(FILE* in, bool from_server) {
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (match_tag(buf, "")) {
copy_element_contents(
@@ -598,7 +598,7 @@ int FILE_INFO::parse(FILE* in, bool from_server) {
);
continue;
} else if (match_tag(buf, "")) {
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) break;
}
continue;
@@ -610,11 +610,11 @@ int FILE_INFO::parse(FILE* in, bool from_server) {
return ERR_XML_PARSE;
}
-int FILE_INFO::write(FILE* out, bool to_server) {
+int FILE_INFO::write(MIOFILE& out, bool to_server) {
unsigned int i;
int retval;
- fprintf(out,
+ out.printf(
"\n"
" %s\n"
" %f\n"
@@ -622,23 +622,23 @@ int FILE_INFO::write(FILE* out, bool to_server) {
name, nbytes, max_nbytes
);
if (strlen(md5_cksum)) {
- fprintf(out,
+ out.printf(
" %s\n",
md5_cksum
);
}
if (!to_server) {
- if (generated_locally) fprintf(out, " \n");
- fprintf(out, " %d\n", status);
- if (executable) fprintf(out, " \n");
- if (uploaded) fprintf(out, " \n");
- if (upload_when_present) fprintf(out, " \n");
- if (sticky) fprintf(out, " \n");
- if (signature_required) fprintf(out, " \n");
- if (file_signature) fprintf(out," \n%s\n", file_signature);
+ if (generated_locally) out.printf(" \n");
+ out.printf(" %d\n", status);
+ if (executable) out.printf(" \n");
+ if (uploaded) out.printf(" \n");
+ if (upload_when_present) out.printf(" \n");
+ if (sticky) out.printf(" \n");
+ if (signature_required) out.printf(" \n");
+ if (file_signature) out.printf(" \n%s\n", file_signature);
}
for (i=0; i%s\n", urls[i].text);
+ out.printf(" %s\n", urls[i].text);
}
if (!to_server && pers_file_xfer) {
retval = pers_file_xfer->write(out);
@@ -646,16 +646,16 @@ int FILE_INFO::write(FILE* out, bool to_server) {
}
if (!to_server) {
if (strlen(signed_xml) && strlen(xml_signature)) {
- fprintf(out, " \n%s \n", signed_xml);
+ out.printf(" \n%s \n", signed_xml);
}
if (strlen(xml_signature)) {
- fprintf(out, " \n%s \n", xml_signature);
+ out.printf(" \n%s \n", xml_signature);
}
}
if (!error_msg.empty()) {
- fprintf(out, " \n%s\n", error_msg.c_str());
+ out.printf(" \n%s\n", error_msg.c_str());
}
- fprintf(out, "\n");
+ out.printf("\n");
return 0;
}
@@ -702,7 +702,7 @@ bool FILE_INFO::had_failure(int& failnum) {
// Parse XML based app_version information, usually from client_state.xml
//
-int APP_VERSION::parse(FILE* in) {
+int APP_VERSION::parse(MIOFILE& in) {
char buf[256];
FILE_REF file_ref;
@@ -712,7 +712,7 @@ int APP_VERSION::parse(FILE* in) {
version_num = 0;
app = NULL;
project = NULL;
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", app_name, sizeof(app_name))) continue;
else if (match_tag(buf, "")) {
@@ -726,11 +726,11 @@ int APP_VERSION::parse(FILE* in) {
return ERR_XML_PARSE;
}
-int APP_VERSION::write(FILE* out) {
+int APP_VERSION::write(MIOFILE& out) {
unsigned int i;
int retval;
- fprintf(out,
+ out.printf(
"\n"
" %s\n"
" %d\n",
@@ -741,13 +741,13 @@ int APP_VERSION::write(FILE* out) {
retval = app_files[i].write(out);
if (retval) return retval;
}
- fprintf(out,
+ out.printf(
"\n"
);
return 0;
}
-int FILE_REF::parse(FILE* in) {
+int FILE_REF::parse(MIOFILE& in) {
char buf[256];
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
@@ -757,7 +757,7 @@ int FILE_REF::parse(FILE* in) {
fd = -1;
main_program = false;
copy_file = false;
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", file_name, sizeof(file_name))) continue;
else if (parse_str(buf, "", open_name, sizeof(open_name))) continue;
@@ -769,30 +769,30 @@ int FILE_REF::parse(FILE* in) {
return ERR_XML_PARSE;
}
-int FILE_REF::write(FILE* out) {
+int FILE_REF::write(MIOFILE& out) {
- fprintf(out,
+ out.printf(
" \n"
" %s\n",
file_name
);
if (strlen(open_name)) {
- fprintf(out, " %s\n", open_name);
+ out.printf(" %s\n", open_name);
}
if (fd >= 0) {
- fprintf(out, " %d\n", fd);
+ out.printf(" %d\n", fd);
}
if (main_program) {
- fprintf(out, " \n");
+ out.printf(" \n");
}
if (copy_file) {
- fprintf(out, " \n");
+ out.printf(" \n");
}
- fprintf(out, " \n");
+ out.printf(" \n");
return 0;
}
-int WORKUNIT::parse(FILE* in) {
+int WORKUNIT::parse(MIOFILE& in) {
char buf[256];
FILE_REF file_ref;
@@ -811,7 +811,7 @@ int WORKUNIT::parse(FILE* in) {
rsc_fpops_bound = 4e9*SECONDS_PER_DAY*7;
rsc_memory_bound = 1e8;
rsc_disk_bound = 1e9;
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", name, sizeof(name))) continue;
else if (parse_str(buf, "", app_name, sizeof(app_name))) continue;
@@ -832,10 +832,10 @@ int WORKUNIT::parse(FILE* in) {
return ERR_XML_PARSE;
}
-int WORKUNIT::write(FILE* out) {
+int WORKUNIT::write(MIOFILE& out) {
unsigned int i;
- fprintf(out,
+ out.printf(
"\n"
" %s\n"
" %s\n"
@@ -859,7 +859,7 @@ int WORKUNIT::write(FILE* out) {
for (i=0; i\n");
+ out.printf("\n");
return 0;
}
@@ -922,14 +922,14 @@ void RESULT::clear() {
// parse a element from scheduling server.
//
-int RESULT::parse_server(FILE* in) {
+int RESULT::parse_server(MIOFILE& in) {
char buf[256];
FILE_REF file_ref;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
clear();
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
if (parse_str(buf, "", name, sizeof(name))) continue;
if (parse_str(buf, "", wu_name, sizeof(wu_name))) continue;
@@ -946,14 +946,14 @@ int RESULT::parse_server(FILE* in) {
// parse a element from state file
//
-int RESULT::parse_state(FILE* in) {
+int RESULT::parse_state(MIOFILE& in) {
char buf[256];
FILE_REF file_ref;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
clear();
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) {
// restore some invariants in case of bad state file
//
@@ -976,7 +976,7 @@ int RESULT::parse_state(FILE* in) {
else if (match_tag(buf, "")) ready_to_report = true;
else if (parse_int(buf, "", state)) continue;
else if (match_tag(buf, "")) {
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) break;
stderr_out.append(buf);
}
@@ -987,12 +987,12 @@ int RESULT::parse_state(FILE* in) {
return ERR_XML_PARSE;
}
-int RESULT::write(FILE* out, bool to_server) {
+int RESULT::write(MIOFILE& out, bool to_server) {
unsigned int i;
FILE_INFO* fip;
int n, retval;
- fprintf(out,
+ out.printf(
"\n"
" %s\n"
" %f\n"
@@ -1004,24 +1004,26 @@ int RESULT::write(FILE* out, bool to_server) {
state
);
if (to_server) {
- fprintf(out,
+ out.printf(
" %d\n",
wup->version_num
);
}
n = stderr_out.length();
if (n) {
- fprintf(out, "\n");
+ out.printf("\n");
if (to_server) {
- fprintf(out,
+ out.printf(
"%d.%.2d\n",
gstate.core_client_major_version,
gstate.core_client_minor_version
);
}
- fprintf(out, stderr_out.c_str());
- if (stderr_out[n-1] != '\n') fprintf(out, "\n");
- fprintf(out, "\n");
+ out.printf(stderr_out.c_str());
+ if (stderr_out[n-1] != '\n') {
+ out.printf("\n");
+ }
+ out.printf("\n");
}
if (to_server) {
for (i=0; i\n");
- if (ready_to_report) fprintf(out, " \n");
- fprintf(out,
+ if (got_server_ack) out.printf(" \n");
+ if (ready_to_report) out.printf(" \n");
+ out.printf(
" %s\n"
" %d\n",
wu_name,
@@ -1045,7 +1047,7 @@ int RESULT::write(FILE* out, bool to_server) {
if (retval) return retval;
}
}
- fprintf(out, "\n");
+ out.printf("\n");
return 0;
}
diff --git a/client/client_types.h b/client/client_types.h
index b0d33b2897..62d1825511 100644
--- a/client/client_types.h
+++ b/client/client_types.h
@@ -34,6 +34,7 @@
#include "md5_file.h"
#include "hostinfo.h"
+#include "miofile.h"
#include "result_state.h"
#define MAX_BLOB_LEN 4096
@@ -85,8 +86,8 @@ public:
FILE_INFO();
~FILE_INFO();
int set_permissions();
- int parse(FILE*, bool from_server);
- int write(FILE*, bool to_server);
+ int parse(MIOFILE&, bool from_server);
+ int write(MIOFILE&, bool to_server);
int delete_file(); // attempt to delete the underlying file
char* get_url();
bool had_failure(int& failnum);
@@ -107,8 +108,8 @@ struct FILE_REF {
FILE_INFO* file_info;
bool copy_file; // if true, core client will copy the file instead of linking
- int parse(FILE*);
- int write(FILE*);
+ int parse(MIOFILE&);
+ int write(MIOFILE&);
};
class PROJECT {
@@ -180,8 +181,8 @@ public:
int write_account_file();
int parse_account(FILE*);
int parse_account_file();
- int parse_state(FILE*);
- int write_state(FILE*);
+ int parse_state(MIOFILE&);
+ int write_state(MIOFILE&);
// set min_rpc_time and have_reported_min_rpc_time
void set_min_rpc_time(time_t future_time);
@@ -193,8 +194,8 @@ struct APP {
char name[256];
PROJECT* project;
- int parse(FILE*);
- int write(FILE*);
+ int parse(MIOFILE&);
+ int write(MIOFILE&);
};
struct APP_VERSION {
@@ -205,8 +206,8 @@ struct APP_VERSION {
vector app_files;
int ref_cnt;
- int parse(FILE*);
- int write(FILE*);
+ int parse(MIOFILE&);
+ int write(MIOFILE&);
};
struct WORKUNIT {
@@ -227,8 +228,8 @@ struct WORKUNIT {
double rsc_memory_bound;
double rsc_disk_bound;
- int parse(FILE*);
- int write(FILE*);
+ int parse(MIOFILE&);
+ int write(MIOFILE&);
bool had_failure(int& failnum);
void get_file_errors(string&);
};
@@ -274,10 +275,10 @@ struct RESULT {
PROJECT* project;
void clear();
- int parse_server(FILE*);
- int parse_state(FILE*);
+ int parse_server(MIOFILE&);
+ int parse_state(MIOFILE&);
int parse_ack(FILE*);
- int write(FILE*, bool to_server);
+ int write(MIOFILE&, bool to_server);
bool is_upload_done(); // files uploaded?
void get_app_version_string(string&);
};
diff --git a/client/cs_scheduler.C b/client/cs_scheduler.C
index 2a580c3786..be247b4278 100644
--- a/client/cs_scheduler.C
+++ b/client/cs_scheduler.C
@@ -251,6 +251,7 @@ void CLIENT_STATE::compute_resource_debts() {
//
int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
FILE* f = boinc_fopen(SCHED_OP_REQUEST_FILE, "wb");
+ MIOFILE mf;
unsigned int i;
RESULT* rp;
int retval;
@@ -258,6 +259,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
char cross_project_id[MD5_LEN];
if (!f) return ERR_FOPEN;
+ mf.init_file(f);
fprintf(f,
"\n"
" %s\n"
@@ -280,7 +282,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
for (i=0; iproject != p) continue;
- avp->write(f);
+ avp->write(mf);
}
fprintf(f, " \n");
}
@@ -339,16 +341,16 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
}
fprintf(f, "\n");
- retval = time_stats.write(f, true);
+ retval = time_stats.write(mf, true);
if (retval) return retval;
- retval = net_stats.write(f, true);
+ retval = net_stats.write(mf, true);
if (retval) return retval;
- retval = host_info.write(f);
+ retval = host_info.write(mf);
if (retval) return retval;
for (i=0; iproject == p && rp->ready_to_report) {
- rp->write(f, true);
+ rp->write(mf, true);
}
}
read_trickle_files(p, f);
diff --git a/client/cs_statefile.C b/client/cs_statefile.C
index 13e99a4033..35269709e7 100644
--- a/client/cs_statefile.C
+++ b/client/cs_statefile.C
@@ -53,6 +53,8 @@ int CLIENT_STATE::parse_state_file() {
}
FILE* f = fopen(STATE_FILE_NAME, "r");
+ MIOFILE mf;
+ mf.init_file(f);
fgets(buf, 256, f);
if (!match_tag(buf, "")) {
retval = ERR_XML_PARSE;
@@ -63,7 +65,7 @@ int CLIENT_STATE::parse_state_file() {
retval = 0;
break;
} else if (match_tag(buf, "")) {
- temp_project.parse_state(f);
+ temp_project.parse_state(mf);
project = lookup_project(temp_project.master_url);
if (project) {
project->copy_state_fields(temp_project);
@@ -73,7 +75,7 @@ int CLIENT_STATE::parse_state_file() {
}
} else if (match_tag(buf, "")) {
APP* app = new APP;
- app->parse(f);
+ app->parse(mf);
if (project) {
retval = link_app(project, app);
if (!retval) apps.push_back(app);
@@ -82,7 +84,7 @@ int CLIENT_STATE::parse_state_file() {
}
} else if (match_tag(buf, "")) {
FILE_INFO* fip = new FILE_INFO;
- fip->parse(f, false);
+ fip->parse(mf, false);
if (project) {
retval = link_file_info(project, fip);
if (!retval) file_infos.push_back(fip);
@@ -102,7 +104,7 @@ int CLIENT_STATE::parse_state_file() {
}
} else if (match_tag(buf, "")) {
APP_VERSION* avp = new APP_VERSION;
- avp->parse(f);
+ avp->parse(mf);
if (project) {
retval = link_app_version(project, avp);
if (!retval) app_versions.push_back(avp);
@@ -111,7 +113,7 @@ int CLIENT_STATE::parse_state_file() {
}
} else if (match_tag(buf, "")) {
WORKUNIT* wup = new WORKUNIT;
- wup->parse(f);
+ wup->parse(mf);
if (project) {
retval = link_workunit(project, wup);
if (!retval) workunits.push_back(wup);
@@ -120,7 +122,7 @@ int CLIENT_STATE::parse_state_file() {
}
} else if (match_tag(buf, "")) {
RESULT* rp = new RESULT;
- rp->parse_state(f);
+ rp->parse_state(mf);
if (project) {
retval = link_result(project, rp);
if (!retval) results.push_back(rp);
@@ -131,16 +133,16 @@ int CLIENT_STATE::parse_state_file() {
delete rp;
}
} else if (match_tag(buf, "")) {
- retval = host_info.parse(f);
+ retval = host_info.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "")) {
- retval = time_stats.parse(f);
+ retval = time_stats.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "")) {
- retval = net_stats.parse(f);
+ retval = net_stats.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "")) {
- retval = active_tasks.parse(f, this);
+ retval = active_tasks.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "")) {
// should match our current platform name
@@ -150,7 +152,7 @@ int CLIENT_STATE::parse_state_file() {
} else if (parse_int(buf, "", old_major_version)) {
} else if (parse_int(buf, "", old_minor_version)) {
} else if (match_tag(buf, "")) {
- retval = pi.parse(f);
+ retval = pi.parse(mf);
if (retval) goto done;
// } else if (parse_int(buf, "")) {
} else if (parse_str(buf, "", host_venue, sizeof(host_venue))) {
@@ -189,7 +191,6 @@ int CLIENT_STATE::parse_venue() {
//
int CLIENT_STATE::write_state_file() {
FILE* f = boinc_fopen(STATE_FILE_TEMP, "w");
- int retval;
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
scope_messages.printf("CLIENT_STATE::write_state_file(): Writing state file\n");
@@ -197,7 +198,9 @@ int CLIENT_STATE::write_state_file() {
msg_printf(0, MSG_ERROR, "Can't open temp state file: %s\n", STATE_FILE_TEMP);
return ERR_FOPEN;
}
- retval = write_state(f);
+ MIOFILE mf;
+ mf.init_file(f);
+ int retval = write_state(mf);
fclose(f);
if (retval) return retval;
retval = boinc_rename(STATE_FILE_TEMP, STATE_FILE_NAME);
@@ -206,11 +209,11 @@ int CLIENT_STATE::write_state_file() {
return 0;
}
-int CLIENT_STATE::write_state(FILE* f) {
+int CLIENT_STATE::write_state(MIOFILE& f) {
unsigned int i, j;
int retval;
- fprintf(f, "\n");
+ f.printf("\n");
retval = host_info.write(f);
if (retval) return retval;
retval = time_stats.write(f, false);
@@ -244,7 +247,7 @@ int CLIENT_STATE::write_state(FILE* f) {
}
}
active_tasks.write(f);
- fprintf(f,
+ f.printf(
"%s\n"
"%d\n"
"%d\n",
@@ -256,13 +259,10 @@ int CLIENT_STATE::write_state(FILE* f) {
// save proxy info
//
pi.write(f);
-#if 0
- fprintf(f, "%d\n", user_run_request);
-#endif
if (strlen(host_venue)) {
- fprintf(f, "%s\n", host_venue);
+ f.printf("%s\n", host_venue);
}
- fprintf(f, "\n");
+ f.printf("\n");
return 0;
}
@@ -308,13 +308,15 @@ void CLIENT_STATE::check_anonymous() {
int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
char buf[256];
+ MIOFILE mf;
+ mf.init_file(in);
while (fgets(buf, 256, in)) {
if (match_tag(buf, "")) continue;
if (match_tag(buf, "")) return 0;
if (match_tag(buf, "")) {
FILE_INFO* fip = new FILE_INFO;
- if (fip->parse(in, false)) {
+ if (fip->parse(mf, false)) {
delete fip;
continue;
}
@@ -328,7 +330,7 @@ int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
}
if (match_tag(buf, "")) {
APP* app = new APP;
- if (app->parse(in)) {
+ if (app->parse(mf)) {
delete app;
continue;
}
@@ -342,7 +344,7 @@ int CLIENT_STATE::parse_app_info(PROJECT* p, FILE* in) {
}
if (match_tag(buf, "")) {
APP_VERSION* avp = new APP_VERSION;
- if (avp->parse(in)) {
+ if (avp->parse(mf)) {
delete avp;
continue;
}
diff --git a/client/gui_rpc_client.C b/client/gui_rpc_client.C
index d9591221cd..b8b0d753da 100644
--- a/client/gui_rpc_client.C
+++ b/client/gui_rpc_client.C
@@ -22,57 +22,80 @@
#endif
#ifndef _WIN32
+#include
+#include
+#include
#include
#include
#include
#include
-#include
-#include
#include
#include
+#include
#endif
#include "parse.h"
#include "error_numbers.h"
+#include "miofile.h"
#include "gui_rpc_client.h"
int RPC_CLIENT::init(char* path) {
- int sock, retval;
+ int retval;
sockaddr_in addr;
addr.sin_family = AF_INET;
addr.sin_port = htons(GUI_RPC_PORT);
- addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ //addr.sin_addr.s_addr = inet_addr("127.0.0.1");
+ addr.sin_addr.s_addr = htonl(INADDR_ANY);
sock = socket(AF_INET, SOCK_STREAM, 0);
+ if (sock <= 0) {
+ perror("socket");
+ exit(1);
+ }
retval = connect(sock, (const sockaddr*)(&addr), sizeof(addr));
if (retval) {
+#ifdef _WIN32
printf( "Windows Socket Error '%d'\n", WSAGetLastError() );
+#endif
perror("connect");
exit(1);
}
-#ifdef _WIN32
- fin = fdopen(dup(_open_osfhandle(sock, _O_RDONLY | _O_BINARY)), "r");
- fout = fdopen(_open_osfhandle(sock, _O_WRONLY | _O_BINARY), "w");
-#else
- fin = fdopen(dup(sock), "r");
- fout = fdopen(sock, "w");
-#endif
-
return 0;
}
RPC_CLIENT::~RPC_CLIENT() {
- fclose(fin);
- fclose(fout);
+}
+
+int RPC_CLIENT::send_request(char* p) {
+ send(sock, p, strlen(p), 0);
+}
+
+int RPC_CLIENT::get_reply(char*& mbuf) {
+ char buf[1025];
+ MFILE mf;
+ int n;
+
+ while (1) {
+ n = recv(sock, buf, 1024, 0);
+ if (n <= 0) break;
+ buf[n]=0;
+ mf.puts(buf);
+ if (strchr(buf, '\003')) break;
+ }
+ mf.get_buf(mbuf, n);
}
int RPC_CLIENT::get_state() {
char buf[256];
PROJECT* project;
+ char* mbuf;
- fprintf(fout, "\n");
- fflush(fout);
- while (fgets(buf, 256, fin)) {
+ send_request("\n");
+ get_reply(mbuf);
+ MIOFILE fin;
+ fin.init_buf(mbuf);
+
+ while (fin.fgets(buf, 256)) {
if (match_tag(buf, "")) break;
else if (match_tag(buf, "")) {
project = new PROJECT;
@@ -167,21 +190,27 @@ int RPC_CLIENT::get_messages(
int nmessages, int offset, vector& msgs
) {
char buf[256];
- fprintf(fout,
+ char* mbuf;
+
+ sprintf(buf,
"\n"
" %d\n"
" %d\n"
"\n",
nmessages, offset
);
- fflush(fout);
- while (fgets(buf, 256, fin)) {
+ send_request(buf);
+ get_reply(mbuf);
+ MIOFILE fin;
+ fin.init_buf(mbuf);
+
+ while (fin.fgets(buf, 256)) {
puts(buf);
if (match_tag(buf, "")) continue;
if (match_tag(buf, "")) break;
if (match_tag(buf, "")) {
MESSAGE_DESC md;
- while (fgets(buf, 256, fin)) {
+ while (fin.fgets(buf, 256)) {
puts(buf);
if (match_tag(buf, "")) break;
if (parse_str(buf, "", md.project)) continue;
@@ -235,9 +264,9 @@ void RPC_CLIENT::print() {
}
}
-int FILE_INFO::parse(FILE* in) {
+int FILE_INFO::parse(MIOFILE& in) {
char buf[256];
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", name)) continue;
else if (match_tag(buf, "")) {
@@ -282,9 +311,9 @@ void FILE_INFO::print() {
printf(" generated locally: %s\n", generated_locally?"yes":"no");
}
-int PROJECT::parse(FILE* in) {
+int PROJECT::parse(MIOFILE& in) {
char buf[256];
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "")) return 0;
else if (parse_str(buf, "", name)) continue;
}
@@ -345,9 +374,9 @@ void APP::print() {
printf(" Project: %s\n", project->project_name.c_str());
}
-int APP_VERSION::parse(FILE* in) {
+int APP_VERSION::parse(MIOFILE& in) {
char buf[256];
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", app_name)) continue;
else if (parse_int(buf, "", version_num)) continue;
@@ -361,9 +390,9 @@ void APP_VERSION::print() {
printf(" project: %s\n", project->project_name.c_str());
}
-int WORKUNIT::parse(FILE* in) {
+int WORKUNIT::parse(MIOFILE& in) {
char buf[256];
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", name)) continue;
else if (parse_str(buf, "", app_name)) continue;
@@ -384,9 +413,9 @@ void WORKUNIT::print() {
printf(" disk bound: %f\n", rsc_disk_bound);
}
-int RESULT::parse(FILE* in) {
+int RESULT::parse(MIOFILE& in) {
char buf[256];
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", name)) continue;
else if (parse_str(buf, "", wu_name)) continue;
@@ -424,9 +453,9 @@ void RESULT::print() {
printf(" stderr_out: %s\n", stderr_out.c_str());
}
-int ACTIVE_TASK::parse(FILE* in) {
+int ACTIVE_TASK::parse(MIOFILE& in) {
char buf[256];
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_str(buf, "", result_name)) continue;
else if (parse_int(buf, "", app_version_num)) continue;
diff --git a/client/gui_rpc_client.h b/client/gui_rpc_client.h
index 60767f4445..d07103090c 100644
--- a/client/gui_rpc_client.h
+++ b/client/gui_rpc_client.h
@@ -26,6 +26,8 @@ using std::string;
using std::vector;
#endif
+#include "miofile.h"
+
#define GUI_RPC_PORT 31416
struct PROJECT;
@@ -45,7 +47,7 @@ struct FILE_INFO {
string hostname;
PROJECT* project;
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -68,7 +70,7 @@ struct PROJECT {
bool sched_rpc_pending; // contact scheduling server for preferences
bool tentative; // master URL and account ID not confirmed
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -76,7 +78,7 @@ struct APP {
string name;
PROJECT* project;
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -86,7 +88,7 @@ struct APP_VERSION {
APP* app;
PROJECT* project;
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -102,7 +104,7 @@ struct WORKUNIT {
APP* app;
APP_VERSION* avp;
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -122,7 +124,7 @@ struct RESULT {
WORKUNIT* wup;
PROJECT* project;
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -135,7 +137,7 @@ struct ACTIVE_TASK {
PROJECT* project;
RESULT* result;
- int parse(FILE*);
+ int parse(MIOFILE&);
void print();
};
@@ -160,8 +162,8 @@ struct MESSAGE_DESC {
class RPC_CLIENT {
int sock;
- FILE* fin;
- FILE* fout;
+ int send_request(char*);
+ int get_reply(char*&);
public:
vector projects;
vector file_infos;
diff --git a/client/gui_rpc_server.C b/client/gui_rpc_server.C
index eb49fa68fc..d04b30da9b 100644
--- a/client/gui_rpc_server.C
+++ b/client/gui_rpc_server.C
@@ -41,18 +41,9 @@
GUI_RPC_CONN::GUI_RPC_CONN(int s) {
sock = s;
-
-#ifdef _WIN32
- fout = fdopen(dup(_open_osfhandle(sock, _O_RDWR | _O_BINARY)), "w");
- setvbuf(fout, buffer, _IOFBF, 262144);
- memset(buffer, NULL, 262144);
-#else
- fout = fdopen(dup(sock), "w");
-#endif
}
GUI_RPC_CONN::~GUI_RPC_CONN() {
- fclose(fout);
#ifdef _WIN32
closesocket(sock);
#else
@@ -60,84 +51,84 @@ GUI_RPC_CONN::~GUI_RPC_CONN() {
#endif
}
-static PROJECT* get_project(char* buf, FILE* fout) {
+static PROJECT* get_project(char* buf, MIOFILE& fout) {
string url;
if (!parse_str(buf, "", url)) {
- fprintf(fout, "Missing project URL\n");
+ fout.printf("Missing project URL\n");
return 0;
}
PROJECT* p = gstate.lookup_project(url.c_str());
if (!p) {
- fprintf(fout, "No such project\n");
+ fout.printf("No such project\n");
return 0 ;
}
return p;
}
-static void handle_result_show_graphics(char* buf, FILE* fout) {
+static void handle_result_show_graphics(char* buf, MIOFILE& fout) {
string result_name;
PROJECT* p = get_project(buf, fout);
if (!p) return;
if (!parse_str(buf, "", result_name)) {
- fprintf(fout, "Missing result name\n");
+ fout.printf("Missing result name\n");
return;
}
RESULT* rp = gstate.lookup_result(p, result_name.c_str());
if (!rp) {
- fprintf(fout, "No such result\n");
+ fout.printf("No such result\n");
return;
}
ACTIVE_TASK* atp = gstate.lookup_active_task_by_result(rp);
if (!atp) {
- fprintf(fout, "Result not active\n");
+ fout.printf("Result not active\n");
return;
}
atp->request_graphics_mode(MODE_WINDOW);
- fprintf(fout, "\n");
+ fout.printf("\n");
}
-static void handle_project_reset(char* buf, FILE* fout) {
+static void handle_project_reset(char* buf, MIOFILE& fout) {
PROJECT* p = get_project(buf, fout);
if (p) {
gstate.reset_project(p);
- fprintf(fout, "\n");
+ fout.printf("\n");
}
}
-static void handle_project_attach(char* buf, FILE* fout) {
+static void handle_project_attach(char* buf, MIOFILE& fout) {
string url, authenticator;
if (!parse_str(buf, "", url)) {
- fprintf(fout, "Missing URL\n");
+ fout.printf("Missing URL\n");
return;
}
if (!parse_str(buf, "", authenticator)) {
- fprintf(fout, "Missing authenticator\n");
+ fout.printf("Missing authenticator\n");
return;
}
gstate.add_project(url.c_str(), authenticator.c_str());
- fprintf(fout, "\n");
+ fout.printf("\n");
}
-static void handle_project_detach(char* buf, FILE* fout) {
+static void handle_project_detach(char* buf, MIOFILE& fout) {
PROJECT* p = get_project(buf, fout);
if (p) {
gstate.detach_project(p);
- fprintf(fout, "\n");
+ fout.printf("\n");
}
}
-static void handle_project_update(char* buf, FILE* fout) {
+static void handle_project_update(char* buf, MIOFILE& fout) {
PROJECT* p = get_project(buf, fout);
if (p) {
p->sched_rpc_pending = true;
p->min_rpc_time = 0;
- fprintf(fout, "\n");
+ fout.printf("\n");
}
}
-static void handle_set_run_mode(char* buf, FILE* fout) {
+static void handle_set_run_mode(char* buf, MIOFILE& fout) {
if (match_tag(buf, "")) {
gstate.user_run_request = USER_RUN_REQUEST_ALWAYS;
} else if (match_tag(buf, "")) {
@@ -145,43 +136,43 @@ static void handle_set_run_mode(char* buf, FILE* fout) {
} else if (match_tag(buf, "")) {
gstate.user_run_request = USER_RUN_REQUEST_AUTO;
} else {
- fprintf(fout, "Missing mode\n");
+ fout.printf("Missing mode\n");
return;
}
- fprintf(fout, "\n");
+ fout.printf("\n");
}
-static void handle_run_benchmarks(char* buf, FILE* fout) {
+static void handle_run_benchmarks(char* buf, MIOFILE& fout) {
// TODO: suspend activities; make sure run at right priority
//
gstate.start_cpu_benchmarks();
- fprintf(fout, "\n");
+ fout.printf("\n");
}
-static void handle_set_proxy_settings(char* buf, FILE* fout) {
+static void handle_set_proxy_settings(char* buf, MIOFILE& fout) {
string socks_proxy_server_name,http_proxy_server_name;
int socks_proxy_server_port,http_proxy_server_port;
if (!parse_str(buf, "", socks_proxy_server_name)) {
- fprintf(fout, "SOCKS proxy server name missing\n");
+ fout.printf("SOCKS proxy server name missing\n");
return;
}
if (!parse_int(buf, "", socks_proxy_server_port)) {
- fprintf(fout, "SOCKS proxy server port missing\n");
+ fout.printf("SOCKS proxy server port missing\n");
return;
}
if (!parse_str(buf, "", http_proxy_server_name)) {
- fprintf(fout, "HTTP proxy server name missing\n");
+ fout.printf("HTTP proxy server name missing\n");
return;
}
if (!parse_int(buf, "", http_proxy_server_port)) {
- fprintf(fout, "HTTP proxy server port missing\n");
+ fout.printf("HTTP proxy server port missing\n");
return;
}
safe_strcpy(gstate.pi.socks_server_name, socks_proxy_server_name.c_str());
gstate.pi.socks_server_port = socks_proxy_server_port;
safe_strcpy(gstate.pi.http_server_name, http_proxy_server_name.c_str());
gstate.pi.http_server_port = http_proxy_server_port;
- fprintf(fout, "\n");
+ fout.printf("\n");
}
// params:
@@ -191,14 +182,14 @@ static void handle_set_proxy_settings(char* buf, FILE* fout) {
// start at message n.
// if no offset is given, return last n messages
//
-void handle_get_messages(char* buf, FILE* fout) {
+void handle_get_messages(char* buf, MIOFILE& fout) {
int nmessages=-1, offset=-1, j;
unsigned int i;
parse_int(buf, "", nmessages);
parse_int(buf, "", offset);
if (nmessages < 0) {
- fprintf(fout, "No nmessages given\n");
+ fout.printf("No nmessages given\n");
return;
}
@@ -212,11 +203,11 @@ void handle_get_messages(char* buf, FILE* fout) {
}
}
- fprintf(fout, "\n");
+ fout.printf("\n");
j = 0;
for (i=offset; i\n"
" %d\n"
" %d\n"
@@ -228,19 +219,23 @@ void handle_get_messages(char* buf, FILE* fout) {
md.timestamp
);
if (md.project) {
- fprintf(fout,
+ fout.printf(
" %s\n",
md.project->get_project_name()
);
}
- fprintf(fout, "\n");
+ fout.printf("\n");
}
- fprintf(fout, "\n");
+ fout.printf("\n");
}
int GUI_RPC_CONN::handle_rpc() {
- char buf[1024];
+ char request_msg[1024];
int n;
+ MIOFILE mf;
+ MFILE m;
+ char* p;
+ mf.init_mfile(&m);
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_GUIRPC);
@@ -249,44 +244,40 @@ int GUI_RPC_CONN::handle_rpc() {
// of malformed request msgs
//
#ifdef _WIN32
- n = recv(sock, buf, 1024, 0);
+ n = recv(sock, request_msg, 1024, 0);
#else
- n = read(sock, buf, 1024);
+ n = read(sock, request_msg, 1024);
#endif
if (n <= 0) return -1;
- buf[n] = 0;
-
- scope_messages.printf("GUI RPC Command = '%s'\n", buf);
-
- if (match_tag(buf, "")) {
- handle_result_show_graphics(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_project_reset(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_project_attach(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_project_detach(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_project_update(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_set_run_mode(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_run_benchmarks(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_set_proxy_settings(buf, fout);
- } else if (match_tag(buf, "")) {
- handle_get_messages(buf, fout);
+ request_msg[n] = 0;
+ msg_printf(NULL, MSG_INFO, "GUI RPC command '%s'\n", request_msg);
+ if (match_tag(request_msg, "")) {
+ handle_result_show_graphics(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_project_reset(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_project_attach(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_project_detach(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_project_update(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_set_run_mode(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_run_benchmarks(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_set_proxy_settings(request_msg, mf);
+ } else if (match_tag(request_msg, "")) {
+ handle_get_messages(request_msg, mf);
} else {
- fprintf(fout, "\n");
+ mf.printf("\n");
}
-#ifdef WIN32
- send(sock, fout->_base, strlen(fout->_base), NULL);
-#else
- fflush(fout);
-#endif
+ mf.printf("\003");
+ m.get_buf(p, n);
+ send(sock, p, n, 0);
return 0;
}
@@ -300,15 +291,12 @@ int GUI_RPC_CONN_SET::init() {
sockaddr_in addr;
int retval;
- SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_GUIRPC);
-
lsock = socket(AF_INET, SOCK_STREAM, 0);
- if (lsock < 0)
- {
- scope_messages.printf("GUI RPC failed to initialize socket (retval = '%d')\n", lsock);
-#ifdef _WIN32
- scope_messages.printf("Windows Socket Error = '%d')\n", WSAGetLastError());
-#endif
+ if (lsock < 0) {
+ msg_printf(NULL, MSG_ERROR,
+ "GUI RPC failed to initialize socket (retval = '%d')\n",
+ lsock
+ );
return ERR_SOCKET;
}
@@ -316,20 +304,22 @@ int GUI_RPC_CONN_SET::init() {
addr.sin_port = htons(GUI_RPC_PORT);
addr.sin_addr.s_addr = htonl(INADDR_ANY);
+ int one = 1;
+ setsockopt(lsock, SOL_SOCKET, SO_REUSEADDR, (char*)&one, 4);
+
retval = bind(lsock, (const sockaddr*)(&addr), sizeof(addr));
if (retval) {
- scope_messages.printf("GUI RPC failed to bind to socket (retval = '%d')\n", retval);
-#ifdef _WIN32
- scope_messages.printf("Windows Socket Error = '%d')\n", WSAGetLastError());
-#endif
+ msg_printf(NULL, MSG_ERROR,
+ "GUI RPC bind failed (retval = '%d')\n", retval
+ );
return ERR_BIND;
}
retval = listen(lsock, 999);
if (retval) {
- scope_messages.printf("GUI RPC failed to put socket into listening state (retval = '%d')\n", retval);
-#ifdef _WIN32
- scope_messages.printf("Windows Socket Error = '%d')\n", WSAGetLastError());
-#endif
+ msg_printf(NULL, MSG_ERROR,
+ "GUI RPC listen failed (retval = '%d')\n",
+ retval
+ );
return ERR_LISTEN;
}
return 0;
@@ -340,7 +330,6 @@ bool GUI_RPC_CONN_SET::poll() {
if (lsock >= 0) {
unsigned int i;
- char buf[256];
fd_set read_fds, error_fds;
int sock, retval;
vector::iterator iter;
@@ -379,11 +368,6 @@ bool GUI_RPC_CONN_SET::poll() {
} else {
GUI_RPC_CONN* gr = new GUI_RPC_CONN(sock);
insert(gr);
-#ifdef WIN32
- send(gr->sock, buf, strlen(buf), NULL);
-#else
- write(gr->sock, buf, strlen(buf));
-#endif
}
}
iter = gui_rpcs.begin();
@@ -406,11 +390,6 @@ bool GUI_RPC_CONN_SET::poll() {
gui_rpcs.erase(iter);
continue;
}
-#ifdef WIN32
- send(gr->sock, buf, strlen(buf), NULL);
-#else
- write(gr->sock, buf, strlen(buf));
-#endif
}
iter++;
}
diff --git a/client/gui_rpc_server.h b/client/gui_rpc_server.h
index c1275f0127..b1e4e53245 100644
--- a/client/gui_rpc_server.h
+++ b/client/gui_rpc_server.h
@@ -20,7 +20,6 @@
class GUI_RPC_CONN {
public:
int sock;
- FILE* fout;
char buffer[262144];
GUI_RPC_CONN(int);
~GUI_RPC_CONN();
diff --git a/client/gui_test.C b/client/gui_test.C
index a0ea35afae..fc614b62dd 100644
--- a/client/gui_test.C
+++ b/client/gui_test.C
@@ -54,7 +54,6 @@ int main(int argc, char** argv) {
vector message_descs;
#ifdef _WIN32
- // Initialize WinSock
if ( WinsockInitialize() != 0 ) {
printf(
"BOINC Core Client Error Message\n"
diff --git a/client/hostinfo.C b/client/hostinfo.C
index 0188d5d926..2634a95a3f 100644
--- a/client/hostinfo.C
+++ b/client/hostinfo.C
@@ -81,13 +81,13 @@ void HOST_INFO::clear_host_info() {
// Parse the host information, usually from the client state XML file
//
-int HOST_INFO::parse(FILE* in) {
+int HOST_INFO::parse(MIOFILE& in) {
char buf[256];
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
memset(this, 0, sizeof(HOST_INFO));
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_int(buf, "", timezone)) continue;
else if (parse_str(buf, "", domain_name, sizeof(domain_name))) continue;
@@ -127,8 +127,8 @@ int HOST_INFO::parse(FILE* in) {
// Write the host information, usually to the client state XML file
//
-int HOST_INFO::write(FILE* out) {
- fprintf(out,
+int HOST_INFO::write(MIOFILE& out) {
+ out.printf(
"\n"
" %d\n"
" %s\n"
diff --git a/client/hostinfo.h b/client/hostinfo.h
index 6a8e711e87..5ed372492d 100644
--- a/client/hostinfo.h
+++ b/client/hostinfo.h
@@ -20,6 +20,8 @@
#ifndef _HOSTINFO_
#define _HOSTINFO_
+#include "miofile.h"
+
// Other host-specific info is kept in
// TIME_STATS (on/connected/active fractions)
// NET_STATS (average network bandwidths)
@@ -51,8 +53,8 @@ struct HOST_INFO {
double d_total;
double d_free;
- int parse(FILE*);
- int write(FILE*);
+ int parse(MIOFILE&);
+ int write(MIOFILE&);
int parse_cpu_benchmarks(FILE*);
int write_cpu_benchmarks(FILE*);
diff --git a/client/makefile.gui_test b/client/makefile.gui_test
index e52eaf6a22..a2b6869b7b 100644
--- a/client/makefile.gui_test
+++ b/client/makefile.gui_test
@@ -1,2 +1,2 @@
-gui_test: gui_test.C gui_rpc_client.C gui_rpc_client.h
- g++ -g -I../lib -o gui_test -lnsl -lsocket gui_test.C gui_rpc_client.C ../lib/libboinc.a
+gui_test: gui_test.C gui_rpc_client.C gui_rpc_client.h miofile.C
+ g++ -g -I../lib -o gui_test -lnsl -lsocket gui_test.C miofile.C gui_rpc_client.C ../lib/libboinc.a
diff --git a/client/miofile.C b/client/miofile.C
new file mode 100644
index 0000000000..a043df1b73
--- /dev/null
+++ b/client/miofile.C
@@ -0,0 +1,87 @@
+#include
+#include
+
+#include "error_numbers.h"
+#include "miofile.h"
+
+MIOFILE::MIOFILE() {
+ mf = 0;
+ f = 0;
+ buf = 0;
+}
+
+MIOFILE::~MIOFILE() {
+}
+
+void MIOFILE::init_mfile(MFILE* _mf) {
+ mf = _mf;
+}
+
+void MIOFILE::init_file(FILE* _f) {
+ f = _f;
+}
+
+void MIOFILE::init_buf(char* _buf) {
+ buf = _buf;
+}
+
+int MIOFILE::printf(const char* format, ...) {
+ int retval;
+
+ va_list ap;
+ va_start(ap, format);
+ if (mf) {
+ retval = mf->vprintf(format, ap);
+ } else {
+ retval = vfprintf(f, format, ap);
+ }
+ va_end(ap);
+ return retval;
+}
+
+char* MIOFILE::fgets(char* dst, int len) {
+ if (f) {
+ return ::fgets(dst, len, f);
+ }
+ char* q = strchr(buf, '\n');
+ if (!q) return 0;
+
+ q++;
+ int n = q - buf;
+ if (n > len-1) n = len-1;
+ memcpy(dst, buf, n);
+ dst[n] = 0;
+
+ buf = q;
+ return dst;
+}
+
+// copy from a file to static buffer
+//
+int copy_element_contents(MIOFILE& in, const char* end_tag, char* p, int len) {
+ char buf[256];
+
+ strcpy(p, "");
+ while (in.fgets(buf, 256)) {
+ if (strstr(buf, end_tag)) {
+ return 0;
+ }
+ strcat(p, buf);
+ }
+ fprintf(stderr, "copy_element_contents(): no end tag\n");
+ return ERR_XML_PARSE;
+}
+
+int copy_element_contents(MIOFILE& in, const char* end_tag, string& str) {
+ char buf[256];
+
+ str = "";
+ while (in.fgets(buf, 256)) {
+ if (strstr(buf, end_tag)) {
+ return 0;
+ }
+ str += buf;
+ }
+ fprintf(stderr, "copy_element_contents(): no end tag\n");
+ return ERR_XML_PARSE;
+}
diff --git a/client/miofile.h b/client/miofile.h
new file mode 100644
index 0000000000..16a2b3be9d
--- /dev/null
+++ b/client/miofile.h
@@ -0,0 +1,44 @@
+#ifndef _MIOFILE_
+#define _MIOFILE_
+
+#ifndef _WIN32
+#include
+using namespace std;
+#endif
+
+#include "mfile.h"
+
+// MIOFILE lets you do formatted I/O to either a FILE or a memory buffer,
+// depending on how you initialize it.
+//
+// output:
+// init_file(): output goes to the FILE* that you specify
+// init_mfile(): output goes to an MFILE (i.e. a memory buffer);
+// you can call MFILE::get_buf() to get the results
+// input:
+// init_file(): input comes from the FILE* that you specify
+// init_buf(): input comes from the buffer you specify.
+// This string is not modified.
+//
+// Why is this here? Because on Windows (9x, maybe all)
+// you can't do fdopen() on a socket.
+
+class MIOFILE {
+public:
+ MIOFILE();
+ ~MIOFILE();
+ void init_mfile(MFILE*);
+ void init_file(FILE*);
+ void init_buf(char*);
+ int printf(const char* format, ...);
+ char* fgets(char*, int);
+private:
+ MFILE* mf;
+ FILE* f;
+ char* buf;
+};
+
+extern int copy_element_contents(MIOFILE& in, const char* end_tag, char* p, int len);
+extern int copy_element_contents(MIOFILE& in, const char* end_tag, string&);
+
+#endif
diff --git a/client/net_stats.C b/client/net_stats.C
index 945f32bc68..a86e602d8f 100644
--- a/client/net_stats.C
+++ b/client/net_stats.C
@@ -95,8 +95,8 @@ void NET_STATS::poll(NET_XFER_SET& nxs) {
// Write XML based network statistics
//
-int NET_STATS::write(FILE* out, bool to_server) {
- fprintf(out,
+int NET_STATS::write(MIOFILE& out, bool to_server) {
+ out.printf(
"\n"
" %f\n"
" %f\n"
@@ -109,12 +109,12 @@ int NET_STATS::write(FILE* out, bool to_server) {
// Read XML based network statistics
//
-int NET_STATS::parse(FILE* in) {
+int NET_STATS::parse(MIOFILE& in) {
char buf[256];
double bwup, bwdown;
memset(this, 0, sizeof(NET_STATS));
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_double(buf, "", bwup)) {
up.starting_throughput = bwup;
diff --git a/client/net_stats.h b/client/net_stats.h
index 1a50e5b782..7020545f04 100644
--- a/client/net_stats.h
+++ b/client/net_stats.h
@@ -49,6 +49,6 @@ public:
NET_STATS();
void poll(NET_XFER_SET&);
- int write(FILE*, bool to_server);
- int parse(FILE*);
+ int write(MIOFILE&, bool to_server);
+ int parse(MIOFILE&);
};
diff --git a/client/net_xfer.h b/client/net_xfer.h
index 10c9e71734..00305a0b98 100644
--- a/client/net_xfer.h
+++ b/client/net_xfer.h
@@ -27,8 +27,8 @@
#endif
-// The following classes provide an interface for polling
-// (non-blocking) network I/O.
+// The following classes implement polling (non-blocking) I/O
+// between a disk file (or memory block) and a socket
#define MAX_BLOCKSIZE 16384
diff --git a/client/pers_file_xfer.C b/client/pers_file_xfer.C
index be79007b03..838103d336 100644
--- a/client/pers_file_xfer.C
+++ b/client/pers_file_xfer.C
@@ -326,10 +326,10 @@ void PERS_FILE_XFER::retry_or_backoff() {
// Parse XML information about a single persistent file transfer
//
-int PERS_FILE_XFER::parse(FILE* fin) {
+int PERS_FILE_XFER::parse(MIOFILE& fin) {
char buf[256];
- while (fgets(buf, 256, fin)) {
+ while (fin.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_int(buf, "", nretry)) continue;
else if (parse_int(buf, "", first_request_time)) continue;
@@ -344,8 +344,8 @@ int PERS_FILE_XFER::parse(FILE* fin) {
// Write XML information about a particular persistent file transfer
//
-int PERS_FILE_XFER::write(FILE* fout) {
- fprintf(fout,
+int PERS_FILE_XFER::write(MIOFILE& fout) {
+ fout.printf(
" \n"
" %d\n"
" %d\n"
@@ -355,7 +355,7 @@ int PERS_FILE_XFER::write(FILE* fout) {
nretry, first_request_time, next_request_time, time_so_far
);
if (fxp) {
- fprintf(fout,
+ fout.printf(
" \n"
" %f\n"
" %f\n"
diff --git a/client/pers_file_xfer.h b/client/pers_file_xfer.h
index 955ca950c6..9439fbdb0e 100644
--- a/client/pers_file_xfer.h
+++ b/client/pers_file_xfer.h
@@ -70,8 +70,8 @@ public:
void handle_xfer_failure();
void retry_or_backoff();
void giveup(char*);
- int write(FILE* fout);
- int parse(FILE* fin);
+ int write(MIOFILE& fout);
+ int parse(MIOFILE& fin);
int start_xfer();
void suspend();
};
diff --git a/client/proxy.C b/client/proxy.C
index d9c6dcd64d..bb93cca592 100644
--- a/client/proxy.C
+++ b/client/proxy.C
@@ -84,13 +84,13 @@ void print_buf( char *buf, int n ) {
printf( "\n" );
}
-int PROXY_INFO::parse(FILE* in) {
+int PROXY_INFO::parse(MIOFILE& in) {
char buf[256];
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
memset(this, 0, sizeof(PROXY_INFO));
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (match_tag(buf, "")) use_http_proxy = true;
else if (match_tag(buf, "")) use_socks_proxy = true;
@@ -106,8 +106,8 @@ int PROXY_INFO::parse(FILE* in) {
return 0;
}
-int PROXY_INFO::write(FILE* out) {
- fprintf(out,
+int PROXY_INFO::write(MIOFILE& out) {
+ out.printf(
"\n"
"%s"
"%s"
diff --git a/client/proxy.h b/client/proxy.h
index 7c00dce371..4ef39242f1 100644
--- a/client/proxy.h
+++ b/client/proxy.h
@@ -33,8 +33,8 @@ struct PROXY_INFO {
char socks5_user_name[256];
char socks5_user_passwd[256];
- int parse(FILE*);
- int write(FILE*);
+ int parse(MIOFILE&);
+ int write(MIOFILE&);
void clear();
};
diff --git a/client/scheduler_op.C b/client/scheduler_op.C
index 4a9be27afe..56cf9fdbb4 100644
--- a/client/scheduler_op.C
+++ b/client/scheduler_op.C
@@ -552,6 +552,8 @@ SCHEDULER_REPLY::~SCHEDULER_REPLY() {
int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
char buf[256], *p;
int retval;
+ MIOFILE mf;
+ mf.init_file(in);
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_SCHED_OP);
@@ -640,24 +642,24 @@ int SCHEDULER_REPLY::parse(FILE* in, PROJECT* project) {
if (retval) return ERR_XML_PARSE;
} else if (match_tag(buf, "")) {
APP app;
- app.parse(in);
+ app.parse(mf);
apps.push_back(app);
} else if (match_tag(buf, "")) {
FILE_INFO file_info;
- file_info.parse(in, true);
+ file_info.parse(mf, true);
file_infos.push_back(file_info);
} else if (match_tag(buf, "")) {
APP_VERSION av;
- av.parse(in);
+ av.parse(mf);
app_versions.push_back(av);
} else if (match_tag(buf, "")) {
WORKUNIT wu;
- wu.parse(in);
+ wu.parse(mf);
workunits.push_back(wu);
} else if (match_tag(buf, "")) {
RESULT result; // make sure this is here so constructor
// gets called each time
- result.parse_server(in);
+ result.parse_server(mf);
results.push_back(result);
} else if (match_tag(buf, "")) {
RESULT result;
diff --git a/client/time_stats.C b/client/time_stats.C
index bccffd3920..8f7ada0fdf 100644
--- a/client/time_stats.C
+++ b/client/time_stats.C
@@ -90,8 +90,8 @@ void TIME_STATS::update(bool is_connected, bool is_active) {
// Write XML based time statistics
//
-int TIME_STATS::write(FILE* out, bool to_server) {
- fprintf(out,
+int TIME_STATS::write(MIOFILE& out, bool to_server) {
+ out.printf(
"\n"
" %f\n"
" %f\n"
@@ -101,23 +101,23 @@ int TIME_STATS::write(FILE* out, bool to_server) {
active_frac
);
if (!to_server) {
- fprintf(out,
+ out.printf(
" %d\n",
last_update
);
}
- fprintf(out, "\n");
+ out.printf("\n");
return 0;
}
// Parse XML based time statistics, usually from client_state.xml
//
-int TIME_STATS::parse(FILE* in) {
+int TIME_STATS::parse(MIOFILE& in) {
char buf[256];
SCOPE_MSG_LOG scope_messages(log_messages, CLIENT_MSG_LOG::DEBUG_STATE);
- while (fgets(buf, 256, in)) {
+ while (in.fgets(buf, 256)) {
if (match_tag(buf, "")) return 0;
else if (parse_int(buf, "", last_update)) continue;
else if (parse_double(buf, "", on_frac)) continue;
diff --git a/client/time_stats.h b/client/time_stats.h
index 6332ddca66..990f214a38 100644
--- a/client/time_stats.h
+++ b/client/time_stats.h
@@ -35,6 +35,6 @@ public:
void update(bool is_connected, bool is_active);
TIME_STATS();
- int write(FILE*, bool to_server);
- int parse(FILE*);
+ int write(MIOFILE&, bool to_server);
+ int parse(MIOFILE&);
};
diff --git a/doc/boinc_dev.php b/doc/boinc_dev.php
index 0010aab246..c7e1350408 100644
--- a/doc/boinc_dev.php
+++ b/doc/boinc_dev.php
@@ -24,6 +24,7 @@ before getting into the source code.
FSM structure
Data structures
Main loop logic
+ Result scheduling
Debugging
Host measurements
Host identification
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 7438512040..1d49fc3d6b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -12,7 +12,6 @@ EXTRA_DIST = result_state.h parse.h std_fixes.h util.h
libboinc_a_SOURCES = \
../api/boinc_api.C \
- ../api/mfile.C \
app_ipc.C \
base64.C \
diagnostics.C \
@@ -21,6 +20,7 @@ libboinc_a_SOURCES = \
language.C \
md5.c \
md5_file.C \
+ mfile.C \
parse.C \
shmem.C \
util.C
diff --git a/lib/Makefile.in b/lib/Makefile.in
index 4d97415994..0cd6845a81 100644
--- a/lib/Makefile.in
+++ b/lib/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
@@ -180,7 +180,6 @@ EXTRA_DIST = result_state.h parse.h std_fixes.h util.h
# libboinc.a is for use by applications (not core client or server)
libboinc_a_SOURCES = \
../api/boinc_api.C \
- ../api/mfile.C \
app_ipc.C \
base64.C \
diagnostics.C \
@@ -189,6 +188,7 @@ libboinc_a_SOURCES = \
language.C \
md5.c \
md5_file.C \
+ mfile.C \
parse.C \
shmem.C \
util.C
@@ -212,10 +212,10 @@ LIBRARIES = $(noinst_LIBRARIES)
libboinc_a_AR = $(AR) cru
libboinc_a_LIBADD =
-am_libboinc_a_OBJECTS = boinc_api.$(OBJEXT) mfile.$(OBJEXT) \
- app_ipc.$(OBJEXT) base64.$(OBJEXT) diagnostics.$(OBJEXT) \
- exception.$(OBJEXT) filesys.$(OBJEXT) language.$(OBJEXT) \
- md5.$(OBJEXT) md5_file.$(OBJEXT) parse.$(OBJEXT) \
+am_libboinc_a_OBJECTS = boinc_api.$(OBJEXT) app_ipc.$(OBJEXT) \
+ base64.$(OBJEXT) diagnostics.$(OBJEXT) exception.$(OBJEXT) \
+ filesys.$(OBJEXT) language.$(OBJEXT) md5.$(OBJEXT) \
+ md5_file.$(OBJEXT) mfile.$(OBJEXT) parse.$(OBJEXT) \
shmem.$(OBJEXT) util.$(OBJEXT)
libboinc_a_OBJECTS = $(am_libboinc_a_OBJECTS)
EXTRA_PROGRAMS = md5_test$(EXEEXT) shmem_test$(EXEEXT) msg_test$(EXEEXT)
@@ -285,7 +285,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)
@@ -400,28 +399,6 @@ boinc_api.obj: ../api/boinc_api.C
@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'`
-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@ 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@
-@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.o `test -f '../api/mfile.C' || echo '$(srcdir)/'`../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@ 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'`
-
.c.o:
@am__fastdepCC_TRUE@ if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" \
@am__fastdepCC_TRUE@ -c -o $@ `test -f '$<' || echo '$(srcdir)/'`$<; \
diff --git a/api/mfile.C b/lib/mfile.C
similarity index 90%
rename from api/mfile.C
rename to lib/mfile.C
index 64de183e4d..5ff063b337 100644
--- a/api/mfile.C
+++ b/lib/mfile.C
@@ -39,22 +39,27 @@ using namespace std;
#include "error_numbers.h"
#include "mfile.h"
-int MFILE::open(const char* path, const char* mode) {
+
+MFILE::MFILE() {
buf = 0;
len = 0;
+}
+
+MFILE::~MFILE() {
+ if (buf) free(buf);
+}
+
+int MFILE::open(const char* path, const char* mode) {
f = boinc_fopen(path, mode);
if (!f) return -1;
return 0;
}
-int MFILE::printf(const char* format, ...) {
- va_list ap;
+int MFILE::vprintf(const char* format, va_list ap) {
char buf2[20000];
int n, k;
- va_start(ap, format);
k = vsprintf(buf2, format, ap);
- va_end(ap);
n = (int)strlen(buf2);
buf = (char*)realloc(buf, len+n);
if (!buf) {
@@ -66,6 +71,16 @@ int MFILE::printf(const char* format, ...) {
return k;
}
+int MFILE::printf(const char* format, ...) {
+ int n;
+ va_list ap;
+
+ va_start(ap, format);
+ n = MFILE::vprintf(format, ap);
+ va_end(ap);
+ return n;
+}
+
size_t MFILE::write(const void *ptr, size_t size, size_t nitems) {
buf = (char *)realloc( buf, len+(size*nitems) );
if (!buf) {
@@ -116,3 +131,10 @@ int MFILE::flush() {
long MFILE::tell() const {
return f ? ftell(f) : -1;
}
+
+void MFILE::get_buf(char*& b, int& l) {
+ b = buf;
+ l = len;
+ buf = 0;
+ len = 0;
+}
diff --git a/api/mfile.h b/lib/mfile.h
similarity index 89%
rename from api/mfile.h
rename to lib/mfile.h
index e474635e00..aaef9f038e 100644
--- a/api/mfile.h
+++ b/lib/mfile.h
@@ -17,7 +17,11 @@
// Contributor(s):
//
+#ifndef _MFILE_
+#define _MFILE_
+
#include
+#include
// MFILE supports a primitive form of checkpointing.
// Write all your output (and restart file) to MFILEs.
@@ -30,13 +34,18 @@ class MFILE {
int len;
FILE* f;
public:
+ MFILE();
+ ~MFILE();
int open(const char* path, const char* mode);
int _putchar(char);
int puts(const char*);
+ int vprintf(const char* format, va_list);
int printf(const char* format, ...);
size_t write(const void *, size_t size, size_t nitems);
int close();
int flush();
long tell() const;
+ void get_buf(char*&, int&);
};
+#endif
diff --git a/py/Boinc/Makefile.in b/py/Boinc/Makefile.in
index 2009d19c09..b96c631890 100644
--- a/py/Boinc/Makefile.in
+++ b/py/Boinc/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
diff --git a/sched/Makefile.in b/sched/Makefile.in
index 51c02757e3..1bd6961829 100644
--- a/sched/Makefile.in
+++ b/sched/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
diff --git a/test/Makefile.in b/test/Makefile.in
index 1d90136d6a..405edbf9ab 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \
diff --git a/tools/Makefile.in b/tools/Makefile.in
index 9eee294f2f..3cdc9ad557 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -152,7 +152,7 @@ RSA_LIBS = \
AM_CFLAGS = -g -Wall
-AM_CXXFLAGS = -g -Wall
+AM_CXXFLAGS = -g -Wall -O3
AM_CPPFLAGS = \
-I$(top_srcdir)/lib \