Пример #1
0
/*
 * Removes all JSockets that are not active during last timeout seconds
 */
guint32 j_poll_remove_timeout(JPoll * jp, guint64 timeout)
{
    guint64 now = (guint64) time(NULL);
    GList *ptr = jp->jsocks;
    guint32 count = 0;
    while (ptr) {
        JSocket *jsock = (JSocket *) ptr->data;
        GList *next = g_list_next(ptr);
        if (j_socket_active_time(jsock) + timeout < now) {
            GList *prev = ptr->prev;
            if (prev) {
                prev->next = next;
            } else {
                jp->jsocks = next;
            }
            if (next) {
                next->prev = prev;
            }
            j_socket_close(jsock);
            g_list_free1(ptr);
            jp->count--;
            count++;
        }
        ptr = next;
    }
    return count;
}
Пример #2
0
void
ags_audio_file_finalize(GObject *gobject)
{
  AgsAudioFile *audio_file;
  GList *list, *list_next;

  audio_file = AGS_AUDIO_FILE(gobject);

  /* AgsAudioSignal */
  list = audio_file->audio_signal;

  while(list != NULL){
    list_next = list->next;

    g_object_unref(G_OBJECT(list->data));
    g_list_free1(list);
    
    list = list_next;
  }

  /* file */
  g_object_unref(audio_file->playable);

  G_OBJECT_CLASS(ags_audio_file_parent_class)->finalize(gobject);
}
Пример #3
0
static void
gst_base_video_decoder_clear_timestamps (GstBaseVideoDecoder *
    base_video_decoder)
{
  GList *l;

  for (l = base_video_decoder->timestamps; l;
      l = base_video_decoder->timestamps) {
    g_slice_free (Timestamp, l->data);
    base_video_decoder->timestamps = l->next;
    g_list_free1 (l);
  }
}
Пример #4
0
/**
 * ags_list_free_and_unref_link:
 * @list: the #GList
 * 
 * Free list and unref data.
 *
 * Since: 0.3
 * Deprecated: Use g_list_free_full() with g_ojbect_unref() instead
 */
void
ags_list_free_and_unref_link(GList *list)
{
  GList *list_next;

  while(list != NULL){
    list_next = list->next;
   
    g_object_unref((GObject *) list->data);
    g_list_free1(list);

    list = list_next;
  }
}
Пример #5
0
/**
 * ags_list_free_and_free_link:
 * @list: the #GList
 * 
 * Free list and free data.
 *
 * Since: 0.3
 * Deprecated: Use g_list_free_full() with g_free() instead
 */
void
ags_list_free_and_free_link(GList *list)
{
  GList *list_next;

  while(list != NULL){
    list_next = list->next;
   
    g_free(list->data);
    g_list_free1(list);

    list = list_next;
  }
}
Пример #6
0
/*
 * Parses a file with an existing JParser.
 */
