Merge branch 'ohligs' into readwrite

This commit is contained in:
Marian Ohligs 2011-05-23 13:48:12 +02:00
commit bb80eec6e4
6 changed files with 60 additions and 10 deletions

1
.gitignore vendored
View file

@ -18,6 +18,7 @@ newlib/examples/hello
newlib/examples/jacobi
newlib/examples/echo
newlib/examples/tests
newlib/examples/hangman
newlib/tmp/*
newlib/x86/*
metalsvm.elf

View file

@ -109,15 +109,14 @@ static void keyboard_handler(struct state *r)
* you would add 128 to the scancode when you look for it
*/
kputchar(kbdus[scancode]);
if (kb_buffer.size <= kb_buffer.maxsize) {
if (kb_buffer.size <= kb_buffer.maxsize && kb_buffer.buffer != NULL) {
memcpy(kb_buffer.buffer + kb_buffer.size, &kbdus[scancode], 1);
kb_buffer.size++;
if (scancode == 28 || scancode == 15 || kb_buffer.size >= kb_buffer.maxsize) {
wakeup_task(kb_buffer.tid);
reschedule();
}
}
if (scancode == 28 || scancode == 15 || kb_buffer.size >= kb_buffer.maxsize) {
wakeup_task(kb_buffer.tid);
reschedule();
}
}
}

View file

@ -119,7 +119,7 @@ static int STDCALL join_test(void* arg)
int test_init(void)
{
char* argv[] = {"/bin/hello", NULL};
char* argv[] = {"/bin/hangman", NULL};
//sem_init(&producing, 1);
//sem_init(&consuming, 0);
@ -131,7 +131,7 @@ int test_init(void)
//create_kernel_task(NULL, consumer, NULL);
//create_kernel_task(NULL, ping, NULL);
//create_user_task(NULL, "/bin/hello", argv);
create_user_task(NULL, "/bin/hello", argv);
create_user_task(NULL, "/bin/hangman", argv);
//create_user_task(NULL, "/bin/jacobi", argv);
return 0;

View file

@ -11,7 +11,7 @@ LDFLAGS =
default: all
all: hello tests jacobi
all: hello tests jacobi hangman
jacobi: jacobi.o
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $< -lm
@ -31,6 +31,13 @@ hello: hello.o
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
chmod a-x $@.sym
hangman: hangman.o
$(CC_FOR_TARGET) -T link.ld -o $@ $(LDFLAGS) $<
$(OBJCOPY_FOR_TARGET) $(KEEP_DEBUG) $@ $@.sym
$(OBJCOPY_FOR_TARGET) $(STRIP_DEBUG) $@
chmod a-x $@.sym
clean:
$(RM) hello tests *.sym *.o *~

41
newlib/examples/hangman.c Normal file
View file

@ -0,0 +1,41 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int Spiel ()
{
//Variablen
char* Wort = malloc(100*sizeof(char));
char* Raten = malloc(100*sizeof(char));;
int Versuche = 10;
printf("Spieler 1 geben sie das Wort ein :");
scanf("%s", Wort);
printf("\n\nNun, Spieler 2 errate bitte das Wort\n");
while(Raten!=Wort && Versuche > 0){
printf("Deine Antwort:");
scanf("%s", Raten);
if(!strcmp(Raten,Wort))
{
printf("ToLL! Das Wort ist richtig");
return 0;
}
else
{
printf("Schade das Wort ist falsch");
}
Versuche--;
}
return 0;
}//Spielen
int main(int argc, char** argv)
{
Spiel();
}

View file

@ -1 +1,3 @@
123456789
test
hallo
huso