aboutsummaryrefslogtreecommitdiffstats
path: root/src/pad.c
diff options
context:
space:
mode:
authorEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-10-13 20:54:28 -0500
committerEpoch Qwert <epoch@53flpnlls43fcguy.onion>2014-10-13 20:54:28 -0500
commit1852f2d7d63c39d0fd97a2774d1bd16bf53ec67d (patch)
tree69bc1a71b839857e6b841862b74aa3c0b56b860c /src/pad.c
downloadmisc-1852f2d7d63c39d0fd97a2774d1bd16bf53ec67d.tar.gz
misc-1852f2d7d63c39d0fd97a2774d1bd16bf53ec67d.zip
initial commit. collected some tools I had laying around.
Diffstat (limited to 'src/pad.c')
-rw-r--r--src/pad.c32
1 files changed, 32 insertions, 0 deletions
diff --git a/src/pad.c b/src/pad.c
new file mode 100644
index 0000000..2f2ea13
--- /dev/null
+++ b/src/pad.c
@@ -0,0 +1,32 @@
+#include <stdio.h>
+#include <string.h>
+
+int main(int argc,char *argv[]) {
+ short in;
+ int i=0;
+ int width=argc>1?atoi(argv[1]):80;
+ char with=argc>2?argv[2][0]:' ';
+ char *line=argc>3?argv[3]:0;
+ if(width <= 0) width=80;
+ if(!line) {
+ while((in=fgetc(stdin)) != -1) {
+ if(in == '\n') {
+ for(;i%width || i == 0;i++) {
+ putchar(with);
+ }
+ i=-1;
+ }
+ i++;
+ putchar(in);
+ }
+ } else {
+ i=strlen(line);
+ }
+ if(i != 0 || line) {
+ if(line) fputs(line,stdout);
+ for(;i%width || i == 0;i++) {
+ putchar(with);
+ }
+ }
+ return 0;
+}