├── .deps ├── base64.Po ├── client.Po ├── clientcommand.Po ├── getaddrinfo.Po ├── http.Po ├── make.Po ├── makegz.Po ├── progress.Po └── url.Po ├── COPYING ├── INSTALL ├── Makefile ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── aclocal.m4 ├── autom4te.cache ├── output.0 ├── output.1 ├── requests ├── traces.0 └── traces.1 ├── autotools ├── ac_c_compile_flags.m4 ├── config.guess ├── config.sub ├── depcomp ├── herrno.m4 ├── in6addr.m4 ├── install-sh ├── missing ├── sockaddrin6.m4 └── sockinttypes.m4 ├── base64.c ├── bootstrap ├── check-zsyncmake ├── client.c ├── client.h ├── clientcommand.c ├── config.h ├── config.h.in ├── config.log ├── config.status ├── configure ├── configure.ac ├── doc ├── Makefile ├── Makefile.am ├── Makefile.in ├── zsync.1 └── zsyncmake.1 ├── format_string.h ├── getaddrinfo.c ├── getaddrinfo.h ├── http.c ├── http.h ├── librcksum ├── .deps │ ├── hash.Po │ ├── md4.Po │ ├── range.Po │ ├── rsum.Po │ └── state.Po ├── Makefile ├── Makefile.am ├── Makefile.in ├── hash.c ├── internal.h ├── md4.c ├── md4.h ├── range.c ├── rcksum.h ├── rsum.c └── state.c ├── libzsync ├── .deps │ ├── sha1.Po │ ├── sha1test.Po │ ├── zmap.Po │ └── zsync.Po ├── Makefile ├── Makefile.am ├── Makefile.in ├── sha1.c ├── sha1.h ├── sha1test.c ├── zmap.c ├── zmap.h ├── zsync.c └── zsync.h ├── make.c ├── makegz.c ├── makegz.h ├── progress.c ├── progress.h ├── stamp-h1 ├── url.c ├── url.h ├── zlib ├── .deps │ ├── adler32.Po │ ├── compress.Po │ ├── crc32.Po │ ├── deflate.Po │ ├── inflate.Po │ ├── inftrees.Po │ ├── trees.Po │ └── zutil.Po ├── Makefile ├── Makefile.am ├── Makefile.in ├── README ├── adler32.c ├── compress.c ├── crc32.c ├── crc32.h ├── deflate.c ├── deflate.h ├── inffixed.h ├── inflate.c ├── inflate.h ├── inftrees.c ├── inftrees.h ├── trees.c ├── trees.h ├── zconf.h ├── zlib.h ├── zutil.c └── zutil.h └── zsglobal.h /.deps/base64.Po: -------------------------------------------------------------------------------- 1 | base64.o base64.o: base64.c /usr/include/stdlib.h \ 2 | /usr/include/available.h /usr/include/_types.h \ 3 | /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ 4 | /usr/include/machine/_types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/wait.h /usr/include/sys/signal.h \ 6 | /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h \ 7 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ 10 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 11 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 12 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h \ 13 | /usr/include/machine/types.h /usr/include/i386/types.h \ 14 | /usr/include/string.h 15 | 16 | /usr/include/stdlib.h: 17 | 18 | /usr/include/available.h: 19 | 20 | /usr/include/_types.h: 21 | 22 | /usr/include/sys/_types.h: 23 | 24 | /usr/include/sys/cdefs.h: 25 | 26 | /usr/include/machine/_types.h: 27 | 28 | /usr/include/i386/_types.h: 29 | 30 | /usr/include/sys/wait.h: 31 | 32 | /usr/include/sys/signal.h: 33 | 34 | /usr/include/sys/appleapiopts.h: 35 | 36 | /usr/include/machine/signal.h: 37 | 38 | /usr/include/i386/signal.h: 39 | 40 | /usr/include/i386/_structs.h: 41 | 42 | /usr/include/sys/_structs.h: 43 | 44 | /usr/include/machine/_structs.h: 45 | 46 | /usr/include/mach/i386/_structs.h: 47 | 48 | /usr/include/sys/resource.h: 49 | 50 | /usr/include/machine/endian.h: 51 | 52 | /usr/include/i386/endian.h: 53 | 54 | /usr/include/sys/_endian.h: 55 | 56 | /usr/include/libkern/_OSByteOrder.h: 57 | 58 | /usr/include/libkern/i386/_OSByteOrder.h: 59 | 60 | /usr/include/alloca.h: 61 | 62 | /usr/include/machine/types.h: 63 | 64 | /usr/include/i386/types.h: 65 | 66 | /usr/include/string.h: 67 | -------------------------------------------------------------------------------- /.deps/client.Po: -------------------------------------------------------------------------------- 1 | client.o client.o: client.c client.h \ 2 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdbool.h \ 3 | /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ 4 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 5 | /usr/include/i386/_types.h zsglobal.h config.h /usr/include/stdlib.h \ 6 | /usr/include/available.h /usr/include/sys/wait.h \ 7 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 8 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 9 | /usr/include/i386/_structs.h /usr/include/sys/_structs.h \ 10 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 11 | /usr/include/sys/resource.h /usr/include/machine/endian.h \ 12 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 13 | /usr/include/libkern/_OSByteOrder.h \ 14 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h \ 15 | /usr/include/machine/types.h /usr/include/i386/types.h \ 16 | /usr/include/string.h /usr/include/unistd.h /usr/include/sys/unistd.h \ 17 | /usr/include/sys/select.h /usr/include/sys/_select.h \ 18 | /usr/include/fcntl.h /usr/include/sys/fcntl.h /usr/include/errno.h \ 19 | /usr/include/sys/errno.h /usr/include/ctype.h /usr/include/runetype.h \ 20 | /usr/include/sys/types.h /usr/include/sys/stat.h /usr/include/utime.h \ 21 | /usr/include/time.h /usr/include/_structs.h libzsync/zsync.h url.h 22 | 23 | client.h: 24 | 25 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdbool.h: 26 | 27 | /usr/include/stdio.h: 28 | 29 | /usr/include/_types.h: 30 | 31 | /usr/include/sys/_types.h: 32 | 33 | /usr/include/sys/cdefs.h: 34 | 35 | /usr/include/machine/_types.h: 36 | 37 | /usr/include/i386/_types.h: 38 | 39 | zsglobal.h: 40 | 41 | config.h: 42 | 43 | /usr/include/stdlib.h: 44 | 45 | /usr/include/available.h: 46 | 47 | /usr/include/sys/wait.h: 48 | 49 | /usr/include/sys/signal.h: 50 | 51 | /usr/include/sys/appleapiopts.h: 52 | 53 | /usr/include/machine/signal.h: 54 | 55 | /usr/include/i386/signal.h: 56 | 57 | /usr/include/i386/_structs.h: 58 | 59 | /usr/include/sys/_structs.h: 60 | 61 | /usr/include/machine/_structs.h: 62 | 63 | /usr/include/mach/i386/_structs.h: 64 | 65 | /usr/include/sys/resource.h: 66 | 67 | /usr/include/machine/endian.h: 68 | 69 | /usr/include/i386/endian.h: 70 | 71 | /usr/include/sys/_endian.h: 72 | 73 | /usr/include/libkern/_OSByteOrder.h: 74 | 75 | /usr/include/libkern/i386/_OSByteOrder.h: 76 | 77 | /usr/include/alloca.h: 78 | 79 | /usr/include/machine/types.h: 80 | 81 | /usr/include/i386/types.h: 82 | 83 | /usr/include/string.h: 84 | 85 | /usr/include/unistd.h: 86 | 87 | /usr/include/sys/unistd.h: 88 | 89 | /usr/include/sys/select.h: 90 | 91 | /usr/include/sys/_select.h: 92 | 93 | /usr/include/fcntl.h: 94 | 95 | /usr/include/sys/fcntl.h: 96 | 97 | /usr/include/errno.h: 98 | 99 | /usr/include/sys/errno.h: 100 | 101 | /usr/include/ctype.h: 102 | 103 | /usr/include/runetype.h: 104 | 105 | /usr/include/sys/types.h: 106 | 107 | /usr/include/sys/stat.h: 108 | 109 | /usr/include/utime.h: 110 | 111 | /usr/include/time.h: 112 | 113 | /usr/include/_structs.h: 114 | 115 | libzsync/zsync.h: 116 | 117 | url.h: 118 | -------------------------------------------------------------------------------- /.deps/clientcommand.Po: -------------------------------------------------------------------------------- 1 | clientcommand.o clientcommand.o: clientcommand.c client.h \ 2 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdbool.h \ 3 | /usr/include/stdio.h /usr/include/_types.h /usr/include/sys/_types.h \ 4 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 5 | /usr/include/i386/_types.h zsglobal.h config.h /usr/include/stdlib.h \ 6 | /usr/include/available.h /usr/include/sys/wait.h \ 7 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 8 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 9 | /usr/include/i386/_structs.h /usr/include/sys/_structs.h \ 10 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 11 | /usr/include/sys/resource.h /usr/include/machine/endian.h \ 12 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 13 | /usr/include/libkern/_OSByteOrder.h \ 14 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/alloca.h \ 15 | /usr/include/machine/types.h /usr/include/i386/types.h \ 16 | /usr/include/string.h /usr/include/unistd.h /usr/include/sys/unistd.h \ 17 | /usr/include/sys/select.h /usr/include/sys/_select.h \ 18 | /usr/include/sys/types.h progress.h http.h 19 | 20 | client.h: 21 | 22 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdbool.h: 23 | 24 | /usr/include/stdio.h: 25 | 26 | /usr/include/_types.h: 27 | 28 | /usr/include/sys/_types.h: 29 | 30 | /usr/include/sys/cdefs.h: 31 | 32 | /usr/include/machine/_types.h: 33 | 34 | /usr/include/i386/_types.h: 35 | 36 | zsglobal.h: 37 | 38 | config.h: 39 | 40 | /usr/include/stdlib.h: 41 | 42 | /usr/include/available.h: 43 | 44 | /usr/include/sys/wait.h: 45 | 46 | /usr/include/sys/signal.h: 47 | 48 | /usr/include/sys/appleapiopts.h: 49 | 50 | /usr/include/machine/signal.h: 51 | 52 | /usr/include/i386/signal.h: 53 | 54 | /usr/include/i386/_structs.h: 55 | 56 | /usr/include/sys/_structs.h: 57 | 58 | /usr/include/machine/_structs.h: 59 | 60 | /usr/include/mach/i386/_structs.h: 61 | 62 | /usr/include/sys/resource.h: 63 | 64 | /usr/include/machine/endian.h: 65 | 66 | /usr/include/i386/endian.h: 67 | 68 | /usr/include/sys/_endian.h: 69 | 70 | /usr/include/libkern/_OSByteOrder.h: 71 | 72 | /usr/include/libkern/i386/_OSByteOrder.h: 73 | 74 | /usr/include/alloca.h: 75 | 76 | /usr/include/machine/types.h: 77 | 78 | /usr/include/i386/types.h: 79 | 80 | /usr/include/string.h: 81 | 82 | /usr/include/unistd.h: 83 | 84 | /usr/include/sys/unistd.h: 85 | 86 | /usr/include/sys/select.h: 87 | 88 | /usr/include/sys/_select.h: 89 | 90 | /usr/include/sys/types.h: 91 | 92 | progress.h: 93 | 94 | http.h: 95 | -------------------------------------------------------------------------------- /.deps/getaddrinfo.Po: -------------------------------------------------------------------------------- 1 | # dummy 2 | -------------------------------------------------------------------------------- /.deps/http.Po: -------------------------------------------------------------------------------- 1 | http.o http.o: http.c zsglobal.h config.h /usr/include/stdio.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h /usr/include/string.h /usr/include/errno.h \ 11 | /usr/include/sys/errno.h /usr/include/unistd.h \ 12 | /usr/include/sys/unistd.h /usr/include/sys/types.h \ 13 | /usr/include/machine/types.h /usr/include/i386/types.h \ 14 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 15 | /usr/include/sys/stat.h /usr/include/sys/socket.h \ 16 | /usr/include/machine/_param.h /usr/include/i386/_param.h \ 17 | /usr/include/netdb.h \ 18 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ 19 | /usr/include/netinet/in.h /usr/include/sys/_endian.h \ 20 | /usr/include/libkern/_OSByteOrder.h \ 21 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/netinet6/in6.h \ 22 | /usr/include/time.h /usr/include/_structs.h http.h url.h progress.h \ 23 | format_string.h /usr/include/inttypes.h 24 | 25 | zsglobal.h: 26 | 27 | config.h: 28 | 29 | /usr/include/stdio.h: 30 | 31 | /usr/include/_types.h: 32 | 33 | /usr/include/sys/_types.h: 34 | 35 | /usr/include/sys/cdefs.h: 36 | 37 | /usr/include/machine/_types.h: 38 | 39 | /usr/include/i386/_types.h: 40 | 41 | /usr/include/stdlib.h: 42 | 43 | /usr/include/available.h: 44 | 45 | /usr/include/sys/wait.h: 46 | 47 | /usr/include/sys/signal.h: 48 | 49 | /usr/include/sys/appleapiopts.h: 50 | 51 | /usr/include/machine/signal.h: 52 | 53 | /usr/include/i386/signal.h: 54 | 55 | /usr/include/sys/_structs.h: 56 | 57 | /usr/include/machine/_structs.h: 58 | 59 | /usr/include/i386/_structs.h: 60 | 61 | /usr/include/mach/i386/_structs.h: 62 | 63 | /usr/include/sys/resource.h: 64 | 65 | /usr/include/string.h: 66 | 67 | /usr/include/errno.h: 68 | 69 | /usr/include/sys/errno.h: 70 | 71 | /usr/include/unistd.h: 72 | 73 | /usr/include/sys/unistd.h: 74 | 75 | /usr/include/sys/types.h: 76 | 77 | /usr/include/machine/types.h: 78 | 79 | /usr/include/i386/types.h: 80 | 81 | /usr/include/machine/endian.h: 82 | 83 | /usr/include/i386/endian.h: 84 | 85 | /usr/include/sys/stat.h: 86 | 87 | /usr/include/sys/socket.h: 88 | 89 | /usr/include/machine/_param.h: 90 | 91 | /usr/include/i386/_param.h: 92 | 93 | /usr/include/netdb.h: 94 | 95 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 96 | 97 | /usr/include/netinet/in.h: 98 | 99 | /usr/include/sys/_endian.h: 100 | 101 | /usr/include/libkern/_OSByteOrder.h: 102 | 103 | /usr/include/libkern/i386/_OSByteOrder.h: 104 | 105 | /usr/include/netinet6/in6.h: 106 | 107 | /usr/include/time.h: 108 | 109 | /usr/include/_structs.h: 110 | 111 | http.h: 112 | 113 | url.h: 114 | 115 | progress.h: 116 | 117 | format_string.h: 118 | 119 | /usr/include/inttypes.h: 120 | -------------------------------------------------------------------------------- /.deps/make.Po: -------------------------------------------------------------------------------- 1 | make.o make.o: make.c zsglobal.h config.h /usr/include/stdio.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h /usr/include/string.h /usr/include/unistd.h \ 11 | /usr/include/sys/unistd.h /usr/include/ctype.h /usr/include/runetype.h \ 12 | /usr/include/errno.h /usr/include/sys/errno.h /usr/include/libgen.h \ 13 | /usr/include/math.h /usr/include/architecture/i386/math.h \ 14 | /usr/include/time.h /usr/include/_structs.h /usr/include/arpa/inet.h \ 15 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ 16 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 17 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 18 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/netinet/in.h \ 19 | /usr/include/sys/socket.h /usr/include/machine/_param.h \ 20 | /usr/include/i386/_param.h /usr/include/netinet6/in6.h \ 21 | /usr/include/inttypes.h /usr/include/sys/types.h \ 22 | /usr/include/machine/types.h /usr/include/i386/types.h \ 23 | /usr/include/sys/stat.h makegz.h librcksum/rcksum.h libzsync/zmap.h \ 24 | zsglobal.h libzsync/sha1.h config.h zlib/zlib.h zlib/zconf.h \ 25 | format_string.h 26 | 27 | zsglobal.h: 28 | 29 | config.h: 30 | 31 | /usr/include/stdio.h: 32 | 33 | /usr/include/_types.h: 34 | 35 | /usr/include/sys/_types.h: 36 | 37 | /usr/include/sys/cdefs.h: 38 | 39 | /usr/include/machine/_types.h: 40 | 41 | /usr/include/i386/_types.h: 42 | 43 | /usr/include/stdlib.h: 44 | 45 | /usr/include/available.h: 46 | 47 | /usr/include/sys/wait.h: 48 | 49 | /usr/include/sys/signal.h: 50 | 51 | /usr/include/sys/appleapiopts.h: 52 | 53 | /usr/include/machine/signal.h: 54 | 55 | /usr/include/i386/signal.h: 56 | 57 | /usr/include/sys/_structs.h: 58 | 59 | /usr/include/machine/_structs.h: 60 | 61 | /usr/include/i386/_structs.h: 62 | 63 | /usr/include/mach/i386/_structs.h: 64 | 65 | /usr/include/sys/resource.h: 66 | 67 | /usr/include/string.h: 68 | 69 | /usr/include/unistd.h: 70 | 71 | /usr/include/sys/unistd.h: 72 | 73 | /usr/include/ctype.h: 74 | 75 | /usr/include/runetype.h: 76 | 77 | /usr/include/errno.h: 78 | 79 | /usr/include/sys/errno.h: 80 | 81 | /usr/include/libgen.h: 82 | 83 | /usr/include/math.h: 84 | 85 | /usr/include/architecture/i386/math.h: 86 | 87 | /usr/include/time.h: 88 | 89 | /usr/include/_structs.h: 90 | 91 | /usr/include/arpa/inet.h: 92 | 93 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 94 | 95 | /usr/include/machine/endian.h: 96 | 97 | /usr/include/i386/endian.h: 98 | 99 | /usr/include/sys/_endian.h: 100 | 101 | /usr/include/libkern/_OSByteOrder.h: 102 | 103 | /usr/include/libkern/i386/_OSByteOrder.h: 104 | 105 | /usr/include/netinet/in.h: 106 | 107 | /usr/include/sys/socket.h: 108 | 109 | /usr/include/machine/_param.h: 110 | 111 | /usr/include/i386/_param.h: 112 | 113 | /usr/include/netinet6/in6.h: 114 | 115 | /usr/include/inttypes.h: 116 | 117 | /usr/include/sys/types.h: 118 | 119 | /usr/include/machine/types.h: 120 | 121 | /usr/include/i386/types.h: 122 | 123 | /usr/include/sys/stat.h: 124 | 125 | makegz.h: 126 | 127 | librcksum/rcksum.h: 128 | 129 | libzsync/zmap.h: 130 | 131 | zsglobal.h: 132 | 133 | libzsync/sha1.h: 134 | 135 | config.h: 136 | 137 | zlib/zlib.h: 138 | 139 | zlib/zconf.h: 140 | 141 | format_string.h: 142 | -------------------------------------------------------------------------------- /.deps/makegz.Po: -------------------------------------------------------------------------------- 1 | makegz.o makegz.o: makegz.c zsglobal.h config.h /usr/include/stdio.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/unistd.h \ 5 | /usr/include/sys/unistd.h /usr/include/stdlib.h \ 6 | /usr/include/available.h /usr/include/sys/wait.h \ 7 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 8 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 9 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 10 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 11 | /usr/include/sys/resource.h zlib/zlib.h zlib/zconf.h \ 12 | /usr/include/sys/types.h /usr/include/machine/types.h \ 13 | /usr/include/i386/types.h /usr/include/machine/endian.h \ 14 | /usr/include/i386/endian.h /usr/include/sys/stat.h 15 | 16 | zsglobal.h: 17 | 18 | config.h: 19 | 20 | /usr/include/stdio.h: 21 | 22 | /usr/include/_types.h: 23 | 24 | /usr/include/sys/_types.h: 25 | 26 | /usr/include/sys/cdefs.h: 27 | 28 | /usr/include/machine/_types.h: 29 | 30 | /usr/include/i386/_types.h: 31 | 32 | /usr/include/unistd.h: 33 | 34 | /usr/include/sys/unistd.h: 35 | 36 | /usr/include/stdlib.h: 37 | 38 | /usr/include/available.h: 39 | 40 | /usr/include/sys/wait.h: 41 | 42 | /usr/include/sys/signal.h: 43 | 44 | /usr/include/sys/appleapiopts.h: 45 | 46 | /usr/include/machine/signal.h: 47 | 48 | /usr/include/i386/signal.h: 49 | 50 | /usr/include/sys/_structs.h: 51 | 52 | /usr/include/machine/_structs.h: 53 | 54 | /usr/include/i386/_structs.h: 55 | 56 | /usr/include/mach/i386/_structs.h: 57 | 58 | /usr/include/sys/resource.h: 59 | 60 | zlib/zlib.h: 61 | 62 | zlib/zconf.h: 63 | 64 | /usr/include/sys/types.h: 65 | 66 | /usr/include/machine/types.h: 67 | 68 | /usr/include/i386/types.h: 69 | 70 | /usr/include/machine/endian.h: 71 | 72 | /usr/include/i386/endian.h: 73 | 74 | /usr/include/sys/stat.h: 75 | -------------------------------------------------------------------------------- /.deps/progress.Po: -------------------------------------------------------------------------------- 1 | progress.o progress.o: progress.c zsglobal.h config.h \ 2 | /usr/include/stdlib.h /usr/include/available.h /usr/include/_types.h \ 3 | /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ 4 | /usr/include/machine/_types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/wait.h /usr/include/sys/signal.h \ 6 | /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h \ 7 | /usr/include/i386/signal.h /usr/include/sys/_structs.h \ 8 | /usr/include/machine/_structs.h /usr/include/i386/_structs.h \ 9 | /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ 10 | /usr/include/stdio.h /usr/include/time.h /usr/include/_structs.h \ 11 | progress.h 12 | 13 | zsglobal.h: 14 | 15 | config.h: 16 | 17 | /usr/include/stdlib.h: 18 | 19 | /usr/include/available.h: 20 | 21 | /usr/include/_types.h: 22 | 23 | /usr/include/sys/_types.h: 24 | 25 | /usr/include/sys/cdefs.h: 26 | 27 | /usr/include/machine/_types.h: 28 | 29 | /usr/include/i386/_types.h: 30 | 31 | /usr/include/sys/wait.h: 32 | 33 | /usr/include/sys/signal.h: 34 | 35 | /usr/include/sys/appleapiopts.h: 36 | 37 | /usr/include/machine/signal.h: 38 | 39 | /usr/include/i386/signal.h: 40 | 41 | /usr/include/sys/_structs.h: 42 | 43 | /usr/include/machine/_structs.h: 44 | 45 | /usr/include/i386/_structs.h: 46 | 47 | /usr/include/mach/i386/_structs.h: 48 | 49 | /usr/include/sys/resource.h: 50 | 51 | /usr/include/stdio.h: 52 | 53 | /usr/include/time.h: 54 | 55 | /usr/include/_structs.h: 56 | 57 | progress.h: 58 | -------------------------------------------------------------------------------- /.deps/url.Po: -------------------------------------------------------------------------------- 1 | url.o url.o: url.c zsglobal.h config.h /usr/include/string.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h url.h 11 | 12 | zsglobal.h: 13 | 14 | config.h: 15 | 16 | /usr/include/string.h: 17 | 18 | /usr/include/_types.h: 19 | 20 | /usr/include/sys/_types.h: 21 | 22 | /usr/include/sys/cdefs.h: 23 | 24 | /usr/include/machine/_types.h: 25 | 26 | /usr/include/i386/_types.h: 27 | 28 | /usr/include/stdlib.h: 29 | 30 | /usr/include/available.h: 31 | 32 | /usr/include/sys/wait.h: 33 | 34 | /usr/include/sys/signal.h: 35 | 36 | /usr/include/sys/appleapiopts.h: 37 | 38 | /usr/include/machine/signal.h: 39 | 40 | /usr/include/i386/signal.h: 41 | 42 | /usr/include/sys/_structs.h: 43 | 44 | /usr/include/machine/_structs.h: 45 | 46 | /usr/include/i386/_structs.h: 47 | 48 | /usr/include/mach/i386/_structs.h: 49 | 50 | /usr/include/sys/resource.h: 51 | 52 | url.h: 53 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | AUTOMAKE_OPTIONS = check-news 3 | 4 | SUBDIRS = librcksum zlib libzsync doc 5 | 6 | bin_PROGRAMS = zsyncmake zsync 7 | 8 | zsyncmake_SOURCES = make.c makegz.c makegz.h format_string.h 9 | zsyncmake_LDADD = libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a zlib/libdeflate.a -lm 10 | 11 | noinst_LIBRARIES = libzsyncclient.a 12 | libzsyncclient_a_SOURCES = client.c url.c url.h progress.c progress.h base64.c format_string.h zsglobal.h 13 | 14 | EXTRA_libzsyncclient_a_SOURCES = getaddrinfo.h 15 | 16 | zsync_SOURCES = clientcommand.c http.c http.h 17 | zsync_LDADD = libzsyncclient.a libzsync/libzsync.a librcksum/librcksum.a zlib/libinflate.a $(LIBOBJS) 18 | 19 | # From "GNU autoconf, automake and libtool" Vaughan, Elliston, 20 | # # Tromey and Taylor, publisher New Riders, p.134 21 | # # They made me do it! :-) 22 | AUX_DIST_GEN = \ 23 | $(ac_aux_dir)/install-sh \ 24 | $(ac_aux_dir)/missing \ 25 | $(ac_aux_dir)/ac_c_compile_flags.m4 \ 26 | $(ac_aux_dir)/herrno.m4 \ 27 | $(ac_aux_dir)/in6addr.m4 \ 28 | $(ac_aux_dir)/sockaddrin6.m4 \ 29 | $(ac_aux_dir)/sockinttypes.m4 30 | 31 | docdir=$(prefix)/share/doc/@PACKAGE@ 32 | doc_DATA = COPYING README 33 | EXTRA_DIST = bootstrap INSTALL README COPYING $(AUX_DIST_GEN) check-zsyncmake 34 | 35 | TESTS_ENVIRONMENT = top_builddir=$(top_builddir) 36 | TESTS = check-zsyncmake 37 | 38 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Changes in 0.6 2 | - fix out-of-bounds memory access when processing last block of non-compressed 3 | download (patch from Timothy Lee). Also fix an error handling fault for the 4 | same. 5 | - fix "try a smaller blocksize" failures when zsyncmakeing for huge compressed 6 | files on 32bit systems 7 | - preserve mtime on downloaded files 8 | - fix potential crash when re/deallocating checksum hash in librcksum (patch 9 | from Timothy Lee) 10 | - explain status code errors better 11 | - better URL handling 12 | - add -q as a substitute for -s, as -q is more conventional (re wget). -q also 13 | suppresses the 'no relevant local data' warning now. 14 | - fix some warnings 15 | - code tidy-up and better commenting of what it is doing 16 | - tidy up autoconf use 17 | 18 | Changes in 0.5 19 | - get large file support where possible 20 | - replacement getaddrinfo on systems that lack it 21 | - fix compilation on MacOS X 22 | 23 | Changes in 0.4.3 24 | - make -s suppress summary info too 25 | - add HTTP authentication support 26 | 27 | Changes in 0.4.2 28 | - fix CAN-2005-1849 for embedded zlib 29 | - obey -s flag 30 | 31 | Changes in 0.4.1 32 | - security fix from zlib-1.2.2 33 | - generate RFC 1123 date strings in HTTP requests 34 | - include port numbers in Host headers 35 | - be slightly more accepting in proxy URL syntax 36 | - don't generate Accept-Ranges headers 37 | 38 | Changes in 0.4.0 39 | - now considered beta instead of alpha quality 40 | - fixed incorrect 100%/done display of progress bar when cleanly disconnected before end by server 41 | - updated autoconf/automake scripts 42 | 43 | Changes in 0.3.3 44 | - build in gzip in zsyncmake which produces .gz files optimised for zsync 45 | - quickly stop downloading from a URL producing bad data 46 | - -k option to keep the .zsync file, and redownload only when it changes 47 | - fixes some possible crashes that could occur with unexpected remote responses 48 | 49 | Changes in 0.3.2 50 | - automatically decompress local seed data when this is appropriate 51 | - progress bars with rate and ETA for all downloads 52 | - automatically recompress downloaded file if possible 53 | - deal better with local .zsyncs containing relative URLs 54 | 55 | Changes in 0.3.1 56 | - fix SEGV when downloading with no local data found 57 | - fix failure when incomplete final block of uncompressed stream is unknown 58 | - fix some memory leaks 59 | 60 | Changes in 0.3.0 61 | - fix endian check in libhash (works on FreeBSD again) 62 | - major code reorganisation 63 | 64 | Changes in 0.2.3 65 | - fix crash in zsyncmake with short files 66 | - "negative" hash table used to speed up processing 67 | 68 | Changes in 0.2.2 69 | - complete support for stored blocks in gzip files 70 | - update block size recommendations in man page 71 | 72 | Changes in 0.2.1 73 | - fixed bug where zsync would loop if fed more than one local source file 74 | - enabled zsync to handle gzip files containing stored (uncompressed) blocks (so we should do slightly better on gzipped binaries now - but this is still incomplete and will not work for all files) 75 | 76 | Changes in 0.2.0 77 | - major reduction in the size of the control file, due to some new optimisations 78 | - further fixes for servers refusing to do multipart/byteranges responses 79 | 80 | Changes in 0.1.6 81 | - fixes some problems with compressed file downloads and unusual server responses 82 | - improved http_proxy parsing 83 | 84 | Changes in 0.1.5 85 | - fixes some minor HTTP problems 86 | 87 | Changes in 0.1.4 88 | - fixed compilation with gcc-3.4 89 | 90 | Changes in 0.1.3 91 | - HTTP proxy support 92 | - better HTTP support - we deal better with unusual server responses 93 | 94 | Changes in 0.1.2 95 | - fixes for Solaris/sparc 96 | 97 | Changes in 0.1.1 98 | - more efficient compressed stream support 99 | - code cleanups 100 | 101 | Changes in 0.1.0 102 | - finished the cleanup of the compressed file transfer code 103 | - major improvement in efficiency for compressed file transfers 104 | - OpenSSL is no longer required 105 | - now under the v2 Artistic License 106 | 107 | Changes in 0.0.6 108 | - just code cleanups and documentation updates 109 | 110 | Changes in 0.0.5 111 | - switch to OpenSSL's MD4 code 112 | - fix checksumming at stream end 113 | - fix various portability problems 114 | 115 | Changes in 0.0.4 116 | - relative URLs in .zsync files supported 117 | - HTTP redirects are followed for the metafile 118 | - now uses both compressed and uncompressed sources to further reduce download sizes 119 | 120 | Changes in 0.0.3 121 | - fix HTTP connection termination handling 122 | - speed up local file reading 123 | 124 | Changes in 0.0.2 125 | - HTTP/1.1, with pipelining 126 | - cleaning up more of the libc streams and mmap clutter 127 | - progress displays 128 | - lots of bugfixes 129 | 130 | First release 0.0.1. 131 | 132 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/th-in-gs/zsync/d1558117e264df7f779e99624fc8a6732b571c9f/README -------------------------------------------------------------------------------- /autom4te.cache/requests: -------------------------------------------------------------------------------- 1 | # This file was generated. 2 | # It contains the lists of macros which have been traced. 3 | # It can be safely removed. 4 | 5 | @request = ( 6 | bless( [ 7 | '0', 8 | 1, 9 | [ 10 | '/usr/share/autoconf' 11 | ], 12 | [ 13 | '/usr/share/autoconf/autoconf/autoconf.m4f', 14 | '/usr/share/aclocal-1.10/amversion.m4', 15 | '/usr/share/aclocal-1.10/auxdir.m4', 16 | '/usr/share/aclocal-1.10/cond.m4', 17 | '/usr/share/aclocal-1.10/depend.m4', 18 | '/usr/share/aclocal-1.10/depout.m4', 19 | '/usr/share/aclocal-1.10/dmalloc.m4', 20 | '/usr/share/aclocal-1.10/init.m4', 21 | '/usr/share/aclocal-1.10/install-sh.m4', 22 | '/usr/share/aclocal-1.10/lead-dot.m4', 23 | '/usr/share/aclocal-1.10/maintainer.m4', 24 | '/usr/share/aclocal-1.10/make.m4', 25 | '/usr/share/aclocal-1.10/missing.m4', 26 | '/usr/share/aclocal-1.10/mkdirp.m4', 27 | '/usr/share/aclocal-1.10/options.m4', 28 | '/usr/share/aclocal-1.10/runlog.m4', 29 | '/usr/share/aclocal-1.10/sanity.m4', 30 | '/usr/share/aclocal-1.10/strip.m4', 31 | '/usr/share/aclocal-1.10/substnot.m4', 32 | '/usr/share/aclocal-1.10/tar.m4', 33 | 'autotools/ac_c_compile_flags.m4', 34 | 'autotools/herrno.m4', 35 | 'autotools/sockinttypes.m4', 36 | 'configure.ac' 37 | ], 38 | { 39 | 'm4_pattern_forbid' => 1, 40 | 'AM_SET_CURRENT_AUTOMAKE_VERSION' => 1, 41 | 'jm_MAINTAINER_MODE' => 1, 42 | '_AM_SET_OPTION' => 1, 43 | 'X_TYPE_SOCKLEN_T' => 1, 44 | 'AC_DEFUN' => 1, 45 | 'AM_PROG_MKDIR_P' => 1, 46 | 'AM_INIT_AUTOMAKE' => 1, 47 | 'AM_AUTOMAKE_VERSION' => 1, 48 | 'AM_MISSING_HAS_RUN' => 1, 49 | 'AM_MISSING_PROG' => 1, 50 | 'AM_WITH_DMALLOC' => 1, 51 | 'AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, 52 | 'AM_MAINTAINER_MODE' => 1, 53 | 'AC_DEFUN_ONCE' => 1, 54 | 'AM_PROG_INSTALL_STRIP' => 1, 55 | 'X_C_COMPILE_FLAGS' => 1, 56 | '_m4_warn' => 1, 57 | 'X_TYPE_IN_PORT_T' => 1, 58 | 'AM_SANITY_CHECK' => 1, 59 | 'X_DECL_H_ERRNO' => 1, 60 | 'include' => 1, 61 | 'fp_WITH_DMALLOC' => 1, 62 | '_AM_PROG_TAR' => 1, 63 | 'AM_AUX_DIR_EXPAND' => 1, 64 | 'AM_DEP_TRACK' => 1, 65 | '_AM_SET_OPTIONS' => 1, 66 | 'AM_RUN_LOG' => 1, 67 | '_AM_OUTPUT_DEPENDENCY_COMMANDS' => 1, 68 | '_AM_IF_OPTION' => 1, 69 | '_AM_SUBST_NOTMAKE' => 1, 70 | '_AM_AUTOCONF_VERSION' => 1, 71 | 'm4_pattern_allow' => 1, 72 | '_AM_MANGLE_OPTION' => 1, 73 | 'AM_SET_LEADING_DOT' => 1, 74 | 'AM_CONDITIONAL' => 1, 75 | 'AM_SET_DEPDIR' => 1, 76 | '_AM_DEPENDENCIES' => 1, 77 | 'X_TYPE_SA_FAMILY_T' => 1, 78 | 'AM_PROG_INSTALL_SH' => 1, 79 | 'm4_include' => 1, 80 | '_AC_AM_CONFIG_HEADER_HOOK' => 1, 81 | 'AU_DEFUN' => 1, 82 | 'AM_MAKE_INCLUDE' => 1 83 | } 84 | ], 'Autom4te::Request' ), 85 | bless( [ 86 | '1', 87 | 1, 88 | [ 89 | '/usr/share/autoconf' 90 | ], 91 | [ 92 | '/usr/share/autoconf/autoconf/autoconf.m4f', 93 | 'aclocal.m4', 94 | 'configure.ac' 95 | ], 96 | { 97 | '_LT_AC_TAGCONFIG' => 1, 98 | 'AM_PROG_F77_C_O' => 1, 99 | 'AC_INIT' => 1, 100 | 'm4_pattern_forbid' => 1, 101 | 'AC_CANONICAL_TARGET' => 1, 102 | 'AC_SUBST' => 1, 103 | 'AC_CONFIG_LIBOBJ_DIR' => 1, 104 | 'AC_FC_SRCEXT' => 1, 105 | 'AC_CANONICAL_HOST' => 1, 106 | 'AC_PROG_LIBTOOL' => 1, 107 | 'AM_INIT_AUTOMAKE' => 1, 108 | 'AC_CONFIG_SUBDIRS' => 1, 109 | 'AM_AUTOMAKE_VERSION' => 1, 110 | 'LT_CONFIG_LTDL_DIR' => 1, 111 | 'AC_REQUIRE_AUX_FILE' => 1, 112 | 'AC_CONFIG_LINKS' => 1, 113 | 'm4_sinclude' => 1, 114 | 'LT_SUPPORTED_TAG' => 1, 115 | 'AM_MAINTAINER_MODE' => 1, 116 | 'AM_GNU_GETTEXT_INTL_SUBDIR' => 1, 117 | '_m4_warn' => 1, 118 | 'AM_PROG_CXX_C_O' => 1, 119 | 'AM_ENABLE_MULTILIB' => 1, 120 | 'AC_CONFIG_FILES' => 1, 121 | 'include' => 1, 122 | 'LT_INIT' => 1, 123 | 'AM_GNU_GETTEXT' => 1, 124 | 'AC_LIBSOURCE' => 1, 125 | 'AM_PROG_FC_C_O' => 1, 126 | 'AC_CANONICAL_BUILD' => 1, 127 | 'AC_FC_FREEFORM' => 1, 128 | 'AH_OUTPUT' => 1, 129 | '_AM_SUBST_NOTMAKE' => 1, 130 | 'AC_CONFIG_AUX_DIR' => 1, 131 | 'sinclude' => 1, 132 | 'AM_PROG_CC_C_O' => 1, 133 | 'm4_pattern_allow' => 1, 134 | 'AC_CANONICAL_SYSTEM' => 1, 135 | 'AM_CONDITIONAL' => 1, 136 | 'AC_CONFIG_HEADERS' => 1, 137 | 'AC_DEFINE_TRACE_LITERAL' => 1, 138 | 'm4_include' => 1, 139 | 'AC_SUBST_TRACE' => 1 140 | } 141 | ], 'Autom4te::Request' ) 142 | ); 143 | 144 | -------------------------------------------------------------------------------- /autotools/ac_c_compile_flags.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([X_C_COMPILE_FLAGS],[ 2 | NEW_CFLAGS="$CFLAGS" 3 | for ac_flag in $1 4 | do 5 | AC_MSG_CHECKING(whether compiler supports $ac_flag) 6 | CFLAGS="$NEW_CFLAGS $ac_flag" 7 | AC_TRY_COMPILE(,[ 8 | void f() {}; 9 | ],[ 10 | NEW_CFLAGS="$CFLAGS" 11 | AC_MSG_RESULT(yes) 12 | ],AC_MSG_RESULT(no)) 13 | done 14 | CFLAGS="$NEW_CFLAGS" 15 | ]) 16 | -------------------------------------------------------------------------------- /autotools/herrno.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for h_errno. 31 | dnl * 32 | AC_DEFUN([X_DECL_H_ERRNO], 33 | [AC_CACHE_CHECK(for h_errno declaration in netdb.h, ac_cv_decl_h_errno, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include ]], [[ 36 | h_errno = 0; 37 | ]])],[ac_cv_decl_h_errno=yes],[ac_cv_decl_h_errno=no])]) 38 | if test "$ac_cv_decl_h_errno" = yes; then 39 | AC_DEFINE(H_ERRNO_DECLARED, 1, 40 | [Define to 1 if `h_errno' is declared by ]) 41 | fi]) 42 | -------------------------------------------------------------------------------- /autotools/in6addr.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct in6_addr 31 | dnl * 32 | AC_DEFUN([X_STRUCT_IN6_ADDR], 33 | [AC_CACHE_CHECK(for struct in6_addr, ac_cv_struct_in6_addr, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include 37 | #include ]], [[ 38 | struct in6_addr address; 39 | ]])],[ac_cv_struct_in6_addr=yes],[ac_cv_struct_in6_addr=no])]) 40 | if test "$ac_cv_struct_in6_addr" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_IN6_ADDR, 1, 42 | [Define to 1 if defines `struct in6_addr']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for in6addr_any. 47 | dnl * 48 | AC_DEFUN([X_DECL_IN6ADDR_ANY], 49 | [AC_REQUIRE([AC_STRUCT_IN6_ADDR]) 50 | if test $ac_cv_struct_in6_addr = no; then 51 | ac_cv_decl_in6addr_any=no 52 | else 53 | AC_CACHE_CHECK(for in6addr_any declaration in netinet/in.h, 54 | ac_cv_decl_in6addr_any, 55 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 56 | #include 57 | #include 58 | #include ]], [[ 59 | unsigned char *address; 60 | address = (char *)&in6addr_any; 61 | ]])],[ac_cv_decl_in6addr_any=yes],[ac_cv_decl_in6addr_any=no])]) 62 | if test "$ac_cv_decl_in6addr_any" = yes; then 63 | AC_DEFINE(IN6ADDR_ANY_DECLARED, 1, 64 | [Define to 1 if `in6addr_any' is declared by ]) 65 | fi 66 | fi]) 67 | 68 | dnl * 69 | dnl * Check for in6addr_loopback. 70 | dnl * 71 | AC_DEFUN([X_DECL_IN6ADDR_LOOPBACK], 72 | [AC_REQUIRE([AC_STRUCT_IN6_ADDR]) 73 | if test $ac_cv_struct_in6_addr = no; then 74 | ac_cv_decl_in6addr_loopback=no 75 | else 76 | AC_CACHE_CHECK(for in6addr_loopback declaration in netinet/in.h, 77 | ac_cv_decl_in6addr_loopback, 78 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 79 | #include 80 | #include 81 | #include ]], [[ 82 | unsigned char *address; 83 | address = (char *)&in6addr_loopback; 84 | ]])],[ac_cv_decl_in6addr_loopback=yes],[ac_cv_decl_in6addr_loopback=no])]) 85 | if test "$ac_cv_decl_in6addr_loopback" = yes; then 86 | AC_DEFINE(IN6ADDR_LOOPBACK_DECLARED, 1, 87 | [Define to 1 if `in6addr_loopback' is declared by ]) 88 | fi 89 | fi]) 90 | -------------------------------------------------------------------------------- /autotools/sockaddrin6.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for struct sockaddr_in6 31 | dnl * 32 | AC_DEFUN([X_STRUCT_SOCKADDR_IN6], 33 | [AC_CACHE_CHECK(for struct sockaddr_in6, ac_cv_struct_sockaddr_in6, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include 37 | #include ]], [[ 38 | struct sockaddr_in6 address; 39 | ]])],[ac_cv_struct_sockaddr_in6=yes],[ac_cv_struct_sockaddr_in6=no])]) 40 | if test "$ac_cv_struct_sockaddr_in6" = yes; then 41 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6, 1, 42 | [Define to 1 if defines `struct sockaddr_in6']) 43 | fi]) 44 | 45 | dnl * 46 | dnl * Check for struct sockaddr_storage 47 | dnl * 48 | AC_DEFUN([X_STRUCT_SOCKADDR_STORAGE], 49 | [AC_CACHE_CHECK(for struct sockaddr_storage, ac_cv_struct_sockaddr_storage, 50 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 51 | #include 52 | #include 53 | #include ]], [[ 54 | struct sockaddr_storage address; 55 | ]])],[ac_cv_struct_sockaddr_storage=yes],[ac_cv_struct_sockaddr_storage=no])]) 56 | if test "$ac_cv_struct_sockaddr_storage" = yes; then 57 | AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, 58 | [Define to 1 if defines `struct sockaddr_storage']) 59 | fi]) 60 | 61 | -------------------------------------------------------------------------------- /autotools/sockinttypes.m4: -------------------------------------------------------------------------------- 1 | dnl * 2 | dnl * Copyright (c) 2001, 2003 Motoyuki Kasahara 3 | dnl * 4 | dnl * Redistribution and use in source and binary forms, with or without 5 | dnl * modification, are permitted provided that the following conditions 6 | dnl * are met: 7 | dnl * 1. Redistributions of source code must retain the above copyright 8 | dnl * notice, this list of conditions and the following disclaimer. 9 | dnl * 2. Redistributions in binary form must reproduce the above copyright 10 | dnl * notice, this list of conditions and the following disclaimer in the 11 | dnl * documentation and/or other materials provided with the distribution. 12 | dnl * 3. Neither the name of the project nor the names of its contributors 13 | dnl * may be used to endorse or promote products derived from this software 14 | dnl * without specific prior written permission. 15 | dnl * 16 | dnl * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | dnl * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | dnl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19 | dnl * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORSBE 20 | dnl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21 | dnl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22 | dnl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23 | dnl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24 | dnl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25 | dnl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF 26 | dnl * THE POSSIBILITY OF SUCH DAMAGE. 27 | dnl * 28 | 29 | dnl * 30 | dnl * Check for socklen_t. 31 | dnl * 32 | AC_DEFUN([X_TYPE_SOCKLEN_T], 33 | [AC_CACHE_CHECK([for socklen_t], ac_cv_type_socklen_t, 34 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 35 | #include 36 | #include ]], [[ 37 | socklen_t socklen; 38 | ]])],[ac_cv_type_socklen_t=yes],[ac_cv_type_socklen_t=no])]) 39 | if test "$ac_cv_type_socklen_t" != yes; then 40 | AC_DEFINE(socklen_t, int, 41 | [Define to `int' if or does not define.]) 42 | fi]) 43 | 44 | dnl * 45 | dnl * Check for in_port_t. 46 | dnl * 47 | AC_DEFUN([X_TYPE_IN_PORT_T], 48 | [AC_CACHE_CHECK([for in_port_t], ac_cv_type_in_port_t, 49 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 50 | #include 51 | #include 52 | #include ]], [[ 53 | in_port_t in_port; 54 | ]])],[ac_cv_type_in_port_t=yes],[ac_cv_type_in_port_t=no])]) 55 | if test "$ac_cv_type_in_port_t" != yes; then 56 | ac_cv_sin_port_size=unknown 57 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 58 | #include 59 | #include 60 | #include 61 | int main() { 62 | struct sockaddr_in addr; 63 | return (sizeof(addr.sin_port) == sizeof(long)) ? 0 : 1; 64 | } 65 | ]])],[ac_cv_sin_port_size=long],[],[]) 66 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 67 | #include 68 | #include 69 | #include 70 | int main() { 71 | struct sockaddr_in addr; 72 | return (sizeof(addr.sin_port) == sizeof(int)) ? 0 : 1; 73 | } 74 | ]])],[ac_cv_sin_port_size=int],[],[]) 75 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 76 | #include 77 | #include 78 | #include 79 | int main() { 80 | struct sockaddr_in addr; 81 | return (sizeof(addr.sin_port) == sizeof(short)) ? 0 : 1; 82 | } 83 | ]])],[ac_cv_sin_port_size=short],[],[]) 84 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 85 | #include 86 | #include 87 | #include 88 | int main() { 89 | struct sockaddr_in addr; 90 | return (sizeof(addr.sin_port) == sizeof(char)) ? 0 : 1; 91 | } 92 | ]])],[ac_cv_sin_port_size=char],[],[]) 93 | if test "$ac_cv_sin_port_size" = unknown; then 94 | AC_MSG_ERROR([Failed to get size of sin_port in struct sockaddr_in.]) 95 | fi 96 | AC_DEFINE_UNQUOTED(in_port_t, unsigned $ac_cv_sin_port_size, 97 | [Define to `unsigned char', `unsigned short', `unsigned int' or 98 | `unsigned long' according with size of `sin_port' in `struct sockaddr_in', 99 | if , or does not define 100 | `in_port_t'.]) 101 | fi]) 102 | 103 | dnl * 104 | dnl * Check for sa_family_t. 105 | dnl * 106 | AC_DEFUN([X_TYPE_SA_FAMILY_T], 107 | [AC_CACHE_CHECK([for sa_family_t], ac_cv_type_sa_family_t, 108 | [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ 109 | #include 110 | #include ]], [[ 111 | sa_family_t sa_family; 112 | ]])],[ac_cv_type_sa_family_t=yes],[ac_cv_type_sa_family_t=no])]) 113 | if test "$ac_cv_type_sa_family_t" != yes; then 114 | ac_cv_sa_family_size=unknown 115 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 116 | #include 117 | #include 118 | int main() { 119 | struct sockaddr addr; 120 | return (sizeof(addr.sa_family) == sizeof(long)) ? 0 : 1; 121 | } 122 | ]])],[ac_cv_sa_family_size=long],[],[]) 123 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 124 | #include 125 | #include 126 | int main() { 127 | struct sockaddr addr; 128 | return (sizeof(addr.sa_family) == sizeof(int)) ? 0 : 1; 129 | } 130 | ]])],[ac_cv_sa_family_size=int],[],[]) 131 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 132 | #include 133 | #include 134 | int main() { 135 | struct sockaddr addr; 136 | return (sizeof(addr.sa_family) == sizeof(short)) ? 0 : 1; 137 | } 138 | ]])],[ac_cv_sa_family_size=short],[],[]) 139 | AC_RUN_IFELSE([AC_LANG_SOURCE([[ 140 | #include 141 | #include 142 | int main() { 143 | struct sockaddr addr; 144 | return (sizeof(addr.sa_family) == sizeof(char)) ? 0 : 1; 145 | } 146 | ]])],[ac_cv_sa_family_size=char],[],[]) 147 | if test "$ac_cv_sa_family_size" = unknown; then 148 | AC_MSG_ERROR([Failed to get size of sa_family in struct sockaddr.]) 149 | fi 150 | AC_DEFINE_UNQUOTED(sa_family_t, unsigned $ac_cv_sa_family_size, 151 | [Define to `unsigned char', `unsigned short', `unsigned int' or 152 | `unsigned long' according with size of `sa_family' in `struct sockaddr', 153 | if or does not define `sa_family_t'.]) 154 | fi]) 155 | -------------------------------------------------------------------------------- /base64.c: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Copyright 1997 Massachusetts Institute of Technology 4 | * 5 | * Permission to use, copy, modify, and distribute this software and 6 | * its documentation for any purpose and without fee is hereby 7 | * granted, provided that both the above copyright notice and this 8 | * permission notice appear in all copies, that both the above 9 | * copyright notice and this permission notice appear in all 10 | * supporting documentation, and that the name of M.I.T. not be used 11 | * in advertising or publicity pertaining to distribution of the 12 | * software without specific, written prior permission. M.I.T. makes 13 | * no representations about the suitability of this software for any 14 | * purpose. It is provided "as is" without express or implied 15 | * warranty. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY M.I.T. ``AS IS''. M.I.T. DISCLAIMS 18 | * ALL EXPRESS OR IMPLIED WARRANTIES WITH REGARD TO THIS SOFTWARE, 19 | * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 20 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT 21 | * SHALL M.I.T. BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 24 | * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 27 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28 | * SUCH DAMAGE. 29 | */ 30 | 31 | #include 32 | #include 33 | 34 | /* 35 | * Base64 encoding 36 | */ 37 | char * base64(const char *src) 38 | { 39 | static const char base64[] = 40 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 41 | "abcdefghijklmnopqrstuvwxyz" 42 | "0123456789+/"; 43 | char *str, *dst; 44 | size_t l; 45 | int t, r; 46 | 47 | l = strlen(src); 48 | if ((str = malloc(((l + 2) / 3) * 4 + 1)) == NULL) 49 | return (NULL); 50 | dst = str; 51 | r = 0; 52 | 53 | while (l >= 3) { 54 | t = (src[0] << 16) | (src[1] << 8) | src[2]; 55 | dst[0] = base64[(t >> 18) & 0x3f]; 56 | dst[1] = base64[(t >> 12) & 0x3f]; 57 | dst[2] = base64[(t >> 6) & 0x3f]; 58 | dst[3] = base64[(t >> 0) & 0x3f]; 59 | src += 3; l -= 3; 60 | dst += 4; r += 4; 61 | } 62 | 63 | switch (l) { 64 | case 2: 65 | t = (src[0] << 16) | (src[1] << 8); 66 | dst[0] = base64[(t >> 18) & 0x3f]; 67 | dst[1] = base64[(t >> 12) & 0x3f]; 68 | dst[2] = base64[(t >> 6) & 0x3f]; 69 | dst[3] = '='; 70 | dst += 4; 71 | r += 4; 72 | break; 73 | case 1: 74 | t = src[0] << 16; 75 | dst[0] = base64[(t >> 18) & 0x3f]; 76 | dst[1] = base64[(t >> 12) & 0x3f]; 77 | dst[2] = dst[3] = '='; 78 | dst += 4; 79 | r += 4; 80 | break; 81 | case 0: 82 | break; 83 | } 84 | 85 | *dst = 0; 86 | return (str); 87 | } 88 | 89 | 90 | -------------------------------------------------------------------------------- /bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | # 3 | # cphipps - short script to start building from a maintainer-clean'ed tree 4 | # 5 | mkdir -p autotools 6 | aclocal -I autotools 7 | autoheader 8 | automake --add-missing 9 | autoconf 10 | -------------------------------------------------------------------------------- /check-zsyncmake: -------------------------------------------------------------------------------- 1 | #!/bin/sh -e 2 | 3 | ${top_builddir-.}/zsyncmake -u foo -f foo ${srcdir-.}/INSTALL 4 | 5 | # Note TAB required for Solaris cksum 6 | x=`sed -e '1s/0\.6/XXX/' foo.zsync | cksum | sed -e 's/[ ][0-9].*//'` 7 | [ $x = 1368366867 ] 8 | rm foo.zsync 9 | 10 | -------------------------------------------------------------------------------- /client.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 4 | * Modifications Copyright (C) 2009 James Montgomerie 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the Artistic License v2 (see the accompanying 8 | * file COPYING for the full license terms), or, at your option, any later 9 | * version of the same license. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * COPYING file for details. 15 | */ 16 | 17 | /* zsync client library header */ 18 | 19 | #include 20 | #include 21 | 22 | struct zsync_http_routines { 23 | // Takes a URL, referrer (updated on a redirect), optional filename to save to. 24 | // Return a handle to the file, opened and positioned at the beginning. 25 | // Returned referrer will be freed by the caller. 26 | // This pointer ('http_get' in the zsync_http_routines structure) may be 27 | // NULL if the zsync control file specified in the zsync_client call is 28 | // already local. 29 | FILE*(*http_get)(const char *orig_url, char **track_referrer, const char *tfname); 30 | 31 | // Prepare to fetch some ranges from a URL. 32 | // Returns a status blob referred to by the calls below.. 33 | void*(*range_fetch_start)(const char *url, const char* referrer); 34 | 35 | // Add ranges to this request. 36 | // First argument is the status blob, from range_fetch_start. 37 | // Second argument is an array of offsets. 38 | // Third argument in number of ranges (pairs of offsets) in the offsets list. 39 | void(*range_fetch_addranges)(void *rf, off_t* ranges, int nranges); 40 | 41 | // Called repeatedly to get the data for a set of range fetches. 42 | // First argument is the status blob from range_fetch_start. 43 | // Second argument will be set to the offset the received data starts at. 44 | // Third argument is a buffer to receive data in. 45 | // Fourth argument is the data buffer length. 46 | // Return the total bytes read, 0 for EOF, -1 for error (like 'read'). 47 | int(*get_range_block)(void *rf, off_t *offset, unsigned char *data, size_t dlen); 48 | 49 | // Returns the total bytes retreived in this request. 50 | // Takes a status blob. 51 | off_t(*range_fetch_bytes_down)(const void *rf); 52 | 53 | // Called after a set of range fetches is complete. 54 | // Takes a status blob (which should become invalid after this call). 55 | void(*range_fetch_end)(void *rf); 56 | }; 57 | 58 | struct zsync_progress_routines { 59 | // Takes a URL, returns a status blob used when further tracking progress 60 | // for this URL. 61 | void*(*start_progress)(const char *url); 62 | 63 | // Takes a status blob returned by start_progress, a percentage and the 64 | // total bytes retreived so far. 65 | void(*do_progress)(void* p, float pcnt, long long newdl); 66 | 67 | // Takes a status blob, and a done parameter: 0 for error, 1 for 68 | // okay-but-incomplete, 2 for completed 69 | void(*end_progress)(void* p, int done); 70 | }; 71 | 72 | #define zs_ok 0 73 | #define zs_read_control_file_err 1 74 | #define zs_download_local_err 2 75 | #define zs_download_receive_err 3 76 | #define zs_move_received_file_err 4 77 | #define zs_backup_old_file_err 5 78 | typedef int zs_return; 79 | 80 | /* progress may be NULL if quiet is true */ 81 | zs_return zsync_client(const char *control_file_location, 82 | const char *keep_control_file_path, 83 | const char *output_file_path, 84 | const char *referrer, 85 | char **seedfiles, 86 | const int nseedfiles, 87 | bool quiet, 88 | struct zsync_http_routines *http, 89 | struct zsync_progress_routines *progress); 90 | -------------------------------------------------------------------------------- /clientcommand.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * zsync - client side rsync over http 4 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 5 | * Modifications Copyright (C) 2009 James Montgomerie 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the Artistic License v2 (see the accompanying 9 | * file COPYING for the full license terms), or, at your option, any later 10 | * version of the same license. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * COPYING file for details. 16 | */ 17 | 18 | /* zsync command-line client program */ 19 | 20 | #include "client.h" 21 | 22 | #include "zsglobal.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | 31 | #include "progress.h" 32 | #include "http.h" 33 | 34 | /* A ptrlist is a very simple structure for storing lists of pointers. This is 35 | * the only function in its API. The structure (not actually a struct) consists 36 | * of a (pointer to a) void*[] and an int giving the number of entries. 37 | * 38 | * ptrlist = append_ptrlist(&entries, ptrlist, new_entry) 39 | * Like realloc(2), this returns the new location of the ptrlist array; the 40 | * number of entries is passed by reference and updated in place. The new entry 41 | * is appended to the list. 42 | */ 43 | static void **append_ptrlist(int *n, void **p, void *a) { 44 | if (!a) 45 | return p; 46 | p = realloc(p, (*n + 1) * sizeof *p); 47 | if (!p) { 48 | fprintf(stderr, "out of memory\n"); 49 | exit(1); 50 | } 51 | p[*n] = a; 52 | (*n)++; 53 | return p; 54 | } 55 | 56 | /**************************************************************************** 57 | * 58 | * Main program */ 59 | int main(int argc, char **argv) { 60 | char **seedfiles = NULL; 61 | int nseedfiles = 0; 62 | char *filename = NULL; 63 | char *zfname = NULL; 64 | char *referrer = NULL; 65 | int no_progress = 0; 66 | 67 | { /* Option parsing */ 68 | int opt; 69 | 70 | while ((opt = getopt(argc, argv, "A:k:o:i:Vsqu:")) != -1) { 71 | switch (opt) { 72 | case 'A': /* Authentication options for remote server */ 73 | { /* Scan string as hostname=username:password */ 74 | char *p = strdup(optarg); 75 | char *q = strchr(p, '='); 76 | char *r = q ? strchr(q, ':') : NULL; 77 | 78 | if (!q || !r) { 79 | fprintf(stderr, 80 | "-A takes hostname=username:password\n"); 81 | return 1; 82 | } 83 | else { 84 | *q++ = *r++ = 0; 85 | add_auth(p, q, r); 86 | } 87 | } 88 | break; 89 | case 'k': 90 | free(zfname); 91 | zfname = strdup(optarg); 92 | break; 93 | case 'o': 94 | free(filename); 95 | filename = strdup(optarg); 96 | break; 97 | case 'i': 98 | seedfiles = (char **)append_ptrlist(&nseedfiles, (void **)seedfiles, optarg); 99 | break; 100 | case 'V': 101 | printf(PACKAGE " v" VERSION " (compiled " __DATE__ " " __TIME__ 102 | ")\n" "By Colin Phipps \n" 103 | "Published under the Artistic License v2, see the COPYING file for details.\n"); 104 | return 0; 105 | case 's': 106 | case 'q': 107 | no_progress = 1; 108 | break; 109 | case 'u': 110 | free(referrer); 111 | referrer = strdup(optarg); 112 | break; 113 | } 114 | } 115 | } 116 | 117 | /* Last and only non-option parameter must be the path/URL of the .zsync */ 118 | if (optind == argc) { 119 | fprintf(stderr, 120 | "No .zsync file specified.\nUsage: zsync http://example.com/some/filename.zsync\n"); 121 | return 3; 122 | } 123 | else if (optind < argc - 1) { 124 | fprintf(stderr, 125 | "Usage: zsync http://example.com/some/filename.zsync\n"); 126 | return 3; 127 | } 128 | 129 | /* No progress display except on terminal */ 130 | if (!isatty(0)) 131 | no_progress = 1; 132 | 133 | { /* Get proxy setting from the environment */ 134 | char *pr = getenv("http_proxy"); 135 | 136 | if (pr != NULL) 137 | set_proxy_from_string(pr); 138 | } 139 | 140 | struct zsync_http_routines http_routines = 141 | { 142 | http_get, 143 | range_fetch_start, 144 | range_fetch_addranges, 145 | get_range_block, 146 | range_fetch_bytes_down, 147 | range_fetch_end 148 | }; 149 | 150 | struct zsync_progress_routines progress_routines = 151 | { 152 | start_progress, 153 | do_progress, 154 | end_progress 155 | }; 156 | 157 | no_http_progress = no_progress; 158 | 159 | return zsync_client(argv[optind], zfname, filename, referrer, seedfiles, nseedfiles, no_progress, &http_routines, &progress_routines); 160 | } 161 | -------------------------------------------------------------------------------- /config.h: -------------------------------------------------------------------------------- 1 | /* config.h. Generated from config.h.in by configure. */ 2 | /* config.h.in. Generated from configure.ac by autoheader. */ 3 | 4 | /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ 5 | #define HAVE_FSEEKO 1 6 | 7 | /* Define to 1 if you have the `getaddrinfo' function. */ 8 | #define HAVE_GETADDRINFO 1 9 | 10 | /* Define to 1 if you have the header file. */ 11 | #define HAVE_INTTYPES_H 1 12 | 13 | /* Define to 1 if you have the `socket' library (-lsocket). */ 14 | /* #undef HAVE_LIBSOCKET */ 15 | 16 | /* Define to 1 if you have the `memcpy' function. */ 17 | #define HAVE_MEMCPY 1 18 | 19 | /* Define to 1 if you have the header file. */ 20 | #define HAVE_MEMORY_H 1 21 | 22 | /* Define to 1 if you have the `mkstemp' function. */ 23 | #define HAVE_MKSTEMP 1 24 | 25 | /* Define to 1 if you have the `pread' function. */ 26 | #define HAVE_PREAD 1 27 | 28 | /* Define to 1 if you have the `pwrite' function. */ 29 | #define HAVE_PWRITE 1 30 | 31 | /* Define to 1 if you have the header file. */ 32 | #define HAVE_STDINT_H 1 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #define HAVE_STDLIB_H 1 36 | 37 | /* Define to 1 if you have the header file. */ 38 | #define HAVE_STRINGS_H 1 39 | 40 | /* Define to 1 if you have the header file. */ 41 | #define HAVE_STRING_H 1 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #define HAVE_SYS_STAT_H 1 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #define HAVE_SYS_TYPES_H 1 48 | 49 | /* Define to 1 if you have the header file. */ 50 | #define HAVE_UNISTD_H 1 51 | 52 | /* Define to 1 if `h_errno' is declared by */ 53 | #define H_ERRNO_DECLARED 1 54 | 55 | /* Name of package */ 56 | #define PACKAGE "zsync" 57 | 58 | /* Define to the address where bug reports for this package should be sent. */ 59 | #define PACKAGE_BUGREPORT "http://zsync.moria.org.uk/" 60 | 61 | /* Define to the full name of this package. */ 62 | #define PACKAGE_NAME "zsync" 63 | 64 | /* Define to the full name and version of this package. */ 65 | #define PACKAGE_STRING "zsync 0.6" 66 | 67 | /* Define to the one symbol short name of this package. */ 68 | #define PACKAGE_TARNAME "zsync" 69 | 70 | /* Define to the version of this package. */ 71 | #define PACKAGE_VERSION "0.6" 72 | 73 | /* The size of `off_t', as computed by sizeof. */ 74 | #define SIZEOF_OFF_T 8 75 | 76 | /* The size of `size_t', as computed by sizeof. */ 77 | #define SIZEOF_SIZE_T 4 78 | 79 | /* Define to 1 if you have the ANSI C header files. */ 80 | #define STDC_HEADERS 1 81 | 82 | /* Version number of package */ 83 | #define VERSION "0.6" 84 | 85 | /* Define if using the dmalloc debugging malloc package */ 86 | /* #undef WITH_DMALLOC */ 87 | 88 | /* Enable BSD extensions if present */ 89 | #define _BSD_SOURCE 1 90 | 91 | /* Number of bits in a file offset, on hosts where this is settable. */ 92 | /* #undef _FILE_OFFSET_BITS */ 93 | 94 | /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ 95 | /* #undef _LARGEFILE_SOURCE */ 96 | 97 | /* Define for large files, on AIX-style hosts. */ 98 | /* #undef _LARGE_FILES */ 99 | 100 | /* Enable POSIX extensions if present */ 101 | #define _XOPEN_SOURCE 600 102 | 103 | /* Define to empty if `const' does not conform to ANSI C. */ 104 | /* #undef const */ 105 | 106 | /* Define to `unsigned char', `unsigned short', `unsigned int' or `unsigned 107 | long' according with size of `sin_port' in `struct sockaddr_in', if 108 | , or does not define 109 | `in_port_t'. */ 110 | /* #undef in_port_t */ 111 | 112 | /* Define to `unsigned int' if does not define. */ 113 | /* #undef size_t */ 114 | 115 | /* Define to `int' if or does not define. */ 116 | /* #undef socklen_t */ 117 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ 4 | #undef HAVE_FSEEKO 5 | 6 | /* Define to 1 if you have the `getaddrinfo' function. */ 7 | #undef HAVE_GETADDRINFO 8 | 9 | /* Define to 1 if you have the header file. */ 10 | #undef HAVE_INTTYPES_H 11 | 12 | /* Define to 1 if you have the `socket' library (-lsocket). */ 13 | #undef HAVE_LIBSOCKET 14 | 15 | /* Define to 1 if you have the `memcpy' function. */ 16 | #undef HAVE_MEMCPY 17 | 18 | /* Define to 1 if you have the header file. */ 19 | #undef HAVE_MEMORY_H 20 | 21 | /* Define to 1 if you have the `mkstemp' function. */ 22 | #undef HAVE_MKSTEMP 23 | 24 | /* Define to 1 if you have the `pread' function. */ 25 | #undef HAVE_PREAD 26 | 27 | /* Define to 1 if you have the `pwrite' function. */ 28 | #undef HAVE_PWRITE 29 | 30 | /* Define to 1 if you have the header file. */ 31 | #undef HAVE_STDINT_H 32 | 33 | /* Define to 1 if you have the header file. */ 34 | #undef HAVE_STDLIB_H 35 | 36 | /* Define to 1 if you have the header file. */ 37 | #undef HAVE_STRINGS_H 38 | 39 | /* Define to 1 if you have the header file. */ 40 | #undef HAVE_STRING_H 41 | 42 | /* Define to 1 if you have the header file. */ 43 | #undef HAVE_SYS_STAT_H 44 | 45 | /* Define to 1 if you have the header file. */ 46 | #undef HAVE_SYS_TYPES_H 47 | 48 | /* Define to 1 if you have the header file. */ 49 | #undef HAVE_UNISTD_H 50 | 51 | /* Define to 1 if `h_errno' is declared by */ 52 | #undef H_ERRNO_DECLARED 53 | 54 | /* Name of package */ 55 | #undef PACKAGE 56 | 57 | /* Define to the address where bug reports for this package should be sent. */ 58 | #undef PACKAGE_BUGREPORT 59 | 60 | /* Define to the full name of this package. */ 61 | #undef PACKAGE_NAME 62 | 63 | /* Define to the full name and version of this package. */ 64 | #undef PACKAGE_STRING 65 | 66 | /* Define to the one symbol short name of this package. */ 67 | #undef PACKAGE_TARNAME 68 | 69 | /* Define to the version of this package. */ 70 | #undef PACKAGE_VERSION 71 | 72 | /* The size of `off_t', as computed by sizeof. */ 73 | #undef SIZEOF_OFF_T 74 | 75 | /* The size of `size_t', as computed by sizeof. */ 76 | #undef SIZEOF_SIZE_T 77 | 78 | /* Define to 1 if you have the ANSI C header files. */ 79 | #undef STDC_HEADERS 80 | 81 | /* Version number of package */ 82 | #undef VERSION 83 | 84 | /* Define if using the dmalloc debugging malloc package */ 85 | #undef WITH_DMALLOC 86 | 87 | /* Enable BSD extensions if present */ 88 | #undef _BSD_SOURCE 89 | 90 | /* Number of bits in a file offset, on hosts where this is settable. */ 91 | #undef _FILE_OFFSET_BITS 92 | 93 | /* Define to 1 to make fseeko visible on some hosts (e.g. glibc 2.2). */ 94 | #undef _LARGEFILE_SOURCE 95 | 96 | /* Define for large files, on AIX-style hosts. */ 97 | #undef _LARGE_FILES 98 | 99 | /* Enable POSIX extensions if present */ 100 | #undef _XOPEN_SOURCE 101 | 102 | /* Define to empty if `const' does not conform to ANSI C. */ 103 | #undef const 104 | 105 | /* Define to `unsigned char', `unsigned short', `unsigned int' or `unsigned 106 | long' according with size of `sin_port' in `struct sockaddr_in', if 107 | , or does not define 108 | `in_port_t'. */ 109 | #undef in_port_t 110 | 111 | /* Define to `unsigned int' if does not define. */ 112 | #undef size_t 113 | 114 | /* Define to `int' if or does not define. */ 115 | #undef socklen_t 116 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # Process this file with autoconf to produce a configure script. 2 | 3 | AC_INIT([zsync],[0.6],[http://zsync.moria.org.uk/]) 4 | 5 | AC_CONFIG_SRCDIR([client.c]) 6 | AC_CONFIG_AUX_DIR([autotools]) 7 | AC_CONFIG_MACRO_DIR([autotools]) 8 | 9 | AC_CANONICAL_HOST 10 | 11 | AM_INIT_AUTOMAKE([dist-bzip2 no-dist-gzip foreign check-news -Woverride -Wobsolete -Wportability -Wsyntax -Wunsupported]) 12 | AM_MAINTAINER_MODE 13 | 14 | dnl --- Check for programs 15 | AC_PROG_CC 16 | AC_PROG_LN_S 17 | AC_PROG_RANLIB 18 | 19 | AC_ARG_ENABLE([profile], 20 | AS_HELP_STRING([--enable-profile],[Turns on profiling]), 21 | [ ZS_CFLAGS="${ZS_CFLAGS} -pg" ]) 22 | 23 | dnl --- Header files, typedefs, structures, libraries 24 | AC_C_CONST 25 | AC_HEADER_STDC 26 | # string.h, memory.h, stdlib.h both included in the default header checks 27 | # but we do need to give at least one .h to test, or Solaris sh errors 28 | AC_CHECK_HEADERS([string.h]) 29 | AC_TYPE_SIZE_T 30 | AC_CHECK_FUNCS(memcpy pwrite pread mkstemp) 31 | 32 | X_TYPE_SOCKLEN_T 33 | X_TYPE_IN_PORT_T 34 | X_DECL_H_ERRNO 35 | 36 | dnl Solaris needs -lsocket - and we need this for the getaddrinfo test 37 | AC_CHECK_LIB(socket,socket) 38 | 39 | AC_REPLACE_FUNCS(getaddrinfo) 40 | 41 | dnl - Large file support if available 42 | AC_SYS_LARGEFILE 43 | AC_FUNC_FSEEKO 44 | AC_CHECK_SIZEOF(size_t) 45 | AC_CHECK_SIZEOF(off_t) 46 | 47 | AM_WITH_DMALLOC 48 | 49 | case $host_os in 50 | mingw32) 51 | host_os_mingw32=yes 52 | LIBS="${LIBS} -lwsock32" 53 | ;; 54 | *) 55 | AC_DEFINE([_XOPEN_SOURCE], 600, [Enable POSIX extensions if present]) 56 | AC_DEFINE([_BSD_SOURCE],1, [Enable BSD extensions if present]) 57 | ;; 58 | esac 59 | AM_CONDITIONAL([MINGW32], test "x$host_os_mingw32" = "xyes") 60 | 61 | X_C_COMPILE_FLAGS($ZS_CFLAGS -g -Wall -Wwrite-strings -Winline -Wextra -Winline -Wmissing-noreturn -Wredundant-decls -Wnested-externs -Wundef -Wbad-function-cast -Wcast-align -Wvolatile-register-var -ffast-math) 62 | 63 | dnl --- output 64 | AC_SUBST(ac_aux_dir) 65 | AC_CONFIG_HEADERS([config.h]) 66 | AC_CONFIG_FILES([Makefile librcksum/Makefile zlib/Makefile libzsync/Makefile doc/Makefile]) 67 | AC_OUTPUT 68 | 69 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | manpages=zsync.1 zsyncmake.1 2 | man_MANS=$(manpages) 3 | EXTRA_DIST=$(manpages) 4 | -------------------------------------------------------------------------------- /doc/zsync.1: -------------------------------------------------------------------------------- 1 | .TH "zsync" "1" "0.6" "Colin Phipps" "File Transfer" 2 | .SH "NAME" 3 | .LP 4 | zsync \- Partial/differential file download client over HTTP 5 | .SH "SYNTAX" 6 | .LP 7 | zsync [ \-u \fIurl\fR ] [ \-i \fIinputfile\fP ] [ \-o \fIoutputfile\fP ] [ { \-s | \-q } ] [ \-k \fIfile\fR.zsync ] [ -A \fIhostname\fP=\fIusername\fR:\fIpassword\fR ] { \fIfilename\fP | \fIurl\fR } 8 | .LP 9 | zsync \-V 10 | .SH "DESCRIPTION" 11 | .LP 12 | Downloads a file over HTTP. zsync uses a control file to determine whether any blocks in the file are already known to the downloader, and only downloads the new blocks. 13 | .LP 14 | Either a filename or a URL can be given on the command line \- this is the path of the \fBcontrol\fR file for the download, which normally has the name of the actual file to downlaod with .zsync appended. (To create this .zsync file you have to have a copy of the target file, so this file should be generated by the person providing the download). 15 | .LP 16 | zsync downloads to your current directory. It looks for any file in the directory of the same name as the file to download. If it finds one, it assumes that this is an earlier or incomplete version of the new file to download, and scans this file for any blocks that it can use to build the target file. (It also looks for a file of the same name with .part appended, so it will automatically find previously interrupted zsync downloads and reuse the data already downloaded. If you know that the local file to use as input has a different name, you must use \fB\-i\fR) 17 | .LP 18 | zsync retrieves the rest of the target file over HTTP. Once the download is finished, the old version (if the new file wants the same name) is moved aside (a .zs\-old extension is appended). The modification time of the file is set to be the same as the remote source file (if specified in the .zsync). 19 | .SH "OPTIONS" 20 | .LP 21 | .TP 22 | \fB\-A\fR \fIhostname\fP=\fIusername\fR:\fIpassword\fR 23 | Specifies a username and password to be used with the given hostname. \fB-A\fR 24 | can be used multiple times (with different hostnames), in cases where e.g. the 25 | .zsync file is on a different server from the download, or there are multiple 26 | download servers (there could be different auth details for different servers - 27 | and zsync never assumes that your password should be sent to a server other 28 | than the one named - otherwise redirects would be dangerous!). 29 | .TP 30 | \fB\-i\fR \fIinputfile\fP 31 | Specifies (extra) input files. \fIinputfile\fP is scanned to identify blocks in common with the target file and zsync uses any blocks found. Can be used multiple times. 32 | .TP 33 | \fB\-k\fR \fIfile\fP.zsync 34 | Indicates that zsync should save the zsync file that it downloads, with the given filename. If that file already exists, then zsync will make a conditional request to the web server, such that it will only download it again if the server's copy is newer. zsync will append .part to the filename for storing it while it is downloading, and will only overwrite the main file once the download is done - and if the download is interrupted, it will resume using the data in the .part file. 35 | .TP 36 | \fB\-o\fR \fIoutputfile\fP 37 | Override the default output file name. 38 | .TP 39 | \fB\-q\fR 40 | Suppress the progress bar, download rate and ETA display. 41 | .TP 42 | \fB\-s\fR 43 | Deprecated synonym for -q. 44 | .TP 45 | \fB\-u\fR \fIurl\fP 46 | This specifies the referring URL. If you have a .zsync file locally (if you 47 | downloaded it separately, with wget, say) and the .zsync file contains a 48 | relative URL, you need to specify where you got the .zsync file from so that 49 | zsync knows which server and path to use for the rest of the download (this is 50 | analogous to adding a to a downloaded web page to make the 51 | links work). 52 | .TP 53 | \fB\-V\fR 54 | Prints the version of zsync. 55 | .SH "FILES" 56 | 57 | .SH "ENVIRONMENT VARIABLES" 58 | .LP 59 | .TP 60 | \fBhttp_proxy\fP 61 | Should be the [http://]hostname:port for your web proxy, if one is required to access the target web server(s). 62 | .SH "EXAMPLES" 63 | .LP 64 | zsync \-i /var/lib/apt/lists/ftp.uk.debian.org_debian_dists_sarge_main_binary\-i386_Packages http://zsync.moria.org.uk/s/sarge/Packages.zsync 65 | 66 | .SH "AUTHORS" 67 | .LP 68 | Colin Phipps 69 | .SH "SEE ALSO" 70 | .LP 71 | zsyncmake(1) 72 | -------------------------------------------------------------------------------- /doc/zsyncmake.1: -------------------------------------------------------------------------------- 1 | .TH "zsyncmake" "1" "0.6" "Colin Phipps" "File Transfer" 2 | .SH "NAME" 3 | .LP 4 | zsyncmake \- Build control file for zsync(1) 5 | .SH "SYNTAX" 6 | .LP 7 | zsyncmake [ { \-z | \-Z } ] [ \-e ] [ \-C ] [ \-u \fIurl\fR ] [ \-U \fIurl\fR ] [ \-b \fIblocksize\fR ] [ \-o \fIoutfile\fR ] [ \-f \fItargetfilename\fR ] [ \-v ] \fIfilename\fP 8 | .LP 9 | zsync \-V 10 | .SH "DESCRIPTION" 11 | .LP 12 | Constructs a metafile for the zsync client program to use to perform partial file downloads. \fIfilename\fR is the file that users wish to downloads; zsyncmake constructs the appropriate metafile and writes \fIfilename\fR.zsync in the current directory. 13 | .LP 14 | zsync will need at least one URL from which to download the file content. If the .zsync will be in the same directory as the file to download, you can accept the default \- zsync includes a relative URL in the control file. If not, use the \fB\-u\fR option to specify the URL. You should also specify a URL for the uncompressed content with \-U if available, as zsync can make use of this for more efficient downloads sometimes. (You can edit the .zsync file and add these afterwards \- it has a simple key: value format in the header \- but I suggest you only do this once you are familiar with the tool.) 15 | .LP 16 | Note that zsyncmake itself does not (currently) verify the URLs or download any data, you must provide the file data locally and check the URLs yourself. 17 | .SH "OPTIONS" 18 | .LP 19 | .TP 20 | \fB\-b\fR \fIblocksize\fR 21 | Specify the blocksize to the underlying rsync algorithm. A smaller blocksize may be more efficient for files where there are likely to be lots of small, scattered changes between downloads; a larger blocksize is more efficient for files with fewer or less scattered changes. This blocksize must be a power of two. If not specified, zsyncmake chooses one which it thinks is best for this file (currently either 2048 or 4096 depending on file size) - so normally tyou should not need to override the default. 22 | .TP 23 | \fB\-C\fR 24 | Tells zsyncmake not to generate any instructions in the .zsync telling the client to compress the data it receives. This is implied by -z, but this option is here in case you compress a file yourself only for the transfer, but want the client to end up with the uncompressed file (e.g. you are transferring an ISO, which is held compressed on the server, but which the client cannot use unless it is uncompressed). Without -C, zsyncmake will produce directions for the client to compress the file it receives where appropriate; -C is here so you can stop it telling the client to do that. 25 | .TP 26 | \fB\-e\fR 27 | Tells zsyncmake that the client must be able to receive the exact file that was supplied. Without this option, zsyncmake only gives a weaker guarantee - that the client will receive the data it contains (e.g. it might transfer the uncompressed version of a .gz to the client). Note that this still doesn't guarantee that the client will get it - the client could ignore the directives in the zsync file, or might be incapable of exactly reproducing the compression used. But with -e you know that zsyncmake has made it possible to get the exact data - it will exit with an error if it cannot. 28 | .TP 29 | \fB\-f\fR \fIfilename\fR 30 | Set the filename to include in the output file (this is what the file will be called when a user finished downloading it). 31 | .TP 32 | \fB\-o\fR \fIoutputfile\fR 33 | Override the default output file name. 34 | .TP 35 | \fB\-u\fR \fIurl\fR 36 | Specifies the URL from which users can download the content of the supplied file. Users need the control file in order to find out what parts of the file they already have, and they need the URLs to retrieve the parts of the file that they don't already have. You can specify multiple URLs by specifying \-u multiple times. If not specified, zsync assumes that the file and the .zsync will reside in the same public directory, and includes a single relative URL. 37 | .TP 38 | \fB\-U\fR \fIurl\fR 39 | Specifies a URL corresponding to the decompressed content of the file (only applicable if it is a gzip file). zsync can sometimes download more efficiently from the uncompressed data than from the compressed data \- it will take advantage of this if available. If no URLs are specifies, zsync looks for a file without the .gz extension and assumes that this will be in the same public dir as the .zsync, and includes a relative URL to it. 40 | .TP 41 | \fB\-v\fR 42 | Enable verbose messages. 43 | .TP 44 | \fB\-V\fR 45 | Prints the version of zsync. 46 | .TP 47 | \fB\-z\fR 48 | Compress the file to transfer. Note that this overwrites any file called \fIfilename\fP.gz without warning (if you don't give a filename, e.g. because you are reading from stdin, then zsync will use the name supplied with -f, or as a last fallback, zsync-target.gz). 49 | .TP 50 | zsync can work with compressed data, and, in most cases where the data is not already compressed, it is more efficient to compress it first. While you can just compress the file to transfer with gzip, if you use this option then zsyncmake will compress the file for you, producing a .gz file which is optimised for zsync. This can be 30% more efficient at download time than compressing with gzip --best - but the compressed file will not be as small at that produced by gzip. 51 | .TP 52 | \fB\-Z\fR 53 | zsyncmake automatically looks inside gzip compressed files and exports the underlying, uncompressed data to the zsyncmake file. In testing this has proved to provide greater download efficiency. \-Z overrides the default behaviour and treats gzip files as just binary data. Use this if it is essential that the user receives the compressed data (for instance because a cryptographic signature is available only for the compressed data). zsync is typically no use if you specify \-Z, unless the gzip file was compressed with the special \-\-rsync option to make it friendly to differential transfers. 54 | .SH "EXAMPLES" 55 | .LP 56 | zsyncmake \-C \-u http://ftp.uk.debian.org/debian/dists/sarge/main/binary\-i386/Packages.gz Packages.gz 57 | .LP 58 | Note use of -C to save the client compressing the file on receipt; the Debian package system uses the file uncompressed. 59 | .LP 60 | zsyncmake \-z my-subversion-dump 61 | .LP 62 | In this case there is a large, compressible file to transfer. This creates a gzipped version of the file (optimised for zsync), and a .zsync file. A URL is automatically added assuming that the two files will be served from the same directory on the web server. 63 | .LP 64 | zsyncmake \-e \-u http://www.mirrorservice.org/sites/ftp.freebsd.org/pub/FreeBSD/ports/distfiles/zsync-0.2.2.tar.gz zsync-0.2.2.tar.gz 65 | .LP 66 | This creates a zsync referring to the named source tarball, which the client 67 | should download from the given URL. This example is for downloading a source 68 | tarball for a FreeBSD port, hence \-e is specified so the client will be able 69 | to match its md5sum. 70 | 71 | .SH "AUTHORS" 72 | .LP 73 | Colin Phipps 74 | .SH "SEE ALSO" 75 | .LP 76 | zsync(1) 77 | -------------------------------------------------------------------------------- /format_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | #include 17 | #include "config.h" 18 | 19 | #ifdef PRIu32 20 | # define SIZE_T_PF "%zd" 21 | #else 22 | # define SIZE_T_PF "%u" 23 | #endif 24 | 25 | #if SIZEOF_OFF_T == 8 26 | # ifdef PRIu64 27 | # define OFF_T_PF "%" PRIu64 28 | # else 29 | # define OFF_T_PF "%llu" 30 | # endif 31 | #else 32 | # ifdef PRIu32 33 | # define OFF_T_PF "%" PRIu32 34 | # else 35 | # define OFF_T_PF "%lu" 36 | # endif 37 | #endif 38 | 39 | -------------------------------------------------------------------------------- /getaddrinfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 02 Motoyuki Kasahara 3 | * 4 | * Redistribution and use in source and binary forms, with or without 5 | * modification, are permitted provided that the following conditions 6 | * are met: 7 | * 1. Redistributions of source code must retain the above copyright 8 | * notice, this list of conditions and the following disclaimer. 9 | * 2. Redistributions in binary form must reproduce the above copyright 10 | * notice, this list of conditions and the following disclaimer in the 11 | * documentation and/or other materials provided with the distribution. 12 | * 3. Neither the name of the project nor the names of its contributors 13 | * may be used to endorse or promote products derived from this software 14 | * without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND 17 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19 | * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE 20 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26 | * SUCH DAMAGE. 27 | */ 28 | 29 | #ifndef GETADDRINFO_H 30 | #define GETADDRINFO_H 31 | 32 | #include 33 | #include 34 | #include 35 | 36 | /********************************************************************/ 37 | /* 38 | * Undefine all the macros. 39 | * might defines some of them. 40 | */ 41 | #ifdef EAI_ADDRFAMILY 42 | #undef EAI_ADDRFAMILY 43 | #endif 44 | #ifdef EAI_AGAIN 45 | #undef EAI_AGAIN 46 | #endif 47 | #ifdef EAI_BADFLAGS 48 | #undef EAI_BADFLAGS 49 | #endif 50 | #ifdef EAI_FAIL 51 | #undef EAI_FAIL 52 | #endif 53 | #ifdef EAI_FAMILY 54 | #undef EAI_FAMILY 55 | #endif 56 | #ifdef EAI_MEMORY 57 | #undef EAI_MEMORY 58 | #endif 59 | #ifdef EAI_NONAME 60 | #undef EAI_NONAME 61 | #endif 62 | #ifdef EAI_OVERFLOW 63 | #undef EAI_OVERFLOW 64 | #endif 65 | #ifdef EAI_SERVICE 66 | #undef EAI_SERVICE 67 | #endif 68 | #ifdef EAI_SOCKTYPE 69 | #undef EAI_SOCKTYPE 70 | #endif 71 | #ifdef EAI_SYSTEM 72 | #undef EAI_SYSTEM 73 | #endif 74 | 75 | #ifdef AI_PASSIVE 76 | #undef AI_PASSIVE 77 | #endif 78 | #ifdef AI_CANONNAME 79 | #undef AI_CANONNAME 80 | #endif 81 | #ifdef AI_NUMERICHOST 82 | #undef AI_NUMERICHOST 83 | #endif 84 | #ifdef AI_NUMERICSERV 85 | #undef AI_NUMERICSERV 86 | #endif 87 | #ifdef AI_V4MAPPED 88 | #undef AI_V4MAPPED 89 | #endif 90 | #ifdef AI_ALL 91 | #undef AI_ALL 92 | #endif 93 | #ifdef AI_ADDRCONFIG 94 | #undef AI_ADDRCONFIG 95 | #endif 96 | #ifdef AI_DEFAULT 97 | #undef AI_DEFAULT 98 | #endif 99 | 100 | #ifdef NI_NOFQDN 101 | #undef NI_NOFQDN 102 | #endif 103 | #ifdef NI_NUMERICHOST 104 | #undef NI_NUMERICHOST 105 | #endif 106 | #ifdef NI_NAMEREQD 107 | #undef NI_NAMEREQD 108 | #endif 109 | #ifdef NI_NUMERICSERV 110 | #undef NI_NUMERICSERV 111 | #endif 112 | #ifdef NI_NUMERICSCOPE 113 | #undef NI_NUMERICSCOPE 114 | #endif 115 | 116 | #ifdef NI_DGRAM 117 | #undef NI_DGRAM 118 | #endif 119 | #ifdef NI_MAXHOST 120 | #undef NI_MAXHOST 121 | #endif 122 | #ifdef NI_MAXSERV 123 | #undef NI_MAXSERV 124 | #endif 125 | 126 | /* 127 | * Fake struct and function names. 128 | * might declares all or some of them. 129 | */ 130 | #if defined(HAVE_GETADDRINFO) || defined(HAVE_GETNAMEINFO) 131 | #define addrinfo my_addrinfo 132 | #define gai_strerror my_gai_strerror 133 | #define freeaddrinfo my_freeaddrinfo 134 | #define getaddrinfo my_getaddrinfo 135 | #define getnameinfo my_getnameinfo 136 | #endif 137 | 138 | /********************************************************************/ 139 | /* 140 | * Error codes. 141 | */ 142 | #define EAI_ADDRFAMILY 1 143 | #define EAI_AGAIN 2 144 | #define EAI_BADFLAGS 3 145 | #define EAI_FAIL 4 146 | #define EAI_FAMILY 5 147 | #define EAI_MEMORY 6 148 | #define EAI_NONAME 7 149 | #define EAI_OVERFLOW 8 150 | #define EAI_SERVICE 9 151 | #define EAI_SOCKTYPE 10 152 | #define EAI_SYSTEM 11 153 | 154 | /* 155 | * Flags for getaddrinfo(). 156 | */ 157 | #define AI_ADDRCONFIG 0x0001 158 | #define AI_ALL 0x0002 159 | #define AI_CANONNAME 0x0004 160 | #define AI_NUMERICHOST 0x0008 161 | #define AI_NUMERICSERV 0x0010 162 | #define AI_PASSIVE 0x0020 163 | #define AI_V4MAPPED 0x0040 164 | #define AI_DEFAULT (AI_V4MAPPED | AI_ADDRCONFIG) 165 | 166 | /* 167 | * Flags for getnameinfo(). 168 | */ 169 | #define NI_DGRAM 0x0001 170 | #define NI_NAMEREQD 0x0002 171 | #define NI_NOFQDN 0x0004 172 | #define NI_NUMERICHOST 0x0008 173 | #define NI_NUMERICSCOPE 0x0010 174 | #define NI_NUMERICSERV 0x0020 175 | 176 | /* 177 | * Maximum length of FQDN and servie name for getnameinfo(). 178 | */ 179 | #define NI_MAXHOST 1025 180 | #define NI_MAXSERV 32 181 | 182 | /* 183 | * Address families and Protocol families. 184 | */ 185 | #ifndef AF_UNSPEC 186 | #define AF_UNSPEC AF_INET 187 | #endif 188 | #ifndef PF_UNSPEC 189 | #define PF_UNSPEC PF_INET 190 | #endif 191 | 192 | /* 193 | * struct addrinfo. 194 | */ 195 | struct addrinfo { 196 | int ai_flags; 197 | int ai_family; 198 | int ai_socktype; 199 | int ai_protocol; 200 | socklen_t ai_addrlen; 201 | char *ai_canonname; 202 | struct sockaddr *ai_addr; 203 | struct addrinfo *ai_next; 204 | }; 205 | 206 | /* 207 | * Functions. 208 | */ 209 | #ifdef __STDC__ 210 | const char *gai_strerror(int); 211 | void freeaddrinfo(struct addrinfo *); 212 | int getaddrinfo(const char *, const char *, const struct addrinfo *, 213 | struct addrinfo **); 214 | int getnameinfo(const struct sockaddr *, socklen_t, char *, 215 | socklen_t, char *, socklen_t, int); 216 | #else 217 | const char *gai_strerror(); 218 | void freeaddrinfo(); 219 | int getaddrinfo(); 220 | int getnameinfo(); 221 | #endif 222 | 223 | #endif /* not GETADDRINFO_H */ 224 | -------------------------------------------------------------------------------- /http.h: -------------------------------------------------------------------------------- 1 | /* 2 | * http.h - simple HTTP client for zsync 3 | * 4 | * Copyright (C) 2004,2005,2009 Colin Phipps 5 | * Modifications Copyright (C) 2009 James Montgomerie 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the Artistic License v2 (see the accompanying 9 | * file COPYING for the full license terms), or, at your option, any later 10 | * version of the same license. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * COPYING file for details. 16 | */ 17 | 18 | extern int no_http_progress; 19 | 20 | int set_proxy_from_string(const char* s); 21 | 22 | FILE* http_get(const char* orig_url, char** track_referrer, const char* tfname); 23 | 24 | void* range_fetch_start(const char* orig_url, const char *referrer); 25 | void range_fetch_addranges(void* rf, off_t* ranges, int nranges); 26 | int get_range_block(void* rf, off_t* offset, unsigned char* data, size_t dlen); 27 | off_t range_fetch_bytes_down(const void *rf); 28 | void range_fetch_end(void* rf); 29 | 30 | void add_auth(char* host, char* user, char* pass); 31 | 32 | /* base64.c */ 33 | char* base64(const char*); 34 | 35 | -------------------------------------------------------------------------------- /librcksum/.deps/hash.Po: -------------------------------------------------------------------------------- 1 | hash.o hash.o: hash.c ../zsglobal.h ../config.h /usr/include/stdlib.h \ 2 | /usr/include/available.h /usr/include/_types.h \ 3 | /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ 4 | /usr/include/machine/_types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/wait.h /usr/include/sys/signal.h \ 6 | /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h \ 7 | /usr/include/i386/signal.h /usr/include/sys/_structs.h \ 8 | /usr/include/machine/_structs.h /usr/include/i386/_structs.h \ 9 | /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ 10 | /usr/include/string.h /usr/include/sys/types.h \ 11 | /usr/include/machine/types.h /usr/include/i386/types.h \ 12 | /usr/include/machine/endian.h /usr/include/i386/endian.h rcksum.h \ 13 | /usr/include/stdio.h internal.h 14 | 15 | ../zsglobal.h: 16 | 17 | ../config.h: 18 | 19 | /usr/include/stdlib.h: 20 | 21 | /usr/include/available.h: 22 | 23 | /usr/include/_types.h: 24 | 25 | /usr/include/sys/_types.h: 26 | 27 | /usr/include/sys/cdefs.h: 28 | 29 | /usr/include/machine/_types.h: 30 | 31 | /usr/include/i386/_types.h: 32 | 33 | /usr/include/sys/wait.h: 34 | 35 | /usr/include/sys/signal.h: 36 | 37 | /usr/include/sys/appleapiopts.h: 38 | 39 | /usr/include/machine/signal.h: 40 | 41 | /usr/include/i386/signal.h: 42 | 43 | /usr/include/sys/_structs.h: 44 | 45 | /usr/include/machine/_structs.h: 46 | 47 | /usr/include/i386/_structs.h: 48 | 49 | /usr/include/mach/i386/_structs.h: 50 | 51 | /usr/include/sys/resource.h: 52 | 53 | /usr/include/string.h: 54 | 55 | /usr/include/sys/types.h: 56 | 57 | /usr/include/machine/types.h: 58 | 59 | /usr/include/i386/types.h: 60 | 61 | /usr/include/machine/endian.h: 62 | 63 | /usr/include/i386/endian.h: 64 | 65 | rcksum.h: 66 | 67 | /usr/include/stdio.h: 68 | 69 | internal.h: 70 | -------------------------------------------------------------------------------- /librcksum/.deps/md4.Po: -------------------------------------------------------------------------------- 1 | md4.o md4.o: md4.c /usr/include/sys/types.h \ 2 | /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h \ 3 | /usr/include/machine/types.h /usr/include/i386/types.h \ 4 | /usr/include/i386/_types.h /usr/include/sys/_types.h \ 5 | /usr/include/machine/_types.h /usr/include/machine/endian.h \ 6 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 7 | /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/include/string.h /usr/include/_types.h md4.h ../zsglobal.h \ 10 | ../config.h /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ 11 | /usr/include/inttypes.h 12 | 13 | /usr/include/sys/types.h: 14 | 15 | /usr/include/sys/appleapiopts.h: 16 | 17 | /usr/include/sys/cdefs.h: 18 | 19 | /usr/include/machine/types.h: 20 | 21 | /usr/include/i386/types.h: 22 | 23 | /usr/include/i386/_types.h: 24 | 25 | /usr/include/sys/_types.h: 26 | 27 | /usr/include/machine/_types.h: 28 | 29 | /usr/include/machine/endian.h: 30 | 31 | /usr/include/i386/endian.h: 32 | 33 | /usr/include/sys/_endian.h: 34 | 35 | /usr/include/libkern/_OSByteOrder.h: 36 | 37 | /usr/include/libkern/i386/_OSByteOrder.h: 38 | 39 | /usr/include/sys/_structs.h: 40 | 41 | /usr/include/string.h: 42 | 43 | /usr/include/_types.h: 44 | 45 | md4.h: 46 | 47 | ../zsglobal.h: 48 | 49 | ../config.h: 50 | 51 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 52 | 53 | /usr/include/inttypes.h: 54 | -------------------------------------------------------------------------------- /librcksum/.deps/range.Po: -------------------------------------------------------------------------------- 1 | range.o range.o: range.c ../zsglobal.h ../config.h /usr/include/stdlib.h \ 2 | /usr/include/available.h /usr/include/_types.h \ 3 | /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ 4 | /usr/include/machine/_types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/wait.h /usr/include/sys/signal.h \ 6 | /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h \ 7 | /usr/include/i386/signal.h /usr/include/sys/_structs.h \ 8 | /usr/include/machine/_structs.h /usr/include/i386/_structs.h \ 9 | /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ 10 | /usr/include/string.h /usr/include/sys/types.h \ 11 | /usr/include/machine/types.h /usr/include/i386/types.h \ 12 | /usr/include/machine/endian.h /usr/include/i386/endian.h rcksum.h \ 13 | /usr/include/stdio.h internal.h 14 | 15 | ../zsglobal.h: 16 | 17 | ../config.h: 18 | 19 | /usr/include/stdlib.h: 20 | 21 | /usr/include/available.h: 22 | 23 | /usr/include/_types.h: 24 | 25 | /usr/include/sys/_types.h: 26 | 27 | /usr/include/sys/cdefs.h: 28 | 29 | /usr/include/machine/_types.h: 30 | 31 | /usr/include/i386/_types.h: 32 | 33 | /usr/include/sys/wait.h: 34 | 35 | /usr/include/sys/signal.h: 36 | 37 | /usr/include/sys/appleapiopts.h: 38 | 39 | /usr/include/machine/signal.h: 40 | 41 | /usr/include/i386/signal.h: 42 | 43 | /usr/include/sys/_structs.h: 44 | 45 | /usr/include/machine/_structs.h: 46 | 47 | /usr/include/i386/_structs.h: 48 | 49 | /usr/include/mach/i386/_structs.h: 50 | 51 | /usr/include/sys/resource.h: 52 | 53 | /usr/include/string.h: 54 | 55 | /usr/include/sys/types.h: 56 | 57 | /usr/include/machine/types.h: 58 | 59 | /usr/include/i386/types.h: 60 | 61 | /usr/include/machine/endian.h: 62 | 63 | /usr/include/i386/endian.h: 64 | 65 | rcksum.h: 66 | 67 | /usr/include/stdio.h: 68 | 69 | internal.h: 70 | -------------------------------------------------------------------------------- /librcksum/.deps/rsum.Po: -------------------------------------------------------------------------------- 1 | rsum.o rsum.o: rsum.c ../zsglobal.h ../config.h /usr/include/stdio.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h /usr/include/string.h /usr/include/errno.h \ 11 | /usr/include/sys/errno.h /usr/include/unistd.h \ 12 | /usr/include/sys/unistd.h md4.h \ 13 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ 14 | /usr/include/inttypes.h rcksum.h internal.h 15 | 16 | ../zsglobal.h: 17 | 18 | ../config.h: 19 | 20 | /usr/include/stdio.h: 21 | 22 | /usr/include/_types.h: 23 | 24 | /usr/include/sys/_types.h: 25 | 26 | /usr/include/sys/cdefs.h: 27 | 28 | /usr/include/machine/_types.h: 29 | 30 | /usr/include/i386/_types.h: 31 | 32 | /usr/include/stdlib.h: 33 | 34 | /usr/include/available.h: 35 | 36 | /usr/include/sys/wait.h: 37 | 38 | /usr/include/sys/signal.h: 39 | 40 | /usr/include/sys/appleapiopts.h: 41 | 42 | /usr/include/machine/signal.h: 43 | 44 | /usr/include/i386/signal.h: 45 | 46 | /usr/include/sys/_structs.h: 47 | 48 | /usr/include/machine/_structs.h: 49 | 50 | /usr/include/i386/_structs.h: 51 | 52 | /usr/include/mach/i386/_structs.h: 53 | 54 | /usr/include/sys/resource.h: 55 | 56 | /usr/include/string.h: 57 | 58 | /usr/include/errno.h: 59 | 60 | /usr/include/sys/errno.h: 61 | 62 | /usr/include/unistd.h: 63 | 64 | /usr/include/sys/unistd.h: 65 | 66 | md4.h: 67 | 68 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 69 | 70 | /usr/include/inttypes.h: 71 | 72 | rcksum.h: 73 | 74 | internal.h: 75 | -------------------------------------------------------------------------------- /librcksum/.deps/state.Po: -------------------------------------------------------------------------------- 1 | state.o state.o: state.c ../zsglobal.h ../config.h /usr/include/stdlib.h \ 2 | /usr/include/available.h /usr/include/_types.h \ 3 | /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ 4 | /usr/include/machine/_types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/wait.h /usr/include/sys/signal.h \ 6 | /usr/include/sys/appleapiopts.h /usr/include/machine/signal.h \ 7 | /usr/include/i386/signal.h /usr/include/sys/_structs.h \ 8 | /usr/include/machine/_structs.h /usr/include/i386/_structs.h \ 9 | /usr/include/mach/i386/_structs.h /usr/include/sys/resource.h \ 10 | /usr/include/string.h /usr/include/unistd.h /usr/include/sys/unistd.h \ 11 | rcksum.h /usr/include/stdio.h internal.h 12 | 13 | ../zsglobal.h: 14 | 15 | ../config.h: 16 | 17 | /usr/include/stdlib.h: 18 | 19 | /usr/include/available.h: 20 | 21 | /usr/include/_types.h: 22 | 23 | /usr/include/sys/_types.h: 24 | 25 | /usr/include/sys/cdefs.h: 26 | 27 | /usr/include/machine/_types.h: 28 | 29 | /usr/include/i386/_types.h: 30 | 31 | /usr/include/sys/wait.h: 32 | 33 | /usr/include/sys/signal.h: 34 | 35 | /usr/include/sys/appleapiopts.h: 36 | 37 | /usr/include/machine/signal.h: 38 | 39 | /usr/include/i386/signal.h: 40 | 41 | /usr/include/sys/_structs.h: 42 | 43 | /usr/include/machine/_structs.h: 44 | 45 | /usr/include/i386/_structs.h: 46 | 47 | /usr/include/mach/i386/_structs.h: 48 | 49 | /usr/include/sys/resource.h: 50 | 51 | /usr/include/string.h: 52 | 53 | /usr/include/unistd.h: 54 | 55 | /usr/include/sys/unistd.h: 56 | 57 | rcksum.h: 58 | 59 | /usr/include/stdio.h: 60 | 61 | internal.h: 62 | -------------------------------------------------------------------------------- /librcksum/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | 3 | noinst_LIBRARIES = librcksum.a 4 | 5 | librcksum_a_SOURCES = internal.h rcksum.h md4.h rsum.c hash.c state.c range.c md4.c 6 | -------------------------------------------------------------------------------- /librcksum/hash.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * rcksum/lib - library for using the rsync algorithm to determine 4 | * which parts of a file you have and which you need. 5 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the Artistic License v2 (see the accompanying 9 | * file COPYING for the full license terms), or, at your option, any later 10 | * version of the same license. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * COPYING file for details. 16 | */ 17 | 18 | /* Functions to manage the rsum and checksum values per block and set up the 19 | * hash tables of the rsum values. */ 20 | 21 | #include "zsglobal.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifdef WITH_DMALLOC 28 | # include 29 | #endif 30 | 31 | #include "rcksum.h" 32 | #include "internal.h" 33 | 34 | /* rcksum_add_target_block(self, blockid, rsum, checksum) 35 | * Sets the stored hash values for the given blockid to the given values. 36 | */ 37 | void rcksum_add_target_block(struct rcksum_state *z, zs_blockid b, 38 | struct rsum r, void *checksum) { 39 | if (b < z->blocks) { 40 | /* Get hash entry with checksums for this block */ 41 | struct hash_entry *e = &(z->blockhashes[b]); 42 | 43 | /* Enter checksums */ 44 | memcpy(e->checksum, checksum, z->checksum_bytes); 45 | e->r.a = r.a & z->rsum_a_mask; 46 | e->r.b = r.b; 47 | 48 | /* New checksums invalidate any existing checksum hash tables */ 49 | if (z->rsum_hash) { 50 | free(z->rsum_hash); 51 | z->rsum_hash = NULL; 52 | free(z->bithash); 53 | z->bithash = NULL; 54 | } 55 | } 56 | } 57 | 58 | /* build_hash(self) 59 | * Build hash tables to quickly lookup a block based on its rsum value. 60 | * Returns non-zero if successful. 61 | */ 62 | int build_hash(struct rcksum_state *z) { 63 | zs_blockid id; 64 | int i = 16; 65 | 66 | /* Try hash size of 2^i; step down the value of i until we find a good size 67 | */ 68 | while ((2 << (i - 1)) > z->blocks && i > 4) 69 | i--; 70 | 71 | /* Allocate hash based on rsum */ 72 | z->hashmask = (2 << i) - 1; 73 | z->rsum_hash = calloc(z->hashmask + 1, sizeof *(z->rsum_hash)); 74 | if (!z->rsum_hash) 75 | return 0; 76 | 77 | /* Allocate bit-table based on rsum */ 78 | z->bithashmask = (2 << (i + BITHASHBITS)) - 1; 79 | z->bithash = calloc(z->bithashmask + 1, 1); 80 | if (!z->bithash) { 81 | free(z->rsum_hash); 82 | z->rsum_hash = NULL; 83 | return 0; 84 | } 85 | 86 | /* Now fill in the hash tables */ 87 | for (id = 0; id < z->blocks; id++) { 88 | struct hash_entry *e = z->blockhashes + id; 89 | 90 | /* Prepend to linked list for this hash entry */ 91 | unsigned h = calc_rhash(z, e); 92 | e->next = z->rsum_hash[h & z->hashmask]; 93 | z->rsum_hash[h & z->hashmask] = e; 94 | 95 | /* And set relevant bit in the bithash to 1 */ 96 | z->bithash[(h & z->bithashmask) >> 3] |= 1 << (h & 7); 97 | } 98 | return 1; 99 | } 100 | -------------------------------------------------------------------------------- /librcksum/internal.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * rcksum/lib - library for using the rsync algorithm to determine 4 | * which parts of a file you have and which you need. 5 | * Copyright (C) 2004,2005,2009 Colin Phipps 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the Artistic License v2 (see the accompanying 9 | * file COPYING for the full license terms), or, at your option, any later 10 | * version of the same license. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * COPYING file for details. 16 | */ 17 | 18 | /* Internal data structures to the library. Not to be included by code outside librcksum. */ 19 | 20 | /* Two types of checksum - 21 | * rsum: rolling Adler-style checksum 22 | * checksum: hopefully-collision-resistant MD4 checksum of the block 23 | */ 24 | 25 | struct hash_entry { 26 | struct hash_entry *next; /* next entry with the same rsum */ 27 | struct rsum r; 28 | unsigned char checksum[CHECKSUM_SIZE]; 29 | }; 30 | 31 | /* An rcksum_state contains the set of checksums of the blocks of a target 32 | * file, and is used to apply the rsync algorithm to detect data in common with 33 | * a local file. It essentially contains as rsum and a checksum per block of 34 | * the target file, plus various hash tables to speed up lookups when looping 35 | * over data looking for matching blocks. */ 36 | 37 | struct rcksum_state { 38 | struct rsum r[2]; /* Current rsums */ 39 | 40 | zs_blockid blocks; /* Number of blocks in the target file */ 41 | size_t blocksize; /* And how many bytes per block */ 42 | int blockshift; /* log2(blocksize) */ 43 | unsigned short rsum_a_mask; /* The mask to apply to rsum values before looking up */ 44 | int checksum_bytes; /* How many bytes of the MD4 checksum are available */ 45 | int seq_matches; 46 | 47 | unsigned int context; /* precalculated blocksize * seq_matches */ 48 | 49 | /* These are used by the library. Note, not thread safe. */ 50 | const struct hash_entry *rover; 51 | const struct hash_entry *next_match; 52 | int skip; /* skip forward on next submit_source_data */ 53 | 54 | /* Hash table for rsync algorithm */ 55 | unsigned int hashmask; 56 | struct hash_entry *blockhashes; 57 | struct hash_entry **rsum_hash; 58 | 59 | /* And a 1-bit per rsum value table to allow fast negative lookups for hash 60 | * values that don't occur in the target file. */ 61 | unsigned int bithashmask; 62 | unsigned char *bithash; 63 | 64 | /* Current state and stats for data collected by algorithm */ 65 | int numranges; 66 | zs_blockid *ranges; 67 | int gotblocks; 68 | struct { 69 | int hashhit, weakhit, stronghit, checksummed; 70 | } stats; 71 | 72 | /* Temp file for output */ 73 | char *filename; 74 | int fd; 75 | }; 76 | 77 | #define BITHASHBITS 3 78 | 79 | /* rcksum_state methods */ 80 | 81 | /* From a hash entry, return the corresponding blockid */ 82 | static inline zs_blockid get_HE_blockid(const struct rcksum_state *z, 83 | const struct hash_entry *e) { 84 | return e - z->blockhashes; 85 | } 86 | 87 | void add_to_ranges(struct rcksum_state *z, zs_blockid n); 88 | int already_got_block(struct rcksum_state *z, zs_blockid n); 89 | 90 | struct hash_entry *calc_hash_entry(void *data, size_t len); 91 | 92 | /* Hash the checksum values for the given hash entry and return the hash value */ 93 | static inline unsigned calc_rhash(const struct rcksum_state *const z, 94 | const struct hash_entry *const e) { 95 | unsigned h = e[0].r.b; 96 | 97 | h ^= ((z->seq_matches > 1) ? e[1].r.b : e[0].r.a) << BITHASHBITS; 98 | 99 | return h; 100 | } 101 | 102 | int build_hash(struct rcksum_state *z); 103 | -------------------------------------------------------------------------------- /librcksum/md4.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: md4.h,v 1.15 2004/06/22 01:57:30 jfb Exp $ */ 2 | 3 | /* 4 | * This code implements the MD4 message-digest algorithm. 5 | * The algorithm is due to Ron Rivest. This code was 6 | * written by Colin Plumb in 1993, no copyright is claimed. 7 | * This code is in the public domain; do with it what you wish. 8 | * Todd C. Miller modified the MD5 code to do MD4 based on RFC 1186. 9 | * 10 | * Equivalent code is available from RSA Data Security, Inc. 11 | * This code has been tested against that, and is equivalent, 12 | * except that you don't need to include two pages of legalese 13 | * with every copy. 14 | */ 15 | 16 | #ifndef _MD4_H_ 17 | #define _MD4_H_ 18 | 19 | #include "zsglobal.h" 20 | 21 | #include 22 | 23 | #ifdef HAVE_INTTYPES_H 24 | #include 25 | #else 26 | #include 27 | #endif 28 | 29 | #define MD4_BLOCK_LENGTH 64 30 | #define MD4_DIGEST_LENGTH 16 31 | #define MD4_DIGEST_STRING_LENGTH (MD4_DIGEST_LENGTH * 2 + 1) 32 | 33 | typedef struct MD4Context { 34 | uint32_t state[4]; /* state */ 35 | uint64_t count; /* number of bits, mod 2^64 */ 36 | uint8_t buffer[MD4_BLOCK_LENGTH]; /* input buffer */ 37 | } MD4_CTX; 38 | 39 | void MD4Init(MD4_CTX *); 40 | void MD4Update(MD4_CTX *, const uint8_t *, size_t) 41 | ZS_DECL_BOUNDED(__string__,2,3); 42 | void MD4Pad(MD4_CTX *); 43 | void MD4Final(uint8_t [MD4_DIGEST_LENGTH], MD4_CTX *) 44 | ZS_DECL_BOUNDED(__minbytes__,1,MD4_DIGEST_LENGTH); 45 | void MD4Transform(uint32_t [4], const uint8_t [MD4_BLOCK_LENGTH]) 46 | ZS_DECL_BOUNDED(__minbytes__,1,4) 47 | ZS_DECL_BOUNDED(__minbytes__,2,MD4_BLOCK_LENGTH); 48 | char *MD4End(MD4_CTX *, char *) 49 | ZS_DECL_BOUNDED(__minbytes__,2,MD4_DIGEST_STRING_LENGTH); 50 | char *MD4File(const char *, char *) 51 | ZS_DECL_BOUNDED(__minbytes__,2,MD4_DIGEST_STRING_LENGTH); 52 | char *MD4FileChunk(const char *, char *, off_t, off_t) 53 | ZS_DECL_BOUNDED(__minbytes__,2,MD4_DIGEST_STRING_LENGTH); 54 | char *MD4Data(const uint8_t *, size_t, char *) 55 | ZS_DECL_BOUNDED(__string__,1,2) 56 | ZS_DECL_BOUNDED(__minbytes__,3,MD4_DIGEST_STRING_LENGTH); 57 | 58 | #endif /* _MD4_H_ */ 59 | -------------------------------------------------------------------------------- /librcksum/range.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * rcksum/lib - library for using the rsync algorithm to determine 4 | * which parts of a file you have and which you need. 5 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the Artistic License v2 (see the accompanying 9 | * file COPYING for the full license terms), or, at your option, any later 10 | * version of the same license. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * COPYING file for details. 16 | */ 17 | 18 | /* Manage storage of the set of ranges in the target file that we have so far 19 | * got data for. */ 20 | 21 | #include "zsglobal.h" 22 | 23 | #include 24 | #include 25 | #include 26 | 27 | #ifdef WITH_DMALLOC 28 | # include 29 | #endif 30 | 31 | #include "rcksum.h" 32 | #include "internal.h" 33 | 34 | /* r = range_before_block(self, x) 35 | * This determines which of the existing known ranges x falls in. 36 | * It returns -1 if it is inside an existing range (it doesn't tell you which 37 | * one; if you already have it, that usually is enough to know). 38 | * Or it returns 0 if x is before the 1st range; 39 | * 1 if it is between ranges 1 and 2 (array indexes 0 and 1) 40 | * ... 41 | * numranges if it is after the last range 42 | */ 43 | static int range_before_block(const struct rcksum_state* rs, zs_blockid x) { 44 | /* Lowest number and highest number block that it could be inside (0 based) */ 45 | register int min = 0, max = rs->numranges-1; 46 | 47 | /* By bisection */ 48 | for (; min<=max;) { 49 | /* Range number to compare against */ 50 | register int r = (max+min)/2; 51 | 52 | if (x > rs->ranges[2*r+1]) min = r+1; /* After range r */ 53 | else if (x < rs->ranges[2*r]) max = r-1;/* Before range r */ 54 | else return -1; /* In range r */ 55 | } 56 | 57 | /* If we reach here, we know min = max + 1 and we were below range max+1 58 | * and above range min-1. 59 | * So we're between range max and max + 1 60 | * So we return max + 1 (return value is 1 based) ( = min ) 61 | */ 62 | return min; 63 | } 64 | 65 | /* add_to_ranges(rs, blockid) 66 | * Mark the given blockid as known, updating the stored known ranges 67 | * appropriately */ 68 | void add_to_ranges(struct rcksum_state *rs, zs_blockid x) { 69 | int r = range_before_block(rs, x); 70 | 71 | if (r == -1) { 72 | /* Already have this block */ 73 | } 74 | else { 75 | rs->gotblocks++; 76 | 77 | /* If between two ranges and exactly filling the hole between them, 78 | * merge them */ 79 | if (r > 0 && r < rs->numranges 80 | && rs->ranges[2 * (r - 1) + 1] == x - 1 81 | && rs->ranges[2 * r] == x + 1) { 82 | 83 | // This block fills the gap between two areas that we have got completely. Merge the adjacent ranges 84 | rs->ranges[2 * (r - 1) + 1] = rs->ranges[2 * r + 1]; 85 | memmove(&rs->ranges[2 * r], &rs->ranges[2 * r + 2], 86 | (rs->numranges - r - 1) * sizeof(rs->ranges[0]) * 2); 87 | rs->numranges--; 88 | } 89 | 90 | /* If adjoining a range below, add to it */ 91 | else if (r > 0 && rs->numranges && rs->ranges[2 * (r - 1) + 1] == x - 1) { 92 | rs->ranges[2 * (r - 1) + 1] = x; 93 | } 94 | 95 | /* If adjoining a range above, add to it */ 96 | else if (r < rs->numranges && rs->ranges[2 * r] == x + 1) { 97 | rs->ranges[2 * r] = x; 98 | } 99 | 100 | else { /* New range for this block alone */ 101 | rs->ranges = 102 | realloc(rs->ranges, 103 | (rs->numranges + 1) * 2 * sizeof(rs->ranges[0])); 104 | memmove(&rs->ranges[2 * r + 2], &rs->ranges[2 * r], 105 | (rs->numranges - r) * 2 * sizeof(rs->ranges[0])); 106 | rs->ranges[2 * r] = rs->ranges[2 * r + 1] = x; 107 | rs->numranges++; 108 | } 109 | } 110 | #if 0 111 | { 112 | int i; 113 | for (i = 0; i < rs->numranges; i++) 114 | fprintf(stderr, "%d-%d,", rs->ranges[i * 2], rs->ranges[i * 2 + 1]); 115 | fprintf(stderr, " are the current ranges got (added %d, %d)\n\n", x, r); 116 | } 117 | #endif 118 | } 119 | 120 | /* already_got_block 121 | * Return true iff blockid x of the target file is already known */ 122 | int already_got_block(struct rcksum_state *rs, zs_blockid x) { 123 | return (range_before_block(rs, x) == -1); 124 | } 125 | 126 | /* rcksum_needed_block_ranges 127 | * Return the block ranges needed to complete the target file */ 128 | zs_blockid *rcksum_needed_block_ranges(const struct rcksum_state * rs, int *num, 129 | zs_blockid from, zs_blockid to) { 130 | int i, n; 131 | int alloc_n = 100; 132 | zs_blockid *r = malloc(2 * alloc_n * sizeof(zs_blockid)); 133 | 134 | if (!r) 135 | return NULL; 136 | 137 | if (to >= rs->blocks) 138 | to = rs->blocks; 139 | r[0] = from; 140 | r[1] = to; 141 | n = 1; 142 | /* Note r[2*n-1] is the last range in our prospective list */ 143 | 144 | for (i = 0; i < rs->numranges; i++) { 145 | if (rs->ranges[2 * i] > r[2 * n - 1]) 146 | continue; 147 | if (rs->ranges[2 * i + 1] < from) 148 | continue; 149 | 150 | /* Okay, they intersect */ 151 | if (n == 1 && rs->ranges[2 * i] <= from) { /* Overlaps the start of our window */ 152 | r[0] = rs->ranges[2 * i + 1] + 1; 153 | } 154 | else { 155 | /* If the last block that we still (which is the last window end -1, due 156 | * to half-openness) then this range just cuts the end of our window */ 157 | if (rs->ranges[2 * i + 1] >= r[2 * n - 1] - 1) { 158 | r[2 * n - 1] = rs->ranges[2 * i]; 159 | } 160 | else { 161 | /* In the middle of our range, split it */ 162 | r[2 * n] = rs->ranges[2 * i + 1] + 1; 163 | r[2 * n + 1] = r[2 * n - 1]; 164 | r[2 * n - 1] = rs->ranges[2 * i]; 165 | n++; 166 | if (n == alloc_n) { 167 | zs_blockid *r2; 168 | alloc_n += 100; 169 | r2 = realloc(r, 2 * alloc_n * sizeof *r); 170 | if (!r2) { 171 | free(r); 172 | return NULL; 173 | } 174 | r = r2; 175 | } 176 | } 177 | } 178 | } 179 | r = realloc(r, 2 * n * sizeof *r); 180 | if (n == 1 && r[0] >= r[1]) 181 | n = 0; 182 | 183 | *num = n; 184 | return r; 185 | } 186 | 187 | /* rcksum_blocks_todo 188 | * Return the number of blocks still needed to complete the target file */ 189 | int rcksum_blocks_todo(const struct rcksum_state *rs) { 190 | int i, n = rs->blocks; 191 | for (i = 0; i < rs->numranges; i++) { 192 | n -= 1 + rs->ranges[2 * i + 1] - rs->ranges[2 * i]; 193 | } 194 | return n; 195 | } 196 | -------------------------------------------------------------------------------- /librcksum/rcksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * rcksum/lib - library for using the rsync algorithm to determine 3 | * which parts of a file you have and which you need. 4 | * Copyright (C) 2004,2005,2009 Colin Phipps 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the Artistic License v2 (see the accompanying 8 | * file COPYING for the full license terms), or, at your option, any later 9 | * version of the same license. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * COPYING file for details. 15 | */ 16 | 17 | /* This is the library interface. Very changeable at this stage. */ 18 | 19 | #include 20 | 21 | struct rcksum_state; 22 | 23 | typedef int zs_blockid; 24 | 25 | struct rsum { 26 | unsigned short a; 27 | unsigned short b; 28 | } __attribute__((packed)); 29 | 30 | #define CHECKSUM_SIZE 16 31 | 32 | struct rcksum_state* rcksum_init(zs_blockid nblocks, size_t blocksize, int rsum_butes, int checksum_bytes, int require_consecutive_matches); 33 | void rcksum_end(struct rcksum_state* z); 34 | 35 | /* These transfer out the filename and handle of the file backing the data retrieved. 36 | * Once you have transferred out the file handle, you can no longer read and write data through librcksum - it has handed it over to you, and can use it no more itself. 37 | * If you transfer out the filename, you are responsible for renaming it to something useful. If you don't transfer out the filename, librcksum will unlink it at rcksum_end. 38 | */ 39 | char* rcksum_filename(struct rcksum_state* z); 40 | int rcksum_filehandle(struct rcksum_state* z); 41 | 42 | void rcksum_add_target_block(struct rcksum_state* z, zs_blockid b, struct rsum r, void* checksum); 43 | 44 | int rcksum_submit_blocks(struct rcksum_state* z, const unsigned char* data, zs_blockid bfrom, zs_blockid bto); 45 | int rcksum_submit_source_data(struct rcksum_state* z, unsigned char* data, size_t len, off_t offset); 46 | int rcksum_submit_source_file(struct rcksum_state* z, FILE* f, int progress); 47 | 48 | /* This reads back in data which is already known. */ 49 | int rcksum_read_known_data(struct rcksum_state* z, unsigned char* buf, off_t offset, size_t len); 50 | 51 | /* rcksum_needed_block_ranges tells you what blocks, within the given range, 52 | * are still unknown. It returns a list of block ranges in r[] 53 | * (at most max ranges, so spece for 2*max elements must be there) 54 | * these are half-open ranges, so r[0] <= x < r[1], r[2] <= x < r[3] etc are needed */ 55 | zs_blockid* rcksum_needed_block_ranges(const struct rcksum_state* z, int* num, zs_blockid from, zs_blockid to); 56 | int rcksum_blocks_todo(const struct rcksum_state*); 57 | 58 | /* For preparing rcksum control files - in both cases len is the block size. */ 59 | struct rsum __attribute__((pure)) rcksum_calc_rsum_block(const unsigned char* data, size_t len); 60 | void rcksum_calc_checksum(unsigned char *c, const unsigned char* data, size_t len); 61 | 62 | -------------------------------------------------------------------------------- /librcksum/state.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * rcksum/lib - library for using the rsync algorithm to determine 4 | * which parts of a file you have and which you need. 5 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 6 | * 7 | * This program is free software; you can redistribute it and/or modify 8 | * it under the terms of the Artistic License v2 (see the accompanying 9 | * file COPYING for the full license terms), or, at your option, any later 10 | * version of the same license. 11 | * 12 | * This program is distributed in the hope that it will be useful, 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | * COPYING file for details. 16 | */ 17 | 18 | /* Effectively the constructor and destructor for the rcksum object. 19 | * Also handles the file handles on the temporary store. 20 | */ 21 | 22 | #include "zsglobal.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #ifdef WITH_DMALLOC 29 | # include 30 | #endif 31 | 32 | #include "rcksum.h" 33 | #include "internal.h" 34 | 35 | /* rcksum_init(num_blocks, block_size, rsum_bytes, checksum_bytes, require_consecutive_matches) 36 | * Creates and returns an rcksum_state with the given properties 37 | */ 38 | struct rcksum_state *rcksum_init(zs_blockid nblocks, size_t blocksize, 39 | int rsum_bytes, int checksum_bytes, 40 | int require_consecutive_matches) { 41 | /* Allocate memory for the object */ 42 | struct rcksum_state *z = malloc(sizeof(struct rcksum_state)); 43 | if (z == NULL) return NULL; 44 | 45 | /* Enter supplied properties. */ 46 | z->blocksize = blocksize; 47 | z->blocks = nblocks; 48 | z->rsum_a_mask = rsum_bytes < 3 ? 0 : rsum_bytes == 3 ? 0xff : 0xffff; 49 | z->checksum_bytes = checksum_bytes; 50 | z->seq_matches = require_consecutive_matches; 51 | 52 | /* require_consecutive_matches is 1 if true; and if true we need 1 block of 53 | * context to do block matching */ 54 | z->context = blocksize * require_consecutive_matches; 55 | 56 | /* Temporary file to hold the target file as we get blocks for it 57 | * Create this in the temporary directory pointed to by $TMPNAM 58 | * if there is one */ 59 | char *tmpdir = getenv("TMPDIR"); 60 | if(tmpdir) { 61 | size_t tmpdir_length = strlen(tmpdir); 62 | z->filename = malloc(tmpdir_length + 15); 63 | strcpy(z->filename, tmpdir); 64 | if(z->filename[tmpdir_length - 1] != '/') { 65 | z->filename[tmpdir_length] = '/'; 66 | ++tmpdir_length; 67 | } 68 | strcpy(z->filename + tmpdir_length, "rcksum-XXXXXX"); 69 | } else { 70 | z->filename = strdup("rcksum-XXXXXX"); 71 | } 72 | 73 | /* Initialise to 0 various state & stats */ 74 | z->gotblocks = 0; 75 | memset(&(z->stats), 0, sizeof(z->stats)); 76 | z->ranges = NULL; 77 | z->numranges = 0; 78 | 79 | /* Hashes for looking up checksums are generated when needed. 80 | * So initially store NULL so we know there's nothing there yet. 81 | */ 82 | z->rsum_hash = NULL; 83 | z->bithash = NULL; 84 | 85 | if (!(z->blocksize & (z->blocksize - 1)) && z->filename != NULL 86 | && z->blocks) { 87 | /* Create temporary file */ 88 | z->fd = mkstemp(z->filename); 89 | if (z->fd == -1) { 90 | perror("open"); 91 | } 92 | else { 93 | { /* Calculate bit-shift for blocksize */ 94 | int i; 95 | for (i = 0; i < 32; i++) 96 | if (z->blocksize == (1u << i)) { 97 | z->blockshift = i; 98 | break; 99 | } 100 | } 101 | 102 | z->blockhashes = 103 | malloc(sizeof(z->blockhashes[0]) * 104 | (z->blocks + z->seq_matches)); 105 | if (z->blockhashes != NULL) 106 | return z; 107 | 108 | /* All below is error handling */ 109 | } 110 | } 111 | free(z->filename); 112 | free(z); 113 | return NULL; 114 | } 115 | 116 | /* rcksum_filename(self) 117 | * Returns temporary filename to caller as malloced string. 118 | * Ownership of the file passes to the caller - the function returns NULL if 119 | * called again, and it is up to the caller to deal with the file. */ 120 | char *rcksum_filename(struct rcksum_state *rs) { 121 | char *p = rs->filename; 122 | rs->filename = NULL; 123 | return p; 124 | } 125 | 126 | /* rcksum_filehandle(self) 127 | * Returns the filehandle for the temporary file. 128 | * Ownership of the handle passes to the caller - the function returns -1 if 129 | * called again, and it is up to the caller to close it. */ 130 | int rcksum_filehandle(struct rcksum_state *rs) { 131 | int h = rs->fd; 132 | rs->fd = -1; 133 | return h; 134 | } 135 | 136 | /* rcksum_end - destructor */ 137 | void rcksum_end(struct rcksum_state *z) { 138 | /* Free temporary file resources */ 139 | if (z->fd != -1) 140 | close(z->fd); 141 | if (z->filename) { 142 | unlink(z->filename); 143 | free(z->filename); 144 | } 145 | 146 | /* Free other allocated memory */ 147 | free(z->rsum_hash); 148 | free(z->blockhashes); 149 | free(z->bithash); 150 | free(z->ranges); // Should be NULL already 151 | #ifdef DEBUG 152 | fprintf(stderr, "hashhit %d, weakhit %d, checksummed %d, stronghit %d\n", 153 | z->stats.hashhit, z->stats.weakhit, z->stats.checksummed, 154 | z->stats.stronghit); 155 | #endif 156 | free(z); 157 | } 158 | -------------------------------------------------------------------------------- /libzsync/.deps/sha1.Po: -------------------------------------------------------------------------------- 1 | sha1.o sha1.o: sha1.c ../zsglobal.h ../config.h /usr/include/sys/param.h \ 2 | /usr/include/sys/_types.h /usr/include/sys/cdefs.h \ 3 | /usr/include/machine/_types.h /usr/include/i386/_types.h \ 4 | /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ 5 | /usr/include/machine/types.h /usr/include/i386/types.h \ 6 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 7 | /usr/include/sys/syslimits.h /usr/include/machine/param.h \ 8 | /usr/include/i386/param.h /usr/include/i386/_param.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ 10 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ 11 | /usr/include/limits.h /usr/include/machine/limits.h \ 12 | /usr/include/i386/limits.h /usr/include/i386/_limits.h \ 13 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 14 | /usr/include/i386/signal.h /usr/include/sys/_structs.h \ 15 | /usr/include/machine/_structs.h /usr/include/i386/_structs.h \ 16 | /usr/include/mach/i386/_structs.h /usr/include/string.h \ 17 | /usr/include/_types.h sha1.h /usr/include/inttypes.h \ 18 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h 19 | 20 | ../zsglobal.h: 21 | 22 | ../config.h: 23 | 24 | /usr/include/sys/param.h: 25 | 26 | /usr/include/sys/_types.h: 27 | 28 | /usr/include/sys/cdefs.h: 29 | 30 | /usr/include/machine/_types.h: 31 | 32 | /usr/include/i386/_types.h: 33 | 34 | /usr/include/sys/types.h: 35 | 36 | /usr/include/sys/appleapiopts.h: 37 | 38 | /usr/include/machine/types.h: 39 | 40 | /usr/include/i386/types.h: 41 | 42 | /usr/include/machine/endian.h: 43 | 44 | /usr/include/i386/endian.h: 45 | 46 | /usr/include/sys/syslimits.h: 47 | 48 | /usr/include/machine/param.h: 49 | 50 | /usr/include/i386/param.h: 51 | 52 | /usr/include/i386/_param.h: 53 | 54 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: 55 | 56 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: 57 | 58 | /usr/include/limits.h: 59 | 60 | /usr/include/machine/limits.h: 61 | 62 | /usr/include/i386/limits.h: 63 | 64 | /usr/include/i386/_limits.h: 65 | 66 | /usr/include/sys/signal.h: 67 | 68 | /usr/include/machine/signal.h: 69 | 70 | /usr/include/i386/signal.h: 71 | 72 | /usr/include/sys/_structs.h: 73 | 74 | /usr/include/machine/_structs.h: 75 | 76 | /usr/include/i386/_structs.h: 77 | 78 | /usr/include/mach/i386/_structs.h: 79 | 80 | /usr/include/string.h: 81 | 82 | /usr/include/_types.h: 83 | 84 | sha1.h: 85 | 86 | /usr/include/inttypes.h: 87 | 88 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 89 | -------------------------------------------------------------------------------- /libzsync/.deps/sha1test.Po: -------------------------------------------------------------------------------- 1 | sha1test.o sha1test.o: sha1test.c ../zsglobal.h ../config.h \ 2 | /usr/include/string.h /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h /usr/include/sys/types.h \ 11 | /usr/include/machine/types.h /usr/include/i386/types.h \ 12 | /usr/include/machine/endian.h /usr/include/i386/endian.h sha1.h \ 13 | /usr/include/inttypes.h \ 14 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h 15 | 16 | ../zsglobal.h: 17 | 18 | ../config.h: 19 | 20 | /usr/include/string.h: 21 | 22 | /usr/include/_types.h: 23 | 24 | /usr/include/sys/_types.h: 25 | 26 | /usr/include/sys/cdefs.h: 27 | 28 | /usr/include/machine/_types.h: 29 | 30 | /usr/include/i386/_types.h: 31 | 32 | /usr/include/stdlib.h: 33 | 34 | /usr/include/available.h: 35 | 36 | /usr/include/sys/wait.h: 37 | 38 | /usr/include/sys/signal.h: 39 | 40 | /usr/include/sys/appleapiopts.h: 41 | 42 | /usr/include/machine/signal.h: 43 | 44 | /usr/include/i386/signal.h: 45 | 46 | /usr/include/sys/_structs.h: 47 | 48 | /usr/include/machine/_structs.h: 49 | 50 | /usr/include/i386/_structs.h: 51 | 52 | /usr/include/mach/i386/_structs.h: 53 | 54 | /usr/include/sys/resource.h: 55 | 56 | /usr/include/sys/types.h: 57 | 58 | /usr/include/machine/types.h: 59 | 60 | /usr/include/i386/types.h: 61 | 62 | /usr/include/machine/endian.h: 63 | 64 | /usr/include/i386/endian.h: 65 | 66 | sha1.h: 67 | 68 | /usr/include/inttypes.h: 69 | 70 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 71 | -------------------------------------------------------------------------------- /libzsync/.deps/zmap.Po: -------------------------------------------------------------------------------- 1 | zmap.o zmap.o: zmap.c ../zsglobal.h ../config.h /usr/include/stdio.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h /usr/include/string.h \ 11 | /usr/include/sys/types.h /usr/include/machine/types.h \ 12 | /usr/include/i386/types.h /usr/include/machine/endian.h \ 13 | /usr/include/i386/endian.h /usr/include/arpa/inet.h \ 14 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ 15 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 16 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/netinet/in.h \ 17 | /usr/include/sys/socket.h /usr/include/machine/_param.h \ 18 | /usr/include/i386/_param.h /usr/include/netinet6/in6.h \ 19 | /usr/include/inttypes.h zmap.h ../format_string.h ../config.h \ 20 | ../zlib/zlib.h ../zlib/zconf.h 21 | 22 | ../zsglobal.h: 23 | 24 | ../config.h: 25 | 26 | /usr/include/stdio.h: 27 | 28 | /usr/include/_types.h: 29 | 30 | /usr/include/sys/_types.h: 31 | 32 | /usr/include/sys/cdefs.h: 33 | 34 | /usr/include/machine/_types.h: 35 | 36 | /usr/include/i386/_types.h: 37 | 38 | /usr/include/stdlib.h: 39 | 40 | /usr/include/available.h: 41 | 42 | /usr/include/sys/wait.h: 43 | 44 | /usr/include/sys/signal.h: 45 | 46 | /usr/include/sys/appleapiopts.h: 47 | 48 | /usr/include/machine/signal.h: 49 | 50 | /usr/include/i386/signal.h: 51 | 52 | /usr/include/sys/_structs.h: 53 | 54 | /usr/include/machine/_structs.h: 55 | 56 | /usr/include/i386/_structs.h: 57 | 58 | /usr/include/mach/i386/_structs.h: 59 | 60 | /usr/include/sys/resource.h: 61 | 62 | /usr/include/string.h: 63 | 64 | /usr/include/sys/types.h: 65 | 66 | /usr/include/machine/types.h: 67 | 68 | /usr/include/i386/types.h: 69 | 70 | /usr/include/machine/endian.h: 71 | 72 | /usr/include/i386/endian.h: 73 | 74 | /usr/include/arpa/inet.h: 75 | 76 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 77 | 78 | /usr/include/sys/_endian.h: 79 | 80 | /usr/include/libkern/_OSByteOrder.h: 81 | 82 | /usr/include/libkern/i386/_OSByteOrder.h: 83 | 84 | /usr/include/netinet/in.h: 85 | 86 | /usr/include/sys/socket.h: 87 | 88 | /usr/include/machine/_param.h: 89 | 90 | /usr/include/i386/_param.h: 91 | 92 | /usr/include/netinet6/in6.h: 93 | 94 | /usr/include/inttypes.h: 95 | 96 | zmap.h: 97 | 98 | ../format_string.h: 99 | 100 | ../config.h: 101 | 102 | ../zlib/zlib.h: 103 | 104 | ../zlib/zconf.h: 105 | -------------------------------------------------------------------------------- /libzsync/.deps/zsync.Po: -------------------------------------------------------------------------------- 1 | zsync.o zsync.o: zsync.c ../zsglobal.h ../config.h /usr/include/stdio.h \ 2 | /usr/include/_types.h /usr/include/sys/_types.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/_types.h \ 4 | /usr/include/i386/_types.h /usr/include/stdlib.h \ 5 | /usr/include/available.h /usr/include/sys/wait.h \ 6 | /usr/include/sys/signal.h /usr/include/sys/appleapiopts.h \ 7 | /usr/include/machine/signal.h /usr/include/i386/signal.h \ 8 | /usr/include/sys/_structs.h /usr/include/machine/_structs.h \ 9 | /usr/include/i386/_structs.h /usr/include/mach/i386/_structs.h \ 10 | /usr/include/sys/resource.h /usr/include/sys/types.h \ 11 | /usr/include/machine/types.h /usr/include/i386/types.h \ 12 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 13 | /usr/include/unistd.h /usr/include/sys/unistd.h /usr/include/string.h \ 14 | /usr/include/ctype.h /usr/include/runetype.h /usr/include/time.h \ 15 | /usr/include/_structs.h /usr/include/arpa/inet.h \ 16 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h \ 17 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 18 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/netinet/in.h \ 19 | /usr/include/sys/socket.h /usr/include/machine/_param.h \ 20 | /usr/include/i386/_param.h /usr/include/netinet6/in6.h ../zlib/zlib.h \ 21 | ../zlib/zconf.h ../librcksum/rcksum.h zsync.h sha1.h \ 22 | /usr/include/inttypes.h zmap.h 23 | 24 | ../zsglobal.h: 25 | 26 | ../config.h: 27 | 28 | /usr/include/stdio.h: 29 | 30 | /usr/include/_types.h: 31 | 32 | /usr/include/sys/_types.h: 33 | 34 | /usr/include/sys/cdefs.h: 35 | 36 | /usr/include/machine/_types.h: 37 | 38 | /usr/include/i386/_types.h: 39 | 40 | /usr/include/stdlib.h: 41 | 42 | /usr/include/available.h: 43 | 44 | /usr/include/sys/wait.h: 45 | 46 | /usr/include/sys/signal.h: 47 | 48 | /usr/include/sys/appleapiopts.h: 49 | 50 | /usr/include/machine/signal.h: 51 | 52 | /usr/include/i386/signal.h: 53 | 54 | /usr/include/sys/_structs.h: 55 | 56 | /usr/include/machine/_structs.h: 57 | 58 | /usr/include/i386/_structs.h: 59 | 60 | /usr/include/mach/i386/_structs.h: 61 | 62 | /usr/include/sys/resource.h: 63 | 64 | /usr/include/sys/types.h: 65 | 66 | /usr/include/machine/types.h: 67 | 68 | /usr/include/i386/types.h: 69 | 70 | /usr/include/machine/endian.h: 71 | 72 | /usr/include/i386/endian.h: 73 | 74 | /usr/include/unistd.h: 75 | 76 | /usr/include/sys/unistd.h: 77 | 78 | /usr/include/string.h: 79 | 80 | /usr/include/ctype.h: 81 | 82 | /usr/include/runetype.h: 83 | 84 | /usr/include/time.h: 85 | 86 | /usr/include/_structs.h: 87 | 88 | /usr/include/arpa/inet.h: 89 | 90 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stdint.h: 91 | 92 | /usr/include/sys/_endian.h: 93 | 94 | /usr/include/libkern/_OSByteOrder.h: 95 | 96 | /usr/include/libkern/i386/_OSByteOrder.h: 97 | 98 | /usr/include/netinet/in.h: 99 | 100 | /usr/include/sys/socket.h: 101 | 102 | /usr/include/machine/_param.h: 103 | 104 | /usr/include/i386/_param.h: 105 | 106 | /usr/include/netinet6/in6.h: 107 | 108 | ../zlib/zlib.h: 109 | 110 | ../zlib/zconf.h: 111 | 112 | ../librcksum/rcksum.h: 113 | 114 | zsync.h: 115 | 116 | sha1.h: 117 | 118 | /usr/include/inttypes.h: 119 | 120 | zmap.h: 121 | -------------------------------------------------------------------------------- /libzsync/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LIBRARIES = libzsync.a 3 | 4 | libzsync_a_SOURCES = zmap.h zsync.h sha1.h zsync.c zmap.c sha1.c 5 | 6 | TESTS = sha1test 7 | noinst_PROGRAMS = sha1test 8 | sha1test_SOURCES = sha1.h sha1.c sha1test.c 9 | 10 | -------------------------------------------------------------------------------- /libzsync/sha1.c: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: sha1.c,v 1.19 2004/05/28 15:10:27 millert Exp $ */ 2 | 3 | /* 4 | * SHA-1 in C 5 | * By Steve Reid 6 | * 100% Public Domain 7 | * 8 | * Test Vectors (from FIPS PUB 180-1) 9 | * "abc" 10 | * A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D 11 | * "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" 12 | * 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 13 | * A million repetitions of "a" 14 | * 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F 15 | */ 16 | 17 | #include "zsglobal.h" 18 | 19 | #if defined(LIBC_SCCS) && !defined(lint) 20 | static const char rcsid[] = "$OpenBSD: sha1.c,v 1.19 2004/05/28 15:10:27 millert Exp $"; 21 | #endif /* LIBC_SCCS and not lint */ 22 | 23 | #include 24 | #include 25 | #include "sha1.h" 26 | 27 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits)))) 28 | 29 | /* Map Solaris endian stuff to something useful */ 30 | #if defined(_BIG_ENDIAN) && !defined(_BYTE_ORDER) 31 | #define LITTLE_ENDIAN 0 32 | #define BIG_ENDIAN 1 33 | #define BYTE_ORDER 1 34 | #endif 35 | 36 | /* 37 | * blk0() and blk() perform the initial expand. 38 | * I got the idea of expanding during the round function from SSLeay 39 | */ 40 | #if BYTE_ORDER == LITTLE_ENDIAN 41 | # define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \ 42 | |(rol(block->l[i],8)&0x00FF00FF)) 43 | #else 44 | # define blk0(i) block->l[i] 45 | #endif 46 | #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \ 47 | ^block->l[(i+2)&15]^block->l[i&15],1)) 48 | 49 | /* 50 | * (R0+R1), R2, R3, R4 are the different operations (rounds) used in SHA1 51 | */ 52 | #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30); 53 | #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30); 54 | #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30); 55 | #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30); 56 | #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30); 57 | 58 | /* 59 | * Hash a single 512-bit block. This is the core of the algorithm. 60 | */ 61 | void 62 | SHA1Transform(uint32_t state[5], const uint8_t buffer[SHA1_BLOCK_LENGTH]) 63 | { 64 | uint32_t a, b, c, d, e; 65 | uint8_t workspace[SHA1_BLOCK_LENGTH]; 66 | typedef union { 67 | uint8_t c[64]; 68 | uint32_t l[16]; 69 | } CHAR64LONG16; 70 | CHAR64LONG16 *block = (CHAR64LONG16 *)workspace; 71 | 72 | (void)memcpy(block, buffer, SHA1_BLOCK_LENGTH); 73 | 74 | /* Copy context->state[] to working vars */ 75 | a = state[0]; 76 | b = state[1]; 77 | c = state[2]; 78 | d = state[3]; 79 | e = state[4]; 80 | 81 | /* 4 rounds of 20 operations each. Loop unrolled. */ 82 | R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3); 83 | R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7); 84 | R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11); 85 | R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15); 86 | R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19); 87 | R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23); 88 | R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27); 89 | R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31); 90 | R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35); 91 | R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39); 92 | R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43); 93 | R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47); 94 | R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51); 95 | R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55); 96 | R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59); 97 | R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63); 98 | R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67); 99 | R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71); 100 | R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75); 101 | R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79); 102 | 103 | /* Add the working vars back into context.state[] */ 104 | state[0] += a; 105 | state[1] += b; 106 | state[2] += c; 107 | state[3] += d; 108 | state[4] += e; 109 | 110 | /* Wipe variables */ 111 | a = b = c = d = e = 0; 112 | } 113 | 114 | 115 | /* 116 | * SHA1Init - Initialize new context 117 | */ 118 | void 119 | SHA1Init(SHA1_CTX *context) 120 | { 121 | 122 | /* SHA1 initialization constants */ 123 | context->count = 0; 124 | context->state[0] = 0x67452301; 125 | context->state[1] = 0xEFCDAB89; 126 | context->state[2] = 0x98BADCFE; 127 | context->state[3] = 0x10325476; 128 | context->state[4] = 0xC3D2E1F0; 129 | } 130 | 131 | 132 | /* 133 | * Run your data through this. 134 | */ 135 | void 136 | SHA1Update(SHA1_CTX *context, const uint8_t *data, size_t len) 137 | { 138 | size_t i, j; 139 | 140 | j = (size_t)((context->count >> 3) & 63); 141 | context->count += (len << 3); 142 | if ((j + len) > 63) { 143 | (void)memcpy(&context->buffer[j], data, (i = 64-j)); 144 | SHA1Transform(context->state, context->buffer); 145 | for ( ; i + 63 < len; i += 64) 146 | SHA1Transform(context->state, (uint8_t *)&data[i]); 147 | j = 0; 148 | } else { 149 | i = 0; 150 | } 151 | (void)memcpy(&context->buffer[j], &data[i], len - i); 152 | } 153 | 154 | 155 | /* 156 | * Add padding and return the message digest. 157 | */ 158 | void 159 | SHA1Pad(SHA1_CTX *context) 160 | { 161 | uint8_t finalcount[8]; 162 | unsigned int i; 163 | 164 | for (i = 0; i < 8; i++) { 165 | finalcount[i] = (uint8_t)((context->count >> 166 | ((7 - (i & 7)) * 8)) & 255); /* Endian independent */ 167 | } 168 | SHA1Update(context, (uint8_t *)"\200", 1); 169 | while ((context->count & 504) != 448) 170 | SHA1Update(context, (uint8_t *)"\0", 1); 171 | SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */ 172 | } 173 | 174 | void 175 | SHA1Final(uint8_t digest[SHA1_DIGEST_LENGTH], SHA1_CTX *context) 176 | { 177 | unsigned int i; 178 | 179 | SHA1Pad(context); 180 | if (digest) { 181 | for (i = 0; i < SHA1_DIGEST_LENGTH; i++) { 182 | digest[i] = (uint8_t) 183 | ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255); 184 | } 185 | memset(context, 0, sizeof(*context)); 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /libzsync/sha1.h: -------------------------------------------------------------------------------- 1 | /* $OpenBSD: sha1.h,v 1.23 2004/06/22 01:57:30 jfb Exp $ */ 2 | 3 | /* 4 | * SHA-1 in C 5 | * By Steve Reid 6 | * 100% Public Domain 7 | */ 8 | 9 | #ifndef _SHA1_H 10 | #define _SHA1_H 11 | 12 | #include "config.h" 13 | 14 | #ifdef HAVE_INTTYPES_H 15 | #include 16 | #else 17 | #include 18 | #endif 19 | 20 | #define SHA1_BLOCK_LENGTH 64 21 | #define SHA1_DIGEST_LENGTH 20 22 | #define SHA1_DIGEST_STRING_LENGTH (SHA1_DIGEST_LENGTH * 2 + 1) 23 | 24 | typedef struct { 25 | uint32_t state[5]; 26 | uint64_t count; 27 | uint8_t buffer[SHA1_BLOCK_LENGTH]; 28 | } SHA1_CTX; 29 | 30 | void SHA1Init(SHA1_CTX *); 31 | void SHA1Pad(SHA1_CTX *); 32 | void SHA1Transform(uint32_t [5], const uint8_t [SHA1_BLOCK_LENGTH]) 33 | ZS_DECL_BOUNDED(__minbytes__,1,5) 34 | ZS_DECL_BOUNDED(__minbytes__,2,SHA1_BLOCK_LENGTH); 35 | void SHA1Update(SHA1_CTX *, const uint8_t *, size_t) 36 | ZS_DECL_BOUNDED(__string__,2,3); 37 | void SHA1Final(uint8_t [SHA1_DIGEST_LENGTH], SHA1_CTX *) 38 | ZS_DECL_BOUNDED(__minbytes__,1,SHA1_DIGEST_LENGTH); 39 | char *SHA1End(SHA1_CTX *, char *) 40 | ZS_DECL_BOUNDED(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH); 41 | char *SHA1File(const char *, char *) 42 | ZS_DECL_BOUNDED(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH); 43 | char *SHA1FileChunk(const char *, char *, off_t, off_t) 44 | ZS_DECL_BOUNDED(__minbytes__,2,SHA1_DIGEST_STRING_LENGTH); 45 | char *SHA1Data(const uint8_t *, size_t, char *) 46 | ZS_DECL_BOUNDED(__string__,1,2) 47 | ZS_DECL_BOUNDED(__minbytes__,3,SHA1_DIGEST_STRING_LENGTH); 48 | 49 | #define HTONDIGEST(x) do { \ 50 | x[0] = htonl(x[0]); \ 51 | x[1] = htonl(x[1]); \ 52 | x[2] = htonl(x[2]); \ 53 | x[3] = htonl(x[3]); \ 54 | x[4] = htonl(x[4]); } while (0) 55 | 56 | #define NTOHDIGEST(x) do { \ 57 | x[0] = ntohl(x[0]); \ 58 | x[1] = ntohl(x[1]); \ 59 | x[2] = ntohl(x[2]); \ 60 | x[3] = ntohl(x[3]); \ 61 | x[4] = ntohl(x[4]); } while (0) 62 | 63 | #endif /* _SHA1_H */ 64 | -------------------------------------------------------------------------------- /libzsync/sha1test.c: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2005 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | #include "zsglobal.h" 17 | 18 | #include 19 | #include 20 | #include 21 | #include "sha1.h" 22 | 23 | // From RFC3174 24 | const char correct_checksum[SHA1_DIGEST_LENGTH] = {0xA9, 0x99, 0x3E, 0x36, 0x47, 0x06, 0x81, 0x6A, 0xBA, 0x3E, 0x25, 0x71, 0x78, 0x50, 0xC2, 0x6C, 0x9C, 0xD0, 0xD8, 0x9D}; 25 | 26 | int main(void) 27 | { 28 | SHA1_CTX ctx; 29 | 30 | SHA1Init(&ctx); 31 | 32 | SHA1Update(&ctx,(uint8_t*)"a",1); 33 | SHA1Update(&ctx,(uint8_t*)"bc",2); 34 | { 35 | uint8_t digest[SHA1_DIGEST_LENGTH]; 36 | SHA1Final(digest,&ctx); 37 | exit(memcmp(digest,correct_checksum,SHA1_DIGEST_LENGTH)); 38 | } 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /libzsync/zmap.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | #include "zsglobal.h" 17 | 18 | struct gzblock { 19 | uint16_t inbitoffset; 20 | uint16_t outbyteoffset; 21 | } __attribute__((packed)); 22 | 23 | #define GZB_NOTBLOCKSTART 0x8000 24 | 25 | struct zmap; 26 | struct z_stream_s; 27 | 28 | struct zmap* zmap_make(const struct gzblock* zb, int n); 29 | void zmap_free(struct zmap*); 30 | 31 | off_t* zmap_to_compressed_ranges(const struct zmap* zm, off_t* byterange, int nrange, int* num); 32 | void configure_zstream_for_zdata(const struct zmap* zm, struct z_stream_s* zs, long zoffset, long long* poutoffset); 33 | 34 | /* gzip flag byte */ 35 | #define GZ_ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ 36 | #define GZ_HEAD_CRC 0x02 /* bit 1 set: header CRC present */ 37 | #define GZ_EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ 38 | #define GZ_ORIG_NAME 0x08 /* bit 3 set: original file name present */ 39 | #define GZ_COMMENT 0x10 /* bit 4 set: file comment present */ 40 | #define GZ_RESERVED 0xE0 /* bits 5..7: reserved */ 41 | 42 | static inline const char* skip_zhead(const char* p) 43 | { 44 | int flags = p[3]; 45 | 46 | p += 10; 47 | if (flags & GZ_ORIG_NAME) 48 | while (*p++ != 0) ; 49 | 50 | return p; 51 | } 52 | 53 | -------------------------------------------------------------------------------- /libzsync/zsync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2009 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | struct zsync_state; 17 | 18 | /* zsync_begin - load a zsync file and return data structure to use for the rest of the process. 19 | */ 20 | struct zsync_state* zsync_begin(FILE* cf); 21 | 22 | /* zsync_hint_decompress - if it returns non-zero, this suggests that 23 | * compressed seed files should be decompressed */ 24 | int zsync_hint_decompress(const struct zsync_state*); 25 | 26 | /* zsync_filename - return the suggested filename from the .zsync file */ 27 | char* zsync_filename(const struct zsync_state*); 28 | /* zsync_mtime - return the suggested mtime from the .zsync file */ 29 | time_t zsync_mtime(const struct zsync_state*); 30 | 31 | /* zsync_rename_file - renames the temporary file used by zsync to the given name. 32 | * You don't "own" the filename until you zsync_end, but you can use this to give zsync a more 33 | * appropriate intermediate filename (in case the user ctrl-c's). 34 | * This is purely a hint; zsync could ignore it. Returns 0 if successful. */ 35 | int zsync_rename_file(struct zsync_state* zs, const char* f); 36 | 37 | /* zsync_status - returns the current state: 38 | * 0 - no relevant local data found yet. 39 | * 1 - some data present 40 | * 2+ - all data downloaded (higher values may be added later to indicate completion 41 | * of checksumming and file handle states) 42 | */ 43 | 44 | int zsync_status(const struct zsync_state* zs); 45 | 46 | /* zsync_progress - returns bytes of the file known so far in *got, 47 | * and the total (roughly, the file length) in *total */ 48 | void zsync_progress(const struct zsync_state* zs, long long* got, long long* total); 49 | 50 | /* zsync_submit_source_file - submit local file data to zsync 51 | */ 52 | int zsync_submit_source_file(struct zsync_state* zs, FILE* f, int progress); 53 | 54 | /* zsync_get_url - returns a URL from which to get needed data. 55 | * Returns NULL on failure, or a array of pointers to URLs. 56 | * Returns the size of the array in *n, 57 | * and the url type (to pass to needed_byte_ranges & begin_receive) 58 | * (the URL pointers are still referenced by the library, and are valid only until zsync_end). 59 | */ 60 | 61 | const char * const * zsync_get_urls(struct zsync_state* zs, int* n, int* t); 62 | 63 | /* zsync_needed_byte_ranges - get the byte ranges needed from a URL. 64 | * Returns the number of ranges in *num, and a malloc'd array (to be freed 65 | * by the caller) of 2*(*num) off_t's which are the starts and ends 66 | * of byte ranges. 67 | */ 68 | 69 | off_t* zsync_needed_byte_ranges(struct zsync_state* zs, int* num, int type); 70 | 71 | /* zsync_complete - set file length and verify checksum if available 72 | * Returns -1 for failure, 1 for success, 0 for unable to verify (e.g. no checksum in the .zsync) */ 73 | int zsync_complete(struct zsync_state* zs); 74 | 75 | /* Clean up and free all resources. The pointer is freed by this call. 76 | * Returns a strdup()d pointer to the name of the file resulting from the process. */ 77 | char* zsync_end(struct zsync_state* zs); 78 | 79 | /* And functions for receiving data on the network */ 80 | struct zsync_receiver; 81 | 82 | /* Begin and end receiving from a particular URL. 83 | * Note that the zsync_receiver stores a reference to the zsync_state, 84 | * and libzsync does not do reference counting, so it is the caller's 85 | * responsibility not to do a zsync_end without doing a zsync_end_receive 86 | * first. 87 | * The url_type is as in the value returned by zsync_get_url. 88 | */ 89 | struct zsync_receiver* zsync_begin_receive(struct zsync_state*zs, int url_type); 90 | void zsync_end_receive(struct zsync_receiver* zr); 91 | 92 | /* Supply data buf of length len received corresponding to offset offset from the URL. 93 | * Returns 0 for success; if not, you should not submit more data. */ 94 | int zsync_receive_data(struct zsync_receiver* zr, const unsigned char* buf, off_t offset, size_t len); 95 | 96 | -------------------------------------------------------------------------------- /makegz.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * zsync - client side rsync over http 4 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the Artistic License v2 (see the accompanying 8 | * file COPYING for the full license terms), or, at your option, any later 9 | * version of the same license. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * COPYING file for details. 15 | */ 16 | 17 | #include "zsglobal.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #include "zlib/zlib.h" 24 | 25 | #include 26 | #include 27 | 28 | #ifdef WITH_DMALLOC 29 | # include 30 | #endif 31 | 32 | /* fputlong(filehandle, long) 33 | * Writes a 32bit int as raw bytes in little-endian to the given filehandle. 34 | * Returns 0 if successful; otherwise ferror(filehandle) to see the error */ 35 | static int fputlong(FILE * f, unsigned long x) { 36 | int n; 37 | for (n = 0; n < 4; n++) { 38 | if (fputc((int)(x & 0xff), f) == EOF) 39 | return -1; 40 | x >>= 8; 41 | } 42 | return 0; 43 | } 44 | 45 | /* time = get_mtime(filehandle) 46 | * Get the mtime of a file from an open filehandle; or 0 if unavailable */ 47 | time_t get_mtime(FILE * f) { 48 | struct stat s; 49 | 50 | if (fstat(fileno(f), &s) == 0) 51 | return s.st_mtime; 52 | else 53 | return 0; 54 | } 55 | 56 | /* filehandle = optimal_gzip(filehandle, out_filename_str, blocksize) 57 | * Constructs a compressed version of the data in the file referenced by the 58 | * supplied filehandle; this is saved in a file with the filename supplied as 59 | * the second parameter. The compressed version is optimised for the zsync 60 | * algorithm with the supplied blocksize. The function returns a handle to the 61 | * compressed file (opened for r+w but rewound to the start of the file, 62 | * ready for reading. 63 | */ 64 | 65 | /* Algorithm: simple really. We construct a gzip (have to write header with 66 | * mtime, footer with length and crc; we do a standard zlib compress on the 67 | * content _except_ that we supply one block (of the size that zsync will be 68 | * using) and a Z_PARTIAL_FLUSH at the end of each one, so zlib breaks the 69 | * compression runs at exactly the places zsync will start/stop retrieving data. 70 | */ 71 | FILE *optimal_gzip(FILE * ffin, const char *fout, size_t blocksize) { 72 | time_t mtime = get_mtime(ffin); 73 | 74 | /* Open output file (for writing, but also reading so we can return the 75 | * handle for reading by the caller. */ 76 | FILE *ffout = fopen(fout, "wb+"); 77 | if (!ffout) { 78 | perror("open"); 79 | return NULL; 80 | } 81 | 82 | /* Write gzip header */ 83 | if (fwrite("\x1f\x8b\x08\x00", 4, 1, ffout) != 1) { 84 | perror("write"); 85 | return NULL; 86 | } 87 | if (fputlong(ffout, mtime) == -1) { 88 | perror("write"); 89 | return NULL; 90 | } 91 | if (fwrite("\x00\x03", 2, 1, ffout) != 1) { 92 | perror("write"); 93 | return NULL; 94 | } 95 | 96 | { /* Now write compressed content */ 97 | z_stream zs; 98 | unsigned char *inbuf = malloc(blocksize); 99 | unsigned char *outbuf = malloc(blocksize + 500); 100 | int err, r; 101 | unsigned long crc = crc32(0L, Z_NULL, 0); 102 | 103 | /* Set up zlib object */ 104 | zs.zalloc = Z_NULL; 105 | zs.zfree = Z_NULL; 106 | zs.opaque = NULL; 107 | zs.total_in = 0; 108 | zs.total_out = 0; 109 | 110 | /* windowBits is passed < 0 to suppress zlib header */ 111 | err = deflateInit2(&zs, 9, 112 | Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY); 113 | 114 | /* Until end of file or error */ 115 | for (r = 1; r > 0;) { 116 | r = fread(inbuf, 1, blocksize, ffin); 117 | if (r < 0) 118 | break; 119 | 120 | /* Maintain running crc (for footer) */ 121 | crc = crc32(crc, inbuf, r); 122 | 123 | /* Set up compressor for this block */ 124 | zs.next_in = inbuf; 125 | zs.avail_in = r; 126 | zs.next_out = outbuf; 127 | zs.avail_out = blocksize + 500; 128 | 129 | /* Compress with partial flush at the end of this block 130 | * unless EOF, in which case finish */ 131 | err = deflate(&zs, r ? Z_PARTIAL_FLUSH : Z_FINISH); 132 | switch (err) { 133 | case Z_STREAM_END: 134 | case Z_OK: 135 | { 136 | size_t w = zs.next_out - outbuf; 137 | 138 | if (w != fwrite(outbuf, 1, w, ffout)) { 139 | perror("write"); 140 | r = -1; 141 | } 142 | } 143 | break; 144 | default: 145 | fprintf(stderr, "zlib error: %s (%d)\n", zs.msg, err); 146 | r = -1; 147 | } 148 | } 149 | 150 | /* Write gzip footer */ 151 | if (fputlong(ffout, crc) == -1) { 152 | perror("write"); 153 | return NULL; 154 | } 155 | if (fputlong(ffout, zs.total_in) == -1) { 156 | perror("write"); 157 | return NULL; 158 | } 159 | 160 | /* Clean up */ 161 | fflush(ffout); 162 | free(outbuf); 163 | free(inbuf); 164 | if (fclose(ffin) != 0 || r != 0) { 165 | fclose(ffout); 166 | return NULL; 167 | } 168 | } 169 | 170 | /* Return rewound handle on the compressed data to the caller */ 171 | rewind(ffout); 172 | return ffout; 173 | } 174 | -------------------------------------------------------------------------------- /makegz.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | FILE* optimal_gzip(FILE* fin, const char* fout, size_t blocksize); 17 | -------------------------------------------------------------------------------- /progress.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * zsync - client side rsync over http 4 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the Artistic License v2 (see the accompanying 8 | * file COPYING for the full license terms), or, at your option, any later 9 | * version of the same license. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * COPYING file for details. 15 | */ 16 | 17 | #include "zsglobal.h" 18 | 19 | #include 20 | #include 21 | #include 22 | 23 | #ifdef WITH_DMALLOC 24 | # include 25 | #endif 26 | 27 | #include "progress.h" 28 | 29 | struct progress { 30 | time_t starttime; 31 | time_t lasttime; 32 | float lastpcnt; 33 | long long lastdl; 34 | }; 35 | 36 | 37 | /* progbar(chars, percent) 38 | * (Re)print progress bar with chars out of 20 shown and followed by the given 39 | * percentage done. */ 40 | static void progbar(int j, float pcnt) { 41 | int i; 42 | char buf[21]; 43 | 44 | for (i = 0; i < j && i < 20; i++) 45 | buf[i] = '#'; 46 | for (; i < 20; i++) 47 | buf[i] = '-'; 48 | buf[i] = 0; 49 | printf("\r%s %.1f%%", buf, pcnt); 50 | } 51 | 52 | /* state=start_progress(url) 53 | * Returns a handle to a progress state used to track progress downloading 54 | * from the given URL.*/ 55 | void *start_progress(const char *url) 56 | { 57 | struct progress *p = calloc(sizeof(struct progress), 1); 58 | return p; 59 | } 60 | 61 | /* do_progress(progress, percent, total_bytes_retrieved 62 | * Updates the supplied progress structure with the new % done given, and 63 | * recalculates the rolling download rate given the supplied 64 | * total_bytes_retrieved (and the current time) */ 65 | void do_progress(void *pv, float pcnt, long long newdl) { 66 | struct progress *p = pv; 67 | /* If new or if time has passed, update progress display & data */ 68 | time_t newtime = time(NULL); 69 | if (p->lasttime != newtime) { 70 | int passed = p->lasttime ? newtime - p->lasttime : 0; 71 | if (!p->lasttime) 72 | p->starttime = newtime; 73 | p->lasttime = newtime; 74 | 75 | /* Update progress bar displayed */ 76 | progbar(pcnt * (20.0 / 100.0), pcnt); 77 | 78 | /* Each time 1s has passed, we update and redisplay our download rate */ 79 | if (passed) { 80 | float rate = newdl - p->lastdl; 81 | int sleft = (100.0f - pcnt) / (pcnt - p->lastpcnt); 82 | if (passed != 1) { 83 | rate /= passed; 84 | sleft *= passed; 85 | } 86 | printf(" %.1f kBps ", rate / 1000.0); 87 | if (sleft < 60 * 1000) 88 | printf("%d:%02d ETA ", sleft / 60, sleft % 60); 89 | else 90 | puts(" "); 91 | } 92 | p->lastdl = newdl; 93 | p->lastpcnt = pcnt; 94 | fflush(stdout); 95 | } 96 | } 97 | 98 | /* end_progress(progress, done) 99 | * Do one final update of the progress display (set to 100% if done is set to 100 | * true), and then release the progress data structures. 101 | */ 102 | void end_progress(void *pv, int done) { 103 | struct progress *p = pv; 104 | if (done == 2) 105 | progbar(20, 100.0); 106 | else 107 | progbar(p->lastpcnt * (20.0 / 100.0), p->lastpcnt); 108 | 109 | { 110 | float rate = ((float)p->lastdl) / (p->lasttime - p->starttime + 0.5); 111 | printf(" %.1f kBps ", rate / 1000.0); 112 | } 113 | puts(done == 2 ? "DONE \n" : !done ? "aborted \n" : " \n"); 114 | fflush(stdout); 115 | free(p); 116 | } 117 | -------------------------------------------------------------------------------- /progress.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2009 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | void *start_progress(const char *url); 17 | 18 | void do_progress(void* p, float pcnt, long long newdl); 19 | 20 | /* end_progress - done parameter is 0 for error, 1 for okay-but-incomplete, 2 for completed */ 21 | void end_progress(void* p, int done); 22 | -------------------------------------------------------------------------------- /stamp-h1: -------------------------------------------------------------------------------- 1 | timestamp for config.h 2 | -------------------------------------------------------------------------------- /url.c: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * zsync - client side rsync over http 4 | * Copyright (C) 2004,2005,2009 Colin Phipps 5 | * 6 | * This program is free software; you can redistribute it and/or modify 7 | * it under the terms of the Artistic License v2 (see the accompanying 8 | * file COPYING for the full license terms), or, at your option, any later 9 | * version of the same license. 10 | * 11 | * This program is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * COPYING file for details. 15 | */ 16 | 17 | /* Very crude URL parsing module */ 18 | 19 | #include "zsglobal.h" 20 | 21 | #include 22 | #include 23 | 24 | #ifdef WITH_DMALLOC 25 | # include 26 | #endif 27 | 28 | #include "url.h" 29 | 30 | const char http_scheme[] = { "http://" }; 31 | 32 | /* path_str = get_http_host_port(url_str, &host, host_len, &port_str) 33 | * For the given url_str, returns: 34 | * the hostname, in host[] array provided by caller (up to length host_len) 35 | * the port (if any) as a malloced string, pointer to this stored in *port_str 36 | * return value is the path part of the URL, a malloced string. 37 | * Or return value NULL on failure (host and port could have been written to). 38 | */ 39 | char *get_http_host_port(const char *url, char *hostn, int hnlen, char **port) { 40 | char *p; 41 | const char *q; 42 | 43 | /* Check it's HTTP */ 44 | if (memcmp(url, http_scheme, strlen(http_scheme))) 45 | return NULL; 46 | 47 | q = url + strlen(http_scheme); 48 | 49 | p = strchr(q, ':'); 50 | if (p) { /* if : is after the first /, we have looked too far ahead */ 51 | char *r = strchr(q, '/'); 52 | if (r && r < p) 53 | p = NULL; 54 | } 55 | if (!p) { 56 | *port = strdup("http"); 57 | p = strchr(q, '/'); 58 | } 59 | 60 | if (!p) 61 | return NULL; 62 | 63 | if (p - q < hnlen - 1) { 64 | memcpy(hostn, q, p - q); 65 | hostn[p - q] = 0; 66 | } 67 | 68 | if (*p == ':') { 69 | size_t l; 70 | q = p; 71 | p = strchr(p, '/'); 72 | l = p ? (size_t) (p - q - 1) : strlen(q) - 1; 73 | *port = malloc(l + 1); 74 | if (!*port) 75 | return NULL; 76 | memcpy(*port, q + 1, l); 77 | (*port)[l] = 0; 78 | if (!p) 79 | p = strdup("/"); 80 | } 81 | return p; 82 | } 83 | 84 | /* abs_url_str = make_url_absolute(base_str, url_str) 85 | * Returns an absolute version of url_str relative to base_str, as a malloced 86 | * string. Or NULL on error. */ 87 | char * __attribute__ ((pure)) make_url_absolute(const char *base, const char *url) { 88 | if (is_url_absolute(url)) 89 | return strdup(url); 90 | 91 | /* Otherwise, we'll need a base URL to get the scheme and host */ 92 | if (!base) 93 | return NULL; 94 | 95 | /* Next, is it a full-path URL? */ 96 | if (*url == '/') { 97 | size_t l; 98 | char *newurl; 99 | 100 | /* Find the end of the scheme of the base URL, then the end of the 101 | * hostname[:port]/ */ 102 | const char *p = strchr(base, ':'); 103 | if (!p || p[1] != '/' || p[2] != '/') 104 | return NULL; 105 | p = strchr(p + 3, '/'); 106 | if (!p) /* We have a http://hostname URL (no trailing / or path) */ 107 | l = strlen(base); 108 | else /* http://hostname/... , we want just http://hostname */ 109 | l = p - base; 110 | 111 | /* assert */ 112 | if (base[l] != '/' && base[l] != '\0') 113 | return NULL; 114 | 115 | /* Append full path to the base http://hostname */ 116 | newurl = malloc(l + strlen(url) + 1); 117 | memcpy(newurl, base, l); 118 | strcpy(newurl + l, url); 119 | return newurl; 120 | } 121 | 122 | /* No leading / or scheme - relative path */ 123 | { 124 | int l; 125 | char *newurl; 126 | 127 | /* Find the end of the path part of the base URL */ 128 | const char *q; 129 | const char *p = strchr(base, '?'); 130 | if (!p) 131 | p = strchr(base, '#'); 132 | if (!p) 133 | p = base + strlen(base); 134 | 135 | /* Find the last / in the path part */ 136 | for (q = p; q > base && *q != '/'; q--); 137 | if (*q != '/') 138 | return NULL; 139 | 140 | /* Take the base URL up to and including the last /, and append the relative URL */ 141 | l = q - base + 1; 142 | newurl = malloc(l + strlen(url) + 1); 143 | memcpy(newurl, base, l); 144 | strcpy(newurl + l, url); 145 | return newurl; 146 | } 147 | } 148 | 149 | /* int n = is_url_absolute(url) 150 | * Returns 0 if the supplied string is not an absolute URL. 151 | * Returns the number of characters in the URL scheme if it is. 152 | */ 153 | static const char special[] = { ":/?" }; 154 | 155 | int __attribute__ ((pure)) is_url_absolute(const char *url) { 156 | /* find end of first no-special-URL-characters part of the string */ 157 | int n = strcspn(url, special); 158 | 159 | /* If the first special character is a :, the start is a URL scheme */ 160 | if (n > 0 && url[n] == ':') 161 | return n; 162 | 163 | /* otherwise, it's a full path or relative path URL, or just a local file 164 | * path (caller knows the context) */ 165 | return 0; 166 | } 167 | -------------------------------------------------------------------------------- /url.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2009 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | extern const char http_scheme[]; 17 | 18 | /* Given an HTTP URL, return the path path of the URL as the return value, and 19 | * return the hostname in the provided buffer (hostn, length hnlen) 20 | * and, if present, return a (malloced) string buffer containing the port string. 21 | * Or return NULL if not HTTP or other parsing failure. 22 | */ 23 | char* get_http_host_port(const char* url, char* hostn, int hnlen, char** port); 24 | 25 | char* __attribute__((pure)) make_url_absolute(const char* base, const char* url); 26 | 27 | int __attribute__((pure)) is_url_absolute(const char* url); 28 | -------------------------------------------------------------------------------- /zlib/.deps/adler32.Po: -------------------------------------------------------------------------------- 1 | adler32.o adler32.o: adler32.c zlib.h zconf.h /usr/include/sys/types.h \ 2 | /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h \ 3 | /usr/include/machine/types.h /usr/include/i386/types.h \ 4 | /usr/include/i386/_types.h /usr/include/sys/_types.h \ 5 | /usr/include/machine/_types.h /usr/include/machine/endian.h \ 6 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 7 | /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h 9 | 10 | zlib.h: 11 | 12 | zconf.h: 13 | 14 | /usr/include/sys/types.h: 15 | 16 | /usr/include/sys/appleapiopts.h: 17 | 18 | /usr/include/sys/cdefs.h: 19 | 20 | /usr/include/machine/types.h: 21 | 22 | /usr/include/i386/types.h: 23 | 24 | /usr/include/i386/_types.h: 25 | 26 | /usr/include/sys/_types.h: 27 | 28 | /usr/include/machine/_types.h: 29 | 30 | /usr/include/machine/endian.h: 31 | 32 | /usr/include/i386/endian.h: 33 | 34 | /usr/include/sys/_endian.h: 35 | 36 | /usr/include/libkern/_OSByteOrder.h: 37 | 38 | /usr/include/libkern/i386/_OSByteOrder.h: 39 | 40 | /usr/include/sys/_structs.h: 41 | -------------------------------------------------------------------------------- /zlib/.deps/compress.Po: -------------------------------------------------------------------------------- 1 | compress.o compress.o: compress.c zlib.h zconf.h /usr/include/sys/types.h \ 2 | /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h \ 3 | /usr/include/machine/types.h /usr/include/i386/types.h \ 4 | /usr/include/i386/_types.h /usr/include/sys/_types.h \ 5 | /usr/include/machine/_types.h /usr/include/machine/endian.h \ 6 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 7 | /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h 9 | 10 | zlib.h: 11 | 12 | zconf.h: 13 | 14 | /usr/include/sys/types.h: 15 | 16 | /usr/include/sys/appleapiopts.h: 17 | 18 | /usr/include/sys/cdefs.h: 19 | 20 | /usr/include/machine/types.h: 21 | 22 | /usr/include/i386/types.h: 23 | 24 | /usr/include/i386/_types.h: 25 | 26 | /usr/include/sys/_types.h: 27 | 28 | /usr/include/machine/_types.h: 29 | 30 | /usr/include/machine/endian.h: 31 | 32 | /usr/include/i386/endian.h: 33 | 34 | /usr/include/sys/_endian.h: 35 | 36 | /usr/include/libkern/_OSByteOrder.h: 37 | 38 | /usr/include/libkern/i386/_OSByteOrder.h: 39 | 40 | /usr/include/sys/_structs.h: 41 | -------------------------------------------------------------------------------- /zlib/.deps/crc32.Po: -------------------------------------------------------------------------------- 1 | crc32.o crc32.o: crc32.c zutil.h zlib.h zconf.h /usr/include/sys/types.h \ 2 | /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h \ 3 | /usr/include/machine/types.h /usr/include/i386/types.h \ 4 | /usr/include/i386/_types.h /usr/include/sys/_types.h \ 5 | /usr/include/machine/_types.h /usr/include/machine/endian.h \ 6 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 7 | /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ 10 | /usr/include/string.h /usr/include/_types.h /usr/include/stdlib.h \ 11 | /usr/include/available.h /usr/include/sys/wait.h \ 12 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 13 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 14 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 15 | /usr/include/sys/resource.h /usr/include/alloca.h /usr/include/errno.h \ 16 | /usr/include/sys/errno.h \ 17 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h \ 18 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h \ 19 | /usr/include/limits.h /usr/include/machine/limits.h \ 20 | /usr/include/i386/limits.h /usr/include/i386/_limits.h \ 21 | /usr/include/sys/syslimits.h crc32.h 22 | 23 | zutil.h: 24 | 25 | zlib.h: 26 | 27 | zconf.h: 28 | 29 | /usr/include/sys/types.h: 30 | 31 | /usr/include/sys/appleapiopts.h: 32 | 33 | /usr/include/sys/cdefs.h: 34 | 35 | /usr/include/machine/types.h: 36 | 37 | /usr/include/i386/types.h: 38 | 39 | /usr/include/i386/_types.h: 40 | 41 | /usr/include/sys/_types.h: 42 | 43 | /usr/include/machine/_types.h: 44 | 45 | /usr/include/machine/endian.h: 46 | 47 | /usr/include/i386/endian.h: 48 | 49 | /usr/include/sys/_endian.h: 50 | 51 | /usr/include/libkern/_OSByteOrder.h: 52 | 53 | /usr/include/libkern/i386/_OSByteOrder.h: 54 | 55 | /usr/include/sys/_structs.h: 56 | 57 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: 58 | 59 | /usr/include/string.h: 60 | 61 | /usr/include/_types.h: 62 | 63 | /usr/include/stdlib.h: 64 | 65 | /usr/include/available.h: 66 | 67 | /usr/include/sys/wait.h: 68 | 69 | /usr/include/sys/signal.h: 70 | 71 | /usr/include/machine/signal.h: 72 | 73 | /usr/include/i386/signal.h: 74 | 75 | /usr/include/i386/_structs.h: 76 | 77 | /usr/include/machine/_structs.h: 78 | 79 | /usr/include/mach/i386/_structs.h: 80 | 81 | /usr/include/sys/resource.h: 82 | 83 | /usr/include/alloca.h: 84 | 85 | /usr/include/errno.h: 86 | 87 | /usr/include/sys/errno.h: 88 | 89 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/limits.h: 90 | 91 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/syslimits.h: 92 | 93 | /usr/include/limits.h: 94 | 95 | /usr/include/machine/limits.h: 96 | 97 | /usr/include/i386/limits.h: 98 | 99 | /usr/include/i386/_limits.h: 100 | 101 | /usr/include/sys/syslimits.h: 102 | 103 | crc32.h: 104 | -------------------------------------------------------------------------------- /zlib/.deps/deflate.Po: -------------------------------------------------------------------------------- 1 | deflate.o deflate.o: deflate.c deflate.h zutil.h zlib.h zconf.h \ 2 | /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/types.h \ 4 | /usr/include/i386/types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/_types.h /usr/include/machine/_types.h \ 6 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 7 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ 10 | /usr/include/string.h /usr/include/_types.h /usr/include/stdlib.h \ 11 | /usr/include/available.h /usr/include/sys/wait.h \ 12 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 13 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 14 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 15 | /usr/include/sys/resource.h /usr/include/alloca.h /usr/include/errno.h \ 16 | /usr/include/sys/errno.h 17 | 18 | deflate.h: 19 | 20 | zutil.h: 21 | 22 | zlib.h: 23 | 24 | zconf.h: 25 | 26 | /usr/include/sys/types.h: 27 | 28 | /usr/include/sys/appleapiopts.h: 29 | 30 | /usr/include/sys/cdefs.h: 31 | 32 | /usr/include/machine/types.h: 33 | 34 | /usr/include/i386/types.h: 35 | 36 | /usr/include/i386/_types.h: 37 | 38 | /usr/include/sys/_types.h: 39 | 40 | /usr/include/machine/_types.h: 41 | 42 | /usr/include/machine/endian.h: 43 | 44 | /usr/include/i386/endian.h: 45 | 46 | /usr/include/sys/_endian.h: 47 | 48 | /usr/include/libkern/_OSByteOrder.h: 49 | 50 | /usr/include/libkern/i386/_OSByteOrder.h: 51 | 52 | /usr/include/sys/_structs.h: 53 | 54 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: 55 | 56 | /usr/include/string.h: 57 | 58 | /usr/include/_types.h: 59 | 60 | /usr/include/stdlib.h: 61 | 62 | /usr/include/available.h: 63 | 64 | /usr/include/sys/wait.h: 65 | 66 | /usr/include/sys/signal.h: 67 | 68 | /usr/include/machine/signal.h: 69 | 70 | /usr/include/i386/signal.h: 71 | 72 | /usr/include/i386/_structs.h: 73 | 74 | /usr/include/machine/_structs.h: 75 | 76 | /usr/include/mach/i386/_structs.h: 77 | 78 | /usr/include/sys/resource.h: 79 | 80 | /usr/include/alloca.h: 81 | 82 | /usr/include/errno.h: 83 | 84 | /usr/include/sys/errno.h: 85 | -------------------------------------------------------------------------------- /zlib/.deps/inflate.Po: -------------------------------------------------------------------------------- 1 | inflate.o inflate.o: inflate.c zutil.h zlib.h zconf.h \ 2 | /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/types.h \ 4 | /usr/include/i386/types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/_types.h /usr/include/machine/_types.h \ 6 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 7 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ 10 | /usr/include/string.h /usr/include/_types.h /usr/include/stdlib.h \ 11 | /usr/include/available.h /usr/include/sys/wait.h \ 12 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 13 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 14 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 15 | /usr/include/sys/resource.h /usr/include/alloca.h /usr/include/errno.h \ 16 | /usr/include/sys/errno.h inftrees.h inflate.h inffixed.h 17 | 18 | zutil.h: 19 | 20 | zlib.h: 21 | 22 | zconf.h: 23 | 24 | /usr/include/sys/types.h: 25 | 26 | /usr/include/sys/appleapiopts.h: 27 | 28 | /usr/include/sys/cdefs.h: 29 | 30 | /usr/include/machine/types.h: 31 | 32 | /usr/include/i386/types.h: 33 | 34 | /usr/include/i386/_types.h: 35 | 36 | /usr/include/sys/_types.h: 37 | 38 | /usr/include/machine/_types.h: 39 | 40 | /usr/include/machine/endian.h: 41 | 42 | /usr/include/i386/endian.h: 43 | 44 | /usr/include/sys/_endian.h: 45 | 46 | /usr/include/libkern/_OSByteOrder.h: 47 | 48 | /usr/include/libkern/i386/_OSByteOrder.h: 49 | 50 | /usr/include/sys/_structs.h: 51 | 52 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: 53 | 54 | /usr/include/string.h: 55 | 56 | /usr/include/_types.h: 57 | 58 | /usr/include/stdlib.h: 59 | 60 | /usr/include/available.h: 61 | 62 | /usr/include/sys/wait.h: 63 | 64 | /usr/include/sys/signal.h: 65 | 66 | /usr/include/machine/signal.h: 67 | 68 | /usr/include/i386/signal.h: 69 | 70 | /usr/include/i386/_structs.h: 71 | 72 | /usr/include/machine/_structs.h: 73 | 74 | /usr/include/mach/i386/_structs.h: 75 | 76 | /usr/include/sys/resource.h: 77 | 78 | /usr/include/alloca.h: 79 | 80 | /usr/include/errno.h: 81 | 82 | /usr/include/sys/errno.h: 83 | 84 | inftrees.h: 85 | 86 | inflate.h: 87 | 88 | inffixed.h: 89 | -------------------------------------------------------------------------------- /zlib/.deps/inftrees.Po: -------------------------------------------------------------------------------- 1 | inftrees.o inftrees.o: inftrees.c zutil.h zlib.h zconf.h \ 2 | /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/types.h \ 4 | /usr/include/i386/types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/_types.h /usr/include/machine/_types.h \ 6 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 7 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ 10 | /usr/include/string.h /usr/include/_types.h /usr/include/stdlib.h \ 11 | /usr/include/available.h /usr/include/sys/wait.h \ 12 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 13 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 14 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 15 | /usr/include/sys/resource.h /usr/include/alloca.h /usr/include/errno.h \ 16 | /usr/include/sys/errno.h inftrees.h 17 | 18 | zutil.h: 19 | 20 | zlib.h: 21 | 22 | zconf.h: 23 | 24 | /usr/include/sys/types.h: 25 | 26 | /usr/include/sys/appleapiopts.h: 27 | 28 | /usr/include/sys/cdefs.h: 29 | 30 | /usr/include/machine/types.h: 31 | 32 | /usr/include/i386/types.h: 33 | 34 | /usr/include/i386/_types.h: 35 | 36 | /usr/include/sys/_types.h: 37 | 38 | /usr/include/machine/_types.h: 39 | 40 | /usr/include/machine/endian.h: 41 | 42 | /usr/include/i386/endian.h: 43 | 44 | /usr/include/sys/_endian.h: 45 | 46 | /usr/include/libkern/_OSByteOrder.h: 47 | 48 | /usr/include/libkern/i386/_OSByteOrder.h: 49 | 50 | /usr/include/sys/_structs.h: 51 | 52 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: 53 | 54 | /usr/include/string.h: 55 | 56 | /usr/include/_types.h: 57 | 58 | /usr/include/stdlib.h: 59 | 60 | /usr/include/available.h: 61 | 62 | /usr/include/sys/wait.h: 63 | 64 | /usr/include/sys/signal.h: 65 | 66 | /usr/include/machine/signal.h: 67 | 68 | /usr/include/i386/signal.h: 69 | 70 | /usr/include/i386/_structs.h: 71 | 72 | /usr/include/machine/_structs.h: 73 | 74 | /usr/include/mach/i386/_structs.h: 75 | 76 | /usr/include/sys/resource.h: 77 | 78 | /usr/include/alloca.h: 79 | 80 | /usr/include/errno.h: 81 | 82 | /usr/include/sys/errno.h: 83 | 84 | inftrees.h: 85 | -------------------------------------------------------------------------------- /zlib/.deps/trees.Po: -------------------------------------------------------------------------------- 1 | trees.o trees.o: trees.c deflate.h zutil.h zlib.h zconf.h \ 2 | /usr/include/sys/types.h /usr/include/sys/appleapiopts.h \ 3 | /usr/include/sys/cdefs.h /usr/include/machine/types.h \ 4 | /usr/include/i386/types.h /usr/include/i386/_types.h \ 5 | /usr/include/sys/_types.h /usr/include/machine/_types.h \ 6 | /usr/include/machine/endian.h /usr/include/i386/endian.h \ 7 | /usr/include/sys/_endian.h /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ 10 | /usr/include/string.h /usr/include/_types.h /usr/include/stdlib.h \ 11 | /usr/include/available.h /usr/include/sys/wait.h \ 12 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 13 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 14 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 15 | /usr/include/sys/resource.h /usr/include/alloca.h /usr/include/errno.h \ 16 | /usr/include/sys/errno.h trees.h 17 | 18 | deflate.h: 19 | 20 | zutil.h: 21 | 22 | zlib.h: 23 | 24 | zconf.h: 25 | 26 | /usr/include/sys/types.h: 27 | 28 | /usr/include/sys/appleapiopts.h: 29 | 30 | /usr/include/sys/cdefs.h: 31 | 32 | /usr/include/machine/types.h: 33 | 34 | /usr/include/i386/types.h: 35 | 36 | /usr/include/i386/_types.h: 37 | 38 | /usr/include/sys/_types.h: 39 | 40 | /usr/include/machine/_types.h: 41 | 42 | /usr/include/machine/endian.h: 43 | 44 | /usr/include/i386/endian.h: 45 | 46 | /usr/include/sys/_endian.h: 47 | 48 | /usr/include/libkern/_OSByteOrder.h: 49 | 50 | /usr/include/libkern/i386/_OSByteOrder.h: 51 | 52 | /usr/include/sys/_structs.h: 53 | 54 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: 55 | 56 | /usr/include/string.h: 57 | 58 | /usr/include/_types.h: 59 | 60 | /usr/include/stdlib.h: 61 | 62 | /usr/include/available.h: 63 | 64 | /usr/include/sys/wait.h: 65 | 66 | /usr/include/sys/signal.h: 67 | 68 | /usr/include/machine/signal.h: 69 | 70 | /usr/include/i386/signal.h: 71 | 72 | /usr/include/i386/_structs.h: 73 | 74 | /usr/include/machine/_structs.h: 75 | 76 | /usr/include/mach/i386/_structs.h: 77 | 78 | /usr/include/sys/resource.h: 79 | 80 | /usr/include/alloca.h: 81 | 82 | /usr/include/errno.h: 83 | 84 | /usr/include/sys/errno.h: 85 | 86 | trees.h: 87 | -------------------------------------------------------------------------------- /zlib/.deps/zutil.Po: -------------------------------------------------------------------------------- 1 | zutil.o zutil.o: zutil.c zutil.h zlib.h zconf.h /usr/include/sys/types.h \ 2 | /usr/include/sys/appleapiopts.h /usr/include/sys/cdefs.h \ 3 | /usr/include/machine/types.h /usr/include/i386/types.h \ 4 | /usr/include/i386/_types.h /usr/include/sys/_types.h \ 5 | /usr/include/machine/_types.h /usr/include/machine/endian.h \ 6 | /usr/include/i386/endian.h /usr/include/sys/_endian.h \ 7 | /usr/include/libkern/_OSByteOrder.h \ 8 | /usr/include/libkern/i386/_OSByteOrder.h /usr/include/sys/_structs.h \ 9 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h \ 10 | /usr/include/string.h /usr/include/_types.h /usr/include/stdlib.h \ 11 | /usr/include/available.h /usr/include/sys/wait.h \ 12 | /usr/include/sys/signal.h /usr/include/machine/signal.h \ 13 | /usr/include/i386/signal.h /usr/include/i386/_structs.h \ 14 | /usr/include/machine/_structs.h /usr/include/mach/i386/_structs.h \ 15 | /usr/include/sys/resource.h /usr/include/alloca.h /usr/include/errno.h \ 16 | /usr/include/sys/errno.h 17 | 18 | zutil.h: 19 | 20 | zlib.h: 21 | 22 | zconf.h: 23 | 24 | /usr/include/sys/types.h: 25 | 26 | /usr/include/sys/appleapiopts.h: 27 | 28 | /usr/include/sys/cdefs.h: 29 | 30 | /usr/include/machine/types.h: 31 | 32 | /usr/include/i386/types.h: 33 | 34 | /usr/include/i386/_types.h: 35 | 36 | /usr/include/sys/_types.h: 37 | 38 | /usr/include/machine/_types.h: 39 | 40 | /usr/include/machine/endian.h: 41 | 42 | /usr/include/i386/endian.h: 43 | 44 | /usr/include/sys/_endian.h: 45 | 46 | /usr/include/libkern/_OSByteOrder.h: 47 | 48 | /usr/include/libkern/i386/_OSByteOrder.h: 49 | 50 | /usr/include/sys/_structs.h: 51 | 52 | /usr/lib/gcc/i686-apple-darwin9/4.0.1/include/stddef.h: 53 | 54 | /usr/include/string.h: 55 | 56 | /usr/include/_types.h: 57 | 58 | /usr/include/stdlib.h: 59 | 60 | /usr/include/available.h: 61 | 62 | /usr/include/sys/wait.h: 63 | 64 | /usr/include/sys/signal.h: 65 | 66 | /usr/include/machine/signal.h: 67 | 68 | /usr/include/i386/signal.h: 69 | 70 | /usr/include/i386/_structs.h: 71 | 72 | /usr/include/machine/_structs.h: 73 | 74 | /usr/include/mach/i386/_structs.h: 75 | 76 | /usr/include/sys/resource.h: 77 | 78 | /usr/include/alloca.h: 79 | 80 | /usr/include/errno.h: 81 | 82 | /usr/include/sys/errno.h: 83 | -------------------------------------------------------------------------------- /zlib/Makefile.am: -------------------------------------------------------------------------------- 1 | 2 | noinst_LIBRARIES = libinflate.a libdeflate.a 3 | 4 | libinflate_a_SOURCES = zlib.h inflate.c inflate.h inffixed.h adler32.c inftrees.c inftrees.h zutil.c zutil.h crc32.c crc32.h zconf.h 5 | 6 | libdeflate_a_SOURCES = deflate.c deflate.h compress.c trees.c trees.h 7 | -------------------------------------------------------------------------------- /zlib/README: -------------------------------------------------------------------------------- 1 | ZLIB DATA COMPRESSION LIBRARY 2 | 3 | zlib 1.2.1.1 is a general purpose data compression library. All the code is 4 | thread safe. The data format used by the zlib library is described by RFCs 5 | (Request for Comments) 1950 to 1952 in the files 6 | http://www.ietf.org/rfc/rfc1950.txt (zlib format), rfc1951.txt (deflate format) 7 | and rfc1952.txt (gzip format). These documents are also available in other 8 | formats from ftp://ftp.uu.net/graphics/png/documents/zlib/zdoc-index.html 9 | 10 | All functions of the compression library are documented in the file zlib.h 11 | (volunteer to write man pages welcome, contact zlib@gzip.org). A usage example 12 | of the library is given in the file example.c which also tests that the library 13 | is working correctly. Another example is given in the file minigzip.c. The 14 | compression library itself is composed of all source files except example.c and 15 | minigzip.c. 16 | 17 | To compile all files and run the test program, follow the instructions given at 18 | the top of Makefile. In short "make test; make install" should work for most 19 | machines. For Unix: "./configure; make test; make install" For MSDOS, use one 20 | of the special makefiles such as Makefile.msc. For VMS, use Make_vms.com or 21 | descrip.mms. 22 | 23 | Questions about zlib should be sent to , or to Gilles Vollant 24 | for the Windows DLL version. The zlib home page is 25 | http://www.zlib.org or http://www.gzip.org/zlib/ Before reporting a problem, 26 | please check this site to verify that you have the latest version of zlib; 27 | otherwise get the latest version and check whether the problem still exists or 28 | not. 29 | 30 | PLEASE read the zlib FAQ http://www.gzip.org/zlib/zlib_faq.html before asking 31 | for help. 32 | 33 | Mark Nelson wrote an article about zlib for the Jan. 1997 34 | issue of Dr. Dobb's Journal; a copy of the article is available in 35 | http://dogma.net/markn/articles/zlibtool/zlibtool.htm 36 | 37 | The changes made in version 1.2.1.1 are documented in the file ChangeLog. 38 | 39 | Unsupported third party contributions are provided in directory "contrib". 40 | 41 | A Java implementation of zlib is available in the Java Development Kit 42 | http://java.sun.com/j2se/1.4.2/docs/api/java/util/zip/package-summary.html 43 | See the zlib home page http://www.zlib.org for details. 44 | 45 | A Perl interface to zlib written by Paul Marquess is in the 46 | CPAN (Comprehensive Perl Archive Network) sites 47 | http://www.cpan.org/modules/by-module/Compress/ 48 | 49 | A Python interface to zlib written by A.M. Kuchling is 50 | available in Python 1.5 and later versions, see 51 | http://www.python.org/doc/lib/module-zlib.html 52 | 53 | A zlib binding for TCL written by Andreas Kupries is 54 | availlable at http://www.oche.de/~akupries/soft/trf/trf_zip.html 55 | 56 | An experimental package to read and write files in .zip format, written on top 57 | of zlib by Gilles Vollant , is available in the 58 | contrib/minizip directory of zlib. 59 | 60 | 61 | Notes for some targets: 62 | 63 | - For Windows DLL versions, please see win32/DLL_FAQ.txt 64 | 65 | - For 64-bit Irix, deflate.c must be compiled without any optimization. With 66 | -O, one libpng test fails. The test works in 32 bit mode (with the -n32 67 | compiler flag). The compiler bug has been reported to SGI. 68 | 69 | - zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works 70 | when compiled with cc. 71 | 72 | - On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is 73 | necessary to get gzprintf working correctly. This is done by configure. 74 | 75 | - zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with 76 | other compilers. Use "make test" to check your compiler. 77 | 78 | - gzdopen is not supported on RISCOS, BEOS and by some Mac compilers. 79 | 80 | - For PalmOs, see http://palmzlib.sourceforge.net/ 81 | 82 | - When building a shared, i.e. dynamic library on Mac OS X, the library must be 83 | installed before testing (do "make install" before "make test"), since the 84 | library location is specified in the library. 85 | 86 | 87 | Acknowledgments: 88 | 89 | The deflate format used by zlib was defined by Phil Katz. The deflate 90 | and zlib specifications were written by L. Peter Deutsch. Thanks to all the 91 | people who reported problems and suggested various improvements in zlib; 92 | they are too numerous to cite here. 93 | 94 | Copyright notice: 95 | 96 | (C) 1995-2003 Jean-loup Gailly and Mark Adler 97 | 98 | This software is provided 'as-is', without any express or implied 99 | warranty. In no event will the authors be held liable for any damages 100 | arising from the use of this software. 101 | 102 | Permission is granted to anyone to use this software for any purpose, 103 | including commercial applications, and to alter it and redistribute it 104 | freely, subject to the following restrictions: 105 | 106 | 1. The origin of this software must not be misrepresented; you must not 107 | claim that you wrote the original software. If you use this software 108 | in a product, an acknowledgment in the product documentation would be 109 | appreciated but is not required. 110 | 2. Altered source versions must be plainly marked as such, and must not be 111 | misrepresented as being the original software. 112 | 3. This notice may not be removed or altered from any source distribution. 113 | 114 | Jean-loup Gailly Mark Adler 115 | jloup@gzip.org madler@alumni.caltech.edu 116 | 117 | If you use the zlib library in a product, we would appreciate *not* 118 | receiving lengthy legal documents to sign. The sources are provided 119 | for free but without warranty of any kind. The library has been 120 | entirely written by Jean-loup Gailly and Mark Adler; it does not 121 | include third-party code. 122 | 123 | If you redistribute modified sources, we would appreciate that you include 124 | in the file ChangeLog history information documenting your changes. Please 125 | read the FAQ for more information on the distribution of modified source 126 | versions. 127 | -------------------------------------------------------------------------------- /zlib/adler32.c: -------------------------------------------------------------------------------- 1 | /* adler32.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | #define BASE 65521UL /* largest prime smaller than 65536 */ 12 | #define NMAX 5552 13 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 14 | 15 | #define DO1(buf,i) {s1 += buf[i]; s2 += s1;} 16 | #define DO2(buf,i) DO1(buf,i); DO1(buf,i+1); 17 | #define DO4(buf,i) DO2(buf,i); DO2(buf,i+2); 18 | #define DO8(buf,i) DO4(buf,i); DO4(buf,i+4); 19 | #define DO16(buf) DO8(buf,0); DO8(buf,8); 20 | 21 | #ifdef NO_DIVIDE 22 | # define MOD(a) \ 23 | do { \ 24 | if (a >= (BASE << 16)) a -= (BASE << 16); \ 25 | if (a >= (BASE << 15)) a -= (BASE << 15); \ 26 | if (a >= (BASE << 14)) a -= (BASE << 14); \ 27 | if (a >= (BASE << 13)) a -= (BASE << 13); \ 28 | if (a >= (BASE << 12)) a -= (BASE << 12); \ 29 | if (a >= (BASE << 11)) a -= (BASE << 11); \ 30 | if (a >= (BASE << 10)) a -= (BASE << 10); \ 31 | if (a >= (BASE << 9)) a -= (BASE << 9); \ 32 | if (a >= (BASE << 8)) a -= (BASE << 8); \ 33 | if (a >= (BASE << 7)) a -= (BASE << 7); \ 34 | if (a >= (BASE << 6)) a -= (BASE << 6); \ 35 | if (a >= (BASE << 5)) a -= (BASE << 5); \ 36 | if (a >= (BASE << 4)) a -= (BASE << 4); \ 37 | if (a >= (BASE << 3)) a -= (BASE << 3); \ 38 | if (a >= (BASE << 2)) a -= (BASE << 2); \ 39 | if (a >= (BASE << 1)) a -= (BASE << 1); \ 40 | if (a >= BASE) a -= BASE; \ 41 | } while (0) 42 | #else 43 | # define MOD(a) a %= BASE 44 | #endif 45 | 46 | /* ========================================================================= */ 47 | uLong ZEXPORT adler32(adler, buf, len) 48 | uLong adler; 49 | const Bytef *buf; 50 | uInt len; 51 | { 52 | unsigned long s1 = adler & 0xffff; 53 | unsigned long s2 = (adler >> 16) & 0xffff; 54 | int k; 55 | 56 | if (buf == Z_NULL) return 1L; 57 | 58 | while (len > 0) { 59 | k = len < NMAX ? (int)len : NMAX; 60 | len -= k; 61 | while (k >= 16) { 62 | DO16(buf); 63 | buf += 16; 64 | k -= 16; 65 | } 66 | if (k != 0) do { 67 | s1 += *buf++; 68 | s2 += s1; 69 | } while (--k); 70 | MOD(s1); 71 | MOD(s2); 72 | } 73 | return (s2 << 16) | s1; 74 | } 75 | -------------------------------------------------------------------------------- /zlib/compress.c: -------------------------------------------------------------------------------- 1 | /* compress.c -- compress a memory buffer 2 | * Copyright (C) 1995-2002 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Compresses the source buffer into the destination buffer. The level 13 | parameter has the same meaning as in deflateInit. sourceLen is the byte 14 | length of the source buffer. Upon entry, destLen is the total size of the 15 | destination buffer, which must be at least 0.1% larger than sourceLen plus 16 | 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. 17 | 18 | compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough 19 | memory, Z_BUF_ERROR if there was not enough room in the output buffer, 20 | Z_STREAM_ERROR if the level parameter is invalid. 21 | */ 22 | int ZEXPORT compress2 (dest, destLen, source, sourceLen, level) 23 | Bytef *dest; 24 | uLongf *destLen; 25 | const Bytef *source; 26 | uLong sourceLen; 27 | int level; 28 | { 29 | z_stream stream; 30 | int err; 31 | 32 | stream.next_in = (Bytef*)source; 33 | stream.avail_in = (uInt)sourceLen; 34 | #ifdef MAXSEG_64K 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | #endif 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | stream.opaque = (voidpf)0; 45 | 46 | err = deflateInit(&stream, level); 47 | if (err != Z_OK) return err; 48 | 49 | err = deflate(&stream, Z_FINISH); 50 | if (err != Z_STREAM_END) { 51 | deflateEnd(&stream); 52 | return err == Z_OK ? Z_BUF_ERROR : err; 53 | } 54 | *destLen = stream.total_out; 55 | 56 | err = deflateEnd(&stream); 57 | return err; 58 | } 59 | 60 | /* =========================================================================== 61 | */ 62 | int ZEXPORT compress (dest, destLen, source, sourceLen) 63 | Bytef *dest; 64 | uLongf *destLen; 65 | const Bytef *source; 66 | uLong sourceLen; 67 | { 68 | return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION); 69 | } 70 | 71 | /* =========================================================================== 72 | If the default memLevel or windowBits for deflateInit() is changed, then 73 | this function needs to be updated. 74 | */ 75 | uLong ZEXPORT compressBound (sourceLen) 76 | uLong sourceLen; 77 | { 78 | return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) + 11; 79 | } 80 | -------------------------------------------------------------------------------- /zlib/inffixed.h: -------------------------------------------------------------------------------- 1 | /* inffixed.h -- table for decoding fixed codes 2 | * Generated automatically by makefixed(). 3 | */ 4 | 5 | /* WARNING: this file should *not* be used by applications. It 6 | is part of the implementation of the compression library and 7 | is subject to change. Applications should only use zlib.h. 8 | */ 9 | 10 | static const code lenfix[512] = { 11 | {96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48}, 12 | {0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128}, 13 | {0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59}, 14 | {0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176}, 15 | {0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20}, 16 | {21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100}, 17 | {0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8}, 18 | {0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216}, 19 | {18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76}, 20 | {0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114}, 21 | {0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2}, 22 | {0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148}, 23 | {20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42}, 24 | {0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86}, 25 | {0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15}, 26 | {0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236}, 27 | {16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62}, 28 | {0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142}, 29 | {0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31}, 30 | {0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162}, 31 | {0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25}, 32 | {0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105}, 33 | {0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4}, 34 | {0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202}, 35 | {17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69}, 36 | {0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125}, 37 | {0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13}, 38 | {0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195}, 39 | {19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35}, 40 | {0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91}, 41 | {0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19}, 42 | {0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246}, 43 | {16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55}, 44 | {0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135}, 45 | {0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99}, 46 | {0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190}, 47 | {0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16}, 48 | {20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96}, 49 | {0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6}, 50 | {0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209}, 51 | {17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72}, 52 | {0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116}, 53 | {0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4}, 54 | {0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153}, 55 | {20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44}, 56 | {0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82}, 57 | {0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11}, 58 | {0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229}, 59 | {16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58}, 60 | {0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138}, 61 | {0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51}, 62 | {0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173}, 63 | {0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30}, 64 | {0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110}, 65 | {0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0}, 66 | {0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195}, 67 | {16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65}, 68 | {0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121}, 69 | {0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9}, 70 | {0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258}, 71 | {19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37}, 72 | {0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93}, 73 | {0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23}, 74 | {0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251}, 75 | {16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51}, 76 | {0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131}, 77 | {0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67}, 78 | {0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183}, 79 | {0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23}, 80 | {64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103}, 81 | {0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9}, 82 | {0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223}, 83 | {18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79}, 84 | {0,9,255} 85 | }; 86 | 87 | static const code distfix[32] = { 88 | {16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025}, 89 | {21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193}, 90 | {18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385}, 91 | {19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577}, 92 | {16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073}, 93 | {22,5,193},{64,5,0} 94 | }; 95 | -------------------------------------------------------------------------------- /zlib/inflate.h: -------------------------------------------------------------------------------- 1 | /* inflate.h -- internal inflate state definition 2 | * Copyright (C) 1995-2003 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* define NO_GZIP when compiling if you want to disable gzip header and 12 | trailer decoding by inflate(). NO_GZIP would be used to avoid linking in 13 | the crc code when it is not needed. For shared libraries, gzip decoding 14 | should be left enabled. */ 15 | #ifndef NO_GZIP 16 | # define GUNZIP 17 | #endif 18 | 19 | /* Possible inflate modes between inflate() calls */ 20 | typedef enum { 21 | HEAD, /* i: waiting for magic header */ 22 | #ifdef GUNZIP 23 | FLAGS, /* i: waiting for method and flags (gzip) */ 24 | TIME, /* i: waiting for modification time (gzip) */ 25 | OS, /* i: waiting for extra flags and operating system (gzip) */ 26 | EXLEN, /* i: waiting for extra length (gzip) */ 27 | EXTRA, /* i: waiting for extra bytes (gzip) */ 28 | NAME, /* i: waiting for end of file name (gzip) */ 29 | COMMENT, /* i: waiting for end of comment (gzip) */ 30 | HCRC, /* i: waiting for header crc (gzip) */ 31 | #endif 32 | DICTID, /* i: waiting for dictionary check value */ 33 | DICT, /* waiting for inflateSetDictionary() call */ 34 | TYPE, /* i: waiting for type bits, including last-flag bit */ 35 | TYPEDO, /* i: same, but skip check to exit inflate on new block */ 36 | STORED, /* i: waiting for stored size (length and complement) */ 37 | COPY, /* i/o: waiting for input or output to copy stored block */ 38 | TABLE, /* i: waiting for dynamic block table lengths */ 39 | LENLENS, /* i: waiting for code length code lengths */ 40 | CODELENS, /* i: waiting for length/lit and distance code lengths */ 41 | LEN, /* i: waiting for length/lit code */ 42 | LENDO, /* i: same, but skip exit check */ 43 | LENEXT, /* i: waiting for length extra bits */ 44 | DIST, /* i: waiting for distance code */ 45 | DISTEXT, /* i: waiting for distance extra bits */ 46 | MATCH, /* o: waiting for output space to copy string */ 47 | LIT, /* o: waiting for output space to write literal */ 48 | CHECK, /* i: waiting for 32-bit check value */ 49 | #ifdef GUNZIP 50 | LENGTH, /* i: waiting for 32-bit length (gzip) */ 51 | #endif 52 | DONE, /* finished check, done -- remain here until reset */ 53 | BAD, /* got a data error -- remain here until reset */ 54 | MEM, /* got an inflate() memory error -- remain here until reset */ 55 | SYNC /* looking for synchronization bytes to restart inflate() */ 56 | } inflate_mode; 57 | 58 | /* 59 | State transitions between above modes - 60 | 61 | (most modes can go to the BAD or MEM mode -- not shown for clarity) 62 | 63 | Process header: 64 | HEAD -> (gzip) or (zlib) 65 | (gzip) -> FLAGS -> TIME -> OS -> EXLEN -> EXTRA -> NAME 66 | NAME -> COMMENT -> HCRC -> TYPE 67 | (zlib) -> DICTID or TYPE 68 | DICTID -> DICT -> TYPE 69 | Read deflate blocks: 70 | TYPE -> STORED or TABLE or LEN or CHECK 71 | STORED -> COPY -> TYPE 72 | TABLE -> LENLENS -> CODELENS -> LEN 73 | Read deflate codes: 74 | LEN -> LENEXT or LIT or TYPE 75 | LENEXT -> DIST -> DISTEXT -> MATCH -> LEN 76 | LIT -> LEN 77 | Process trailer: 78 | CHECK -> LENGTH -> DONE 79 | */ 80 | 81 | /* state maintained between inflate() calls. Approximately 7K bytes. */ 82 | struct inflate_state { 83 | inflate_mode mode; /* current inflate mode */ 84 | int last; /* true if processing last block */ 85 | int wrap; /* bit 0 true for zlib, bit 1 true for gzip */ 86 | int havedict; /* true if dictionary provided */ 87 | int flags; /* gzip header method and flags (0 if zlib) */ 88 | unsigned long check; /* protected copy of check value */ 89 | unsigned long total; /* protected copy of output count */ 90 | /* sliding window */ 91 | unsigned wbits; /* log base 2 of requested window size */ 92 | unsigned wsize; /* window size or zero if not using window */ 93 | unsigned whave; /* valid bytes in the window */ 94 | unsigned write; /* window write index */ 95 | unsigned char FAR *window; /* allocated sliding window, if needed */ 96 | /* bit accumulator */ 97 | unsigned long hold; /* input bit accumulator */ 98 | unsigned bits; /* number of bits in "in" */ 99 | /* for string and stored block copying */ 100 | unsigned length; /* literal or length of data to copy */ 101 | unsigned offset; /* distance back to copy string from */ 102 | /* for table and code decoding */ 103 | unsigned extra; /* extra bits needed */ 104 | /* fixed and dynamic code tables */ 105 | code const FAR *lencode; /* starting table for length/literal codes */ 106 | code const FAR *distcode; /* starting table for distance codes */ 107 | unsigned lenbits; /* index bits for lencode */ 108 | unsigned distbits; /* index bits for distcode */ 109 | /* dynamic table building */ 110 | unsigned ncode; /* number of code length code lengths */ 111 | unsigned nlen; /* number of length code lengths */ 112 | unsigned ndist; /* number of distance code lengths */ 113 | unsigned have; /* number of code lengths in lens[] */ 114 | code FAR *next; /* next available space in codes[] */ 115 | unsigned short lens[320]; /* temporary storage for code lengths */ 116 | unsigned short work[288]; /* work area for code table building */ 117 | code codes[ENOUGH]; /* space for code tables */ 118 | }; 119 | -------------------------------------------------------------------------------- /zlib/inftrees.h: -------------------------------------------------------------------------------- 1 | /* inftrees.h -- header to use inftrees.c 2 | * Copyright (C) 1995-2005 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* Structure for decoding tables. Each entry provides either the 12 | information needed to do the operation requested by the code that 13 | indexed that table entry, or it provides a pointer to another 14 | table that indexes more bits of the code. op indicates whether 15 | the entry is a pointer to another table, a literal, a length or 16 | distance, an end-of-block, or an invalid code. For a table 17 | pointer, the low four bits of op is the number of index bits of 18 | that table. For a length or distance, the low four bits of op 19 | is the number of extra bits to get after the code. bits is 20 | the number of bits in this code or part of the code to drop off 21 | of the bit buffer. val is the actual byte to output in the case 22 | of a literal, the base length or distance, or the offset from 23 | the current table to the next table. Each entry is four bytes. */ 24 | typedef struct { 25 | unsigned char op; /* operation, extra bits, table bits */ 26 | unsigned char bits; /* bits in this part of the code */ 27 | unsigned short val; /* offset in table or code value */ 28 | } code; 29 | 30 | /* op values as set by inflate_table(): 31 | 00000000 - literal 32 | 0000tttt - table link, tttt != 0 is the number of table index bits 33 | 0001eeee - length or distance, eeee is the number of extra bits 34 | 01100000 - end of block 35 | 01000000 - invalid code 36 | */ 37 | 38 | /* Maximum size of dynamic tree. The maximum found in a long but non- 39 | exhaustive search was 1444 code structures (852 for length/literals 40 | and 592 for distances, the latter actually the result of an 41 | exhaustive search). The true maximum is not known, but the value 42 | below is more than safe. */ 43 | #define ENOUGH 2048 44 | #define MAXD 592 45 | 46 | /* Type of code to build for inftable() */ 47 | typedef enum { 48 | CODES, 49 | LENS, 50 | DISTS 51 | } codetype; 52 | 53 | extern int inflate_table OF((codetype type, unsigned short FAR *lens, 54 | unsigned codes, code FAR * FAR *table, 55 | unsigned FAR *bits, unsigned short FAR *work)); 56 | -------------------------------------------------------------------------------- /zlib/zutil.h: -------------------------------------------------------------------------------- 1 | /* zutil.h -- internal interface and configuration of the compression library 2 | * Copyright (C) 1995-2003 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | /* @(#) $Id$ */ 12 | 13 | #ifndef ZUTIL_H 14 | #define ZUTIL_H 15 | 16 | #define ZLIB_INTERNAL 17 | #include "zlib.h" 18 | 19 | #ifdef STDC 20 | # include 21 | # include 22 | # include 23 | #endif 24 | #ifdef NO_ERRNO_H 25 | extern int errno; 26 | #else 27 | # include 28 | #endif 29 | 30 | #ifndef local 31 | # define local static 32 | #endif 33 | /* compile with -Dlocal if your debugger can't find static symbols */ 34 | 35 | typedef unsigned char uch; 36 | typedef uch FAR uchf; 37 | typedef unsigned short ush; 38 | typedef ush FAR ushf; 39 | typedef unsigned long ulg; 40 | 41 | extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */ 42 | /* (size given to avoid silly warnings with Visual C++) */ 43 | 44 | #define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)] 45 | 46 | #define ERR_RETURN(strm,err) \ 47 | return (strm->msg = (char*)ERR_MSG(err), (err)) 48 | /* To be used only when the state is known to be valid */ 49 | 50 | /* common constants */ 51 | 52 | #ifndef DEF_WBITS 53 | # define DEF_WBITS MAX_WBITS 54 | #endif 55 | /* default windowBits for decompression. MAX_WBITS is for compression only */ 56 | 57 | #if MAX_MEM_LEVEL >= 8 58 | # define DEF_MEM_LEVEL 8 59 | #else 60 | # define DEF_MEM_LEVEL MAX_MEM_LEVEL 61 | #endif 62 | /* default memLevel */ 63 | 64 | #define STORED_BLOCK 0 65 | #define STATIC_TREES 1 66 | #define DYN_TREES 2 67 | /* The three kinds of block type */ 68 | 69 | #define MIN_MATCH 3 70 | #define MAX_MATCH 258 71 | /* The minimum and maximum match lengths */ 72 | 73 | #define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */ 74 | 75 | /* target dependencies */ 76 | 77 | #if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32)) 78 | # define OS_CODE 0x00 79 | # if defined(__TURBOC__) || defined(__BORLANDC__) 80 | # if(__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__)) 81 | /* Allow compilation with ANSI keywords only enabled */ 82 | void _Cdecl farfree( void *block ); 83 | void *_Cdecl farmalloc( unsigned long nbytes ); 84 | # else 85 | # include 86 | # endif 87 | # else /* MSC or DJGPP */ 88 | # include 89 | # endif 90 | #endif 91 | 92 | #ifdef AMIGA 93 | # define OS_CODE 0x01 94 | #endif 95 | 96 | #if defined(VAXC) || defined(VMS) 97 | # define OS_CODE 0x02 98 | # define F_OPEN(name, mode) \ 99 | fopen((name), (mode), "mbc=60", "ctx=stm", "rfm=fix", "mrs=512") 100 | #endif 101 | 102 | #if defined(ATARI) || defined(atarist) 103 | # define OS_CODE 0x05 104 | #endif 105 | 106 | #ifdef OS2 107 | # define OS_CODE 0x06 108 | #endif 109 | 110 | #if defined(MACOS) || defined(TARGET_OS_MAC) 111 | # define OS_CODE 0x07 112 | # if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os 113 | # include /* for fdopen */ 114 | # else 115 | # ifndef fdopen 116 | # define fdopen(fd,mode) NULL /* No fdopen() */ 117 | # endif 118 | # endif 119 | #endif 120 | 121 | #ifdef TOPS20 122 | # define OS_CODE 0x0a 123 | #endif 124 | 125 | #ifdef WIN32 126 | # ifndef __CYGWIN__ /* Cygwin is Unix, not Win32 */ 127 | # define OS_CODE 0x0b 128 | # endif 129 | #endif 130 | 131 | #ifdef __50SERIES /* Prime/PRIMOS */ 132 | # define OS_CODE 0x0f 133 | #endif 134 | 135 | #if defined(_BEOS_) || defined(RISCOS) 136 | # define fdopen(fd,mode) NULL /* No fdopen() */ 137 | #endif 138 | 139 | #if (defined(_MSC_VER) && (_MSC_VER > 600)) 140 | # if defined(_WIN32_WCE) 141 | # define fdopen(fd,mode) NULL /* No fdopen() */ 142 | # ifndef _PTRDIFF_T_DEFINED 143 | typedef int ptrdiff_t; 144 | # define _PTRDIFF_T_DEFINED 145 | # endif 146 | # else 147 | # define fdopen(fd,type) _fdopen(fd,type) 148 | # endif 149 | #endif 150 | 151 | /* common defaults */ 152 | 153 | #ifndef OS_CODE 154 | # define OS_CODE 0x03 /* assume Unix */ 155 | #endif 156 | 157 | #ifndef F_OPEN 158 | # define F_OPEN(name, mode) fopen((name), (mode)) 159 | #endif 160 | 161 | /* functions */ 162 | 163 | #if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550) 164 | # ifndef HAVE_VSNPRINTF 165 | # define HAVE_VSNPRINTF 166 | # endif 167 | #endif 168 | #if defined(__CYGWIN__) 169 | # ifndef HAVE_VSNPRINTF 170 | # define HAVE_VSNPRINTF 171 | # endif 172 | #endif 173 | #ifndef HAVE_VSNPRINTF 174 | # ifdef MSDOS 175 | /* vsnprintf may exist on some MS-DOS compilers (DJGPP?), 176 | but for now we just assume it doesn't. */ 177 | # define NO_vsnprintf 178 | # endif 179 | # ifdef __TURBOC__ 180 | # define NO_vsnprintf 181 | # endif 182 | # ifdef WIN32 183 | /* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */ 184 | # if !defined(vsnprintf) && !defined(NO_vsnprintf) 185 | # define vsnprintf _vsnprintf 186 | # endif 187 | # endif 188 | # ifdef __SASC 189 | # define NO_vsnprintf 190 | # endif 191 | #endif 192 | 193 | #ifdef HAVE_STRERROR 194 | extern char *strerror OF((int)); 195 | # define zstrerror(errnum) strerror(errnum) 196 | #else 197 | # define zstrerror(errnum) "" 198 | #endif 199 | 200 | #if defined(pyr) 201 | # define NO_MEMCPY 202 | #endif 203 | #if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__) 204 | /* Use our own functions for small and medium model with MSC <= 5.0. 205 | * You may have to use the same strategy for Borland C (untested). 206 | * The __SC__ check is for Symantec. 207 | */ 208 | # define NO_MEMCPY 209 | #endif 210 | #if defined(STDC) && !defined(HAVE_MEMCPY) && !defined(NO_MEMCPY) 211 | # define HAVE_MEMCPY 212 | #endif 213 | #ifdef HAVE_MEMCPY 214 | # ifdef SMALL_MEDIUM /* MSDOS small or medium model */ 215 | # define zmemcpy _fmemcpy 216 | # define zmemcmp _fmemcmp 217 | # define zmemzero(dest, len) _fmemset(dest, 0, len) 218 | # else 219 | # define zmemcpy memcpy 220 | # define zmemcmp memcmp 221 | # define zmemzero(dest, len) memset(dest, 0, len) 222 | # endif 223 | #else 224 | extern void zmemcpy OF((Bytef* dest, const Bytef* source, uInt len)); 225 | extern int zmemcmp OF((const Bytef* s1, const Bytef* s2, uInt len)); 226 | extern void zmemzero OF((Bytef* dest, uInt len)); 227 | #endif 228 | 229 | /* Diagnostic functions */ 230 | #ifdef DEBUG 231 | # include 232 | extern int z_verbose; 233 | extern void z_error OF((char *m)); 234 | # define Assert(cond,msg) {if(!(cond)) z_error(msg);} 235 | # define Trace(x) {if (z_verbose>=0) fprintf x ;} 236 | # define Tracev(x) {if (z_verbose>0) fprintf x ;} 237 | # define Tracevv(x) {if (z_verbose>1) fprintf x ;} 238 | # define Tracec(c,x) {if (z_verbose>0 && (c)) fprintf x ;} 239 | # define Tracecv(c,x) {if (z_verbose>1 && (c)) fprintf x ;} 240 | #else 241 | # define Assert(cond,msg) 242 | # define Trace(x) 243 | # define Tracev(x) 244 | # define Tracevv(x) 245 | # define Tracec(c,x) 246 | # define Tracecv(c,x) 247 | #endif 248 | 249 | 250 | voidpf zcalloc OF((voidpf opaque, unsigned items, unsigned size)); 251 | void zcfree OF((voidpf opaque, voidpf ptr)); 252 | 253 | #define ZALLOC(strm, items, size) \ 254 | (*((strm)->zalloc))((strm)->opaque, (items), (size)) 255 | #define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr)) 256 | #define TRY_FREE(s, p) {if (p) ZFREE(s, p);} 257 | 258 | #endif /* ZUTIL_H */ 259 | -------------------------------------------------------------------------------- /zsglobal.h: -------------------------------------------------------------------------------- 1 | /* 2 | * zsync - client side rsync over http 3 | * Copyright (C) 2004,2005,2007,2009 Colin Phipps 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the Artistic License v2 (see the accompanying 7 | * file COPYING for the full license terms), or, at your option, any later 8 | * version of the same license. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * COPYING file for details. 14 | */ 15 | 16 | #ifndef ZSGLOBAL_H 17 | #define ZSGLOBAL_H 18 | 19 | 20 | #ifdef HAVE_CONFIG_H 21 | # include "config.h" 22 | #endif 23 | 24 | #if defined(__GNUC__) && defined (__OpenBSD__) 25 | # define ZS_DECL_BOUNDED(x,y,z) __attribute__((__bounded__(x,y,z))) 26 | #else 27 | # define ZS_DECL_BOUNDED(x,y,z) 28 | #endif /* ZS_DECL_BOUNDED */ 29 | 30 | #endif 31 | --------------------------------------------------------------------------------