mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 13:24:01 +02:00
wip
This commit is contained in:
parent
521af62b24
commit
d0dffee14d
5 changed files with 45 additions and 12 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
brmbar
|
||||
brmbar.com
|
||||
|
|
9
Makefile
9
Makefile
|
@ -1,11 +1,12 @@
|
|||
CC=bcc
|
||||
CFLAGS=-Md -W
|
||||
|
||||
brmbar.com: brmbar.c defines.h
|
||||
$(CC) $(CFLAGS) brmbar.c -o brmbar.com
|
||||
all: brmbar.c defines.h
|
||||
gcc -Wall brmbar.c -o brmbar
|
||||
bcc -Md -W brmbar.c -o brmbar.com
|
||||
|
||||
clean:
|
||||
rm -f brmbar.com
|
||||
rm -f brmbar.com brmbar
|
||||
|
||||
run:
|
||||
dos:
|
||||
dosbox brmbar.com
|
||||
|
|
39
brmbar.c
39
brmbar.c
|
@ -1,4 +1,5 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "defines.h"
|
||||
|
||||
struct item {
|
||||
|
@ -7,7 +8,10 @@ struct item {
|
|||
int price;
|
||||
} items[ITEM_MAXNUM];
|
||||
|
||||
char *people[PERSON_MAXLEN];
|
||||
|
||||
int items_count;
|
||||
int people_count;
|
||||
|
||||
void fill_items()
|
||||
{
|
||||
|
@ -19,14 +23,24 @@ void fill_items()
|
|||
fclose(f);
|
||||
}
|
||||
|
||||
void fill_people()
|
||||
{
|
||||
FILE *f = fopen("people.txt", "r");
|
||||
people_count = 0;
|
||||
while (fgets(people[people_count], PERSON_MAXLEN , f)) {
|
||||
++people_count;
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
||||
int read_item() {
|
||||
char buf[128];
|
||||
int i;
|
||||
for (;;) {
|
||||
printf("i> ");
|
||||
if (fgets(buf, 128, stdin)) {
|
||||
for (i = 0; ; ++i) {
|
||||
if (!strncmp( buf, items[0].ean, strlen(items[0].ean) )) {
|
||||
for (i = 0; i < items_count; ++i) {
|
||||
if (!strncmp( buf, items[i].ean, strlen(items[i].ean) )) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
@ -35,18 +49,29 @@ int read_item() {
|
|||
}
|
||||
}
|
||||
|
||||
int read_action() {
|
||||
return 0;
|
||||
int read_person() {
|
||||
char buf[128];
|
||||
int i;
|
||||
for (;;) {
|
||||
printf("p> ");
|
||||
if (fgets(buf, 128, stdin)) {
|
||||
for (i = 0; i < people_count; ++i) {
|
||||
if (!strncmp( buf, people[0], strlen(people[0]) )) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
printf("Unknown person %s\n", buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int i, a;
|
||||
int i, p;
|
||||
fill_items();
|
||||
for (;;) {
|
||||
i = read_item();
|
||||
a = read_action();
|
||||
p = read_person();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#define EAN_MAXLEN 32
|
||||
#define NAME_MAXLEN 128
|
||||
#define ITEM_MAXNUM 128
|
||||
#define PERSON_MAXLEN 16
|
||||
|
||||
#endif
|
||||
|
||||
|
|
5
people.txt
Normal file
5
people.txt
Normal file
|
@ -0,0 +1,5 @@
|
|||
biiter
|
||||
czestmyr
|
||||
niekt0
|
||||
stick
|
||||
tomsuch
|
Loading…
Add table
Add a link
Reference in a new issue