From c4fbcd7189466c9f9d962a182e2a39b62aed391c Mon Sep 17 00:00:00 2001 From: Nakidai Date: Sat, 18 Nov 2023 21:12:57 +0300 Subject: [PATCH] Move some code --- a.out | Bin 0 -> 17960 bytes main.c | 32 ++++++++++++++++---------------- 2 files changed, 16 insertions(+), 16 deletions(-) create mode 100755 a.out diff --git a/a.out b/a.out new file mode 100755 index 0000000000000000000000000000000000000000..80e751db7fb057e245fbec6a06d95195bbceafc8 GIT binary patch literal 17960 zcmd5^3wTu3oj-T(yz(Fu2#)|FH%c_9OaK9?A|#NsHwZQI5=+7`OePOWX3}{;a7BU< zmuZZ}b@9~)zP6?N(JpPb7PU$cE2!OWcI&F^W1DJSlS*6a+KSKY?|<(3&rBv0irsJb z+XMIf-;eXS=iYnf-t4Si@p+r3$P^blerdq;K6k1}k zbKvMxa&8~Pc9j^zbUSKe#W>4P#au%o4DVNoG0e2U0)|%5HFx&Hak^h@^G#9ne%LFPiEEr{F-bAB8#bzV-S;TYgfz^_y=`(7VVV9UdH1 zC~ulGv_2K!$is1_qE4q_Dil*qZ^@^1C;ePO;&L96Fds)QA;HkrmPj}xe7^QbxGCgs z3krWM*wGRbzLro+%ol5o3X5F6)we3x)Dn#aBgTrtt&Q!GmQbuw z1X{y^Exx8;EY<>7(U4+;(HxG(q<`S8;ii_5FCwC`NT97Lnxw{G2dqqOr!0?ooOjPg2EhG+_gV&O0tpurIVe@v7aVWW=h<^Nn2iv3y%`B1Dx z>VO!coLq`>;GpZojmDduyPp60o1H&`Pvxc&>+t4igRq+9qwqeNl0n8Yy79)o@81YZ zqD9&B_dS36o1HgbMubt0_SYFImyxZFNBvE~%PHdx{)n8%^||8BUH81X>+a`!E}8je z*X_zQ8VrO(4YGSmqZOsmT+xZnr=tvqHdViZu4#50Cvc560XwkRHv=BVO~)QUcQNKM zAQid}P|&tBS!*WVs=T&xUFF)!HLGiD5}&T< zUQ!b{ZuXpW-0V75Xm(vW_F`DYU1nmM8(2-(Gw$l$LpPPzbUV%6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sz{K6Y-_BBTE zp^mQ^&)!K&c=6c|wB#PASMF(grI~zUMK<){D!kVRU?acmkq@RaOMhES0El$n6pmSD zo1@Tf2yTuy`S7U7sDJb3NN_7ta&tu~;qIpiUxg@2HiB-B@c9SxWYSEu;(nQNKii_a zV*bs-8*PTYg;|j9udJtY^=O^G$&=bUO1lY2e`Zf@4ycD=wTm%gQ^DF2Qqtj%<+Kq% zn*;LuB*ftjlI%MJ@`2uZs zo-ga?Vre@H4J|>09P#}ac4^}6^4qb`_9YoMR-&VQPS)n{@WrFS2#uYuH5h7&HDhC^ z!^dBwrSq)d%u%b&Uk+%Qqyx)_EC+0cf)+i&0?Aq}t4TTsm!3sSOGz1p-#1>b z>{yRNBKkwF^rTxAP`}Pt89DHZ5?E55@sxtGx4>A~=Cib?H*jd|*`DwJlYggxItPX0 zGUR@F3bOS6>tAM&y5PT$a7a?AitU(l0!X?&zt6vSyrt2>iVAXkX8#Ki;&J}`rjlDN z{Cu9Wey0745U3`yiiB+cHyO{}nYzCk#s0o2mb+^?G37neo__exgIq!yxAFgg=H4w{!#L0KjTNSKXkEWe=x%@+cBJ`>@(EF zCbjUbXGNuuIezpUm!Tpx56`j;zW-;&Z^0<`EtgvMofb&enX#(D;I%uc1mu*m?^g?6 qDR?xboIlUYm9Wp~V(F%Dp#;L05io-k*N$RePW!7U9T~}G+W$A_NUj?I literal 0 HcmV?d00001 diff --git a/main.c b/main.c index 1cd3362..b966a69 100644 --- a/main.c +++ b/main.c @@ -39,23 +39,14 @@ void getuptime(char *buffer, int max_length) int main(int argc, char **argv) { - if (argc > 2) die(1, "usage: %s [artname]\n", argv[0]); - - struct utsname uname_buf; - char hostname[max_hostname_length]; - char username[max_username_length]; - char uptime[max_uptime_length]; - - int i; - char **art = NULL; - - gethostname(hostname, max_hostname_length); - getlogin_r(username, max_username_length); - getuptime(uptime, max_uptime_length); - - if (argc == 2) + char *art[4]; + if (argc > 2) { - for (i = 0; i < sizeof(arts)/sizeof(struct art_entry); ++i) + die(1, "usage: %s [artname]\n", argv[0]); + } + else if (argc == 2) + { + for (int i = 0; i < sizeof(arts)/sizeof(struct art_entry); ++i) if (!strcmp(arts[i].name, argv[1])) { art = arts[i].art; break; } if (!art) die(1, "Art %s not found\n", argv[1]); } else @@ -63,7 +54,16 @@ int main(int argc, char **argv) art = arts[0].art; } + char hostname[max_hostname_length]; + char username[max_username_length]; + char uptime[max_uptime_length]; + struct utsname uname_buf; + + gethostname(hostname, max_hostname_length); + getlogin_r(username, max_username_length); + getuptime(uptime, max_uptime_length); uname(&uname_buf); + printf("%s %s@%s\n", art[0], username, hostname); printf("%s --\n", art[1]); printf("%s %s %s\n", art[2], uname_buf.sysname, uname_buf.release);