This file is indexed.

/usr/share/doc/libglyr-doc/examples/example.c is in libglyr-doc 1.0.9-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/***********************************************************
 * This file is part of glyr
 * + a command-line tool and library to download various sort of music related metadata.
 * + Copyright (C) [2011-2012]  [Christopher Pahl]
 * + Hosted at: https://github.com/sahib/glyr
 *
 * glyr is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * glyr is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with glyr. If not, see <http://www.gnu.org/licenses/>.
 **************************************************************/

/***********************************************************
* This is a brief example on how to use libglyr's interface
* This is not a complete documentation, rather a quickstart
* It uses nevertheless all important functions and for sure
* everything you will need to hack your own application...
*
* Compile with: gcc example.c -o example -lglyr
************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/* Usually only this needs to be included */
#include "../../lib/glyr.h"


static void print_item (GlyrMemCache * cacheditem, int num)
{
    fprintf (stderr,"\n------- ITEM #%d --------\n",num);
    glyr_cache_print (cacheditem);
    fprintf (stderr,"\n------------------------\n");
}

/////////////////////////////////

/* This is called whenever glyr gets a ready to use item */
static GLYR_ERROR funny_callback (GlyrMemCache * c, GlyrQuery * q)
{
    /* You can pass a void pointer to the callback,
     * by passing it as third argument to glyr_opt_dlcallback()
     */
    int * i = q->callback.user_pointer;

    if (*i == 1)
    {
        puts ("=> Gentlemen, we received an item.");
        puts ("=> We originally wanted more, but we decide to stop here.");
        puts ("=> Therefore we return GLYRE_STOP_PRE. Goodbye.");
        return GLYRE_STOP_PRE;
        /*
         * You can also return:
         * - GLYRE_STOP_POST which will stop libglyr, but still add the current item
         * - GLYRE_STOP_PRE  which will stop libglyr, but skip the current item
         * - GLYRE_SKIP which will cause libglyr not to add this item to the results
         */
    }
    *i = *i + 1;
    return GLYRE_OK;
}

/////////////////////////////////

int main (int argc, char * argv[])
{
    /* You need to call this before anything happens */
    glyr_init();
    atexit (glyr_cleanup);

    /* Initialize a new query (this may allocate memory) */
    GlyrQuery q;
    glyr_query_init (&q);

    /* Say we want a Songtext */
    GLYR_GET_TYPE type = GLYR_GET_LYRICS;
    glyr_opt_type (&q,type);

    /* Set at least the required fields to your needs        *
     * For lyrics those are 'artist' and 'title', ('album')  *
     * is strictly optional and may be used by a few plugins */
    glyr_opt_artist (&q, (char*) "Die Apokalyptischen Reiter");
    glyr_opt_album (&q, (char*) "Riders on the Storm");
    glyr_opt_title (&q, (char*) "Friede sei mit dir");

    /* Execute a func when getting one item */
    int this_be_my_counter = 0;
    glyr_opt_dlcallback (&q,funny_callback,&this_be_my_counter);

    /* For the start: Enable verbosity */
    glyr_opt_verbosity (&q,2);

    /* Download 5 (or less) items */
    glyr_opt_number (&q,5);

    /* Just search, without downloading items */
    glyr_opt_download (&q,0);

    /* Call the most important command: GET!
     * This returned a list of (GlyrMemCache *)s
     * Each containing ONE item. (i.e. a songtext)
     */
    GLYR_ERROR err;
    GlyrMemCache * it = glyr_get (&q,&err,NULL);

    if (err != GLYRE_OK)
        fprintf (stderr,"E:%s\n",glyr_strerror (err) );

    /* Now iterate through it... */
    if (it != NULL)
    {
        GlyrMemCache * start = it;

        int counter = 0;
        while (it != NULL)
        {
            /* This has the same effect as in the callback,
             * Just that it's executed just once after all DL is done.
             * Commented out, as this would print it twice
             * */
            print_item (it,counter);

            /* Every cache has a link to the next and prev one (or NULL respectively) */
            it = it->next;
            ++counter;
        }

        /* The contents of it are dynamically allocated. */
        /* So better free them if you're not keen on memoryleaks */
        glyr_free_list (start);
    }
    /* Destroy query (reset to default values and free dyn memory) */
    /* You could start right off to use this query in another glyr_get */
    glyr_query_destroy (&q);
    return EXIT_SUCCESS;
}