summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2015-01-09 19:25:02 -0600
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2015-01-09 19:25:02 -0600
commit3f6b64304a8a11f0505e91681384327696983928 (patch)
tree77cffccf8ad8901b844334a0c068ac951e93d6a8 /src
parente23c6287bb1124397c126c83cc73fed17fda998f (diff)
downloadmisc-3f6b64304a8a11f0505e91681384327696983928.tar.gz
misc-3f6b64304a8a11f0505e91681384327696983928.zip
XuntilY.awk is actually a shell script, but mostly written in awk to make XuntilY easier to use for people without Perl
gopherd.sh... I don't remember the change. music.c is to practice reading music. sockip is to get the IP of the listening socket, like if ran from inetd
Diffstat (limited to 'src')
-rw-r--r--src/games/music.c59
-rw-r--r--src/libexec/sockip.c15
2 files changed, 74 insertions, 0 deletions
diff --git a/src/games/music.c b/src/games/music.c
new file mode 100644
index 0000000..3b52b4e
--- /dev/null
+++ b/src/games/music.c
@@ -0,0 +1,59 @@
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <stdlib.h>
+
+char cheat;
+
+void print_note(char n) {
+ printf(" %c \n",n=='G'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='F'?cheat?n:'o':'-');
+ printf(" %c \n",n=='E'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='D'?cheat?n:'o':'-');
+ printf(" %c \n",n=='C'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='B'?cheat?n:'o':'-');
+ printf(" %c \n",n=='A'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='g'?cheat?n:'o':'-');
+ printf(" %c \n",n=='f'?cheat?n:'o':' ');
+ printf("--%c--\n",n=='e'?cheat?n:'o':'-');
+ printf(" %c \n",n=='d'?cheat?n:'o':' ');
+ printf(" %c \n",n=='c'?cheat?n:'o':' ');
+ printf(" %c \n",n=='b'?cheat?n:'o':' ');
+ printf(" %c \n",n=='a'?cheat?n:'o':' ');
+}
+
+char notes[]="ABCDEFGabcdefg";
+
+int main(int argc,char *argv[]) {
+ int count;
+ int correct=0;
+ int total=20;
+ char note;
+ cheat=argc > 1;
+ short in;
+ srandom(time(0));
+ total=20;
+ count=total;
+ printf("\x1b[H\x1b[J");
+ time_t end;
+ time_t start=time(0);
+ for(;in != -1 && count;count--) {
+ note=notes[random()%strlen(notes)];
+ print_note(note);
+ in=fgetc(stdin);
+ if(in == note || in == note+' ') {
+ printf("\x1b[H\x1b[J");
+ printf("Yay!\n");
+ correct++;
+ in=fgetc(stdin);//kill the newline
+ } else {
+ printf("\x1b[H\x1b[J");
+ printf("boo!\n");
+ in=fgetc(stdin);//kill the newline
+ }
+ }
+ end=time(0);
+ printf("took you %lld seconds\n",end-start);
+ printf("got %d/%d right.\n",correct,total);
+ return 0;
+}
diff --git a/src/libexec/sockip.c b/src/libexec/sockip.c
new file mode 100644
index 0000000..542a88d
--- /dev/null
+++ b/src/libexec/sockip.c
@@ -0,0 +1,15 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#include <netinet/in.h>
+
+int main(int argc,char *argv[]) {
+ struct sockaddr_in6 sa6;
+ unsigned int sl=sizeof(sa6);
+ char h[NI_MAXHOST], s[NI_MAXSERV];
+ if(getsockname(0,(struct sockaddr *)&sa6,&sl) == -1) return 1;
+ if(getnameinfo((struct sockaddr *)&sa6,sl,h,sizeof(h),s,sizeof(s),NI_NUMERICHOST|NI_NUMERICSERV)) return 2;
+ puts(h);
+ puts(s);
+ return 0;
+}