RC file Alternativen

Digital Recording
jan_x
Neugieriger
Neugieriger
Beiträge: 3
Registriert: Sonntag 11. Mai 2003, 10:25

RC file Alternativen

Beitrag von jan_x »

Hallo,

ich fände es prima, wenn die Config-Files systematisch gesucht würden:
erst lokal, dann im HOME und letztlich im /etc-Verzeichnis.
Als c++ analphabet habe ich folgendes gestrickt, nun auch für das mcrec.progs:

Code: Alles auswählen

56,57d55
< #define RCFILE        "mcrec.rc"
< #define MCFILE        "mcrec.progs"
642,643c640
<       if (((urlbufptr = strstr(urlbuffer, "\r\n\r\n")) == NULL)
<       &&  ((urlbufptr = strstr(urlbuffer, "\n\n")) == NULL))
---
>       if ((urlbufptr = strstr(urlbuffer, "\r\n\r\n")) == NULL)
669,681c666,667
<       char mcname[256];
<       strcpy(mcname,MCFILE);
<       if (stat(mcname, &mcstat) != 0)
<       {
<               strcpy(mcname,"/etc/");
<               strcat(mcname,MCFILE);
<               if (stat(mcname, &mcstat) != 0)
<               {
<                       logprintf("Programm file (mcrec.progs) not found!\n");
<                       exit(0);
<       }       }
<
<       if (((progfile = fopen(mcname, "r")) != NULL))
---
>       if ((stat("mcrec.progs", &mcstat) == 0) &&
>               ((progfile = fopen("mcrec.progs", "r")) != NULL))
705c691
<               logprintf("Cannot open mcrec.progs!\n");
---
>               logprintf("mcrec.progs not found!\n");
1308d1293
<       char rcname[256];
1310,1322c1295,1296
<       strcpy(rcname,RCFILE);
<       if (stat(rcname, &rcstat) != 0)
<       {
<               strcpy(rcname,getenv("HOME"));
<               strcat(rcname,"/.mcrecrc");
<               if (stat(rcname, &rcstat) != 0)
<               {
<                       strcpy(rcname,"/etc/");
<                       strcat(rcname,RCFILE);
<                       if (stat([color=red]rcname[/color], &rcstat) != 0)
<                       {
<                               return;
<       }   }   }
---
>       if (stat("mcrec.rc", &rcstat) != 0)
>               return;
1326c1300
<       if ((rcfile = fopen(rcname, "r")) != NULL)
---
>       if ((rcfile = fopen("mcrec.rc", "r")) != NULL)
Kann man das in künftige Releases einbauen?
Im übrigen ist das Programm prima, wenngleich
mein Proxy mir einigen Ärger bereitete.
Jan[/quote]