summaryrefslogtreecommitdiffstats
path: root/c/src/libnetworking/rtems_webserver/webpage.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>1999-10-27 12:50:33 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>1999-10-27 12:50:33 +0000
commitc1cdaa0ce8017b075487e6670f89eb4e715258ea (patch)
treed4571a02595d6cf6a24d40d6968d83ece3b7a574 /c/src/libnetworking/rtems_webserver/webpage.c
parentNew files created by split of old imfs_handlers.c. (diff)
downloadrtems-c1cdaa0ce8017b075487e6670f89eb4e715258ea.tar.bz2
Patch from Emmanuel Raguet <raguet@crf.canon.fr> and Eric Valette
<valette@crf.canon.fr> to add a port of the GoAhead web server (httpd) to the RTEMS build tree. They have successfully used this BSP on i386/pc386 and PowerPC/mcp750. Mark and Joel spoke with Nick Berliner <nickb@goahead.com> on 26 Oct 1999 about this port and got verbal approval to include it in RTEMS distributions.
Diffstat (limited to 'c/src/libnetworking/rtems_webserver/webpage.c')
-rw-r--r--c/src/libnetworking/rtems_webserver/webpage.c138
1 files changed, 138 insertions, 0 deletions
diff --git a/c/src/libnetworking/rtems_webserver/webpage.c b/c/src/libnetworking/rtems_webserver/webpage.c
new file mode 100644
index 0000000000..d2b976e38f
--- /dev/null
+++ b/c/src/libnetworking/rtems_webserver/webpage.c
@@ -0,0 +1,138 @@
+/*
+ * Page.c -- Support for page retrieval.
+ *
+ * Copyright (c) Go Ahead Software Inc., 1995-1999. All Rights Reserved.
+ *
+ * See the file "license.txt" for usage and redistribution license requirements
+ */
+
+/******************************** Description *********************************/
+
+/*
+ * This module provides page retrieval handling. It provides support for
+ * reading web pages from file systems and has expansion for ROMed web
+ * pages.
+ */
+
+/********************************* Includes ***********************************/
+
+#include "wsIntrn.h"
+
+/*********************************** Code *************************************/
+/*
+ * Open a web page. lpath is the local filename. path is the URL path name.
+ */
+
+int websPageOpen(webs_t wp, char_t *lpath, char_t *path, int mode, int perm)
+{
+ a_assert(websValid(wp));
+
+#if WEBS_PAGE_ROM
+ return websRomPageOpen(wp, path, mode, perm);
+#else
+ return (wp->docfd = gopen(lpath, mode, perm));
+#endif /* WEBS_PAGE_ROM */
+}
+
+/******************************************************************************/
+/*
+ * Close a web page
+ */
+
+void websPageClose(webs_t wp)
+{
+#if WEBS_PAGE_ROM
+ websRomPageClose(wp->docfd);
+#else
+ if (wp->docfd >= 0) {
+ close(wp->docfd);
+ wp->docfd = -1;
+ }
+#endif
+}
+
+/******************************************************************************/
+/*
+ * Stat a web page lpath is the local filename. path is the URL path name.
+ */
+
+int websPageStat(webs_t wp, char_t *lpath, char_t *path, websStatType* sbuf)
+{
+#if WEBS_PAGE_ROM
+ return websRomPageStat(path, sbuf);
+#else
+ gstat_t s;
+
+ if (gstat(lpath, &s) < 0) {
+ return -1;
+ }
+ sbuf->size = s.st_size;
+ sbuf->mtime = s.st_mtime;
+ sbuf->isDir = s.st_mode & S_IFDIR;
+ return 0;
+#endif
+}
+
+/******************************************************************************/
+/*
+ * Is this file a directory?
+ */
+
+int websPageIsDirectory(char_t *lpath)
+{
+#if WEBS_PAGE_ROM
+ websStatType sbuf;
+
+ if (websRomPageStat(lpath, &sbuf) >= 0) {
+ return(sbuf.isDir);
+ } else {
+ return 0;
+ }
+#else
+ gstat_t sbuf;
+
+ if (gstat(lpath, &sbuf) >= 0) {
+ return(sbuf.st_mode & S_IFDIR);
+ } else {
+ return 0;
+ }
+#endif
+}
+
+
+/******************************************************************************/
+/*
+ * Read a web page. Returns the number of _bytes_ read.
+ * len is the size of buf, in bytes.
+ */
+
+int websPageReadData(webs_t wp, char *buf, int nBytes)
+{
+
+#if WEBS_PAGE_ROM
+ a_assert(websValid(wp));
+ return websRomPageReadData(wp, buf, nBytes);
+#else
+ a_assert(websValid(wp));
+ return read(wp->docfd, buf, nBytes);
+#endif
+}
+
+/******************************************************************************/
+/*
+ * Move file pointer offset bytes.
+ */
+
+void websPageSeek(webs_t wp, long offset)
+{
+ a_assert(websValid(wp));
+
+#if WEBS_PAGE_ROM
+ websRomPageSeek(wp, offset, SEEK_CUR);
+#else
+ lseek(wp->docfd, offset, SEEK_CUR);
+#endif
+}
+
+/******************************************************************************/
+