~ubuntu-branches/ubuntu/karmic/libapache2-mod-python/karmic-updates

« back to all changes in this revision

Viewing changes to src/hlist.c

  • Committer: Bazaar Package Importer
  • Author(s): Thom May
  • Date: 2004-09-06 20:27:57 UTC
  • Revision ID: james.westby@ubuntu.com-20040906202757-yzpyu1bcabgpjtiu
Tags: upstream-3.1.3
ImportĀ upstreamĀ versionĀ 3.1.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2004 Apache Software Foundation 
 
3
 * 
 
4
 * Licensed under the Apache License, Version 2.0 (the "License"); you
 
5
 * may not use this file except in compliance with the License.  You
 
6
 * may obtain a copy of the License at
 
7
 *
 
8
 *      http://www.apache.org/licenses/LICENSE-2.0
 
9
 *
 
10
 * Unless required by applicable law or agreed to in writing, software
 
11
 * distributed under the License is distributed on an "AS IS" BASIS,
 
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
 
13
 * implied.  See the License for the specific language governing
 
14
 * permissions and limitations under the License.
 
15
 *
 
16
 * Originally developed by Gregory Trubetskoy.
 
17
 *
 
18
 *
 
19
 * hlist.c 
 
20
 *
 
21
 * $Id: hlist.c,v 1.5 2004/02/16 19:47:27 grisha Exp $
 
22
 *
 
23
 * See accompanying documentation and source code comments 
 
24
 * for details.
 
25
 *
 
26
 */
 
27
 
 
28
#include "mod_python.h"
 
29
 
 
30
/**
 
31
 ** hlist_new
 
32
 **
 
33
 *  Start a new list.
 
34
 */
 
35
 
 
36
hl_entry *hlist_new(apr_pool_t *p, const char *h, const char *d, 
 
37
                    const int s)
 
38
{
 
39
    hl_entry *hle;
 
40
 
 
41
    hle = (hl_entry *)apr_pcalloc(p, sizeof(hl_entry));
 
42
 
 
43
    hle->handler = apr_pstrdup(p, h);
 
44
    hle->directory = apr_pstrdup(p, d);
 
45
    hle->silent = s;
 
46
 
 
47
    return hle;
 
48
}
 
49
 
 
50
/**
 
51
 ** hlist_append
 
52
 **
 
53
 *  Appends an hl_entry to a list identified by hle, 
 
54
 *  and returns the new tail. This func will skip
 
55
 *  to the tail of the list.
 
56
 *  If hle is NULL, a new list is created.
 
57
 */
 
58
 
 
59
hl_entry *hlist_append(apr_pool_t *p, hl_entry *hle, const char * h,
 
60
                       const char *d, const int s)
 
61
{
 
62
    hl_entry *nhle;
 
63
 
 
64
    /* find tail */
 
65
    while (hle && hle->next)
 
66
        hle = hle->next;
 
67
 
 
68
    nhle = (hl_entry *)apr_pcalloc(p, sizeof(hl_entry));
 
69
 
 
70
    nhle->handler = apr_pstrdup(p, h);
 
71
    nhle->directory = apr_pstrdup(p, d);
 
72
    nhle->silent = s;
 
73
 
 
74
    if (hle)
 
75
        hle->next = nhle;
 
76
 
 
77
    return nhle;
 
78
}
 
79
 
 
80
/**
 
81
 ** hlist_copy
 
82
 **
 
83
 */
 
84
 
 
85
hl_entry *hlist_copy(apr_pool_t *p, const hl_entry *hle)
 
86
{
 
87
    hl_entry *nhle;
 
88
    hl_entry *head;
 
89
 
 
90
    head = (hl_entry *)apr_pcalloc(p, sizeof(hl_entry));
 
91
    head->handler = apr_pstrdup(p, hle->handler);
 
92
    head->directory = apr_pstrdup(p, hle->directory);
 
93
    head->silent = hle->silent;
 
94
 
 
95
    hle = hle->next;
 
96
    nhle = head;
 
97
    while (hle) {
 
98
        nhle->next = (hl_entry *)apr_pcalloc(p, sizeof(hl_entry));
 
99
        nhle = nhle->next;
 
100
        nhle->handler = apr_pstrdup(p, hle->handler);
 
101
        nhle->directory = apr_pstrdup(p, hle->directory);
 
102
        nhle->silent = hle->silent;
 
103
        hle = hle->next;
 
104
    }
 
105
 
 
106
    return head;
 
107
}
 
108