(root)/
fontconfig-2.14.2/
test/
test-issue180.c
       1  /*
       2   * fontconfig/test/test-issue180.c
       3   *
       4   * Copyright © 2000 Keith Packard
       5   *
       6   * Permission to use, copy, modify, distribute, and sell this software and its
       7   * documentation for any purpose is hereby granted without fee, provided that
       8   * the above copyright notice appear in all copies and that both that
       9   * copyright notice and this permission notice appear in supporting
      10   * documentation, and that the name of the author(s) not be used in
      11   * advertising or publicity pertaining to distribution of the software without
      12   * specific, written prior permission.  The authors make no
      13   * representations about the suitability of this software for any purpose.  It
      14   * is provided "as is" without express or implied warranty.
      15   *
      16   * THE AUTHOR(S) DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
      17   * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
      18   * EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY SPECIAL, INDIRECT OR
      19   * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
      20   * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
      21   * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
      22   * PERFORMANCE OF THIS SOFTWARE.
      23   */
      24  #include <stdio.h>
      25  #include <stdlib.h>
      26  #include <fontconfig/fontconfig.h>
      27  
      28  int
      29  main (void)
      30  {
      31      const FcChar8 *doc = (const FcChar8 *) ""
      32  	"<fontconfig>\n"
      33  	"  <cachedir></cachedir>\n"
      34  	"</fontconfig>\n"
      35  	"";
      36      const FcChar8 *doc2 = (const FcChar8 *) ""
      37  	"<fontconfig>\n"
      38  	"  <cachedir prefix=\"xdg\"></cachedir>\n"
      39  	"</fontconfig>\n"
      40  	"";
      41      FcConfig *cfg = FcConfigCreate ();
      42      FcStrList *l;
      43      FcChar8 *p;
      44  
      45      if (!FcConfigParseAndLoadFromMemory (cfg, doc, FcTrue))
      46      {
      47  	fprintf (stderr, "Unable to load a config from memory.\n");
      48  	return 1;
      49      }
      50      l = FcConfigGetCacheDirs (cfg);
      51      if ((p = FcStrListNext (l)) != NULL)
      52      {
      53  	fprintf (stderr, "There was one or more cachedirs\n");
      54  	return 1;
      55      }
      56      FcStrListDone (l);
      57      FcConfigDestroy (cfg);
      58  
      59      cfg = FcConfigCreate ();
      60      if (!FcConfigParseAndLoadFromMemory (cfg, doc2, FcTrue))
      61      {
      62  	fprintf (stderr, "Unable to load a config from memory (with prefix).\n");
      63  	return 1;
      64      }
      65      l = FcConfigGetCacheDirs (cfg);
      66      if ((p = FcStrListNext (l)) != NULL)
      67      {
      68  	fprintf (stderr, "There was one or more cachedirs (with prefix)\n");
      69  	return 1;
      70      }
      71      FcStrListDone (l);
      72      FcConfigDestroy (cfg);
      73  
      74      return 0;
      75  }