├── hw02 ├── wget-1.15 │ ├── .version │ ├── .tarball-version │ ├── po │ │ ├── stamp-po │ │ ├── be.gmo │ │ ├── bg.gmo │ │ ├── ca.gmo │ │ ├── cs.gmo │ │ ├── da.gmo │ │ ├── da.po │ │ ├── de.gmo │ │ ├── el.gmo │ │ ├── eo.gmo │ │ ├── es.gmo │ │ ├── et.gmo │ │ ├── eu.gmo │ │ ├── fi.gmo │ │ ├── fr.gmo │ │ ├── ga.gmo │ │ ├── ga.po │ │ ├── gl.gmo │ │ ├── he.gmo │ │ ├── he.po │ │ ├── hr.gmo │ │ ├── hu.gmo │ │ ├── id.gmo │ │ ├── it.gmo │ │ ├── ja.gmo │ │ ├── lt.gmo │ │ ├── nb.gmo │ │ ├── nb.po │ │ ├── nl.gmo │ │ ├── pl.gmo │ │ ├── pt.gmo │ │ ├── ro.gmo │ │ ├── ro.po │ │ ├── ru.gmo │ │ ├── sk.gmo │ │ ├── sl.gmo │ │ ├── sl.po │ │ ├── sr.gmo │ │ ├── sv.gmo │ │ ├── tr.gmo │ │ ├── uk.gmo │ │ ├── vi.gmo │ │ ├── en_GB.gmo │ │ ├── pt_BR.gmo │ │ ├── zh_CN.gmo │ │ ├── zh_TW.gmo │ │ ├── quot.sed │ │ ├── boldquot.sed │ │ ├── LINGUAS │ │ ├── remove-potcdate.sin │ │ ├── insert-header.sin │ │ ├── POTFILES.in │ │ ├── en@quot.header │ │ └── en@boldquot.header │ ├── lib │ │ ├── pipe.h │ │ ├── xsize.c │ │ ├── unistd.c │ │ ├── binary-io.c │ │ ├── stat-time.c │ │ ├── timespec.c │ │ ├── sig-handler.c │ │ ├── sys_socket.c │ │ ├── wctype-h.c │ │ ├── rawmemchr.valgrind │ │ ├── strchrnul.valgrind │ │ ├── memchr.valgrind │ │ ├── exitfail.h │ │ ├── exitfail.c │ │ ├── mbtowc.c │ │ ├── ref-del.sin │ │ ├── getline.c │ │ ├── ref-add.sin │ │ ├── spawnattr_destroy.c │ │ ├── waitpid.c │ │ ├── unistd--.h │ │ ├── itold.c │ │ ├── fseek.c │ │ ├── unistd-safer.h │ │ ├── dup-safer.c │ │ ├── asnprintf.c │ │ ├── spawn_faction_destroy.c │ │ ├── getpass.h │ │ ├── asprintf.c │ │ ├── btowc.c │ │ ├── spawnattr_init.c │ │ ├── secure_getenv.c │ │ ├── size_max.h │ │ ├── spawnattr_setsigmask.c │ │ ├── ftell.c │ │ ├── tmpdir.h │ │ ├── spawnp.c │ │ ├── gettime.c │ │ ├── listen.c │ │ ├── dup-safer-flag.c │ │ ├── float.c │ │ ├── localcharset.h │ │ ├── recv.c │ │ ├── xalloc-die.c │ │ ├── bind.c │ │ └── send.c │ ├── doc │ │ ├── stamp-vti │ │ └── version.texi │ ├── tests │ │ ├── WgetFeature.cfg │ │ ├── Test--post-file.px │ │ ├── WgetFeature.pm │ │ ├── certs │ │ │ ├── server-key.pem │ │ │ └── server-cert.pem │ │ ├── Test-ftp.px │ │ ├── Test-auth-retcode.px │ │ ├── Test-nonexisting-quiet.px │ │ ├── Test-O.px │ │ ├── Test-O-nc.px │ │ ├── Test-O-nonexisting.px │ │ ├── HTTPTest.pm │ │ ├── Test-ftp-iri-recursive.px │ │ ├── Test-ftp-iri.px │ │ ├── Test--spider.px │ │ ├── Test-stdouterr.px │ │ ├── Test-ftp-iri-fallback.px │ │ ├── Test--spider-fail.px │ │ ├── Test-O--no-content-disposition-trivial.px │ │ ├── Test-O-HTTP-Content-Disposition.px │ │ ├── Test-N.px │ │ ├── Test-ftp-recursive.px │ │ ├── Test-noop.px │ │ ├── Test-O--no-content-disposition.px │ │ ├── Test-ftp-iri-disabled.px │ │ ├── Test-Restrict-Lowercase.px │ │ ├── Test-Restrict-Uppercase.px │ │ ├── Test-auth-basic.px │ │ ├── Test--no-content-disposition-trivial.px │ │ ├── Test-cookies-401.px │ │ ├── Test-N--no-content-disposition-trivial.px │ │ ├── Test-proxy-auth-basic.px │ │ ├── Test-auth-no-challenge-url.px │ │ ├── FTPTest.pm │ │ └── Test--no-content-disposition.px │ ├── m4 │ │ ├── xalloc.m4 │ │ ├── quotearg.m4 │ │ ├── timespec.m4 │ │ ├── msvc-nothrow.m4 │ │ ├── tmpdir.m4 │ │ ├── unistd-safer.m4 │ │ ├── quote.m4 │ │ ├── spawn-pipe.m4 │ │ ├── xsize.m4 │ │ ├── waitpid.m4 │ │ ├── wait-process.m4 │ │ ├── fatal-signal.m4 │ │ ├── base32.m4 │ │ ├── md5.m4 │ │ ├── sha1.m4 │ │ ├── gettime.m4 │ │ ├── sockets.m4 │ │ ├── mbtowc.m4 │ │ ├── fseek.m4 │ │ ├── ftell.m4 │ │ ├── off_t.m4 │ │ ├── pipe2.m4 │ │ ├── tempname.m4 │ │ ├── dirname.m4 │ │ ├── sig_atomic_t.m4 │ │ ├── localcharset.m4 │ │ ├── localeconv.m4 │ │ ├── mkostemp.m4 │ │ ├── rawmemchr.m4 │ │ ├── sys_types_h.m4 │ │ ├── msvc-inval.m4 │ │ ├── secure_getenv.m4 │ │ ├── ssize_t.m4 │ │ ├── wchar_t.m4 │ │ ├── codeset.m4 │ │ ├── error.m4 │ │ ├── sigpipe.m4 │ │ ├── signalblocking.m4 │ │ ├── glibc21.m4 │ │ ├── sys_uio_h.m4 │ │ ├── eealloc.m4 │ │ ├── fstat.m4 │ │ ├── stdint_h.m4 │ │ ├── raise.m4 │ │ ├── write.m4 │ │ ├── inttypes_h.m4 │ │ ├── wint_t.m4 │ │ ├── netinet_in_h.m4 │ │ ├── strcase.m4 │ │ ├── close.m4 │ │ ├── sched_h.m4 │ │ ├── vasprintf.m4 │ │ ├── nls.m4 │ │ ├── pathmax.m4 │ │ ├── sys_wait_h.m4 │ │ ├── mode_t.m4 │ │ ├── sigaction.m4 │ │ ├── utimbuf.m4 │ │ ├── 00gnulib.m4 │ │ └── clock_time.m4 │ ├── build-aux │ │ └── snippet │ │ │ ├── _Noreturn.h │ │ │ └── arg-nonnull.h │ ├── src │ │ ├── build_info.c.in │ │ ├── exits.h │ │ ├── warc.h │ │ └── build_info.c │ ├── util │ │ ├── README │ │ └── Makefile.am │ └── ChangeLog.README └── find_track.c ├── lecture14 ├── Makefile └── graph_data.py ├── README.md ├── lecture19 ├── Makefile ├── mutex.h └── mutex.c ├── lecture21 └── Makefile ├── lecture18 ├── Makefile └── simple2threads.c ├── .gitignore ├── hw04 ├── wave3 │ └── reverse.py └── wave2 │ └── wave2.ino ├── hw03 ├── test1.c ├── test_rand2.c ├── check_uniform.py └── Makefile ├── roman ├── soln │ ├── str_echo08.c │ ├── str_cli08.c │ ├── Makefile │ ├── writen.c │ ├── wraplib.c │ ├── wrapstdio.c │ ├── tcpcli01.c │ ├── readline.c │ └── tcpserv01.c ├── str_cli08.c ├── str_echo08.c ├── tcpcli01.c ├── Makefile ├── writen.c ├── wraplib.c ├── tcpserv01.c ├── wrapstdio.c └── readline.c ├── lecture24 ├── Makefile └── mem_errors.c ├── lecture04 └── aspace.c ├── lecture23 ├── semaphore.h ├── soln │ └── Makefile └── Makefile ├── lecture03 ├── quiz01_bad.c └── stack.c ├── lecture08 ├── strjoin.c └── strjoin_soln.c ├── lecture06 └── interleave.c ├── exam1 └── center.c └── lecture13 └── rational.c /hw02/wget-1.15/.version: -------------------------------------------------------------------------------- 1 | 1.15 2 | -------------------------------------------------------------------------------- /hw02/wget-1.15/.tarball-version: -------------------------------------------------------------------------------- 1 | 1.15 2 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/stamp-po: -------------------------------------------------------------------------------- 1 | timestamp 2 | -------------------------------------------------------------------------------- /lecture14/Makefile: -------------------------------------------------------------------------------- 1 | cache: cache.c 2 | gcc -o cache cache.c 3 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/pipe.h: -------------------------------------------------------------------------------- 1 | /* Obsolete; consider using spawn-pipe.h instead. */ 2 | #include "spawn-pipe.h" 3 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/be.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/be.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/bg.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/bg.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ca.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ca.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/cs.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/cs.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/da.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/da.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/da.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/da.po -------------------------------------------------------------------------------- /hw02/wget-1.15/po/de.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/de.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/el.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/el.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/eo.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/eo.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/es.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/es.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/et.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/et.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/eu.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/eu.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/fi.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/fi.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/fr.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/fr.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ga.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ga.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ga.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ga.po -------------------------------------------------------------------------------- /hw02/wget-1.15/po/gl.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/gl.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/he.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/he.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/he.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/he.po -------------------------------------------------------------------------------- /hw02/wget-1.15/po/hr.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/hr.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/hu.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/hu.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/id.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/id.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/it.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/it.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ja.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ja.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/lt.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/lt.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/nb.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/nb.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/nb.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/nb.po -------------------------------------------------------------------------------- /hw02/wget-1.15/po/nl.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/nl.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/pl.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/pl.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/pt.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/pt.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ro.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ro.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ro.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ro.po -------------------------------------------------------------------------------- /hw02/wget-1.15/po/ru.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/ru.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/sk.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/sk.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/sl.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/sl.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/sl.po: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/sl.po -------------------------------------------------------------------------------- /hw02/wget-1.15/po/sr.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/sr.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/sv.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/sv.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/tr.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/tr.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/uk.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/uk.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/vi.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/vi.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/xsize.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define XSIZE_INLINE _GL_EXTERN_INLINE 3 | #include "xsize.h" 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/en_GB.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/en_GB.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/pt_BR.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/pt_BR.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/zh_CN.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/zh_CN.gmo -------------------------------------------------------------------------------- /hw02/wget-1.15/po/zh_TW.gmo: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/AllenDowney/SoftwareSystems/HEAD/hw02/wget-1.15/po/zh_TW.gmo -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | SoftwareSystems 2 | =============== 3 | 4 | Repo for software related to Software Systems at Olin College. 5 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/unistd.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define _GL_UNISTD_INLINE _GL_EXTERN_INLINE 3 | #include "unistd.h" 4 | -------------------------------------------------------------------------------- /lecture19/Makefile: -------------------------------------------------------------------------------- 1 | pthreadlock: array.c mutex.c mutex.h 2 | gcc -Wall array.c mutex.c -o pthreadlock -lpthread 3 | 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/binary-io.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define BINARY_IO_INLINE _GL_EXTERN_INLINE 3 | #include "binary-io.h" 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/stat-time.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define _GL_STAT_TIME_INLINE _GL_EXTERN_INLINE 3 | #include "stat-time.h" 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/timespec.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define _GL_TIMESPEC_INLINE _GL_EXTERN_INLINE 3 | #include "timespec.h" 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/sig-handler.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define SIG_HANDLER_INLINE _GL_EXTERN_INLINE 3 | #include "sig-handler.h" 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/sys_socket.c: -------------------------------------------------------------------------------- 1 | #include 2 | #define _GL_SYS_SOCKET_INLINE _GL_EXTERN_INLINE 3 | #include "sys/socket.h" 4 | -------------------------------------------------------------------------------- /hw02/wget-1.15/doc/stamp-vti: -------------------------------------------------------------------------------- 1 | @set UPDATED 4 January 2014 2 | @set UPDATED-MONTH January 2014 3 | @set EDITION 1.15 4 | @set VERSION 1.15 5 | -------------------------------------------------------------------------------- /hw02/wget-1.15/doc/version.texi: -------------------------------------------------------------------------------- 1 | @set UPDATED 4 January 2014 2 | @set UPDATED-MONTH January 2014 3 | @set EDITION 1.15 4 | @set VERSION 1.15 5 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/quot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | -------------------------------------------------------------------------------- /lecture21/Makefile: -------------------------------------------------------------------------------- 1 | 2 | counter: counter.c 3 | gcc -Wall -o counter counter.c -lpthread 4 | 5 | counter_mutex: counter_mutex.c 6 | gcc -Wall -o counter_mutex counter_mutex.c -lpthread 7 | 8 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/wctype-h.c: -------------------------------------------------------------------------------- 1 | /* Normally this would be wctype.c, but that name's already taken. */ 2 | #include 3 | #define _GL_WCTYPE_INLINE _GL_EXTERN_INLINE 4 | #include "wctype.h" 5 | -------------------------------------------------------------------------------- /lecture18/Makefile: -------------------------------------------------------------------------------- 1 | simple2threads: simple2threads.c 2 | gcc -o simple2threads simple2threads.c -lpthread 3 | 4 | pthread_example: pthread_example.c 5 | gcc -o pthread_example pthread_example.c -lpthread 6 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/WgetFeature.cfg: -------------------------------------------------------------------------------- 1 | %skip_messages = ( 2 | https => "Not running test: Wget under test doesn't support HTTPS.", 3 | iri => "Not running test: Wget under test doesn't support IDN/IRI.", 4 | ); 5 | 6 | 1; 7 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Object files 2 | *.o 3 | *.ko 4 | 5 | # Libraries 6 | *.lib 7 | *.a 8 | 9 | # Shared objects (inc. Windows DLLs) 10 | *.dll 11 | *.so 12 | *.so.* 13 | *.dylib 14 | 15 | # Executables 16 | *.exe 17 | *.out 18 | *.app 19 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/boldquot.sed: -------------------------------------------------------------------------------- 1 | s/"\([^"]*\)"/“\1”/g 2 | s/`\([^`']*\)'/‘\1’/g 3 | s/ '\([^`']*\)' / ‘\1’ /g 4 | s/ '\([^`']*\)'$/ ‘\1’/g 5 | s/^'\([^`']*\)' /‘\1’ /g 6 | s/“”/""/g 7 | s/“/“/g 8 | s/”/”/g 9 | s/‘/‘/g 10 | s/’/’/g 11 | -------------------------------------------------------------------------------- /hw04/wave3/reverse.py: -------------------------------------------------------------------------------- 1 | print 'int reverse1[] = {' 2 | for i in range(64): 3 | s = bin(i)[2:].zfill(6) 4 | print '%d,' % int(s[::-1], 2), 5 | print '};' 6 | 7 | print 'int reverse2[] = {' 8 | for i in [0, 2, 1, 3]: 9 | print '%d,' % (i * 64), 10 | print '};' 11 | 12 | -------------------------------------------------------------------------------- /hw03/test1.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "rand.c" 5 | 6 | main (int argc, char *argv[]) 7 | { 8 | int i; 9 | double x; 10 | 11 | srandom (time (NULL)); 12 | 13 | for (i=0; i<10000; i++) { 14 | x = my_random_double(); 15 | printf ("%lf\n", x); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/LINGUAS: -------------------------------------------------------------------------------- 1 | be 2 | bg 3 | ca 4 | cs 5 | da 6 | de 7 | el 8 | en_GB 9 | eo 10 | es 11 | et 12 | eu 13 | fi 14 | fr 15 | ga 16 | gl 17 | he 18 | hr 19 | hu 20 | id 21 | it 22 | ja 23 | lt 24 | nb 25 | nl 26 | pl 27 | pt 28 | pt_BR 29 | ro 30 | ru 31 | sk 32 | sl 33 | sr 34 | sv 35 | tr 36 | uk 37 | vi 38 | zh_CN 39 | zh_TW 40 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/rawmemchr.valgrind: -------------------------------------------------------------------------------- 1 | # Suppress a valgrind message about use of uninitialized memory in rawmemchr(). 2 | # This use is OK because it provides only a speedup. 3 | { 4 | rawmemchr-value4 5 | Memcheck:Value4 6 | fun:rawmemchr 7 | } 8 | { 9 | rawmemchr-value8 10 | Memcheck:Value8 11 | fun:rawmemchr 12 | } 13 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/strchrnul.valgrind: -------------------------------------------------------------------------------- 1 | # Suppress a valgrind message about use of uninitialized memory in strchrnul(). 2 | # This use is OK because it provides only a speedup. 3 | { 4 | strchrnul-value4 5 | Memcheck:Value4 6 | fun:strchrnul 7 | } 8 | { 9 | strchrnul-value8 10 | Memcheck:Value8 11 | fun:strchrnul 12 | } 13 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/xalloc.m4: -------------------------------------------------------------------------------- 1 | # xalloc.m4 serial 18 2 | dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_XALLOC], [:]) 8 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/quotearg.m4: -------------------------------------------------------------------------------- 1 | # quotearg.m4 serial 9 2 | dnl Copyright (C) 2002, 2004-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_QUOTEARG], 8 | [ 9 | : 10 | ]) 11 | -------------------------------------------------------------------------------- /roman/soln/str_echo08.c: -------------------------------------------------------------------------------- 1 | #include "unp.h" 2 | 3 | void 4 | str_echo(int sockfd) 5 | { 6 | ssize_t n; 7 | char line[MAXLINE]; 8 | 9 | for ( ; ; ) { 10 | if ( (n = Readline(sockfd, line, MAXLINE)) == 0) 11 | return; /* connection closed by other end */ 12 | 13 | printf("Received %s\n", line); 14 | 15 | n = strlen(line); 16 | Writen(sockfd, line, n); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /hw02/wget-1.15/build-aux/snippet/_Noreturn.h: -------------------------------------------------------------------------------- 1 | #if !defined _Noreturn && __STDC_VERSION__ < 201112 2 | # if (3 <= __GNUC__ || (__GNUC__ == 2 && 8 <= __GNUC_MINOR__) \ 3 | || 0x5110 <= __SUNPRO_C) 4 | # define _Noreturn __attribute__ ((__noreturn__)) 5 | # elif 1200 <= _MSC_VER 6 | # define _Noreturn __declspec (noreturn) 7 | # else 8 | # define _Noreturn 9 | # endif 10 | #endif 11 | -------------------------------------------------------------------------------- /lecture19/mutex.h: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2012 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | 10 | typedef struct { 11 | int value; 12 | pthread_mutex_t mutex[1]; 13 | } Lock; 14 | 15 | Lock *make_lock (); 16 | void acquire (Lock *lock); 17 | void release (Lock *lock); 18 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/timespec.m4: -------------------------------------------------------------------------------- 1 | #serial 15 2 | 3 | # Copyright (C) 2000-2001, 2003-2007, 2009-2013 Free Software Foundation, Inc. 4 | 5 | # This file is free software; the Free Software Foundation 6 | # gives unlimited permission to copy and/or distribute it, 7 | # with or without modifications, as long as this notice is preserved. 8 | 9 | dnl From Jim Meyering 10 | 11 | AC_DEFUN([gl_TIMESPEC], [:]) 12 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/msvc-nothrow.m4: -------------------------------------------------------------------------------- 1 | # msvc-nothrow.m4 serial 1 2 | dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_MSVC_NOTHROW], 8 | [ 9 | AC_REQUIRE([gl_MSVC_INVAL]) 10 | ]) 11 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/tmpdir.m4: -------------------------------------------------------------------------------- 1 | # tmpdir.m4 serial 4 2 | dnl Copyright (C) 2001-2002, 2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Prerequisites for lib/tmpdir.c 8 | 9 | AC_DEFUN([gt_TMPDIR], [:]) 10 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/unistd-safer.m4: -------------------------------------------------------------------------------- 1 | #serial 9 2 | dnl Copyright (C) 2002, 2005-2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_UNISTD_SAFER], 8 | [ 9 | AC_CHECK_FUNCS_ONCE([pipe]) 10 | ]) 11 | -------------------------------------------------------------------------------- /roman/str_cli08.c: -------------------------------------------------------------------------------- 1 | #include "unp.h" 2 | 3 | void 4 | str_cli(FILE *fp, int sockfd) 5 | { 6 | char sendline[MAXLINE], recvline[MAXLINE]; 7 | 8 | while (Fgets(sendline, MAXLINE, fp) != NULL) { 9 | 10 | Writen(sockfd, sendline, strlen(sendline)); 11 | 12 | if (Readline(sockfd, recvline, MAXLINE) == 0) 13 | err_quit("str_cli: server terminated prematurely"); 14 | 15 | Fputs(recvline, stdout); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /roman/soln/str_cli08.c: -------------------------------------------------------------------------------- 1 | #include "unp.h" 2 | 3 | void 4 | str_cli(FILE *fp, int sockfd) 5 | { 6 | char sendline[MAXLINE], recvline[MAXLINE]; 7 | 8 | while (Fgets(sendline, MAXLINE, fp) != NULL) { 9 | 10 | Writen(sockfd, sendline, strlen(sendline)); 11 | 12 | if (Readline(sockfd, recvline, MAXLINE) == 0) 13 | err_quit("str_cli: server terminated prematurely"); 14 | 15 | Fputs(recvline, stdout); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/quote.m4: -------------------------------------------------------------------------------- 1 | # quote.m4 serial 6 2 | dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | AC_DEFUN([gl_QUOTE], 9 | [ 10 | dnl Prerequisites of lib/quote.c. 11 | dnl (none) 12 | : 13 | ]) 14 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/spawn-pipe.m4: -------------------------------------------------------------------------------- 1 | # spawn-pipe.m4 serial 2 2 | dnl Copyright (C) 2004, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_SPAWN_PIPE], 8 | [ 9 | dnl Prerequisites of lib/spawn-pipe.c. 10 | AC_REQUIRE([AC_TYPE_MODE_T]) 11 | ]) 12 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/xsize.m4: -------------------------------------------------------------------------------- 1 | # xsize.m4 serial 5 2 | dnl Copyright (C) 2003-2004, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_XSIZE], 8 | [ 9 | dnl Prerequisites of lib/xsize.h. 10 | AC_REQUIRE([gl_SIZE_MAX]) 11 | AC_CHECK_HEADERS([stdint.h]) 12 | ]) 13 | -------------------------------------------------------------------------------- /hw02/wget-1.15/src/build_info.c.in: -------------------------------------------------------------------------------- 1 | digest defined ENABLE_DIGEST 2 | https defined HAVE_SSL 3 | ipv6 defined ENABLE_IPV6 4 | iri defined ENABLE_IRI 5 | large-file SIZEOF_OFF_T >= 8 6 | 7 | nls defined ENABLE_NLS 8 | ntlm defined ENABLE_NTLM 9 | opie defined ENABLE_OPIE 10 | 11 | ssl choice: 12 | openssl defined HAVE_LIBSSL || defined HAVE_LIBSSL32 13 | gnutls defined HAVE_LIBGNUTLS 14 | -------------------------------------------------------------------------------- /lecture24/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -g -Wall 3 | LIBS = -lglib-2.0 4 | DEPS = 5 | OBJ = glibhash.o 6 | 7 | mem_errors: mem_errors.c 8 | gcc $(CFLAGS) -o mem_errors mem_errors.c 9 | 10 | list_errors: list_errors.c 11 | gcc $(CFLAGS) -o list_errors list_errors.c 12 | 13 | valgrind: 14 | G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --log-file=vgdump --show-reachable=yes ./mem_errors 15 | 16 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/waitpid.m4: -------------------------------------------------------------------------------- 1 | # waitpid.m4 serial 2 2 | dnl Copyright (C) 2010-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_WAITPID], 8 | [ 9 | AC_REQUIRE([AC_CANONICAL_HOST]) 10 | HAVE_WAITPID=1 11 | case $host_os in 12 | mingw*) HAVE_WAITPID=0 ;; 13 | esac 14 | ]) 15 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/wait-process.m4: -------------------------------------------------------------------------------- 1 | # wait-process.m4 serial 6 2 | dnl Copyright (C) 2003, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_WAIT_PROCESS], 8 | [ 9 | dnl Prerequisites of lib/wait-process.c. 10 | AC_REQUIRE([gt_TYPE_SIG_ATOMIC_T]) 11 | AC_CHECK_FUNCS([waitid]) 12 | ]) 13 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/fatal-signal.m4: -------------------------------------------------------------------------------- 1 | # fatal-signal.m4 serial 9 2 | dnl Copyright (C) 2003-2004, 2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FATAL_SIGNAL], 8 | [ 9 | AC_REQUIRE([gt_TYPE_SIG_ATOMIC_T]) 10 | AC_CHECK_HEADERS_ONCE([unistd.h]) 11 | gl_PREREQ_SIG_HANDLER_H 12 | ]) 13 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/memchr.valgrind: -------------------------------------------------------------------------------- 1 | # Suppress a valgrind message about use of uninitialized memory in memchr(). 2 | # POSIX states that when the character is found, memchr must not read extra 3 | # bytes in an overestimated length (for example, where memchr is used to 4 | # implement strnlen). However, we use a safe word read to provide a speedup. 5 | { 6 | memchr-value4 7 | Memcheck:Value4 8 | fun:rpl_memchr 9 | } 10 | { 11 | memchr-value8 12 | Memcheck:Value8 13 | fun:rpl_memchr 14 | } 15 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/base32.m4: -------------------------------------------------------------------------------- 1 | # base32.m4 serial 4 2 | dnl Copyright (C) 2004, 2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_BASE32], 8 | [ 9 | gl_PREREQ_BASE32 10 | ]) 11 | 12 | # Prerequisites of lib/base32.c. 13 | AC_DEFUN([gl_PREREQ_BASE32], [ 14 | AC_REQUIRE([AC_C_RESTRICT]) 15 | ]) 16 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/md5.m4: -------------------------------------------------------------------------------- 1 | # md5.m4 serial 14 2 | dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_MD5], 8 | [ 9 | dnl Prerequisites of lib/md5.c. 10 | AC_REQUIRE([gl_BIGENDIAN]) 11 | 12 | dnl Determine HAVE_OPENSSL_MD5 and LIB_CRYPTO 13 | gl_CRYPTO_CHECK([MD5]) 14 | ]) 15 | -------------------------------------------------------------------------------- /lecture04/aspace.c: -------------------------------------------------------------------------------- 1 | /* Example code for Think OS. 2 | 3 | Copyright 2014 Allen Downey 4 | License: GNU GPLv3 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | int global; 12 | 13 | int main () 14 | { 15 | int local = 5; 16 | void *p = malloc(128); 17 | 18 | printf ("Address of main is %p\n", main); 19 | printf ("Address of global is %p\n", &global); 20 | printf ("Address of local is %p\n", &local); 21 | printf ("Address of p is %p\n", p); 22 | 23 | return 0; 24 | } 25 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sha1.m4: -------------------------------------------------------------------------------- 1 | # sha1.m4 serial 12 2 | dnl Copyright (C) 2002-2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_SHA1], 8 | [ 9 | dnl Prerequisites of lib/sha1.c. 10 | AC_REQUIRE([gl_BIGENDIAN]) 11 | 12 | dnl Determine HAVE_OPENSSL_SHA1 and LIB_CRYPTO 13 | gl_CRYPTO_CHECK([SHA1]) 14 | ]) 15 | -------------------------------------------------------------------------------- /hw03/test_rand2.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "rand.c" 11 | 12 | main (int argc, char *argv[]) 13 | { 14 | int i; 15 | float f; 16 | double t0, t1; 17 | int iters = 1000; 18 | int seed = 17; 19 | 20 | srandom (seed); 21 | 22 | for (i=0; i"); 11 | 12 | sockfd = Socket(AF_INET, SOCK_STREAM, 0); 13 | 14 | bzero(&servaddr, sizeof(servaddr)); 15 | servaddr.sin_family = AF_INET; 16 | servaddr.sin_port = htons(SERV_PORT); 17 | Inet_pton(AF_INET, argv[1], &servaddr.sin_addr); 18 | 19 | Connect(sockfd, (SA *) &servaddr, sizeof(servaddr)); 20 | 21 | str_cli(stdin, sockfd); /* do it all */ 22 | 23 | exit(0); 24 | } 25 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/fseek.m4: -------------------------------------------------------------------------------- 1 | # fseek.m4 serial 4 2 | dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_FSEEK], 8 | [ 9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 10 | AC_REQUIRE([gl_FUNC_FSEEKO]) 11 | dnl When fseeko needs fixes, fseek needs them too. 12 | if test $HAVE_FSEEKO = 0 || test $REPLACE_FSEEKO = 1; then 13 | REPLACE_FSEEK=1 14 | fi 15 | ]) 16 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/ftell.m4: -------------------------------------------------------------------------------- 1 | # ftell.m4 serial 3 2 | dnl Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_FTELL], 8 | [ 9 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 10 | AC_REQUIRE([gl_FUNC_FTELLO]) 11 | dnl When ftello needs fixes, ftell needs them too. 12 | if test $HAVE_FTELLO = 0 || test $REPLACE_FTELLO = 1; then 13 | REPLACE_FTELL=1 14 | fi 15 | ]) 16 | -------------------------------------------------------------------------------- /lecture14/graph_data.py: -------------------------------------------------------------------------------- 1 | import thinkplot 2 | import matplotlib.pyplot as pyplot 3 | 4 | d = {} 5 | for line in open('data'): 6 | t = line.split() 7 | size, stride, time = int(t[1]), int(t[3]), float(t[5]) 8 | d.setdefault(stride, []).append((size, time)) 9 | 10 | 11 | thinkplot.PrePlot(num=7) 12 | for stride in sorted(d.keys()): 13 | if stride >= 512: continue 14 | 15 | xs, ys = zip(*d[stride]) 16 | thinkplot.plot(xs, ys, label=str(stride)) 17 | print stride, len(d[stride]) 18 | 19 | pyplot.xscale('log', basex=2) 20 | thinkplot.show(xlabel='size (B)', ylabel='access time (ns)') 21 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/off_t.m4: -------------------------------------------------------------------------------- 1 | # off_t.m4 serial 1 2 | dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl Check whether to override the 'off_t' type. 8 | dnl Set WINDOWS_64_BIT_OFF_T. 9 | 10 | AC_DEFUN([gl_TYPE_OFF_T], 11 | [ 12 | m4_ifdef([gl_LARGEFILE], [ 13 | AC_REQUIRE([gl_LARGEFILE]) 14 | ], [ 15 | WINDOWS_64_BIT_OFF_T=0 16 | ]) 17 | AC_SUBST([WINDOWS_64_BIT_OFF_T]) 18 | ]) 19 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/pipe2.m4: -------------------------------------------------------------------------------- 1 | # pipe2.m4 serial 2 2 | dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_PIPE2], 8 | [ 9 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 10 | 11 | dnl Persuade glibc to declare pipe2(). 12 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 13 | 14 | AC_CHECK_FUNCS_ONCE([pipe2]) 15 | if test $ac_cv_func_pipe2 != yes; then 16 | HAVE_PIPE2=0 17 | fi 18 | ]) 19 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/tempname.m4: -------------------------------------------------------------------------------- 1 | #serial 5 2 | 3 | # Copyright (C) 2006-2007, 2009-2013 Free Software Foundation, Inc. 4 | # This file is free software; the Free Software Foundation 5 | # gives unlimited permission to copy and/or distribute it, 6 | # with or without modifications, as long as this notice is preserved. 7 | 8 | # glibc provides __gen_tempname as a wrapper for mk[ds]temp. Expose 9 | # it as a public API, and provide it on systems that are lacking. 10 | AC_DEFUN([gl_FUNC_GEN_TEMPNAME], 11 | [ 12 | gl_PREREQ_TEMPNAME 13 | ]) 14 | 15 | # Prerequisites of lib/tempname.c. 16 | AC_DEFUN([gl_PREREQ_TEMPNAME], 17 | [ 18 | : 19 | ]) 20 | -------------------------------------------------------------------------------- /lecture23/soln/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -g -Wall -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 3 | LIBS = -lglib-2.0 4 | DEPS = 5 | OBJ = glibhash.o 6 | 7 | %.o: %.c $(DEPS) 8 | $(CC) -c -o $@ $< $(CFLAGS) 9 | 10 | glibhash: $(OBJ) 11 | gcc -o $@ $^ $(CFLAGS) $(LIBS) 12 | 13 | valgrind: 14 | G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --log-file=vgdump --show-reachable=yes ./glibhash 15 | 16 | tar: 17 | rm -rf hw20_soln 18 | mkdir hw20_soln 19 | cp glibhash.c Makefile emma.txt hw20_soln 20 | tar -czf hw20_soln.tgz hw20_soln -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/dirname.m4: -------------------------------------------------------------------------------- 1 | #serial 10 -*- autoconf -*- 2 | dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_DIRNAME], 8 | [ 9 | AC_REQUIRE([gl_DIRNAME_LGPL]) 10 | ]) 11 | 12 | AC_DEFUN([gl_DIRNAME_LGPL], 13 | [ 14 | dnl Prerequisites of lib/dirname.h. 15 | AC_REQUIRE([gl_DOUBLE_SLASH_ROOT]) 16 | 17 | dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c, 18 | dnl lib/stripslash.c. 19 | ]) 20 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sig_atomic_t.m4: -------------------------------------------------------------------------------- 1 | # sig_atomic_t.m4 serial 3 2 | dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gt_TYPE_SIG_ATOMIC_T], 8 | [ 9 | AC_CHECK_TYPES([sig_atomic_t], , 10 | [AC_DEFINE([sig_atomic_t], [int], 11 | [Define as an integer type suitable for memory locations that can be 12 | accessed atomically even in the presence of asynchronous signals.])], 13 | [#include ]) 14 | ]) 15 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/localcharset.m4: -------------------------------------------------------------------------------- 1 | # localcharset.m4 serial 7 2 | dnl Copyright (C) 2002, 2004, 2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_LOCALCHARSET], 8 | [ 9 | dnl Prerequisites of lib/localcharset.c. 10 | AC_REQUIRE([AM_LANGINFO_CODESET]) 11 | AC_REQUIRE([gl_FCNTL_O_FLAGS]) 12 | AC_CHECK_DECLS_ONCE([getc_unlocked]) 13 | 14 | dnl Prerequisites of the lib/Makefile.am snippet. 15 | AC_REQUIRE([AC_CANONICAL_HOST]) 16 | AC_REQUIRE([gl_GLIBC21]) 17 | ]) 18 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test--post-file.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $cmdline = $WgetTest::WGETPATH . " -d --post-file=nofile http://localhost:{{port}}/"; 12 | 13 | my $expected_error_code = 3; 14 | 15 | 16 | ############################################################################### 17 | 18 | my $the_test = HTTPTest->new (name => "Test-missing-file", 19 | cmdline => $cmdline, 20 | errcode => $expected_error_code); 21 | exit $the_test->run(); 22 | 23 | # vim: et ts=4 sw=4 24 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/WgetFeature.pm: -------------------------------------------------------------------------------- 1 | package WgetFeature; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use WgetTest; 7 | 8 | our %skip_messages; 9 | require 'WgetFeature.cfg'; 10 | 11 | sub import 12 | { 13 | my ($class, $feature) = @_; 14 | 15 | my $output = `$WgetTest::WGETPATH --version`; 16 | my ($list) = $output =~ /^([\+\-]\S+(?:\s+[\+\-]\S+)+)/m; 17 | my %have_features = map { 18 | my $feature = $_; 19 | $feature =~ s/^.//; 20 | ($feature, /^\+/ ? 1 : 0); 21 | } split /\s+/, $list; 22 | 23 | unless ($have_features{$feature}) { 24 | print $skip_messages{$feature}, "\n"; 25 | exit 2; # skip 26 | } 27 | } 28 | 29 | 1; 30 | -------------------------------------------------------------------------------- /hw03/check_uniform.py: -------------------------------------------------------------------------------- 1 | """This file contains code for use with "Think Stats", 2 | by Allen B. Downey, available from greenteapress.com 3 | 4 | Copyright 2014 Allen B. Downey 5 | License: GNU GPLv3 http://www.gnu.org/licenses/gpl.html 6 | """ 7 | 8 | import sys 9 | import thinkstats2 10 | import thinkplot 11 | 12 | def read_file(filename): 13 | t = [] 14 | for line in open(filename): 15 | x = float(line.rstrip()) 16 | t.append(x) 17 | return t 18 | 19 | def main(script, filename='data'): 20 | t = read_file(filename) 21 | cdf = thinkstats2.MakeCdfFromList(t) 22 | thinkplot.Cdf(cdf) 23 | thinkplot.Show() 24 | 25 | if __name__ == '__main__': 26 | main(*sys.argv) 27 | -------------------------------------------------------------------------------- /lecture19/mutex.c: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2012 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include "mutex.h" 15 | 16 | Lock *make_lock () 17 | { 18 | Lock *lock = (Lock *) malloc (sizeof(Lock)); 19 | pthread_mutex_init (lock->mutex, NULL); 20 | return lock; 21 | } 22 | 23 | void acquire (Lock *lock) 24 | { 25 | pthread_mutex_lock (lock->mutex); 26 | } 27 | 28 | void release (Lock *lock) 29 | { 30 | pthread_mutex_unlock (lock->mutex); 31 | } 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/localeconv.m4: -------------------------------------------------------------------------------- 1 | # localeconv.m4 serial 1 2 | dnl Copyright (C) 2012-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_LOCALECONV], 8 | [ 9 | AC_REQUIRE([gl_LOCALE_H_DEFAULTS]) 10 | AC_REQUIRE([gl_LOCALE_H]) 11 | 12 | if test $REPLACE_STRUCT_LCONV = 1; then 13 | REPLACE_LOCALECONV=1 14 | fi 15 | ]) 16 | 17 | # Prerequisites of lib/localeconv.c. 18 | AC_DEFUN([gl_PREREQ_LOCALECONV], 19 | [ 20 | AC_CHECK_MEMBERS([struct lconv.decimal_point], [], [], 21 | [[#include ]]) 22 | ]) 23 | -------------------------------------------------------------------------------- /lecture03/quiz01_bad.c: -------------------------------------------------------------------------------- 1 | /* Example code for Think OS. 2 | 3 | Copyright 2014 Allen Downey 4 | License: GNU GPLv3 5 | 6 | */ 7 | 8 | #include ; 9 | 10 | // Checks whether a character is a digit. 11 | int is_digit(char c) { 12 | return c >= '0' & c <= '9'; 13 | } 14 | 15 | // Checks whether a string is an integer (all digits). 16 | int is_integer(char *s) { 17 | int i = 0; 18 | 19 | while (s[i] != '0') { 20 | if (!is_digit(s[i])) 21 | return 0; 22 | } 23 | return 1; 24 | } 25 | 26 | int main() 27 | { 28 | char string[] = "123"; 29 | int number; 30 | 31 | if (is_integer(string)) 32 | number = atoi(string); 33 | printf("Your number is: %i\n", number); 34 | 35 | return 0; 36 | } 37 | -------------------------------------------------------------------------------- /roman/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -Wall 3 | WRAPPERS = wraplib.o wrapstdio.c wrapsock.o wrapunix.o error.o \ 4 | writen.c readline.c 5 | FILES = error.c str_cli08.c tcpserv01.c wrapsock.c writen.c \ 6 | Makefile str_echo08.c unp.h wrapstdio.c \ 7 | readline.c tcpcli01.c wraplib.c wrapunix.c 8 | 9 | 10 | tcpcli01: tcpcli01.o str_cli08.o ${WRAPPERS} 11 | ${CC} ${CFLAGS} -o $@ tcpcli01.o str_cli08.o ${WRAPPERS} 12 | 13 | tcpserv01: tcpserv01.o str_echo08.o 14 | ${CC} ${CFLAGS} -o $@ tcpserv01.o str_echo08.o ${WRAPPERS} 15 | 16 | distrib: 17 | rm -rf roman 18 | mkdir roman 19 | cp ${FILES} roman 20 | tar -czf ../roman.tgz roman 21 | rm -rf roman 22 | 23 | clean: 24 | rm *.o *~ tcpcli01 tcpserv01 -------------------------------------------------------------------------------- /hw02/wget-1.15/ChangeLog.README: -------------------------------------------------------------------------------- 1 | Please note that Wget has more than one ChangeLog file: 2 | 3 | ./ChangeLog: documents changes to files in the top-level directory 4 | and to files in subdirectories like po/ that don't have 5 | their own ChangeLogs 6 | 7 | src/ChangeLog: documents only changes to files in the src directory 8 | 9 | doc/ChangeLog: documents only changes to files in the doc directory 10 | 11 | windows/ChangeLog: documents only changes to files in the windows directory 12 | 13 | msdos/ChangeLog: documents only changes to files in the msdos directory 14 | 15 | When checking to see if a patch you sent in has been applied, please 16 | look in the appropriate ChangeLog(s). 17 | -------------------------------------------------------------------------------- /roman/soln/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -g -Wall 3 | WRAPPERS = wraplib.o wrapstdio.c wrapsock.o wrapunix.o error.o \ 4 | writen.c readline.c 5 | FILES = error.c str_cli08.c tcpserv01.c wrapsock.c writen.c \ 6 | Makefile str_echo08.c unp.h wrapstdio.c \ 7 | readline.c tcpcli01.c wraplib.c wrapunix.c 8 | 9 | 10 | tcpcli01: tcpcli01.o str_cli08.o ${WRAPPERS} 11 | ${CC} ${CFLAGS} -o $@ tcpcli01.o str_cli08.o ${WRAPPERS} 12 | 13 | tcpserv01: tcpserv01.o str_echo08.o 14 | ${CC} ${CFLAGS} -o $@ tcpserv01.o str_echo08.o ${WRAPPERS} 15 | 16 | distrib: 17 | rm -rf roman 18 | mkdir roman 19 | cp ${FILES} roman 20 | tar -czf ../roman.tgz roman 21 | rm -rf roman 22 | 23 | clean: 24 | rm *.o *~ tcpcli01 tcpserv01 -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/mkostemp.m4: -------------------------------------------------------------------------------- 1 | # mkostemp.m4 serial 2 2 | dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_MKOSTEMP], 8 | [ 9 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 10 | 11 | dnl Persuade glibc to declare mkostemp(). 12 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 13 | 14 | AC_CHECK_FUNCS_ONCE([mkostemp]) 15 | if test $ac_cv_func_mkostemp != yes; then 16 | HAVE_MKOSTEMP=0 17 | fi 18 | ]) 19 | 20 | # Prerequisites of lib/mkostemp.c. 21 | AC_DEFUN([gl_PREREQ_MKOSTEMP], 22 | [ 23 | ]) 24 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/rawmemchr.m4: -------------------------------------------------------------------------------- 1 | # rawmemchr.m4 serial 2 2 | dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_RAWMEMCHR], 8 | [ 9 | dnl Persuade glibc to declare rawmemchr(). 10 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 11 | 12 | AC_REQUIRE([gl_HEADER_STRING_H_DEFAULTS]) 13 | AC_CHECK_FUNCS([rawmemchr]) 14 | if test $ac_cv_func_rawmemchr = no; then 15 | HAVE_RAWMEMCHR=0 16 | fi 17 | ]) 18 | 19 | # Prerequisites of lib/strchrnul.c. 20 | AC_DEFUN([gl_PREREQ_RAWMEMCHR], [:]) 21 | -------------------------------------------------------------------------------- /lecture23/Makefile: -------------------------------------------------------------------------------- 1 | CC = gcc 2 | CFLAGS = -g -Wall -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 3 | LIBS = -lglib-2.0 4 | DEPS = 5 | OBJ = glibhash.o 6 | 7 | %.o: %.c $(DEPS) 8 | $(CC) -c -o $@ $< $(CFLAGS) 9 | 10 | counter: counter.c semaphore.c semaphore.h 11 | gcc -Wall -o counter counter.c semaphore.c -lpthread 12 | 13 | glibhash: $(OBJ) 14 | gcc -o $@ $^ $(CFLAGS) $(LIBS) 15 | 16 | valgrind: 17 | G_SLICE=always-malloc G_DEBUG=gc-friendly valgrind --tool=memcheck --leak-check=full --leak-resolution=high --num-callers=20 --log-file=vgdump --show-reachable=yes ./glibhash 18 | 19 | tar: 20 | rm -rf hw20_soln 21 | mkdir hw20_soln 22 | cp glibhash.c Makefile emma.txt hw20_soln 23 | tar -czf hw20_soln.tgz hw20_soln -------------------------------------------------------------------------------- /roman/writen.c: -------------------------------------------------------------------------------- 1 | /* include writen */ 2 | #include "unp.h" 3 | 4 | ssize_t /* Write "n" bytes to a descriptor. */ 5 | writen(int fd, const void *vptr, size_t n) 6 | { 7 | size_t nleft; 8 | ssize_t nwritten; 9 | const char *ptr; 10 | 11 | ptr = vptr; 12 | nleft = n; 13 | while (nleft > 0) { 14 | if ( (nwritten = write(fd, ptr, nleft)) <= 0) { 15 | if (errno == EINTR) 16 | nwritten = 0; /* and call write() again */ 17 | else 18 | return(-1); /* error */ 19 | } 20 | 21 | nleft -= nwritten; 22 | ptr += nwritten; 23 | } 24 | return(n); 25 | } 26 | /* end writen */ 27 | 28 | void 29 | Writen(int fd, void *ptr, size_t nbytes) 30 | { 31 | if (writen(fd, ptr, nbytes) != nbytes) 32 | err_sys("writen error"); 33 | } 34 | -------------------------------------------------------------------------------- /roman/soln/writen.c: -------------------------------------------------------------------------------- 1 | /* include writen */ 2 | #include "unp.h" 3 | 4 | ssize_t /* Write "n" bytes to a descriptor. */ 5 | writen(int fd, const void *vptr, size_t n) 6 | { 7 | size_t nleft; 8 | ssize_t nwritten; 9 | const char *ptr; 10 | 11 | ptr = vptr; 12 | nleft = n; 13 | while (nleft > 0) { 14 | if ( (nwritten = write(fd, ptr, nleft)) <= 0) { 15 | if (errno == EINTR) 16 | nwritten = 0; /* and call write() again */ 17 | else 18 | return(-1); /* error */ 19 | } 20 | 21 | nleft -= nwritten; 22 | ptr += nwritten; 23 | } 24 | return(n); 25 | } 26 | /* end writen */ 27 | 28 | void 29 | Writen(int fd, void *ptr, size_t nbytes) 30 | { 31 | if (writen(fd, ptr, nbytes) != nbytes) 32 | err_sys("writen error"); 33 | } 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sys_types_h.m4: -------------------------------------------------------------------------------- 1 | # sys_types_h.m4 serial 5 2 | dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN_ONCE([gl_SYS_TYPES_H], 8 | [ 9 | AC_REQUIRE([gl_SYS_TYPES_H_DEFAULTS]) 10 | gl_NEXT_HEADERS([sys/types.h]) 11 | 12 | dnl Ensure the type pid_t gets defined. 13 | AC_REQUIRE([AC_TYPE_PID_T]) 14 | 15 | dnl Ensure the type mode_t gets defined. 16 | AC_REQUIRE([AC_TYPE_MODE_T]) 17 | 18 | dnl Whether to override the 'off_t' type. 19 | AC_REQUIRE([gl_TYPE_OFF_T]) 20 | ]) 21 | 22 | AC_DEFUN([gl_SYS_TYPES_H_DEFAULTS], 23 | [ 24 | ]) 25 | -------------------------------------------------------------------------------- /lecture03/stack.c: -------------------------------------------------------------------------------- 1 | /* Example code for Think OS. 2 | 3 | Copyright 2014 Allen Downey 4 | License: GNU GPLv3 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | 11 | #define SIZE 5 12 | 13 | int *foo() { 14 | int i; 15 | int array[SIZE]; 16 | 17 | printf("%p\n", array); 18 | 19 | for (i=0; i 9 | #include 10 | #include 11 | 12 | char *tracks[] = { 13 | "So What", 14 | "Freddie Freeloader", 15 | "Blue in Green", 16 | "All Blues", 17 | "Flamenco Sketches" 18 | }; 19 | 20 | /* Returns a heap-allocated string that contains the strings 21 | from the given array, joined up with no spaces between. 22 | */ 23 | char *strjoin(char *array[], int n) 24 | { 25 | // TODO: fill this in 26 | return NULL; 27 | } 28 | 29 | 30 | int main (int argc, char *argv[]) 31 | { 32 | char *s = strjoin(tracks, 5); 33 | printf("%s\n", s); 34 | return 0; 35 | } 36 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/msvc-inval.m4: -------------------------------------------------------------------------------- 1 | # msvc-inval.m4 serial 1 2 | dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_MSVC_INVAL], 8 | [ 9 | AC_CHECK_FUNCS_ONCE([_set_invalid_parameter_handler]) 10 | if test $ac_cv_func__set_invalid_parameter_handler = yes; then 11 | HAVE_MSVC_INVALID_PARAMETER_HANDLER=1 12 | AC_DEFINE([HAVE_MSVC_INVALID_PARAMETER_HANDLER], [1], 13 | [Define to 1 on MSVC platforms that have the "invalid parameter handler" 14 | concept.]) 15 | else 16 | HAVE_MSVC_INVALID_PARAMETER_HANDLER=0 17 | fi 18 | AC_SUBST([HAVE_MSVC_INVALID_PARAMETER_HANDLER]) 19 | ]) 20 | -------------------------------------------------------------------------------- /lecture18/simple2threads.c: -------------------------------------------------------------------------------- 1 | /* Example from Figure 2.4 of Hailperin, Operating Systems and Middleware. 2 | 3 | Copyright 2012 Max Hailperin 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | Modified by Allen Downey. 7 | */ 8 | 9 | #include 10 | #include 11 | #include 12 | 13 | 14 | static void *child(void *ignored) 15 | { 16 | sleep(3); 17 | printf("Child is done sleeping 3 seconds.\n"); 18 | return NULL; 19 | } 20 | 21 | 22 | int main(int argc, char *argv[]) 23 | { 24 | pthread_t child_thread; 25 | int code; 26 | 27 | code = pthread_create(&child_thread, NULL, child, NULL); 28 | if (code) { 29 | fprintf(stderr, "pthread_create failed with code %d\n", code); 30 | } 31 | sleep(5); 32 | printf("Parent is done sleeping 5 seconds.\n"); 33 | return 0; 34 | } 35 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/exitfail.h: -------------------------------------------------------------------------------- 1 | /* Failure exit status 2 | 3 | Copyright (C) 2002, 2009-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | extern int volatile exit_failure; 19 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/POTFILES.in: -------------------------------------------------------------------------------- 1 | # List of files which containing translatable strings. 2 | # Copyright (C) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 3 | # 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 Free Software 4 | # Foundation, Inc. 5 | 6 | # Package source files 7 | lib/error.c 8 | lib/gai_strerror.c 9 | lib/getopt.c 10 | lib/quotearg.c 11 | lib/spawn-pipe.c 12 | lib/w32spawn.h 13 | lib/wait-process.c 14 | lib/xalloc-die.c 15 | src/connect.c 16 | src/convert.c 17 | src/cookies.c 18 | src/ftp-ls.c 19 | src/ftp.c 20 | src/gnutls.c 21 | src/host.c 22 | src/html-url.c 23 | src/http.c 24 | src/init.c 25 | src/iri.c 26 | src/log.c 27 | src/main.c 28 | src/mswindows.c 29 | src/netrc.c 30 | src/openssl.c 31 | src/progress.c 32 | src/ptimer.c 33 | src/recur.c 34 | src/res.c 35 | src/retr.c 36 | src/spider.c 37 | src/url.c 38 | src/utils.c 39 | src/warc.c 40 | -------------------------------------------------------------------------------- /roman/wraplib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Wrapper functions for our own library functions. 3 | * Most are included in the source file for the function itself. 4 | */ 5 | 6 | #include "unp.h" 7 | 8 | const char * 9 | Inet_ntop(int family, const void *addrptr, char *strptr, size_t len) 10 | { 11 | const char *ptr; 12 | 13 | if (strptr == NULL) /* check for old code */ 14 | err_quit("NULL 3rd argument to inet_ntop"); 15 | if ( (ptr = inet_ntop(family, addrptr, strptr, len)) == NULL) 16 | err_sys("inet_ntop error"); /* sets errno */ 17 | return(ptr); 18 | } 19 | 20 | void 21 | Inet_pton(int family, const char *strptr, void *addrptr) 22 | { 23 | int n; 24 | 25 | if ( (n = inet_pton(family, strptr, addrptr)) < 0) 26 | err_sys("inet_pton error for %s", strptr); /* errno set */ 27 | else if (n == 0) 28 | err_quit("inet_pton error for %s", strptr); /* errno not set */ 29 | 30 | /* nothing to return */ 31 | } 32 | -------------------------------------------------------------------------------- /roman/soln/wraplib.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Wrapper functions for our own library functions. 3 | * Most are included in the source file for the function itself. 4 | */ 5 | 6 | #include "unp.h" 7 | 8 | const char * 9 | Inet_ntop(int family, const void *addrptr, char *strptr, size_t len) 10 | { 11 | const char *ptr; 12 | 13 | if (strptr == NULL) /* check for old code */ 14 | err_quit("NULL 3rd argument to inet_ntop"); 15 | if ( (ptr = inet_ntop(family, addrptr, strptr, len)) == NULL) 16 | err_sys("inet_ntop error"); /* sets errno */ 17 | return(ptr); 18 | } 19 | 20 | void 21 | Inet_pton(int family, const char *strptr, void *addrptr) 22 | { 23 | int n; 24 | 25 | if ( (n = inet_pton(family, strptr, addrptr)) < 0) 26 | err_sys("inet_pton error for %s", strptr); /* errno set */ 27 | else if (n == 0) 28 | err_quit("inet_pton error for %s", strptr); /* errno not set */ 29 | 30 | /* nothing to return */ 31 | } 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/secure_getenv.m4: -------------------------------------------------------------------------------- 1 | # Look up an environment variable more securely. 2 | dnl Copyright 2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_SECURE_GETENV], 8 | [ 9 | dnl Persuade glibc to declare secure_getenv(). 10 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 11 | 12 | AC_REQUIRE([gl_STDLIB_H_DEFAULTS]) 13 | AC_CHECK_FUNCS_ONCE([secure_getenv]) 14 | if test $ac_cv_func_secure_getenv = no; then 15 | HAVE_SECURE_GETENV=0 16 | fi 17 | ]) 18 | 19 | # Prerequisites of lib/secure_getenv.c. 20 | AC_DEFUN([gl_PREREQ_SECURE_GETENV], [ 21 | AC_CHECK_FUNCS([__secure_getenv]) 22 | if test $ac_cv_func___secure_getenv = no; then 23 | AC_CHECK_FUNCS([issetugid]) 24 | fi 25 | ]) 26 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/ssize_t.m4: -------------------------------------------------------------------------------- 1 | # ssize_t.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2001-2003, 2006, 2010-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether ssize_t is defined. 9 | 10 | AC_DEFUN([gt_TYPE_SSIZE_T], 11 | [ 12 | AC_CACHE_CHECK([for ssize_t], [gt_cv_ssize_t], 13 | [AC_COMPILE_IFELSE( 14 | [AC_LANG_PROGRAM( 15 | [[#include ]], 16 | [[int x = sizeof (ssize_t *) + sizeof (ssize_t); 17 | return !x;]])], 18 | [gt_cv_ssize_t=yes], [gt_cv_ssize_t=no])]) 19 | if test $gt_cv_ssize_t = no; then 20 | AC_DEFINE([ssize_t], [int], 21 | [Define as a signed type of the same size as size_t.]) 22 | fi 23 | ]) 24 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/wchar_t.m4: -------------------------------------------------------------------------------- 1 | # wchar_t.m4 serial 4 (gettext-0.18.2) 2 | dnl Copyright (C) 2002-2003, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether has the 'wchar_t' type. 9 | dnl Prerequisite: AC_PROG_CC 10 | 11 | AC_DEFUN([gt_TYPE_WCHAR_T], 12 | [ 13 | AC_CACHE_CHECK([for wchar_t], [gt_cv_c_wchar_t], 14 | [AC_COMPILE_IFELSE( 15 | [AC_LANG_PROGRAM( 16 | [[#include 17 | wchar_t foo = (wchar_t)'\0';]], 18 | [[]])], 19 | [gt_cv_c_wchar_t=yes], 20 | [gt_cv_c_wchar_t=no])]) 21 | if test $gt_cv_c_wchar_t = yes; then 22 | AC_DEFINE([HAVE_WCHAR_T], [1], [Define if you have the 'wchar_t' type.]) 23 | fi 24 | ]) 25 | -------------------------------------------------------------------------------- /roman/tcpserv01.c: -------------------------------------------------------------------------------- 1 | #include "unp.h" 2 | 3 | int 4 | main(int argc, char **argv) 5 | { 6 | int listenfd, connfd; 7 | pid_t childpid; 8 | socklen_t clilen; 9 | struct sockaddr_in cliaddr, servaddr; 10 | 11 | listenfd = Socket(AF_INET, SOCK_STREAM, 0); 12 | 13 | bzero(&servaddr, sizeof(servaddr)); 14 | servaddr.sin_family = AF_INET; 15 | servaddr.sin_addr.s_addr = htonl(INADDR_ANY); 16 | servaddr.sin_port = htons(SERV_PORT); 17 | 18 | Bind(listenfd, (SA *) &servaddr, sizeof(servaddr)); 19 | 20 | Listen(listenfd, LISTENQ); 21 | 22 | for ( ; ; ) { 23 | clilen = sizeof(cliaddr); 24 | connfd = Accept(listenfd, (SA *) &cliaddr, &clilen); 25 | 26 | if ( (childpid = Fork()) == 0) { /* child process */ 27 | Close(listenfd); /* close listening socket */ 28 | str_echo(connfd); /* process the request */ 29 | exit(0); 30 | } 31 | Close(connfd); /* parent closes connected socket */ 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/codeset.m4: -------------------------------------------------------------------------------- 1 | # codeset.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2000-2002, 2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | 9 | AC_DEFUN([AM_LANGINFO_CODESET], 10 | [ 11 | AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset], 12 | [AC_LINK_IFELSE( 13 | [AC_LANG_PROGRAM( 14 | [[#include ]], 15 | [[char* cs = nl_langinfo(CODESET); return !cs;]])], 16 | [am_cv_langinfo_codeset=yes], 17 | [am_cv_langinfo_codeset=no]) 18 | ]) 19 | if test $am_cv_langinfo_codeset = yes; then 20 | AC_DEFINE([HAVE_LANGINFO_CODESET], [1], 21 | [Define if you have and nl_langinfo(CODESET).]) 22 | fi 23 | ]) 24 | -------------------------------------------------------------------------------- /lecture06/interleave.c: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2014 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | /* Returns a heap-allocated string that contains the letters 13 | from the input strings, interleaved. 14 | */ 15 | char *interleave(char *s1, char *s2) 16 | { 17 | int size; 18 | char *dest; 19 | int i=0, j=0, k=0; 20 | 21 | size = strlen(s1) + strlen(s2) + 1; 22 | 23 | dest = malloc (size * sizeof(char)); 24 | 25 | for (k=0; k]], 17 | [[error_at_line (0, 0, "", 0, "an error occurred");]])], 18 | [ac_cv_lib_error_at_line=yes], 19 | [ac_cv_lib_error_at_line=no])]) 20 | ]) 21 | 22 | # Prerequisites of lib/error.c. 23 | AC_DEFUN([gl_PREREQ_ERROR], 24 | [ 25 | AC_REQUIRE([AC_FUNC_STRERROR_R]) 26 | : 27 | ]) 28 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/exitfail.c: -------------------------------------------------------------------------------- 1 | /* Failure exit status 2 | 3 | Copyright (C) 2002-2003, 2005-2007, 2009-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #include 19 | 20 | #include "exitfail.h" 21 | 22 | #include 23 | 24 | int volatile exit_failure = EXIT_FAILURE; 25 | -------------------------------------------------------------------------------- /roman/soln/tcpcli01.c: -------------------------------------------------------------------------------- 1 | #include "unp.h" 2 | 3 | void send_get(int sockfd) 4 | { 5 | int n; 6 | char recvline[MAXLINE]; 7 | char *sendline = "GET /MCXI HTTP/1.1\r\n"; 8 | 9 | Writen(sockfd, sendline, strlen(sendline)); 10 | printf("Sent %s\n", sendline); 11 | 12 | while (1) { 13 | n = Readline(sockfd, recvline, MAXLINE); 14 | if (n == 0) break; 15 | 16 | Fputs(recvline, stdout); 17 | } 18 | } 19 | 20 | int main(int argc, char **argv) 21 | { 22 | int sockfd; 23 | struct sockaddr_in servaddr; 24 | 25 | if (argc != 2) 26 | err_quit("usage: tcpcli "); 27 | 28 | sockfd = Socket(AF_INET, SOCK_STREAM, 0); 29 | 30 | bzero(&servaddr, sizeof(servaddr)); 31 | servaddr.sin_family = AF_INET; 32 | servaddr.sin_port = htons(8081); 33 | Inet_pton(AF_INET, argv[1], &servaddr.sin_addr); 34 | 35 | Connect(sockfd, (SA *) &servaddr, sizeof(servaddr)); 36 | 37 | send_get(sockfd); 38 | 39 | exit(0); 40 | } 41 | -------------------------------------------------------------------------------- /exam1/center.c: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2014 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | // Returns a heap-allocated string with length n, with 14 | // the given string in the middle, surrounded by fillchar. 15 | // 16 | // For example, if s is allen, n is 10 and fillchar is . 17 | // the result is ..allen... 18 | 19 | char *center(char *s, int n, char fillchar) 20 | { 21 | // FILL THIS IN 22 | // return NULL; 23 | } 24 | 25 | 26 | int main (int argc, char *argv[]) 27 | { 28 | char *s = center("Software", 30, '.'); 29 | printf("%s\n", s); 30 | 31 | char *s2 = center("Systems", 31, '-'); 32 | printf("%s\n", s2); 33 | 34 | char *s3 = center("Spring 2014", 32, '*'); 35 | printf("%s\n", s3); 36 | 37 | char *s4 = center("Exam 1", 33, '^'); 38 | printf("%s\n", s4); 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sigpipe.m4: -------------------------------------------------------------------------------- 1 | # sigpipe.m4 serial 2 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl Tests whether SIGPIPE is provided by . 8 | dnl Sets gl_cv_header_signal_h_SIGPIPE. 9 | AC_DEFUN([gl_SIGNAL_SIGPIPE], 10 | [ 11 | dnl Use AC_REQUIRE here, so that the default behavior below is expanded 12 | dnl once only, before all statements that occur in other macros. 13 | AC_REQUIRE([gl_SIGNAL_SIGPIPE_BODY]) 14 | ]) 15 | 16 | AC_DEFUN([gl_SIGNAL_SIGPIPE_BODY], 17 | [ 18 | AC_REQUIRE([AC_PROG_CC]) 19 | AC_CACHE_CHECK([for SIGPIPE], [gl_cv_header_signal_h_SIGPIPE], [ 20 | AC_EGREP_CPP([booboo],[ 21 | #include 22 | #if !defined SIGPIPE 23 | booboo 24 | #endif 25 | ], 26 | [gl_cv_header_signal_h_SIGPIPE=no], 27 | [gl_cv_header_signal_h_SIGPIPE=yes]) 28 | ]) 29 | ]) 30 | -------------------------------------------------------------------------------- /hw02/wget-1.15/src/exits.h: -------------------------------------------------------------------------------- 1 | /* Exit status related declarations. 2 | Copyright (C) 2009, 2010, 2011, 2012 Free Software Foundation, Inc. 3 | 4 | This file is part of GNU Wget. 5 | 6 | GNU Wget is free software; you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 10 | 11 | GNU Wget 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 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with Wget. If not, see . */ 18 | 19 | #ifndef WGET_EXITS_H 20 | #define WGET_EXITS_H 21 | 22 | #include "wget.h" 23 | 24 | 25 | void inform_exit_status (uerr_t err); 26 | 27 | int get_exit_status (void); 28 | 29 | 30 | #endif /* WGET_EXITS_H */ 31 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/mbtowc.c: -------------------------------------------------------------------------------- 1 | /* Convert multibyte character to wide character. 2 | Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | Written by Bruno Haible , 2011. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #include "mbtowc-impl.h" 27 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/signalblocking.m4: -------------------------------------------------------------------------------- 1 | # signalblocking.m4 serial 14 2 | dnl Copyright (C) 2001-2002, 2006-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Determine available signal blocking primitives. Three different APIs exist: 8 | # 1) POSIX: sigemptyset, sigaddset, sigprocmask 9 | # 2) SYSV: sighold, sigrelse 10 | # 3) BSD: sigblock, sigsetmask 11 | # For simplicity, here we check only for the POSIX signal blocking. 12 | AC_DEFUN([gl_SIGNALBLOCKING], 13 | [ 14 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 15 | AC_REQUIRE([gl_CHECK_TYPE_SIGSET_T]) 16 | if test $gl_cv_type_sigset_t = yes; then 17 | AC_CHECK_FUNC([sigprocmask], [gl_cv_func_sigprocmask=1]) 18 | fi 19 | if test -z "$gl_cv_func_sigprocmask"; then 20 | HAVE_POSIX_SIGNALBLOCKING=0 21 | fi 22 | ]) 23 | 24 | # Prerequisites of lib/sigprocmask.c. 25 | AC_DEFUN([gl_PREREQ_SIGPROCMASK], [:]) 26 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/certs/server-key.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN RSA PRIVATE KEY----- 2 | Proc-Type: 4,ENCRYPTED 3 | DEK-Info: DES-EDE3-CBC,8B09CBCC4587B80C 4 | 5 | Yikael4jBlULlN5QU2SIN38OsTqbkcNZGVcoT5rpGf2Mh+aLRRnSvpIAOqNbIcEw 6 | T8pOtbic9AUh2YaCUK5xw5ou47t2dkieWB0a/amfOAFiajca+94AI+f1k73D85Y9 7 | bqCkal7pMzIEh22+qIHrUqJLeZdFOIq/C2j4a8Ymv2qmcQ7aKHfmtM3I1XWqg/ql 8 | GNDwhDxTJ1C6rMvXblDQ5gb4uqdUCw03jVOKTh7kQCNjV6RZqtzFShARiuL2yt4J 9 | l8H116hT6JtyVAm6kQIws0wqYPiIQxgpHQV21OibDh7WwD+i2sN77vnG06bYi7C6 10 | l8PkHsB2VbR2GjrZXAW1MGrCIVllbouFJ3zhPTr1DsDuCQ7G9dc8J/lviaWCi+HL 11 | aWq99V824sjz0CuzRqdUINx1f2XR53+ltSiyXk77NpyUOj/2nGQd2RhsjC/gLHdU 12 | J5152dOoYRmhftubfNr9Cend76rCkwLhZ1ZOa1LDgkT7HFD+4FIeW02opwGpRo/k 13 | XxOIkI7EF3em1MXfbRq1GEXr/KBkTKKeiaVUYW4klytX9crOZ+Dxv9KZRANAPzuF 14 | Tmx1gO4qJL2d8SXlNbUd4MRwCwK2CgUyUknL9kGkt98N2sYUyJETwSWUWbNnP31g 15 | R0sUKSvJN1k8DfZTpP/8znW1kz+vPa66tuRjBRd96JNUDdqSHHywT4DnR/pUNzdG 16 | uUD4/x4VgEwMcOYOKAFeOInn5pPINecU8EE4SehLODW3YdQW4hnxxaltuXPAkvNo 17 | 6ST/6HVi/iSJsfvqUuEEXw/SGRMB0aZ+YEIOn4hVnu+gE8N07tuyvQ== 18 | -----END RSA PRIVATE KEY----- 19 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/ref-del.sin: -------------------------------------------------------------------------------- 1 | # Remove this package from a list of references stored in a text file. 2 | # 3 | # Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 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 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program; if not, see . 17 | # 18 | # Written by Bruno Haible . 19 | # 20 | /^# Packages using this file: / { 21 | s/# Packages using this file:// 22 | s/ @PACKAGE@ / / 23 | s/^/# Packages using this file:/ 24 | } 25 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/glibc21.m4: -------------------------------------------------------------------------------- 1 | # glibc21.m4 serial 5 2 | dnl Copyright (C) 2000-2002, 2004, 2008, 2010-2013 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | # Test for the GNU C Library, version 2.1 or newer, or uClibc. 9 | # From Bruno Haible. 10 | 11 | AC_DEFUN([gl_GLIBC21], 12 | [ 13 | AC_CACHE_CHECK([whether we are using the GNU C Library >= 2.1 or uClibc], 14 | [ac_cv_gnu_library_2_1], 15 | [AC_EGREP_CPP([Lucky], 16 | [ 17 | #include 18 | #ifdef __GNU_LIBRARY__ 19 | #if (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 1) || (__GLIBC__ > 2) 20 | Lucky GNU user 21 | #endif 22 | #endif 23 | #ifdef __UCLIBC__ 24 | Lucky user 25 | #endif 26 | ], 27 | [ac_cv_gnu_library_2_1=yes], 28 | [ac_cv_gnu_library_2_1=no]) 29 | ] 30 | ) 31 | AC_SUBST([GLIBC21]) 32 | GLIBC21="$ac_cv_gnu_library_2_1" 33 | ] 34 | ) 35 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/getline.c: -------------------------------------------------------------------------------- 1 | /* getline.c --- Implementation of replacement getline function. 2 | Copyright (C) 2005-2007, 2009-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software; you can redistribute it and/or 5 | modify it under the terms of the GNU General Public License as 6 | published by the Free Software Foundation; either version 3, or (at 7 | your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, but 10 | WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program; if not, see . */ 16 | 17 | /* Written by Simon Josefsson. */ 18 | 19 | #include 20 | 21 | #include 22 | 23 | ssize_t 24 | getline (char **lineptr, size_t *n, FILE *stream) 25 | { 26 | return getdelim (lineptr, n, '\n', stream); 27 | } 28 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sys_uio_h.m4: -------------------------------------------------------------------------------- 1 | # sys_uio_h.m4 serial 1 2 | dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_HEADER_SYS_UIO], 8 | [ 9 | AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 10 | dnl is always overridden, because of GNULIB_POSIXCHECK. 11 | gl_CHECK_NEXT_HEADERS([sys/uio.h]) 12 | if test $ac_cv_header_sys_uio_h = yes; then 13 | HAVE_SYS_UIO_H=1 14 | else 15 | HAVE_SYS_UIO_H=0 16 | fi 17 | AC_SUBST([HAVE_SYS_UIO_H]) 18 | ]) 19 | 20 | AC_DEFUN([gl_SYS_UIO_MODULE_INDICATOR], 21 | [ 22 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 23 | AC_REQUIRE([gl_SYS_UIO_H_DEFAULTS]) 24 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 25 | dnl Define it also as a C macro, for the benefit of the unit tests. 26 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) 27 | ]) 28 | 29 | AC_DEFUN([gl_SYS_UIO_H_DEFAULTS], 30 | [ 31 | ]) 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/eealloc.m4: -------------------------------------------------------------------------------- 1 | # eealloc.m4 serial 3 2 | dnl Copyright (C) 2003, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_EEALLOC], 8 | [ 9 | AC_REQUIRE([gl_EEMALLOC]) 10 | AC_REQUIRE([gl_EEREALLOC]) 11 | ]) 12 | 13 | AC_DEFUN([gl_EEMALLOC], 14 | [ 15 | _AC_FUNC_MALLOC_IF( 16 | [gl_cv_func_malloc_0_nonnull=1], 17 | [gl_cv_func_malloc_0_nonnull=0]) 18 | AC_DEFINE_UNQUOTED([MALLOC_0_IS_NONNULL], [$gl_cv_func_malloc_0_nonnull], 19 | [If malloc(0) is != NULL, define this to 1. Otherwise define this 20 | to 0.]) 21 | ]) 22 | 23 | AC_DEFUN([gl_EEREALLOC], 24 | [ 25 | _AC_FUNC_REALLOC_IF( 26 | [gl_cv_func_realloc_0_nonnull=1], 27 | [gl_cv_func_realloc_0_nonnull=0]) 28 | AC_DEFINE_UNQUOTED([REALLOC_0_IS_NONNULL], [$gl_cv_func_realloc_0_nonnull], 29 | [If realloc(NULL,0) is != NULL, define this to 1. Otherwise define this 30 | to 0.]) 31 | ]) 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/fstat.m4: -------------------------------------------------------------------------------- 1 | # fstat.m4 serial 4 2 | dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_FSTAT], 8 | [ 9 | AC_REQUIRE([gl_SYS_STAT_H_DEFAULTS]) 10 | 11 | AC_REQUIRE([gl_MSVC_INVAL]) 12 | if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 13 | REPLACE_FSTAT=1 14 | fi 15 | 16 | AC_REQUIRE([gl_HEADER_SYS_STAT_H]) 17 | if test $WINDOWS_64_BIT_ST_SIZE = 1; then 18 | REPLACE_FSTAT=1 19 | fi 20 | 21 | dnl Replace fstat() for supporting the gnulib-defined open() on directories. 22 | m4_ifdef([gl_FUNC_FCHDIR], [ 23 | gl_TEST_FCHDIR 24 | if test $HAVE_FCHDIR = 0; then 25 | case "$gl_cv_func_open_directory_works" in 26 | *yes) ;; 27 | *) 28 | REPLACE_FSTAT=1 29 | ;; 30 | esac 31 | fi 32 | ]) 33 | ]) 34 | 35 | # Prerequisites of lib/fstat.c. 36 | AC_DEFUN([gl_PREREQ_FSTAT], [:]) 37 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/stdint_h.m4: -------------------------------------------------------------------------------- 1 | # stdint_h.m4 serial 9 2 | dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | # Define HAVE_STDINT_H_WITH_UINTMAX if exists, 10 | # doesn't clash with , and declares uintmax_t. 11 | 12 | AC_DEFUN([gl_AC_HEADER_STDINT_H], 13 | [ 14 | AC_CACHE_CHECK([for stdint.h], [gl_cv_header_stdint_h], 15 | [AC_COMPILE_IFELSE( 16 | [AC_LANG_PROGRAM( 17 | [[#include 18 | #include ]], 19 | [[uintmax_t i = (uintmax_t) -1; return !i;]])], 20 | [gl_cv_header_stdint_h=yes], 21 | [gl_cv_header_stdint_h=no])]) 22 | if test $gl_cv_header_stdint_h = yes; then 23 | AC_DEFINE_UNQUOTED([HAVE_STDINT_H_WITH_UINTMAX], [1], 24 | [Define if exists, doesn't clash with , 25 | and declares uintmax_t. ]) 26 | fi 27 | ]) 28 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/raise.m4: -------------------------------------------------------------------------------- 1 | # raise.m4 serial 3 2 | dnl Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_RAISE], 8 | [ 9 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 10 | AC_REQUIRE([AC_CANONICAL_HOST]) 11 | AC_REQUIRE([gl_MSVC_INVAL]) 12 | AC_CHECK_FUNCS([raise]) 13 | if test $ac_cv_func_raise = no; then 14 | HAVE_RAISE=0 15 | else 16 | if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 17 | REPLACE_RAISE=1 18 | fi 19 | m4_ifdef([gl_SIGNALBLOCKING], [ 20 | gl_SIGNALBLOCKING 21 | if test $HAVE_POSIX_SIGNALBLOCKING = 0; then 22 | m4_ifdef([gl_SIGNAL_SIGPIPE], [ 23 | gl_SIGNAL_SIGPIPE 24 | if test $gl_cv_header_signal_h_SIGPIPE != yes; then 25 | REPLACE_RAISE=1 26 | fi 27 | ], [:]) 28 | fi 29 | ]) 30 | fi 31 | ]) 32 | 33 | # Prerequisites of lib/raise.c. 34 | AC_DEFUN([gl_PREREQ_RAISE], [:]) 35 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-ftp.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use FTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $afile = < { 21 | content => $afile, 22 | }, 23 | ); 24 | 25 | my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:{{port}}/afile.txt"; 26 | 27 | my $expected_error_code = 0; 28 | 29 | my %expected_downloaded_files = ( 30 | 'afile.txt' => { 31 | content => $afile, 32 | }, 33 | ); 34 | 35 | ############################################################################### 36 | 37 | my $the_test = FTPTest->new (name => "Test-ftp", 38 | input => \%urls, 39 | cmdline => $cmdline, 40 | errcode => $expected_error_code, 41 | output => \%expected_downloaded_files); 42 | exit $the_test->run(); 43 | 44 | # vim: et ts=4 sw=4 45 | 46 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/ref-add.sin: -------------------------------------------------------------------------------- 1 | # Add this package to a list of references stored in a text file. 2 | # 3 | # Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3, or (at your option) 8 | # any later version. 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 | # GNU General Public License for more details. 14 | # 15 | # You should have received a copy of the GNU General Public License along 16 | # with this program; if not, see . 17 | # 18 | # Written by Bruno Haible . 19 | # 20 | /^# Packages using this file: / { 21 | s/# Packages using this file:// 22 | ta 23 | :a 24 | s/ @PACKAGE@ / @PACKAGE@ / 25 | tb 26 | s/ $/ @PACKAGE@ / 27 | :b 28 | s/^/# Packages using this file:/ 29 | } 30 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/spawnattr_destroy.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | /* Initialize data structure for file attribute for 'spawn' call. */ 23 | int 24 | posix_spawnattr_destroy (posix_spawnattr_t *attr) 25 | { 26 | /* Nothing to do in the moment. */ 27 | return 0; 28 | } 29 | -------------------------------------------------------------------------------- /lecture08/strjoin_soln.c: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2014 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | char *tracks[] = { 13 | "So What", 14 | "Freddie Freeloader", 15 | "Blue in Green", 16 | "All Blues", 17 | "Flamenco Sketches" 18 | }; 19 | 20 | /* Returns a heap-allocated string that contains the strings 21 | from the given array, joined up with no spaces between. 22 | */ 23 | char *strjoin(char *array[], int n) 24 | { 25 | int i; 26 | int total = 1; 27 | char *dest, *buf; 28 | 29 | for (i=0; i. */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | /* Implementation for native Windows systems. */ 23 | 24 | #include /* for _cwait, WAIT_CHILD */ 25 | 26 | pid_t 27 | waitpid (pid_t pid, int *statusp, int options) 28 | { 29 | return _cwait (statusp, pid, WAIT_CHILD); 30 | } 31 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/unistd--.h: -------------------------------------------------------------------------------- 1 | /* Like unistd.h, but redefine some names to avoid glitches. 2 | 3 | Copyright (C) 2005, 2009-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paul Eggert. */ 19 | 20 | #include 21 | #include "unistd-safer.h" 22 | 23 | #undef dup 24 | #define dup dup_safer 25 | 26 | #undef pipe 27 | #define pipe pipe_safer 28 | 29 | #if GNULIB_PIPE2_SAFER 30 | # undef pipe2 31 | # define pipe2 pipe2_safer 32 | #endif 33 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/write.m4: -------------------------------------------------------------------------------- 1 | # write.m4 serial 5 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_WRITE], 8 | [ 9 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 10 | AC_REQUIRE([gl_MSVC_INVAL]) 11 | if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 12 | REPLACE_WRITE=1 13 | fi 14 | dnl This ifdef is just an optimization, to avoid performing a configure 15 | dnl check whose result is not used. It does not make the test of 16 | dnl GNULIB_UNISTD_H_SIGPIPE or GNULIB_SIGPIPE redundant. 17 | m4_ifdef([gl_SIGNAL_SIGPIPE], [ 18 | gl_SIGNAL_SIGPIPE 19 | if test $gl_cv_header_signal_h_SIGPIPE != yes; then 20 | REPLACE_WRITE=1 21 | fi 22 | ]) 23 | m4_ifdef([gl_NONBLOCKING_IO], [ 24 | gl_NONBLOCKING_IO 25 | if test $gl_cv_have_nonblocking != yes; then 26 | REPLACE_WRITE=1 27 | fi 28 | ]) 29 | ]) 30 | 31 | # Prerequisites of lib/write.c. 32 | AC_DEFUN([gl_PREREQ_WRITE], [:]) 33 | -------------------------------------------------------------------------------- /hw02/wget-1.15/src/warc.h: -------------------------------------------------------------------------------- 1 | /* Declarations of WARC helper methods. */ 2 | #ifndef WARC_H 3 | #define WARC_H 4 | 5 | #include "host.h" 6 | 7 | void warc_init (void); 8 | void warc_close (void); 9 | void warc_timestamp (char *timestamp); 10 | void warc_uuid_str (char *id_str); 11 | 12 | FILE * warc_tempfile (void); 13 | 14 | bool warc_write_request_record (char *url, char *timestamp_str, 15 | char *concurrent_to_uuid, ip_address *ip, FILE *body, off_t payload_offset); 16 | bool warc_write_response_record (char *url, char *timestamp_str, 17 | char *concurrent_to_uuid, ip_address *ip, FILE *body, off_t payload_offset, 18 | char *mime_type, int response_code, char *redirect_location); 19 | bool warc_write_resource_record (char *resource_uuid, const char *url, 20 | const char *timestamp_str, const char *concurrent_to_uuid, ip_address *ip, 21 | const char *content_type, FILE *body, off_t payload_offset); 22 | bool warc_write_metadata_record (char *record_uuid, const char *url, 23 | const char *timestamp_str, const char *concurrent_to_uuid, ip_address *ip, 24 | const char *content_type, FILE *body, off_t payload_offset); 25 | 26 | #endif /* WARC_H */ 27 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/inttypes_h.m4: -------------------------------------------------------------------------------- 1 | # inttypes_h.m4 serial 10 2 | dnl Copyright (C) 1997-2004, 2006, 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Paul Eggert. 8 | 9 | # Define HAVE_INTTYPES_H_WITH_UINTMAX if exists, 10 | # doesn't clash with , and declares uintmax_t. 11 | 12 | AC_DEFUN([gl_AC_HEADER_INTTYPES_H], 13 | [ 14 | AC_CACHE_CHECK([for inttypes.h], [gl_cv_header_inttypes_h], 15 | [AC_COMPILE_IFELSE( 16 | [AC_LANG_PROGRAM( 17 | [[ 18 | #include 19 | #include 20 | ]], 21 | [[uintmax_t i = (uintmax_t) -1; return !i;]])], 22 | [gl_cv_header_inttypes_h=yes], 23 | [gl_cv_header_inttypes_h=no])]) 24 | if test $gl_cv_header_inttypes_h = yes; then 25 | AC_DEFINE_UNQUOTED([HAVE_INTTYPES_H_WITH_UINTMAX], [1], 26 | [Define if exists, doesn't clash with , 27 | and declares uintmax_t. ]) 28 | fi 29 | ]) 30 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/itold.c: -------------------------------------------------------------------------------- 1 | /* Replacement for 'int' to 'long double' conversion routine. 2 | Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | Written by Bruno Haible , 2011. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #include 19 | 20 | /* Specification. */ 21 | #include 22 | 23 | void 24 | _Qp_itoq (long double *result, int a) 25 | { 26 | /* Convert from 'int' to 'double', then from 'double' to 'long double'. */ 27 | *result = (double) a; 28 | } 29 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-auth-retcode.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | # code, msg, headers, content 12 | my %urls = ( 13 | '/dummy.txt' => { 14 | code => "403", 15 | msg => "Dontcare", 16 | headers => { 17 | "Content-type" => "text/plain", 18 | "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT", 19 | }, 20 | }, 21 | ); 22 | 23 | my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/dummy.txt"; 24 | 25 | my $expected_error_code = 8; 26 | 27 | my %expected_downloaded_files = (); 28 | 29 | ############################################################################### 30 | 31 | my $the_test = HTTPTest->new (name => "Test-auth-retcode", 32 | input => \%urls, 33 | cmdline => $cmdline, 34 | errcode => $expected_error_code, 35 | output => \%expected_downloaded_files); 36 | exit $the_test->run(); 37 | 38 | # vim: et ts=4 sw=4 39 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/fseek.c: -------------------------------------------------------------------------------- 1 | /* An fseek() function that, together with fflush(), is POSIX compliant. 2 | Copyright (C) 2007, 2009-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | /* Get off_t. */ 23 | #include 24 | 25 | int 26 | fseek (FILE *fp, long offset, int whence) 27 | { 28 | /* Use the replacement fseeko function with all its workarounds. */ 29 | return fseeko (fp, (off_t)offset, whence); 30 | } 31 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/unistd-safer.h: -------------------------------------------------------------------------------- 1 | /* Invoke unistd-like functions, but avoid some glitches. 2 | 3 | Copyright (C) 2001, 2003, 2005, 2009-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paul Eggert and Eric Blake. */ 19 | 20 | int dup_safer (int); 21 | int fd_safer (int); 22 | int pipe_safer (int[2]); 23 | 24 | #if GNULIB_FD_SAFER_FLAG 25 | int dup_safer_flag (int, int); 26 | int fd_safer_flag (int, int); 27 | #endif 28 | 29 | #if GNULIB_PIPE2_SAFER 30 | int pipe2_safer (int[2], int); 31 | #endif 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/wint_t.m4: -------------------------------------------------------------------------------- 1 | # wint_t.m4 serial 5 (gettext-0.18.2) 2 | dnl Copyright (C) 2003, 2007-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl From Bruno Haible. 8 | dnl Test whether has the 'wint_t' type. 9 | dnl Prerequisite: AC_PROG_CC 10 | 11 | AC_DEFUN([gt_TYPE_WINT_T], 12 | [ 13 | AC_CACHE_CHECK([for wint_t], [gt_cv_c_wint_t], 14 | [AC_COMPILE_IFELSE( 15 | [AC_LANG_PROGRAM( 16 | [[ 17 | /* Tru64 with Desktop Toolkit C has a bug: must be included before 18 | . 19 | BSD/OS 4.0.1 has a bug: , and must be included 20 | before . */ 21 | #include 22 | #include 23 | #include 24 | #include 25 | wint_t foo = (wchar_t)'\0';]], 26 | [[]])], 27 | [gt_cv_c_wint_t=yes], 28 | [gt_cv_c_wint_t=no])]) 29 | if test $gt_cv_c_wint_t = yes; then 30 | AC_DEFINE([HAVE_WINT_T], [1], [Define if you have the 'wint_t' type.]) 31 | fi 32 | ]) 33 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/dup-safer.c: -------------------------------------------------------------------------------- 1 | /* Invoke dup, but avoid some glitches. 2 | 3 | Copyright (C) 2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paul Eggert. */ 19 | 20 | #include 21 | 22 | #include "unistd-safer.h" 23 | 24 | #include 25 | #include 26 | 27 | /* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or 28 | STDERR_FILENO. */ 29 | 30 | int 31 | dup_safer (int fd) 32 | { 33 | return fcntl (fd, F_DUPFD, STDERR_FILENO + 1); 34 | } 35 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/asnprintf.c: -------------------------------------------------------------------------------- 1 | /* Formatted output to strings. 2 | Copyright (C) 1999, 2002, 2006, 2009-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software; you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3, or (at your option) 7 | any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License along 15 | with this program; if not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include "vasnprintf.h" 21 | 22 | #include 23 | 24 | char * 25 | asnprintf (char *resultbuf, size_t *lengthp, const char *format, ...) 26 | { 27 | va_list args; 28 | char *result; 29 | 30 | va_start (args, format); 31 | result = vasnprintf (resultbuf, lengthp, format, args); 32 | va_end (args); 33 | return result; 34 | } 35 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-nonexisting-quiet.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | }, 23 | content => $dummyfile 24 | }, 25 | ); 26 | 27 | my $cmdline = $WgetTest::WGETPATH . " --quiet http://localhost:{{port}}/nonexistent"; 28 | 29 | my $expected_error_code = 8; 30 | 31 | my %expected_downloaded_files = ( 32 | ); 33 | 34 | ############################################################################### 35 | 36 | my $the_test = HTTPTest->new (name => "Test-nonexisting-quiet", 37 | input => \%urls, 38 | cmdline => $cmdline, 39 | errcode => $expected_error_code, 40 | output => \%expected_downloaded_files); 41 | exit $the_test->run(); 42 | 43 | # vim: et ts=4 sw=4 44 | 45 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/spawn_faction_destroy.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | #include 23 | 24 | /* Initialize data structure for file attribute for 'spawn' call. */ 25 | int 26 | posix_spawn_file_actions_destroy (posix_spawn_file_actions_t *file_actions) 27 | { 28 | /* Free the memory allocated. */ 29 | free (file_actions->_actions); 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/getpass.h: -------------------------------------------------------------------------------- 1 | /* getpass.h -- Read a password of arbitrary length from /dev/tty or stdin. 2 | Copyright (C) 2004, 2009-2013 Free Software Foundation, Inc. 3 | Contributed by Simon Josefsson , 2004. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, see . */ 17 | 18 | #ifndef GETPASS_H 19 | # define GETPASS_H 20 | 21 | /* Get getpass declaration, if available. */ 22 | # include 23 | 24 | # if !HAVE_DECL_GETPASS 25 | /* Read a password of arbitrary length from /dev/tty or stdin. */ 26 | char *getpass (const char *prompt); 27 | 28 | # endif 29 | 30 | #endif /* GETPASS_H */ 31 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/netinet_in_h.m4: -------------------------------------------------------------------------------- 1 | # netinet_in_h.m4 serial 5 2 | dnl Copyright (C) 2006-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_HEADER_NETINET_IN], 8 | [ 9 | AC_CACHE_CHECK([whether is self-contained], 10 | [gl_cv_header_netinet_in_h_selfcontained], 11 | [ 12 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], [[]])], 13 | [gl_cv_header_netinet_in_h_selfcontained=yes], 14 | [gl_cv_header_netinet_in_h_selfcontained=no]) 15 | ]) 16 | if test $gl_cv_header_netinet_in_h_selfcontained = yes; then 17 | NETINET_IN_H='' 18 | else 19 | NETINET_IN_H='netinet/in.h' 20 | AC_CHECK_HEADERS([netinet/in.h]) 21 | gl_CHECK_NEXT_HEADERS([netinet/in.h]) 22 | if test $ac_cv_header_netinet_in_h = yes; then 23 | HAVE_NETINET_IN_H=1 24 | else 25 | HAVE_NETINET_IN_H=0 26 | fi 27 | AC_SUBST([HAVE_NETINET_IN_H]) 28 | fi 29 | AC_SUBST([NETINET_IN_H]) 30 | AM_CONDITIONAL([GL_GENERATE_NETINET_IN_H], [test -n "$NETINET_IN_H"]) 31 | ]) 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/strcase.m4: -------------------------------------------------------------------------------- 1 | # strcase.m4 serial 11 2 | dnl Copyright (C) 2002, 2005-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_STRCASE], 8 | [ 9 | gl_FUNC_STRCASECMP 10 | gl_FUNC_STRNCASECMP 11 | ]) 12 | 13 | AC_DEFUN([gl_FUNC_STRCASECMP], 14 | [ 15 | AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 16 | AC_CHECK_FUNCS([strcasecmp]) 17 | if test $ac_cv_func_strcasecmp = no; then 18 | HAVE_STRCASECMP=0 19 | fi 20 | ]) 21 | 22 | AC_DEFUN([gl_FUNC_STRNCASECMP], 23 | [ 24 | AC_REQUIRE([gl_HEADER_STRINGS_H_DEFAULTS]) 25 | AC_CHECK_FUNCS([strncasecmp]) 26 | if test $ac_cv_func_strncasecmp = yes; then 27 | HAVE_STRNCASECMP=1 28 | else 29 | HAVE_STRNCASECMP=0 30 | fi 31 | AC_CHECK_DECLS([strncasecmp]) 32 | if test $ac_cv_have_decl_strncasecmp = no; then 33 | HAVE_DECL_STRNCASECMP=0 34 | fi 35 | ]) 36 | 37 | # Prerequisites of lib/strcasecmp.c. 38 | AC_DEFUN([gl_PREREQ_STRCASECMP], [ 39 | : 40 | ]) 41 | 42 | # Prerequisites of lib/strncasecmp.c. 43 | AC_DEFUN([gl_PREREQ_STRNCASECMP], [ 44 | : 45 | ]) 46 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-O.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | }, 23 | content => $dummyfile 24 | }, 25 | ); 26 | 27 | my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:{{port}}/dummy.txt"; 28 | 29 | my $expected_error_code = 0; 30 | 31 | my %expected_downloaded_files = ( 32 | 'out' => { 33 | content => $dummyfile, 34 | } 35 | ); 36 | 37 | ############################################################################### 38 | 39 | my $the_test = HTTPTest->new (name => "Test-O", 40 | input => \%urls, 41 | cmdline => $cmdline, 42 | errcode => $expected_error_code, 43 | output => \%expected_downloaded_files); 44 | exit $the_test->run(); 45 | 46 | # vim: et ts=4 sw=4 47 | 48 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-O-nc.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | }, 23 | content => $dummyfile 24 | }, 25 | ); 26 | 27 | my $cmdline = $WgetTest::WGETPATH . " -nc -O out http://localhost:{{port}}/dummy.txt"; 28 | 29 | my $expected_error_code = 0; 30 | 31 | my %expected_downloaded_files = ( 32 | 'out' => { 33 | content => $dummyfile, 34 | } 35 | ); 36 | 37 | ############################################################################### 38 | 39 | my $the_test = HTTPTest->new (name => "Test-O-nc", 40 | input => \%urls, 41 | cmdline => $cmdline, 42 | errcode => $expected_error_code, 43 | output => \%expected_downloaded_files); 44 | exit $the_test->run(); 45 | 46 | # vim: et ts=4 sw=4 47 | 48 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/asprintf.c: -------------------------------------------------------------------------------- 1 | /* Formatted output to strings. 2 | Copyright (C) 1999, 2002, 2006-2007, 2009-2013 Free Software Foundation, 3 | Inc. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, see . */ 17 | 18 | #include 19 | 20 | /* Specification. */ 21 | #ifdef IN_LIBASPRINTF 22 | # include "vasprintf.h" 23 | #else 24 | # include 25 | #endif 26 | 27 | #include 28 | 29 | int 30 | asprintf (char **resultp, const char *format, ...) 31 | { 32 | va_list args; 33 | int result; 34 | 35 | va_start (args, format); 36 | result = vasprintf (resultp, format, args); 37 | va_end (args); 38 | return result; 39 | } 40 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/btowc.c: -------------------------------------------------------------------------------- 1 | /* Convert unibyte character to wide character. 2 | Copyright (C) 2008, 2010-2013 Free Software Foundation, Inc. 3 | Written by Bruno Haible , 2008. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #include 19 | 20 | /* Specification. */ 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | wint_t 27 | btowc (int c) 28 | { 29 | if (c != EOF) 30 | { 31 | char buf[1]; 32 | wchar_t wc; 33 | 34 | buf[0] = c; 35 | if (mbtowc (&wc, buf, 1) >= 0) 36 | return wc; 37 | } 38 | return WEOF; 39 | } 40 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/spawnattr_init.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | #include 23 | 24 | /* Initialize data structure for file attribute for 'spawn' call. */ 25 | int 26 | posix_spawnattr_init (posix_spawnattr_t *attr) 27 | { 28 | /* All elements have to be initialized to the default values which 29 | is generally zero. */ 30 | memset (attr, '\0', sizeof (*attr)); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/close.m4: -------------------------------------------------------------------------------- 1 | # close.m4 serial 8 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_FUNC_CLOSE], 8 | [ 9 | AC_REQUIRE([gl_UNISTD_H_DEFAULTS]) 10 | AC_REQUIRE([gl_MSVC_INVAL]) 11 | if test $HAVE_MSVC_INVALID_PARAMETER_HANDLER = 1; then 12 | REPLACE_CLOSE=1 13 | fi 14 | m4_ifdef([gl_PREREQ_SYS_H_WINSOCK2], [ 15 | gl_PREREQ_SYS_H_WINSOCK2 16 | if test $UNISTD_H_HAVE_WINSOCK2_H = 1; then 17 | dnl Even if the 'socket' module is not used here, another part of the 18 | dnl application may use it and pass file descriptors that refer to 19 | dnl sockets to the close() function. So enable the support for sockets. 20 | REPLACE_CLOSE=1 21 | fi 22 | ]) 23 | dnl Replace close() for supporting the gnulib-defined fchdir() function, 24 | dnl to keep fchdir's bookkeeping up-to-date. 25 | m4_ifdef([gl_FUNC_FCHDIR], [ 26 | if test $REPLACE_CLOSE = 0; then 27 | gl_TEST_FCHDIR 28 | if test $HAVE_FCHDIR = 0; then 29 | REPLACE_CLOSE=1 30 | fi 31 | fi 32 | ]) 33 | ]) 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sched_h.m4: -------------------------------------------------------------------------------- 1 | # sched_h.m4 serial 6 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl Written by Bruno Haible. 8 | 9 | AC_DEFUN([gl_SCHED_H], 10 | [ 11 | AC_COMPILE_IFELSE( 12 | [AC_LANG_PROGRAM([[ 13 | #include 14 | struct sched_param a; 15 | int b[] = { SCHED_FIFO, SCHED_RR, SCHED_OTHER }; 16 | pid_t t1; 17 | ]])], 18 | [SCHED_H=''], 19 | [SCHED_H='sched.h' 20 | 21 | gl_CHECK_NEXT_HEADERS([sched.h]) 22 | 23 | if test $ac_cv_header_sched_h = yes; then 24 | HAVE_SCHED_H=1 25 | else 26 | HAVE_SCHED_H=0 27 | fi 28 | AC_SUBST([HAVE_SCHED_H]) 29 | 30 | AC_CHECK_TYPE([struct sched_param], 31 | [HAVE_STRUCT_SCHED_PARAM=1], [HAVE_STRUCT_SCHED_PARAM=0], 32 | [#include ]) 33 | AC_SUBST([HAVE_STRUCT_SCHED_PARAM]) 34 | 35 | dnl Ensure the type pid_t gets defined. 36 | AC_REQUIRE([AC_TYPE_PID_T]) 37 | ]) 38 | AC_SUBST([SCHED_H]) 39 | AM_CONDITIONAL([GL_GENERATE_SCHED_H], [test -n "$SCHED_H"]) 40 | ]) 41 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-O-nonexisting.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/html", 22 | }, 23 | content => $dummyfile 24 | }, 25 | ); 26 | 27 | my $cmdline = $WgetTest::WGETPATH . " --quiet -O out http://localhost:{{port}}/nonexistent"; 28 | 29 | my $expected_error_code = 8; 30 | 31 | my %expected_downloaded_files = ( 32 | 'out' => { 33 | content => "", 34 | } 35 | ); 36 | 37 | ############################################################################### 38 | 39 | my $the_test = HTTPTest->new (name => "Test-O-nonexisting", 40 | input => \%urls, 41 | cmdline => $cmdline, 42 | errcode => $expected_error_code, 43 | output => \%expected_downloaded_files); 44 | exit $the_test->run(); 45 | 46 | # vim: et ts=4 sw=4 47 | 48 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/HTTPTest.pm: -------------------------------------------------------------------------------- 1 | package HTTPTest; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPServer; 7 | use WgetTest; 8 | 9 | our @ISA = qw(WgetTest); 10 | my $VERSION = 0.01; 11 | 12 | 13 | { 14 | my %_attr_data = ( # DEFAULT 15 | ); 16 | 17 | sub _default_for 18 | { 19 | my ($self, $attr) = @_; 20 | return $_attr_data{$attr} if exists $_attr_data{$attr}; 21 | return $self->SUPER::_default_for($attr); 22 | } 23 | 24 | sub _standard_keys 25 | { 26 | my ($self) = @_; 27 | ($self->SUPER::_standard_keys(), keys %_attr_data); 28 | } 29 | } 30 | 31 | 32 | sub _setup_server { 33 | my $self = shift; 34 | $self->{_server} = HTTPServer->new (LocalAddr => 'localhost', 35 | ReuseAddr => 1) 36 | or die "Cannot create server!!!"; 37 | } 38 | 39 | 40 | sub _launch_server { 41 | my $self = shift; 42 | my $synch_func = shift; 43 | 44 | $self->{_server}->run ($self->{_input}, $synch_func); 45 | } 46 | 47 | sub _substitute_port { 48 | my $self = shift; 49 | my $ret = shift; 50 | $ret =~ s/{{port}}/$self->{_server}->sockport/eg; 51 | return $ret; 52 | } 53 | 54 | 1; 55 | 56 | # vim: et ts=4 sw=4 57 | 58 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/secure_getenv.c: -------------------------------------------------------------------------------- 1 | /* Look up an environment variable more securely. 2 | 3 | Copyright 2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify it 6 | under the terms of the GNU General Public License as published 7 | by the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 GNU 13 | General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #include 19 | 20 | #include 21 | 22 | #if !HAVE___SECURE_GETENV 23 | # if HAVE_ISSETUGID 24 | # include 25 | # else 26 | # undef issetugid 27 | # define issetugid() 1 28 | # endif 29 | #endif 30 | 31 | char * 32 | secure_getenv (char const *name) 33 | { 34 | #if HAVE___SECURE_GETENV 35 | return __secure_getenv (name); 36 | #else 37 | if (issetugid ()) 38 | return 0; 39 | return getenv (name); 40 | #endif 41 | } 42 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/size_max.h: -------------------------------------------------------------------------------- 1 | /* size_max.h -- declare SIZE_MAX through system headers 2 | Copyright (C) 2005-2006, 2009-2013 Free Software Foundation, Inc. 3 | Written by Simon Josefsson. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program; if not, see . */ 17 | 18 | #ifndef GNULIB_SIZE_MAX_H 19 | #define GNULIB_SIZE_MAX_H 20 | 21 | /* Get SIZE_MAX declaration on systems like Solaris 7/8/9. */ 22 | # include 23 | /* Get SIZE_MAX declaration on systems like glibc 2. */ 24 | # if HAVE_STDINT_H 25 | # include 26 | # endif 27 | /* On systems where these include files don't define it, SIZE_MAX is defined 28 | in config.h. */ 29 | 30 | #endif /* GNULIB_SIZE_MAX_H */ 31 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/spawnattr_setsigmask.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | #include 23 | 24 | /* Set signal mask for the new process in ATTR to SIGMASK. */ 25 | int 26 | posix_spawnattr_setsigmask (posix_spawnattr_t *attr, 27 | const sigset_t *sigmask) 28 | { 29 | /* Copy the sigset_t data to the user buffer. */ 30 | memcpy (&attr->_ss, sigmask, sizeof (sigset_t)); 31 | 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/ftell.c: -------------------------------------------------------------------------------- 1 | /* An ftell() function that works around platform bugs. 2 | Copyright (C) 2007-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | #include 23 | #include 24 | 25 | long 26 | ftell (FILE *fp) 27 | { 28 | /* Use the replacement ftello function with all its workarounds. */ 29 | off_t offset = ftello (fp); 30 | if (LONG_MIN <= offset && offset <= LONG_MAX) 31 | return /* (long) */ offset; 32 | else 33 | { 34 | errno = EOVERFLOW; 35 | return -1; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/en@quot.header: -------------------------------------------------------------------------------- 1 | # All this catalog "translates" are quotation characters. 2 | # The msgids must be ASCII and therefore cannot contain real quotation 3 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) 4 | # and double quote (0x22). These substitutes look strange; see 5 | # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 6 | # 7 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to 8 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). 9 | # It also translates pairs of apostrophe (0x27) to 10 | # left single quotation mark (U+2018) and right single quotation mark (U+2019) 11 | # and pairs of quotation mark (0x22) to 12 | # left double quotation mark (U+201C) and right double quotation mark (U+201D). 13 | # 14 | # When output to an UTF-8 terminal, the quotation characters appear perfectly. 15 | # When output to an ISO-8859-1 terminal, the single quotation marks are 16 | # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to 17 | # grave/acute accent (by libiconv), and the double quotation marks are 18 | # transliterated to 0x22. 19 | # When output to an ASCII terminal, the single quotation marks are 20 | # transliterated to apostrophes, and the double quotation marks are 21 | # transliterated to 0x22. 22 | # 23 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/vasprintf.m4: -------------------------------------------------------------------------------- 1 | # vasprintf.m4 serial 6 2 | dnl Copyright (C) 2002-2003, 2006-2007, 2009-2013 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | AC_DEFUN([gl_FUNC_VASPRINTF], 9 | [ 10 | AC_CHECK_FUNCS([vasprintf]) 11 | if test $ac_cv_func_vasprintf = no; then 12 | gl_REPLACE_VASPRINTF 13 | fi 14 | ]) 15 | 16 | AC_DEFUN([gl_REPLACE_VASPRINTF], 17 | [ 18 | AC_LIBOBJ([vasprintf]) 19 | AC_LIBOBJ([asprintf]) 20 | AC_REQUIRE([gl_STDIO_H_DEFAULTS]) 21 | if test $ac_cv_func_vasprintf = yes; then 22 | REPLACE_VASPRINTF=1 23 | else 24 | HAVE_VASPRINTF=0 25 | fi 26 | gl_PREREQ_VASPRINTF_H 27 | gl_PREREQ_VASPRINTF 28 | gl_PREREQ_ASPRINTF 29 | ]) 30 | 31 | # Prerequisites of the vasprintf portion of lib/stdio.h. 32 | AC_DEFUN([gl_PREREQ_VASPRINTF_H], 33 | [ 34 | dnl Persuade glibc to declare asprintf() and vasprintf(). 35 | AC_REQUIRE([AC_USE_SYSTEM_EXTENSIONS]) 36 | ]) 37 | 38 | # Prerequisites of lib/vasprintf.c. 39 | AC_DEFUN([gl_PREREQ_VASPRINTF], 40 | [ 41 | ]) 42 | 43 | # Prerequisites of lib/asprintf.c. 44 | AC_DEFUN([gl_PREREQ_ASPRINTF], 45 | [ 46 | ]) 47 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-ftp-iri-recursive.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use WgetFeature qw(iri); 7 | use FTPTest; 8 | 9 | 10 | ############################################################################### 11 | 12 | my $ccedilla_l1 = "\xE7"; 13 | my $ccedilla_u8 = "\xC3\xA7"; 14 | 15 | my $francais = < { 24 | content => $francais, 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " --local-encoding=iso-8859-1 -r -nH -S ftp://localhost:{{port}}/"; 29 | 30 | my $expected_error_code = 0; 31 | 32 | my %expected_downloaded_files = ( 33 | "fran${ccedilla_l1}ais.txt" => { 34 | content => $francais, 35 | }, 36 | ); 37 | 38 | ############################################################################### 39 | 40 | my $the_test = FTPTest->new (name => "Test-ftp-iri-recursive", 41 | input => \%urls, 42 | cmdline => $cmdline, 43 | errcode => $expected_error_code, 44 | output => \%expected_downloaded_files); 45 | exit $the_test->run(); 46 | 47 | # vim: et ts=4 sw=4 48 | 49 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-ftp-iri.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use WgetFeature qw(iri); 7 | use FTPTest; 8 | 9 | 10 | ############################################################################### 11 | 12 | my $ccedilla_l1 = "\xE7"; 13 | my $ccedilla_u8 = "\xC3\xA7"; 14 | 15 | my $francais = < { 25 | content => $francais, 26 | }, 27 | ); 28 | 29 | my $cmdline = $WgetTest::WGETPATH . " --local-encoding=iso-8859-1 -S ftp://localhost:{{port}}/fran${ccedilla_l1}ais.txt"; 30 | 31 | my $expected_error_code = 0; 32 | 33 | my %expected_downloaded_files = ( 34 | "fran${ccedilla_u8}ais.txt" => { 35 | content => $francais, 36 | }, 37 | ); 38 | 39 | ############################################################################### 40 | 41 | my $the_test = FTPTest->new (name => "Test-ftp-iri", 42 | input => \%urls, 43 | cmdline => $cmdline, 44 | errcode => $expected_error_code, 45 | output => \%expected_downloaded_files); 46 | exit $the_test->run(); 47 | 48 | # vim: et ts=4 sw=4 49 | 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test--spider.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $mainpage = < 13 | 14 | Main Page 15 | 16 | 17 |

