aboutsummaryrefslogtreecommitdiffstats
path: root/src/bin/clump.c
diff options
context:
space:
mode:
authorepochqwert <epoch@53flpnlls43fcguy.onion>2015-02-06 02:32:04 -0600
committerepochqwert <epoch@53flpnlls43fcguy.onion>2015-02-06 02:32:04 -0600
commit3c2d290d17b739f14774dfcdf48581c1fb212286 (patch)
tree4b3bcf021e9994c21030aad99f84831ad31dbe02 /src/bin/clump.c
parentabe09a4717370f331b050ad39da3a7e9a478f02d (diff)
downloadmisc-3c2d290d17b739f14774dfcdf48581c1fb212286.tar.gz
misc-3c2d290d17b739f14774dfcdf48581c1fb212286.zip
some new tools. clump is useful. httpd got some better logging. cuturl got some bugfixes I think. todo is just a version of segfault's !todo but for shell. don't remember what I did to telnet-gateway.sh
Diffstat (limited to 'src/bin/clump.c')
-rw-r--r--src/bin/clump.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/bin/clump.c b/src/bin/clump.c
new file mode 100644
index 0000000..18c8e5b
--- /dev/null
+++ b/src/bin/clump.c
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+//clumps together consecutive rows containing the same first column
+//to have column 2- printed after a single column 1 value.
+//just try it out.
+//printf "a a\na b\na c\nb a\nb b\nc a\nc b\n" | clump
+//still working on the name.
+
+int main() {
+ char line[256];
+ char *id;
+ char *value;
+ char *oldid=malloc(1);
+ *oldid=0;
+ while(fgets(line,sizeof(line),stdin)) {
+ id=line;
+ if(strchr(line,'\n')) *strchr(line,'\n')=0;
+ if(strchr(id,' ')) {
+ value=strchr(id,' ');
+ *value=0;
+ value++;
+ }
+ if(strcmp(id,oldid)) {
+ if(*oldid != 0) {
+ printf("\n");
+ }
+ printf("%s:",id);
+ free(oldid);
+ oldid=strdup(id);
+ }
+ printf(" %s",value);
+ }
+ printf("\n");
+ return 0;
+}