How to make a config file?

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

How to make a config file?

Post by angelo »

Hello, guys. I've coded this EBOOT launcher however I want to make a config file for it so the the can allocate it's target:

Here's my function and what I use to run it:

Code: Select all

//Load_EBOOT Function 
       
      void Load_EBOOT(char *target) 
      {    
      struct SceKernelLoadExecVSHParam param; 
      memset(&param, 0, sizeof(param)); 
      param.key = "game"; 
      param.size = sizeof(param); 
      param.args = strlen(target)+1; 
      param.argp = target; 
      sctrlKernelLoadExecVSHMs2(target, &param);    
      } 

//EBOOT 1 
          
      if (isKeyPressed(KEY_1) && ctrl && alt){ 
      displayStatusText("Loading Application 1..."); 
      sceKernelDelayThread(3 * 1000 * 1000); 
      Load_EBOOT("ms0:/SEPlugins/piKey/Applications/App1/EBOOT.PBP"); 
        } 

I've come up with this so far:

Code: Select all

int Application_1 = 0; 
       
      // Read the config file 
      int cfg = configOpen("ms0:/SEPlugins/piKey/AppLaunchConfig.txt"); 
      if (cfg >= 0) 
      { 
      while (configRead(cfg, cfgtoken, cfgvalue)) 
      { 
      if (strcmp(cfgtoken, "Application 1") == 0) 
      { 
        Application_1 = (cfgvalue); 
      } 
         } 
            } 

       
      //EBOOT 1 
          
      if (isKeyPressed(KEY_1) && ctrl && alt){ 
      displayStatusText("Loading Application 1..."); 
      sceKernelDelayThread(3 * 1000 * 1000); 
      Load_EBOOT(Application_1); 
        } 

It gives the following errors:

Code: Select all

ctrlout.c:515: warning: assignment makes integer from pointer without a cast 
ctrlout.c:526: warning: passing argument 1 of 'Load_EBOOT' makes pointer from integer without a cast
I also have this in the config file:

Code: Select all

Application 1 = "ms0:/SEPlugins/piKey/Applications/App1/EBOOT.PBP" 
Any ideas please?

Anything is greatly appreciated!

Angelo
Insert_witty_name
Posts: 376
Joined: Wed May 10, 2006 11:31 pm

Post by Insert_witty_name »

See moonlight's config code in his 1.5 cfw proof of concept.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

The compiler output is useless since we don't know what lines correspond to the numbers, nor have some of the functions they refer to.
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

Code: Select all

int Application_1 = 0; 
        
      // Read the config file 
      int cfg = configOpen("ms0:/SEPlugins/piKey/AppLaunchConfig.txt"); 
      if (cfg >= 0) 
      { 
      while (configRead(cfg, cfgtoken, cfgvalue)) 
      { 
      if (strcmp(cfgtoken, "Application 1") == 0) 
      { 
        Application_1 = (cfgvalue); //LINE AFFECTED
      } 
         } 
            } 

        
      //EBOOT 1 
          
      if (isKeyPressed(KEY_1) && ctrl && alt){ 
      displayStatusText("Loading Application 1..."); 
      sceKernelDelayThread(3 * 1000 * 1000); 
      Load_EBOOT(Application_1);  //LINE AFFECTED
        }
After studying Dark_AleX's code, I still don't get it! Looks all very complex!

I need to do more researh and work so I get this!
Last edited by angelo on Sun Aug 10, 2008 5:54 am, edited 1 time in total.
User avatar
Raphael
Posts: 646
Joined: Tue Jan 17, 2006 4:54 pm
Location: Germany
Contact:

Post by Raphael »

int Application_1 = 0;
... this is supposed to be a char*, if anything at all.
<Don't push the river, it flows.>
http://wordpress.fx-world.org - my devblog
http://wiki.fx-world.org - VFPU documentation wiki

Alexander Berl
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

Ok... I tried that!

Code: Select all

      // Read the config file 
      int cfg = configOpen&#40;"ms0&#58;/SEPlugins/piKey/AppLaunchConfig.txt"&#41;; 
      if &#40;cfg >= 0&#41; 
      &#123; 
      while &#40;configRead&#40;cfg, cfgtoken, cfgvalue&#41;&#41; 
      &#123; 
      if &#40;strcmp&#40;cfgtoken, "Application 1"&#41; == 0&#41; 
      &#123; 
        Application_1 = &#40;cfgvalue&#41;; //LINE AFFECTED
      &#125; 
         &#125; 
            &#125; 

        
      //EBOOT 1 
          
      if &#40;isKeyPressed&#40;KEY_1&#41; && ctrl && alt&#41;&#123; 
      displayStatusText&#40;"Loading Application 1..."&#41;; 
      sceKernelDelayThread&#40;3 * 1000 * 1000&#41;; 
      Load_EBOOT&#40;Application_1&#41;;  //LINE AFFECTED
        &#125;
This time, no errors when compiling, but now my PSP just freezes when I try a boot a game.

Here's the config file:

Code: Select all

Application 1 = "ms0&#58;/SEPlugins/piKey/Applications/App1/EBOOT.PBP"
I'm confused as to what's going wrong...
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

Are you closing the config file? Might not be your problem, but it's certainly something you should be doing.

Also, cfgvalue is a char array. Is (cfgvalue) a char*? I'd be using &cfgvalue there.
angelo
Posts: 168
Joined: Wed Aug 29, 2007 9:34 pm

Post by angelo »

Smart thinking there J.F! Hey why don't you join the team?! XD Hehe!

I'll try it in the morning, it's nealry 12:00 am here and I'm typing on my Targus

Thanks guys! I'll let you all know how it goes!
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

angelo wrote:Smart thinking there J.F! Hey why don't you join the team?! XD Hehe!
<Arnold Voice>You very funny guy - that why I kill you last.</Arnold Voice>
User avatar
jean
Posts: 489
Joined: Sat Jan 05, 2008 2:44 am

Post by jean »

..........
i can hear voices from the past screaming "no noob question here"....then all turns black. But it's all envy since i didn't get invited to "THE TEAM", too.....omg,wtf....
Post Reply