From bc5affc51b2f6ad35ce197e2de336086f4ab1a68 Mon Sep 17 00:00:00 2001 From: shockrah Date: Sun, 8 Sep 2019 18:26:58 -0700 Subject: [PATCH] redid structure for 334 keeping things clean now --- 334/Makefile | 11 +++++- 334/bin | Bin 17112 -> 0 bytes 334/{ => homework/1}/bindec.c | 0 334/{responses => homework/1}/binhex.txt | 0 334/{responses => homework/1}/os-intro.txt | 0 334/homework/2/msh.c | 44 +++++++++++++++++++++ 334/homework/2/processes.txt | 22 +++++++++++ 334/homework/2/puzzle.txt | 32 +++++++++++++++ 8 files changed, 107 insertions(+), 2 deletions(-) delete mode 100755 334/bin rename 334/{ => homework/1}/bindec.c (100%) rename 334/{responses => homework/1}/binhex.txt (100%) rename 334/{responses => homework/1}/os-intro.txt (100%) create mode 100644 334/homework/2/msh.c create mode 100644 334/homework/2/processes.txt create mode 100644 334/homework/2/puzzle.txt diff --git a/334/Makefile b/334/Makefile index 5a2856f..f67c39b 100644 --- a/334/Makefile +++ b/334/Makefile @@ -1,3 +1,10 @@ # Single make file for everything becauz lazy -1: - gcc bindec.c -o bin +object=hw.c +cc=gcc +output=bin + +default: + $(cc) $(object) -o $(output) + +clean: + rm -f $(output) diff --git a/334/bin b/334/bin deleted file mode 100755 index c1564b356f1c9c6d129b1615086356073d3fcd36..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 17112 zcmeHOeQX@X6`%9v!;s|c1OoXe@s<+RKz*?TF%D_So$X83krP7Vq*TP&oPBHisC}2- z?FA=-){<%3t7Do!kQ%9_rK&2?f2vl6s(-YQG$<5=DhHJ|g(A5qR5qc-lt4`hx&GeF zyz}1rT%@*ArE15zee-_rW8S=-UGMD9d^y&>wIUD@T!P{*LEMRIg+#Pq#U@<=iHIh# z2*(<+Ml1k7Phv_QQ3O&|`YK9krN)DxWcP%Yd+8^%9#f8xDA~30zzTR@?v|26bs>@)1-jH)NMzhoUfB&aei|t9n}5)nxQ` zl=DeBq2IIGpO>~mMujQqQrY!}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^=V@viQvUbhlMd@ZD_&rR#W}c&9Lfs2bfj1GpP`dc@#ML=lj0065^QDpM73_0K8nk=IZZ{q@QKt(kI!o zqQ8*%>^zXPoc~`-vukFJhd)R^v(NkMTA%;_NEV0pWM%gFtV9O_V)l4giTgqY{WtNP zmo?B|hP(~w|98}XDq&O%St~ufB=OnfYCG_9`zQ7TFSj2e4ZIrTlh@O8E4AdOV)k`< zcn<$xp9BBS9QZHiz{h}7Jl^Z&HQ?p)@D}i;6)Oeb_c{I#2&W`#qj_3TiTqQZU(`vG z?>r%^(zv1XFW+?n|1Eyi82<+&sJP1S;Gg{P{xp7c@K+Dq zaQWqGtJG(1hVBDS{q_3qn#0e7z;B!}pQ&|coUD`U=?QmZZ_4(T-Bx?so({_rGy7L8 zXTa*F9W2 zGnHkG`G?dcv zl!om-J&5}faKfB2Rijy1aQ*&nsG*toK(ZS#q#be(gvLi0Sr=hkR|B|KX0Fx$pho}i zajU}r998%^mMPDZv{>qLo#?0Vqqzy&^YboK12T8v`z&J(sJQL=mO>w@*Zg-+Wb2ql<=WM1;lpGYAhEbL0T|Cd)2aF!s*`DW%OnH6? z6oNTT>}hVtJU`zvHFQhf_%$r(d5m((_B;<@I;9o4 zeQ*CC*7nU>kLL?a2VM4*Gq3$4z$hnrnoIv2Rne5^!5WpZa-C=%KexT1?U)`UC0Fsd z7mq^bwja_8OgUb5!93H)Jofzmp6NTBSnYt@XMf-K*z>%HDbMR!-#h+)sO^i*7+O