18 | Some text. 19 |

20 | 21 | 22 | EOF 23 | 24 | # code, msg, headers, content 25 | my %urls = ( 26 | '/index.html' => { 27 | code => "200", 28 | msg => "Dontcare", 29 | headers => { 30 | "Content-type" => "text/html", 31 | }, 32 | content => $mainpage, 33 | }, 34 | ); 35 | 36 | my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:{{port}}/index.html"; 37 | 38 | my $expected_error_code = 0; 39 | 40 | my %expected_downloaded_files = ( 41 | ); 42 | 43 | ############################################################################### 44 | 45 | my $the_test = HTTPTest->new (name => "Test--spider", 46 | input => \%urls, 47 | cmdline => $cmdline, 48 | errcode => $expected_error_code, 49 | output => \%expected_downloaded_files); 50 | exit $the_test->run(); 51 | 52 | # vim: et ts=4 sw=4 53 | 54 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-stdouterr.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | # code, msg, headers, content 12 | my %urls = ( 13 | '/somefile.txt' => { 14 | code => "200", 15 | msg => "Dontcare", 16 | headers => { 17 | "Content-type" => "text/plain", 18 | }, 19 | content => "blabla", 20 | }, 21 | ); 22 | 23 | unless(-e "/dev/full") { 24 | exit(2); # skip 25 | } 26 | 27 | my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt -O /dev/full"; 28 | 29 | my $expected_error_code = 3; 30 | 31 | my %existing_files = ( 32 | ); 33 | 34 | my %expected_downloaded_files = ( 35 | ); 36 | 37 | ############################################################################### 38 | 39 | my $the_test = HTTPTest->new (name => "Test-stdouterr", 40 | input => \%urls, 41 | cmdline => $cmdline, 42 | errcode => $expected_error_code, 43 | existing => \%existing_files, 44 | output => \%expected_downloaded_files); 45 | exit $the_test->run(); 46 | 47 | # vim: et ts=4 sw=4 48 | 49 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-ftp-iri-fallback.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use WgetFeature qw(iri); 7 | use FTPTest; 8 | 9 | 10 | ############################################################################### 11 | 12 | my $ccedilla_l1 = "\xE7"; 13 | my $ccedilla_u8 = "\xC3\xA7"; 14 | 15 | my $francais = < { 24 | content => $francais, 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " --local-encoding=iso-8859-1 -S ftp://localhost:{{port}}/fran${ccedilla_l1}ais.txt"; 29 | 30 | my $expected_error_code = 0; 31 | 32 | my %expected_downloaded_files = ( 33 | "fran${ccedilla_l1}ais.txt" => { 34 | content => $francais, 35 | }, 36 | ); 37 | 38 | ############################################################################### 39 | 40 | my $the_test = FTPTest->new (name => "Test-ftp-iri-fallback", 41 | input => \%urls, 42 | cmdline => $cmdline, 43 | errcode => $expected_error_code, 44 | output => \%expected_downloaded_files); 45 | exit $the_test->run(); 46 | 47 | # vim: et ts=4 sw=4 48 | 49 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test--spider-fail.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $mainpage = < 13 | 14 | Main Page 15 | 16 | 17 |

