* emit a plain text file */
| 946 | * emit a plain text file |
| 947 | */ |
| 948 | static void do_emit_plain(request_rec *r, apr_file_t *f) |
| 949 | { |
| 950 | char buf[AP_IOBUFSIZE + 1]; |
| 951 | int ch; |
| 952 | apr_size_t i, c, n; |
| 953 | apr_status_t rv; |
| 954 | |
| 955 | ap_rputs("<pre>\n", r); |
| 956 | while (!apr_file_eof(f)) { |
| 957 | do { |
| 958 | n = sizeof(char) * AP_IOBUFSIZE; |
| 959 | rv = apr_file_read(f, buf, &n); |
| 960 | } while (APR_STATUS_IS_EINTR(rv)); |
| 961 | if (n == 0 || rv != APR_SUCCESS) { |
| 962 | /* ###: better error here? */ |
| 963 | break; |
| 964 | } |
| 965 | buf[n] = '\0'; |
| 966 | c = 0; |
| 967 | while (c < n) { |
| 968 | for (i = c; i < n; i++) { |
| 969 | if (buf[i] == '<' || buf[i] == '>' || buf[i] == '&') { |
| 970 | break; |
| 971 | } |
| 972 | } |
| 973 | ch = buf[i]; |
| 974 | buf[i] = '\0'; |
| 975 | ap_rputs(&buf[c], r); |
| 976 | if (ch == '<') { |
| 977 | ap_rputs("<", r); |
| 978 | } |
| 979 | else if (ch == '>') { |
| 980 | ap_rputs(">", r); |
| 981 | } |
| 982 | else if (ch == '&') { |
| 983 | ap_rputs("&", r); |
| 984 | } |
| 985 | c = i + 1; |
| 986 | } |
| 987 | } |
| 988 | ap_rputs("</pre>\n", r); |
| 989 | } |
| 990 | |
| 991 | /* |
| 992 | * Handle the preamble through the H1 tag line, inclusive. Locate |