mirror of
https://github.com/brmlab/brmbar.git
synced 2025-06-08 21:33:59 +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
|
brmbar.com
|
||||||
|
|
9
Makefile
9
Makefile
|
@ -1,11 +1,12 @@
|
||||||
CC=bcc
|
CC=bcc
|
||||||
CFLAGS=-Md -W
|
CFLAGS=-Md -W
|
||||||
|
|
||||||
brmbar.com: brmbar.c defines.h
|
all: brmbar.c defines.h
|
||||||
$(CC) $(CFLAGS) brmbar.c -o brmbar.com
|
gcc -Wall brmbar.c -o brmbar
|
||||||
|
bcc -Md -W brmbar.c -o brmbar.com
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f brmbar.com
|
rm -f brmbar.com brmbar
|
||||||
|
|
||||||
run:
|
dos:
|
||||||
dosbox brmbar.com
|
dosbox brmbar.com
|
||||||
|
|
41
brmbar.c
41
brmbar.c
|
@ -1,4 +1,5 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
#include "defines.h"
|
#include "defines.h"
|
||||||
|
|
||||||
struct item {
|
struct item {
|
||||||
|
@ -7,7 +8,10 @@ struct item {
|
||||||
int price;
|
int price;
|
||||||
} items[ITEM_MAXNUM];
|
} items[ITEM_MAXNUM];
|
||||||
|
|
||||||
|
char *people[PERSON_MAXLEN];
|
||||||
|
|
||||||
int items_count;
|
int items_count;
|
||||||
|
int people_count;
|
||||||
|
|
||||||
void fill_items()
|
void fill_items()
|
||||||
{
|
{
|
||||||
|
@ -15,7 +19,17 @@ void fill_items()
|
||||||
FILE *f = fopen("items.txt", "r");
|
FILE *f = fopen("items.txt", "r");
|
||||||
while (fgets(buf, 128, f)) {
|
while (fgets(buf, 128, f)) {
|
||||||
printf("%s\n", buf);
|
printf("%s\n", buf);
|
||||||
}
|
}
|
||||||
|
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);
|
fclose(f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,8 +39,8 @@ int read_item() {
|
||||||
for (;;) {
|
for (;;) {
|
||||||
printf("i> ");
|
printf("i> ");
|
||||||
if (fgets(buf, 128, stdin)) {
|
if (fgets(buf, 128, stdin)) {
|
||||||
for (i = 0; ; ++i) {
|
for (i = 0; i < items_count; ++i) {
|
||||||
if (!strncmp( buf, items[0].ean, strlen(items[0].ean) )) {
|
if (!strncmp( buf, items[i].ean, strlen(items[i].ean) )) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,18 +49,29 @@ int read_item() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int read_action() {
|
int read_person() {
|
||||||
return 0;
|
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 main()
|
||||||
{
|
{
|
||||||
int i, a;
|
int i, p;
|
||||||
fill_items();
|
fill_items();
|
||||||
for (;;) {
|
for (;;) {
|
||||||
i = read_item();
|
i = read_item();
|
||||||
a = read_action();
|
p = read_person();
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#define EAN_MAXLEN 32
|
#define EAN_MAXLEN 32
|
||||||
#define NAME_MAXLEN 128
|
#define NAME_MAXLEN 128
|
||||||
#define ITEM_MAXNUM 128
|
#define ITEM_MAXNUM 128
|
||||||
|
#define PERSON_MAXLEN 16
|
||||||
|
|
||||||
#endif
|
#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