18 | Some text. 19 |

20 | 21 | 22 | EOF 23 | 24 | # code, msg, headers, content 25 | my %urls = ( 26 | '/index.html' => { 27 | code => "200", 28 | msg => "Dontcare", 29 | headers => { 30 | "Content-type" => "text/html", 31 | }, 32 | content => $mainpage, 33 | }, 34 | ); 35 | 36 | my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:{{port}}/nonexistent"; 37 | 38 | my $expected_error_code = 8; 39 | 40 | my %expected_downloaded_files = ( 41 | ); 42 | 43 | ############################################################################### 44 | 45 | my $the_test = HTTPTest->new (name => "Test--spider-fail", 46 | input => \%urls, 47 | cmdline => $cmdline, 48 | errcode => $expected_error_code, 49 | output => \%expected_downloaded_files); 50 | exit $the_test->run(); 51 | 52 | # vim: et ts=4 sw=4 53 | 54 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-O--no-content-disposition-trivial.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | }, 23 | content => $dummyfile 24 | }, 25 | ); 26 | 27 | my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:{{port}}/dummy.txt"; 28 | 29 | my $expected_error_code = 0; 30 | 31 | my %expected_downloaded_files = ( 32 | 'out' => { 33 | content => $dummyfile, 34 | } 35 | ); 36 | 37 | ############################################################################### 38 | 39 | my $the_test = HTTPTest->new (name => "Test-O--no-content-disposition-trivial", 40 | input => \%urls, 41 | cmdline => $cmdline, 42 | errcode => $expected_error_code, 43 | output => \%expected_downloaded_files); 44 | exit $the_test->run(); 45 | 46 | # vim: et ts=4 sw=4 47 | 48 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/nls.m4: -------------------------------------------------------------------------------- 1 | # nls.m4 serial 3 (gettext-0.15) 2 | dnl Copyright (C) 1995-2003, 2005-2006 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | dnl 7 | dnl This file can can be used in projects which are not available under 8 | dnl the GNU General Public License or the GNU Library General Public 9 | dnl License but which still want to provide support for the GNU gettext 10 | dnl functionality. 11 | dnl Please note that the actual code of the GNU gettext library is covered 12 | dnl by the GNU Library General Public License, and the rest of the GNU 13 | dnl gettext package package is covered by the GNU General Public License. 14 | dnl They are *not* in the public domain. 15 | 16 | dnl Authors: 17 | dnl Ulrich Drepper , 1995-2000. 18 | dnl Bruno Haible , 2000-2003. 19 | 20 | AC_PREREQ(2.50) 21 | 22 | AC_DEFUN([AM_NLS], 23 | [ 24 | AC_MSG_CHECKING([whether NLS is requested]) 25 | dnl Default is enabled NLS 26 | AC_ARG_ENABLE(nls, 27 | [ --disable-nls do not use Native Language Support], 28 | USE_NLS=$enableval, USE_NLS=yes) 29 | AC_MSG_RESULT($USE_NLS) 30 | AC_SUBST(USE_NLS) 31 | ]) 32 | -------------------------------------------------------------------------------- /hw04/wave2/wave2.ino: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | 4 | Author: Allen Downey 5 | 6 | Based on http://arduino.cc/en/Tutorial/AnalogInput 7 | Created by David Cuartielles 8 | modified 30 Aug 2011 9 | By Tom Igoe 10 | 11 | License: Public Domain 12 | 13 | */ 14 | 15 | 16 | int ledPin = 5; // select the pin for the LED 17 | int buttonPin1 = 2; 18 | int buttonPin2 = 3; 19 | 20 | void setup() { 21 | Serial.begin(9600); 22 | 23 | pinMode(buttonPin1, INPUT_PULLUP); 24 | pinMode(buttonPin2, INPUT_PULLUP); 25 | 26 | pinMode(ledPin, OUTPUT); 27 | 28 | pinMode(13, OUTPUT); 29 | pinMode(12, OUTPUT); 30 | pinMode(11, OUTPUT); 31 | pinMode(10, OUTPUT); 32 | pinMode(9, OUTPUT); 33 | pinMode(8, OUTPUT); 34 | pinMode(7, OUTPUT); 35 | pinMode(6, OUTPUT); 36 | } 37 | 38 | void writeByte(int x) { 39 | int pin; 40 | 41 | for (pin=13; pin>=6; pin--) { 42 | digitalWrite(pin, x&1); 43 | x >>= 1; 44 | } 45 | } 46 | 47 | int low = 36; 48 | int high = 255; 49 | int stride = 5; 50 | int counter = low; 51 | 52 | void loop() { 53 | int button1 = digitalRead(buttonPin1); 54 | if (button1) return; 55 | 56 | counter += stride; 57 | if (counter > high) { 58 | counter = low; 59 | //Serial.println(counter); 60 | } 61 | 62 | // write to the digital pins 63 | writeByte(counter); 64 | } 65 | -------------------------------------------------------------------------------- /hw02/wget-1.15/build-aux/snippet/arg-nonnull.h: -------------------------------------------------------------------------------- 1 | /* A C macro for declaring that specific arguments must not be NULL. 2 | Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify it 5 | under the terms of the GNU General Public License as published 6 | by the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 | General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | /* _GL_ARG_NONNULL((n,...,m)) tells the compiler and static analyzer tools 18 | that the values passed as arguments n, ..., m must be non-NULL pointers. 19 | n = 1 stands for the first argument, n = 2 for the second argument etc. */ 20 | #ifndef _GL_ARG_NONNULL 21 | # if (__GNUC__ == 3 && __GNUC_MINOR__ >= 3) || __GNUC__ > 3 22 | # define _GL_ARG_NONNULL(params) __attribute__ ((__nonnull__ params)) 23 | # else 24 | # define _GL_ARG_NONNULL(params) 25 | # endif 26 | #endif 27 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/pathmax.m4: -------------------------------------------------------------------------------- 1 | # pathmax.m4 serial 10 2 | dnl Copyright (C) 2002-2003, 2005-2006, 2009-2013 Free Software Foundation, 3 | dnl Inc. 4 | dnl This file is free software; the Free Software Foundation 5 | dnl gives unlimited permission to copy and/or distribute it, 6 | dnl with or without modifications, as long as this notice is preserved. 7 | 8 | AC_DEFUN([gl_PATHMAX], 9 | [ 10 | dnl Prerequisites of lib/pathmax.h. 11 | AC_CHECK_HEADERS_ONCE([sys/param.h]) 12 | ]) 13 | 14 | # Expands to a piece of C program that defines PATH_MAX in the same way as 15 | # "pathmax.h" will do. 16 | AC_DEFUN([gl_PATHMAX_SNIPPET], [[ 17 | /* Arrange to define PATH_MAX, like "pathmax.h" does. */ 18 | #if HAVE_UNISTD_H 19 | # include 20 | #endif 21 | #include 22 | #if defined HAVE_SYS_PARAM_H && !defined PATH_MAX && !defined MAXPATHLEN 23 | # include 24 | #endif 25 | #if !defined PATH_MAX && defined MAXPATHLEN 26 | # define PATH_MAX MAXPATHLEN 27 | #endif 28 | #ifdef __hpux 29 | # undef PATH_MAX 30 | # define PATH_MAX 1024 31 | #endif 32 | #if (defined _WIN32 || defined __WIN32__) && ! defined __CYGWIN__ 33 | # undef PATH_MAX 34 | # define PATH_MAX 260 35 | #endif 36 | ]]) 37 | 38 | # Prerequisites of gl_PATHMAX_SNIPPET. 39 | AC_DEFUN([gl_PATHMAX_SNIPPET_PREREQ], 40 | [ 41 | AC_CHECK_HEADERS_ONCE([unistd.h sys/param.h]) 42 | ]) 43 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sys_wait_h.m4: -------------------------------------------------------------------------------- 1 | # sys_wait_h.m4 serial 6 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | AC_DEFUN([gl_SYS_WAIT_H], 8 | [ 9 | AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS]) 10 | 11 | dnl is always overridden, because of GNULIB_POSIXCHECK. 12 | gl_CHECK_NEXT_HEADERS([sys/wait.h]) 13 | 14 | dnl Ensure the type pid_t gets defined. 15 | AC_REQUIRE([AC_TYPE_PID_T]) 16 | 17 | dnl Check for declarations of anything we want to poison if the 18 | dnl corresponding gnulib module is not in use. 19 | gl_WARN_ON_USE_PREPARE([[#include ]], 20 | [waitpid]) 21 | ]) 22 | 23 | AC_DEFUN([gl_SYS_WAIT_MODULE_INDICATOR], 24 | [ 25 | dnl Use AC_REQUIRE here, so that the default settings are expanded once only. 26 | AC_REQUIRE([gl_SYS_WAIT_H_DEFAULTS]) 27 | gl_MODULE_INDICATOR_SET_VARIABLE([$1]) 28 | dnl Define it also as a C macro, for the benefit of the unit tests. 29 | gl_MODULE_INDICATOR_FOR_TESTS([$1]) 30 | ]) 31 | 32 | AC_DEFUN([gl_SYS_WAIT_H_DEFAULTS], 33 | [ 34 | GNULIB_WAITPID=0; AC_SUBST([GNULIB_WAITPID]) 35 | dnl Assume proper GNU behavior unless another module says otherwise. 36 | ]) 37 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/mode_t.m4: -------------------------------------------------------------------------------- 1 | # mode_t.m4 serial 2 2 | dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # For using mode_t, it's sufficient to use AC_TYPE_MODE_T and 8 | # include . 9 | 10 | # Define PROMOTED_MODE_T to the type that is the result of "default argument 11 | # promotion" (ISO C 6.5.2.2.(6)) of the type mode_t. 12 | AC_DEFUN([gl_PROMOTED_TYPE_MODE_T], 13 | [ 14 | AC_REQUIRE([AC_TYPE_MODE_T]) 15 | AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [ 16 | dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int', 17 | dnl and to itself otherwise. This assumption is not guaranteed by the ISO C 18 | dnl standard, but we don't know of any real-world counterexamples. 19 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include ]], 20 | [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])], 21 | [gl_cv_promoted_mode_t='int'], 22 | [gl_cv_promoted_mode_t='mode_t']) 23 | ]) 24 | AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t], 25 | [Define to the type that is the result of default argument promotions of type mode_t.]) 26 | ]) 27 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/tmpdir.h: -------------------------------------------------------------------------------- 1 | /* Determine a temporary directory. 2 | Copyright (C) 2001-2002, 2009-2013 Free Software Foundation, Inc. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | #include 19 | 20 | /* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is 21 | non-null and exists, uses it; otherwise uses the first of $TMPDIR, 22 | P_tmpdir, /tmp that exists. Copies into TMPL a template suitable 23 | for use with mk[s]temp. Will fail (-1) if DIR is non-null and 24 | doesn't exist, none of the searched dirs exists, or there's not 25 | enough space in TMPL. */ 26 | extern int path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx, bool try_tmpdir); 27 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-O-HTTP-Content-Disposition.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | "Content-Disposition" => "attachment; filename=\"filename.txt\"", 23 | }, 24 | content => $dummyfile 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:{{port}}/dummy.txt"; 29 | 30 | my $expected_error_code = 0; 31 | 32 | my %expected_downloaded_files = ( 33 | 'out' => { 34 | content => $dummyfile, 35 | } 36 | ); 37 | 38 | ############################################################################### 39 | 40 | my $the_test = HTTPTest->new (name => "Test-O-HTTP-Content-Disposition", 41 | input => \%urls, 42 | cmdline => $cmdline, 43 | errcode => $expected_error_code, 44 | output => \%expected_downloaded_files); 45 | exit $the_test->run(); 46 | 47 | # vim: et ts=4 sw=4 48 | 49 | -------------------------------------------------------------------------------- /roman/readline.c: -------------------------------------------------------------------------------- 1 | /* include readline */ 2 | #include "unp.h" 3 | 4 | static ssize_t 5 | my_read(int fd, char *ptr) 6 | { 7 | static int read_cnt = 0; 8 | static char *read_ptr; 9 | static char read_buf[MAXLINE]; 10 | 11 | if (read_cnt <= 0) { 12 | again: 13 | if ( (read_cnt = read(fd, read_buf, sizeof(read_buf))) < 0) { 14 | if (errno == EINTR) 15 | goto again; 16 | return(-1); 17 | } else if (read_cnt == 0) 18 | return(0); 19 | read_ptr = read_buf; 20 | } 21 | 22 | read_cnt--; 23 | *ptr = *read_ptr++; 24 | return(1); 25 | } 26 | 27 | ssize_t 28 | readline(int fd, void *vptr, size_t maxlen) 29 | { 30 | int n, rc; 31 | char c, *ptr; 32 | 33 | ptr = vptr; 34 | for (n = 1; n < maxlen; n++) { 35 | if ( (rc = my_read(fd, &c)) == 1) { 36 | *ptr++ = c; 37 | if (c == '\n') 38 | break; /* newline is stored, like fgets() */ 39 | } else if (rc == 0) { 40 | if (n == 1) 41 | return(0); /* EOF, no data read */ 42 | else 43 | break; /* EOF, some data was read */ 44 | } else 45 | return(-1); /* error, errno set by read() */ 46 | } 47 | 48 | *ptr = 0; /* null terminate like fgets() */ 49 | return(n); 50 | } 51 | /* end readline */ 52 | 53 | ssize_t 54 | Readline(int fd, void *ptr, size_t maxlen) 55 | { 56 | ssize_t n; 57 | 58 | if ( (n = readline(fd, ptr, maxlen)) < 0) 59 | err_sys("readline error"); 60 | return(n); 61 | } 62 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-N.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT", 23 | }, 24 | content => $dummyfile 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/dummy.txt"; 29 | 30 | my $expected_error_code = 0; 31 | 32 | my %expected_downloaded_files = ( 33 | 'dummy.txt' => { 34 | content => $dummyfile, 35 | timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT" 36 | } 37 | ); 38 | 39 | ############################################################################### 40 | 41 | my $the_test = HTTPTest->new (name => "Test-N", 42 | input => \%urls, 43 | cmdline => $cmdline, 44 | errcode => $expected_error_code, 45 | output => \%expected_downloaded_files); 46 | exit $the_test->run(); 47 | 48 | # vim: et ts=4 sw=4 49 | 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-ftp-recursive.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use FTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $afile = < { 25 | content => $afile, 26 | }, 27 | '/bar/baz/bfile.txt' => { 28 | content => $bfile, 29 | }, 30 | ); 31 | 32 | my $cmdline = $WgetTest::WGETPATH . " -S -nH -r ftp://localhost:{{port}}/"; 33 | 34 | my $expected_error_code = 0; 35 | 36 | my %expected_downloaded_files = ( 37 | 'foo/afile.txt' => { 38 | content => $afile, 39 | }, 40 | 'bar/baz/bfile.txt' => { 41 | content => $bfile, 42 | }, 43 | ); 44 | 45 | ############################################################################### 46 | 47 | my $the_test = FTPTest->new (name => "Test-ftp-recursive", 48 | input => \%urls, 49 | cmdline => $cmdline, 50 | errcode => $expected_error_code, 51 | output => \%expected_downloaded_files); 52 | exit $the_test->run(); 53 | 54 | # vim: et ts=4 sw=4 55 | 56 | -------------------------------------------------------------------------------- /roman/soln/readline.c: -------------------------------------------------------------------------------- 1 | /* include readline */ 2 | #include "unp.h" 3 | 4 | static ssize_t 5 | my_read(int fd, char *ptr) 6 | { 7 | static int read_cnt = 0; 8 | static char *read_ptr; 9 | static char read_buf[MAXLINE]; 10 | 11 | if (read_cnt <= 0) { 12 | again: 13 | if ( (read_cnt = read(fd, read_buf, sizeof(read_buf))) < 0) { 14 | if (errno == EINTR) 15 | goto again; 16 | return(-1); 17 | } else if (read_cnt == 0) 18 | return(0); 19 | read_ptr = read_buf; 20 | } 21 | 22 | read_cnt--; 23 | *ptr = *read_ptr++; 24 | return(1); 25 | } 26 | 27 | ssize_t 28 | readline(int fd, void *vptr, size_t maxlen) 29 | { 30 | int n, rc; 31 | char c, *ptr; 32 | 33 | ptr = vptr; 34 | for (n = 1; n < maxlen; n++) { 35 | if ( (rc = my_read(fd, &c)) == 1) { 36 | *ptr++ = c; 37 | if (c == '\n') 38 | break; /* newline is stored, like fgets() */ 39 | } else if (rc == 0) { 40 | if (n == 1) 41 | return(0); /* EOF, no data read */ 42 | else 43 | break; /* EOF, some data was read */ 44 | } else 45 | return(-1); /* error, errno set by read() */ 46 | } 47 | 48 | *ptr = 0; /* null terminate like fgets() */ 49 | return(n); 50 | } 51 | /* end readline */ 52 | 53 | ssize_t 54 | Readline(int fd, void *ptr, size_t maxlen) 55 | { 56 | ssize_t n; 57 | 58 | if ( (n = readline(fd, ptr, maxlen)) < 0) 59 | err_sys("readline error"); 60 | return(n); 61 | } 62 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-noop.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $index = < 13 | 14 | Page Title 15 | 16 | 17 |

