Listing 5. These two functions write preference
data to a file, traversing a GList to get
category information.

code:
void
XRUSavePrefs()
{
   ...

   /* Write the preferences to it. */
   fprintf(fd, "hostname:%s\n", prefs.hostname);
   if ( prefs.daemondir )
      fprintf(fd, "daemondir:%s\n",prefs.daemondir);
   else
      fprintf(fd, "daemondir:\n");
   fprintf(fd, "favorites:%d\n",
      (int)prefs.enable_favorites);
   fprintf(fd, "channels:%d\n",
      (int)prefs.channel_windows);
   fprintf(fd, "performance:%d\n",
      prefs.performance);

   /* Run the list of categories and save them
    * and their states
    */


   g_list_foreach(prefs.categories,
      SavePrefsCategory, fd);

   ...
}

static void
SavePrefsCategory(
   CatEntryT   *catentry,
   FILE        *fd
)
{
   fprintf(fd, "category:%s:%d\n", catentry->name,
      catentry->state);
}

