#define OPT_ALL			0
#define OPT_HELP		1
#define OPT_ARTICLES		2
#define OPT_COUNT		3

#define TEMPLATE		"ALL/S,HELP/S,A=ARTICLES/M"

#include "NPNS.h"

int CommandContents( int *all, char ***CToSend )

{

  int i;
  int cnum_to_send = 0;

  char **articles;
  long opts[OPT_COUNT];
  struct RDArgs *rdargs;

  memset( (char *)opts, 0, sizeof(opts) );

  if ( rdargs = ReadArgs( TEMPLATE, opts, NULL ) ) {

	if ( opts[OPT_HELP] ) {

		Printf( " \nUsage: sendnews %s\n\n", TEMPLATE );

		Printf( " ALL\t\t-\tPost articles specified on command line AND spooled articles\n" );
		Printf( " HELP\t\t-\tPrint this help message\n" );
		Printf( " A=ARTICLES\t-\tFilenames of articles to post\n" );
		Printf( " ?\t\t-\tTo get template for sendnews\n\n" );

		Printf( " If no options are supplied then spooled articles will be sent\n\n" );

		Printf( " If files specified on command line then spooled articles will\n" );
		Printf( " not be sent unless ALL option is specified\n\n" );

		Printf( " Spooled articles will now be sent ....\n\n" );
		 
	} else {

		*all = opts[OPT_ALL] ? TRUE : FALSE;

		if ( articles = (char **)opts[OPT_ARTICLES] ) {

			for ( i = 0; articles[i]; i++ ) {};
			cnum_to_send = i;

			(*CToSend) = (char **)AllocMem( ((long)cnum_to_send * sizeof(char *)), MEMF_ANY );
			for ( i = 0; i < cnum_to_send; i++ )
				(*CToSend)[i] = (char *)AllocMem( (NAME_SIZE * sizeof(char)), MEMF_ANY );
	
			articles = (char **)opts[OPT_ARTICLES];
			for ( i = 0; i < cnum_to_send; i++ )	
				strcpy( (*CToSend)[i], articles[i] );

		}   /* if articles */

	}   /* if */

	FreeArgs( rdargs );

  } else {

	PrintFault( IoErr(), NULL );

  }  /* if args */

  return cnum_to_send;

}   /* CommandContents */