Page Title

18 |

19 | Some text here. 20 |

21 | 22 | 23 | EOF 24 | 25 | # code, msg, headers, content 26 | my %urls = ( 27 | '/index.html' => { 28 | code => "200", 29 | msg => "Dontcare", 30 | headers => { 31 | "Content-type" => "text/html", 32 | }, 33 | content => $index 34 | }, 35 | ); 36 | 37 | my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/"; 38 | 39 | my $expected_error_code = 0; 40 | 41 | my %expected_downloaded_files = ( 42 | 'index.html' => { 43 | content => $index, 44 | } 45 | ); 46 | 47 | ############################################################################### 48 | 49 | my $the_test = HTTPTest->new (name => "Test-noop", 50 | input => \%urls, 51 | cmdline => $cmdline, 52 | errcode => $expected_error_code, 53 | output => \%expected_downloaded_files); 54 | exit $the_test->run(); 55 | 56 | # vim: et ts=4 sw=4 57 | 58 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-O--no-content-disposition.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | "Content-Disposition" => "attachment; filename=\"filename.txt\"", 23 | }, 24 | content => $dummyfile 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:{{port}}/dummy.txt"; 29 | 30 | my $expected_error_code = 0; 31 | 32 | my %expected_downloaded_files = ( 33 | 'out' => { 34 | content => $dummyfile, 35 | } 36 | ); 37 | 38 | ############################################################################### 39 | 40 | my $the_test = HTTPTest->new (name => "Test-O--no-content-disposition", 41 | input => \%urls, 42 | cmdline => $cmdline, 43 | errcode => $expected_error_code, 44 | output => \%expected_downloaded_files); 45 | exit $the_test->run(); 46 | 47 | # vim: et ts=4 sw=4 48 | 49 | -------------------------------------------------------------------------------- /roman/soln/tcpserv01.c: -------------------------------------------------------------------------------- 1 | #include "unp.h" 2 | 3 | char *reply = "HTTP/1.0 200 OK\r\n" 4 | "\r\n" 5 | "1111\r\n" 6 | "\r\n"; 7 | 8 | void handle_request(int sockfd) 9 | { 10 | ssize_t n; 11 | char line[MAXLINE]; 12 | 13 | n = Readline(sockfd, line, MAXLINE); 14 | if (n == 0) { 15 | return; 16 | } 17 | printf("Received %s\n", line); 18 | 19 | printf("Sending %s\n", reply); 20 | n = strlen(reply); 21 | Writen(sockfd, reply, n); 22 | } 23 | 24 | int main(int argc, char **argv) 25 | { 26 | int listenfd, connfd; 27 | pid_t childpid; 28 | socklen_t clilen; 29 | struct sockaddr_in cliaddr, servaddr; 30 | 31 | listenfd = Socket(AF_INET, SOCK_STREAM, 0); 32 | 33 | bzero(&servaddr, sizeof(servaddr)); 34 | servaddr.sin_family = AF_INET; 35 | servaddr.sin_addr.s_addr = htonl(INADDR_ANY); 36 | servaddr.sin_port = htons(8081); 37 | 38 | Bind(listenfd, (SA *) &servaddr, sizeof(servaddr)); 39 | 40 | Listen(listenfd, LISTENQ); 41 | printf("Listening\n"); 42 | 43 | for ( ; ; ) { 44 | clilen = sizeof(cliaddr); 45 | connfd = Accept(listenfd, (SA *) &cliaddr, &clilen); 46 | printf("Accepted\n"); 47 | 48 | if ( (childpid = Fork()) == 0) { 49 | printf("Forked\n"); 50 | Close(listenfd); 51 | handle_request(connfd); 52 | exit(0); 53 | } 54 | Close(connfd); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/sigaction.m4: -------------------------------------------------------------------------------- 1 | # sigaction.m4 serial 7 2 | dnl Copyright (C) 2008-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Determine if sigaction interface is present. 8 | AC_DEFUN([gl_SIGACTION], 9 | [ 10 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 11 | AC_CHECK_FUNCS_ONCE([sigaction]) 12 | if test $ac_cv_func_sigaction = yes; then 13 | AC_CHECK_MEMBERS([struct sigaction.sa_sigaction], , , 14 | [[#include ]]) 15 | if test $ac_cv_member_struct_sigaction_sa_sigaction = no; then 16 | HAVE_STRUCT_SIGACTION_SA_SIGACTION=0 17 | fi 18 | else 19 | HAVE_SIGACTION=0 20 | fi 21 | ]) 22 | 23 | # Prerequisites of the part of lib/signal.in.h and of lib/sigaction.c. 24 | AC_DEFUN([gl_PREREQ_SIGACTION], 25 | [ 26 | AC_REQUIRE([gl_SIGNAL_H_DEFAULTS]) 27 | AC_REQUIRE([AC_C_RESTRICT]) 28 | AC_REQUIRE([AC_TYPE_UID_T]) 29 | AC_REQUIRE([gl_PREREQ_SIG_HANDLER_H]) 30 | AC_CHECK_FUNCS_ONCE([sigaltstack siginterrupt]) 31 | AC_CHECK_TYPES([siginfo_t], [], [], [[ 32 | #include 33 | ]]) 34 | if test $ac_cv_type_siginfo_t = no; then 35 | HAVE_SIGINFO_T=0 36 | fi 37 | ]) 38 | 39 | # Prerequisites of lib/sig-handler.h. 40 | AC_DEFUN([gl_PREREQ_SIG_HANDLER_H], [:]) 41 | -------------------------------------------------------------------------------- /hw02/wget-1.15/src/build_info.c: -------------------------------------------------------------------------------- 1 | /* Autogenerated by build_info.pl - DO NOT EDIT */ 2 | 3 | /* This stores global variables that are initialized with 4 | preprocessor declarations for output with the --version flag. 5 | 6 | Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 7 | 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. */ 8 | 9 | #include "wget.h" 10 | #include 11 | 12 | const char *compiled_features[] = 13 | { 14 | 15 | #if defined ENABLE_DIGEST 16 | "+digest", 17 | #else 18 | "-digest", 19 | #endif 20 | 21 | #if defined HAVE_SSL 22 | "+https", 23 | #else 24 | "-https", 25 | #endif 26 | 27 | #if defined ENABLE_IPV6 28 | "+ipv6", 29 | #else 30 | "-ipv6", 31 | #endif 32 | 33 | #if defined ENABLE_IRI 34 | "+iri", 35 | #else 36 | "-iri", 37 | #endif 38 | 39 | #if SIZEOF_OFF_T >= 8 40 | "+large-file", 41 | #else 42 | "-large-file", 43 | #endif 44 | 45 | #if defined ENABLE_NLS 46 | "+nls", 47 | #else 48 | "-nls", 49 | #endif 50 | 51 | #if defined ENABLE_NTLM 52 | "+ntlm", 53 | #else 54 | "-ntlm", 55 | #endif 56 | 57 | #if defined ENABLE_OPIE 58 | "+opie", 59 | #else 60 | "-opie", 61 | #endif 62 | 63 | #if defined HAVE_LIBSSL || defined HAVE_LIBSSL32 64 | "+ssl/openssl", 65 | #elif defined HAVE_LIBGNUTLS 66 | "+ssl/gnutls", 67 | #else 68 | "-ssl", 69 | #endif 70 | 71 | 72 | /* sentinel value */ 73 | NULL 74 | }; 75 | 76 | 77 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/certs/server-cert.pem: -------------------------------------------------------------------------------- 1 | -----BEGIN CERTIFICATE----- 2 | MIIDnDCCAwWgAwIBAgIJAIsoR6UicPPEMA0GCSqGSIb3DQEBBQUAMIGRMQswCQYD 3 | VQQGEwJVUzETMBEGA1UECBMKQ2FsaWZvcm5pYTETMBEGA1UEBxMKU2FudGEgQ2xh 4 | YTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRQwEgYDVQQDEwtN 5 | aWNhaCBDb3dhbjEfMB0GCSqGSIb3DQEJARYQbWljYWhAY293YW4ubmFtZTAeFw0w 6 | ODA0MjIwNTQxNDBaFw0wODA1MjIwNTQxNDBaMIGRMQswCQYDVQQGEwJVUzETMBEG 7 | A1UECBMKQ2FsaWZvcm5pYTETMBEGA1UEBxMKU2FudGEgQ2xhYTEhMB8GA1UEChMY 8 | SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRQwEgYDVQQDEwtNaWNhaCBDb3dhbjEf 9 | MB0GCSqGSIb3DQEJARYQbWljYWhAY293YW4ubmFtZTCBnzANBgkqhkiG9w0BAQEF 10 | AAOBjQAwgYkCgYEAxgJGqBxMUjykBTWHg0jTAH59WbxV6JLMAirwskri0u9o6m9f 11 | Xw/ZsteKxmypgvwPcDoqZFWF5TB4sEf2l2m7N++mOLtjS9PLBaE8Y0siF1+EMXrI 12 | mffet9PeXXceuTMFx6bTzls7EwLMvmvSynwFK1j9EHH0mFA19MkeQwWG5zECAwEA 13 | AaOB+TCB9jAdBgNVHQ4EFgQU0LEi7ld7tvUls/fmbmn80+b//TAwgcYGA1UdIwSB 14 | vjCBu4AU0LEi7ld7tvUls/fmbmn80+b//TChgZekgZQwgZExCzAJBgNVBAYTAlVT 15 | MRMwEQYDVQQIEwpDYWxpZm9ybmlhMRMwEQYDVQQHEwpTYW50YSBDbGFhMSEwHwYD 16 | VQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxFDASBgNVBAMTC01pY2FoIENv 17 | d2FuMR8wHQYJKoZIhvcNAQkBFhBtaWNhaEBjb3dhbi5uYW1lggkAiyhHpSJw88Qw 18 | DAYDVR0TBAUwAwEB/zANBgkqhkiG9w0BAQUFAAOBgQBOSi75jsItAkhiYW0Up1d8 19 | OFA1saDlxBDm7ZUQTcfxIQL75iYfxMUEWeWPRLmNId96a1PgMT6U2+vKrnoNj8bu 20 | R45xNaFPKxOzp7axWSOp9AJcR6neug2v7lKkKOcQ14dFlKH1AoP+fDuvSAZyfMeC 21 | 7fbIfz3XFNxaR4Rd07w/OQ== 22 | -----END CERTIFICATE----- 23 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/spawnp.c: -------------------------------------------------------------------------------- 1 | /* Copyright (C) 2000, 2009-2013 Free Software Foundation, Inc. 2 | This file is part of the GNU C Library. 3 | 4 | This program is free software: you can redistribute it and/or modify 5 | it under the terms of the GNU General Public License as published by 6 | the Free Software Foundation; either version 3 of the License, or 7 | (at your option) any later version. 8 | 9 | This program is distributed in the hope that it will be useful, 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | GNU General Public License for more details. 13 | 14 | You should have received a copy of the GNU General Public License 15 | along with this program. If not, see . */ 16 | 17 | #include 18 | 19 | /* Specification. */ 20 | #include 21 | 22 | #include "spawn_int.h" 23 | 24 | /* Spawn a new process executing FILE with the attributes describes in *ATTRP. 25 | Before running the process perform the actions described in FILE-ACTIONS. */ 26 | int 27 | posix_spawnp (pid_t *pid, const char *file, 28 | const posix_spawn_file_actions_t *file_actions, 29 | const posix_spawnattr_t *attrp, char *const argv[], 30 | char *const envp[]) 31 | { 32 | return __spawni (pid, file, file_actions, attrp, argv, envp, 1); 33 | } 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-ftp-iri-disabled.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use WgetFeature qw(iri); 7 | use FTPTest; 8 | 9 | 10 | ############################################################################### 11 | 12 | my $ccedilla_l1 = "\xE7"; 13 | my $ccedilla_u8 = "\xC3\xA7"; 14 | 15 | my $francais = < { 25 | content => $francais, 26 | }, 27 | "/fran${ccedilla_l1}ais.txt" => { 28 | content => $francais, 29 | }, 30 | ); 31 | 32 | my $cmdline = $WgetTest::WGETPATH . " --no-iri --local-encoding=iso-8859-1 -S ftp://localhost:{{port}}/fran${ccedilla_l1}ais.txt"; 33 | 34 | my $expected_error_code = 0; 35 | 36 | my %expected_downloaded_files = ( 37 | "fran${ccedilla_l1}ais.txt" => { 38 | content => $francais, 39 | }, 40 | ); 41 | 42 | ############################################################################### 43 | 44 | my $the_test = FTPTest->new (name => "Test-ftp-iri-disabled", 45 | input => \%urls, 46 | cmdline => $cmdline, 47 | errcode => $expected_error_code, 48 | output => \%expected_downloaded_files); 49 | exit $the_test->run(); 50 | 51 | # vim: et ts=4 sw=4 52 | 53 | -------------------------------------------------------------------------------- /lecture24/mem_errors.c: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2014 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | 13 | void free_anything(int *p) { 14 | free(p); 15 | } 16 | 17 | int read_element(int *array, int index) { 18 | int x = array[index]; 19 | return x; 20 | } 21 | 22 | 23 | int main () 24 | { 25 | int never_allocated; 26 | int *free_twice = malloc (sizeof (int)); 27 | int *use_after_free = malloc (sizeof (int)); 28 | int *never_free = malloc (sizeof (int)); 29 | int array1[100]; 30 | int *array2 = malloc (100 * sizeof (int)); 31 | 32 | // valgrind does not bounds-check static arrays 33 | read_element(array1, -1); 34 | read_element(array1, 100); 35 | 36 | // but it does bounds-check dynamic arrays 37 | read_element(array2, -1); 38 | read_element(array2, 100); 39 | 40 | // and it catches use after free 41 | free(use_after_free); 42 | *use_after_free = 17; 43 | 44 | // never_free is definitely lost 45 | *never_free = 17; 46 | 47 | // the following line would generate a warning 48 | // free(&never_allocated); 49 | 50 | // but this one doesn't 51 | free_anything(&never_allocated); 52 | 53 | free(free_twice); 54 | free(free_twice); 55 | 56 | return 0; 57 | } 58 | 59 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/gettime.c: -------------------------------------------------------------------------------- 1 | /* gettime -- get the system clock 2 | 3 | Copyright (C) 2002, 2004-2007, 2009-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paul Eggert. */ 19 | 20 | #include 21 | 22 | #include "timespec.h" 23 | 24 | #include 25 | 26 | /* Get the system time into *TS. */ 27 | 28 | void 29 | gettime (struct timespec *ts) 30 | { 31 | #if HAVE_NANOTIME 32 | nanotime (ts); 33 | #else 34 | 35 | # if defined CLOCK_REALTIME && HAVE_CLOCK_GETTIME 36 | if (clock_gettime (CLOCK_REALTIME, ts) == 0) 37 | return; 38 | # endif 39 | 40 | { 41 | struct timeval tv; 42 | gettimeofday (&tv, NULL); 43 | ts->tv_sec = tv.tv_sec; 44 | ts->tv_nsec = tv.tv_usec * 1000; 45 | } 46 | 47 | #endif 48 | } 49 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/utimbuf.m4: -------------------------------------------------------------------------------- 1 | # serial 9 2 | 3 | # Copyright (C) 1998-2001, 2003-2004, 2007, 2009-2013 Free Software Foundation, 4 | # Inc. 5 | # 6 | # This file is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | dnl From Jim Meyering 11 | 12 | dnl Define HAVE_STRUCT_UTIMBUF if 'struct utimbuf' is declared -- 13 | dnl usually in . 14 | dnl Some systems have utime.h but don't declare the struct anywhere. 15 | 16 | AC_DEFUN([gl_CHECK_TYPE_STRUCT_UTIMBUF], 17 | [ 18 | AC_CHECK_HEADERS_ONCE([sys/time.h utime.h]) 19 | AC_CACHE_CHECK([for struct utimbuf], [gl_cv_sys_struct_utimbuf], 20 | [AC_COMPILE_IFELSE( 21 | [AC_LANG_PROGRAM( 22 | [[#if HAVE_SYS_TIME_H 23 | #include 24 | #endif 25 | #include 26 | #ifdef HAVE_UTIME_H 27 | #include 28 | #endif 29 | ]], 30 | [[static struct utimbuf x; x.actime = x.modtime;]])], 31 | [gl_cv_sys_struct_utimbuf=yes], 32 | [gl_cv_sys_struct_utimbuf=no])]) 33 | 34 | if test $gl_cv_sys_struct_utimbuf = yes; then 35 | AC_DEFINE([HAVE_STRUCT_UTIMBUF], [1], 36 | [Define if struct utimbuf is declared -- usually in . 37 | Some systems have utime.h but don't declare the struct anywhere. ]) 38 | fi 39 | ]) 40 | -------------------------------------------------------------------------------- /hw02/wget-1.15/po/en@boldquot.header: -------------------------------------------------------------------------------- 1 | # All this catalog "translates" are quotation characters. 2 | # The msgids must be ASCII and therefore cannot contain real quotation 3 | # characters, only substitutes like grave accent (0x60), apostrophe (0x27) 4 | # and double quote (0x22). These substitutes look strange; see 5 | # http://www.cl.cam.ac.uk/~mgk25/ucs/quotes.html 6 | # 7 | # This catalog translates grave accent (0x60) and apostrophe (0x27) to 8 | # left single quotation mark (U+2018) and right single quotation mark (U+2019). 9 | # It also translates pairs of apostrophe (0x27) to 10 | # left single quotation mark (U+2018) and right single quotation mark (U+2019) 11 | # and pairs of quotation mark (0x22) to 12 | # left double quotation mark (U+201C) and right double quotation mark (U+201D). 13 | # 14 | # When output to an UTF-8 terminal, the quotation characters appear perfectly. 15 | # When output to an ISO-8859-1 terminal, the single quotation marks are 16 | # transliterated to apostrophes (by iconv in glibc 2.2 or newer) or to 17 | # grave/acute accent (by libiconv), and the double quotation marks are 18 | # transliterated to 0x22. 19 | # When output to an ASCII terminal, the single quotation marks are 20 | # transliterated to apostrophes, and the double quotation marks are 21 | # transliterated to 0x22. 22 | # 23 | # This catalog furthermore displays the text between the quotation marks in 24 | # bold face, assuming the VT100/XTerm escape sequences. 25 | # 26 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-Restrict-Lowercase.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $mainpage = < 13 | 14 | Some Page Title 15 | 16 | 17 |

