Hi folks,

I feel a little guilt coming here and only asking questions - hard for me to contribute to the community here much at the moment as I'm on a steep learning curve. A big thanks for all of the help I've had here so far. Hope you don't mind me asking further questions...

I'm building a set of functions which are intended to read a set of configuration data from a .conf text-based file into a structure. I want a "getConfDataFromFile" function to fill the configuration structure such that I can use it something like this:-

Code:
struct configurationOptions thisProcessConfig;
if ( getConfDataFromFile(&thisProcessConfig) ) {
 doYourThing();
} else {
 bail("Couldn't load configuration file");
}
So far I have the following piece of code. The getStringFromConf and getIntFromConf have been tested and appear to work succesfully. My problem is with the loadConfigurationOptionsFromFile function, which gives the following errors on compile attempt:-

Code:
includes/configuration.h:45: error: request for member ‘host’ in something not a structure or union
includes/configuration.h:46: error: request for member ‘host’ in something not a structure or union
includes/configuration.h:50: error: request for member ‘port’ in something not a structure or union
includes/configuration.h:51: error: request for member ‘port’ in something not a structure or union
... etc (they all fail).

This is the full code, with the function causing me a problem highlighted in red:-

Code:
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <string.h>

#include "defines.h"

/* A structure to hold all of our configuration data */
typedef struct  {
	char 	host[16];
	int		port;
	char	adminHost[16];
	int		adminPort;
	int		logLevel;
	int		selfConsumeMode;
	ushort	queueSize;
	char	pidFilePath[120];
	int		persistMessages;
} configurationOptions;


/* Load up config options from conf file to supplied structure */
int loadConfigurationOptions(struct configurationOptions *suppliedStructure) {
	 
	/* We need at least a host and port for the queue and for admins */
	if (!getStringFromConf("host", suppliedStructure.host, sizeof suppliedStructure.host)) {
		return(0);
	}
	
	suppliedStructure.port = getIntFromConf("port");
	if (suppliedStructure.port == 0) {
		return(0);
	}
	
	if (!getStringFromConf("adminhost", suppliedStructure.adminHost, sizeof suppliedStructure.adminHost)) {
		return(0);
	}
	
	suppliedStructure.adminPort = getIntFromConf("adminport");
	if (suppliedStructure.adminPort == 0) {
		return(0);
	}

	/* Anything missing from here on is non-critical and we'll use defaults if we can't load */
	suppliedStructure.logLevel = getIntFromConf("loglevel");
	if (suppliedStructure.logLevel == 0) {
		suppliedStructure.logLevel = LOG_LEVEL_DEFAULT;
	}

	/* Defaults to zero (off) if the int fails to load */
	suppliedStructure.selfConsumeMode = getIntFromConf("selfconsume");

	suppliedStructure.queueSize = getIntFromConf("queuesize");
	if (suppliedStructure.queueSize == 0) {
		suppliedStructure.queueSize = QUEUE_SIZE;
	}
	
	/* Maximum size of an IPC V queue is 65535 */
	if (suppliedStructure.queueSize > 65535) {
		suppliedStructure.queueSize = QUEUE_SIZE;
	}
	
	if ( !getStringFromConf("pidfilepath", suppliedStructure.pidFilePath, sizeof (suppliedStructure.pidFilePath-1)) ) {
		strcpy(suppliedStructure.pidFilePath, PID_FILE_PATH);
	}

	return(1);
}

int getStringFromConf(const char * searchkey, char *resultValue, size_t resultSize) {
	int result, i = 0;
	char c[120];
	FILE *f = NULL;
	f = fopen(CONF_FILE_PATH, "r");
	if (f != NULL)  {

		while ( fgets(c, 120, f) != NULL ) {
			char *sep = "=";
			char *key, *value = "";
			key = strtok(c, sep);
			value = strtok(NULL, sep);

			if ( (value != NULL) && (strcmp(key, searchkey) == 0) ) {
				if ( strlen(value) > resultSize-1 ) {
					result = 0;
					strncpy(resultValue, CONF_FILE_BUFFERSIZE_ERROR, resultSize);
				} else {
					strncpy(resultValue, value, resultSize);

					/* remove any newlines */
					for ( i = 0; i < 119; i++ ) {
					    if ( resultValue[i] == '\n' ) {
					        resultValue[i] = '\0';
        					break;
    					}
}
					result = 1;
				}
			}
		}

		fclose(f);

	} else {
		result = 0;
		strncpy(resultValue, CONF_FILE_NOTFOUND_ERROR, resultSize);
	}
	return result;
}

/* Only to be used to fetch positive ints */
int getIntFromConf(const char * searchkey) {
	/* Returns either an positive integer value or -1 in event of error */
	char charValue[10];
	int j = -1;

	if ( getStringFromConf(searchkey, charValue, 9) ) {
		j = atoi(charValue);
	}
	return j;
}
Full code posted for completeness, although I have a feeling that my problem lies in the way that I'm trying to reference the supplied structure by pointer.

Any shove in the right direction would be much appreciated......