From 41d3ed4406f33f9308cd9c45d4b7c9f4c1ccf2a9 Mon Sep 17 00:00:00 2001 From: Huck Boles Date: Wed, 2 Nov 2022 19:00:02 -0500 Subject: [PATCH] automatic backup --- ...@usr@include@bits@libc-header-start.h.blob | Bin 3215 -> 3215 bytes .../@usr@include@bits@types.h.blob | Bin 9860 -> 9850 bytes .../@usr@include@bits@types@FILE.h.blob | Bin 2649 -> 2651 bytes .../@usr@include@bits@wordsize.h.blob | Bin 2630 -> 2630 bytes .../@usr@include@features-time64.h.blob | Bin 2447 -> 2447 bytes .../@usr@include@gnu@stubs-64.h.blob | Bin 2946 -> 2946 bytes .../@usr@include@gnu@stubs.h.blob | Bin 2426 -> 2416 bytes .../@usr@include@stdc-predef.h.blob | Bin 2908 -> 2908 bytes .../@usr@include@stdio.h.blob | Bin 37520 -> 37510 bytes .../@home@huck@.repos@odot/dialogue.c.blob | Bin 3363 -> 3357 bytes .ccls-cache/@home@huck@.repos@odot/file.c | 44 +++++++++--------- .../@home@huck@.repos@odot/file.c.blob | Bin 5525 -> 5971 bytes .ccls-cache/@home@huck@.repos@odot/func.c | 3 +- .../@home@huck@.repos@odot/func.c.blob | Bin 4771 -> 4722 bytes .ccls-cache/@home@huck@.repos@odot/input.c | 3 -- .../@home@huck@.repos@odot/input.c.blob | Bin 3931 -> 3822 bytes .ccls-cache/@home@huck@.repos@odot/main.c | 36 -------------- .../@home@huck@.repos@odot/main.c.blob | Bin 4283 -> 2774 bytes .ccls-cache/@home@huck@.repos@odot/odot.h | 7 ++- .../@home@huck@.repos@odot/odot.h.blob | Bin 4560 -> 4588 bytes .../@home@huck@.repos@odot/structure.c | 18 ++++--- .../@home@huck@.repos@odot/structure.c.blob | Bin 4130 -> 3722 bytes file.c | 44 +++++++++--------- func.c | 3 +- input.c | 3 -- main.c | 36 -------------- odot.h | 7 ++- structure.c | 18 ++++--- 28 files changed, 76 insertions(+), 146 deletions(-) diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@libc-header-start.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@libc-header-start.h.blob index 17abd5fc969584c584f03fdae3cf38861ada6399..78e4a2591fdfa78d86407f1433a16e201df19d8a 100644 GIT binary patch delta 20 ccmeB|?3dio!O9%)>F8tuX35PgZ$vX35P E09Uvc1poj5 diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@types@FILE.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@types@FILE.h.blob index 81754144e5a0515f6d5a3007892719a8d5cdc998..469004ae98d3bc00cc51f6526cf97923eb9c0e61 100644 GIT binary patch delta 44 tcmca9a$97AB1dsaQE75XY0*RtB{+LyU;-<1z^9{=8Cj$@pJVN20RV%N5Xk@l delta 42 scmcaDa#Li2B6~_^VorW~=|oK>7;|HA0xNUVtD}<{StU20XYFAD099EJr~m)} diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@wordsize.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@bits@wordsize.h.blob index 0df941655ed7ed6200408a581fb7b787f4d15f9a..1cb7b380dd73bf9e598ca185ed8ac3a6d2e48ed1 100644 GIT binary patch delta 20 ccmX>ma!h2yW>)5aPe&&+vPy0~&sxp`09mpJ+W-In delta 20 ccmX>ma!h2yW>)5=S4Sr^vPy0~&sxp`09&#M1poj5 diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@features-time64.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@features-time64.h.blob index 9338a5f824597e978c061b0975a23654419ac701..866759eaacb0a35c25e2ad7ad099e948d0c23cba 100644 GIT binary patch delta 20 ccmeAd?ib#$nUy)<)6vO{tdg70vmRgu08#Y^vj6}9 delta 20 ccmeAd?ib#$nU%Te)zQg}tdg70vmRgu08{k`-2eap diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@gnu@stubs-64.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@gnu@stubs-64.h.blob index 0df69ffac7037391e2132dd909cdcd124eb18a04..926a83b8b87f165bf26ea31590289ebaf5d625c0 100644 GIT binary patch delta 20 ccmZn?ZxY|InUy)<)6vO{tdg70vu*!X5K_C2)!{Ro|QS~`_ajatdg70v#w?a0Q|rWSpWb4 delta 56 zcmew$^h;=hqHu9ZQE75XX;G?PG6QpRPGVj)5aPe&&+vPy0~&)Ulh09|VcA^-pY delta 20 ccmca3c1LW(W>)5=S4Sr^vPy0~&)Ulh0AFheOaK4? diff --git a/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdio.h.blob b/.ccls-cache/@@home@huck@.repos@odot/@usr@include@stdio.h.blob index ae8a81b14499ab0a543cb33280c56da6b36f50aa..176afb76b189c61ba0a7ca74def5922161d73a82 100644 GIT binary patch delta 38 rcmbQRl&Nhg(*$#t+{Dbhi4KZjdSg~RD|5{Eqmvi1NNj$>x~2yJ7VHl$ delta 43 pcmZo$$}|Cp%sGooib|79N{dn_S}P(r8x!JLnVMd0KFE5s2LN*h5xM{X diff --git a/.ccls-cache/@home@huck@.repos@odot/dialogue.c.blob b/.ccls-cache/@home@huck@.repos@odot/dialogue.c.blob index 394b920a1173e16ff3c5b973d8ace6aca06cc14a..3b44d931ffd526300a29738ae1aed47538cc9e22 100644 GIT binary patch delta 56 zcmV-80LTBM8l4&oDggf8_Ql2k0RaG$e+U(^Ag2WbT=&J3aReH(4lM-(L delta 62 zcmbO$wOEQp4U>DlBJZZhCceav_V<<|nL5EW){lIts}diA4%p Sxkfq)nRz7&$(x0_xR?QH{}QeM diff --git a/.ccls-cache/@home@huck@.repos@odot/file.c b/.ccls-cache/@home@huck@.repos@odot/file.c index ddf96f1..d4fcd1d 100644 --- a/.ccls-cache/@home@huck@.repos@odot/file.c +++ b/.ccls-cache/@home@huck@.repos@odot/file.c @@ -7,12 +7,30 @@ extern FILE *fp; enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; -void add(void){ - fp = fopen(TODOLIST, "a"); - if (fp != NULL){ - fputs(strcat(note,"\n"),fp); - fclose(fp); +void add(struct task t, int size){ + int l,m,h,i; + + h = linecount(); + m = h / 2; + l = 0; + + while (h != m && m != l){ + i = strcmp(t.task,gettask().task); + + if (i < 0) { + h = m; + } else if (i > 0) { + l = m; + } else { + dialogue("Task already on list",t.task, BLUE); + return; + } + + m = (h + l)/2; } + + puttask(t); + return; } void rem(void){ @@ -50,19 +68,3 @@ void show(void){ free(c); } -int listcheck(void){ - char *s; - - fp = fopen(TODOLIST, "r"); - s = (char *) malloc(MAXLINE * sizeof(char)); - - while (fgets(s, MAXLINE, fp) != NULL){ - s[strlen(s) - 1] = 0; - if (strcmp(note, s) == 0){ - free(s); - return 1; - } - } - free(s); - return 0; -} diff --git a/.ccls-cache/@home@huck@.repos@odot/file.c.blob b/.ccls-cache/@home@huck@.repos@odot/file.c.blob index 06ba4f6dd24f6f3d16846e3349eac4bafccd20ed..1421e3e8dd6d3e112aa9569e7a6f264e784e2ebd 100644 GIT binary patch delta 2024 zcmb7FYitx%6rQ^~yUYx;+u7aeFsVyBZ1=_NZqshI54M(0TadLpBnk=?l%}ohYH1s~ z#b;d}k~Bd9nV|f@7lGg-!SD!C6EGkUO;FRI5gR2MlmtmI1Ve+`UhkP@)^7M^f80C! zbv!+NmDhy2i+fMrw($b*!}V9r9sOeg=Q&^{=euN=A4fhfx&G+sv)c?H;cCV5 zs#iB~W8-fDAj@(XSNyy)c9h0)B^jBdI5 zvH*Z4X$n5Gae3;a2X3y%d)UIr@QgCcvy2X*<75EqQS>Nt_B8Px8Ahr|vr2nn9|24i8e(A@VXWnbMV4v#V z7ltXPlQDD7AP=Z;J0MnJtzjDJ9}9bynP#xiPFkW-fC&gRno;m>eyX}Co+lJ_}CF#Sn)EOu+)#->L?Z;lqR4wZ+h zG?b7NVGY#=YYE@x@@9hQX|X0~Ufgi}VCMNAQUU2AVjEa(!a^gqn$=EB@cK@7ywV5Qj?M$uqYAN0f-v(-9VS``b30U`@&_dMKx z-@Y~5zFTk$WVOUvV<{fRr8tOTUK#p7uDYCG^b-~QjDLmEe7ovXN!uerga{e&MaXkB z9!>Bl7LSp&-d!(}4CeO-`1G1`3LLp6iJWdjPTI*hLC!j%fk-Gz&Oek%}4b*|@=>^Kj0+ z-`qL(JLfxR&X`9sVh6YSyJ!9@4snOJHJ`ZtK!a!hr7!8zg7(p3!@Q>|Iakhato)@8 z{5JW>jJ|VndS+~5``E*&G>5T_@;D#mQJ%Y*=Qs{IFFo-$j;@|M-dKxFab zg-fqUbXmMDz{45#2F2Q97QMQmU+9!N<8&%mX>WiF;8jQub$}1c;o3ecXKNm+LRb8E zR9kVY0tcMY+2J#n6M^??#HS~w9k9Oo%^$Dw$ywEboGdI`%6d|Obm1;m#?5g7(gj`#oT%~Bv0n2Qw&?D_b=4-Z zi50YoO9Cz4S$eR%EYD4ycJddzKmB~;2hBk_E~i{FUjsmGT!gOyplYrYnyRg(RIT?) zM2Wb2C8|Z+od350{riVN&g33g1jnuoD~Jxs%bZ_o$4Veg?2H65wewc&*gf-0a8 z4oL!PS|8Q1iP1;(j%kh%rYY)Hx>X)^<8GA;5RPjs;-aV^+pyaRDoG`oS);_(J-MDd zL1m-N*8Ot7LXcDM(Y1hM{{>82N}5GX6v zO&euJW?#uz-df|~)eMcDk4O>5AYw$=I+}|z2C-a>*><^IA#_K`q;bU@BqA1xg8Y)7 zg(ZDtfS^E2z#u4$!wlDKt(TyLnurpV#aV`!w#g7nwHQ*s1%}wR-Ai{V_evhpL2~S} zWYlCyCwu6(N{;%}gNUPVsNHlSWYNPR5t;yC+eJI1DU1OtvmsMYgt6 HHe3G-EG4q2 diff --git a/.ccls-cache/@home@huck@.repos@odot/func.c b/.ccls-cache/@home@huck@.repos@odot/func.c index 06fe268..f5db53d 100644 --- a/.ccls-cache/@home@huck@.repos@odot/func.c +++ b/.ccls-cache/@home@huck@.repos@odot/func.c @@ -1,6 +1,7 @@ #include "odot.h" enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; +extern FILE *fp; int listcheck(struct task t){ @@ -26,7 +27,7 @@ char *gettime(void){ return NULL; } -int linecount(FILE *fp){ +int linecount(void){ int i = 0; char c; while ((c = fgetc(fp)) != EOF){ diff --git a/.ccls-cache/@home@huck@.repos@odot/func.c.blob b/.ccls-cache/@home@huck@.repos@odot/func.c.blob index fbb01542509103c54d7d87fd219002672ed05d05..c849efdb44ddba85bb396d3d95d5b1ded238151e 100644 GIT binary patch delta 930 zcmah|T}TvB6ux)vIx{;vf4ffWIIin;8D-s6)O1r(*rZfSj35mpMUg~FR?yXl$TUkZ z=tXWpfe>L-1PNM66h8PDK|%B&Vwo>OFA7p&y|hhtj1_!p9%c@QbH498=X^7n_1zRg z;Lpa-d>DpCB;#b$(vf-j6mz?=JL#rko=%48pGXP(F^T8 z{n1!32k^WHrt|3r1Jgk^0{~#GyJyWCPj1FXtlO)1@-J<7FESY8kQG?IHomYH7(f({ z!jfE}(3vWx(#}+nMmmHOh?bElA?#9h72Bj5uaO<$6jF4BRJ!t!OLdW`s}4CmPBQ1J zN#;Ua*sha;QnCG&HJPM{9Z2#@WLS(K&c~5OF>i?FS<1o!?>~L#3Wvb%^V8MV?=OeW zl+4ucinK6j!Kp`l^XA*jwmuu#`qnuS{FFVnv6uL71r_D9?&s8h9Qk@(wOgoK!^%TN zTdls6Ywzp~)rGBvfri@YG0*T`f(k!CLnpuo5_ELaI=rZCHO?=M+Aa2OtXqRG$G7h_ zJhT(`l0Hbmti-axEIq=32ku`4kWo2DNz4z~5L@Jc#3wgNuku&Q(pFzgLL?(Ec`X+g zxcAT3-r3fR+kqg^^}!5JhQ`1QK0}+4M0#zkV?%?PdM0UBQdwMqt0IuBE7=NH!5tT& zR4!GCPzfo-t+v!AnEPVA{p~RvYwNp+V?ft!V78bI#~BA?eQemevYx*1_}F_kPAL#q z%9T5y6qZUIkOBv(~Ta*+sp`>;i00v&-;zpJ*fdbVEAB` zH%k{GDRq~Sr%C}CR8qoLPufKD=t|8GiFP3a`5{CA`IDTyQ`DfK3K|`xR;m*r&cy{H zG`*%lA-dhwNlw2rKSByUDQSXFu&vlAwM3xdHT?9SN%)J*yDN)1jq@^)TPlMgxW#84N=8UtmskuJg zvadN4Te+sH(n&Pzjst`YXd^q|f;K300RRL#aPfD2$G6}2>D~0X-q%IqXS#j9^7z8$ z_$gP|2`6Y|@I-t6NMygj8t^`J*UF|H?RC9L4q(VM0GTZZJr=f@tOWw3TCNlrm0Xfj zUd_@R?#zdLWK>=!sFq5Ky-7jVWm4m<5|Dw&ZSN|dl#o)q4##jQ|0 zLXd2UbmLjAA`)2_5lrFcU3B*HqFo2igyPhHzH7#CXh|Ptg)s{6+(0#-o*&{CxibCH z*b#eI^k_5-{I`Ocvgwuh`ZveFoYXmmxed@+LdjU2y>{e9c5pv-X#f7|)m^8Jqgj9% zpVWp;;7kJ8=utZJsW!Ip$v_*Y@NDSW!w=fOUar2*0UlDH5-ZFt0QB&5|9#-ZmH=6< zZqjnggSKr)-H>?IxRT2RiV3lV+)_(hjfs_}8@KLp(m03hM}5J$u_N)c=QsKJ6du@pJE5~py7f+6b$ra2gp%&5Dzt8ZQn7qoH zy4hoU_}y;AwH0uhe_Dv?<~Fc5vu9sA<7Bq(-Qi?_W%1C(QZdB?6m2m@kGv1|-(31q W;sFX$nN;qEIEBmHP%TnpZul2|ksJ*G diff --git a/.ccls-cache/@home@huck@.repos@odot/input.c b/.ccls-cache/@home@huck@.repos@odot/input.c index 20cf7bb..a8846d3 100644 --- a/.ccls-cache/@home@huck@.repos@odot/input.c +++ b/.ccls-cache/@home@huck@.repos@odot/input.c @@ -34,8 +34,5 @@ void getopt(int n, char *arg[]){ free(c); } - - if (strlen(o) == 0) - o = (listcheck() == 0) ? "n" : "d"; } diff --git a/.ccls-cache/@home@huck@.repos@odot/input.c.blob b/.ccls-cache/@home@huck@.repos@odot/input.c.blob index 8f364817c81b6315a4b42eccbd54985d6097d3ea..0338a569a4846675ed62909ea2b64ad189c8409b 100644 GIT binary patch delta 90 zcmV-g0Hy!i9_}3pDggf8_Ql2k0g*2tu_=ND16=pTli>mxv&RL%0|5t diff --git a/.ccls-cache/@home@huck@.repos@odot/main.c b/.ccls-cache/@home@huck@.repos@odot/main.c index 6ec8b64..a1134e2 100644 --- a/.ccls-cache/@home@huck@.repos@odot/main.c +++ b/.ccls-cache/@home@huck@.repos@odot/main.c @@ -4,43 +4,7 @@ extern char *note, *o; extern int urgency; int main(int argc, char *argv[]){ - char op; - int length,i; - struct task t; - note = (char *) malloc(MAXLINE * sizeof(char)); - o = (char *) malloc (3 * sizeof(char)); - t = maketask(argc, argv); - getopt(argc, argv); - - for (i = 0; i < strlen(o); i++) - switch (o[i]) { - case 'n': - if (listcheck(t) == 0){ - add(); - printf("\033[32mAdded to list\033[0m: %s\n", note); - } else { - printf("\033[33mAlready on list\033[0m: %s\nRemove from list? (y/\033[1mn\033[0m): ", note); - if (getchar() == 'y') - rem(); - } - break; - case 'd': - if (listcheck(t) == 1) { - rem(); - printf("\033[36mRemoved from list\033[0m: %s\n", note); - } else { - printf("\033[31mNot on list\033[0m: %s\nAdd to list? (y/\033[1mn\033[0m): ", note); - if (getchar() == 'y') - add(); - } - break; - case 's': - printf("\n\tTODO LIST:\n"); - show(); - break; - } - free(note); return 0; } diff --git a/.ccls-cache/@home@huck@.repos@odot/main.c.blob b/.ccls-cache/@home@huck@.repos@odot/main.c.blob index ca1a5167a231dfae28496bf10bb300151c741f61..f86f036a14cfa53f06ac571ab277b8bfd1dfce97 100644 GIT binary patch delta 138 zcmdn3cukZ`i{anBZ%2 UYXZr){5q3O1yq5oTmc{-02rAlrvLx| delta 1659 zcmZWpQHUE=6n!trCNJY86SCtZu1S1}Yj!e(G~lvot;;T~B0@j=(Q3h%ohC8aWJ#tf zUDu(-N?9yeqwP;c5!5Y;U@PrHvBj!Iib`umsuX|rM^tJ{{SaaMeD{$|XXt#)dtC0l z=iYnHeLvrQIx89I*4pIid4$oSXA_@g4~+Qt{qaqIZyya=0w#?pIUOV*HyW2iA zU$V?@o4(L#%+p<6)6~VyD4=ALAo0oY#|ANC8{;#W{XYKH#pKz>9^uzD7xV&>q@c^y zmnOCn@8ab@+5!;cpSSdF%A(VA&h>y<8#*0iWQI#EtcLsYh$6({@PTIj!t zD`(ypfR*|AI{`=aQ2~@I=L9gjx&Gi&|7vsB8*PiW8a<9=R-1ay>h7*u)T;FCW&sfr zcf-c@_-24j=_zrt%JR0$H|~oZ6R^E{=S6|*naKp5&_#of%w77?ci_=?gfH)`vuNoY zyGWr$YCOFYW+di_5F9qb5fV{F?2Y6$n*dPba7r{c`hd~std2nm1s z5!t!^?aOWj8Vi+Ht5elIQz)RZF*k-UtcOJ|DJKE%{r%yG?4pmi5@f01%BEM3MBii2 zY<{eJuzS&Bv;PDxpeJ@5WZAX3Q>WKA9bwO%{kVSlaOMPi{?eZ7_eaB%DkOC3@$;0B z*<*m&u;GBg1NdV@-u)Z)_zdvChHQchNXn5S7(l0voWTIYV#8^J0jB0Lz&5bq{(uK8 zm$QRl0Ku}G_CWDqfxYv%00*9|K!(Qv%jSWBRq~Vyym>-E{LYg2ZH^01g!8UIAuh&fg;*fkUxSN@Pfh z49MwNyd<4P{*DB=TQDBfd^kvg+Hn9vtnZhK5uaR=r(_(-MGP7D%Tj?`ax%Y1v`B_q zc1Xp0@7n(QnIFDyU31S5ho{1GGq}HB%8&XbBJp08Ddk}q$7qaK-v2}@JP-_%a7@MO dK6ORL+E3b58D~~9Z_1dSqZeds#Emf-{|^Ws>%IU0 diff --git a/.ccls-cache/@home@huck@.repos@odot/odot.h b/.ccls-cache/@home@huck@.repos@odot/odot.h index 897570b..c206b4f 100644 --- a/.ccls-cache/@home@huck@.repos@odot/odot.h +++ b/.ccls-cache/@home@huck@.repos@odot/odot.h @@ -17,7 +17,7 @@ struct task { char *getnote(int, char *[]); void getopt(int, char *[]); -void add(void); +void add(struct task, int); void rem(void); void show(void); @@ -27,7 +27,10 @@ char *gettime(void); void error(char); -struct task maketask(int n, char **arg); +int linecount(void); +void dialogue(char *, char *, int); + +struct task maketask(char *, char *); void puttask(struct task n); struct task gettask(void); diff --git a/.ccls-cache/@home@huck@.repos@odot/odot.h.blob b/.ccls-cache/@home@huck@.repos@odot/odot.h.blob index 519e307eab40e65ec045b25968ea1b114eef77bf..a50c03a18115e62cff62d35c47afb00f94ce04d1 100644 GIT binary patch delta 537 zcmcbh{6?8oi{W3)_l>N{+>CsaAM)By{=u!IrzD}I#>l9|pk&0r@V|7j*mMssyJuzj znJEg1DJdGoB}JvlB?={p#o0OvnRz9XV|XPPO(vJ}8cdeu)th{cM_2sw4_Av<35^#R zco-NM6}c287#S5A6wM}2<8hdr%wslrDX;BhLmnfSwk(FtBEEfJkc?EwP0UUOnXQqW zkyxalrK13$H5nu%1Q@^oWT=9Kf(9d_0)v9bFiie@L+dzuVfTu2tn zamfJcuzTjU$(nr8ifRmM94w66Aod|hrvEp;znNwv(D!TdI=)y9 zSkSNvD+p__Fp6u58?i7d@F|F~Fe+*&8n7@b@hJh>+>>?rB{<3WJIW15hMK;E*xQc;pbx0|p%vC?bp$P5v?g k?U7P6`CoTO_RtE)Gi-l(CTj^sbE-(G$be0n+$ZP+05Xw{!vFvP delta 540 zcmaE(d_kF2i{am_*Be=rxubdhmu2XE5YIdkUR+XCnp~n#l31LrkeisD3Swwv=9MVq z=_n*;Bo--XX(bk=Ycfbk2rvKv)BiVb%=%N)jh?2-sLE@+gWhF)A`BiZDRj0E-GlgfZ~(0mF<@ k)=kz2><|lCABMj?lLG|~P4*HD=TwwZlmVMCd6l3O0IFq?Pyhe` diff --git a/.ccls-cache/@home@huck@.repos@odot/structure.c b/.ccls-cache/@home@huck@.repos@odot/structure.c index 3f75b10..cf3c428 100644 --- a/.ccls-cache/@home@huck@.repos@odot/structure.c +++ b/.ccls-cache/@home@huck@.repos@odot/structure.c @@ -4,26 +4,24 @@ extern int urgency; extern FILE *fp; -struct task maketask(int n, char **arg){ - struct task temp; +struct task maketask(char *task, char *group){ + struct task tmp; - temp.task = getnote(n,arg); - temp.length = strlen(temp.task); - temp.date = gettime(); - temp.due = 0; - temp.urgency = urgency; + tmp.task = task; + tmp.date = 0; + tmp.group = group; - return temp; + return tmp; } void puttask(struct task n){ - fprintf(fp, "%i\t%s\t%s\t%s\t%i\n",n.length,n.task,n.date,n.due,n.urgency); + fprintf(fp, "%s\t%i\t%s\n",n.task,n.date,n.group); } struct task gettask(void){ struct task tmp; - fscanf(fp,"%i\t%s\t%s\t%s\t%i\n",&tmp.length,tmp.task,tmp.date,tmp.due,&tmp.urgency); + fscanf(fp,"%s\t%i\t%s\n",tmp.task,&tmp.date,tmp.group); return tmp; } diff --git a/.ccls-cache/@home@huck@.repos@odot/structure.c.blob b/.ccls-cache/@home@huck@.repos@odot/structure.c.blob index 690b7521f9bfe7492e1a9316498612b0b7e53f41..c4d3cc0a0fc6912dcd7284adcd5a20028ed5d876 100644 GIT binary patch delta 769 zcmZ9KPe>F|9LL{pclPc4d9Lr}?7UgaWvH-i(-IL63oYs)qH;5+Si~f;KO3RRx}HM! z5*0yFOw`39JarY1T_n=}5O@=Us7rxle=eaBZPRa>c9kyQVcxvo_kF(KH#5$SCN)id zzgt^aB<`q|xO14zwqA{d2i6x{h$QBgBJ*L0xVNK9CTR>2Lcn{u zy#Lk8($o*|zwgoe6`=~tUDI3lah=;C;ABg%aVGareX+Xz3-}wnC(j#}pRMj-;mXb~ z2IxfGX(O2(E({f&bc+)_cN5#@Ky8`|0VOftC+r=~&X4ex@&oVV`%~Ssshgj?!KBi= zaP509ard&e&gz?2J+Outp)qPH5VfL71$c_LDPYD-T!~w8_b!_(gLk=faQa(fb&=@a z*oR};UyrWe4^T=&;}{dx`n_5Ie6O9~ z`gvhAFw11l43*9j)${=Z3Z3gVQuK*DQk;~7SD==DGsP$}V2Qxnc}FFL9W?Te8byUQ zU>=bbNFk1h9BRK9a3^EC%3+ObzJHH6g#JAewO0CO|BaMUCyFVfYV^O9nySSV&{ZAP zPz}^NtIiKuz09EPe?2qo8EEbR&HJ>phvrEIy8^>8(l}H76E<#$FovZ7?WEbi6KR?a YCbXp1?9SD+Wh}SQbfx6x)VqX{Zw8i@lKTX4u3glen3b zn8s`yLs~*8%9topS{sq}Nf9A$^===eRD3EaS}24NRIqs{g~B@iXEw8qbRYg5&YbW6 zF8@FCP0Oa3LI3WJe18MEwnRTTq<*z~E)t&k^Jf=F=-0nSz6)c~eP4PbOhxK$NT~)R zVI)J?K#d`U5cV#Ae*V$=u{}MQy?<7IvrI%{R9arb-h;P|TepYSHwy##l9?%5jx#uH zrP4@Mqkx2;$_iFYrPaTGC3$smVt=nxyKj#;R%+08o-?aQM~*!KmQ1M%zCCkbxvwG> zPPre+Pc`VWo(N$b)mJsX{%!Bt0lc<~L7V%VytBMHa4~f!dHt?6;aDZx9Jj{?i?-Eo z4vpAFbId6XS$3*0Vvjjn%xRR#_-X^ua*N#Ni(YLyJ$E*`*aV>Qf@3=Qv6JR-{-nho zn0C_+)MxUgVj3k9G0Y!L@Tm~yQH;q8d(VHSR$ks1Uh&TT67TIi_}+c*nZm>N*1U2( z%=~#lFkxV1#9knu9kBRnQL_VgpVIb1(7+3<*X9)AqrAak!4R4`tf%xg4jWMePU1$~ zy{f!h4tb}YS1$fT|GH5VhE#9QkKe?^dzn|6CFZT8W4u(f?7}-ptoO$$GAo*{ne~_~ zkWW-hKc!#HVsG`~-%Hupg-6v9R-yfQ$3kj?L6DDAbY&OdN@P+kV>(4=RqUlZb>XLL zXLmeigsBvr0U-28;R9t|ZU$fvISz!qv=0b_h1@<7XLuBn=V9C8W*oLRF2LXhb$ zJy+{pf!+~vn7qbe(nn4}waF;dDKZW9JelXPcPIJB5pU_so7IHeF3l)&k}g3Y@{4k( zib+2i0(WoG5-12(q 0) { + l = m; + } else { + dialogue("Task already on list",t.task, BLUE); + return; + } + + m = (h + l)/2; } + + puttask(t); + return; } void rem(void){ @@ -50,19 +68,3 @@ void show(void){ free(c); } -int listcheck(void){ - char *s; - - fp = fopen(TODOLIST, "r"); - s = (char *) malloc(MAXLINE * sizeof(char)); - - while (fgets(s, MAXLINE, fp) != NULL){ - s[strlen(s) - 1] = 0; - if (strcmp(note, s) == 0){ - free(s); - return 1; - } - } - free(s); - return 0; -} diff --git a/func.c b/func.c index 06fe268..f5db53d 100644 --- a/func.c +++ b/func.c @@ -1,6 +1,7 @@ #include "odot.h" enum color {BLACK, RED, GREEN, YELLOW, BLUE, MAGENTA, CYAN, WHITE}; +extern FILE *fp; int listcheck(struct task t){ @@ -26,7 +27,7 @@ char *gettime(void){ return NULL; } -int linecount(FILE *fp){ +int linecount(void){ int i = 0; char c; while ((c = fgetc(fp)) != EOF){ diff --git a/input.c b/input.c index 20cf7bb..a8846d3 100644 --- a/input.c +++ b/input.c @@ -34,8 +34,5 @@ void getopt(int n, char *arg[]){ free(c); } - - if (strlen(o) == 0) - o = (listcheck() == 0) ? "n" : "d"; } diff --git a/main.c b/main.c index 6ec8b64..a1134e2 100644 --- a/main.c +++ b/main.c @@ -4,43 +4,7 @@ extern char *note, *o; extern int urgency; int main(int argc, char *argv[]){ - char op; - int length,i; - struct task t; - note = (char *) malloc(MAXLINE * sizeof(char)); - o = (char *) malloc (3 * sizeof(char)); - t = maketask(argc, argv); - getopt(argc, argv); - - for (i = 0; i < strlen(o); i++) - switch (o[i]) { - case 'n': - if (listcheck(t) == 0){ - add(); - printf("\033[32mAdded to list\033[0m: %s\n", note); - } else { - printf("\033[33mAlready on list\033[0m: %s\nRemove from list? (y/\033[1mn\033[0m): ", note); - if (getchar() == 'y') - rem(); - } - break; - case 'd': - if (listcheck(t) == 1) { - rem(); - printf("\033[36mRemoved from list\033[0m: %s\n", note); - } else { - printf("\033[31mNot on list\033[0m: %s\nAdd to list? (y/\033[1mn\033[0m): ", note); - if (getchar() == 'y') - add(); - } - break; - case 's': - printf("\n\tTODO LIST:\n"); - show(); - break; - } - free(note); return 0; } diff --git a/odot.h b/odot.h index 897570b..c206b4f 100644 --- a/odot.h +++ b/odot.h @@ -17,7 +17,7 @@ struct task { char *getnote(int, char *[]); void getopt(int, char *[]); -void add(void); +void add(struct task, int); void rem(void); void show(void); @@ -27,7 +27,10 @@ char *gettime(void); void error(char); -struct task maketask(int n, char **arg); +int linecount(void); +void dialogue(char *, char *, int); + +struct task maketask(char *, char *); void puttask(struct task n); struct task gettask(void); diff --git a/structure.c b/structure.c index 3f75b10..cf3c428 100644 --- a/structure.c +++ b/structure.c @@ -4,26 +4,24 @@ extern int urgency; extern FILE *fp; -struct task maketask(int n, char **arg){ - struct task temp; +struct task maketask(char *task, char *group){ + struct task tmp; - temp.task = getnote(n,arg); - temp.length = strlen(temp.task); - temp.date = gettime(); - temp.due = 0; - temp.urgency = urgency; + tmp.task = task; + tmp.date = 0; + tmp.group = group; - return temp; + return tmp; } void puttask(struct task n){ - fprintf(fp, "%i\t%s\t%s\t%s\t%i\n",n.length,n.task,n.date,n.due,n.urgency); + fprintf(fp, "%s\t%i\t%s\n",n.task,n.date,n.group); } struct task gettask(void){ struct task tmp; - fscanf(fp,"%i\t%s\t%s\t%s\t%i\n",&tmp.length,tmp.task,tmp.date,tmp.due,&tmp.urgency); + fscanf(fp,"%s\t%i\t%s\n",tmp.task,&tmp.date,tmp.group); return tmp; } -- 2.45.2