18 | Some text... 19 |

20 | 21 | 22 | EOF 23 | 24 | # code, msg, headers, content 25 | my %urls = ( 26 | '/SomePage.html' => { 27 | code => "200", 28 | msg => "Dontcare", 29 | headers => { 30 | "Content-type" => "text/html", 31 | }, 32 | content => $mainpage, 33 | }, 34 | ); 35 | 36 | my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=lowercase http://localhost:{{port}}/SomePage.html"; 37 | 38 | my $expected_error_code = 0; 39 | 40 | my %expected_downloaded_files = ( 41 | 'somepage.html' => { 42 | content => $mainpage, 43 | }, 44 | ); 45 | 46 | ############################################################################### 47 | 48 | my $the_test = HTTPTest->new (name => "Test-Restrict-Lowercase", 49 | input => \%urls, 50 | cmdline => $cmdline, 51 | errcode => $expected_error_code, 52 | output => \%expected_downloaded_files); 53 | exit $the_test->run(); 54 | 55 | # vim: et ts=4 sw=4 56 | 57 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-Restrict-Uppercase.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $mainpage = < 13 | 14 | Some Page Title 15 | 16 | 17 |

18 | Some text... 19 |

20 | 21 | 22 | EOF 23 | 24 | # code, msg, headers, content 25 | my %urls = ( 26 | '/SomePage.html' => { 27 | code => "200", 28 | msg => "Dontcare", 29 | headers => { 30 | "Content-type" => "text/html", 31 | }, 32 | content => $mainpage, 33 | }, 34 | ); 35 | 36 | my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=uppercase http://localhost:{{port}}/SomePage.html"; 37 | 38 | my $expected_error_code = 0; 39 | 40 | my %expected_downloaded_files = ( 41 | 'SOMEPAGE.HTML' => { 42 | content => $mainpage, 43 | }, 44 | ); 45 | 46 | ############################################################################### 47 | 48 | my $the_test = HTTPTest->new (name => "Test-Restrict-Uppercase", 49 | input => \%urls, 50 | cmdline => $cmdline, 51 | errcode => $expected_error_code, 52 | output => \%expected_downloaded_files); 53 | exit $the_test->run(); 54 | 55 | # vim: et ts=4 sw=4 56 | 57 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-auth-basic.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $wholefile = "You're all authenticated.\n"; 12 | 13 | # code, msg, headers, content 14 | my %urls = ( 15 | '/needs-auth.txt' => { 16 | auth_method => 'Basic', 17 | user => 'fiddle-dee-dee', 18 | passwd => 'Dodgson', 19 | code => "200", 20 | msg => "You want fries with that?", 21 | headers => { 22 | "Content-type" => "text/plain", 23 | }, 24 | content => $wholefile, 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee --password=Dodgson" 29 | . " http://localhost:{{port}}/needs-auth.txt"; 30 | 31 | my $expected_error_code = 0; 32 | 33 | my %expected_downloaded_files = ( 34 | 'needs-auth.txt' => { 35 | content => $wholefile, 36 | }, 37 | ); 38 | 39 | ############################################################################### 40 | 41 | my $the_test = HTTPTest->new (name => "Test-auth-basic", 42 | input => \%urls, 43 | cmdline => $cmdline, 44 | errcode => $expected_error_code, 45 | output => \%expected_downloaded_files); 46 | exit $the_test->run(); 47 | 48 | # vim: et ts=4 sw=4 49 | 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test--no-content-disposition-trivial.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < 13 | 14 | Page Title 15 | 16 | 17 |

