home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 January
/
usenetsourcesnewsgroupsinfomagicjanuary1994.iso
/
sources
/
x
/
volume4
/
xgen
/
part03
/
parse_resources.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-06-29
|
2KB
|
88 lines
#include <stdio.h>
#include "application.h"
struct resource *parse_resources( fp1, shell_label, label)
FILE *fp1;
char *shell_label;
char *label;
{
char resource_value[1024];
char *temp;
struct resource *header,
*pres_resource,
*prev_resource;
int C ;
int count = 0;
/* start a linked list of the widget resources */
header = (struct resource *)malloc(sizeof(
struct resource));
strcpy( header->name, "label");
/*first resource is the label of the widget*/
header->value = ( char *)malloc(
(strlen(label) +1)*sizeof(char));
strcpy( header->value, label);
/* fprintf(stderr, "parsing object %s", header->value); */
/* initialize the linked list */
pres_resource = header;
prev_resource = header;
while(1)
{
get_symbol(fp1, &C) ;
/* if the option declaration is closed exit loop */
if (C == ';'|| C == '(')
{
ungetc(C, fp1);
break;
}
ungetc(C, fp1);
/* otherwise add a new data resource to the list */
pres_resource = (struct resource *)malloc(sizeof(
struct resource));
prev_resource->next = pres_resource;
/* read and resource name */
get_string(fp1, pres_resource->name, ':', STR_LEN) ;
/* fprintf(stderr,"parsing option %s\n", pres_resource->name);*/
temp = resource_value;
/* read colon */
get_symbol(fp1, &C) ;
if( C != ':' )
{
fprintf(stderr, "Syntax error in shell \"%s\" in object \"%s\" declaration\n",
shell_label, label);
exit(-1);
}
get_string(fp1, temp, ';', 1024) ;
pres_resource->value = ( char *)malloc(
(strlen( resource_value)+1) * sizeof(char));
strcpy(pres_resource->value, resource_value);
/* fprintf(stderr,"option val %s\n", pres_resource->value);*/
prev_resource = pres_resource;
}
/*close linked list*/
/* fprintf(stderr,"option val %s\n", pres_resource->value);*/
pres_resource->next = NULL;
return(header);
}