MCPcopy Create free account
hub / github.com/apache/httpd / find_title

Function find_title

modules/generators/mod_autoindex.c:1194–1247  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1192
1193
1194static char *find_title(request_rec *r)
1195{
1196 char titlebuf[MAX_STRING_LEN], *find = "<title>";
1197 apr_file_t *thefile = NULL;
1198 int x, y, p;
1199 apr_size_t n;
1200
1201 if (r->status != HTTP_OK) {
1202 return NULL;
1203 }
1204 if ((r->content_type != NULL)
1205 && (response_is_html(r)
1206 || !strcmp(r->content_type, INCLUDES_MAGIC_TYPE))
1207 && !r->content_encoding) {
1208 if (apr_file_open(&thefile, r->filename, APR_READ,
1209 APR_OS_DEFAULT, r->pool) != APR_SUCCESS) {
1210 return NULL;
1211 }
1212 n = sizeof(char) * (MAX_STRING_LEN - 1);
1213 apr_file_read(thefile, titlebuf, &n);
1214 if (n == 0) {
1215 apr_file_close(thefile);
1216 return NULL;
1217 }
1218 titlebuf[n] = '\0';
1219 for (x = 0, p = 0; titlebuf[x]; x++) {
1220 if (apr_tolower(titlebuf[x]) == find[p]) {
1221 if (!find[++p]) {
1222 if ((p = ap_ind(&titlebuf[++x], '<')) != -1) {
1223 titlebuf[x + p] = '\0';
1224 }
1225 /* Scan for line breaks for Tanmoy's secretary */
1226 for (y = x; titlebuf[y]; y++) {
1227 if ((titlebuf[y] == CR) || (titlebuf[y] == LF)) {
1228 if (y == x) {
1229 x++;
1230 }
1231 else {
1232 titlebuf[y] = ' ';
1233 }
1234 }
1235 }
1236 apr_file_close(thefile);
1237 return apr_pstrdup(r->pool, &titlebuf[x]);
1238 }
1239 }
1240 else {
1241 p = 0;
1242 }
1243 }
1244 apr_file_close(thefile);
1245 }
1246 return NULL;
1247}
1248
1249static struct ent *make_parent_entry(apr_int32_t autoindex_opts,
1250 autoindex_config_rec *d,

Callers 1

make_autoindex_entryFunction · 0.85

Calls 2

response_is_htmlFunction · 0.85
ap_indFunction · 0.85

Tested by

no test coverage detected