gboolean j_parse_more(JParser * p, const gchar * path, GError ** error)
{
    gboolean ret = FALSE;

    gchar *all = readall(path, error);
    if (all == NULL) {
        return ret;
    }
    guint i, len = strlen(all);

    JParserState state = J_STATE_NEW;
    guint line = 1;
    guint start = 0;
    gchar *dname = NULL;
    GList *groups = NULL;       /* stack */
    for (i = 0; i < len; i++) {
        gchar c = all[i];
        switch (state) {
        case J_STATE_COMMENT:
            if (j_isnewline(c)) {
                state = J_STATE_NEW;
                line++;
            }
            break;
        case J_STATE_NEW:
            if (j_iscomment(c)) {
                state = J_STATE_COMMENT;
            } else if (j_isnewline(c)) {
                /* skip empty line */
                line++;
            } else if (j_isalpha(c)) {
                state = J_STATE_DIRECTIVE_NAME;
                start = i;
            } else if (j_isgroup(c)) {
                state = J_STATE_GROUP;
            } else if (!j_isspace(c)) {
                fill_error(error,
                           "directive name must start with "
                           "ascii letter, at %s:%u", path, line);
                goto OUT;
            }
            break;
        case J_STATE_DIRECTIVE_NAME:
            if (j_iscomment(c) || j_isnewline(c)) {
                dname = g_strndup(all + start, i - start);
                if (groups == NULL && g_strcmp0(INCLUDE_CONF, dname) == 0) {
                    fill_error(error, "missing file path, at %s:%u", path,
                               line);
                    goto OUT;
                }
                JDirective *d = j_directive_alloc_take(dname, NULL);
                dname = NULL;
                if (groups == NULL) {
                    j_parser_append_directive(p, d);
                } else {
                    j_group_append_directive((JGroup *)
                                             groups->data, d);
                }
                if (j_iscomment(c)) {
                    state = J_STATE_COMMENT;
                } else {
                    state = J_STATE_NEW;
                    line++;
                }
            } else if (j_isspace(c)) {
                state = J_STATE_DIRECTIVE_NAME_END;
                dname = g_strndup(all + start, i - start);
            } else if (!j_isname(c)) {
                fill_error(error,
                           "directive name must only contain letters,"
                           " digits or underline, at %s:%u", path, line);
                goto OUT;

            }
            break;
        case J_STATE_DIRECTIVE_NAME_END:
            if (j_iscomment(c) || j_isnewline(c)) {
                if (groups == NULL && g_strcmp0(INCLUDE_CONF, dname) == 0) {
                    fill_error(error, "missing file path, at %s:%u", path,
                               line);
                    goto OUT;
                }
                JDirective *d = j_directive_alloc_take(dname, NULL);
                if (groups == NULL) {
                    j_parser_append_directive(p, d);
                } else {
                    j_group_append_directive((JGroup *)
                                             groups->data, d);
                }
                dname = NULL;
                if (j_iscomment(c)) {
                    state = J_STATE_COMMENT;
                } else {
                    state = J_STATE_NEW;
                    line++;
                }
            } else if (!j_isspace(c)) {
                state = J_STATE_DIRECTIVE_VALUE;
                start = i;
            }
            break;
        case J_STATE_DIRECTIVE_VALUE:
            if (j_iscomment(c) || j_isnewline(c)) {
                if (groups == NULL && g_strcmp0(INCLUDE_CONF, dname) == 0) {
                    gchar *path =
                        g_strstrip(g_strndup(all + start, i - start));
                    gboolean more = j_parse_more(p, path, error);
                    g_free(path);
                    if (!more) {
                        goto OUT;
                    }
                    g_free(dname);
                } else {
                    JDirective *d = j_directive_alloc_take(dname,
                                                           g_strndup(all +
                                                                     start,
                                                                     i -
                                                                     start));
                    if (groups == NULL) {
                        j_parser_append_directive(p, d);
                    } else {
                        j_group_append_directive((JGroup *)
                                                 groups->data, d);
                    }
                }
                dname = NULL;
                if (j_iscomment(c)) {
                    state = J_STATE_COMMENT;
                } else {
                    state = J_STATE_NEW;
                    line++;
                }
            }
            break;
        case J_STATE_GROUP:
            if (j_isgroupend(c)) {
                state = J_STATE_GROUP_END;
            } else if (j_isspace(c)) {
                state = J_STATE_GROUP_START;
            } else if (j_isalpha(c)) {
                state = J_STATE_GROUP_START_NAME;
                start = i;
            } else {
                fill_error(error, "unexpected character %c, at %s:%u", c,
                           path, line);
                goto OUT;
            }
            break;
        case J_STATE_GROUP_START:
            if (j_isalpha(c)) {
                state = J_STATE_GROUP_START_NAME;
                start = i;
            } else if (!j_isspace(c)) {
                fill_error(error, "unexpected character %c, at %s:%u", c,
                           path, line);
                goto OUT;
            }
            break;
        case J_STATE_GROUP_START_NAME:
            if (j_iscomment(c)) {
                fill_error(error,
                           "unexpected character %c in group name, at %s:%u",
                           c, path, line);
                goto OUT;
            } else if (j_isnewline(c)) {
                fill_error(error, "unexpected EOL at %s:%u", path, line);
                goto OUT;
            } else if (j_isclose(c)) {
                JGroup *g =
                    j_group_alloc_take(g_strndup(all + start, i - start),
                                       NULL);
                if (groups == NULL) {
                    g = j_parser_append_group(p, g);
                } else {
                    g = j_group_append_group((JGroup *)
                                             groups->data, g);
                }
                groups = g_list_prepend(groups, g);
                state = J_STATE_NEW;
            } else if (j_isspace(c)) {
                state = J_STATE_GROUP_START_NAME_END;
                dname = g_strndup(all + start, i - start);
            } else if (!j_isname(c)) {
                fill_error(error, "unexpected character %c, at %s:%u", c,
                           path, line);
                goto OUT;
            }
            break;
        case J_STATE_GROUP_START_NAME_END:
            if (j_iscomment(c)) {
                fill_error(error, "unexpected character %c, at %s:%u", c,
                           path, line);
                goto OUT;
            } else if (j_isnewline(c)) {
                fill_error(error, "unexpected EOL at %s:%u", path, line);
                goto OUT;
            } else if (j_isclose(c)) {
                JGroup *g = j_group_alloc_take(dname, NULL);
                if (groups == NULL) {
                    g = j_parser_append_group(p, g);
                } else {
                    g = j_group_append_group((JGroup *)
                                             groups->data, g);
                }
                groups = g_list_prepend(groups, g);
                dname = NULL;
                state = J_STATE_NEW;
            } else if (!j_isspace(c)) {
                state = J_STATE_GROUP_START_VALUE;
                start = i;
            }
            break;
        case J_STATE_GROUP_START_VALUE:
            if (j_iscomment(c)) {
                fill_error(error, "unexpected character %c at %s:%u", c,
                           path, line);
                goto OUT;
            } else if (j_isnewline(c)) {
                fill_error(error, "unexpected EOL at %s:%u", path, line);
                goto OUT;
            } else if (j_isclose(c)) {
                JGroup *g = j_group_alloc_take(dname,
                                               g_strndup(all + start,
                                                         i - start));
                if (groups == NULL) {
                    g = j_parser_append_group(p, g);
                } else {
                    g = j_group_append_group((JGroup *)
                                             groups->data, g);
                }
                groups = g_list_prepend(groups, g);
                dname = NULL;
                state = J_STATE_NEW;
            }
            break;
        case J_STATE_GROUP_END:
            if (j_isalpha(c)) {
                state = J_STATE_GROUP_END_NAME;
                start = i;
            } else if (!j_isspace(c)) {
                fill_error(error, "unexpected character %c at %s:%u",
                           path, line);
                goto OUT;
            }
            break;
        case J_STATE_GROUP_END_NAME:
            if (j_isspace(c)) {
                dname = g_strndup(all + start, i - start);
                state = J_STATE_GROUP_END_NAME_END;
            } else if (j_isclose(c)) {
                dname = g_strndup(all + start, i - start);
                if (groups) {
                    JGroup *g = (JGroup *) groups->data;
                    if (g_strcmp0(dname, j_group_get_name(g))) {
                        fill_error(error,
                                   "group name doesn't match, at %s, %u",
                                   path, line);
                        goto OUT;
                    }
                    GList *next = g_list_next(groups);
                    g_list_free1(groups);
                    groups = next;
                    g_free(dname);
                    dname = NULL;
                } else {
                    fill_error(error, "unexpected group end, at %s:%u",
                               path, line);
                    goto OUT;
                }
                state = J_STATE_NEW;
            } else if (!j_isname(c)) {
                fill_error(error,
                           "unexpected character %c in group name, at %s:%u",
                           c, path, line);
                goto OUT;
            }
            break;
        case J_STATE_GROUP_END_NAME_END:
            if (j_isclose(c)) {
                dname = g_strndup(all + start, i - start);
                if (groups) {
                    JGroup *g = (JGroup *) groups->data;
                    if (g_strcmp0(dname, j_group_get_name(g))) {
                        fill_error(error,
                                   "group name doesn't match, at %s, %u",
                                   path, line);
                        goto OUT;
                    }
                    GList *next = g_list_next(groups);
                    g_list_free1(groups);
                    groups = next;
                    g_free(dname);
                    dname = NULL;
                } else {
                    fill_error(error, "unexpected group end, at %s:%u",
                               path, line);
                    goto OUT;
                }
                state = J_STATE_NEW;
            } else if (!j_isspace(c)) {
                fill_error(error, "unexpected character %c, at %s:%u",
                           path, line);
                goto OUT;
            }
            break;
        }
    }
    if (state != J_STATE_NEW) {
        fill_error(error, "unexpected EOF at %s", path);
        goto OUT;
    } else if (groups != NULL) {
        fill_error(error, "missing group end at %s", path);
        goto OUT;
    }
    ret = TRUE;
  OUT:
    g_free(all);
    g_list_free(groups);
    g_free(dname);
    return ret;
}