Apache HTTPD
filesys.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You 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 implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "apr.h"
18#include "apr_arch_file_io.h"
19#include "apr_strings.h"
20#include "apr_lib.h"
21#include <ctype.h>
22
23/* OS/2 Exceptions:
24 *
25 * Note that trailing spaces and trailing periods are never recorded
26 * in the file system.
27 *
28 * Leading spaces and periods are accepted, however.
29 * The * ? < > codes all have wildcard side effects
30 * The " / \ : are exclusively component separator tokens
31 * The system doesn't accept | for any (known) purpose
32 * Oddly, \x7f _is_ acceptable ;)
33 */
34
35const char c_is_fnchar[256] =
36{/* Reject all ctrl codes... */
37 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
38 /* " * / : < > ? */
39 1,1,0,1,1,1,1,1,1,1,0,1,1,1,1,0, 1,1,1,1,1,1,1,1,1,1,0,1,0,1,0,0,
40 /* \ */
41 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
42 /* | */
43 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,0,1,1,1,
44 /* High bit codes are accepted */
45 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
46 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
47 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
48 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
49};
50
51
52#define IS_SLASH(c) (c == '/' || c == '\\')
53
54
56{
57 char drive = apr_toupper(path[0]);
58
59 if (drive >= 'A' && drive <= 'Z' && path[1] == ':' && IS_SLASH(path[2]))
60 return APR_SUCCESS;
61
62 return APR_EBADPATH;
63}
64
65
68{
69 char path[APR_PATH_MAX];
70 char *pos;
71 ULONG rc;
72 ULONG bufsize = sizeof(path) - 3;
73
74 path[0] = drive;
75 path[1] = ':';
76 path[2] = '/';
77
79
80 if (rc) {
81 return APR_FROM_OS_ERROR(rc);
82 }
83
84 if (!(flags & APR_FILEPATH_NATIVE)) {
85 for (pos=path; *pos; pos++) {
86 if (*pos == '\\')
87 *pos = '/';
88 }
89 }
90
92 return APR_SUCCESS;
93}
94
95
97{
98 if (root[0] && apr_islower(root[0]) && root[1] == ':') {
99 *rootpath = apr_pstrdup(p, root);
100 (*rootpath)[0] = apr_toupper((*rootpath)[0]);
101 }
102 else {
103 *rootpath = root;
104 }
105 return APR_SUCCESS;
106}
107
108
110 apr_pool_t *p)
111{
112 char path[APR_PATH_MAX];
113 ULONG drive;
115 ULONG rv, pathlen = sizeof(path) - 3;
116 char *pos;
117
119 path[0] = '@' + drive;
120 strcpy(path+1, ":\\");
121 rv = DosQueryCurrentDir(drive, path+3, &pathlen);
122
124
125 if (!(flags & APR_FILEPATH_NATIVE)) {
126 for (pos=*defpath; *pos; pos++) {
127 if (*pos == '\\')
128 *pos = '/';
129 }
130 }
131
132 return APR_SUCCESS;
133}
134
135
136
138{
139 ULONG rv = 0;
140
141 if (path[1] == ':')
142 rv = DosSetDefaultDisk(apr_toupper(path[0]) - '@');
143
144 if (rv == 0)
146
147 return APR_FROM_OS_ERROR(rv);
148}
APR general purpose library routines.
APR Strings library.
request_rec int int apr_table_t const char * path
#define APR_EBADPATH
Definition apr_errno.h:332
const char apr_ssize_t int flags
Definition apr_encode.h:168
apr_redis_t * rc
Definition apr_redis.h:173
const void apr_status_t(*) apr_status_t(* APR_DECLARE)(void) apr_pool_pre_cleanup_register(apr_pool_t *p
Definition apr_pools.h:646
apr_size_t size
#define apr_toupper(c)
Definition apr_lib.h:233
#define apr_islower(c)
Definition apr_lib.h:213
#define APR_FROM_OS_ERROR(e)
Definition apr_errno.h:1214
#define APR_SUCCESS
Definition apr_errno.h:225
char apr_size_t bufsize
Definition apr_errno.h:53
int apr_status_t
Definition apr_errno.h:44
#define APR_FILEPATH_NATIVE
const char * rootpath
apr_pool_t * p
Definition md_event.c:32
apr_status_t filepath_root_case(char **rootpath, char *root, apr_pool_t *p)
Definition filesys.c:21
#define IS_SLASH(c)
Definition filesys.c:52
const char c_is_fnchar[256]
Definition filesys.c:35
apr_status_t filepath_root_test(char *path, apr_pool_t *p)
Definition filesys.c:55
apr_status_t filepath_drive_get(char **rootpath, char drive, apr_int32_t flags, apr_pool_t *p)
Definition filesys.c:66