Changeset - 1a7ea8a134dd
[Not reviewed]
default
0 1 0
ethanzonca - 16 years ago 2009-07-11 12:26:42

Added sample arg-catching code from getopt's ex., edit it so it does something...
1 file changed with 51 insertions and 0 deletions:
0 comments (0 inline, 0 general)
src/server/distrend.c
Show inline comments
 
@@ -29,12 +29,14 @@
 

	
 
#include "execio.h"
 
#include "options.h"
 
#include <confuse.h>
 
#include <stdio.h>
 
#include <malloc.h>
 
#include <unistd.h> /* getopt */
 

	
 

	
 
#define MAX_BLENDJOBS 100 // maximum number of stored jobs in memory, per job type (lux/blend). Eventually we can dump this data to disk, or atleast the remainder not in memory...
 

	
 
/* internally defined funcs */
 
void status_report_generator();
 

	
 
@@ -231,12 +233,61 @@ return your_frame; // your_frame is retu
 

	
 

	
 
/* ************************** Main ************************* */
 

	
 
int main(int argc, char *argv[])
 
{
 
//// Begin Getopt Sample
 
		   int aflag = 0;
 
	       int bflag = 0;
 
	       char *cvalue = NULL;
 
	       int index;
 
	       int c;
 

	
 
	       opterr = 0;
 

	
 
	       while ((c = getopt (argc, argv, "abc:")) != -1)
 
	         switch (c)
 
	           {
 
	           case 'a':
 
	             aflag = 1;
 
	             break;
 
	           case 'b':
 
	             bflag = 1;
 
	             break;
 
	           case 'c':
 
	             cvalue = optarg;
 
	             break;
 
	           case '?':
 
	             if (optopt == 'c')
 
	               fprintf (stderr, "Option -%c requires an argument.\n", optopt);
 
	             else if (isprint (optopt))
 
	               fprintf (stderr, "Unknown option `-%c'.\n", optopt);
 
	             else
 
	               fprintf (stderr,
 
	                        "Unknown option character `\\x%x'.\n",
 
	                        optopt);
 
	             return 1;
 
	           default:
 
	             abort ();
 
	           }
 

	
 
	       printf ("aflag = %d, bflag = %d, cvalue = %s\n",
 
	               aflag, bflag, cvalue);
 

	
 
	       for (index = optind; index < argc; index++)
 
	         printf ("Non-option argument %s\n", argv[index]);
 
//// End getopt sample
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 

	
 
// Begin non-working framework?
 
	int distrend_do_config(int argc, char *argv[], struct distrend_config *config)
 
	{
 
	  cfg_opt_t myopts_listen[] =
 
	    {
0 comments (0 inline, 0 general)