source: rtems/cpukit/httpd/rom.c @ 54650f51

4.104.114.84.95
Last change on this file since 54650f51 was ee3afa2, checked in by Joel Sherrill <joel.sherrill@…>, on 04/11/03 at 14:46:55

2002-04-10 Mike Siers <mikes@…>

  • rtems_webserver/NOTES, rtems_webserver/asp.c, rtems_webserver/balloc.c, rtems_webserver/default.c, rtems_webserver/ej.h, rtems_webserver/ejIntrn.h, rtems_webserver/ejlex.c, rtems_webserver/ejparse.c, rtems_webserver/emfdb.c, rtems_webserver/emfdb.h, rtems_webserver/form.c, rtems_webserver/h.c, rtems_webserver/handler.c, rtems_webserver/license.txt, rtems_webserver/md5.h, rtems_webserver/md5c.c, rtems_webserver/mime.c, rtems_webserver/misc.c, rtems_webserver/ringq.c, rtems_webserver/rom.c, rtems_webserver/security.c, rtems_webserver/sock.c, rtems_webserver/sym.c, rtems_webserver/uemf.c, rtems_webserver/uemf.h, rtems_webserver/um.c, rtems_webserver/um.h, rtems_webserver/url.c, rtems_webserver/value.c, rtems_webserver/wbase64.c, rtems_webserver/webcomp.c, rtems_webserver/webpage.c, rtems_webserver/webrom.c, rtems_webserver/webs.c, rtems_webserver/webs.h, rtems_webserver/websuemf.c, rtems_webserver/wsIntrn.h: Update to GoAhead? Webserver 2.1.4. The following URL is the release notes from GoAhead?.

http://data.goahead.com/Software/Webserver/2.1.4/release.htm

I have only done a minimal amount of testing (i.e. the network
demo program works fine). Please try this out and let me know
if it works. The patch needs to be applied on the
c/src/libnetworking/rtems_webserver directory.

  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 * rom.c -- Support for ROMed page retrieval.
3 *
4 * Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
5 *
6 * See the file "license.txt" for usage and redistribution license requirements
7 *
8 * $Id$
9 */
10
11/******************************** Description *********************************/
12
13/*
14 *      This module provides web page retrieval from compiled web pages. Use the
15 *      webcomp program to compile web pages and link into the GoAhead WebServer.
16 *      This module uses a hashed symbol table for fast page lookup.
17 *
18 *      Usage: webcomp -f webPageFileList -p Prefix >webrom.c
19 */
20
21/********************************* Includes ***********************************/
22
23#include        <stdlib.h>
24
25#include        "wsIntrn.h"
26
27/******************************** Local Data **********************************/
28
29#ifdef WEBS_PAGE_ROM
30
31sym_fd_t        romTab;                                         /* Symbol table for web pages */
32
33/*********************************** Code *************************************/
34/*
35 *      Open the ROM module
36 */
37
38int websRomOpen()
39{
40        websRomPageIndexType    *wip;
41        int                                             nchars;
42        char_t                                  name[SYM_MAX];
43
44        romTab = symOpen(WEBS_SYM_INIT);
45
46        for (wip = websRomPageIndex; wip->path; wip++) {
47                gstrncpy(name, wip->path, SYM_MAX);
48                nchars = gstrlen(name) - 1;
49                if (nchars > 0 &&
50                        (name[nchars] == '/' || name[nchars] == '\\')) {
51                        name[nchars] = '\0';
52                }
53                symEnter(romTab, name, valueInteger((int) wip), 0);
54        }
55        return 0;
56}
57
58/******************************************************************************/
59/*
60 *      Close the ROM module
61 */
62
63void websRomClose()
64{
65        symClose(romTab);
66}
67
68/******************************************************************************/
69/*
70 *      Open a web page
71 */
72
73int websRomPageOpen(webs_t wp, char_t *path, int mode, int perm)
74{
75        websRomPageIndexType    *wip;
76        sym_t                                   *sp;
77
78        a_assert(websValid(wp));
79        a_assert(path && *path);
80
81        if ((sp = symLookup(romTab, path)) == NULL) {
82                return -1;
83        }
84        wip = (websRomPageIndexType*) sp->content.value.integer;
85        wip->pos = 0;
86        return (wp->docfd = wip - websRomPageIndex);
87}
88
89/******************************************************************************/
90/*
91 *      Close a web page
92 */
93
94void websRomPageClose(int fd)
95{
96}
97
98/******************************************************************************/
99/*
100 *      Stat a web page
101 */
102
103int websRomPageStat(char_t *path, websStatType *sbuf)
104{
105        websRomPageIndexType    *wip;
106        sym_t                                   *sp;
107
108        a_assert(path && *path);
109
110        if ((sp = symLookup(romTab, path)) == NULL) {
111                return -1;
112        }
113        wip = (websRomPageIndexType*) sp->content.value.integer;
114
115        memset(sbuf, 0, sizeof(websStatType));
116        sbuf->size = wip->size;
117        if (wip->page == NULL) {
118                sbuf->isDir = 1;
119        }
120        return 0;
121}
122
123/******************************************************************************/
124/*
125 *      Read a web page
126 */
127
128int websRomPageReadData(webs_t wp, char *buf, int nBytes)
129{
130        websRomPageIndexType    *wip;
131        int                                             len;
132
133        a_assert(websValid(wp));
134        a_assert(buf);
135        a_assert(wp->docfd >= 0);
136
137        wip = &websRomPageIndex[wp->docfd];
138
139        len = min(wip->size - wip->pos, nBytes);
140        memcpy(buf, &wip->page[wip->pos], len);
141        wip->pos += len;
142        return len;
143}
144
145/******************************************************************************/
146/*
147 *      Position a web page
148 */
149
150long websRomPageSeek(webs_t wp, long offset, int origin)
151{
152        websRomPageIndexType    *wip;
153        long pos;
154
155        a_assert(websValid(wp));
156        a_assert(origin == SEEK_SET || origin == SEEK_CUR || origin == SEEK_END);
157        a_assert(wp->docfd >= 0);
158
159        wip = &websRomPageIndex[wp->docfd];
160
161        if (origin != SEEK_SET && origin != SEEK_CUR && origin != SEEK_END) {
162                errno = EINVAL;
163                return -1;
164        }
165
166        if (wp->docfd < 0) {
167                errno = EBADF;
168                return -1;
169        }
170
171        pos = offset;
172        switch (origin) {
173        case SEEK_CUR:
174                pos = wip->pos + offset;
175                break;
176        case SEEK_END:
177                pos = wip->size + offset;
178                break;
179        default:
180                break;
181        }
182
183        if (pos < 0) {
184                errno = EBADF;
185                return -1;
186        }
187
188        return (wip->pos = pos);
189}
190
191#endif /* WEBS_PAGE_ROM */
192
193/******************************************************************************/
Note: See TracBrowser for help on using the repository browser.