dt_Handle pattern, molecule, pathset, container;
  dt_Integer slen, pcount, acount, bocunt;
  dt_String str;

  /* Read SMARTS in. */
  pattern = dt_smartin(2, "Oa");

  /* Optimized for matches on typical molecules. */
  str = dt_smarts_opt(&slen, 2, "aO", 0);
  printf("The optimized SMARTS expression is %.*s.\n", slen, str);

  /* The aromatic oxygen pattern and hydroquinone have
    matching paths. */
  molecule = dt_smilin(12, "Oc1ccc(O)cc1");
  pathset = dt_match(pattern, molecule, 0);

  /* There are two oxygen-aromatic paths in hydroquinone. */
  pcount = dt_count(pathset, TYP_PATH);
  printf("There are %d oxygen-aromatic atom paths in hydroquinone.\n", pcount);

  /* The oxygen-aromatic path contains 2 atoms and 1 bond. */
  acount = dt_count(pathset, TYP_ATOM);
  bcount = dt_count(pathset, TYP_BOND);
  printf("The oxygen-aromatic path contains %d atoms and %d bond.\n",
      acount/pcount, bcount/pcount);

  /* The pathset refers to the molecule as its base. */
  if (dt_base(pathset) == molecule)
    printf("You can access the molecule through the pathset.\n");

  /* Stream the pathset. */
  container = dt_stream(pathset, TYP_PATH);
  /* The path stream refers to the pathset as its base. */
 
if (dt_base(container) == pathset)
   
printf("You can access the pathset through the stream.\n");

 
/* The molecules are not deallocated when
    the molecule stream is deallocated. */

 
dt_dealloc(container);
 
if (dt_invalid(path1) == 0)
   
printf("The path is not deallocated.\n");

 
/* The stream is deallocated when the molecule is deallocated */
 
container = dt_stream(pathset, TYP_PATH);
 
dt_dealloc(pathset);
 
if (dt_invalid(container) == 1)
   
printf("The container is deallocated.\n");

The optimized SMARTS expression is Oa.
There are 2 oxygen-aromatic atom paths in hydroquinone.
The oxygen-aromatic path contains 2 atoms and 1 bond.
You can access the molecule through the pathset.
You can access the pathset through the stream.
The path is not deallocated.
The container is deallocated.