/ins.c (39840bed670aa774d82be871dbd7cad97fc60612) (817 bytes) (mode 100644) (type blob)
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main(int argc, char *argv[])
{
FILE *fp, *tfp;
char *fbuf;
char *buf;
long fsize, tsize;
char instext[10000];
fread(instext, sizeof(instext), 1, stdin);
for (int i=1; argv[i]; i++) {
if (argc>1&&(fp=fopen(argv[i], "a+"))==NULL) {
fprintf(stderr, "ins: unable to open %s\n", argv[i]);
continue;
}
if ((tfp=fopen(".instemp~~~", "a+"))==NULL) {
fprintf(stderr, "ins: unable to open temporary file\n");
return 1;
}
fseek(fp, 0L, SEEK_END);
fsize=ftell(fp);
fbuf=malloc(fsize+1);
rewind(fp);
fread(fbuf, fsize, 1, fp);
buf=malloc(sizeof(instext)+sizeof(fbuf)+2);
strcpy(buf, instext);
strcat(buf, fbuf);
fputs(buf, tfp);
rename(".instemp~~~", argv[i]);
free(buf);
fclose(fp);
fclose(tfp);
}
return 0;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
82 |
c1252739cccef312e4b451b9ca190350e65798b9 |
COPYING |
100755 |
blob |
676 |
b83c078041e2f7cc06ed7bde425708a9f0daf948 |
INSTALL |
100644 |
blob |
1573 |
9e8fb6bfb8b01fa3ffc9683a4aa74479e4640aa3 |
README |
100644 |
blob |
3492 |
2fdd5ec93f3a04a1c8d3a2e74fea922ffee58b41 |
clp.c |
100644 |
blob |
142 |
66ddd77911db11fab37139f10ccace21a21ea7e8 |
echo.c |
100644 |
blob |
152 |
4cac7fdfacc7df35b2d09f641a524d9370a564ae |
exho.c |
100644 |
blob |
817 |
39840bed670aa774d82be871dbd7cad97fc60612 |
ins.c |
100644 |
blob |
347 |
94381f8173b7b7b6732e81bd4588c5ce0bc6f18f |
nl.l |
100644 |
blob |
1278 |
5d13cc09ac4024170ba3ca102c657f10e2d0fac5 |
sc.c |
100644 |
blob |
341 |
0a5de084da1b736602af29a9175341ac9322ffcd |
spng.c |
100644 |
blob |
513 |
1ad1125d57e0a255ed9218defa5b14d9c7962b0a |
tee.c |
100644 |
blob |
1444 |
d3316c60317a88cbe4f9c4230cec56022348dca6 |
wc.c |
100644 |
blob |
130 |
17ddde74c448540143c760e7cacd359c3d6ca85e |
yes.c |
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"
Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/spicylord/clutils
Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/spicylord/clutils
Clone this repository using git:
git clone git://git.rocketgit.com/user/spicylord/clutils
You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a
merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main