コード例 #1
0
ファイル: yp.c プロジェクト: cmelendez/icecast-kh
static ypdata_t *create_yp_entry (const char *mount)
{
    ypdata_t *yp;
    char *s;

    yp = calloc (1, sizeof (ypdata_t));
    do
    {
        unsigned len = 512;
        int ret;
        char *url;
        mount_proxy *mountproxy = NULL;
        ice_config_t *config;

        if (yp == NULL)
            break;
        yp->mount = strdup (mount);
        yp->server_name = strdup ("");
        yp->server_desc = strdup ("");
        yp->server_genre = strdup ("");
        yp->bitrate = strdup ("");
        yp->server_type = strdup ("");
        yp->cluster_password = strdup ("");
        yp->url = strdup ("");
        yp->current_song = strdup ("");
        yp->audio_info = strdup ("");
        yp->subtype = strdup ("");
        yp->process = do_yp_add;

        url = malloc (len);
        if (url == NULL)
            break;
        config = config_get_config();
        ret = snprintf (url, len, "http://%s:%d%s", config->hostname, config->port, mount);
        if (ret >= (signed)len)
        {
            s = realloc (url, ++ret);
            if (s) url = s;
            snprintf (url, ret, "http://%s:%d%s", config->hostname, config->port, mount);
        }

        mountproxy = config_find_mount (config, mount);
        if (mountproxy && mountproxy->cluster_password)
            add_yp_info (yp, mountproxy->cluster_password, YP_CLUSTER_PASSWORD);
        config_release_config();

        yp->listen_url = util_url_escape (url);
        free (url);
        if (yp->listen_url == NULL)
            break;

        yp_schedule (yp, 0);
        return yp;
    } while (0);

    yp_destroy_ypdata (yp);
    return NULL;
}
コード例 #2
0
ファイル: yp.c プロジェクト: kitsune-dsu/kitsune-icecast
static void delete_marked_yp (struct yp_server *server)
{
    ypdata_t *yp = server->mounts, **prev = &server->mounts;

    while (yp)
    {
        if (yp->remove)
        {
            ypdata_t *to_go = yp;
            DEBUG2 ("removed %s from YP server %s", yp->mount, server->url);
            *prev = yp->next;
            yp = yp->next;
            yp_destroy_ypdata (to_go);
            continue;
        }
        prev = &yp->next;
        yp = yp->next;
    }
}
コード例 #3
0
ファイル: yp.c プロジェクト: miksago/icecast
static ypdata_t *create_yp_entry (source_t *source)
{
    ypdata_t *yp;
    char *s;

    if (source->running == 0 || source->yp_public == 0)
        return NULL;
    yp = calloc (1, sizeof (ypdata_t));
    do
    {
        unsigned len = 512;
        int ret;
        char *url;
        ice_config_t *config;

        if (yp == NULL)
            break;
        yp->mount = strdup (source->mount);
        yp->server_name = strdup ("");
        yp->server_desc = strdup ("");
        yp->server_genre = strdup ("");
        yp->bitrate = strdup ("");
        yp->server_desc = strdup ("");
        yp->server_type = strdup ("");
        yp->cluster_password = strdup ("");
        yp->url = strdup ("");
        yp->current_song = strdup ("");
        yp->audio_info = strdup ("");
        yp->process = do_yp_add;

        url = malloc (len);
        if (url == NULL)
            break;
        config = config_get_config();
        ret = snprintf (url, len, "http://%s:%d%s", config->hostname, config->port, source->mount);
        if (ret >= (signed)len)
        {
            s = realloc (url, ++ret);
            if (s) url = s;
            snprintf (url, ret, "http://%s:%d%s", config->hostname, config->port, source->mount);
        }
        config_release_config();
        yp->listen_url = util_url_escape (url);
        free (url);
        if (yp->listen_url == NULL)
            break;

        /* ice-* is icecast, icy-* is shoutcast */
        add_yp_info (yp, "server_type", source->format->format_description, YP_SERVER_TYPE);
        if ((s = httpp_getvar(source->parser, "ice-name"))) {
            add_yp_info (yp, "server_name", s, YP_SERVER_NAME);
        }
        if ((s = httpp_getvar(source->parser, "icy-name"))) {
            add_yp_info (yp, "server_name", s, YP_SERVER_NAME);
        }
        if ((s = httpp_getvar(source->parser, "ice-url"))) {
            add_yp_info(yp, "server_url", s, YP_SERVER_URL);
        }
        if ((s = httpp_getvar(source->parser, "icy-url"))) {
            add_yp_info(yp, "server_url", s, YP_SERVER_URL);
        }
        if ((s = httpp_getvar(source->parser, "ice-genre"))) {
            add_yp_info(yp, "genre", s, YP_SERVER_GENRE);
        }
        if ((s = httpp_getvar(source->parser, "icy-genre"))) {
            add_yp_info(yp, "genre", s, YP_SERVER_GENRE);
        }
        if ((s = httpp_getvar(source->parser, "ice-bitrate"))) {
            add_yp_info(yp, "bitrate", s, YP_BITRATE);
        }
        if ((s = httpp_getvar(source->parser, "icy-br"))) {
            add_yp_info(yp, "bitrate", s, YP_BITRATE);
        }
        if ((s = httpp_getvar(source->parser, "ice-description"))) {
            add_yp_info(yp, "server_description", s, YP_SERVER_DESC);
        }
        s = util_dict_urlencode (source->audio_info, '&');
        if (s)
            add_yp_info (yp, "audio_info", s, YP_AUDIO_INFO);
        free(s);
        return yp;
    } while (0);

    yp_destroy_ypdata (yp);
    return NULL;
}