18 | Some text. 19 |

20 | 21 | 22 | EOF 23 | 24 | # code, msg, headers, content 25 | my %urls = ( 26 | '/dummy.html' => { 27 | code => "200", 28 | msg => "Dontcare", 29 | headers => { 30 | "Content-type" => "text/html", 31 | }, 32 | content => $dummyfile, 33 | }, 34 | ); 35 | 36 | my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html"; 37 | 38 | my $expected_error_code = 0; 39 | 40 | my %expected_downloaded_files = ( 41 | 'dummy.html' => { 42 | content => $dummyfile, 43 | } 44 | ); 45 | 46 | ############################################################################### 47 | 48 | my $the_test = HTTPTest->new (name => "Test--no-content-disposition-trivial", 49 | input => \%urls, 50 | cmdline => $cmdline, 51 | errcode => $expected_error_code, 52 | output => \%expected_downloaded_files); 53 | exit $the_test->run(); 54 | 55 | # vim: et ts=4 sw=4 56 | 57 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-cookies-401.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $content = "You got it.\n"; 12 | 13 | # code, msg, headers, content 14 | my %urls = ( 15 | '/one.txt' => { 16 | code => "401", 17 | msg => "Forbidden", 18 | headers => { 19 | "Set-Cookie" => "foo=bar", 20 | }, 21 | }, 22 | '/two.txt' => { 23 | code => "200", 24 | msg => "Ok", 25 | content => $content, 26 | request_headers => { 27 | "Cookie" => qr|foo=bar|, 28 | }, 29 | }, 30 | ); 31 | 32 | my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/one.txt" 33 | . " http://localhost:{{port}}/two.txt"; 34 | 35 | my $expected_error_code = 6; 36 | 37 | my %expected_downloaded_files = ( 38 | 'two.txt' => { 39 | content => $content, 40 | }, 41 | ); 42 | 43 | ############################################################################### 44 | 45 | my $the_test = HTTPTest->new (name => "Test-cookies-401", 46 | input => \%urls, 47 | cmdline => $cmdline, 48 | errcode => $expected_error_code, 49 | output => \%expected_downloaded_files); 50 | exit $the_test->run(); 51 | 52 | # vim: et ts=4 sw=4 53 | 54 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/listen.c: -------------------------------------------------------------------------------- 1 | /* listen.c --- wrappers for Windows listen function 2 | 3 | Copyright (C) 2008-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paolo Bonzini */ 19 | 20 | #include 21 | 22 | #define WIN32_LEAN_AND_MEAN 23 | /* Get winsock2.h. */ 24 | #include 25 | 26 | /* Get set_winsock_errno, FD_TO_SOCKET etc. */ 27 | #include "w32sock.h" 28 | 29 | #undef listen 30 | 31 | int 32 | rpl_listen (int fd, int backlog) 33 | { 34 | SOCKET sock = FD_TO_SOCKET (fd); 35 | 36 | if (sock == INVALID_SOCKET) 37 | { 38 | errno = EBADF; 39 | return -1; 40 | } 41 | else 42 | { 43 | int r = listen (sock, backlog); 44 | if (r < 0) 45 | set_winsock_errno (); 46 | 47 | return r; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-N--no-content-disposition-trivial.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < { 18 | code => "200", 19 | msg => "Dontcare", 20 | headers => { 21 | "Content-type" => "text/plain", 22 | "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT", 23 | }, 24 | content => $dummyfile 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:{{port}}/dummy.txt"; 29 | 30 | my $expected_error_code = 0; 31 | 32 | my %expected_downloaded_files = ( 33 | 'dummy.txt' => { 34 | content => $dummyfile, 35 | timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT" 36 | } 37 | ); 38 | 39 | ############################################################################### 40 | 41 | my $the_test = HTTPTest->new (name => "Test-N--no-content-disposition-trivial", 42 | input => \%urls, 43 | cmdline => $cmdline, 44 | errcode => $expected_error_code, 45 | output => \%expected_downloaded_files); 46 | exit $the_test->run(); 47 | 48 | # vim: et ts=4 sw=4 49 | 50 | -------------------------------------------------------------------------------- /lecture13/rational.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | typedef struct { 8 | int numer; 9 | int denom; 10 | } Rational; 11 | 12 | // Returns a new Rational with the given numer and denom. 13 | // If unable to allocate, prints an error message and exits. 14 | Rational *make_rational(int numer, int denom) { 15 | // FILL THIS IN 16 | return NULL; 17 | } 18 | 19 | // Computes a floating-point approximation of a Rational. 20 | double rational_to_double(Rational *rational) { 21 | // FILL THIS IN 22 | return 0.0; 23 | } 24 | 25 | // Multiplies two rational numbers; returns a new Rational. 26 | Rational *mult_rational(Rational *r1, Rational *r2) { 27 | // FILL THIS IN 28 | return NULL; 29 | } 30 | 31 | // Frees a Rational. 32 | void free_rational(Rational *rational) { 33 | free(rational); 34 | } 35 | 36 | // Prints a rational in fraction form. 37 | void print_rational(Rational *rational) { 38 | printf("%d / %d\n", rational->numer, rational->denom); 39 | } 40 | 41 | int main(void) 42 | { 43 | Rational *rational = make_rational(3, 7); 44 | print_rational(rational); 45 | 46 | double d = rational_to_double(rational); 47 | printf("%lf\n", d); 48 | 49 | Rational *square = mult_rational(rational, rational); 50 | print_rational(square); 51 | 52 | free_rational(rational); 53 | free_rational(square); 54 | 55 | return EXIT_SUCCESS; 56 | } 57 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/dup-safer-flag.c: -------------------------------------------------------------------------------- 1 | /* Duplicate a file descriptor result, avoiding clobbering 2 | STD{IN,OUT,ERR}_FILENO, with specific flags. 3 | 4 | Copyright (C) 2001, 2004-2006, 2009-2013 Free Software Foundation, Inc. 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 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 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . */ 18 | 19 | /* Written by Paul Eggert and Eric Blake. */ 20 | 21 | #include 22 | 23 | /* Specification. */ 24 | #include "unistd-safer.h" 25 | 26 | #include 27 | #include 28 | 29 | /* Like dup, but do not return STDIN_FILENO, STDOUT_FILENO, or 30 | STDERR_FILENO. If FLAG contains O_CLOEXEC, behave like 31 | fcntl(F_DUPFD_CLOEXEC) rather than fcntl(F_DUPFD). */ 32 | 33 | int 34 | dup_safer_flag (int fd, int flag) 35 | { 36 | return fcntl (fd, (flag & O_CLOEXEC) ? F_DUPFD_CLOEXEC : F_DUPFD, 37 | STDERR_FILENO + 1); 38 | } 39 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/float.c: -------------------------------------------------------------------------------- 1 | /* Auxiliary definitions for . 2 | Copyright (C) 2011-2013 Free Software Foundation, Inc. 3 | Written by Bruno Haible , 2011. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | #include 19 | 20 | /* Specification. */ 21 | #include 22 | 23 | #if (defined _ARCH_PPC || defined _POWER) && (defined _AIX || defined __linux__) && (LDBL_MANT_DIG == 106) && defined __GNUC__ 24 | const union gl_long_double_union gl_LDBL_MAX = 25 | { { DBL_MAX, DBL_MAX / (double)134217728UL / (double)134217728UL } }; 26 | #elif defined __i386__ 27 | const union gl_long_double_union gl_LDBL_MAX = 28 | { { 0xFFFFFFFF, 0xFFFFFFFF, 32766 } }; 29 | #else 30 | /* This declaration is solely to ensure that after preprocessing 31 | this file is never empty. */ 32 | typedef int dummy; 33 | #endif 34 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/localcharset.h: -------------------------------------------------------------------------------- 1 | /* Determine a canonical name for the current locale's character encoding. 2 | Copyright (C) 2000-2003, 2009-2013 Free Software Foundation, Inc. 3 | This file is part of the GNU CHARSET Library. 4 | 5 | This program is free software; you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3, or (at your option) 8 | any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License along 16 | with this program; if not, see . */ 17 | 18 | #ifndef _LOCALCHARSET_H 19 | #define _LOCALCHARSET_H 20 | 21 | 22 | #ifdef __cplusplus 23 | extern "C" { 24 | #endif 25 | 26 | 27 | /* Determine the current locale's character encoding, and canonicalize it 28 | into one of the canonical names listed in config.charset. 29 | The result must not be freed; it is statically allocated. 30 | If the canonical name cannot be determined, the result is a non-canonical 31 | name. */ 32 | extern const char * locale_charset (void); 33 | 34 | 35 | #ifdef __cplusplus 36 | } 37 | #endif 38 | 39 | 40 | #endif /* _LOCALCHARSET_H */ 41 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/00gnulib.m4: -------------------------------------------------------------------------------- 1 | # 00gnulib.m4 serial 2 2 | dnl Copyright (C) 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | dnl This file must be named something that sorts before all other 8 | dnl gnulib-provided .m4 files. It is needed until such time as we can 9 | dnl assume Autoconf 2.64, with its improved AC_DEFUN_ONCE semantics. 10 | 11 | # AC_DEFUN_ONCE([NAME], VALUE) 12 | # ---------------------------- 13 | # Define NAME to expand to VALUE on the first use (whether by direct 14 | # expansion, or by AC_REQUIRE), and to nothing on all subsequent uses. 15 | # Avoid bugs in AC_REQUIRE in Autoconf 2.63 and earlier. This 16 | # definition is slower than the version in Autoconf 2.64, because it 17 | # can only use interfaces that existed since 2.59; but it achieves the 18 | # same effect. Quoting is necessary to avoid confusing Automake. 19 | m4_version_prereq([2.63.263], [], 20 | [m4_define([AC][_DEFUN_ONCE], 21 | [AC][_DEFUN([$1], 22 | [AC_REQUIRE([_gl_DEFUN_ONCE([$1])], 23 | [m4_indir([_gl_DEFUN_ONCE([$1])])])])]dnl 24 | [AC][_DEFUN([_gl_DEFUN_ONCE([$1])], [$2])])]) 25 | 26 | # gl_00GNULIB 27 | # ----------- 28 | # Witness macro that this file has been included. Needed to force 29 | # Automake to include this file prior to all other gnulib .m4 files. 30 | AC_DEFUN([gl_00GNULIB]) 31 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/recv.c: -------------------------------------------------------------------------------- 1 | /* recv.c --- wrappers for Windows recv function 2 | 3 | Copyright (C) 2008-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paolo Bonzini */ 19 | 20 | #include 21 | 22 | #define WIN32_LEAN_AND_MEAN 23 | /* Get winsock2.h. */ 24 | #include 25 | 26 | /* Get set_winsock_errno, FD_TO_SOCKET etc. */ 27 | #include "w32sock.h" 28 | 29 | #undef recv 30 | 31 | ssize_t 32 | rpl_recv (int fd, void *buf, size_t len, int flags) 33 | { 34 | SOCKET sock = FD_TO_SOCKET (fd); 35 | 36 | if (sock == INVALID_SOCKET) 37 | { 38 | errno = EBADF; 39 | return -1; 40 | } 41 | else 42 | { 43 | int r = recv (sock, buf, len, flags); 44 | if (r < 0) 45 | set_winsock_errno (); 46 | 47 | return r; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/xalloc-die.c: -------------------------------------------------------------------------------- 1 | /* Report a memory allocation failure and exit. 2 | 3 | Copyright (C) 1997-2000, 2002-2004, 2006, 2009-2013 Free Software 4 | Foundation, Inc. 5 | 6 | This program is free software: you can redistribute it and/or modify 7 | it under the terms of the GNU General Public License as published by 8 | the Free Software Foundation; either version 3 of the License, or 9 | (at your option) any later version. 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 | GNU General Public License for more details. 15 | 16 | You should have received a copy of the GNU General Public License 17 | along with this program. If not, see . */ 18 | 19 | #include 20 | 21 | #include "xalloc.h" 22 | 23 | #include 24 | 25 | #include "error.h" 26 | #include "exitfail.h" 27 | 28 | #include "gettext.h" 29 | #define _(msgid) gettext (msgid) 30 | 31 | void 32 | xalloc_die (void) 33 | { 34 | error (exit_failure, 0, "%s", _("memory exhausted")); 35 | 36 | /* _Noreturn cannot be given to error, since it may return if 37 | its first argument is 0. To help compilers understand the 38 | xalloc_die does not return, call abort. Also, the abort is a 39 | safety feature if exit_failure is 0 (which shouldn't happen). */ 40 | abort (); 41 | } 42 | -------------------------------------------------------------------------------- /hw02/wget-1.15/m4/clock_time.m4: -------------------------------------------------------------------------------- 1 | # clock_time.m4 serial 10 2 | dnl Copyright (C) 2002-2006, 2009-2013 Free Software Foundation, Inc. 3 | dnl This file is free software; the Free Software Foundation 4 | dnl gives unlimited permission to copy and/or distribute it, 5 | dnl with or without modifications, as long as this notice is preserved. 6 | 7 | # Check for clock_gettime and clock_settime, and set LIB_CLOCK_GETTIME. 8 | # For a program named, say foo, you should add a line like the following 9 | # in the corresponding Makefile.am file: 10 | # foo_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) 11 | 12 | AC_DEFUN([gl_CLOCK_TIME], 13 | [ 14 | dnl Persuade glibc and Solaris to declare these functions. 15 | AC_REQUIRE([gl_USE_SYSTEM_EXTENSIONS]) 16 | 17 | # Solaris 2.5.1 needs -lposix4 to get the clock_gettime function. 18 | # Solaris 7 prefers the library name -lrt to the obsolescent name -lposix4. 19 | 20 | # Save and restore LIBS so e.g., -lrt, isn't added to it. Otherwise, *all* 21 | # programs in the package would end up linked with that potentially-shared 22 | # library, inducing unnecessary run-time overhead. 23 | LIB_CLOCK_GETTIME= 24 | AC_SUBST([LIB_CLOCK_GETTIME]) 25 | gl_saved_libs=$LIBS 26 | AC_SEARCH_LIBS([clock_gettime], [rt posix4], 27 | [test "$ac_cv_search_clock_gettime" = "none required" || 28 | LIB_CLOCK_GETTIME=$ac_cv_search_clock_gettime]) 29 | AC_CHECK_FUNCS([clock_gettime clock_settime]) 30 | LIBS=$gl_saved_libs 31 | ]) 32 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/bind.c: -------------------------------------------------------------------------------- 1 | /* bind.c --- wrappers for Windows bind function 2 | 3 | Copyright (C) 2008-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paolo Bonzini */ 19 | 20 | #include 21 | 22 | #define WIN32_LEAN_AND_MEAN 23 | /* Get winsock2.h. */ 24 | #include 25 | 26 | /* Get set_winsock_errno, FD_TO_SOCKET etc. */ 27 | #include "w32sock.h" 28 | 29 | #undef bind 30 | 31 | int 32 | rpl_bind (int fd, const struct sockaddr *sockaddr, socklen_t len) 33 | { 34 | SOCKET sock = FD_TO_SOCKET (fd); 35 | 36 | if (sock == INVALID_SOCKET) 37 | { 38 | errno = EBADF; 39 | return -1; 40 | } 41 | else 42 | { 43 | int r = bind (sock, sockaddr, len); 44 | if (r < 0) 45 | set_winsock_errno (); 46 | 47 | return r; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/lib/send.c: -------------------------------------------------------------------------------- 1 | /* send.c --- wrappers for Windows send function 2 | 3 | Copyright (C) 2008-2013 Free Software Foundation, Inc. 4 | 5 | This program is free software: you can redistribute it and/or modify 6 | it under the terms of the GNU General Public License as published by 7 | the Free Software Foundation; either version 3 of the License, or 8 | (at your option) any later version. 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 | GNU General Public License for more details. 14 | 15 | You should have received a copy of the GNU General Public License 16 | along with this program. If not, see . */ 17 | 18 | /* Written by Paolo Bonzini */ 19 | 20 | #include 21 | 22 | #define WIN32_LEAN_AND_MEAN 23 | /* Get winsock2.h. */ 24 | #include 25 | 26 | /* Get set_winsock_errno, FD_TO_SOCKET etc. */ 27 | #include "w32sock.h" 28 | 29 | #undef send 30 | 31 | ssize_t 32 | rpl_send (int fd, const void *buf, size_t len, int flags) 33 | { 34 | SOCKET sock = FD_TO_SOCKET (fd); 35 | 36 | if (sock == INVALID_SOCKET) 37 | { 38 | errno = EBADF; 39 | return -1; 40 | } 41 | else 42 | { 43 | int r = send (sock, buf, len, flags); 44 | if (r < 0) 45 | set_winsock_errno (); 46 | 47 | return r; 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /hw02/find_track.c: -------------------------------------------------------------------------------- 1 | /* Example code for Software Systems at Olin College. 2 | 3 | Copyright 2014 Allen Downey 4 | License: Creative Commons Attribution-ShareAlike 3.0 5 | 6 | */ 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | #define NUM_TRACKS 5 13 | 14 | char tracks[][80] = { 15 | "So What", 16 | "Freddie Freeloader", 17 | "Blue in Green", 18 | "All Blues", 19 | "Flamenco Sketches" 20 | }; 21 | 22 | 23 | // Finds all tracks that contain the given string. 24 | // 25 | // Prints track number and title. 26 | void find_track(char search_for[]) 27 | { 28 | int i; 29 | for (i=0; i { 16 | auth_method => 'Basic', 17 | user => 'fiddle-dee-dee', 18 | passwd => 'Dodgson', 19 | code => "200", 20 | msg => "You want fries with that?", 21 | headers => { 22 | "Content-type" => "text/plain", 23 | }, 24 | content => $wholefile, 25 | }, 26 | ); 27 | 28 | my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee --password=Dodgson" 29 | . " -e http_proxy=localhost:{{port}} http://no.such.domain/needs-auth.txt"; 30 | 31 | my $expected_error_code = 0; 32 | 33 | my %expected_downloaded_files = ( 34 | 'needs-auth.txt' => { 35 | content => $wholefile, 36 | }, 37 | ); 38 | 39 | ############################################################################### 40 | 41 | my $the_test = HTTPTest->new (name => "Test-auth-basic", 42 | input => \%urls, 43 | cmdline => $cmdline, 44 | errcode => $expected_error_code, 45 | output => \%expected_downloaded_files); 46 | exit $the_test->run(); 47 | 48 | # vim: et ts=4 sw=4 49 | 50 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test-auth-no-challenge-url.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $wholefile = "You're all authenticated.\n"; 12 | 13 | # code, msg, headers, content 14 | my %urls = ( 15 | '/needs-auth.txt' => { 16 | auth_no_challenge => 1, 17 | auth_method => 'Basic', 18 | user => 'fiddle-dee-dee', 19 | passwd => 'Dodgson', 20 | code => "200", 21 | msg => "You want fries with that?", 22 | headers => { 23 | "Content-type" => "text/plain", 24 | }, 25 | content => $wholefile, 26 | }, 27 | ); 28 | 29 | my $cmdline = $WgetTest::WGETPATH . " --auth-no-challenge " 30 | . "http://fiddle-dee-dee:Dodgson\@localhost:{{port}}/needs-auth.txt"; 31 | 32 | my $expected_error_code = 0; 33 | 34 | my %expected_downloaded_files = ( 35 | 'needs-auth.txt' => { 36 | content => $wholefile, 37 | }, 38 | ); 39 | 40 | ############################################################################### 41 | 42 | my $the_test = HTTPTest->new (name => "Test-auth-no-challenge-url", 43 | input => \%urls, 44 | cmdline => $cmdline, 45 | errcode => $expected_error_code, 46 | output => \%expected_downloaded_files); 47 | exit $the_test->run(); 48 | 49 | # vim: et ts=4 sw=4 50 | 51 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/FTPTest.pm: -------------------------------------------------------------------------------- 1 | package FTPTest; 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use FTPServer; 7 | use WgetTest; 8 | 9 | our @ISA = qw(WgetTest); 10 | my $VERSION = 0.01; 11 | 12 | 13 | { 14 | my %_attr_data = ( # DEFAULT 15 | ); 16 | 17 | sub _default_for 18 | { 19 | my ($self, $attr) = @_; 20 | return $_attr_data{$attr} if exists $_attr_data{$attr}; 21 | return $self->SUPER::_default_for($attr); 22 | } 23 | 24 | sub _standard_keys 25 | { 26 | my ($self) = @_; 27 | ($self->SUPER::_standard_keys(), keys %_attr_data); 28 | } 29 | } 30 | 31 | 32 | sub _setup_server { 33 | my $self = shift; 34 | 35 | $self->{_server} = FTPServer->new (input => $self->{_input}, 36 | server_behavior => 37 | $self->{_server_behavior}, 38 | LocalAddr => 'localhost', 39 | ReuseAddr => 1, 40 | rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!"; 41 | } 42 | 43 | 44 | sub _launch_server { 45 | my $self = shift; 46 | my $synch_func = shift; 47 | 48 | $self->{_server}->run ($synch_func); 49 | } 50 | 51 | sub _substitute_port { 52 | my $self = shift; 53 | my $ret = shift; 54 | $ret =~ s/{{port}}/$self->{_server}->sockport/eg; 55 | return $ret; 56 | } 57 | 58 | 1; 59 | 60 | # vim: et ts=4 sw=4 61 | 62 | -------------------------------------------------------------------------------- /hw02/wget-1.15/tests/Test--no-content-disposition.px: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | 3 | use strict; 4 | use warnings; 5 | 6 | use HTTPTest; 7 | 8 | 9 | ############################################################################### 10 | 11 | my $dummyfile = < 13 | 14 | Page Title 15 | 16 | 17 |