HGM73x3R^E`?vU0?3vZT}ev-S%UK(q>A}iSFWU|9J>Q`0=!tpPzZ(wO5~c zrZ2;`%4N^ei{OI`w?vr(e@mt*Pi(+sE{x2 zKR5V>P{c`>iktG-RT6a^(hjF|;%@*<5ciwzMO5he;@Bmi e4~Onhm6IOl+%D@bMWvj5<(*1{pW|8IYyVHrz+dwK diff --git a/334/bindec.c b/334/homework/1/bindec.c similarity index 100% rename from 334/bindec.c rename to 334/homework/1/bindec.c diff --git a/334/responses/binhex.txt b/334/homework/1/binhex.txt similarity index 100% rename from 334/responses/binhex.txt rename to 334/homework/1/binhex.txt diff --git a/334/responses/os-intro.txt b/334/homework/1/os-intro.txt similarity index 100% rename from 334/responses/os-intro.txt rename to 334/homework/1/os-intro.txt diff --git a/334/homework/2/msh.c b/334/homework/2/msh.c new file mode 100644 index 0000000..53f5725 --- /dev/null +++ b/334/homework/2/msh.c @@ -0,0 +1,44 @@ +#include +#include +#include + +#define PROMPT "msh> " +#define EXIT_CMD "exit" +// Accounting for the \n +#define MAX_BUF 121 + +void echo(const char*); +void remove_newline(char*); +void exit_branch(const char*); + +int main(void) { + char buffer[MAX_BUF]; + while(1) { + printf("%s", PROMPT); + fgets(buffer, MAX_BUF, stdin); + // process the input + remove_newline(buffer); + exit_branch(buffer); + echo(buffer); + } + return 0; +} + +void echo(const char* buf) { + printf("%s\n", buf); +} + + +void remove_newline(char* buf) { + char* c = buf; + while(*c != '\n') { c++; } + *c='\0'; +} + +void exit_branch(const char* buf) { + if(strcmp(buf, EXIT_CMD)) { + return; + } + exit(0); + return; // just for gcc but exit shouldn't fail +} diff --git a/334/homework/2/processes.txt b/334/homework/2/processes.txt new file mode 100644 index 0000000..117ecdb --- /dev/null +++ b/334/homework/2/processes.txt @@ -0,0 +1,22 @@ +# Instructions: edit this file to provide your homework answers. +# +# Problem numbers are shown on lines that begin with #@. +# Please put your solution to a problem on the line *after* the +# line with the problem number. +# +# Do not modify this file *except* to add lines as needed after each problem. +# Blank lines are ignored. You don't need to put your name in the file. +# +# No points will be awarded to incorrectly-formatted files. +# + +#@ 1 -- enter 'a', 'b', or 'c' (don't use quotes in any answer) +b +#@ 2 -- enter 'a', 'b', or 'c' +c +#@ 3 -- enter 'a' or 'b' +b +#@ 4 -- enter 'a' or 'b' +b +#@ 5 -- enter 'a', 'b', or 'c' +c diff --git a/334/homework/2/puzzle.txt b/334/homework/2/puzzle.txt new file mode 100644 index 0000000..2f0daeb --- /dev/null +++ b/334/homework/2/puzzle.txt @@ -0,0 +1,32 @@ +# Instructions: edit this file to provide your homework answers. +# +# Problem numbers are shown on lines that begin with #@. +# Please put your solution to a problem on the line *after* the +# line with the problem number. +# +# Do not modify this file *except* to add lines as needed after each problem. +# Blank lines are ignored. You don't need to put your name in the file. +# +# No points will be awarded to incorrectly-formatted files. +# + +#@ 1 -- enter a single number +1 +#@ 2 -- enter 'Y' or 'N' +2 +#@ 3 -- enter 'Y' or 'N' +Y +#@ 4 -- enter 'Y' or 'N' +N +#@ 5 -- enter text on a single line +some stuff +#@ 6 -- enter 'Y' or 'N' +Y +#@ 7 -- enter text on a single line +stuff +#@ 8 -- enter 'Y' or 'N' +N +#@ 9 -- enter text on a single line +some stuff +#@ 10 -- enter 'Y' or 'N' +Y