<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: gtk code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Mon, 06 Oct 2008 14:57:54 GMT</pubDate>
    <description>DZone Snippets: gtk code</description>
    <item>
      <title>Put mounted drives list into Glist</title>
      <link>http://snippets.dzone.com/posts/show/5350</link>
      <description>Function that gets list of mounted drives from '/etc/fstab' and '/etc/mtab' files and puts data in the GList object (from GLib library) that can be further used in GTK.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;#include &lt;glib.h&gt;&lt;br /&gt;#include &lt;mntent.h&gt;&lt;br /&gt;#include &lt;string.h&gt;&lt;br /&gt;&lt;br /&gt;GList * g_get_drives_list(GList * g) {&lt;br /&gt;	FILE *fstab = NULL;&lt;br /&gt;	struct mntent *part = NULL;&lt;br /&gt;	gchar *mntp = NULL;&lt;br /&gt;	&lt;br /&gt;	if ((fstab = setmntent( "/etc/fstab", "r" )) != NULL) {&lt;br /&gt;		while ((part = getmntent(fstab))  != NULL) {&lt;br /&gt;			if((strcmp(part-&gt;mnt_type, "proc")) != 0 &amp;&amp; (strcmp(part-&gt;mnt_type, "devpts")) != 0 &lt;br /&gt;																					&amp;&amp; (strcmp(part-&gt;mnt_type, "swap")) != 0) {&lt;br /&gt;				mntp = g_strdup(part-&gt;mnt_dir);&lt;br /&gt;				g=g_list_append(g, mntp);&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;		endmntent(fstab);&lt;br /&gt;	}&lt;br /&gt;	&lt;br /&gt;	if ((fstab = setmntent( "/etc/mtab", "r")) != NULL) {&lt;br /&gt;		while ((part = getmntent(fstab)) != NULL) {&lt;br /&gt;			if (part-&gt;mnt_type != NULL) {&lt;br /&gt;				if((strcmp(part-&gt;mnt_type, "proc")) != 0 &amp;&amp; (strcmp(part-&gt;mnt_type, "devpts")) != 0&lt;br /&gt;						&amp;&amp; (strcmp(part-&gt;mnt_type, "swap")) != 0 &amp;&amp; (strcmp(part-&gt;mnt_type, "sysfs")) != 0&lt;br /&gt;						&amp;&amp; (strcmp(part-&gt;mnt_type, "tmpfs")) != 0 &amp;&amp; (strcmp(part-&gt;mnt_type, "fuseblk")) != 0&lt;br /&gt;						&amp;&amp; (strcmp(part-&gt;mnt_type, "securityfs")) != 0) {&lt;br /&gt;					if((g_list_find_custom(g, part-&gt;mnt_dir, (GCompareFunc)strcmp)) == 0) {&lt;br /&gt;						mntp=g_strdup(part-&gt;mnt_dir);&lt;br /&gt;						g=g_list_append(g, mntp);&lt;br /&gt;					}&lt;br /&gt;				}&lt;br /&gt;			}&lt;br /&gt;		}&lt;br /&gt;		endmntent(fstab);&lt;br /&gt;	}&lt;br /&gt;	return g;&lt;br /&gt;}&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sat, 12 Apr 2008 13:22:02 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5350</guid>
      <author>Tvrtko (Tvrtko)</author>
    </item>
  </channel>
</rss>