18 | Some text. 19 |

20 | 21 | 22 | EOF 23 | 24 | # code, msg, headers, content 25 | my %urls = ( 26 | '/dummy.html' => { 27 | code => "200", 28 | msg => "Dontcare", 29 | headers => { 30 | "Content-type" => "text/html", 31 | "Content-Disposition" => "attachment; filename=\"filename.html\"", 32 | }, 33 | content => $dummyfile, 34 | }, 35 | ); 36 | 37 | my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html"; 38 | 39 | my $expected_error_code = 0; 40 | 41 | my %expected_downloaded_files = ( 42 | 'dummy.html' => { 43 | content => $dummyfile, 44 | } 45 | ); 46 | 47 | ############################################################################### 48 | 49 | my $the_test = HTTPTest->new (name => "Test--no-content-disposition", 50 | input => \%urls, 51 | cmdline => $cmdline, 52 | errcode => $expected_error_code, 53 | output => \%expected_downloaded_files); 54 | exit $the_test->run(); 55 | 56 | # vim: et ts=4 sw=4 57 | 58 | -------------------------------------------------------------------------------- /hw02/wget-1.15/util/Makefile.am: -------------------------------------------------------------------------------- 1 | # Makefile for `wget' utility 2 | # Copyright (C) 1995, 1996, 1997, 2007, 2008, 2009, 2010, 2011 Free 3 | # Software Foundation, Inc. 4 | 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; either version 3 of the License, or 8 | # (at your option) any later version. 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 | # GNU General Public License for more details. 14 | 15 | # You should have received a copy of the GNU General Public License 16 | # along with this program. If not, see . 17 | 18 | # Additional permission under GNU GPL version 3 section 7 19 | 20 | # If you modify this program, or any covered work, by linking or 21 | # combining it with the OpenSSL project's OpenSSL library (or a 22 | # modified version of that library), containing parts covered by the 23 | # terms of the OpenSSL or SSLeay licenses, the Free Software Foundation 24 | # grants you additional permission to convey the resulting work. 25 | # Corresponding Source for a non-source form of such a combination 26 | # shall include the source code for the parts of OpenSSL used as well 27 | # as that of the covered work. 28 | 29 | # 30 | # Version: @VERSION@ 31 | # 32 | 33 | EXTRA_DIST = README rmold.pl trunc.c 34 | --------------------------------------------------------------------------------