... | ... |
@@ -1,5 +1,5 @@ |
1 | 1 |
bin_PROGRAMS = msync |
2 | 2 |
sbin_PROGRAMS = makuosan |
3 |
-makuosan_SOURCES = makuosan.c common.c mexec.c minit.c mexit.c mrecv.c msend.c makuosan.h |
|
3 |
+makuosan_SOURCES = makuosan.c common.c mexec.c minit.c mexit.c mrecv.c msend.c xprint.c makuosan.h |
|
4 | 4 |
msync_SOURCES = msync.c |
5 | 5 |
EXTRA_DIST = support |
... | ... |
@@ -1,8 +1,8 @@ |
1 |
-# Makefile.in generated by automake 1.10 from Makefile.am. |
|
1 |
+# Makefile.in generated by automake 1.10.1 from Makefile.am. |
|
2 | 2 |
# @configure_input@ |
3 | 3 |
|
4 | 4 |
# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, |
5 |
-# 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
|
5 |
+# 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
|
6 | 6 |
# This Makefile.in is free software; the Free Software Foundation |
7 | 7 |
# gives unlimited permission to copy and/or distribute it, |
8 | 8 |
# with or without modifications, as long as this notice is preserved. |
... | ... |
@@ -52,7 +52,7 @@ sbinPROGRAMS_INSTALL = $(INSTALL_PROGRAM) |
52 | 52 |
PROGRAMS = $(bin_PROGRAMS) $(sbin_PROGRAMS) |
53 | 53 |
am_makuosan_OBJECTS = makuosan.$(OBJEXT) common.$(OBJEXT) \ |
54 | 54 |
mexec.$(OBJEXT) minit.$(OBJEXT) mexit.$(OBJEXT) \ |
55 |
- mrecv.$(OBJEXT) msend.$(OBJEXT) |
|
55 |
+ mrecv.$(OBJEXT) msend.$(OBJEXT) xprint.$(OBJEXT) |
|
56 | 56 |
makuosan_OBJECTS = $(am_makuosan_OBJECTS) |
57 | 57 |
makuosan_LDADD = $(LDADD) |
58 | 58 |
am_msync_OBJECTS = msync.$(OBJEXT) |
... | ... |
@@ -165,7 +165,7 @@ sysconfdir = @sysconfdir@ |
165 | 165 |
target_alias = @target_alias@ |
166 | 166 |
top_builddir = @top_builddir@ |
167 | 167 |
top_srcdir = @top_srcdir@ |
168 |
-makuosan_SOURCES = makuosan.c common.c mexec.c minit.c mexit.c mrecv.c msend.c makuosan.h |
|
168 |
+makuosan_SOURCES = makuosan.c common.c mexec.c minit.c mexit.c mrecv.c msend.c xprint.c makuosan.h |
|
169 | 169 |
msync_SOURCES = msync.c |
170 | 170 |
EXTRA_DIST = support |
171 | 171 |
all: config.h |
... | ... |
@@ -290,6 +290,7 @@ distclean-compile: |
290 | 290 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mrecv.Po@am__quote@ |
291 | 291 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msend.Po@am__quote@ |
292 | 292 |
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/msync.Po@am__quote@ |
293 |
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/xprint.Po@am__quote@ |
|
293 | 294 |
|
294 | 295 |
.c.o: |
295 | 296 |
@am__fastdepCC_TRUE@ $(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< |
... | ... |
@@ -310,8 +311,8 @@ ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES) |
310 | 310 |
unique=`for i in $$list; do \ |
311 | 311 |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
312 | 312 |
done | \ |
313 |
- $(AWK) ' { files[$$0] = 1; } \ |
|
314 |
- END { for (i in files) print i; }'`; \ |
|
313 |
+ $(AWK) '{ files[$$0] = 1; nonemtpy = 1; } \ |
|
314 |
+ END { if (nonempty) { for (i in files) print i; }; }'`; \ |
|
315 | 315 |
mkid -fID $$unique |
316 | 316 |
tags: TAGS |
317 | 317 |
|
... | ... |
@@ -323,8 +324,8 @@ TAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ |
323 | 323 |
unique=`for i in $$list; do \ |
324 | 324 |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
325 | 325 |
done | \ |
326 |
- $(AWK) ' { files[$$0] = 1; } \ |
|
327 |
- END { for (i in files) print i; }'`; \ |
|
326 |
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ |
|
327 |
+ END { if (nonempty) { for (i in files) print i; }; }'`; \ |
|
328 | 328 |
if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \ |
329 | 329 |
test -n "$$unique" || unique=$$empty_fix; \ |
330 | 330 |
$(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ |
... | ... |
@@ -334,13 +335,12 @@ ctags: CTAGS |
334 | 334 |
CTAGS: $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \ |
335 | 335 |
$(TAGS_FILES) $(LISP) |
336 | 336 |
tags=; \ |
337 |
- here=`pwd`; \ |
|
338 | 337 |
list='$(SOURCES) $(HEADERS) config.h.in $(LISP) $(TAGS_FILES)'; \ |
339 | 338 |
unique=`for i in $$list; do \ |
340 | 339 |
if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ |
341 | 340 |
done | \ |
342 |
- $(AWK) ' { files[$$0] = 1; } \ |
|
343 |
- END { for (i in files) print i; }'`; \ |
|
341 |
+ $(AWK) '{ files[$$0] = 1; nonempty = 1; } \ |
|
342 |
+ END { if (nonempty) { for (i in files) print i; }; }'`; \ |
|
344 | 343 |
test -z "$(CTAGS_ARGS)$$tags$$unique" \ |
345 | 344 |
|| $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ |
346 | 345 |
$$tags $$unique |
... | ... |
@@ -394,6 +394,10 @@ dist-bzip2: distdir |
394 | 394 |
tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2 |
395 | 395 |
$(am__remove_distdir) |
396 | 396 |
|
397 |
+dist-lzma: distdir |
|
398 |
+ tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma |
|
399 |
+ $(am__remove_distdir) |
|
400 |
+ |
|
397 | 401 |
dist-tarZ: distdir |
398 | 402 |
tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z |
399 | 403 |
$(am__remove_distdir) |
... | ... |
@@ -420,6 +424,8 @@ distcheck: dist |
420 | 420 |
GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\ |
421 | 421 |
*.tar.bz2*) \ |
422 | 422 |
bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\ |
423 |
+ *.tar.lzma*) \ |
|
424 |
+ unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\ |
|
423 | 425 |
*.tar.Z*) \ |
424 | 426 |
uncompress -c $(distdir).tar.Z | $(am__untar) ;;\ |
425 | 427 |
*.shar.gz*) \ |
... | ... |
@@ -574,11 +580,11 @@ uninstall-am: uninstall-binPROGRAMS uninstall-sbinPROGRAMS |
574 | 574 |
|
575 | 575 |
.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \ |
576 | 576 |
clean-binPROGRAMS clean-generic clean-sbinPROGRAMS ctags dist \ |
577 |
- dist-all dist-bzip2 dist-gzip dist-shar dist-tarZ dist-zip \ |
|
578 |
- distcheck distclean distclean-compile distclean-generic \ |
|
579 |
- distclean-hdr distclean-tags distcleancheck distdir \ |
|
580 |
- distuninstallcheck dvi dvi-am html html-am info info-am \ |
|
581 |
- install install-am install-binPROGRAMS install-data \ |
|
577 |
+ dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \ |
|
578 |
+ dist-zip distcheck distclean distclean-compile \ |
|
579 |
+ distclean-generic distclean-hdr distclean-tags distcleancheck \ |
|
580 |
+ distdir distuninstallcheck dvi dvi-am html html-am info \ |
|
581 |
+ info-am install install-am install-binPROGRAMS install-data \ |
|
582 | 582 |
install-data-am install-dvi install-dvi-am install-exec \ |
583 | 583 |
install-exec-am install-html install-html-am install-info \ |
584 | 584 |
install-info-am install-man install-pdf install-pdf-am \ |
... | ... |
@@ -1,7 +1,7 @@ |
1 |
-# generated automatically by aclocal 1.10 -*- Autoconf -*- |
|
1 |
+# generated automatically by aclocal 1.10.1 -*- Autoconf -*- |
|
2 | 2 |
|
3 | 3 |
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
4 |
-# 2005, 2006 Free Software Foundation, Inc. |
|
4 |
+# 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
|
5 | 5 |
# This file is free software; the Free Software Foundation |
6 | 6 |
# gives unlimited permission to copy and/or distribute it, |
7 | 7 |
# with or without modifications, as long as this notice is preserved. |
... | ... |
@@ -11,12 +11,15 @@ |
11 | 11 |
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
12 | 12 |
# PARTICULAR PURPOSE. |
13 | 13 |
|
14 |
-m4_if(m4_PACKAGE_VERSION, [2.61],, |
|
15 |
-[m4_fatal([this file was generated for autoconf 2.61. |
|
16 |
-You have another version of autoconf. If you want to use that, |
|
17 |
-you should regenerate the build system entirely.], [63])]) |
|
14 |
+m4_ifndef([AC_AUTOCONF_VERSION], |
|
15 |
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl |
|
16 |
+m4_if(AC_AUTOCONF_VERSION, [2.61],, |
|
17 |
+[m4_warning([this file was generated for autoconf 2.61. |
|
18 |
+You have another version of autoconf. It may work, but is not guaranteed to. |
|
19 |
+If you have problems, you may need to regenerate the build system entirely. |
|
20 |
+To do so, use the procedure documented by the package, typically `autoreconf'.])]) |
|
18 | 21 |
|
19 |
-# Copyright (C) 2002, 2003, 2005, 2006 Free Software Foundation, Inc. |
|
22 |
+# Copyright (C) 2002, 2003, 2005, 2006, 2007 Free Software Foundation, Inc. |
|
20 | 23 |
# |
21 | 24 |
# This file is free software; the Free Software Foundation |
22 | 25 |
# gives unlimited permission to copy and/or distribute it, |
... | ... |
@@ -31,7 +34,7 @@ AC_DEFUN([AM_AUTOMAKE_VERSION], |
31 | 31 |
[am__api_version='1.10' |
32 | 32 |
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to |
33 | 33 |
dnl require some minimum version. Point them to the right macro. |
34 |
-m4_if([$1], [1.10], [], |
|
34 |
+m4_if([$1], [1.10.1], [], |
|
35 | 35 |
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl |
36 | 36 |
]) |
37 | 37 |
|
... | ... |
@@ -47,8 +50,10 @@ m4_define([_AM_AUTOCONF_VERSION], []) |
47 | 47 |
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. |
48 | 48 |
# This function is AC_REQUIREd by AC_INIT_AUTOMAKE. |
49 | 49 |
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], |
50 |
-[AM_AUTOMAKE_VERSION([1.10])dnl |
|
51 |
-_AM_AUTOCONF_VERSION(m4_PACKAGE_VERSION)]) |
|
50 |
+[AM_AUTOMAKE_VERSION([1.10.1])dnl |
|
51 |
+m4_ifndef([AC_AUTOCONF_VERSION], |
|
52 |
+ [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl |
|
53 |
+_AM_AUTOCONF_VERSION(AC_AUTOCONF_VERSION)]) |
|
52 | 54 |
|
53 | 55 |
# AM_AUX_DIR_EXPAND -*- Autoconf -*- |
54 | 56 |
|
... | ... |
@@ -320,7 +325,7 @@ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], |
320 | 320 |
# each Makefile.in and add a new line on top of each file to say so. |
321 | 321 |
# Grep'ing the whole file is not good either: AIX grep has a line |
322 | 322 |
# limit of 2048, but all sed's we know have understand at least 4000. |
323 |
- if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then |
|
323 |
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then |
|
324 | 324 |
dirpart=`AS_DIRNAME("$mf")` |
325 | 325 |
else |
326 | 326 |
continue |
... | ... |
@@ -368,13 +373,13 @@ AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], |
368 | 368 |
# Do all the work for Automake. -*- Autoconf -*- |
369 | 369 |
|
370 | 370 |
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, |
371 |
-# 2005, 2006 Free Software Foundation, Inc. |
|
371 |
+# 2005, 2006, 2008 Free Software Foundation, Inc. |
|
372 | 372 |
# |
373 | 373 |
# This file is free software; the Free Software Foundation |
374 | 374 |
# gives unlimited permission to copy and/or distribute it, |
375 | 375 |
# with or without modifications, as long as this notice is preserved. |
376 | 376 |
|
377 |
-# serial 12 |
|
377 |
+# serial 13 |
|
378 | 378 |
|
379 | 379 |
# This macro actually does too much. Some checks are only needed if |
380 | 380 |
# your package does certain things. But this isn't really a big deal. |
... | ... |
@@ -479,16 +484,17 @@ AC_PROVIDE_IFELSE([AC_PROG_OBJC], |
479 | 479 |
# our stamp files there. |
480 | 480 |
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], |
481 | 481 |
[# Compute $1's index in $config_headers. |
482 |
+_am_arg=$1 |
|
482 | 483 |
_am_stamp_count=1 |
483 | 484 |
for _am_header in $config_headers :; do |
484 | 485 |
case $_am_header in |
485 |
- $1 | $1:* ) |
|
486 |
+ $_am_arg | $_am_arg:* ) |
|
486 | 487 |
break ;; |
487 | 488 |
* ) |
488 | 489 |
_am_stamp_count=`expr $_am_stamp_count + 1` ;; |
489 | 490 |
esac |
490 | 491 |
done |
491 |
-echo "timestamp for $1" >`AS_DIRNAME([$1])`/stamp-h[]$_am_stamp_count]) |
|
492 |
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) |
|
492 | 493 |
|
493 | 494 |
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc. |
494 | 495 |
# |
... | ... |
@@ -760,7 +766,7 @@ AC_SUBST([INSTALL_STRIP_PROGRAM])]) |
760 | 760 |
|
761 | 761 |
# _AM_SUBST_NOTMAKE(VARIABLE) |
762 | 762 |
# --------------------------- |
763 |
-# Prevent Automake from outputing VARIABLE = @VARIABLE@ in Makefile.in. |
|
763 |
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. |
|
764 | 764 |
# This macro is traced by Automake. |
765 | 765 |
AC_DEFUN([_AM_SUBST_NOTMAKE]) |
766 | 766 |
|
... | ... |
@@ -12,133 +12,6 @@ int loop_flag = 1; |
12 | 12 |
struct timeval curtime; |
13 | 13 |
BF_KEY EncKey; |
14 | 14 |
|
15 |
-char *opcodestrlist[]={"PING ", |
|
16 |
- "EXIT ", |
|
17 |
- "SEND ", |
|
18 |
- "MD5 ", |
|
19 |
- "DSYNC", |
|
20 |
- "DEL ", |
|
21 |
- "UNKNOWN"}; |
|
22 |
- |
|
23 |
-uint8_t opcodenumlist[]={MAKUO_OP_PING, |
|
24 |
- MAKUO_OP_EXIT, |
|
25 |
- MAKUO_OP_SEND, |
|
26 |
- MAKUO_OP_MD5, |
|
27 |
- MAKUO_OP_DSYNC, |
|
28 |
- MAKUO_OP_DEL, |
|
29 |
- MAKUO_OPCODE_MAX}; |
|
30 |
- |
|
31 |
-char *sstatestrlist[]={"SEND_STAT ", |
|
32 |
- "SEND_OPEN ", |
|
33 |
- "SEND_DATA ", |
|
34 |
- "SEND_MARK ", |
|
35 |
- "SEND_CLOSE ", |
|
36 |
- "SEND_LAST ", |
|
37 |
- "SEND_ERROR ", |
|
38 |
- "SEND_BREAK ", |
|
39 |
- "SEND_UNKNOWN"}; |
|
40 |
- |
|
41 |
-uint8_t sstatenumlist[]={MAKUO_SENDSTATE_STAT, |
|
42 |
- MAKUO_SENDSTATE_OPEN, |
|
43 |
- MAKUO_SENDSTATE_DATA, |
|
44 |
- MAKUO_SENDSTATE_MARK, |
|
45 |
- MAKUO_SENDSTATE_CLOSE, |
|
46 |
- MAKUO_SENDSTATE_LAST, |
|
47 |
- MAKUO_SENDSTATE_ERROR, |
|
48 |
- MAKUO_SENDSTATE_BREAK, |
|
49 |
- MAKUO_STATE_MAX}; |
|
50 |
- |
|
51 |
-char *rstatestrlist[] = {"RECV_NONE ", |
|
52 |
- "RECV_UPDATE ", |
|
53 |
- "RECV_SKIP ", |
|
54 |
- "RECV_OPEN ", |
|
55 |
- "RECV_MARK ", |
|
56 |
- "RECV_CLOSE ", |
|
57 |
- "RECV_IGNORE ", |
|
58 |
- "RECV_READONLY", |
|
59 |
- "RECV_BREAK ", |
|
60 |
- "RECV_LAST ", |
|
61 |
- "RECV_MD5OK ", |
|
62 |
- "RECV_MD5NG ", |
|
63 |
- "RECV_DELETEOK", |
|
64 |
- "RECV_DELETENG", |
|
65 |
- "RECV_OPENERR ", |
|
66 |
- "RECV_READERR ", |
|
67 |
- "RECV_WRITEERR", |
|
68 |
- "RECV_CLOSEERR", |
|
69 |
- "RECV_UNKNOWN"}; |
|
70 |
- |
|
71 |
-uint8_t rstatenumlist[]={MAKUO_RECVSTATE_NONE, |
|
72 |
- MAKUO_RECVSTATE_UPDATE, |
|
73 |
- MAKUO_RECVSTATE_SKIP, |
|
74 |
- MAKUO_RECVSTATE_OPEN, |
|
75 |
- MAKUO_RECVSTATE_MARK, |
|
76 |
- MAKUO_RECVSTATE_CLOSE, |
|
77 |
- MAKUO_RECVSTATE_IGNORE, |
|
78 |
- MAKUO_RECVSTATE_READONLY, |
|
79 |
- MAKUO_RECVSTATE_BREAK, |
|
80 |
- MAKUO_RECVSTATE_LAST, |
|
81 |
- MAKUO_RECVSTATE_MD5OK, |
|
82 |
- MAKUO_RECVSTATE_MD5NG, |
|
83 |
- MAKUO_RECVSTATE_DELETEOK, |
|
84 |
- MAKUO_RECVSTATE_DELETENG, |
|
85 |
- MAKUO_RECVSTATE_OPENERROR, |
|
86 |
- MAKUO_RECVSTATE_READERROR, |
|
87 |
- MAKUO_RECVSTATE_WRITEERROR, |
|
88 |
- MAKUO_RECVSTATE_CLOSEERROR, |
|
89 |
- MAKUO_STATE_MAX}; |
|
90 |
- |
|
91 |
-char *strsstate(uint8_t n) |
|
92 |
-{ |
|
93 |
- int i; |
|
94 |
- for(i=0;sstatenumlist[i] != MAKUO_STATE_MAX;i++){ |
|
95 |
- if(sstatenumlist[i] == n){ |
|
96 |
- break; |
|
97 |
- } |
|
98 |
- } |
|
99 |
- return(sstatestrlist[i]); |
|
100 |
-} |
|
101 |
- |
|
102 |
-char *strrstate(uint8_t n) |
|
103 |
-{ |
|
104 |
- int i; |
|
105 |
- for(i=0;rstatenumlist[i] != MAKUO_STATE_MAX;i++){ |
|
106 |
- if(rstatenumlist[i] == n){ |
|
107 |
- break; |
|
108 |
- } |
|
109 |
- } |
|
110 |
- return(rstatestrlist[i]); |
|
111 |
-} |
|
112 |
- |
|
113 |
-char *strmstate(mdata *data) |
|
114 |
-{ |
|
115 |
- if(data->head.flags & MAKUO_FLAG_ACK){ |
|
116 |
- return(strrstate(data->head.nstate)); |
|
117 |
- } |
|
118 |
- return(strsstate(data->head.nstate)); |
|
119 |
-} |
|
120 |
- |
|
121 |
-char *stropcode(mdata *data) |
|
122 |
-{ |
|
123 |
- int i; |
|
124 |
- for(i=0;opcodenumlist[i] != MAKUO_STATE_MAX;i++){ |
|
125 |
- if(opcodenumlist[i] == data->head.opcode){ |
|
126 |
- break; |
|
127 |
- } |
|
128 |
- } |
|
129 |
- return(opcodestrlist[i]); |
|
130 |
-} |
|
131 |
- |
|
132 |
-char *strackreq(mdata *data) |
|
133 |
-{ |
|
134 |
- char *ack = "ack"; |
|
135 |
- char *req = "req"; |
|
136 |
- if(data->head.flags & MAKUO_FLAG_ACK){ |
|
137 |
- return(ack); |
|
138 |
- } |
|
139 |
- return(req); |
|
140 |
-} |
|
141 |
- |
|
142 | 15 |
int md5sum(int fd, unsigned char *digest) |
143 | 16 |
{ |
144 | 17 |
int rd; |
... | ... |
@@ -235,70 +108,6 @@ int isexclude(char *fn, excludeitem *exclude, int dir) |
235 | 235 |
return(0); |
236 | 236 |
} |
237 | 237 |
|
238 |
-void fdprintf(int s, char *fmt, ...) |
|
239 |
-{ |
|
240 |
- char m[2048]; |
|
241 |
- va_list arg; |
|
242 |
- if(s != -1){ |
|
243 |
- va_start(arg, fmt); |
|
244 |
- vsnprintf(m, sizeof(m), fmt, arg); |
|
245 |
- va_end(arg); |
|
246 |
- m[sizeof(m) - 1] = 0; |
|
247 |
- write(s, m, strlen(m)); |
|
248 |
- } |
|
249 |
-} |
|
250 |
- |
|
251 |
-void lprintf(int l, char *fmt, ...) |
|
252 |
-{ |
|
253 |
- va_list arg; |
|
254 |
- struct timeval tv; |
|
255 |
- char m[2048]; |
|
256 |
- if(moption.loglevel >= l){ |
|
257 |
- va_start(arg, fmt); |
|
258 |
- vsnprintf(m, sizeof(m), fmt, arg); |
|
259 |
- va_end(arg); |
|
260 |
- m[sizeof(m) - 1] = 0; |
|
261 |
-#ifdef MAKUO_DEBUG |
|
262 |
- gettimeofday(&tv, NULL); |
|
263 |
- fprintf(stderr, "%02d.%06d %s", tv.tv_sec % 60, tv.tv_usec, m); |
|
264 |
-#else |
|
265 |
- fprintf(stderr, "%s", m); |
|
266 |
-#endif |
|
267 |
- syslog(LOG_ERR, "%s: %s", moption.user_name, m); |
|
268 |
- } |
|
269 |
-} |
|
270 |
- |
|
271 |
-void cprintf(int l, mcomm *c, char *fmt, ...) |
|
272 |
-{ |
|
273 |
- char m[2048]; |
|
274 |
- va_list arg; |
|
275 |
- if(!c) |
|
276 |
- return; |
|
277 |
- if(c->fd[0] == -1) |
|
278 |
- return; |
|
279 |
- if(c->loglevel >= l){ |
|
280 |
- va_start(arg, fmt); |
|
281 |
- vsnprintf(m, sizeof(m), fmt, arg); |
|
282 |
- va_end(arg); |
|
283 |
- m[sizeof(m) - 1] = 0; |
|
284 |
- write(c->fd[0], m, strlen(m)); |
|
285 |
- fsync(c->fd[0]); |
|
286 |
- } |
|
287 |
-} |
|
288 |
- |
|
289 |
-void mprintf(const char *func, mfile *m) |
|
290 |
-{ |
|
291 |
- lprintf(9, "%s: rid=%d init=%d wait=%d %s %s %s %s\n", |
|
292 |
- func, |
|
293 |
- m->mdata.head.reqid, |
|
294 |
- m->initstate, |
|
295 |
- m->sendwait, |
|
296 |
- inet_ntoa(m->addr.sin_addr), |
|
297 |
- stropcode(&(m->mdata)), |
|
298 |
- strmstate(&(m->mdata)), |
|
299 |
- m->fn); |
|
300 |
-} |
|
301 |
- |
|
302 | 238 |
uint32_t getrid() |
303 | 239 |
{ |
304 | 240 |
static uint32_t rid=0; |
... | ... |
@@ -478,15 +287,32 @@ void member_del(mhost *t) |
478 | 478 |
void member_del_message(mhost *t, char *mess) |
479 | 479 |
{ |
480 | 480 |
int i; |
481 |
+ mfile *m; |
|
482 |
+ |
|
481 | 483 |
if(!t || !mess){ |
482 | 484 |
return; |
483 | 485 |
} |
486 |
+ for(i=0;i<MAKUO_HOSTSTATE_SIZE;i++){ |
|
487 |
+ if(m = t->mflist[i]){ |
|
488 |
+ if(m->comm){ |
|
489 |
+ if(m->comm->working){ |
|
490 |
+ cprintf(0, m->comm, "error: %s: %s\n", mess, m->cmdline); |
|
491 |
+ lprintf(0, "[error] %s: %s: ST=%s RC=%02d: %s\n", |
|
492 |
+ __func__, |
|
493 |
+ mess, |
|
494 |
+ strmstate(&(m->mdata)), |
|
495 |
+ m->retrycnt, |
|
496 |
+ m->cmdline); |
|
497 |
+ } |
|
498 |
+ } |
|
499 |
+ } |
|
500 |
+ } |
|
484 | 501 |
for(i=0;i<MAX_COMM;i++){ |
485 | 502 |
if(moption.comm[i].working){ |
486 |
- cprintf(0, &(moption.comm[i]), "error: %s %s(%s)\n", |
|
487 |
- mess, inet_ntoa(t->ad), t->hostname); |
|
503 |
+ cprintf(0, &(moption.comm[i]), "error: %s: %s(%s)\n", mess, inet_ntoa(t->ad), t->hostname); |
|
488 | 504 |
} |
489 | 505 |
} |
506 |
+ lprintf(0, "[error] %s: %s: %s(%s)\n", __func__, mess, inet_ntoa(t->ad), t->hostname); |
|
490 | 507 |
} |
491 | 508 |
|
492 | 509 |
mmark *markalloc() |
... | ... |
@@ -9786,21 +9786,22 @@ echo "$as_me: $ac_file is unchanged" >&6;} |
9786 | 9786 |
fi |
9787 | 9787 |
rm -f "$tmp/out12" |
9788 | 9788 |
# Compute $ac_file's index in $config_headers. |
9789 |
+_am_arg=$ac_file |
|
9789 | 9790 |
_am_stamp_count=1 |
9790 | 9791 |
for _am_header in $config_headers :; do |
9791 | 9792 |
case $_am_header in |
9792 |
- $ac_file | $ac_file:* ) |
|
9793 |
+ $_am_arg | $_am_arg:* ) |
|
9793 | 9794 |
break ;; |
9794 | 9795 |
* ) |
9795 | 9796 |
_am_stamp_count=`expr $_am_stamp_count + 1` ;; |
9796 | 9797 |
esac |
9797 | 9798 |
done |
9798 |
-echo "timestamp for $ac_file" >`$as_dirname -- $ac_file || |
|
9799 |
-$as_expr X$ac_file : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ |
|
9800 |
- X$ac_file : 'X\(//\)[^/]' \| \ |
|
9801 |
- X$ac_file : 'X\(//\)$' \| \ |
|
9802 |
- X$ac_file : 'X\(/\)' \| . 2>/dev/null || |
|
9803 |
-echo X$ac_file | |
|
9799 |
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" || |
|
9800 |
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ |
|
9801 |
+ X"$_am_arg" : 'X\(//\)[^/]' \| \ |
|
9802 |
+ X"$_am_arg" : 'X\(//\)$' \| \ |
|
9803 |
+ X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null || |
|
9804 |
+echo X"$_am_arg" | |
|
9804 | 9805 |
sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ |
9805 | 9806 |
s//\1/ |
9806 | 9807 |
q |
... | ... |
@@ -9863,7 +9864,7 @@ echo "$as_me: executing $ac_file commands" >&6;} |
9863 | 9863 |
# each Makefile.in and add a new line on top of each file to say so. |
9864 | 9864 |
# Grep'ing the whole file is not good either: AIX grep has a line |
9865 | 9865 |
# limit of 2048, but all sed's we know have understand at least 4000. |
9866 |
- if sed 10q "$mf" | grep '^#.*generated by automake' > /dev/null 2>&1; then |
|
9866 |
+ if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then |
|
9867 | 9867 |
dirpart=`$as_dirname -- "$mf" || |
9868 | 9868 |
$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ |
9869 | 9869 |
X"$mf" : 'X\(//\)[^/]' \| \ |
... | ... |
@@ -11,18 +11,17 @@ void recv_timeout(mfile *m) |
11 | 11 |
if(!m){ |
12 | 12 |
return; |
13 | 13 |
} |
14 |
- m->retrycnt = MAKUO_SEND_RETRYCNT; |
|
15 | 14 |
do{ |
16 | 15 |
for(t=members;t;t=t->next){ |
17 | 16 |
r = get_hoststate(t, m); |
18 | 17 |
if(*r == MAKUO_RECVSTATE_NONE){ |
19 |
- lprintf(0, "[error] %s: %s(%s) > %s\n", __func__, inet_ntoa(t->ad), t->hostname, m->cmdline); |
|
20 | 18 |
member_del_message(t, "receive time out"); |
21 | 19 |
member_del(t); |
22 | 20 |
break; |
23 | 21 |
} |
24 | 22 |
} |
25 | 23 |
}while(t); |
24 |
+ m->retrycnt = MAKUO_SEND_RETRYCNT; |
|
26 | 25 |
} |
27 | 26 |
|
28 | 27 |
struct timeval *pingpong(int n) |
... | ... |
@@ -55,7 +55,7 @@ |
55 | 55 |
|
56 | 56 |
/*----- timeout -----*/ |
57 | 57 |
#define MAKUO_SEND_TIMEOUT 500 /* 再送間隔(ms) */ |
58 |
-#define MAKUO_SEND_RETRYCNT 120 /* 再送回数 */ |
|
58 |
+#define MAKUO_SEND_RETRYCNT 60 /* 再送回数 */ |
|
59 | 59 |
#define MAKUO_PONG_TIMEOUT 300000 /* メンバから除外するまでの時間(ms) */ |
60 | 60 |
#define MAKUO_PONG_INTERVAL 45000 /* PONG送信間隔(ms) */ |
61 | 61 |
#define MAKUO_RECV_GCWAIT 180000 /* 消し損ねたオブジェクトを開放する待ち時間(ms) */ |
... | ... |
@@ -138,12 +138,12 @@ int mexec_scan_send(int fd, char *path, char *sendhost, int mode, gid_t gid) |
138 | 138 |
sprintf(comm, "check %s%s\r\n", buff, path); |
139 | 139 |
break; |
140 | 140 |
} |
141 |
- mexec_scan_cmd(fd, comm); |
|
142 |
- return(0); |
|
141 |
+ return(mexec_scan_cmd(fd, comm)); |
|
143 | 142 |
} |
144 | 143 |
|
145 | 144 |
int mexec_scan_dir(int fd, char *base, char *sendhost, int mode, mcomm *c, int baseflag, gid_t gid) |
146 | 145 |
{ |
146 |
+ int r; |
|
147 | 147 |
DIR *d; |
148 | 148 |
struct dirent *dent; |
149 | 149 |
char path[PATH_MAX]; |
... | ... |
@@ -154,19 +154,24 @@ int mexec_scan_dir(int fd, char *base, char *sendhost, int mode, mcomm *c, int b |
154 | 154 |
mexec_scan_echo(fd, "directory open error %s", base); |
155 | 155 |
}else{ |
156 | 156 |
while(dent=readdir(d)){ |
157 |
- if(!loop_flag) |
|
158 |
- break; |
|
159 |
- if(!strcmp(dent->d_name, ".")) |
|
157 |
+ if(!loop_flag){ |
|
158 |
+ return(1); |
|
159 |
+ } |
|
160 |
+ if(!strcmp(dent->d_name, ".")){ |
|
160 | 161 |
continue; |
161 |
- if(!strcmp(dent->d_name, "..")) |
|
162 |
+ } |
|
163 |
+ if(!strcmp(dent->d_name, "..")){ |
|
162 | 164 |
continue; |
165 |
+ } |
|
163 | 166 |
if(baseflag){ |
164 | 167 |
sprintf(path, "%s/%s", base, dent->d_name); |
165 | 168 |
}else{ |
166 | 169 |
strcpy(path, dent->d_name); |
167 | 170 |
} |
168 | 171 |
space_escape(path); |
169 |
- mexec_scan_child(fd, path, sendhost, mode, c, gid); |
|
172 |
+ if(r = mexec_scan_child(fd, path, sendhost, mode, c, gid)){ |
|
173 |
+ return(r); |
|
174 |
+ } |
|
170 | 175 |
} |
171 | 176 |
closedir(d); |
172 | 177 |
} |
... | ... |
@@ -175,25 +180,29 @@ int mexec_scan_dir(int fd, char *base, char *sendhost, int mode, mcomm *c, int b |
175 | 175 |
|
176 | 176 |
int mexec_scan_child(int fd, char *base, char *sendhost, int mode, mcomm *c, gid_t gid) |
177 | 177 |
{ |
178 |
+ int r; |
|
178 | 179 |
char path[PATH_MAX]; |
179 | 180 |
if(*base == 0){ |
180 | 181 |
getcwd(path, PATH_MAX); |
181 |
- mexec_scan_dir(fd, path, sendhost, mode, c, 0, gid); |
|
182 |
- }else{ |
|
183 |
- /*----- exclude -----*/ |
|
184 |
- sprintf(path, "%s/%s", moption.real_dir, base); |
|
185 |
- if(!mfnmatch(path, c->exclude)){ |
|
186 |
- if(!is_dir(base)){ |
|
187 |
- mexec_scan_send(fd, base, sendhost, mode, gid); |
|
188 |
- }else{ |
|
189 |
- /*----- exclude dir -----*/ |
|
190 |
- strcat(path, "/"); |
|
191 |
- if(mfnmatch(path, c->exclude)) |
|
192 |
- return(0); |
|
193 |
- mexec_scan_dir(fd, base, sendhost, mode, c, 1, gid); |
|
194 |
- if(loop_flag && (mode != MAKUO_MEXEC_MD5)){ |
|
195 |
- mexec_scan_send(fd, base, sendhost, mode, gid); |
|
196 |
- } |
|
182 |
+ return(mexec_scan_dir(fd, path, sendhost, mode, c, 0, gid)); |
|
183 |
+ } |
|
184 |
+ /*----- exclude -----*/ |
|
185 |
+ sprintf(path, "%s/%s", moption.real_dir, base); |
|
186 |
+ if(!mfnmatch(path, c->exclude)){ |
|
187 |
+ if(!is_dir(base)){ |
|
188 |
+ return(mexec_scan_send(fd, base, sendhost, mode, gid)); |
|
189 |
+ }else{ |
|
190 |
+ /*----- exclude dir -----*/ |
|
191 |
+ strcat(path, "/"); |
|
192 |
+ if(mfnmatch(path, c->exclude)){ |
|
193 |
+ return(0); |
|
194 |
+ } |
|
195 |
+ /*----- scan dir -----*/ |
|
196 |
+ if(r = mexec_scan_dir(fd, base, sendhost, mode, c, 1, gid)){ |
|
197 |
+ return(r); |
|
198 |
+ } |
|
199 |
+ if(loop_flag && (mode != MAKUO_MEXEC_MD5)){ |
|
200 |
+ return(mexec_scan_send(fd, base, sendhost, mode, gid)); |
|
197 | 201 |
} |
198 | 202 |
} |
199 | 203 |
} |
... | ... |
@@ -287,6 +287,11 @@ static void mrecv_ack_dsync(mdata *data, struct sockaddr_in *addr) |
287 | 287 |
} |
288 | 288 |
} |
289 | 289 |
} |
290 |
+ if(m->mdata.head.nstate == MAKUO_SENDSTATE_CLOSE){ |
|
291 |
+ if(!set_hoststate(t, m, data->head.nstate)){ |
|
292 |
+ lprintf(0, "%s: not allocate state area\n", __func__); |
|
293 |
+ } |
|
294 |
+ } |
|
290 | 295 |
return; |
291 | 296 |
} |
292 | 297 |
|
... | ... |
@@ -824,7 +829,7 @@ static mfile *mrecv_req_send_create(mdata *data, struct sockaddr_in *addr) |
824 | 824 |
} |
825 | 825 |
|
826 | 826 |
/* create object */ |
827 |
- if(!(m = mfadd(1))){ |
|
827 |
+ if(!(m = mfadd(MFRECV))){ |
|
828 | 828 |
return(NULL); |
829 | 829 |
} |
830 | 830 |
|
... | ... |
@@ -1170,6 +1175,19 @@ static void mrecv_req_dsync_data(mfile *m, mdata *data, struct sockaddr_in *addr |
1170 | 1170 |
} |
1171 | 1171 |
} |
1172 | 1172 |
|
1173 |
+static void mrecv_req_dsync_close(mfile *m, mdata *data, struct sockaddr_in *addr) |
|
1174 |
+{ |
|
1175 |
+ if(!m){ |
|
1176 |
+ mkack(data, addr, MAKUO_RECVSTATE_CLOSE); |
|
1177 |
+ return; |
|
1178 |
+ } |
|
1179 |
+ if(m->link){ |
|
1180 |
+ mkack(data, addr, MAKUO_RECVSTATE_OPEN); |
|
1181 |
+ }else{ |
|
1182 |
+ mkack(data, addr, MAKUO_RECVSTATE_CLOSE); |
|
1183 |
+ } |
|
1184 |
+} |
|
1185 |
+ |
|
1173 | 1186 |
static void mrecv_req_dsync_last(mfile *m, mdata *data, struct sockaddr_in *addr) |
1174 | 1187 |
{ |
1175 | 1188 |
if(!m){ |
... | ... |
@@ -1207,6 +1225,9 @@ static void mrecv_req_dsync(mdata *data, struct sockaddr_in *addr) |
1207 | 1207 |
case MAKUO_SENDSTATE_DATA: |
1208 | 1208 |
mrecv_req_dsync_data(m, data, addr); |
1209 | 1209 |
break; |
1210 |
+ case MAKUO_SENDSTATE_CLOSE: |
|
1211 |
+ mrecv_req_dsync_close(m, data, addr); |
|
1212 |
+ break; |
|
1210 | 1213 |
case MAKUO_SENDSTATE_LAST: |
1211 | 1214 |
mrecv_req_dsync_last(m, data, addr); |
1212 | 1215 |
break; |
... | ... |
@@ -144,6 +144,7 @@ static int msend_retry(mfile *m) |
144 | 144 |
m->retrycnt = MAKUO_SEND_RETRYCNT; |
145 | 145 |
return(0); |
146 | 146 |
} |
147 |
+ /* |
|
147 | 148 |
if(m->mdata.head.opcode == MAKUO_OP_DSYNC){ |
148 | 149 |
if(m->mdata.head.nstate == MAKUO_SENDSTATE_CLOSE){ |
149 | 150 |
m->retrycnt--; |
... | ... |
@@ -155,6 +156,7 @@ static int msend_retry(mfile *m) |
155 | 155 |
} |
156 | 156 |
} |
157 | 157 |
} |
158 |
+ */ |
|
158 | 159 |
lprintf(2, "%s: send retry count=%02d rid=%06d op=%s state=%s %s\n", |
159 | 160 |
__func__, |
160 | 161 |
m->retrycnt, |
... | ... |
@@ -817,12 +819,19 @@ static void msend_req_dsync_close(int s, mfile *m) |
817 | 817 |
m->sendwait = 1; |
818 | 818 |
m->initstate = 0; |
819 | 819 |
ack_clear(m, MAKUO_RECVSTATE_OPEN); |
820 |
+ msend_packet(s, &(m->mdata), &(m->addr)); |
|
820 | 821 |
return; |
821 | 822 |
} |
822 | 823 |
if(m->sendwait){ |
824 |
+ msend_packet(s, &(m->mdata), &(m->addr)); |
|
823 | 825 |
return; |
824 | 826 |
} |
825 |
- msend_mfdel(m); |
|
827 |
+ if(!ack_check(m, MAKUO_RECVSTATE_OPEN)){ |
|
828 |
+ msend_mfdel(m); |
|
829 |
+ }else{ |
|
830 |
+ m->sendwait = 0; |
|
831 |
+ m->initstate = 1; |
|
832 |
+ } |
|
826 | 833 |
} |
827 | 834 |
|
828 | 835 |
static void msend_req_dsync_break(int s, mfile *m) |
... | ... |
@@ -871,35 +880,6 @@ static void msend_req_dsync(int s, mfile *m) |
871 | 871 |
} |
872 | 872 |
} |
873 | 873 |
|
874 |
-static void msend_req_del_mark(int s, mfile *m) |
|
875 |
-{ |
|
876 |
- mfile *d = m->link; /* dsync object */ |
|
877 |
- |
|
878 |
- if(!d){ |
|
879 |
- m->sendwait = 0; |
|
880 |
- m->mdata.head.nstate = MAKUO_SENDSTATE_LAST; |
|
881 |
- }else{ |
|
882 |
- if(m->initstate){ |
|
883 |
- m->initstate = 0; |
|
884 |
- m->sendwait = 1; |
|
885 |
- ack_clear(m, -1); |
|
886 |
- if(member_get(&(d->addr.sin_addr))){ |
|
887 |
- mkack(&(d->mdata), &(d->addr), MAKUO_RECVSTATE_CLOSE); |
|
888 |
- }else{ |
|
889 |
- d->lastrecv.tv_sec = 1; |
|
890 |
- } |
|
891 |
- return; |
|
892 |
- } |
|
893 |
- if(m->sendwait){ |
|
894 |
- if(member_get(&(d->addr.sin_addr))){ |
|
895 |
- mkack(&(d->mdata), &(d->addr), MAKUO_RECVSTATE_CLOSE); |
|
896 |
- }else{ |
|
897 |
- d->lastrecv.tv_sec = 1; |
|
898 |
- } |
|
899 |
- } |
|
900 |
- } |
|
901 |
-} |
|
902 |
- |
|
903 | 874 |
static int msend_req_del_stat_read_pathcmp(int s, mfile *m) |
904 | 875 |
{ |
905 | 876 |
char *p1; |
... | ... |
@@ -1006,7 +986,7 @@ static void msend_req_del_stat(int s, mfile *m) |
1006 | 1006 |
if(msend_req_del_stat_waitcheck(s, m)){ |
1007 | 1007 |
m->sendwait = 1; |
1008 | 1008 |
}else{ |
1009 |
- m->mdata.head.nstate = MAKUO_SENDSTATE_MARK; |
|
1009 |
+ m->mdata.head.nstate = MAKUO_SENDSTATE_LAST; |
|
1010 | 1010 |
m->initstate = 1; |
1011 | 1011 |
m->sendwait = 0; |
1012 | 1012 |
ack_clear(m, -1); |
... | ... |
@@ -1093,9 +1073,6 @@ static void msend_req_del(int s, mfile *m) |
1093 | 1093 |
case MAKUO_SENDSTATE_STAT: |
1094 | 1094 |
msend_req_del_stat(s, m); |
1095 | 1095 |
break; |
1096 |
- case MAKUO_SENDSTATE_MARK: |
|
1097 |
- msend_req_del_mark(s, m); |
|
1098 |
- break; |
|
1099 | 1096 |
case MAKUO_SENDSTATE_LAST: |
1100 | 1097 |
msend_req_del_last(s, m); |
1101 | 1098 |
break; |
1102 | 1099 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,200 @@ |
0 |
+/* |
|
1 |
+ * xprint.c |
|
2 |
+ * Copyright (C) 2008 KLab Inc. |
|
3 |
+ */ |
|
4 |
+#include "makuosan.h" |
|
5 |
+ |
|
6 |
+char *opcodestrlist[]={"PING ", |
|
7 |
+ "EXIT ", |
|
8 |
+ "SEND ", |
|
9 |
+ "MD5 ", |
|
10 |
+ "DSYNC", |
|
11 |
+ "DEL ", |
|
12 |
+ "UNKNOWN"}; |
|
13 |
+ |
|
14 |
+uint8_t opcodenumlist[]={MAKUO_OP_PING, |
|
15 |
+ MAKUO_OP_EXIT, |
|
16 |
+ MAKUO_OP_SEND, |
|
17 |
+ MAKUO_OP_MD5, |
|
18 |
+ MAKUO_OP_DSYNC, |
|
19 |
+ MAKUO_OP_DEL, |
|
20 |
+ MAKUO_OPCODE_MAX}; |
|
21 |
+ |
|
22 |
+char *sstatestrlist[]={"SEND_STAT ", |
|
23 |
+ "SEND_OPEN ", |
|
24 |
+ "SEND_DATA ", |
|
25 |
+ "SEND_MARK ", |
|
26 |
+ "SEND_CLOSE ", |
|
27 |
+ "SEND_LAST ", |
|
28 |
+ "SEND_ERROR ", |
|
29 |
+ "SEND_BREAK ", |
|
30 |
+ "SEND_UNKNOWN"}; |
|
31 |
+ |
|
32 |
+uint8_t sstatenumlist[]={MAKUO_SENDSTATE_STAT, |
|
33 |
+ MAKUO_SENDSTATE_OPEN, |
|
34 |
+ MAKUO_SENDSTATE_DATA, |
|
35 |
+ MAKUO_SENDSTATE_MARK, |
|
36 |
+ MAKUO_SENDSTATE_CLOSE, |
|
37 |
+ MAKUO_SENDSTATE_LAST, |
|
38 |
+ MAKUO_SENDSTATE_ERROR, |
|
39 |
+ MAKUO_SENDSTATE_BREAK, |
|
40 |
+ MAKUO_STATE_MAX}; |
|
41 |
+ |
|
42 |
+char *rstatestrlist[] = {"RECV_NONE ", |
|
43 |
+ "RECV_UPDATE ", |
|
44 |
+ "RECV_SKIP ", |
|
45 |
+ "RECV_OPEN ", |
|
46 |
+ "RECV_MARK ", |
|
47 |
+ "RECV_CLOSE ", |
|
48 |
+ "RECV_IGNORE ", |
|
49 |
+ "RECV_READONLY", |
|
50 |
+ "RECV_BREAK ", |
|
51 |
+ "RECV_LAST ", |
|
52 |
+ "RECV_MD5OK ", |
|
53 |
+ "RECV_MD5NG ", |
|
54 |
+ "RECV_DELETEOK", |
|
55 |
+ "RECV_DELETENG", |
|
56 |
+ "RECV_OPENERR ", |
|
57 |
+ "RECV_READERR ", |
|
58 |
+ "RECV_WRITEERR", |
|
59 |
+ "RECV_CLOSEERR", |
|
60 |
+ "RECV_UNKNOWN"}; |
|
61 |
+ |
|
62 |
+uint8_t rstatenumlist[]={MAKUO_RECVSTATE_NONE, |
|
63 |
+ MAKUO_RECVSTATE_UPDATE, |
|
64 |
+ MAKUO_RECVSTATE_SKIP, |
|
65 |
+ MAKUO_RECVSTATE_OPEN, |
|
66 |
+ MAKUO_RECVSTATE_MARK, |
|
67 |
+ MAKUO_RECVSTATE_CLOSE, |
|
68 |
+ MAKUO_RECVSTATE_IGNORE, |
|
69 |
+ MAKUO_RECVSTATE_READONLY, |
|
70 |
+ MAKUO_RECVSTATE_BREAK, |
|
71 |
+ MAKUO_RECVSTATE_LAST, |
|
72 |
+ MAKUO_RECVSTATE_MD5OK, |
|
73 |
+ MAKUO_RECVSTATE_MD5NG, |
|
74 |
+ MAKUO_RECVSTATE_DELETEOK, |
|
75 |
+ MAKUO_RECVSTATE_DELETENG, |
|
76 |
+ MAKUO_RECVSTATE_OPENERROR, |
|
77 |
+ MAKUO_RECVSTATE_READERROR, |
|
78 |
+ MAKUO_RECVSTATE_WRITEERROR, |
|
79 |
+ MAKUO_RECVSTATE_CLOSEERROR, |
|
80 |
+ MAKUO_STATE_MAX}; |
|
81 |
+ |
|
82 |
+char *strsstate(uint8_t n) |
|
83 |
+{ |
|
84 |
+ int i; |
|
85 |
+ for(i=0;sstatenumlist[i] != MAKUO_STATE_MAX;i++){ |
|
86 |
+ if(sstatenumlist[i] == n){ |
|
87 |
+ break; |
|
88 |
+ } |
|
89 |
+ } |
|
90 |
+ return(sstatestrlist[i]); |
|
91 |
+} |
|
92 |
+ |
|
93 |
+char *strrstate(uint8_t n) |
|
94 |
+{ |
|
95 |
+ int i; |
|
96 |
+ for(i=0;rstatenumlist[i] != MAKUO_STATE_MAX;i++){ |
|
97 |
+ if(rstatenumlist[i] == n){ |
|
98 |
+ break; |
|
99 |
+ } |
|
100 |
+ } |
|
101 |
+ return(rstatestrlist[i]); |
|
102 |
+} |
|
103 |
+ |
|
104 |
+char *strmstate(mdata *data) |
|
105 |
+{ |
|
106 |
+ if(data->head.flags & MAKUO_FLAG_ACK){ |
|
107 |
+ return(strrstate(data->head.nstate)); |
|
108 |
+ } |
|
109 |
+ return(strsstate(data->head.nstate)); |
|
110 |
+} |
|
111 |
+ |
|
112 |
+char *stropcode(mdata *data) |
|
113 |
+{ |
|
114 |
+ int i; |
|
115 |
+ for(i=0;opcodenumlist[i] != MAKUO_STATE_MAX;i++){ |
|
116 |
+ if(opcodenumlist[i] == data->head.opcode){ |
|
117 |
+ break; |
|
118 |
+ } |
|
119 |
+ } |
|
120 |
+ return(opcodestrlist[i]); |
|
121 |
+} |
|
122 |
+ |
|
123 |
+char *strackreq(mdata *data) |
|
124 |
+{ |
|
125 |
+ char *ack = "ack"; |
|
126 |
+ char *req = "req"; |
|
127 |
+ if(data->head.flags & MAKUO_FLAG_ACK){ |
|
128 |
+ return(ack); |
|
129 |
+ } |
|
130 |
+ return(req); |
|
131 |
+} |
|
132 |
+ |
|
133 |
+void fdprintf(int s, char *fmt, ...) |
|
134 |
+{ |
|
135 |
+ char m[2048]; |
|
136 |
+ va_list arg; |
|
137 |
+ if(s != -1){ |
|
138 |
+ va_start(arg, fmt); |
|
139 |
+ vsnprintf(m, sizeof(m), fmt, arg); |
|
140 |
+ va_end(arg); |
|
141 |
+ m[sizeof(m) - 1] = 0; |
|
142 |
+ write(s, m, strlen(m)); |
|
143 |
+ } |
|
144 |
+} |
|
145 |
+ |
|
146 |
+void lprintf(int l, char *fmt, ...) |
|
147 |
+{ |
|
148 |
+ va_list arg; |
|
149 |
+ struct timeval tv; |
|
150 |
+ char m[2048]; |
|
151 |
+ if(moption.loglevel >= l){ |
|
152 |
+ va_start(arg, fmt); |
|
153 |
+ vsnprintf(m, sizeof(m), fmt, arg); |
|
154 |
+ va_end(arg); |
|
155 |
+ m[sizeof(m) - 1] = 0; |
|
156 |
+#ifdef MAKUO_DEBUG |
|
157 |
+ gettimeofday(&tv, NULL); |
|
158 |
+ fprintf(stderr, "%02d.%06d %s", tv.tv_sec % 60, tv.tv_usec, m); |
|
159 |
+#else |
|
160 |
+ fprintf(stderr, "%s", m); |
|
161 |
+#endif |
|
162 |
+ syslog(LOG_ERR, "%s: %s", moption.user_name, m); |
|
163 |
+ } |
|
164 |
+} |
|
165 |
+ |
|
166 |
+void cprintf(int l, mcomm *c, char *fmt, ...) |
|
167 |
+{ |
|
168 |
+ char m[2048]; |
|
169 |
+ va_list arg; |
|
170 |
+ if(!c) |
|
171 |
+ return; |
|
172 |
+ if(c->fd[0] == -1) |
|
173 |
+ return; |
|
174 |
+ if(c->loglevel >= l){ |
|
175 |
+ va_start(arg, fmt); |
|
176 |
+ vsnprintf(m, sizeof(m), fmt, arg); |
|
177 |
+ va_end(arg); |
|
178 |
+ m[sizeof(m) - 1] = 0; |
|
179 |
+ write(c->fd[0], m, strlen(m)); |
|
180 |
+ fsync(c->fd[0]); |
|
181 |
+ } |
|
182 |
+} |
|
183 |
+ |
|
184 |
+void mprintf(const char *func, mfile *m) |
|
185 |
+{ |
|
186 |
+ if(!m) |
|
187 |
+ return; |
|
188 |
+ lprintf(9, "%s: rc=%d rid=%d init=%d wait=%d %s %s %s %s\n", |
|
189 |
+ func, |
|
190 |
+ m->retrycnt, |
|
191 |
+ m->mdata.head.reqid, |
|
192 |
+ m->initstate, |
|
193 |
+ m->sendwait, |
|
194 |
+ inet_ntoa(m->addr.sin_addr), |
|
195 |
+ stropcode(&(m->mdata)), |
|
196 |
+ strmstate(&(m->mdata)), |
|
197 |
+ m->fn); |
|
198 |
+} |
|
199 |
+ |