Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Fmask [c posix]

Name: Anonymous 2014-05-03 7:06

This is the main code, resize.c, reverse.c, xor.c, swap.c, rswap.c will be posted you want to see them. Hope you like...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

#define PROGRAM_VERSION "1.1"
#define BIN_PATH "bin/"

struct { const char *p, *s; } cmds[] = {
{ "swap", "rswap" },
{ "blowfish", "blowfish_dec" },
{ "rc4", "rc4_dec" },
{ "aes", "aes_dec" }
};

void help(void)
{
printf("fmask v. %s -- apply masks to files\n"
"fmask [operation_1 ... operation_k] <file>\n"
"operation may be: reverse, swap, xor, aes, "
"blowfish or rc4\n", PROGRAM_VERSION);
}

char **push(char *p)
{
static char *s[128], **q = s + 1;
*q = malloc(strlen(p) + 1);
strcpy(*q, p);
return q++;
}

char *inversecmd(char *p)
{
static char r[128];
size_t i;
char *s = strchr(p, ' ');

if(s && s - p < sizeof r) {
strncpy(r, p, s - p);
r[s - p] = 0;
} else *r = 0;
for(i = 0; i < sizeof cmds / sizeof *cmds; i++)
if(strcmp(r, cmds[i].p) == 0) {
strcpy(r, cmds[i].s);
break;
} else if(strcmp(r, cmds[i].s) == 0) {
strcpy(r, cmds[i].p);
break;
}
return r;
}

char *cmd(char *p, char *s)
{
size_t i, j = strlen(p), k = strlen(s), n = strlen(BIN_PATH);
char *r;

if(r = malloc(j + k + n + 2)) {
strncpy(r, BIN_PATH, n);
r += n;
for(i = 0; i < j; i++)
r[i] = p[i] == ':' ? ' ' : p[i];
r[i] = ' ';
strcpy(r + i + 1, s);
}
return r ? r - n : 0;
}

int main(int argc, char **argv)
{
char *file, *p, *q, *qq, qqq[128], **stack = 0;
int i;
unsigned long lu = 0, b = 0;
struct stat s;
FILE *fp;

if(argc < 3) {
help();
return 0;
}
else file = argv[--argc];
if(stat(file, &s) == -1) return 0;
for(i = 1; i < argc; i++) {
p = cmd(argv[i], file);
if(p == NULL) return 0;
if(fp = popen(p, "r")) {
q = inversecmd(p + sizeof BIN_PATH - 1);
if(fscanf(fp, "%lu", &lu) == 1) {
b = 1;
qq = strchr(argv[i], ':');
if(lu)
sprintf(qqq, "%s%s resize:%lu", q, qq ? qq : "",
(s.st_size += lu) - lu), lu = 0;
else
sprintf(qqq, "%s%s", q, qq ? qq : "");
stack = push(qqq);
}
pclose(fp);
}
free(p);
}
while(stack && *stack) {
printf("%s ", *stack);
free(*stack--);
}
if(b) puts(file);
return 0;
}

Name: Anonymous 2014-05-09 1:10

Stop fishing for compliments. Just post this shit on reddit.

Name: Anonymous 2014-05-09 3:03

>>11
reddit a shit. I like seeing code posted here. compliments or not.

*downvotes >>11-sama*

Name: Anonymous 2014-05-09 13:01

>>11
I ``fish'', if anything, for discussion and criticism, because I wrote it. I want others to take interest in something I worked on. I will post it on reddit.

Name: Anonymous 2014-05-09 13:44

Name: Cocklover 2014-05-09 14:50

I love cocks

Name: Anonymous 2014-05-09 14:52

I'm so happy for >>11-san

Name: Anonymous 2014-05-09 20:44

I'm so happy for >>15 san.

Name: Anonymous 2014-05-09 21:11

>>14
STAY ON REDDIT, PLEASE.

Name: >>18 2014-05-10 11:26

And after a few weeks, come back and show us the brilliant and amusing memes of reddit!

Name: Anonymous 2015-12-30 2:30

bampu pantsu

Name: Anonymous 2015-12-30 3:27

>>22
nice ducks

Name: Anonymous 2015-12-30 6:21

>>21
Suck a dick, dubsfaggot.

Name: Anonymous 2015-12-30 6:53

>>22
quack

Name: Anonymous 2015-12-30 16:37

Holy shit that some nice dubs !!

Name: Anonymous 2015-12-31 1:02

>>9
No comments? This is depressing.

Yes, it's very depressing to see the lack of comments in your code, you piece of shit. Nobody wants to look at that wall of uncommented single-character variable names.

It's not like smaller source code makes it run faster, you know.

Name: Anonymous 2015-12-31 3:41

>>25
Where is your program for inspection? >>1- has written his already, but you have nothing but vitriol to show us.

Name: Anonymous 2015-12-31 4:31

>>26
Not for your eyes. Besides, the shittiness of uncommented, single-char variable code stands on its own judgment, and needs no exemplar to see how shit it is.

Name: Anonymous 2016-01-01 11:55

>>26
Critics need not practise their subject, and it is often detrimental to do so. Ever seen a chef who is also a food critic? The only music critics-turned-musicians were the Pet Shop Boys, and that's not exactly top-of-the-line material. Program reviewers need not also present a program of their own as a license to pass comment.
Point is, >>26, you should just stick to today's special.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List