View | Details | Raw Unified | Return to bug 53120
Collapse All | Expand All

(-)module-2.0/mbox_parse.c (-5 / +50 lines)
Lines 42-47 Link Here
42
#include "apr_date.h"
42
#include "apr_date.h"
43
#include "apr_lib.h"
43
#include "apr_lib.h"
44
44
45
#include <libgen.h>
46
45
#define OPEN_DBM(r, db, flags, suffix, temp, status) \
47
#define OPEN_DBM(r, db, flags, suffix, temp, status) \
46
    temp = apr_pstrcat(r->pool, r->filename, suffix, NULL); \
48
    temp = apr_pstrcat(r->pool, r->filename, suffix, NULL); \
47
    status = apr_dbm_open(&db, temp, flags, APR_OS_DEFAULT, r->pool );
49
    status = apr_dbm_open(&db, temp, flags, APR_OS_DEFAULT, r->pool );
Lines 1120-1134 static apr_table_t *fetch_first_headers(request_re Link Here
1120
    return table;
1122
    return table;
1121
}
1123
}
1122
1124
1123
char *mbox_get_list_post(request_rec *r, char *path)
1125
/* Returns contents of file generated by:
1126
     printf '%s@%s\n' > PATH/.listname
1127
   Returns pointer into static buffer */
1128
static char *read_listname(char *path, apr_pool_t *p)
1124
{
1129
{
1125
    apr_status_t rv;
1130
    apr_status_t rv;
1126
    char *fullpath;
1127
    apr_file_t *f;
1131
    apr_file_t *f;
1132
    static char buf[256];
1133
    apr_size_t nread;
1134
1135
    rv = apr_file_open(&f, 
1136
                       apr_pstrcat(p, path, "/.listname", (char*)NULL),
1137
                       APR_READ, APR_OS_DEFAULT, p);
1138
    if (rv != APR_SUCCESS) {
1139
        return NULL;
1140
    }
1141
1142
    rv = apr_file_read_full(f, buf, sizeof(buf) - 1, &nread);
1143
    if (rv != APR_EOF) {
1144
        return NULL;
1145
    }
1146
1147
    buf[nread] = '\0';
1148
    if (--nread >= 0 && buf[nread] == '\n') {
1149
        buf[nread] = '\0';
1150
    }
1151
    apr_file_close(f);
1152
1153
    return buf;
1154
}
1155
1156
static const char *get_list_post(request_rec *r, char *path, char *fullpath)
1157
{
1158
    apr_status_t rv;
1159
    apr_file_t *f;
1128
    apr_table_t *headers;
1160
    apr_table_t *headers;
1161
    const char *list_post;
1129
1162
1130
    fullpath = apr_pstrcat(r->pool, r->filename, path, NULL);
1131
1132
    rv = apr_file_open(&f, fullpath, APR_READ, APR_OS_DEFAULT, r->pool);
1163
    rv = apr_file_open(&f, fullpath, APR_READ, APR_OS_DEFAULT, r->pool);
1133
1164
1134
    if (rv != APR_SUCCESS) {
1165
    if (rv != APR_SUCCESS) {
Lines 1142-1150 static apr_table_t *fetch_first_headers(request_re Link Here
1142
1174
1143
    apr_file_close(f);
1175
    apr_file_close(f);
1144
1176
1145
    return apr_pstrdup(r->pool, apr_table_get(headers, "List-Post"));
1177
    return apr_table_get(headers, "List-Post");
1146
}
1178
}
1147
1179
1180
char *mbox_get_list_post(request_rec *r, char *path)
1181
{
1182
    char *fullpath = apr_pstrcat(r->pool, r->filename, path, NULL);
1183
    const char *list_post = get_list_post(r, path, fullpath);
1184
1185
    if (list_post != NULL) {
1186
        return apr_pstrdup(r->pool, list_post);
1187
    }
1188
    else {
1189
        list_post = read_listname(dirname(fullpath), r->pool);
1190
        return apr_pstrcat(r->pool, "<mailto:", list_post, ">", (char *)NULL);
1191
    }
1192
}
1193
1148
/**
1194
/**
1149
 * List of all C-T-E Types found on httpd-dev and FreeBSD-current:
1195
 * List of all C-T-E Types found on httpd-dev and FreeBSD-current:
1150
 *
1196
 *

Return to bug 53120