mirror of
https://gitlab.rtems.org/rtems/rtos/rtems.git
synced 2025-12-26 14:18:20 +00:00
* 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.
194 lines
3.9 KiB
C
194 lines
3.9 KiB
C
/*
|
|
* rom.c -- Support for ROMed page retrieval.
|
|
*
|
|
* Copyright (c) GoAhead Software Inc., 1995-2000. All Rights Reserved.
|
|
*
|
|
* See the file "license.txt" for usage and redistribution license requirements
|
|
*
|
|
* $Id$
|
|
*/
|
|
|
|
/******************************** Description *********************************/
|
|
|
|
/*
|
|
* This module provides web page retrieval from compiled web pages. Use the
|
|
* webcomp program to compile web pages and link into the GoAhead WebServer.
|
|
* This module uses a hashed symbol table for fast page lookup.
|
|
*
|
|
* Usage: webcomp -f webPageFileList -p Prefix >webrom.c
|
|
*/
|
|
|
|
/********************************* Includes ***********************************/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "wsIntrn.h"
|
|
|
|
/******************************** Local Data **********************************/
|
|
|
|
#ifdef WEBS_PAGE_ROM
|
|
|
|
sym_fd_t romTab; /* Symbol table for web pages */
|
|
|
|
/*********************************** Code *************************************/
|
|
/*
|
|
* Open the ROM module
|
|
*/
|
|
|
|
int websRomOpen()
|
|
{
|
|
websRomPageIndexType *wip;
|
|
int nchars;
|
|
char_t name[SYM_MAX];
|
|
|
|
romTab = symOpen(WEBS_SYM_INIT);
|
|
|
|
for (wip = websRomPageIndex; wip->path; wip++) {
|
|
gstrncpy(name, wip->path, SYM_MAX);
|
|
nchars = gstrlen(name) - 1;
|
|
if (nchars > 0 &&
|
|
(name[nchars] == '/' || name[nchars] == '\\')) {
|
|
name[nchars] = '\0';
|
|
}
|
|
symEnter(romTab, name, valueInteger((int) wip), 0);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/*
|
|
* Close the ROM module
|
|
*/
|
|
|
|
void websRomClose()
|
|
{
|
|
symClose(romTab);
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/*
|
|
* Open a web page
|
|
*/
|
|
|
|
int websRomPageOpen(webs_t wp, char_t *path, int mode, int perm)
|
|
{
|
|
websRomPageIndexType *wip;
|
|
sym_t *sp;
|
|
|
|
a_assert(websValid(wp));
|
|
a_assert(path && *path);
|
|
|
|
if ((sp = symLookup(romTab, path)) == NULL) {
|
|
return -1;
|
|
}
|
|
wip = (websRomPageIndexType*) sp->content.value.integer;
|
|
wip->pos = 0;
|
|
return (wp->docfd = wip - websRomPageIndex);
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/*
|
|
* Close a web page
|
|
*/
|
|
|
|
void websRomPageClose(int fd)
|
|
{
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/*
|
|
* Stat a web page
|
|
*/
|
|
|
|
int websRomPageStat(char_t *path, websStatType *sbuf)
|
|
{
|
|
websRomPageIndexType *wip;
|
|
sym_t *sp;
|
|
|
|
a_assert(path && *path);
|
|
|
|
if ((sp = symLookup(romTab, path)) == NULL) {
|
|
return -1;
|
|
}
|
|
wip = (websRomPageIndexType*) sp->content.value.integer;
|
|
|
|
memset(sbuf, 0, sizeof(websStatType));
|
|
sbuf->size = wip->size;
|
|
if (wip->page == NULL) {
|
|
sbuf->isDir = 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/*
|
|
* Read a web page
|
|
*/
|
|
|
|
int websRomPageReadData(webs_t wp, char *buf, int nBytes)
|
|
{
|
|
websRomPageIndexType *wip;
|
|
int len;
|
|
|
|
a_assert(websValid(wp));
|
|
a_assert(buf);
|
|
a_assert(wp->docfd >= 0);
|
|
|
|
wip = &websRomPageIndex[wp->docfd];
|
|
|
|
len = min(wip->size - wip->pos, nBytes);
|
|
memcpy(buf, &wip->page[wip->pos], len);
|
|
wip->pos += len;
|
|
return len;
|
|
}
|
|
|
|
/******************************************************************************/
|
|
/*
|
|
* Position a web page
|
|
*/
|
|
|
|
long websRomPageSeek(webs_t wp, long offset, int origin)
|
|
{
|
|
websRomPageIndexType *wip;
|
|
long pos;
|
|
|
|
a_assert(websValid(wp));
|
|
a_assert(origin == SEEK_SET || origin == SEEK_CUR || origin == SEEK_END);
|
|
a_assert(wp->docfd >= 0);
|
|
|
|
wip = &websRomPageIndex[wp->docfd];
|
|
|
|
if (origin != SEEK_SET && origin != SEEK_CUR && origin != SEEK_END) {
|
|
errno = EINVAL;
|
|
return -1;
|
|
}
|
|
|
|
if (wp->docfd < 0) {
|
|
errno = EBADF;
|
|
return -1;
|
|
}
|
|
|
|
pos = offset;
|
|
switch (origin) {
|
|
case SEEK_CUR:
|
|
pos = wip->pos + offset;
|
|
break;
|
|
case SEEK_END:
|
|
pos = wip->size + offset;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if (pos < 0) {
|
|
errno = EBADF;
|
|
return -1;
|
|
}
|
|
|
|
return (wip->pos = pos);
|
|
}
|
|
|
|
#endif /* WEBS_PAGE_ROM */
|
|
|
|
/******************************************************************************/
|