| View previous topic :: View next topic |
| Author |
Message |
fr34k*
Joined: 31 Aug 2007 Posts: 17
|
Posted: Sat Sep 01, 2007 7:22 am Post subject: Include config.cfg |
|
|
Hi how can in include config.cfg in my prx file?
| Quote: | | #include config.cfg |
Is it right?
And what must stay in the config.cfg?
Must I use spezial commands in the config.cfg? _________________ SORRY FOR MY BAD ENGLISH!!!!! |
|
| Back to top |
|
 |
PSPJunkie
Joined: 23 Jan 2007 Posts: 14 Location: Jersey
|
Posted: Sat Sep 01, 2007 2:24 pm Post subject: |
|
|
Actually, I believe it is,
| Code: |
#USETHISCONFIGPLZ "config.cfg"
|
... |
|
| Back to top |
|
 |
fr34k*
Joined: 31 Aug 2007 Posts: 17
|
Posted: Sat Sep 01, 2007 10:01 pm Post subject: |
|
|
A very nice joke -.-
I search for the instruction! _________________ SORRY FOR MY BAD ENGLISH!!!!! |
|
| Back to top |
|
 |
Fanjita
Joined: 28 Sep 2005 Posts: 217
|
Posted: Sat Sep 01, 2007 10:13 pm Post subject: |
|
|
Assuming that you want the config to apply at run-time, rather than at compile-time, then you're going to need to write some code in your program to open the file, read it and parse it.
If you want to see some really crap code for doing this, then the PiKey source code contains some simple and small config reading code, but you can almost certainly find better on the internet. _________________ Got a v2.0-v2.80 firmware PSP? Download the eLoader here to run homebrew on it!
The PSP Homebrew Database needs you! |
|
| Back to top |
|
 |
Drajwer
Joined: 24 Aug 2007 Posts: 6
|
Posted: Sat Sep 01, 2007 11:43 pm Post subject: |
|
|
I wrote a simple INI parser for my MMO. Im sure you know how INI file looks, so here is the code:
(this parser skips comment lines too.)
| Code: |
void LoadConfig() {
FILE* f;
f=fopen("config.ini","r");
int i;
if (!f) {
printf("FAIL!\n");
}
else {
char line[100];
char l2[100];
char value[100];
while (!feof(f)) {
fgets(line,100,f);
char *tmp;
if (line[0] == '#')
continue;
if (line[0] == '[') {
tmp = strchr(line, ']');
if (!tmp)
continue;
*tmp = 0;
memset(l2,0,100);
strcat(l2,line+1);
continue;
}
if ((tmp = strchr(line, '='))) {
*tmp = 0;
tmp++;
memset(value,0,100);
strcat(value,tmp);
//l2 = SECTION
//line = ident
//value = value :)
if (strcmp(l2,"ACCOUNT") == 0) {
if (strcmp(line,"login")==0) { memset(cLoginData[0],0,20); strcat(cLoginData[0],value); }
if (strcmp(line,"password")==0) { memset(cLoginData[1],0,20); strcat(cLoginData[1],value); }
}
}
}
fclose(f);
printf("OK!\n");
value[i]=0;
cLoginData[0][strlen(cLoginData[0])-1]=0; //dunno why :)
cLoginData[1][strlen(cLoginData[1])-1]=0;
//printf("Login: %s Password: %s\n",cLoginData[0],cLoginData[1]);
}
}
|
|
|
| Back to top |
|
 |
fr34k*
Joined: 31 Aug 2007 Posts: 17
|
Posted: Sun Sep 02, 2007 12:16 am Post subject: |
|
|
that's it! Thank you to Fanjita and Drajwer! _________________ SORRY FOR MY BAD ENGLISH!!!!! |
|
| Back to top |
|
 |
Jim

Joined: 02 Jul 2005 Posts: 487 Location: Sydney
|
Posted: Sun Sep 02, 2007 2:24 pm Post subject: |
|
|
| Code: | | cLoginData[0][strlen(cLoginData[0])-1]=0; //dunno why :) |
Probably because of the \n or Windows line endings.
Jim _________________ http://www.dbfinteractive.com |
|
| Back to top |
|
 |
|