]> 4ch.mooo.com Git - bakadb.git/commitdiff
so much shit to do!
authorVictoria Crenshaw <sparky4@drbulldong>
Fri, 14 Aug 2015 19:40:49 +0000 (14:40 -0500)
committerVictoria Crenshaw <sparky4@drbulldong>
Fri, 14 Aug 2015 19:40:49 +0000 (14:40 -0500)
modified:   bakadb.c
modified:   bakadb.h
new file:   done
new file:   price
new file:   wr

bakadb.c
bakadb.h
done [new file with mode: 0755]
price [new file with mode: 0755]
wr [new file with mode: 0755]

index ffdd913877746b05c8efa09602beb6993d8fc578..4b14bce3582c9c9f189205d078465b989ceb639d 100755 (executable)
--- a/bakadb.c
+++ b/bakadb.c
@@ -39,10 +39,13 @@ byte *bakapee = NULL;
 iword found_id=0;
 
 
-iword baka_id;              //work order numer
-byte baka_name[64];     //name of client
-byte baka_phone[64];     //name of client
-byte baka_address[64];     //name of client
+iword baka_id;              //work order number
+iword bakacust_id;              //customer id
+byte bakacust_lastname[64];     //name of client
+byte bakacust_firstname[64];     //name of client
+byte bakacust_phone[64];     //phopne number of client
+byte bakacust_address[64];     //address of client
+byte bakacust_zipcode[64];     //zipcode
 byte baka_desc[4096];     //Description of the problem
 time_t                         baka_date;
 byte baka_price;                       //price
@@ -54,17 +57,19 @@ word baka_done;                     //is it done?
 
 void bdwr(void)
 {
-       byte str[BAKAPEE], buff[BAKAPEE], st[24];
+       byte str[BAKAPEE], strc[BAKAPEE], buff[BAKAPEE], st[24];
        byte *pc = NULL;
        byte *p;
 
-       FILE *in = fopen ( "baka.db", "r+" );
-       FILE *out = NULL;
-       if(in == NULL)
+       FILE *inbaka = fopen ( BAKADB, "r+" );
+       FILE *outbaka = NULL;
+       FILE *incust = fopen ( CUSTDB, "r+" );
+       FILE *outcust = NULL;
+       if(inbaka == NULL)
        {
                newdb:
-               fclose(in);
-               out = fopen ( "baka.db", "w+" );
+               fclose(inbaka);
+               outbaka = fopen ( BAKADB, "w+" );
                printf("\nNew database being made ^^;\n");
                printf("Work order number: ");
                scanf("%ud\n", &baka_id);   // input~
@@ -72,36 +77,45 @@ void bdwr(void)
        }
        else
        {
-               fgets(buff, 1, in);
+               fgets(buff, 1, inbaka);
                if(buff==NULL)
                {
-                       unlink("baka.db");
+                       unlink(BAKADB);
                        goto newdb;
                }
-               while ( fgets ( buff, sizeof buff, in ) != NULL );
-               fclose(in);
+               while ( fgets ( buff, sizeof buff, inbaka) != NULL );
+               fclose(inbaka);
                pc = strtok(buff, SEPE);
                baka_id = atoi(pc);
                baka_id++;
-               out = fopen ( "baka.db", "a+" );
+               outbaka = fopen ( BAKADB, "a+" );
+               outcust = fopen ( CUSTDB, "a+" );
                //printf("      baka_id=%u\n", baka_id);
        }
        sprintf(st, "%u", baka_id);
        strcpy(str, st);
        strcat(str,SEPE);
 
-       printf("Client's name: ");
-       scanf("%s", &(baka_name));     // input~
+       strcpy(str, st);
+       strcat(strc,SEPE);
+
+       //input 1st and last~
+       printf("Client's name Last Name: ");
+       scanf("%s", &(bakacust_lastname));     // input~
+       printf("Client's name First Name: ");
+       scanf("%s", &(bakacust_firstname));     // input~
 
        //TODO make uppercased names
        found_id=0;
-       cmpstrfromdb(1);
+       cmpstrfromdb(1);        //++++update
 
-       strcat(str,baka_name);  strcat(str,SEPE);
+       strcat(str,bakacust_lastname);  strcat(str,SEPE);
+       strcat(str,bakacust_lastname);  strcat(str,SEPE);
+       strcat(str,bakacust_lastname);  strcat(str,SEPE);
        if(found_id==0)
        {
                printf("Client's Phone Number: ");
-               scanf("%s", &(baka_phone));     // input~
+               scanf("%s", &(bakacust_phone));     // input~
        }else getstrfromdb(2);
        strcat(str,baka_phone);  strcat(str,SEPE);
        if(found_id==0)
@@ -132,8 +146,8 @@ void bdwr(void)
        strcat(str,SEPE);
        strcat(str,"\n");
        //bdmksheet(&bddb);
-       fwrite(str, strlen(str), 1, out);
-       fclose(out);
+       fwrite(str, strlen(str), 1, outbaka);
+       fclose(outbaka);
        found_id=0;
        free(pc);
 }
