mirror of https://github.com/dirtbags/moth.git
add fizzbuzz
This commit is contained in:
parent
23bd50f9bb
commit
8420f518ab
|
@ -0,0 +1,13 @@
|
||||||
|
#! /bin/sh
|
||||||
|
|
||||||
|
for i in $(seq 100); do
|
||||||
|
if [ $(expr $i % 15) = 0 ]; then
|
||||||
|
echo 'FizzBuzz'
|
||||||
|
elif [ $(expr $i % 3) = 0 ]; then
|
||||||
|
echo 'Fizz'
|
||||||
|
elif [ $(expr $i % 5) = 0 ]; then
|
||||||
|
echo 'Buzz'
|
||||||
|
else
|
||||||
|
echo $i
|
||||||
|
fi
|
||||||
|
done
|
|
@ -0,0 +1,29 @@
|
||||||
|
FIZZBUZZ_PKGDIR = $(TARGET)/fizzbuzz
|
||||||
|
FIZZBUZZ_BUILDDIR = $(BUILD)/fizzbuzz
|
||||||
|
|
||||||
|
$(FIZZBUZZ_BUILDDIR)/token.enc: packages/fizzbuzz/tokens.txt
|
||||||
|
$(FIZZBUZZ_BUILDDIR)/token.enc: packages/fizzbuzz/fizzbuzz-client.sh
|
||||||
|
$(FIZZBUZZ_BUILDDIR)/token.enc: $(FIZZBUZZ_BUILDDIR)/fizzbuzz-native
|
||||||
|
packages/fizzbuzz/fizzbuzz-client.sh | $(FIZZBUZZ_BUILDDIR)/fizzbuzz-native 3< packages/fizzbuzz/tokens.txt > $@
|
||||||
|
|
||||||
|
$(FIZZBUZZ_BUILDDIR)/fizzbuzz-native: packages/fizzbuzz/src/fizzbuzz.c
|
||||||
|
@ mkdir -p $(@D)
|
||||||
|
cc -o $@ $<
|
||||||
|
|
||||||
|
fizzbuzz-install: fizzbuzz-build
|
||||||
|
mkdir -p $(FIZZBUZZ_PKGDIR)/bin/
|
||||||
|
|
||||||
|
$(call COPYTREE, packages/fizzbuzz/service, $(FIZZBUZZ_PKGDIR)/service)
|
||||||
|
|
||||||
|
cp packages/fizzbuzz/tokens.txt $(FIZZBUZZ_PKGDIR)/
|
||||||
|
cp $(FIZZBUZZ_BUILDDIR)/token.enc $(FIZZBUZZ_PKGDIR)/
|
||||||
|
cp packages/fizzbuzz/src/fizzbuzz $(FIZZBUZZ_PKGDIR)/bin/
|
||||||
|
|
||||||
|
fizzbuzz-clean:
|
||||||
|
rm -rf $(FIZZBUZZ_PKGDIR) $(FIZZBUZZ_BUILDDIR)
|
||||||
|
$(MAKE) -C packages/fizzbuzz/src clean
|
||||||
|
|
||||||
|
fizzbuzz-build: $(FIZZBUZZ_BUILDDIR)/token.enc
|
||||||
|
$(MAKE) -C packages/fizzbuzz/src build
|
||||||
|
|
||||||
|
PACKAGES += fizzbuzz
|
|
@ -0,0 +1,11 @@
|
||||||
|
CFLAGS = -Wall -Werror
|
||||||
|
TARGETS = fizzbuzz
|
||||||
|
|
||||||
|
all: build
|
||||||
|
build: $(TARGETS)
|
||||||
|
|
||||||
|
install: $(TARGETS)
|
||||||
|
install -m 0755 $(TARGETS) $(DESTDIR)/bin
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f *.o $(TARGETS)
|
|
@ -1,5 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* How this works:
|
* How this works:
|
||||||
|
@ -25,7 +26,7 @@
|
||||||
* echo $i
|
* echo $i
|
||||||
* fi
|
* fi
|
||||||
* done
|
* done
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
char craptable[] = {
|
char craptable[] = {
|
||||||
|
@ -50,11 +51,11 @@ main(int argc, char *argv[])
|
||||||
printf("Somebody didn't read the instructions.\n");
|
printf("Somebody didn't read the instructions.\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
tokenlen = fread(token, 1, sizeof(token), tokenin);
|
tokenlen = fread(token, 1, sizeof(token), tokenin);
|
||||||
fclose(tokenin);
|
fclose(tokenin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (i=1; i <= 100; i += 1) {
|
for (i=1; i <= 100; i += 1) {
|
||||||
char l[100];
|
char l[100];
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
net:xuhen-fizuv-syvex
|
|
@ -4,10 +4,11 @@ exec 2>&1
|
||||||
|
|
||||||
install -d /var/lib/ctf
|
install -d /var/lib/ctf
|
||||||
|
|
||||||
# Create CTF user
|
# Create CTF and nobody users
|
||||||
touch /etc/group /etc/passwd
|
touch /etc/group /etc/passwd
|
||||||
addgroup -g 56634 nogroup || true
|
addgroup -g 65534 nogroup || true
|
||||||
adduser -D -S -h /var/lib/ctf -H ctf || true
|
adduser -D -S -h /var/lib/ctf -H ctf || true
|
||||||
|
adduser -D -g nogroup -u 65534 -h /tmp -H nobody || true
|
||||||
|
|
||||||
# Set up base directories
|
# Set up base directories
|
||||||
NEWDIR=/var/lib/ctf/points.new
|
NEWDIR=/var/lib/ctf/points.new
|
||||||
|
|
|
@ -8,4 +8,4 @@ install: $(TARGETS)
|
||||||
install -m 0755 $(TARGETS) $(DESTDIR)/bin
|
install -m 0755 $(TARGETS) $(DESTDIR)/bin
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o $(TARGETS)
|
rm -f *.o $(TARGETS)
|
||||||
|
|
Loading…
Reference in New Issue