1  /* Test ambiguous forward lookups post-deduplication.
       2  
       3     This also makes sure that deduplication succeeds in this case and does not
       4     throw spurious errors.  */
       5  
       6  #include <ctf-api.h>
       7  #include <stdio.h>
       8  #include <stdlib.h>
       9  
      10  int
      11  main (int argc, char *argv[])
      12  {
      13    ctf_dict_t *fp;
      14    ctf_archive_t *ctf;
      15    ctf_id_t type;
      16    ctf_arinfo_t ar;
      17    int err;
      18  
      19    if (argc != 2)
      20      {
      21        fprintf (stderr, "Syntax: %s PROGRAM\n", argv[0]);
      22        exit(1);
      23      }
      24  
      25    if ((ctf = ctf_open (argv[1], NULL, &err)) == NULL)
      26      goto open_err;
      27    if ((fp = ctf_dict_open (ctf, NULL, &err)) == NULL)
      28      goto open_err;
      29  
      30    /* Dig out the array type and resolve its element type.  */
      31  
      32    if ((type = ctf_lookup_by_name (fp, "a_array") ) == CTF_ERR)
      33      goto err;
      34    if ((type = ctf_type_resolve (fp, type)) == CTF_ERR)
      35      goto err;
      36    if (ctf_array_info (fp, type, &ar) < 0)
      37      goto err;
      38    printf ("Kind of array element is %i\n", ctf_type_kind (fp, ar.ctr_contents));
      39  
      40    ctf_dict_close (fp);
      41    ctf_close (ctf);
      42  
      43    return 0;
      44  
      45   open_err:
      46    fprintf (stderr, "%s: cannot open: %s\n", argv[0], ctf_errmsg (err));
      47    return 1;
      48   err:
      49    fprintf (stderr, "Lookup failed: %s\n", ctf_errmsg (ctf_errno (fp)));
      50    return 1;
      51  }