@@ -144,7 +158,7 @@ void bddone(iword id)
        byte *p;
        siword eed;
 
-       FILE *in = fopen ( "baka.db", "r" );
+       FILE *in = fopen ( BAKADB, "r" );
        FILE *out = NULL;
        while ( fgets ( buff, sizeof buff, in ) != (NULL) )
        {
@@ -165,7 +179,7 @@ void bddone(iword id)
                }
        }
        fclose(in);
-       out = fopen ( "baka.db", "w+" );
+       out = fopen ( BAKADB, "w+" );
        fwrite(str, strlen(str), 1, out);
        fclose(out);
        free(p);
@@ -178,7 +192,7 @@ void bdchange(iword id, byte i, sword t)
        byte *p;
        siword eed;
 
-       FILE *in = fopen ( "baka.db", "r" );
+       FILE *in = fopen ( BAKADB, "r" );
        FILE *out = NULL;
        dbvar(t);
        found_id=id;
@@ -202,7 +216,7 @@ void bdchange(iword id, byte i, sword t)
                }
        }
        fclose(in);
-       out = fopen ( "baka.db", "w+" );
+       out = fopen ( BAKADB, "w+" );
        fwrite(str, strlen(str), 1, out);
        fclose(out);
        free(p);
@@ -280,7 +294,7 @@ void getstrfromdb(sword i)
 {
        byte buff[BAKAPEE];
        word q;
-       FILE *in = fopen ( "baka.db", "r+" );
+       FILE *in = fopen ( BAKADB, "r+" );
        if(found_id>0) dbvar(i);
        while ( fgets ( buff, sizeof buff, in ) != NULL )
        {
@@ -314,7 +328,7 @@ void cmpstrfromdb(word i)
        byte buff[BAKAPEE];
        byte pee[16];
        word q;
-       FILE *in = fopen ( "baka.db", "r+" );
+       FILE *in = fopen ( BAKADB, "r+" );
        dbvar(i);
        while ( fgets ( buff, sizeof buff, in ) != NULL )
        {
index 31bfbae3f0208ba350178be74a24115199ddd6e8..98e4e5222b5a1d90273200f47be3d7491596d36e 100755 (executable)
--- a/bakadb.h
+++ b/bakadb.h
@@ -20,6 +20,9 @@
  *
  */
 
+#ifndef __BAKADB_H__
+#define __BAKADB_H__
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <errno.h>
 #include <time.h>
 
-#ifndef __BAKADB_H__
-#define __BAKADB_H__
-
 #include "types.h"
 #include "bdb.h"
 
+#define CUSTDB "../../customer.db"
+#define BAKADB "baka.db"
+
 extern iword baka_id;              //work order numer
 extern byte baka_name[64];     //name of client
 extern byte baka_phone[64];     //name of client
diff --git a/done b/done
new file mode 100755 (executable)
index 0000000..7fed450
Binary files /dev/null and b/done differ
diff --git a/price b/price
new file mode 100755 (executable)
index 0000000..99ac5ca
Binary files /dev/null and b/price differ
diff --git a/wr b/wr
new file mode 100755 (executable)
index 0000000..8cffe25
Binary files /dev/null and b/wr differ