home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Media Share 9
/
MEDIASHARE_09.ISO
/
comm
/
ykh121.zip
/
YKHSRC.ZIP
/
UTILITY.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-18
|
853b
|
45 lines
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "utility.h"
void GetPrivateProfileString(char* head, char* value, char* def, char* dest, int length, char* filename)
{
FILE* infile;
char t[80];
char* s;
infile=fopen(filename,"r");
if (infile==NULL) return;
while (fgets(t,80,infile)!=NULL)
if (
(t[0]=='[') &&
strstr(t,head)==t+1 &&
t[strlen(head)+1]==']'
)
while (fgets(t,80,infile)!=NULL)
if (strstr(t,value)==t)
{
s=t;
while (*s!='=' && *s!=0)
s++;
if (*s==0)
{
fclose(infile);
strncpy(dest,def,length);
return;
}
s++;
while (*s==32) s++;
while (strlen(s) && s[strlen(s)-1]<=32)
s[strlen(s)-1]=0;
fclose(infile);
strncpy(dest,s,length);
return;
}
fclose(infile);
strncpy(dest,def,length);
return;
}