<?xml version="1.0" encoding="UTF-8"?>
<collection>

<spec_type>
  <kind> common_env </kind>
  <global_code>
    static int aVal = 141421;
    static unsigned int aFlag = 0x8aceU;

    static short aShort = (short)4523;
    static int aInt = 271828;
    static long aLong = 738905609L;
    static long long aLongLong = 738905609LL;
    static float aFloat = 3.1415926535;
    static double aDouble = 9.86960440108935861883;
    static const char ** aArgv = NULL;

    static struct poptOption optionsTable[] = {
      { "val", '\0', POPT_ARG_VAL | POPT_ARGFLAG_SHOW_DEFAULT, &aVal, 125992,
    	"POPT_ARG_VAL: 125992 141421", 0},
      { "int", 'i', POPT_ARG_INT | POPT_ARGFLAG_SHOW_DEFAULT, &aInt, 0,
    	"POPT_ARG_INT: 271828", NULL },
      { "short", 's', POPT_ARG_SHORT | POPT_ARGFLAG_SHOW_DEFAULT, &aShort, 0,
    	"POPT_ARG_SHORT: 4523", NULL },
      { "long", 'l', POPT_ARG_LONG | POPT_ARGFLAG_SHOW_DEFAULT, &aLong, 0,
    	"POPT_ARG_LONG: 738905609", NULL },
      { "longlong", 'L', POPT_ARG_LONGLONG | POPT_ARGFLAG_SHOW_DEFAULT, &aLongLong, 0,
    	"POPT_ARG_LONGLONG: 738905609", NULL },
      { "float", 'f', POPT_ARG_FLOAT | POPT_ARGFLAG_SHOW_DEFAULT, &aFloat, 0,
    	"POPT_ARG_FLOAT: 3.14159", NULL },
      { "double", 'd', POPT_ARG_DOUBLE | POPT_ARGFLAG_SHOW_DEFAULT, &aDouble, 0,
    	"POPT_ARG_DOUBLE: 9.8696", NULL },
      { "argv", '\0', POPT_ARG_ARGV, &aArgv, 0,
    	"POPT_ARG_ARGV: append string to argv array (can be used multiple times)","STRING"},
      POPT_AUTOALIAS
      POPT_AUTOHELP
      POPT_TABLEEND
    };
  </global_code>
</spec_type>

<spec_type>
  <kind> common_param </kind>
  <data_type> poptContext </data_type>
  <value> poptGetContext(argv[0], argc, argv, optionsTable, 0) </value>
  <final_code>
    $0 = poptFreeContext($0);
  </final_code>
  <associating>
    <except>
      poptAddItem	<!-- FIXME -->
    </except>
  </associating>
</spec_type>
<spec_type>
  <kind> normal </kind>
  <data_type> poptContext </data_type>
  <value> poptGetContext(argv[0], argc, argv, optionsTable, 0) </value>
  <associating>
    <interfaces>
      poptFreeContext
      poptFini
    </interfaces>
    <links> param1 </links>
  </associating>
</spec_type>
<spec_type>
  <kind> normal </kind>
  <data_type> poptItem </data_type>
  <value> NULL </value>
  <global_code>
    #include <malloc.h>
  </global_code>
  <init_code>
    $0 = calloc(1, sizeof(*$0));
    $0->option = *poptHelpOptionsI18N;
    $0->argc = 1;
    $0->argv = calloc(2, sizeof(*$0->argv));
    $0->argv[0] = strdup("arg1");
  </init_code>
  <associating>
    <interfaces> poptAddItem </interfaces>
    <links> param2 </links>
  </associating>
</spec_type>

<spec_type>
  <kind> common_param </kind>
  <data_type> struct poptAlias </data_type>
  <value> _alias </value>
  <global_code>
    #include <malloc.h>
    static struct poptAlias _alias = {
      .longName = "longName",
      .shortName = 'l',
      .argc = 0,
      .argv = NULL
    };
  </global_code>
  <init_code>
    $0.argc = 1;
    $0.argv = calloc($0.argc + 1, sizeof(*$0.argv));
    $0.argv[0] = strdup("arg1");
  </init_code>
</spec_type>

<spec_type>
  <kind> common_param </kind>
  <name> poptBits </name>
  <data_type> poptBits </data_type>
  <value>
    create_poptBits()
  </value>
  <global_code>
    poptBits create_poptBits()
    {
	poptBits a = NULL;
	(void) poptSaveBits(&a, 0, "foo");
	(void) poptSaveBits(&a, 0, "bar");
	(void) poptSaveBits(&a, 0, "baz");
	return a;
    }
  </global_code>
</spec_type>

<spec_type>
  <kind> normal </kind>
  <data_type> const char *** </data_type>
  <value> &av </value>
  <global_code>
    #include <malloc.h>
  </global_code>
  <init_code>
    const char ** av = NULL;
  </init_code>
  <final_code>
    free(av[0]);
    free(av);
  </final_code>
  <associating>
    <interfaces> poptSaveString </interfaces>
    <links> param1 </links>
  </associating>
</spec_type>

</collection>

