Cleaned up crud, added to README
This commit is contained in:
parent
14eb6244f4
commit
acd1f59fa7
BIN
flags/a.out
BIN
flags/a.out
Binary file not shown.
|
@ -1,47 +0,0 @@
|
|||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
const char fileext[] = "flag";
|
||||
const char magic[] = "flag";
|
||||
#define MAGICLEN 4
|
||||
|
||||
const int maxlen = 256;
|
||||
|
||||
|
||||
int main (void)
|
||||
{
|
||||
DIR *dirp;
|
||||
struct dirent *entryp;
|
||||
dirp = opendir("./");
|
||||
|
||||
if(dirp != NULL){
|
||||
while(entryp = readdir(dirp)){
|
||||
char *filename = entryp->d_name;
|
||||
int fextpos = strnlen(filename, maxlen) - strlen(fileext);
|
||||
if(0 == strncmp(fileext, &filename[fextpos], maxlen)){
|
||||
printf("flagfile: ");
|
||||
FILE *file = fopen(filename, "r");
|
||||
if(file != NULL){
|
||||
char sample[MAGICLEN];
|
||||
fread(&sample , MAGICLEN, 1, file);
|
||||
fclose(file);
|
||||
if(0 == strncmp(magic, sample, MAGICLEN)){
|
||||
printf("[valid] ");
|
||||
}
|
||||
}else{
|
||||
perror("Couldn't open file. ");
|
||||
}
|
||||
}
|
||||
printf("%s\t\n", filename);
|
||||
}
|
||||
|
||||
(void)closedir(dirp);
|
||||
}else{
|
||||
perror("Couldn't open the directory");
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
flag: 0.0;
|
||||
// mockup flag file
|
||||
name:
|
||||
pride
|
||||
;
|
||||
aliases:
|
||||
;
|
||||
description:
|
||||
The well-known, six-striped pride-flag.
|
||||
;
|
||||
data:
|
||||
#e70000, // red
|
||||
#ff8c00, // orange
|
||||
#ffef00, // yellow
|
||||
#00811F, // green
|
||||
#0044FF, // blue
|
||||
#760098 // purple
|
||||
;
|
Loading…
Reference in a new issue