/sc.c (14427f08d4bd234619f7e493847d9178e8e40f57) (1976 bytes) (mode 100644) (type blob)
/*
Copyright 2019 Matthew Graham <sl@airmail.cc>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char *buf;
unsigned int ccase = 0;
long size;
int i = 1;
FILE *fp = stdin;
if (argv[1] && argv[1][0]=='-' && argv[1][1]) {
switch (argv[1][1]) {
case 'l': ccase = 'l'; break;
case 'u': ccase = 'u'; break;
case 's': ccase = 's'; break;
}
}
else {
fprintf(stderr, "sc: usage: sc -[ l|u|s ] [file...]\n");
return 1;
}
argc--;
argv++;
do {
if (argc > 1 && (fp=fopen(argv[i], "r"))==NULL) {
fprintf(stderr, "sc: unable to open %s\n", argv[i]);
continue;
}
fseek(fp, 0L, SEEK_END);
size = ftell(fp);
rewind(fp);
buf = malloc(size+1);
fread(buf, size, 1, fp);
switch (ccase) {
case 'l':
for (int a=0; buf[a]; a++) {
if (buf[a] >= 'A' && buf[a] <= 'Z')
buf[a] += 32;
putchar(buf[a]);
}
break;
case 'u':
for (int b=0; buf[b]; b++) {
if (buf[b] >= 'a' && buf[b] <= 'z')
buf[b] -= 32;
putchar(buf[b]);
}
break;
case 's':
for (int c=0; buf[c]; c++) {
if (buf[c] >= 'a' && buf[c] <= 'z') {
buf[c] -= 32;
putchar(buf[c]);
continue;
}
else if (buf[c] >= 'A' && buf[c] <= 'Z') {
buf[c] += 32;
putchar(buf[c]);
continue;
}
putchar(buf[c]);
}
break;
}
} while (++i<argc);
return 0;
}
Mode |
Type |
Size |
Ref |
File |
100644 |
blob |
35149 |
f288702d2fa16d3cdf0035b15a9fcbc552cd88e7 |
COPYING |
100755 |
blob |
676 |
b83c078041e2f7cc06ed7bde425708a9f0daf948 |
INSTALL |
100644 |
blob |
1794 |
b38b363dcdd9a397f9aeead45ca0abd624cb8993 |
README |
100644 |
blob |
4170 |
65ea38779720e5b46409bf1ca341350c916a53dd |
clp.c |
100644 |
blob |
819 |
0f2b94b95ab8a249b6131cb9947c1524ec456e49 |
echo.c |
100644 |
blob |
819 |
5f4f1921ce280bf5a1e2c67cca5431356411d10f |
exho.c |
100644 |
blob |
1498 |
ee38f5bf9009a0326bd8e6d8d5c0d300e8863fcb |
ins.c |
100644 |
blob |
991 |
4c5b7c9b92e8d0b61b9247d1e81d1f026598fd30 |
nl.l |
100644 |
blob |
1976 |
14427f08d4bd234619f7e493847d9178e8e40f57 |
sc.c |
100644 |
blob |
1016 |
6e2a3e198c94e1cda600226a8e49a9d35e7c358f |
spng.c |
100644 |
blob |
1190 |
4f47af1f84fdf30597c7bf12889a86ec4318e87d |
tee.c |
100644 |
blob |
2111 |
11761302592629a999a113c68d55f88ffd9c8052 |
wc.c |
100644 |
blob |
798 |
bde359728301efd5f511798225cc4bd2ab6c1733 |
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