+static void parse_group(const gchar *buf, gulong len,
+ ObtDDParse *parse, gboolean *error)
+{
+ ObtDDParseGroup *g;
+ gchar *group;
+ gulong i;
+
+ /* get the group name */
+ group = g_strndup(buf+1, len-2);
+ for (i = 0; i < len-2; ++i)
+ if ((guchar)group[i] < 32 || (guchar)group[i] >= 127) {
+ /* valid ASCII only */
+ parse_error("Invalid character found", parse, NULL);
+ group[i] = '\0'; /* stopping before this character */
+ break;
+ }
+
+ /* make sure it's a new group */
+ g = g_hash_table_lookup(parse->group_hash, group);
+ if (g && g->seen) {
+ parse_error("Duplicate group found", parse, error);
+ g_free(group);
+ return;
+ }
+ /* if it's the first group, make sure it's named Desktop Entry */
+ else if (!parse->group && strcmp(group, "Desktop Entry") != 0)
+ {
+ parse_error("Incorrect group found, "
+ "expected [Desktop Entry]",
+ parse, error);
+ g_free(group);
+ return;
+ }
+ else {
+ if (!g) {
+ g = g_slice_new(ObtDDParseGroup);
+ g->name = group;
+ g->func = NULL;
+ g_hash_table_insert(parse->group_hash, group, g);
+ }
+ else
+ g_free(group);
+
+ g->seen = TRUE;
+ parse->group = g;
+ g_print("Found group %s\n", g->name);
+ }
+}
+