-
Notifications
You must be signed in to change notification settings - Fork 1
/
database.c
76 lines (56 loc) · 1.68 KB
/
database.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
Author: Mike Bok
Email: freaknigh@hotmail.com
Website: www.nighsoft.net
License and Rights: Full licensing and Rights available at www.nighsoft.net.
If licensing and rights not available at www.nighsoft.net, then all the following apply as bulleted:
-all rights reserved.
-you can not modify source code in this file.
-you can compile and use this source code.
*/
#include "main.h"
void read_host_info()
{
FILE *ifp; //declare file pointer, its just how this stuff works
char cur_line[1024] = "", temp_str[3][21];
int i = 0; //use this as the length of the line read
ifp = fopen("host.txt","r"); //setup this declared file to open user.db to read from
if (!ifp) //if the file doesnt exist, then create it. and setup standard locations
{
strcpy(game.hub_address,"hestia.nighsoft.net");
write_host_info();
ifp = fopen("host.txt","r");
}
fscanf(ifp,"%50s",game.hub_address);
fclose(ifp);
}
void write_host_info()
{
FILE *ofp;
ofp = fopen("host.txt","w");
fprintf(ofp, "%s", game.hub_address);
fclose(ofp);
}
void read_config_info()
{
FILE *ifp; //declare file pointer, its just how this stuff works
char cur_line[1024] = "", temp_str[3][21];
int i = 0; //use this as the length of the line read
ifp = fopen("config.txt","r"); //setup this declared file to open user.db to read from
if (!ifp) //if the file doesnt exist, then create it. and setup standard locations
{
game.sound_on = 1;
game.engine_on = 1;
write_host_info();
return;
}
fscanf(ifp,"%d %d", &(game.sound_on), &(game.engine_on));
fclose(ifp);
}
void write_config_info()
{
FILE *ofp;
ofp = fopen("config.txt","w");
fprintf(ofp, "%d %d", game.sound_on, game.engine_on);
fclose(ofp);
}