This file is indexed.

/usr/include/mpd/parser.h is in libmpdclient-dev 2.11-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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* libmpdclient
   (c) 2003-2017 The Music Player Daemon Project
   This project's homepage is: http://www.musicpd.org

   Redistribution and use in source and binary forms, with or without
   modification, are permitted provided that the following conditions
   are met:

   - Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.

   - Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.

   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR
   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef LIBMPDCLIENT_PARSER_H
#define LIBMPDCLIENT_PARSER_H

#include <mpd/protocol.h>
#include <mpd/compiler.h>

#include <stdbool.h>

enum mpd_parser_result {
	/**
	 * Response line was not understood.
	 */
	MPD_PARSER_MALFORMED,

	/**
	 * MPD has returned "OK" or "list_OK" (check with
	 * mpd_parser_is_discrete()).
	 */
	MPD_PARSER_SUCCESS,

	/**
	 * MPD has returned "ACK" with an error code.  Call
	 * mpd_parser_get_server_error() to get the error code.
	 */
	MPD_PARSER_ERROR,

	/**
	 * MPD has returned a name-value pair.  Call
	 * mpd_parser_get_name() and mpd_parser_get_value().
	 */
	MPD_PARSER_PAIR,
};

/**
 * \struct mpd_parser
 *
 * This opaque object is a low-level parser for the MPD protocol.  You
 * feed it with input lines, and it provides parsed representations.
 */
struct mpd_parser;

#ifdef __cplusplus
extern "C" {
#endif

/**
 * Allocates a new mpd_parser object.  Returns NULL on error (out of
 * memory).
 */
mpd_malloc
struct mpd_parser *
mpd_parser_new(void);

/**
 * Frees a mpd_parser object.
 */
void
mpd_parser_free(struct mpd_parser *parser);

/**
 * Feeds a line (without the trailing newline character) received from
 * MPD / mpd_async_recv_line() into the parser.
 *
 * Note that the line parameter is writable, because the parser will
 * modify it.  The functions mpd_parser_get_name() and
 * mpd_parser_get_value() will return pointers inside this buffer.
 * This means that after passing the line to this function, you must
 * not modify or free it, until the name and value pointers are not
 * used anymore.
 *
 * @param parser the #mpd_parser object
 * @param line a line received from the MPD server
 * @return a result code indicating the type of line, or error
 */
enum mpd_parser_result
mpd_parser_feed(struct mpd_parser *parser, char *line);

/**
 * Call this when mpd_parser_feed() has returned #MPD_PARSER_SUCCESS
 * to find out whether this is an "OK" (false) or a "list_OK" (true)
 * response.
 *
 * @param parser the #mpd_parser object
 */
mpd_pure
bool
mpd_parser_is_discrete(const struct mpd_parser *parser);

/**
 * Call this when mpd_parser_feed() has returned #MPD_PARSER_ERROR to
 * obtain the reason for the error.
 *
 * @param parser the #mpd_parser object
 */
mpd_pure
enum mpd_server_error
mpd_parser_get_server_error(const struct mpd_parser *parser);

/**
 * On #MPD_PARSER_ERROR, this returns the number of the list command
 * which failed.  Don't call this outside of a command list.
 *
 * @param parser the #mpd_parser object
 */
mpd_pure
unsigned
mpd_parser_get_at(const struct mpd_parser *parser);

/**
 * On #MPD_PARSER_ERROR, this returns the human readable error message
 * returned by MPD (UTF-8).
 *
 * This returns a pointer into the line buffer passed to
 * mpd_parser_feed().  It is valid as long as the buffer is not
 * freed/modified.
 *
 * @param parser the #mpd_parser object
 */
mpd_pure
const char *
mpd_parser_get_message(const struct mpd_parser *parser);

/**
 * On #MPD_PARSER_PAIR, this returns the name.
 *
 * This returns a pointer into the line buffer passed to
 * mpd_parser_feed().  It is valid as long as the buffer is not
 * freed/modified.
 *
 * @param parser the #mpd_parser object
 */
mpd_pure
const char *
mpd_parser_get_name(const struct mpd_parser *parser);

/**
 * On #MPD_PARSER_PAIR, this returns the value.
 *
 * This returns a pointer into the line buffer passed to
 * mpd_parser_feed().  It is valid as long as the buffer is not
 * freed/modified.
 *
 * @param parser the #mpd_parser object
 */
mpd_pure
const char *
mpd_parser_get_value(const struct mpd_parser *parser);

#ifdef __cplusplus
}
#endif

#endif