From 7b52f4dca2764ee98ad4b76874e99af850f402cb Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Mon, 25 Jan 2010 10:43:08 +0000 Subject: [PATCH] aop: Initial import (verified compilation). --- aop/.footprint | 20 ++++ aop/.md5sum | 2 + aop/Pkgfile | 17 +++ aop/aop-0.6.patch | 271 ++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 310 insertions(+) create mode 100644 aop/.footprint create mode 100644 aop/.md5sum create mode 100644 aop/Pkgfile create mode 100644 aop/aop-0.6.patch diff --git a/aop/.footprint b/aop/.footprint new file mode 100644 index 0000000..f9eacf4 --- /dev/null +++ b/aop/.footprint @@ -0,0 +1,20 @@ +drwxr-xr-x root/root usr/ +drwxr-xr-x root/root usr/bin/ +-rwxr-xr-x root/root usr/bin/aop +drwxr-xr-x root/root usr/share/ +drwxr-xr-x root/root usr/share/aop/ +-rw-r--r-- root/root usr/share/aop/aop-level-01.txt +-rw-r--r-- root/root usr/share/aop/aop-level-02.txt +-rw-r--r-- root/root usr/share/aop/aop-level-03.txt +-rw-r--r-- root/root usr/share/aop/aop-level-04.txt +-rw-r--r-- root/root usr/share/aop/aop-level-05.txt +-rw-r--r-- root/root usr/share/aop/aop-level-06.txt +-rw-r--r-- root/root usr/share/aop/aop-level-07.txt +-rw-r--r-- root/root usr/share/aop/aop-level-08.txt +-rw-r--r-- root/root usr/share/aop/aop-level-09.txt +-rw-r--r-- root/root usr/share/aop/aop-level-10.txt +-rw-r--r-- root/root usr/share/aop/aop-level-11.txt +drwxr-xr-x root/root var/ +drwxr-xr-x root/root var/spool/ +drwxrwxrwx root/root var/spool/aop/ +-rw-rw-rw- root/root var/spool/aop/score (EMPTY) diff --git a/aop/.md5sum b/aop/.md5sum new file mode 100644 index 0000000..a271937 --- /dev/null +++ b/aop/.md5sum @@ -0,0 +1,2 @@ +cdbda15d804fde906a6112231a853a53 aop-0.6.patch +8057b3ec240db608253d653eb692d244 aop-0.6.tar.gz diff --git a/aop/Pkgfile b/aop/Pkgfile new file mode 100644 index 0000000..857aa1d --- /dev/null +++ b/aop/Pkgfile @@ -0,0 +1,17 @@ +# Description: Aop is a curses based arcade game. +# URL: http://raffi.at/view/code/aop +# Arch Maintainer: CRUX-ARM System Team, crux-arm at mikeux dot dyndns dot org +# Depends on: ncurses + +name=aop +version=0.6 +release=3 +source=(http://raffi.at/code/$name/$name-$version.tar.gz \ + $name-$version.patch) + +build() { + cd $name-$version + patch -p1 -i $SRC/$name-$version.patch + make CC="$CC" CFLAGS="$CFLAGS" + make DESTDIR=$PKG install +} diff --git a/aop/aop-0.6.patch b/aop/aop-0.6.patch new file mode 100644 index 0000000..0f2c24d --- /dev/null +++ b/aop/aop-0.6.patch @@ -0,0 +1,271 @@ +diff -purN aop-0.6.orig/Makefile aop-0.6/Makefile +--- aop-0.6.orig/Makefile 2009-09-02 08:19:08.652153613 +0200 ++++ aop-0.6/Makefile 2009-09-02 09:26:25.984152748 +0200 +@@ -1,14 +1,27 @@ ++DESTDIR = + ++CC = gcc ++CFLAGS = -Wall -O2 + LDFLAGS = -lncurses ++SRCS = scoring.c aop.c ++OBJS = $(SRCS:.c=.o) + +-aop: aop.c ++all: aop ++ ++.c.o: ++ $(CC) $(CFLAGS) -c $*.c -o $*.o ++ ++aop: $(OBJS) ++ $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ + + install: aop +- install -d /usr/local/bin +- install -d /usr/local/share/aop +- install -m 755 aop /usr/local/bin/aop +- install -m 644 aop-level-*.txt /usr/local/share/aop/ ++ install -d $(DESTDIR)/usr/bin ++ install -d $(DESTDIR)/usr/share/aop ++ install -m 755 aop $(DESTDIR)/usr/bin/aop ++ install -m 644 aop-level-*.txt $(DESTDIR)/usr/share/aop/ ++ install -d -m 777 $(DESTDIR)/var/spool/aop ++ touch $(DESTDIR)/var/spool/aop/score ++ chmod 666 $(DESTDIR)/var/spool/aop/score + + clean: +- rm -f aop core* *~ +- ++ rm -f aop *.o *~ +diff -purN aop-0.6.orig/aop.c aop-0.6/aop.c +--- aop-0.6.orig/aop.c 2009-09-02 08:19:08.652153613 +0200 ++++ aop-0.6/aop.c 2009-09-02 10:22:28.457051144 +0200 +@@ -2,14 +2,20 @@ + /* Raffael Himmelreich */ + /* Clifford Wolf */ + ++/* Patched by Jose V Beneyto */ ++ + #include + #include + #include ++#include ++#include "scoring.h" + + int main(int argc, char *argv[]) { +- int px, py, opx, opy, ipx, ipy, x, y, c=0, p=0, op, dir; ++ int px, py, opx, opy, ipx, ipy, x, y, c=0, p=0, op, dir, scorepos; + int last_lv = argc>=2 ? argc-1 : 11, level=1, lifes=5; FILE *f; + char ch, field[25][81], tmp[96], *lastword = "Bye."; ++ char *playerName=NULL; ++ struct passwd *userinfo; + + if ( argc > 1 && *argv[1] == '-' ) { + printf("Usage: %s [aop-level-01.txt [..] ]\n", argv[0]); +@@ -21,7 +27,7 @@ int main(int argc, char *argv[]) { + init_pair(1, COLOR_RED, COLOR_BLACK); + + start: memset(field, ' ', 25*81); +- snprintf(tmp, 96, "/usr/local/share/aop/aop-level-%02d.txt", level); ++ snprintf(tmp, 96, "/usr/share/aop/aop-level-%02d.txt", level); + f = fopen(argc>=2 ? argv[level] : tmp, "r"); + if (!f) { endwin(); printf("Can't open level file.\n"); return 1; } + opx=ipx=px=3, opy=ipy=py=2; op=p; p += 700000 + level*373737; +@@ -55,10 +61,28 @@ start: memset(field, ' ', 25*81); + attron(COLOR_PAIR(1)); + mvprintw(0, 0, "Lifes: %d, Points: %d ", + lifes, p=p-(dir < 5 ? 1 : 2)); +- refresh(); usleep(dir < 5 ? 50000 : 100000); ++ refresh(); usleep(dir < 5 ? 100000 : 200000); + } while( (c=getch()) != 'q' ); +- endwin(); printf("%s (%d points)\n", lastword, p); ++ endwin(); ++ printf("%s (%d points)\n", lastword, p); ++ if (playerName==NULL) { ++ userinfo = getpwuid(getuid()); ++ if (userinfo!=NULL) { ++ playerName = strdup(userinfo->pw_name); ++ } ++ else { ++ playerName = strdup("UNKNOWN"); ++ } ++ } ++ scorepos = add_high_score(playerName, level, p); ++ if (scorepos==0) { ++ fprintf(stderr,"\nUnable to write highscore file %s\n\n", HIGHSCOREFILE); ++ } ++ else { ++ if (scorepos != MAXHIGHSCORES+1) { ++ printf("\nYou got into position %d in the score table\n\n", scorepos); ++ } ++ print_high_scores(); ++ } + return strcmp(lastword, "Sucker!") == 0; + } +- +-/* Yup - This are 64 lines of C code. ;-) */ +diff -purN aop-0.6.orig/scoring.c aop-0.6/scoring.c +--- aop-0.6.orig/scoring.c 1970-01-01 01:00:00.000000000 +0100 ++++ aop-0.6/scoring.c 2009-09-02 10:24:39.536533588 +0200 +@@ -0,0 +1,128 @@ ++/* ++ Routines to deal with high score files for tetris. ++ Copyright 1999 Jonathan McDowell for Project Purple ++ 21/05/99 ++ ++ 27/06/99 - Added date field ++ ++ Jose V Beneyto ++ 02/09/09 - Removed basedelay from the struct and fixed highscorefile usage ++*/ ++ ++#include ++#include ++#include ++#include ++#include "scoring.h" ++ ++int get_high_scores(struct highscoreent *highscores[], int *numscores) ++{ ++ FILE *scorefile; ++ long filelen; ++ ++ if ((scorefile=fopen(HIGHSCOREFILE,"r"))==NULL) { ++ return 0; ++ } ++ ++ fseek(scorefile, 0, SEEK_END); ++ filelen=ftell(scorefile)+1; ++ rewind(scorefile); ++ ++ if ((*highscores=malloc(filelen))==NULL) { ++ return 0; ++ } ++ ++ fread(*highscores, 1, filelen, scorefile); ++ *numscores=filelen/sizeof(struct highscoreent); ++ if (*numscores>MAXHIGHSCORES) *numscores=MAXHIGHSCORES; ++ ++ fclose(scorefile); ++ return 1; ++} ++ ++int save_high_scores(struct highscoreent highscores[], int *numscores) ++{ ++ FILE *scorefile; ++ ++ if ((scorefile=fopen(HIGHSCOREFILE,"w"))==NULL) { ++ return 0; ++ } ++ ++ if (*numscores>MAXHIGHSCORES) *numscores=MAXHIGHSCORES; ++ fwrite(highscores, 1, *numscores * sizeof(struct highscoreent), scorefile); ++ ++ fclose(scorefile); ++ return 1; ++} ++ ++/* Checks if a score got into the high score table and if so add it to ++ the high score file. Returns 0 if unable to do so, MAXHIGHSCORES+1 ++ if the score didn't get into the high score table, otherwise the ++ position in the table. */ ++int add_high_score(const char name[], unsigned int endlvl, unsigned int score) ++{ ++ struct highscoreent highscore; ++ struct highscoreent *scores, *newscores; ++ int loop, numscores; ++ ++ strncpy(highscore.name, name, 15); ++ highscore.name[15]=numscores=0; ++ highscore.endlvl=endlvl; ++ highscore.score=score; ++ highscore.date=time(NULL); ++ ++ if (get_high_scores(&scores, &numscores)==0 || numscores==0) { ++ numscores=1; ++ if (save_high_scores(&highscore, &numscores)) ++ return 1; ++ else ++ return 0; ++ } ++ ++ if (numscores==MAXHIGHSCORES) numscores--; ++ ++ if ((newscores=malloc(sizeof(struct highscoreent)*(numscores+1)))==NULL) { ++ return 0; ++ } ++ ++ memcpy(newscores, scores, sizeof(struct highscoreent)*numscores); ++ ++ loop=0; ++ while (score<(scores[loop]).score && loop ++ 02/09/09 - Removed basedelay from the struct and fixed highscorefile usage ++*/ ++ ++#include ++ ++/* Default high score file location */ ++#define HIGHSCOREFILE "/var/spool/aop/score" ++/* Max number of high scores we store */ ++#define MAXHIGHSCORES 20 ++ ++struct highscoreent { ++ char name[16]; ++ unsigned int endlvl, lines, score; ++ time_t date; ++}; ++ ++int get_high_scores(struct highscoreent *highscores[], int *numscores); ++int save_high_scores(struct highscoreent highscores[], int *numscores); ++/* Checks if a score got into the high score table and if so add it to ++ the high score file. Returns 0 if unable to do so, MAXHIGHSCORE+1 ++ if the score didn't get into the high score table, otherwise the ++ position in the table. */ ++int add_high_score(const char name[], unsigned int endlvl, unsigned int score); ++void print_high_scores(void); -- 2.26.2