*** empty log message ***

svn path=/trunk/boinc/; revision=3543
This commit is contained in:
David Anderson 2004-06-12 04:45:36 +00:00
parent ffd445a82c
commit 4df39e85e4
44 changed files with 642 additions and 389 deletions

View File

@ -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 \

2
aclocal.m4 vendored
View File

@ -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

View File

@ -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

View File

@ -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@

View File

@ -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 \

View File

@ -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)

View File

@ -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 \

View File

@ -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; \

View File

@ -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(
"<active_task>\n"
" <project_master_url>%s</project_master_url>\n"
" <result_name>%s</result_name>\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, "</active_task>")) {
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, "<active_task_set>\n");
fout.printf("<active_task_set>\n");
for (i=0; i<active_tasks.size(); i++) {
retval = active_tasks[i]->write(fout);
if (retval) return retval;
}
fprintf(fout, "</active_task_set>\n");
fout.printf("</active_task_set>\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, "</active_task_set>")) return 0;
else if (match_tag(buf, "<active_task>")) {
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);

View File

@ -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

View File

@ -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();

View File

@ -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, "</project>")) return 0;
else if (parse_str(buf, "<scheduler_url>", 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(
"<project>\n"
);
for (i=0; i<scheduler_urls.size(); i++) {
fprintf(out,
out.printf(
" <scheduler_url>%s</scheduler_url>\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(
" <master_url>%s</master_url>\n"
" <project_name>%s</project_name>\n"
" <user_name>%s</user_name>\n"
@ -388,11 +388,11 @@ int PROJECT::write_state(FILE* out) {
sched_rpc_pending?" <sched_rpc_pending/>\n":""
);
if (strlen(code_sign_key)) {
fprintf(out,
out.printf(
" <code_sign_key>\n%s</code_sign_key>\n", code_sign_key
);
}
fprintf(out,
out.printf(
"</project>\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, "</app>")) return 0;
else if (parse_str(buf, "<name>", 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(
"<app>\n"
" <name>%s</name>\n"
"</app>\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 <xml_signature> 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, "</file_info>")) return 0;
else if (match_tag(buf, "<xml_signature>")) {
copy_element_contents(
@ -598,7 +598,7 @@ int FILE_INFO::parse(FILE* in, bool from_server) {
);
continue;
} else if (match_tag(buf, "<file_xfer>")) {
while (fgets(buf, 256, in)) {
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</file_xfer>")) 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(
"<file_info>\n"
" <name>%s</name>\n"
" <nbytes>%f</nbytes>\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(
" <md5_cksum>%s</md5_cksum>\n",
md5_cksum
);
}
if (!to_server) {
if (generated_locally) fprintf(out, " <generated_locally/>\n");
fprintf(out, " <status>%d</status>\n", status);
if (executable) fprintf(out, " <executable/>\n");
if (uploaded) fprintf(out, " <uploaded/>\n");
if (upload_when_present) fprintf(out, " <upload_when_present/>\n");
if (sticky) fprintf(out, " <sticky/>\n");
if (signature_required) fprintf(out, " <signature_required/>\n");
if (file_signature) fprintf(out," <file_signature>\n%s</file_signature>\n", file_signature);
if (generated_locally) out.printf(" <generated_locally/>\n");
out.printf(" <status>%d</status>\n", status);
if (executable) out.printf(" <executable/>\n");
if (uploaded) out.printf(" <uploaded/>\n");
if (upload_when_present) out.printf(" <upload_when_present/>\n");
if (sticky) out.printf(" <sticky/>\n");
if (signature_required) out.printf(" <signature_required/>\n");
if (file_signature) out.printf(" <file_signature>\n%s</file_signature>\n", file_signature);
}
for (i=0; i<urls.size(); i++) {
fprintf(out, " <url>%s</url>\n", urls[i].text);
out.printf(" <url>%s</url>\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, " <signed_xml>\n%s </signed_xml>\n", signed_xml);
out.printf(" <signed_xml>\n%s </signed_xml>\n", signed_xml);
}
if (strlen(xml_signature)) {
fprintf(out, " <xml_signature>\n%s </xml_signature>\n", xml_signature);
out.printf(" <xml_signature>\n%s </xml_signature>\n", xml_signature);
}
}
if (!error_msg.empty()) {
fprintf(out, " <error_msg>\n%s</error_msg>\n", error_msg.c_str());
out.printf(" <error_msg>\n%s</error_msg>\n", error_msg.c_str());
}
fprintf(out, "</file_info>\n");
out.printf("</file_info>\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, "</app_version>")) return 0;
else if (parse_str(buf, "<app_name>", app_name, sizeof(app_name))) continue;
else if (match_tag(buf, "<file_ref>")) {
@ -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(
"<app_version>\n"
" <app_name>%s</app_name>\n"
" <version_num>%d</version_num>\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(
"</app_version>\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, "</file_ref>")) return 0;
else if (parse_str(buf, "<file_name>", file_name, sizeof(file_name))) continue;
else if (parse_str(buf, "<open_name>", 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(
" <file_ref>\n"
" <file_name>%s</file_name>\n",
file_name
);
if (strlen(open_name)) {
fprintf(out, " <open_name>%s</open_name>\n", open_name);
out.printf(" <open_name>%s</open_name>\n", open_name);
}
if (fd >= 0) {
fprintf(out, " <fd>%d</fd>\n", fd);
out.printf(" <fd>%d</fd>\n", fd);
}
if (main_program) {
fprintf(out, " <main_program/>\n");
out.printf(" <main_program/>\n");
}
if (copy_file) {
fprintf(out, " <copy_file/>\n");
out.printf(" <copy_file/>\n");
}
fprintf(out, " </file_ref>\n");
out.printf(" </file_ref>\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, "</workunit>")) return 0;
else if (parse_str(buf, "<name>", name, sizeof(name))) continue;
else if (parse_str(buf, "<app_name>", 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(
"<workunit>\n"
" <name>%s</name>\n"
" <app_name>%s</app_name>\n"
@ -859,7 +859,7 @@ int WORKUNIT::write(FILE* out) {
for (i=0; i<input_files.size(); i++) {
input_files[i].write(out);
}
fprintf(out, "</workunit>\n");
out.printf("</workunit>\n");
return 0;
}
@ -922,14 +922,14 @@ void RESULT::clear() {
// parse a <result> 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, "</result>")) return 0;
if (parse_str(buf, "<name>", name, sizeof(name))) continue;
if (parse_str(buf, "<wu_name>", wu_name, sizeof(wu_name))) continue;
@ -946,14 +946,14 @@ int RESULT::parse_server(FILE* in) {
// parse a <result> 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, "</result>")) {
// 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/>")) ready_to_report = true;
else if (parse_int(buf, "<state>", state)) continue;
else if (match_tag(buf, "<stderr_out>")) {
while (fgets(buf, 256, in)) {
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</stderr_out>")) 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(
"<result>\n"
" <name>%s</name>\n"
" <final_cpu_time>%f</final_cpu_time>\n"
@ -1004,24 +1004,26 @@ int RESULT::write(FILE* out, bool to_server) {
state
);
if (to_server) {
fprintf(out,
out.printf(
" <app_version_num>%d</app_version_num>\n",
wup->version_num
);
}
n = stderr_out.length();
if (n) {
fprintf(out, "<stderr_out>\n");
out.printf("<stderr_out>\n");
if (to_server) {
fprintf(out,
out.printf(
"<core_client_version>%d.%.2d</core_client_version>\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, "</stderr_out>\n");
out.printf(stderr_out.c_str());
if (stderr_out[n-1] != '\n') {
out.printf("\n");
}
out.printf("</stderr_out>\n");
}
if (to_server) {
for (i=0; i<output_files.size(); i++) {
@ -1032,9 +1034,9 @@ int RESULT::write(FILE* out, bool to_server) {
}
}
} else {
if (got_server_ack) fprintf(out, " <got_server_ack/>\n");
if (ready_to_report) fprintf(out, " <ready_to_report/>\n");
fprintf(out,
if (got_server_ack) out.printf(" <got_server_ack/>\n");
if (ready_to_report) out.printf(" <ready_to_report/>\n");
out.printf(
" <wu_name>%s</wu_name>\n"
" <report_deadline>%d</report_deadline>\n",
wu_name,
@ -1045,7 +1047,7 @@ int RESULT::write(FILE* out, bool to_server) {
if (retval) return retval;
}
}
fprintf(out, "</result>\n");
out.printf("</result>\n");
return 0;
}

View File

@ -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<FILE_REF> 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&);
};

View File

@ -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,
"<scheduler_request>\n"
" <authenticator>%s</authenticator>\n"
@ -280,7 +282,7 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
for (i=0; i<app_versions.size(); i++) {
APP_VERSION* avp = app_versions[i];
if (avp->project != p) continue;
avp->write(f);
avp->write(mf);
}
fprintf(f, " </app_versions>\n");
}
@ -339,16 +341,16 @@ int CLIENT_STATE::make_scheduler_request(PROJECT* p, double work_req) {
}
fprintf(f, "</projects>\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; i<results.size(); i++) {
rp = results[i];
if (rp->project == p && rp->ready_to_report) {
rp->write(f, true);
rp->write(mf, true);
}
}
read_trickle_files(p, f);

View File

@ -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, "<client_state>")) {
retval = ERR_XML_PARSE;
@ -63,7 +65,7 @@ int CLIENT_STATE::parse_state_file() {
retval = 0;
break;
} else if (match_tag(buf, "<project>")) {
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* 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>")) {
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>")) {
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>")) {
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>")) {
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, "<host_info>")) {
retval = host_info.parse(f);
retval = host_info.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "<time_stats>")) {
retval = time_stats.parse(f);
retval = time_stats.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "<net_stats>")) {
retval = net_stats.parse(f);
retval = net_stats.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "<active_task_set>")) {
retval = active_tasks.parse(f, this);
retval = active_tasks.parse(mf);
if (retval) goto done;
} else if (match_tag(buf, "<platform_name>")) {
// should match our current platform name
@ -150,7 +152,7 @@ int CLIENT_STATE::parse_state_file() {
} else if (parse_int(buf, "<core_client_major_version>", old_major_version)) {
} else if (parse_int(buf, "<core_client_minor_version>", old_minor_version)) {
} else if (match_tag(buf, "<proxy_info>")) {
retval = pi.parse(f);
retval = pi.parse(mf);
if (retval) goto done;
// } else if (parse_int(buf, "<user_run_request/>")) {
} else if (parse_str(buf, "<host_venue>", 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, "<client_state>\n");
f.printf("<client_state>\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(
"<platform_name>%s</platform_name>\n"
"<core_client_major_version>%d</core_client_major_version>\n"
"<core_client_minor_version>%d</core_client_minor_version>\n",
@ -256,13 +259,10 @@ int CLIENT_STATE::write_state(FILE* f) {
// save proxy info
//
pi.write(f);
#if 0
fprintf(f, "<user_run_request>%d</user_run_request>\n", user_run_request);
#endif
if (strlen(host_venue)) {
fprintf(f, "<host_venue>%s</host_venue>\n", host_venue);
f.printf("<host_venue>%s</host_venue>\n", host_venue);
}
fprintf(f, "</client_state>\n");
f.printf("</client_state>\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, "<app_info>")) continue;
if (match_tag(buf, "</app_info>")) return 0;
if (match_tag(buf, "<file_info>")) {
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* 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>")) {
APP_VERSION* avp = new APP_VERSION;
if (avp->parse(in)) {
if (avp->parse(mf)) {
delete avp;
continue;
}

View File

@ -22,57 +22,80 @@
#endif
#ifndef _WIN32
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <arpa/inet.h>
#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, "<get_state/>\n");
fflush(fout);
while (fgets(buf, 256, fin)) {
send_request("<get_state/>\n");
get_reply(mbuf);
MIOFILE fin;
fin.init_buf(mbuf);
while (fin.fgets(buf, 256)) {
if (match_tag(buf, "</client_state>")) break;
else if (match_tag(buf, "<project>")) {
project = new PROJECT;
@ -167,21 +190,27 @@ int RPC_CLIENT::get_messages(
int nmessages, int offset, vector<MESSAGE_DESC>& msgs
) {
char buf[256];
fprintf(fout,
char* mbuf;
sprintf(buf,
"<get_messages>\n"
" <nmessages>%d</nmessages>\n"
" <offset>%d</offset>\n"
"</get_messages>\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, "<msgs>")) continue;
if (match_tag(buf, "</msgs>")) break;
if (match_tag(buf, "<msg>")) {
MESSAGE_DESC md;
while (fgets(buf, 256, fin)) {
while (fin.fgets(buf, 256)) {
puts(buf);
if (match_tag(buf, "</msg>")) break;
if (parse_str(buf, "<project>", 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, "</file_info>")) return 0;
else if (parse_str(buf, "<name>", name)) continue;
else if (match_tag(buf, "<generated_locally/>")) {
@ -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, "</project>")) return 0;
else if (parse_str(buf, "<master_url", master_url)) continue;
else if (parse_double(buf, "<resource_share", resource_share)) continue;
@ -331,9 +360,9 @@ void PROJECT::print() {
printf(" tentative: %s\n", tentative?"yes":"no");
}
int APP::parse(FILE* in) {
int APP::parse(MIOFILE& in) {
char buf[256];
while (fgets(buf, 256, in)) {
while (in.fgets(buf, 256)) {
if (match_tag(buf, "</app>")) return 0;
else if (parse_str(buf, "<name>", 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, "</app_version>")) return 0;
else if (parse_str(buf, "<app_name>", app_name)) continue;
else if (parse_int(buf, "<version_num>", 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, "</workunit>")) return 0;
else if (parse_str(buf, "<name>", name)) continue;
else if (parse_str(buf, "<app_name>", 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, "</result>")) return 0;
else if (parse_str(buf, "<name>", name)) continue;
else if (parse_str(buf, "<wu_name>", 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, "</active_task>")) return 0;
else if (parse_str(buf, "<result_name>", result_name)) continue;
else if (parse_int(buf, "<app_version_num>", app_version_num)) continue;

View File

@ -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<PROJECT*> projects;
vector<FILE_INFO*> file_infos;

View File

@ -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, "<project_url>", url)) {
fprintf(fout, "<error>Missing project URL</error>\n");
fout.printf("<error>Missing project URL</error>\n");
return 0;
}
PROJECT* p = gstate.lookup_project(url.c_str());
if (!p) {
fprintf(fout, "<error>No such project</error>\n");
fout.printf("<error>No such project</error>\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>", result_name)) {
fprintf(fout, "<error>Missing result name</error>\n");
fout.printf("<error>Missing result name</error>\n");
return;
}
RESULT* rp = gstate.lookup_result(p, result_name.c_str());
if (!rp) {
fprintf(fout, "<error>No such result</error>\n");
fout.printf("<error>No such result</error>\n");
return;
}
ACTIVE_TASK* atp = gstate.lookup_active_task_by_result(rp);
if (!atp) {
fprintf(fout, "<error>Result not active</error>\n");
fout.printf("<error>Result not active</error>\n");
return;
}
atp->request_graphics_mode(MODE_WINDOW);
fprintf(fout, "<success/>\n");
fout.printf("<success/>\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, "<success/>\n");
fout.printf("<success/>\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>", url)) {
fprintf(fout, "<error>Missing URL</error>\n");
fout.printf("<error>Missing URL</error>\n");
return;
}
if (!parse_str(buf, "<authenticator>", authenticator)) {
fprintf(fout, "<error>Missing authenticator</error>\n");
fout.printf("<error>Missing authenticator</error>\n");
return;
}
gstate.add_project(url.c_str(), authenticator.c_str());
fprintf(fout, "<success/>\n");
fout.printf("<success/>\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, "<success/>\n");
fout.printf("<success/>\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, "<success/>\n");
fout.printf("<success/>\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, "<always>")) {
gstate.user_run_request = USER_RUN_REQUEST_ALWAYS;
} else if (match_tag(buf, "<never>")) {
@ -145,43 +136,43 @@ static void handle_set_run_mode(char* buf, FILE* fout) {
} else if (match_tag(buf, "<auto>")) {
gstate.user_run_request = USER_RUN_REQUEST_AUTO;
} else {
fprintf(fout, "<error>Missing mode</error>\n");
fout.printf("<error>Missing mode</error>\n");
return;
}
fprintf(fout, "<success/>\n");
fout.printf("<success/>\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, "<success/>\n");
fout.printf("<success/>\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>", socks_proxy_server_name)) {
fprintf(fout, "<error>SOCKS proxy server name missing</error>\n");
fout.printf("<error>SOCKS proxy server name missing</error>\n");
return;
}
if (!parse_int(buf, "<socks_proxy_server_port>", socks_proxy_server_port)) {
fprintf(fout, "<error>SOCKS proxy server port missing</error>\n");
fout.printf("<error>SOCKS proxy server port missing</error>\n");
return;
}
if (!parse_str(buf, "<http_proxy_server_name>", http_proxy_server_name)) {
fprintf(fout, "<error>HTTP proxy server name missing</error>\n");
fout.printf("<error>HTTP proxy server name missing</error>\n");
return;
}
if (!parse_int(buf, "<http_proxy_server_port>", http_proxy_server_port)) {
fprintf(fout, "<error>HTTP proxy server port missing</error>\n");
fout.printf("<error>HTTP proxy server port missing</error>\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, "<success/>\n");
fout.printf("<success/>\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>", nmessages);
parse_int(buf, "<offset>", offset);
if (nmessages < 0) {
fprintf(fout, "<error>No nmessages given</error>\n");
fout.printf("<error>No nmessages given</error>\n");
return;
}
@ -212,11 +203,11 @@ void handle_get_messages(char* buf, FILE* fout) {
}
}
fprintf(fout, "<msgs>\n");
fout.printf("<msgs>\n");
j = 0;
for (i=offset; i<message_descs.size()&&j<nmessages; i++, j++) {
MESSAGE_DESC& md = message_descs[i];
fprintf(fout,
fout.printf(
"<msg>\n"
" <i>%d</i>\n"
" <pri>%d</pri>\n"
@ -228,19 +219,23 @@ void handle_get_messages(char* buf, FILE* fout) {
md.timestamp
);
if (md.project) {
fprintf(fout,
fout.printf(
" <project>%s</project>\n",
md.project->get_project_name()
);
}
fprintf(fout, "</msg>\n");
fout.printf("</msg>\n");
}
fprintf(fout, "</msgs>\n");
fout.printf("</msgs>\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, "<get_state")) {
gstate.write_state(fout);
} else if (match_tag(buf, "<result_show_graphics>")) {
handle_result_show_graphics(buf, fout);
} else if (match_tag(buf, "<project_reset>")) {
handle_project_reset(buf, fout);
} else if (match_tag(buf, "<project_attach>")) {
handle_project_attach(buf, fout);
} else if (match_tag(buf, "<project_detach>")) {
handle_project_detach(buf, fout);
} else if (match_tag(buf, "<project_update>")) {
handle_project_update(buf, fout);
} else if (match_tag(buf, "<set_run_mode>")) {
handle_set_run_mode(buf, fout);
} else if (match_tag(buf, "<run_benchmarks>")) {
handle_run_benchmarks(buf, fout);
} else if (match_tag(buf, "<set_proxy_settings>")) {
handle_set_proxy_settings(buf, fout);
} else if (match_tag(buf, "<get_messages>")) {
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, "<get_state")) {
gstate.write_state(mf);
} else if (match_tag(request_msg, "<result_show_graphics>")) {
handle_result_show_graphics(request_msg, mf);
} else if (match_tag(request_msg, "<project_reset>")) {
handle_project_reset(request_msg, mf);
} else if (match_tag(request_msg, "<project_attach>")) {
handle_project_attach(request_msg, mf);
} else if (match_tag(request_msg, "<project_detach>")) {
handle_project_detach(request_msg, mf);
} else if (match_tag(request_msg, "<project_update>")) {
handle_project_update(request_msg, mf);
} else if (match_tag(request_msg, "<set_run_mode>")) {
handle_set_run_mode(request_msg, mf);
} else if (match_tag(request_msg, "<run_benchmarks>")) {
handle_run_benchmarks(request_msg, mf);
} else if (match_tag(request_msg, "<set_proxy_settings>")) {
handle_set_proxy_settings(request_msg, mf);
} else if (match_tag(request_msg, "<get_messages>")) {
handle_get_messages(request_msg, mf);
} else {
fprintf(fout, "<unrecognized/>\n");
mf.printf("<unrecognized/>\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<GUI_RPC_CONN*>::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++;
}

View File

@ -20,7 +20,6 @@
class GUI_RPC_CONN {
public:
int sock;
FILE* fout;
char buffer[262144];
GUI_RPC_CONN(int);
~GUI_RPC_CONN();

View File

@ -54,7 +54,6 @@ int main(int argc, char** argv) {
vector<MESSAGE_DESC> message_descs;
#ifdef _WIN32
// Initialize WinSock
if ( WinsockInitialize() != 0 ) {
printf(
"BOINC Core Client Error Message\n"

View File

@ -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, "</host_info>")) return 0;
else if (parse_int(buf, "<timezone>", timezone)) continue;
else if (parse_str(buf, "<domain_name>", 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(
"<host_info>\n"
" <timezone>%d</timezone>\n"
" <domain_name>%s</domain_name>\n"

View File

@ -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*);

View File

@ -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

87
client/miofile.C Normal file
View File

@ -0,0 +1,87 @@
#include <string.h>
#include <stdarg.h>
#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;
}

44
client/miofile.h Normal file
View File

@ -0,0 +1,44 @@
#ifndef _MIOFILE_
#define _MIOFILE_
#ifndef _WIN32
#include <string>
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

View File

@ -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(
"<net_stats>\n"
" <bwup>%f</bwup>\n"
" <bwdown>%f</bwdown>\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, "</net_stats>")) return 0;
else if (parse_double(buf, "<bwup>", bwup)) {
up.starting_throughput = bwup;

View File

@ -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&);
};

View File

@ -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

View File

@ -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, "</persistent_file_xfer>")) return 0;
else if (parse_int(buf, "<num_retries>", nretry)) continue;
else if (parse_int(buf, "<first_request_time>", 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(
" <persistent_file_xfer>\n"
" <num_retries>%d</num_retries>\n"
" <first_request_time>%d</first_request_time>\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(
" <file_xfer>\n"
" <bytes_xferred>%f</bytes_xferred>\n"
" <file_offset>%f</file_offset>\n"

View File

@ -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();
};

View File

@ -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, "</proxy_info>")) return 0;
else if (match_tag(buf, "<use_http_proxy/>")) use_http_proxy = true;
else if (match_tag(buf, "<use_socks_proxy/>")) 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(
"<proxy_info>\n"
"%s"
"%s"

View File

@ -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();
};

View File

@ -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;
app.parse(in);
app.parse(mf);
apps.push_back(app);
} else if (match_tag(buf, "<file_info>")) {
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>")) {
APP_VERSION av;
av.parse(in);
av.parse(mf);
app_versions.push_back(av);
} else if (match_tag(buf, "<workunit>")) {
WORKUNIT wu;
wu.parse(in);
wu.parse(mf);
workunits.push_back(wu);
} else if (match_tag(buf, "<result>")) {
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_ack>")) {
RESULT result;

View File

@ -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(
"<time_stats>\n"
" <on_frac>%f</on_frac>\n"
" <connected_frac>%f</connected_frac>\n"
@ -101,23 +101,23 @@ int TIME_STATS::write(FILE* out, bool to_server) {
active_frac
);
if (!to_server) {
fprintf(out,
out.printf(
" <last_update>%d</last_update>\n",
last_update
);
}
fprintf(out, "</time_stats>\n");
out.printf("</time_stats>\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, "</time_stats>")) return 0;
else if (parse_int(buf, "<last_update>", last_update)) continue;
else if (parse_double(buf, "<on_frac>", on_frac)) continue;

View File

@ -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&);
};

View File

@ -24,6 +24,7 @@ before getting into the source code.
<li> <a href=client_fsm.php>FSM structure</a>
<li> <a href=client_data.php>Data structures</a>
<li> <a href=client_logic.php>Main loop logic</a>
<li> <a href=client_sched.php>Result scheduling</a>
<li> <a href=client_debug.php>Debugging</a>
<li> <a href=host_measure.php>Host measurements</a>
<li> <a href=host_id.php>Host identification</a>

View File

@ -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

View File

@ -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)/'`$<; \

View File

@ -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;
}

View File

@ -17,7 +17,11 @@
// Contributor(s):
//
#ifndef _MFILE_
#define _MFILE_
#include <stdio.h>
#include <stdarg.h>
// 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

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \

View File

@ -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 \