Changeset - dcf2a2b217f1
[Not reviewed]
default
0 2 0
Nathan Brink (binki) - 16 years ago 2009-04-07 22:17:55
ohnobinki@ohnopublishing.net
common/options: API improvements
2 files changed with 8 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/common/options.c
Show inline comments
 
@@ -20,13 +20,13 @@
 
#include "options.h"
 

	
 
#include <confuse.h>
 
#include <string.h>
 
#include <stdio.h>
 

	
 
int options_init(int argc, char *argv[], cfg_t **mycfg, struct options_common **allopts)
 
int options_init(int argc, char *argv[], cfg_t **mycfg, cfg_opt_t *myopts, const char *myname, struct options_common **allopts)
 
{
 
  char *configfile;
 
  
 
  configfile = strdup(SYSCONFDIR "/distren.conf");
 
  if(!configfile)
 
    {
src/common/options.h
Show inline comments
 
@@ -24,34 +24,37 @@
 

	
 
#ifndef _DISTREN_OPTIONS_H
 
#define _DISTREN_OPTIONS_H
 

	
 
#include <confuse.h>
 

	
 
/*
 
/**
 
  incomplete:
 
  maybe remoteio.h should define its own struct which is injected into this struct and have its own handlers that parse its section of the confuse config file... (it'd be more modular)?
 
 */
 
struct options_common
 
{
 
  char *remoteio_rsh;
 
  char *remoteio_user;
 
  struct remoteio_opts *remoteio;
 
  struct client_opts *client;
 
  struct daemon_opts *daemon;
 
};
 

	
 
/**
 
  This function needs to eat some of your arguments to it, just like gtk+ and other libs like to. It particularly needs to be able to find the location of the config file, which should be taken from arguments if it's there. The argument list will have members that I recognize removed.
 
  
 
  Options should be kept alive during the program's life.
 
  
 
  \param mycfg will be set to the section of the configuration file specific to the caller (client or server specific section)
 
  \param myopts holds the caller's confuse option declarations
 
  \param myname holds the name of the section of the config file that refers to mycfg and myopts
 

	
 
  \param allopts will be set to a pointer that many functions need for operation
 
  \param argc the argc that was passed to main()
 
  \param argv the argv that was passed to main()
 
 */
 
int options_init(int argc, char *argv[], cfg_t **mycfg, struct options_common **allopts);
 
int options_init(int argc, char *argv[], cfg_t **mycfg, cfg_opt_t *myopts, const char *myname, struct options_common **allopts);
 

	
 
/**
 
   Frees the struct options_common. This should be run before the program exits.
 
 */
 
int options_free(struct options_common *allopts);
 
#endif
0 comments (0 inline, 0 general)