/*   -*- coding: utf-8 -*-  */
/***********************************************************************
*
*               Module   : MediaWiki
*               Fichier  : MediaWikiImportCommand.c
*               Auteur   : Ducloy
*               Date     : Decembre 2016
*
************************************************************************
*
* Copyleft 2016 Jacques Ducloy 
* 
************************************************************************/

#include <getopt.h>
#include <stdio.h>     /* for printf */
#include <stdlib.h>    /* for exit */
#include "MediaWiki.h"

int main(int argc, char **argv)
{
  int cOption;
  char *command;
  char *pageName;
  char *user;

  user=getenv("USER");
  command=NULL;
  while((cOption=getopt(argc,argv,"c:p:u:"))!=EOF)
    {
      {switch (cOption)
	  {
	  case 'c':
	    command=optarg;
	    break;
	  case 'p':
	    pageName=optarg;
	    break;
	  case 'u':
	    user=optarg;
	    break;
	  }
      }
    }
  if (strcmp(command, "fileBegin")==0) MediaWikiExportFileBegin();
  else if (strcmp(command, "fileEnd")==0)  MediaWikiExportFileEnd();
  else if (strcmp(command, "pageBegin")==0)  MediaWikiExportPageBegin(pageName, user, NULL);
  else if (strcmp(command, "pageEnd")==0)  MediaWikiExportPageEnd();
  exit (EXIT_SUCCESS);
      
}
