forked from Imagelibrary/rtems
Whitespace removal.
This commit is contained in:
@@ -11,8 +11,8 @@
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* The ASP module processes ASP pages and executes embedded scripts. It
|
||||
* support an open scripting architecture with in-built support for
|
||||
* The ASP module processes ASP pages and executes embedded scripts. It
|
||||
* support an open scripting architecture with in-built support for
|
||||
* Ejscript(TM).
|
||||
*/
|
||||
|
||||
@@ -69,7 +69,7 @@ void websAspClose(void)
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Process ASP requests and expand all scripting commands. We read the
|
||||
* entire ASP page into memory and then process. If you have really big
|
||||
* entire ASP page into memory and then process. If you have really big
|
||||
* documents, it is better to make them plain HTML files rather than ASPs.
|
||||
*/
|
||||
|
||||
@@ -194,7 +194,7 @@ int websAspRequest(webs_t wp, char_t *lpath)
|
||||
*/
|
||||
if (websValid(wp)) {
|
||||
if (result) {
|
||||
websWrite(wp, T("<h2><b>ASP Error: %s</b></h2>\n"),
|
||||
websWrite(wp, T("<h2><b>ASP Error: %s</b></h2>\n"),
|
||||
result);
|
||||
websWrite(wp, T("<pre>%s</pre>"), nextp);
|
||||
bfree(B_L, result);
|
||||
@@ -243,10 +243,10 @@ done:
|
||||
* Define an ASP Ejscript function. Bind an ASP name to a C procedure.
|
||||
*/
|
||||
|
||||
int websAspDefine(char_t *name,
|
||||
int websAspDefine(char_t *name,
|
||||
int (*fn)(int ejid, webs_t wp, int argc, char_t **argv))
|
||||
{
|
||||
return ejSetGlobalFunctionDirect(websAspFunctions, name,
|
||||
return ejSetGlobalFunctionDirect(websAspFunctions, name,
|
||||
(int (*)(int, void*, int, char_t**)) fn);
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ int websAspWrite(int ejid, webs_t wp, int argc, char_t **argv)
|
||||
int i;
|
||||
|
||||
a_assert(websValid(wp));
|
||||
|
||||
|
||||
for (i = 0; i < argc; ) {
|
||||
a_assert(argv);
|
||||
if (websWriteBlock(wp, argv[i], gstrlen(argv[i])) < 0) {
|
||||
@@ -305,7 +305,7 @@ static char_t *strtokcmp(char_t *s1, char_t *s2)
|
||||
* Skip white space
|
||||
*/
|
||||
|
||||
static char_t *skipWhite(char_t *s)
|
||||
static char_t *skipWhite(char_t *s)
|
||||
{
|
||||
a_assert(s);
|
||||
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
/*
|
||||
* This module implements a very fast block allocation scheme suitable for
|
||||
* ROMed environments. It maintains block class queues for rapid allocation
|
||||
* and minimal fragmentation. This module does not coalesce blocks. The
|
||||
* storage space may be populated statically or via the traditional malloc
|
||||
* mechanisms. Large blocks greater than the maximum class size may be
|
||||
* allocated from the O/S or run-time system via malloc. To permit the use
|
||||
* and minimal fragmentation. This module does not coalesce blocks. The
|
||||
* storage space may be populated statically or via the traditional malloc
|
||||
* mechanisms. Large blocks greater than the maximum class size may be
|
||||
* allocated from the O/S or run-time system via malloc. To permit the use
|
||||
* of malloc, call bopen with flags set to B_USE_MALLOC (this is the default).
|
||||
* It is recommended that bopen be called first thing in the application.
|
||||
* If it is not, it will be called with default values on the first call to
|
||||
* It is recommended that bopen be called first thing in the application.
|
||||
* If it is not, it will be called with default values on the first call to
|
||||
* balloc(). Note that this code is not designed for multi-threading purposes
|
||||
* and it depends on newly declared variables being initialized to zero.
|
||||
*/
|
||||
*/
|
||||
|
||||
/********************************* Includes ***********************************/
|
||||
|
||||
@@ -85,7 +85,7 @@ static int bStatsMemMalloc = 0; /* Malloced memory */
|
||||
#endif /* B_STATS */
|
||||
|
||||
/*
|
||||
* ROUNDUP4(size) returns the next higher integer value of size that is
|
||||
* ROUNDUP4(size) returns the next higher integer value of size that is
|
||||
* divisible by 4, or the value of size if size is divisible by 4.
|
||||
* ROUNDUP4() is used in aligning memory allocations on 4-byte boundaries.
|
||||
*
|
||||
@@ -131,10 +131,10 @@ static int ballocGetSize(int size, int *q);
|
||||
/********************************** Code **************************************/
|
||||
/*
|
||||
* Initialize the balloc module. bopen should be called the very first thing
|
||||
* after the application starts and bclose should be called the last thing
|
||||
* before exiting. If bopen is not called, it will be called on the first
|
||||
* allocation with default values. "buf" points to memory to use of size
|
||||
* "bufsize". If buf is NULL, memory is allocated using malloc. flags may
|
||||
* after the application starts and bclose should be called the last thing
|
||||
* before exiting. If bopen is not called, it will be called on the first
|
||||
* allocation with default values. "buf" points to memory to use of size
|
||||
* "bufsize". If buf is NULL, memory is allocated using malloc. flags may
|
||||
* be set to B_USE_MALLOC if using malloc is okay. This routine will allocate
|
||||
* an initial buffer of size bufsize for use by the application.
|
||||
*/
|
||||
@@ -205,7 +205,7 @@ void bclose(void)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Allocate a block of the requested size. First check the block
|
||||
* Allocate a block of the requested size. First check the block
|
||||
* queues for a suitable one.
|
||||
*/
|
||||
|
||||
@@ -289,7 +289,7 @@ void *balloc(B_ARGS_DEC, int size)
|
||||
} else {
|
||||
if (bFreeLeft > memSize) {
|
||||
/*
|
||||
* The q was empty, and the free list has spare memory so
|
||||
* The q was empty, and the free list has spare memory so
|
||||
* create a new block out of the primary free block
|
||||
*/
|
||||
bp = (bType*) bFreeNext;
|
||||
@@ -390,7 +390,7 @@ void bfree(B_ARGS_DEC, void *mp)
|
||||
free(bp);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
#ifdef B_VERIFY_CAUSES_SEVERE_OVERHEAD
|
||||
bFillBlock(bp, memSize);
|
||||
#endif
|
||||
@@ -442,7 +442,7 @@ char *bstrdupA(B_ARGS_DEC, char *s)
|
||||
/*
|
||||
* Duplicate an ascii string, allow NULL pointers and then dup an empty string.
|
||||
* If UNICODE, bstrdup above works with wide chars, so we need this routine
|
||||
* for ascii strings.
|
||||
* for ascii strings.
|
||||
*/
|
||||
|
||||
char_t *bstrdup(B_ARGS_DEC, char_t *s)
|
||||
@@ -463,7 +463,7 @@ char_t *bstrdup(B_ARGS_DEC, char_t *s)
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Reallocate a block. Allow NULL pointers and just do a malloc.
|
||||
* Note: if the realloc fails, we return NULL and the previous buffer is
|
||||
* Note: if the realloc fails, we return NULL and the previous buffer is
|
||||
* preserved.
|
||||
*/
|
||||
|
||||
@@ -494,7 +494,7 @@ void *brealloc(B_ARGS_DEC, void *mp, int newsize)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Find the size of the block to be balloc'ed. It takes in a size, finds the
|
||||
* Find the size of the block to be balloc'ed. It takes in a size, finds the
|
||||
* smallest binary block it fits into, adds an overhead amount and returns.
|
||||
* q is the binary size used to keep track of block sizes in use. Called
|
||||
* from both balloc and bfree.
|
||||
@@ -526,8 +526,8 @@ static void bFillBlock(void *buf, int bufsize)
|
||||
/******************************************************************************/
|
||||
#ifdef B_STATS
|
||||
/*
|
||||
* Statistics. Do output via calling the writefn callback function with
|
||||
* "handle" as the output file handle.
|
||||
* Statistics. Do output via calling the writefn callback function with
|
||||
* "handle" as the output file handle.
|
||||
*/
|
||||
|
||||
void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
@@ -568,9 +568,9 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
}
|
||||
mem = count * (1 << (q + B_SHIFT));
|
||||
total += mem;
|
||||
(*writefn)(handle,
|
||||
(*writefn)(handle,
|
||||
T("%2d %5d %4d %6d %4d %5d %4d\n"),
|
||||
q, 1 << (q + B_SHIFT), count, mem, bStats[q].inuse,
|
||||
q, 1 << (q + B_SHIFT), count, mem, bStats[q].inuse,
|
||||
bStats[q].inuse * (1 << (q + B_SHIFT)), bStats[q].alloc);
|
||||
}
|
||||
|
||||
@@ -581,7 +581,7 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
*
|
||||
* bFreeSize Initial memory reserved with bopen call
|
||||
* bStatsMemMalloc memory from calls to system MALLOC
|
||||
* bStatsMemMax
|
||||
* bStatsMemMax
|
||||
* bStatsBallocMax largest amount of memory from balloc calls
|
||||
* bStatsMemInUse
|
||||
* bStatsBallocInUse present balloced memory being used
|
||||
@@ -599,7 +599,7 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
(*writefn)(handle, T("Memory currently in use %7d\n"), bStatsMemInUse);
|
||||
(*writefn)(handle, T("Memory currently balloced %7d\n"), bStatsBallocInUse);
|
||||
(*writefn)(handle, T("Max blocks allocated %7d\n"), bStatsBlksMax);
|
||||
(*writefn)(handle, T("Maximum stack used %7d\n"),
|
||||
(*writefn)(handle, T("Maximum stack used %7d\n"),
|
||||
(int) bStackStart - (int) bStackMin);
|
||||
|
||||
(*writefn)(handle, T("Free memory on all queues %7d\n"), total);
|
||||
@@ -618,17 +618,17 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
}
|
||||
memcpy(files, bStatsFiles, len);
|
||||
qsort(files, bStatsFilesMax, sizeof(bStatsFileType), bStatsFileSort);
|
||||
|
||||
|
||||
(*writefn)(handle, T("\nMemory Currently Allocated\n"));
|
||||
total = 0;
|
||||
(*writefn)(handle,
|
||||
(*writefn)(handle,
|
||||
T(" bytes, blocks in use, total times,")
|
||||
T("largest, q\n"));
|
||||
|
||||
for (fp = files; fp < &files[bStatsFilesMax]; fp++) {
|
||||
if (fp->file[0]) {
|
||||
(*writefn)(handle, T("%18s, %7d, %5d, %6d, %7d,%4d\n"),
|
||||
fp->file, fp->allocated, fp->count, fp->times, fp->largest,
|
||||
fp->file, fp->allocated, fp->count, fp->times, fp->largest,
|
||||
fp->q);
|
||||
total += fp->allocated;
|
||||
}
|
||||
@@ -644,7 +644,7 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
cp = (char_t*) ((char*) blkp->ptr + sizeof(bType));
|
||||
fp = blkp->who;
|
||||
if (gisalnum(*cp)) {
|
||||
(*writefn)(handle, T("%-50s allocated by %s\n"), cp,
|
||||
(*writefn)(handle, T("%-50s allocated by %s\n"), cp,
|
||||
fp->file);
|
||||
}
|
||||
}
|
||||
@@ -774,7 +774,7 @@ static void bStatsFree(B_ARGS_DEC, void *ptr, int q, int size)
|
||||
bStats[q].inuse--;
|
||||
|
||||
/*
|
||||
* Update the per block stats. Try from the end first
|
||||
* Update the per block stats. Try from the end first
|
||||
*/
|
||||
for (bp = &bStatsBlks[bStatsBlksMax - 1]; bp >= bStatsBlks; bp--) {
|
||||
if (bp->ptr == ptr) {
|
||||
@@ -832,7 +832,7 @@ void bstats(int handle, void (*writefn)(int handle, char_t *fmt, ...))
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* verifyUsedBlock verifies that a block which was previously allocated is
|
||||
* still uncorrupted.
|
||||
* still uncorrupted.
|
||||
*/
|
||||
|
||||
static void verifyUsedBlock(bType *bp, int q)
|
||||
@@ -885,7 +885,7 @@ void verifyBallocSpace()
|
||||
/*
|
||||
* First verify all the free blocks.
|
||||
*/
|
||||
for (q = 0; q < B_MAX_CLASS; q++) {
|
||||
for (q = 0; q < B_MAX_CLASS; q++) {
|
||||
for (bp = bQhead[q]; bp != NULL; bp = bp->u.next) {
|
||||
verifyFreeBlock(bp, q);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/********************************** Description *******************************/
|
||||
/*
|
||||
* This module implements the /cgi-bin handler. CGI processing differs from
|
||||
* goforms processing in that each CGI request is executed as a separate
|
||||
* goforms processing in that each CGI request is executed as a separate
|
||||
* process, rather than within the webserver process. For each CGI request the
|
||||
* environment of the new process must be set to include all the CGI variables
|
||||
* and its standard input and output must be directed to the socket. This
|
||||
@@ -45,7 +45,7 @@ static int cgiMax; /* Size of hAlloc list */
|
||||
/*
|
||||
* Process a form request. Returns 1 always to indicate it handled the URL
|
||||
*/
|
||||
int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
char_t *url, char_t *path, char_t* query)
|
||||
{
|
||||
cgiRec *cgip;
|
||||
@@ -100,7 +100,7 @@ int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
}
|
||||
#endif /* ! VXWORKS */
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Get the CWD for resetting after launching the child process CGI
|
||||
*/
|
||||
@@ -116,12 +116,12 @@ int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
/*
|
||||
* Build command line arguments. Only used if there is no non-encoded
|
||||
* = character. This is indicative of a ISINDEX query. POST separators
|
||||
* are & and others are +. argp will point to a balloc'd array of
|
||||
* are & and others are +. argp will point to a balloc'd array of
|
||||
* pointers. Each pointer will point to substring within the
|
||||
* query string. This array of string pointers is how the spawn or
|
||||
* exec routines expect command line arguments to be passed. Since
|
||||
* query string. This array of string pointers is how the spawn or
|
||||
* exec routines expect command line arguments to be passed. Since
|
||||
* we don't know ahead of time how many individual items there are in
|
||||
* the query string, the for loop includes logic to grow the array
|
||||
* the query string, the for loop includes logic to grow the array
|
||||
* size via brealloc.
|
||||
*/
|
||||
argpsize = 10;
|
||||
@@ -143,9 +143,9 @@ int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
*(argp+n) = NULL;
|
||||
/*
|
||||
* Add all CGI variables to the environment strings to be passed
|
||||
* to the spawned CGI process. This includes a few we don't
|
||||
* to the spawned CGI process. This includes a few we don't
|
||||
* already have in the symbol table, plus all those that are in
|
||||
* the cgiVars symbol table. envp will point to a balloc'd array of
|
||||
* the cgiVars symbol table. envp will point to a balloc'd array of
|
||||
* pointers. Each pointer will point to a balloc'd string containing
|
||||
* the keyword value pair in the form keyword=value. Since we don't
|
||||
* know ahead of time how many environment strings there will be the
|
||||
@@ -183,14 +183,14 @@ int websCgiHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
*/
|
||||
if (wp->cgiStdin == NULL) {
|
||||
wp->cgiStdin = websGetCgiCommName();
|
||||
}
|
||||
}
|
||||
stdIn = wp->cgiStdin;
|
||||
stdOut = websGetCgiCommName();
|
||||
/*
|
||||
* Now launch the process. If not successful, do the cleanup of resources.
|
||||
* If successful, the cleanup will be done after the process completes.
|
||||
*/
|
||||
if ((pHandle = websLaunchCgiProc(cgiPath, argp, envp, stdIn, stdOut))
|
||||
if ((pHandle = websLaunchCgiProc(cgiPath, argp, envp, stdIn, stdOut))
|
||||
== -1) {
|
||||
websError(wp, 200, T("failed to spawn CGI task"));
|
||||
for (ep = envp; *ep != NULL; ep++) {
|
||||
@@ -234,7 +234,7 @@ void websCgiGatherOutput (cgiRec *cgip)
|
||||
{
|
||||
gstat_t sbuf;
|
||||
char_t cgiBuf[FNAMESIZE];
|
||||
if ((gstat(cgip->stdOut, &sbuf) == 0) &&
|
||||
if ((gstat(cgip->stdOut, &sbuf) == 0) &&
|
||||
(sbuf.st_size > cgip->fplacemark)) {
|
||||
int fdout;
|
||||
fdout = gopen(cgip->stdOut, O_RDONLY | O_BINARY, 0444 );
|
||||
@@ -283,15 +283,15 @@ void websCgiCleanup()
|
||||
* We get here if the CGI process has terminated. Clean up.
|
||||
*/
|
||||
nTries = 0;
|
||||
/*
|
||||
/*
|
||||
* Make sure we didn't miss something during a task switch.
|
||||
* Maximum wait is 100 times 10 msecs (1 second).
|
||||
*/
|
||||
while ((cgip->fplacemark == 0) && (nTries < 100)) {
|
||||
websCgiGatherOutput(cgip);
|
||||
/*
|
||||
* There are some cases when we detect app exit
|
||||
* before the file is ready.
|
||||
/*
|
||||
* There are some cases when we detect app exit
|
||||
* before the file is ready.
|
||||
*/
|
||||
if (cgip->fplacemark == 0) {
|
||||
#ifdef WIN
|
||||
|
||||
@@ -35,8 +35,8 @@ static void websDefaultWriteEvent(webs_t wp);
|
||||
/*
|
||||
* Process a default URL request. This will validate the URL and handle "../"
|
||||
* and will provide support for Active Server Pages. As the handler is the
|
||||
* last handler to run, it always indicates that it has handled the URL
|
||||
* by returning 1.
|
||||
* last handler to run, it always indicates that it has handled the URL
|
||||
* by returning 1.
|
||||
*/
|
||||
|
||||
int websDefaultHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
@@ -84,11 +84,11 @@ int websDefaultHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
/*
|
||||
* Open the document. Stat for later use.
|
||||
*/
|
||||
if (websPageOpen(wp, lpath, path, SOCKET_RDONLY | SOCKET_BINARY,
|
||||
if (websPageOpen(wp, lpath, path, SOCKET_RDONLY | SOCKET_BINARY,
|
||||
0666) < 0) {
|
||||
websError(wp, 400, T("Cannot open URL <b>%s</b>"), url);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (websPageStat(wp, lpath, path, &sbuf) < 0) {
|
||||
websError(wp, 400, T("Cannot stat page for URL <b>%s</b>"), url);
|
||||
@@ -234,7 +234,7 @@ int websValidateUrl(webs_t wp, char_t *path)
|
||||
* backslash character, like:
|
||||
*
|
||||
* GoAhead is vulnerable to a directory traversal bug. A request such as
|
||||
*
|
||||
*
|
||||
* GoAhead-server/../../../../../../../ results in an error message
|
||||
* 'Cannot open URL'.
|
||||
|
||||
@@ -242,7 +242,7 @@ int websValidateUrl(webs_t wp, char_t *path)
|
||||
* the
|
||||
* web root and read arbitrary files from the server.
|
||||
* Hence a request like:
|
||||
*
|
||||
*
|
||||
* GoAhead-server/..%5C..%5C..%5C..%5C..%5C..%5C/winnt/win.ini returns the
|
||||
* contents of the win.ini file.
|
||||
* (Note that the description uses forward slashes (0x2F), but the example
|
||||
@@ -257,12 +257,12 @@ int websValidateUrl(webs_t wp, char_t *path)
|
||||
*token = '/';
|
||||
token = gstrchr(token, '\\');
|
||||
}
|
||||
|
||||
|
||||
token = gstrtok(path, T("/"));
|
||||
|
||||
/*
|
||||
* Look at each directory segment and process "." and ".." segments
|
||||
* Don't allow the browser to pop outside the root web.
|
||||
* Don't allow the browser to pop outside the root web.
|
||||
*/
|
||||
while (token != NULL) {
|
||||
if (gstrcmp(token, T("..")) == 0) {
|
||||
@@ -363,7 +363,7 @@ static void websDefaultWriteEvent(webs_t wp)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Closing down. Free resources.
|
||||
*/
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* ej.h -- Ejscript(TM) header
|
||||
*
|
||||
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
* GoAhead Ejscript(TM) header. This defines the Ejscript API and internal
|
||||
* structures.
|
||||
*/
|
||||
@@ -35,7 +35,7 @@ extern int ejArgs(int argc, char_t **argv, char_t *fmt, ...);
|
||||
extern void ejSetResult(int eid, char_t *s);
|
||||
extern int ejOpenEngine(sym_fd_t variables, sym_fd_t functions);
|
||||
extern void ejCloseEngine(int eid);
|
||||
extern int ejSetGlobalFunction(int eid, char_t *name,
|
||||
extern int ejSetGlobalFunction(int eid, char_t *name,
|
||||
int (*fn)(int eid, void *handle, int argc, char_t **argv));
|
||||
extern void ejSetVar(int eid, char_t *var, char_t *value);
|
||||
extern int ejGetVar(int eid, char_t *var, char_t **value);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* ejIntrn.h -- Ejscript(TM) header
|
||||
*
|
||||
* Copyright (c) GoAhead Software, Inc., 1992-2000
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
* GoAhead Ejscript(TM) header. This defines the Ejscript API and internal
|
||||
* structures.
|
||||
*/
|
||||
@@ -193,7 +193,7 @@ extern char_t *ejEvalFile(int eid, char_t *path, char_t **emsg);
|
||||
#endif
|
||||
extern int ejRemoveGlobalFunction(int eid, char_t *name);
|
||||
extern void *ejGetGlobalFunction(int eid, char_t *name);
|
||||
extern int ejSetGlobalFunctionDirect(sym_fd_t functions, char_t *name,
|
||||
extern int ejSetGlobalFunctionDirect(sym_fd_t functions, char_t *name,
|
||||
int (*fn)(int eid, void *handle, int argc, char_t **argv));
|
||||
extern void ejError(ej_t* ep, char_t* fmt, ...);
|
||||
extern void ejSetUserHandle(int eid, int handle);
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* Ejscript lexical analyser. This implementes a lexical analyser for a
|
||||
* Ejscript lexical analyser. This implementes a lexical analyser for a
|
||||
* a subset of the JavaScript language.
|
||||
*/
|
||||
|
||||
@@ -508,7 +508,7 @@ static int getLexicalToken(ej_t* ep, int state)
|
||||
}
|
||||
return TOK_LITERAL;
|
||||
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '0': case '1': case '2': case '3': case '4':
|
||||
case '5': case '6': case '7': case '8': case '9':
|
||||
do {
|
||||
if (tokenAddChar(ep, c) < 0) {
|
||||
@@ -540,7 +540,7 @@ static int getLexicalToken(ej_t* ep, int state)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (! gisalpha(*tokq->servp) && *tokq->servp != '$' &&
|
||||
if (! gisalpha(*tokq->servp) && *tokq->servp != '$' &&
|
||||
*tokq->servp != '_') {
|
||||
ejError(ep, T("Invalid identifier %s"), tokq->servp);
|
||||
return TOK_ERR;
|
||||
@@ -566,10 +566,10 @@ static int getLexicalToken(ej_t* ep, int state)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Skip white space after token to find out whether this is
|
||||
* a function or not.
|
||||
*/
|
||||
*/
|
||||
while (c == ' ' || c == '\t' || c == '\r' || c == '\n') {
|
||||
if ((c = inputGetc(ep)) < 0)
|
||||
break;
|
||||
@@ -682,7 +682,7 @@ static void inputPutback(ej_t* ep, int c)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Convert a hex or octal character back to binary, return original char if
|
||||
* Convert a hex or octal character back to binary, return original char if
|
||||
* not a hex digit
|
||||
*/
|
||||
|
||||
|
||||
@@ -174,26 +174,26 @@ char_t *ejEvalFile(int eid, char_t *path, char_t **emsg)
|
||||
ejError(ep, T("Bad handle %d"), eid);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (gstat(path, &sbuf) < 0) {
|
||||
gclose(fd);
|
||||
ejError(ep, T("Cant stat %s"), path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if ((fileBuf = balloc(B_L, sbuf.st_size + 1)) == NULL) {
|
||||
gclose(fd);
|
||||
ejError(ep, T("Cant malloc %d"), sbuf.st_size);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (gread(fd, fileBuf, sbuf.st_size) != (int)sbuf.st_size) {
|
||||
gclose(fd);
|
||||
bfree(B_L, fileBuf);
|
||||
ejError(ep, T("Error reading %s"), path);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
fileBuf[sbuf.st_size] = '\0';
|
||||
gclose(fd);
|
||||
|
||||
@@ -292,13 +292,13 @@ char_t *ejEval(int eid, char_t *script, char_t **emsg)
|
||||
int state;
|
||||
void *endlessLoopTest;
|
||||
int loopCounter;
|
||||
|
||||
|
||||
|
||||
|
||||
a_assert(script);
|
||||
|
||||
if (emsg) {
|
||||
*emsg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if ((ep = ejPtr(eid)) == NULL) {
|
||||
return NULL;
|
||||
|
||||
@@ -29,11 +29,11 @@
|
||||
* Variable to support the basicSet and basicGet functions.
|
||||
*/
|
||||
|
||||
static char_t *basicProdDir = NULL;
|
||||
static char_t *basicProdDir = NULL;
|
||||
static char_t *basicDefaultDir = T("."); /* Default set to current */
|
||||
|
||||
/*
|
||||
* hAlloc chain list of table schemas to be closed
|
||||
* hAlloc chain list of table schemas to be closed
|
||||
*/
|
||||
|
||||
static int dbMaxTables = 0;
|
||||
@@ -46,8 +46,8 @@ static char_t *trim(char_t *str);
|
||||
static int GetColumnIndex(int tid, char_t *colName);
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Add a schema to the module-internal schema database
|
||||
/*
|
||||
* Add a schema to the module-internal schema database
|
||||
*/
|
||||
|
||||
int dbRegisterDBSchema(dbTable_t *pTableRegister)
|
||||
@@ -57,14 +57,14 @@ int dbRegisterDBSchema(dbTable_t *pTableRegister)
|
||||
|
||||
a_assert(pTableRegister);
|
||||
|
||||
trace(4, T("DB: Registering database table <%s>\n"),
|
||||
trace(4, T("DB: Registering database table <%s>\n"),
|
||||
pTableRegister->name);
|
||||
|
||||
/*
|
||||
* Bump up the size of the table array
|
||||
*/
|
||||
tid = hAllocEntry((void*) &dbListTables,
|
||||
&dbMaxTables, sizeof(dbTable_t));
|
||||
tid = hAllocEntry((void*) &dbListTables,
|
||||
&dbMaxTables, sizeof(dbTable_t));
|
||||
|
||||
/*
|
||||
* Copy the table schema to the last spot in schema array
|
||||
@@ -92,7 +92,7 @@ int dbRegisterDBSchema(dbTable_t *pTableRegister)
|
||||
pTable->columnTypes = balloc(B_L, sizeof(int *) * pTable->nColumns);
|
||||
|
||||
for (i = 0; (i < pTableRegister->nColumns); i++) {
|
||||
pTable->columnNames[i] =
|
||||
pTable->columnNames[i] =
|
||||
bstrdup(B_L, pTableRegister->columnNames[i]);
|
||||
pTable->columnTypes[i] = pTableRegister->columnTypes[i];
|
||||
}
|
||||
@@ -117,10 +117,10 @@ int dbRegisterDBSchema(dbTable_t *pTableRegister)
|
||||
* with staticly defined schemas. There is only one did in this package: 0.
|
||||
*/
|
||||
|
||||
int dbOpen(char_t *tablename, char_t *filename,
|
||||
int dbOpen(char_t *tablename, char_t *filename,
|
||||
int (*gettime)(int did), int flags)
|
||||
{
|
||||
basicProdDir = NULL;
|
||||
basicProdDir = NULL;
|
||||
basicDefaultDir = T(".");
|
||||
dbMaxTables = 0;
|
||||
dbListTables = NULL;
|
||||
@@ -234,7 +234,7 @@ void dbZero(int did)
|
||||
* Find the a row in the table with the given string in the given column
|
||||
*/
|
||||
|
||||
int dbSearchStr(int did, char_t *tablename,
|
||||
int dbSearchStr(int did, char_t *tablename,
|
||||
char_t *colName, char_t *value, int flags)
|
||||
{
|
||||
int tid, nRows, nColumns, column;
|
||||
@@ -252,7 +252,7 @@ int dbSearchStr(int did, char_t *tablename,
|
||||
} else {
|
||||
return DB_ERR_TABLE_NOT_FOUND;
|
||||
}
|
||||
|
||||
|
||||
nColumns = pTable->nColumns;
|
||||
nRows = pTable->nRows;
|
||||
column = GetColumnIndex(tid, colName);
|
||||
@@ -269,7 +269,7 @@ int dbSearchStr(int did, char_t *tablename,
|
||||
while (row < nRows) {
|
||||
pRow = pTable->rows[row];
|
||||
if (pRow) {
|
||||
compareVal = (char_t *)(pRow[column]);
|
||||
compareVal = (char_t *)(pRow[column]);
|
||||
if (compareVal && (gstrcmp(compareVal, value) == 0)) {
|
||||
return row;
|
||||
}
|
||||
@@ -280,7 +280,7 @@ int dbSearchStr(int did, char_t *tablename,
|
||||
/*
|
||||
* Return -2 if search column was not found
|
||||
*/
|
||||
trace(3, T("DB: Unable to find column <%s> in table <%s>\n"),
|
||||
trace(3, T("DB: Unable to find column <%s> in table <%s>\n"),
|
||||
colName, tablename);
|
||||
return DB_ERR_COL_NOT_FOUND;
|
||||
}
|
||||
@@ -316,14 +316,14 @@ int dbAddRow(int did, char_t *tablename)
|
||||
|
||||
size = pTable->nColumns * max(sizeof(int), sizeof(char_t *));
|
||||
return hAllocEntry((void***) &(pTable->rows), &(pTable->nRows), size);
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Delete a row in the table.
|
||||
* Delete a row in the table.
|
||||
*/
|
||||
|
||||
int dbDeleteRow(int did, char_t *tablename, int row)
|
||||
@@ -353,7 +353,7 @@ int dbDeleteRow(int did, char_t *tablename, int row)
|
||||
* Free up any allocated strings
|
||||
*/
|
||||
while (column < nColumns) {
|
||||
if (pRow[column] &&
|
||||
if (pRow[column] &&
|
||||
(pTable->columnTypes[column] == T_STRING)) {
|
||||
bfree(B_L, (char_t *)pRow[column]);
|
||||
}
|
||||
@@ -367,21 +367,21 @@ int dbDeleteRow(int did, char_t *tablename, int row)
|
||||
|
||||
bfreeSafe(B_L, pRow);
|
||||
pTable->nRows = hFree((void ***)&pTable->rows, row);
|
||||
trace(5, T("DB: Deleted row <%d> from table <%s>\n"),
|
||||
trace(5, T("DB: Deleted row <%d> from table <%s>\n"),
|
||||
row, tablename);
|
||||
}
|
||||
return 0;
|
||||
} else {
|
||||
trace(3, T("DB: Unable to delete row <%d> from table <%s>\n"),
|
||||
trace(3, T("DB: Unable to delete row <%d> from table <%s>\n"),
|
||||
row, tablename);
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Grow the rows in the table to the nominated size.
|
||||
* Grow the rows in the table to the nominated size.
|
||||
*/
|
||||
|
||||
int dbSetTableNrow(int did, char_t *tablename, int nNewRows)
|
||||
@@ -408,13 +408,13 @@ int dbSetTableNrow(int did, char_t *tablename, int nNewRows)
|
||||
nRet = 0;
|
||||
|
||||
if (nRows >= nNewRows) {
|
||||
/*
|
||||
/*
|
||||
* If number of rows already allocated exceeds requested number, do nothing
|
||||
*/
|
||||
trace(4, T("DB: Ignoring row set to <%d> in table <%s>\n"),
|
||||
nNewRows, tablename);
|
||||
} else {
|
||||
trace(4, T("DB: Setting rows to <%d> in table <%s>\n"),
|
||||
trace(4, T("DB: Setting rows to <%d> in table <%s>\n"),
|
||||
nNewRows, tablename);
|
||||
while (pTable->nRows < nNewRows) {
|
||||
if (dbAddRow(did, tablename) < 0) {
|
||||
@@ -422,7 +422,7 @@ int dbSetTableNrow(int did, char_t *tablename, int nNewRows)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return nRet;
|
||||
}
|
||||
@@ -435,7 +435,7 @@ int dbSetTableNrow(int did, char_t *tablename, int nNewRows)
|
||||
int dbGetTableNrow(int did, char_t *tablename)
|
||||
{
|
||||
int tid;
|
||||
|
||||
|
||||
a_assert(tablename);
|
||||
tid = dbGetTableId(did, tablename);
|
||||
|
||||
@@ -455,7 +455,7 @@ int dbReadInt(int did, char_t *table, char_t *column, int row, int *returnValue)
|
||||
{
|
||||
int colIndex, *pRow, tid;
|
||||
dbTable_t *pTable;
|
||||
|
||||
|
||||
a_assert(table);
|
||||
a_assert(column);
|
||||
a_assert(returnValue);
|
||||
@@ -489,7 +489,7 @@ int dbReadInt(int did, char_t *table, char_t *column, int row, int *returnValue)
|
||||
if (pRow) {
|
||||
*returnValue = pRow[colIndex];
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return DB_ERR_ROW_DELETED;
|
||||
}
|
||||
return DB_ERR_COL_NOT_FOUND;
|
||||
@@ -512,7 +512,7 @@ int dbReadStr(int did, char_t *table, char_t *column, int row,
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* The dbWriteInt function writes a value into a table at a given row and
|
||||
* column. The existence of the row and column is verified before the
|
||||
* column. The existence of the row and column is verified before the
|
||||
* write. 0 is returned on succes, -1 is returned on error.
|
||||
*/
|
||||
|
||||
@@ -535,7 +535,7 @@ int dbWriteInt(int did, char_t *table, char_t *column, int row, int iData)
|
||||
}
|
||||
|
||||
pTable = dbListTables[tid];
|
||||
|
||||
|
||||
if (pTable) {
|
||||
/*
|
||||
* Make sure that the column exists
|
||||
@@ -565,8 +565,8 @@ int dbWriteInt(int did, char_t *table, char_t *column, int row, int iData)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* The dbWriteStr function writes a string value into a table at a given row
|
||||
* and column. The existence of the row and column is verified before the
|
||||
* The dbWriteStr function writes a string value into a table at a given row
|
||||
* and column. The existence of the row and column is verified before the
|
||||
* write. The column is also checked to confirm it is a string field.
|
||||
* 0 is returned on succes, -1 is returned on error.
|
||||
*/
|
||||
@@ -657,7 +657,7 @@ static int dbWriteKeyValue(int fd, char_t *key, char_t *value)
|
||||
|
||||
a_assert(key && *key);
|
||||
a_assert(value);
|
||||
|
||||
|
||||
fmtAlloc(&pLineOut, BUF_MAX, T("%s=%s\n"), key, value);
|
||||
|
||||
if (pLineOut) {
|
||||
@@ -696,7 +696,7 @@ int dbSave(int did, char_t *filename, int flags)
|
||||
* First write to a temporary file, then switch around later.
|
||||
*/
|
||||
fmtAlloc(&tmpFile, FNAMESIZE, T("%s/data.tmp"), basicGetProductDir());
|
||||
if ((fd = gopen(tmpFile,
|
||||
if ((fd = gopen(tmpFile,
|
||||
O_CREAT | O_TRUNC | O_WRONLY | O_BINARY, 0666)) < 0) {
|
||||
trace(1, T("WARNING: Failed to open file %s\n"), tmpFile);
|
||||
bfree(B_L, tmpFile);
|
||||
@@ -723,14 +723,14 @@ int dbSave(int did, char_t *filename, int flags)
|
||||
* if row is NULL, the row has been deleted, so don't
|
||||
* write it out.
|
||||
*/
|
||||
if ((pRow == NULL) || (pRow[0] == '\0') ||
|
||||
if ((pRow == NULL) || (pRow[0] == '\0') ||
|
||||
(*(char_t *)(pRow[0]) == '\0')) {
|
||||
continue;
|
||||
}
|
||||
/*
|
||||
* Print the ROW=rowNumber directive to the file
|
||||
*/
|
||||
fmtAlloc(&tmpNum, 20, T("%d"), row);
|
||||
fmtAlloc(&tmpNum, 20, T("%d"), row);
|
||||
rc = dbWriteKeyValue(fd, KEYWORD_ROW, tmpNum);
|
||||
bfreeSafe(B_L, tmpNum);
|
||||
|
||||
@@ -739,20 +739,20 @@ int dbSave(int did, char_t *filename, int flags)
|
||||
/*
|
||||
* Print the key-value pairs (COLUMN=value) for data cells
|
||||
*/
|
||||
for (column = 0; (column < nColumns) && (rc >= 0);
|
||||
for (column = 0; (column < nColumns) && (rc >= 0);
|
||||
column++, colNames++, colTypes++) {
|
||||
if (*colTypes == T_STRING) {
|
||||
rc = dbWriteKeyValue(fd, *colNames,
|
||||
rc = dbWriteKeyValue(fd, *colNames,
|
||||
(char_t *)(pRow[column]));
|
||||
} else {
|
||||
fmtAlloc(&tmpNum, 20, T("%d"), pRow[column]);
|
||||
fmtAlloc(&tmpNum, 20, T("%d"), pRow[column]);
|
||||
rc = dbWriteKeyValue(fd, *colNames, tmpNum);
|
||||
bfreeSafe(B_L, tmpNum);
|
||||
}
|
||||
}
|
||||
|
||||
if (rc < 0) {
|
||||
trace(1, T("WARNING: Failed to write to file %s\n"),
|
||||
trace(1, T("WARNING: Failed to write to file %s\n"),
|
||||
tmpFile);
|
||||
nRet = -1;
|
||||
}
|
||||
@@ -812,7 +812,7 @@ static int crack(char_t *buf, char_t **key, char_t **val)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Parse the file. These files consist of key-value pairs, separated by the
|
||||
* Parse the file. These files consist of key-value pairs, separated by the
|
||||
* "=" sign. Parsing of tables starts with the "TABLE=value" pair, and rows
|
||||
* are parsed starting with the "ROW=value" pair.
|
||||
*/
|
||||
@@ -955,12 +955,12 @@ int dbGetTableId(int did, char_t *tablename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Return a pointer to the table name, given its ID
|
||||
*/
|
||||
|
||||
@@ -991,7 +991,7 @@ static char_t *trim(char_t *str)
|
||||
* Return a column index given the column name
|
||||
*/
|
||||
|
||||
static int GetColumnIndex(int tid, char_t *colName)
|
||||
static int GetColumnIndex(int tid, char_t *colName)
|
||||
{
|
||||
int column;
|
||||
dbTable_t *pTable;
|
||||
@@ -1019,10 +1019,10 @@ void basicSetProductDir(char_t *proddir)
|
||||
{
|
||||
int len;
|
||||
|
||||
if (basicProdDir != NULL) {
|
||||
if (basicProdDir != NULL) {
|
||||
bfree(B_L, basicProdDir);
|
||||
}
|
||||
|
||||
|
||||
basicProdDir = bstrdup(B_L, proddir);
|
||||
/*
|
||||
* Make sure that prefix-directory doesn't end with a '/'
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
/*
|
||||
* This module implements the /goform handler. It emulates CGI processing
|
||||
* but performs this in-process and not as an external process. This enables
|
||||
* a very high performance implementation with easy parsing and decoding
|
||||
* a very high performance implementation with easy parsing and decoding
|
||||
* of query strings and posted data.
|
||||
*/
|
||||
|
||||
@@ -30,7 +30,7 @@ static sym_fd_t formSymtab = -1; /* Symbol table for form handlers */
|
||||
* Process a form request. Returns 1 always to indicate it handled the URL
|
||||
*/
|
||||
|
||||
int websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
int websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
char_t *url, char_t *path, char_t *query)
|
||||
{
|
||||
sym_t *sp;
|
||||
@@ -58,7 +58,7 @@ int websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
}
|
||||
|
||||
/*
|
||||
* Lookup the C form function first and then try tcl (no javascript support
|
||||
* Lookup the C form function first and then try tcl (no javascript support
|
||||
* yet).
|
||||
*/
|
||||
sp = symLookup(formSymtab, formName);
|
||||
@@ -92,7 +92,7 @@ int websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
* Define a form function in the "form" map space.
|
||||
*/
|
||||
|
||||
int websFormDefine(char_t *name, void (*fn)(webs_t wp, char_t *path,
|
||||
int websFormDefine(char_t *name, void (*fn)(webs_t wp, char_t *path,
|
||||
char_t *query))
|
||||
{
|
||||
a_assert(name && *name);
|
||||
|
||||
@@ -28,7 +28,7 @@ static int urlHandlerOpenCount = 0; /* count of apps */
|
||||
/**************************** Forward Declarations ****************************/
|
||||
|
||||
static int websUrlHandlerSort(const void *p1, const void *p2);
|
||||
static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
int sid, char_t *url, char_t *path, char_t *query);
|
||||
static char_t *websCondenseMultipleChars(char_t *strToCondense, char_t cCondense);
|
||||
|
||||
@@ -72,16 +72,16 @@ void websUrlHandlerClose(void)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Define a new URL handler. urlPrefix is the URL prefix to match. webDir is
|
||||
* Define a new URL handler. urlPrefix is the URL prefix to match. webDir is
|
||||
* an optional root directory path for a web directory. arg is an optional
|
||||
* arg to pass to the URL handler. flags defines the matching order. Valid
|
||||
* flags include WEBS_HANDLER_LAST, WEBS_HANDLER_FIRST. If multiple users
|
||||
* specify last or first, their order is defined alphabetically by the
|
||||
* flags include WEBS_HANDLER_LAST, WEBS_HANDLER_FIRST. If multiple users
|
||||
* specify last or first, their order is defined alphabetically by the
|
||||
* urlPrefix.
|
||||
*/
|
||||
|
||||
int websUrlHandlerDefine(char_t *urlPrefix, char_t *webDir, int arg,
|
||||
int (*handler)(webs_t wp, char_t *urlPrefix, char_t *webdir, int arg,
|
||||
int (*handler)(webs_t wp, char_t *urlPrefix, char_t *webdir, int arg,
|
||||
char_t *url, char_t *path, char_t *query), int flags)
|
||||
{
|
||||
websUrlHandlerType *sp;
|
||||
@@ -114,18 +114,18 @@ int websUrlHandlerDefine(char_t *urlPrefix, char_t *webDir, int arg,
|
||||
/*
|
||||
* Sort in decreasing URL length order observing the flags for first and last
|
||||
*/
|
||||
qsort(websUrlHandler, websUrlHandlerMax, sizeof(websUrlHandlerType),
|
||||
qsort(websUrlHandler, websUrlHandlerMax, sizeof(websUrlHandlerType),
|
||||
websUrlHandlerSort);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Delete an existing URL handler. We don't reclaim the space of the old
|
||||
* Delete an existing URL handler. We don't reclaim the space of the old
|
||||
* handler, just NULL the entry. Return -1 if handler is not found.
|
||||
*/
|
||||
|
||||
int websUrlHandlerDelete(int (*handler)(webs_t wp, char_t *urlPrefix,
|
||||
int websUrlHandlerDelete(int (*handler)(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path, char_t *query))
|
||||
{
|
||||
websUrlHandlerType *sp;
|
||||
@@ -172,7 +172,7 @@ static int websUrlHandlerSort(const void *p1, const void *p2)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return -rc;
|
||||
return -rc;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -216,7 +216,7 @@ char_t *websGetPublishDir(char_t *path, char_t **urlPrefix)
|
||||
* default handler do the rest.
|
||||
*/
|
||||
|
||||
static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
int sid, char_t *url, char_t *path, char_t *query)
|
||||
{
|
||||
int len;
|
||||
@@ -225,7 +225,7 @@ static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
a_assert(path);
|
||||
|
||||
/*
|
||||
* Trim the urlPrefix off the path and set the webdirectory. Add one to step
|
||||
* Trim the urlPrefix off the path and set the webdirectory. Add one to step
|
||||
* over the trailing '/'
|
||||
*/
|
||||
len = gstrlen(urlPrefix) + 1;
|
||||
@@ -236,7 +236,7 @@ static int websPublishHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* See if any valid handlers are defined for this request. If so, call them
|
||||
* and continue calling valid handlers until one accepts the request.
|
||||
* and continue calling valid handlers until one accepts the request.
|
||||
* Return true if a handler was invoked, else return FALSE.
|
||||
*/
|
||||
|
||||
@@ -255,7 +255,7 @@ int websUrlHandlerRequest(webs_t wp)
|
||||
socketDeleteHandler(wp->sid);
|
||||
wp->state = WEBS_PROCESSING;
|
||||
websStats.handlerHits++;
|
||||
|
||||
|
||||
websSetRequestPath(wp, websGetDefaultDir(), NULL);
|
||||
|
||||
/*
|
||||
@@ -265,7 +265,7 @@ int websUrlHandlerRequest(webs_t wp)
|
||||
websCondenseMultipleChars(wp->url, '/');
|
||||
|
||||
/*
|
||||
* We loop over each handler in order till one accepts the request.
|
||||
* We loop over each handler in order till one accepts the request.
|
||||
* The security handler will handle the request if access is NOT allowed.
|
||||
*/
|
||||
first = 1;
|
||||
@@ -276,12 +276,12 @@ int websUrlHandlerRequest(webs_t wp)
|
||||
websSetEnv(wp);
|
||||
first = 0;
|
||||
}
|
||||
if ((*sp->handler)(wp, sp->urlPrefix, sp->webDir, sp->arg,
|
||||
if ((*sp->handler)(wp, sp->urlPrefix, sp->webDir, sp->arg,
|
||||
wp->url, wp->path, wp->query)) {
|
||||
return 1;
|
||||
}
|
||||
if (!websValid(wp)) {
|
||||
trace(0,
|
||||
trace(0,
|
||||
T("webs: handler %s called websDone, but didn't return 1\n"),
|
||||
sp->urlPrefix);
|
||||
return 1;
|
||||
@@ -289,7 +289,7 @@ int websUrlHandlerRequest(webs_t wp)
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If no handler processed the request, then return an error. Note: It is
|
||||
* If no handler processed the request, then return an error. Note: It is
|
||||
* the handlers responsibility to call websDone
|
||||
*/
|
||||
if (i >= websUrlHandlerMax) {
|
||||
@@ -326,7 +326,7 @@ static int websTidyUrl(webs_t wp)
|
||||
|
||||
/*
|
||||
* Look at each directory segment and process "." and ".." segments
|
||||
* Don't allow the browser to pop outside the root web.
|
||||
* Don't allow the browser to pop outside the root web.
|
||||
*/
|
||||
while (token != NULL) {
|
||||
if (gstrcmp(token, T("..")) == 0) {
|
||||
@@ -393,7 +393,7 @@ static char_t *websCondenseMultipleChars(char_t *strToCondense, char_t cCondense
|
||||
if (pStr != pScan) {
|
||||
*pStr = *pScan;
|
||||
}
|
||||
|
||||
|
||||
pScan++;
|
||||
pStr++;
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
|
||||
rights reserved.
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ char_t *dirname(char_t *buf, char_t *name, int bufsize)
|
||||
a_assert(bufsize > 0);
|
||||
|
||||
#if (defined (WIN) || defined (NW))
|
||||
if ((cp = gstrrchr(name, '/')) == NULL &&
|
||||
if ((cp = gstrrchr(name, '/')) == NULL &&
|
||||
(cp = gstrrchr(name, '\\')) == NULL)
|
||||
#else
|
||||
if ((cp = gstrrchr(name, '/')) == NULL)
|
||||
@@ -259,16 +259,16 @@ static int dsnprintf(char_t **s, int size, char_t *fmt, va_list arg, int msize)
|
||||
int width = 0;
|
||||
int prec = -1;
|
||||
for ( ; c != '\0'; c = *fmt++) {
|
||||
if (c == '-') {
|
||||
f |= flag_minus;
|
||||
} else if (c == '+') {
|
||||
f |= flag_plus;
|
||||
} else if (c == ' ') {
|
||||
f |= flag_space;
|
||||
} else if (c == '#') {
|
||||
f |= flag_hash;
|
||||
} else if (c == '0') {
|
||||
f |= flag_zero;
|
||||
if (c == '-') {
|
||||
f |= flag_minus;
|
||||
} else if (c == '+') {
|
||||
f |= flag_plus;
|
||||
} else if (c == ' ') {
|
||||
f |= flag_space;
|
||||
} else if (c == '#') {
|
||||
f |= flag_hash;
|
||||
} else if (c == '0') {
|
||||
f |= flag_zero;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -341,10 +341,10 @@ static int dsnprintf(char_t **s, int size, char_t *fmt, va_list arg, int msize)
|
||||
} else {
|
||||
if (f & flag_hash && value != 0) {
|
||||
if (c == 'x') {
|
||||
put_ulong(&buf, value, 16, 0, T("0x"), width,
|
||||
put_ulong(&buf, value, 16, 0, T("0x"), width,
|
||||
prec, f);
|
||||
} else {
|
||||
put_ulong(&buf, value, 16, 1, T("0X"), width,
|
||||
put_ulong(&buf, value, 16, 1, T("0X"), width,
|
||||
prec, f);
|
||||
}
|
||||
} else {
|
||||
@@ -471,22 +471,22 @@ static void put_string(strbuf_t *buf, char_t *s, int len, int width,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (len < 0) {
|
||||
len = strnlen(s, prec >= 0 ? prec : ULONG_MAX);
|
||||
} else if (prec >= 0 && prec < len) {
|
||||
len = prec;
|
||||
if (len < 0) {
|
||||
len = strnlen(s, prec >= 0 ? prec : ULONG_MAX);
|
||||
} else if (prec >= 0 && prec < len) {
|
||||
len = prec;
|
||||
}
|
||||
if (width > len && !(f & flag_minus)) {
|
||||
for (i = len; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
for (i = len; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
}
|
||||
}
|
||||
for (i = 0; i < len; ++i) {
|
||||
put_char(buf, s[i]);
|
||||
for (i = 0; i < len; ++i) {
|
||||
put_char(buf, s[i]);
|
||||
}
|
||||
if (width > len && f & flag_minus) {
|
||||
for (i = len; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
for (i = len; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -504,31 +504,31 @@ static void put_ulong(strbuf_t *buf, unsigned long int value, int base,
|
||||
|
||||
for (len = 1, x = 1; x < ULONG_MAX / base; ++len, x = x2) {
|
||||
x2 = x * base;
|
||||
if (x2 > value) {
|
||||
break;
|
||||
if (x2 > value) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
zeros = (prec > len) ? prec - len : 0;
|
||||
width -= zeros + len;
|
||||
if (prefix != NULL) {
|
||||
width -= strnlen(prefix, ULONG_MAX);
|
||||
if (prefix != NULL) {
|
||||
width -= strnlen(prefix, ULONG_MAX);
|
||||
}
|
||||
if (!(f & flag_minus)) {
|
||||
if (f & flag_zero) {
|
||||
for (i = 0; i < width; ++i) {
|
||||
put_char(buf, '0');
|
||||
for (i = 0; i < width; ++i) {
|
||||
put_char(buf, '0');
|
||||
}
|
||||
} else {
|
||||
for (i = 0; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
for (i = 0; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
if (prefix != NULL) {
|
||||
put_string(buf, prefix, -1, 0, -1, flag_none);
|
||||
if (prefix != NULL) {
|
||||
put_string(buf, prefix, -1, 0, -1, flag_none);
|
||||
}
|
||||
for (i = 0; i < zeros; ++i) {
|
||||
put_char(buf, '0');
|
||||
for (i = 0; i < zeros; ++i) {
|
||||
put_char(buf, '0');
|
||||
}
|
||||
for ( ; x > 0; x /= base) {
|
||||
int digit = (value / x) % base;
|
||||
@@ -536,8 +536,8 @@ static void put_ulong(strbuf_t *buf, unsigned long int value, int base,
|
||||
digit));
|
||||
}
|
||||
if (f & flag_minus) {
|
||||
for (i = 0; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
for (i = 0; i < width; ++i) {
|
||||
put_char(buf, ' ');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
* ^ ^ ^ ^
|
||||
* | | | |
|
||||
* rq->buf rq->servp rq->endp rq->enduf
|
||||
*
|
||||
*
|
||||
* The queue is empty when servp == endp. This means that the queue will hold
|
||||
* at most rq->buflen -1 bytes. It is the filler's responsibility to ensure
|
||||
* the ringq is never filled such that servp == endp.
|
||||
@@ -77,7 +77,7 @@ int ringqGrowCalls = 0;
|
||||
* Create a new ringq. "increment" is the amount to increase the size of the
|
||||
* ringq should it need to grow to accomodate data being added. "maxsize" is
|
||||
* an upper limit (sanity level) beyond which the q must not grow. Set maxsize
|
||||
* to -1 to imply no upper limit. The buffer for the ringq is always
|
||||
* to -1 to imply no upper limit. The buffer for the ringq is always
|
||||
* dynamically allocated. Set maxsize
|
||||
*/
|
||||
|
||||
@@ -123,7 +123,7 @@ void ringqClose(ringq_t *rq)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Return the length of the data in the ringq. Users must fill the queue to
|
||||
* Return the length of the data in the ringq. Users must fill the queue to
|
||||
* a high water mark of at most one less than the queue size.
|
||||
*/
|
||||
|
||||
@@ -167,7 +167,7 @@ int ringqGetc(ringq_t *rq)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Add a char to the queue. Note if being used to store wide strings
|
||||
* Add a char to the queue. Note if being used to store wide strings
|
||||
* this does not add a trailing '\0'. Grow the q as required.
|
||||
*/
|
||||
|
||||
@@ -413,7 +413,7 @@ int ringqGetBlk(ringq_t *rq, unsigned char *buf, int size)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Return the maximum number of bytes the ring q can accept via a single
|
||||
* Return the maximum number of bytes the ring q can accept via a single
|
||||
* block copy. Useful if the user is doing their own data insertion.
|
||||
*/
|
||||
|
||||
@@ -423,7 +423,7 @@ int ringqPutBlkMax(ringq_t *rq)
|
||||
|
||||
a_assert(rq);
|
||||
a_assert(rq->buflen == (rq->endbuf - rq->buf));
|
||||
|
||||
|
||||
space = rq->buflen - RINGQ_LEN(rq) - 1;
|
||||
in_a_line = rq->endbuf - rq->endp;
|
||||
|
||||
@@ -432,7 +432,7 @@ int ringqPutBlkMax(ringq_t *rq)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Return the maximum number of bytes the ring q can provide via a single
|
||||
* Return the maximum number of bytes the ring q can provide via a single
|
||||
* block copy. Useful if the user is doing their own data retrieval.
|
||||
*/
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
/********************************** Defines ***********************************/
|
||||
/*
|
||||
* The following #defines change the behaviour of security in the absence
|
||||
* The following #defines change the behaviour of security in the absence
|
||||
* of User Management.
|
||||
* Note that use of User management functions require prior calling of
|
||||
* umInit() to behave correctly
|
||||
@@ -53,7 +53,7 @@ static int debugSecurity = 0;
|
||||
* Determine if this request should be honored
|
||||
*/
|
||||
|
||||
int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
char_t *url, char_t *path, char_t *query)
|
||||
{
|
||||
char_t *type, *userid, *password, *accessLimit;
|
||||
@@ -77,7 +77,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
if (accessLimit == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Check to see if URL must be encrypted
|
||||
*/
|
||||
@@ -116,7 +116,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
if (!umUserExists(userid)) {
|
||||
websStats.access++;
|
||||
websError(wp, 401, T("Access Denied\nUnknown User"));
|
||||
trace(3, T("SEC: Unknown user <%s> attempted to access <%s>\n"),
|
||||
trace(3, T("SEC: Unknown user <%s> attempted to access <%s>\n"),
|
||||
userid, path);
|
||||
nRet = 1;
|
||||
} else if (!umUserCanAccessURL(userid, accessLimit)) {
|
||||
@@ -153,7 +153,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
a_assert(wp->digest);
|
||||
a_assert(wp->nonce);
|
||||
a_assert(wp->password);
|
||||
|
||||
|
||||
digestCalc = websCalcDigest(wp);
|
||||
a_assert(digestCalc);
|
||||
|
||||
@@ -175,7 +175,7 @@ int websSecurityHandler(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
}
|
||||
#endif
|
||||
websStats.errors++;
|
||||
websError(wp, 401,
|
||||
websError(wp, 401,
|
||||
T("Access to this document requires a password"));
|
||||
nRet = 1;
|
||||
}
|
||||
@@ -211,7 +211,7 @@ void websSecurityDelete(void)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Store the new password, expect a decoded password. Store in websPassword in
|
||||
* Store the new password, expect a decoded password. Store in websPassword in
|
||||
* the decoded form.
|
||||
*/
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* Posix Socket Module. This supports blocking and non-blocking buffered
|
||||
* Posix Socket Module. This supports blocking and non-blocking buffered
|
||||
* socket I/O.
|
||||
*/
|
||||
|
||||
@@ -41,8 +41,8 @@ static int tryAlternateSendTo(int sock, char *buf, int toWrite, int i,
|
||||
|
||||
/*********************************** Code *************************************/
|
||||
/*
|
||||
* Write to a socket. Absorb as much data as the socket can buffer. Block if
|
||||
* the socket is in blocking mode. Returns -1 on error, otherwise the number
|
||||
* Write to a socket. Absorb as much data as the socket can buffer. Block if
|
||||
* the socket is in blocking mode. Returns -1 on error, otherwise the number
|
||||
* of bytes written.
|
||||
*/
|
||||
|
||||
@@ -60,7 +60,7 @@ int socketWrite(int sid, char *buf, int bufsize)
|
||||
}
|
||||
|
||||
/*
|
||||
* Loop adding as much data to the output ringq as we can absorb. Initiate a
|
||||
* Loop adding as much data to the output ringq as we can absorb. Initiate a
|
||||
* flush when the ringq is too full and continue. Block in socketFlush if the
|
||||
* socket is in blocking mode.
|
||||
*/
|
||||
@@ -104,7 +104,7 @@ int socketWriteString(int sid, char_t *buf)
|
||||
#ifdef UNICODE
|
||||
char *byteBuf;
|
||||
int r, len;
|
||||
|
||||
|
||||
len = gstrlen(buf);
|
||||
byteBuf = ballocUniToAsc(buf, len);
|
||||
r = socketWrite(sid, byteBuf, len);
|
||||
@@ -119,12 +119,12 @@ int socketWriteString(int sid, char_t *buf)
|
||||
/*
|
||||
* Read from a socket. Return the number of bytes read if successful. This
|
||||
* may be less than the requested "bufsize" and may be zero. Return -1 for
|
||||
* errors. Return 0 for EOF. Otherwise return the number of bytes read.
|
||||
* errors. Return 0 for EOF. Otherwise return the number of bytes read.
|
||||
* If this routine returns zero it indicates an EOF condition.
|
||||
* which can be verified with socketEof()
|
||||
|
||||
|
||||
* Note: this ignores the line buffer, so a previous socketGets
|
||||
* which read a partial line may cause a subsequent socketRead to miss some
|
||||
* which read a partial line may cause a subsequent socketRead to miss some
|
||||
* data. This routine may block if the socket is in blocking mode.
|
||||
*
|
||||
*/
|
||||
@@ -161,7 +161,7 @@ int socketRead(int sid, char *buf, int bufsize)
|
||||
/*
|
||||
* This flush is critical for readers of datagram packets. If the
|
||||
* buffer is not big enough to read the whole datagram in one hit,
|
||||
* the recvfrom call will fail.
|
||||
* the recvfrom call will fail.
|
||||
*/
|
||||
ringqFlush(rq);
|
||||
room = ringqPutBlkMax(rq);
|
||||
@@ -181,7 +181,7 @@ int socketRead(int sid, char *buf, int bufsize)
|
||||
} else if (len == 0) {
|
||||
/*
|
||||
* If bytesRead is 0, this is EOF since socketRead should never
|
||||
* be called unless there is data yet to be read. Set the flag.
|
||||
* be called unless there is data yet to be read. Set the flag.
|
||||
* Then pass back the number of bytes read.
|
||||
*/
|
||||
if (bytesRead == 0) {
|
||||
@@ -204,10 +204,10 @@ int socketRead(int sid, char *buf, int bufsize)
|
||||
/*
|
||||
* Get a string from a socket. This returns data in *buf in a malloced string
|
||||
* after trimming the '\n'. If there is zero bytes returned, *buf will be set
|
||||
* to NULL. If doing non-blocking I/O, it returns -1 for error, EOF or when
|
||||
* to NULL. If doing non-blocking I/O, it returns -1 for error, EOF or when
|
||||
* no complete line yet read. If doing blocking I/O, it will block until an
|
||||
* entire line is read. If a partial line is read socketInputBuffered or
|
||||
* socketEof can be used to distinguish between EOF and partial line still
|
||||
* entire line is read. If a partial line is read socketInputBuffered or
|
||||
* socketEof can be used to distinguish between EOF and partial line still
|
||||
* buffered. This routine eats and ignores carriage returns.
|
||||
*/
|
||||
|
||||
@@ -231,7 +231,7 @@ int socketGets(int sid, char_t **buf)
|
||||
if ((rc = socketRead(sid, &c, 1)) < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
if (rc == 0) {
|
||||
/*
|
||||
* If there is a partial line and we are at EOF, pretend we saw a '\n'
|
||||
@@ -308,7 +308,7 @@ int socketFlush(int sid)
|
||||
return -1;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
/*
|
||||
* Ensure we get a FD_WRITE message when the socket can absorb
|
||||
@@ -317,7 +317,7 @@ int socketFlush(int sid)
|
||||
*/
|
||||
if (sp->saveMask < 0 ) {
|
||||
sp->saveMask = sp->handlerMask;
|
||||
socketRegisterInterest(sp,
|
||||
socketRegisterInterest(sp,
|
||||
sp->handlerMask | SOCKET_WRITABLE);
|
||||
}
|
||||
return 0;
|
||||
@@ -433,7 +433,7 @@ void socketSetBufferSize(int sid, int in, int line, int out)
|
||||
* is an event of interest as defined by handlerMask (SOCKET_READABLE, ...)
|
||||
*/
|
||||
|
||||
void socketCreateHandler(int sid, int handlerMask, socketHandler_t handler,
|
||||
void socketCreateHandler(int sid, int handlerMask, socketHandler_t handler,
|
||||
int data)
|
||||
{
|
||||
socket_t *sp;
|
||||
@@ -535,7 +535,7 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
|
||||
* more data
|
||||
*/
|
||||
#ifndef UEMF
|
||||
#ifdef WIN
|
||||
#ifdef WIN
|
||||
if (sp->interestEvents & FD_WRITE) {
|
||||
emfTime_t blockTime = { 0, 0 };
|
||||
emfSetMaxBlockTime(&blockTime);
|
||||
@@ -547,9 +547,9 @@ static int socketDoOutput(socket_t *sp, char *buf, int toWrite, int *errCode)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* If the sendto failed, swap the first two bytes in the
|
||||
* If the sendto failed, swap the first two bytes in the
|
||||
* sockaddr structure. This is a kludge due to a change in
|
||||
* VxWorks between versions 5.3 and 5.4, but we want the
|
||||
* VxWorks between versions 5.3 and 5.4, but we want the
|
||||
* product to run on either.
|
||||
*/
|
||||
static int tryAlternateSendTo(int sock, char *buf, int toWrite, int i,
|
||||
@@ -661,7 +661,7 @@ void socketFree(int sid)
|
||||
for (i = 0; i < socketMax; i++) {
|
||||
if ((sp = socketList[i]) == NULL) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
socketHighestFd = max(socketHighestFd, sp->sock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* Posix Socket Module. This supports blocking and non-blocking buffered
|
||||
* Posix Socket Module. This supports blocking and non-blocking buffered
|
||||
* socket I/O.
|
||||
*/
|
||||
|
||||
@@ -163,7 +163,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
#else
|
||||
hostent = gethostbyname(host);
|
||||
if (hostent != NULL) {
|
||||
memcpy((char *) &sockaddr.sin_addr,
|
||||
memcpy((char *) &sockaddr.sin_addr,
|
||||
(char *) hostent->h_addr_list[0],
|
||||
(size_t) hostent->h_length);
|
||||
} else {
|
||||
@@ -221,7 +221,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
*/
|
||||
if (host) {
|
||||
/*
|
||||
* Connect to the remote server in blocking mode, then go into
|
||||
* Connect to the remote server in blocking mode, then go into
|
||||
* non-blocking mode if desired.
|
||||
*/
|
||||
if (!dgram) {
|
||||
@@ -250,7 +250,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
|
||||
}
|
||||
if ((rc = connect(sp->sock, (struct sockaddr *) &sockaddr,
|
||||
sizeof(sockaddr))) < 0 &&
|
||||
sizeof(sockaddr))) < 0 &&
|
||||
(rc = tryAlternateConnect(sp->sock,
|
||||
(struct sockaddr *) &sockaddr)) < 0) {
|
||||
#if (defined (WIN) || defined (CE))
|
||||
@@ -272,7 +272,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
*/
|
||||
rc = 1;
|
||||
setsockopt(sp->sock, SOL_SOCKET, SO_REUSEADDR, (char *)&rc, sizeof(rc));
|
||||
if (bind(sp->sock, (struct sockaddr *) &sockaddr,
|
||||
if (bind(sp->sock, (struct sockaddr *) &sockaddr,
|
||||
sizeof(sockaddr)) < 0) {
|
||||
socketFree(sid);
|
||||
return -1;
|
||||
@@ -308,9 +308,9 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* If the connection failed, swap the first two bytes in the
|
||||
* If the connection failed, swap the first two bytes in the
|
||||
* sockaddr structure. This is a kludge due to a change in
|
||||
* VxWorks between versions 5.3 and 5.4, but we want the
|
||||
* VxWorks between versions 5.3 and 5.4, but we want the
|
||||
* product to run on either.
|
||||
*/
|
||||
|
||||
@@ -451,20 +451,20 @@ int socketGetInput(int sid, char *buf, int toRead, int *errCode)
|
||||
} else {
|
||||
bytesRead = recv(sp->sock, buf, toRead, 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* BUG 01865 -- CPU utilization hangs on Windows. The original code used
|
||||
* BUG 01865 -- CPU utilization hangs on Windows. The original code used
|
||||
* the 'errno' global variable, which is not set by the winsock functions
|
||||
* as it is under *nix platforms. We use the platform independent
|
||||
* socketGetError() function instead, which does handle Windows correctly.
|
||||
* socketGetError() function instead, which does handle Windows correctly.
|
||||
* Other, *nix compatible platforms should work as well, since on those
|
||||
* platforms, socketGetError() just returns the value of errno.
|
||||
* Thanks to Jonathan Burgoyne for the fix.
|
||||
*/
|
||||
if (bytesRead < 0)
|
||||
if (bytesRead < 0)
|
||||
{
|
||||
*errCode = socketGetError();
|
||||
if (*errCode == ECONNRESET)
|
||||
if (*errCode == ECONNRESET)
|
||||
{
|
||||
sp->flags |= SOCKET_CONNRESET;
|
||||
return 0;
|
||||
@@ -599,7 +599,7 @@ int socketReady(int sid)
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sp->flags & SOCKET_CONNRESET) {
|
||||
socketCloseConnection(sid);
|
||||
return 0;
|
||||
@@ -623,7 +623,7 @@ int socketReady(int sid)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Wait for a handle to become readable or writable and return a number of
|
||||
* Wait for a handle to become readable or writable and return a number of
|
||||
* noticed events. Timeout is in milliseconds.
|
||||
*/
|
||||
|
||||
@@ -773,7 +773,7 @@ int socketSelect(int sid, int timeout)
|
||||
*/
|
||||
index = sp->sock / (NBBY * sizeof(fd_mask));
|
||||
bit = 1 << (sp->sock % (NBBY * sizeof(fd_mask)));
|
||||
|
||||
|
||||
/*
|
||||
* Set the appropriate bit in the ready masks for the sp->sock.
|
||||
*/
|
||||
@@ -893,11 +893,11 @@ static int socketDoEvent(socket_t *sp)
|
||||
|
||||
sid = sp->sid;
|
||||
if (sp->currentEvents & SOCKET_READABLE) {
|
||||
if (sp->flags & SOCKET_LISTENING) {
|
||||
if (sp->flags & SOCKET_LISTENING) {
|
||||
socketAccept(sp);
|
||||
sp->currentEvents = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
@@ -929,11 +929,11 @@ static int socketDoEvent(socket_t *sp)
|
||||
* socket, so we must be very careful after calling the handler.
|
||||
*/
|
||||
if (sp->handler && (sp->handlerMask & sp->currentEvents)) {
|
||||
(sp->handler)(sid, sp->handlerMask & sp->currentEvents,
|
||||
(sp->handler)(sid, sp->handlerMask & sp->currentEvents,
|
||||
sp->handler_data);
|
||||
/*
|
||||
* Make sure socket pointer is still valid, then reset the currentEvents.
|
||||
*/
|
||||
*/
|
||||
if (socketList && sid < socketMax && socketList[sid] == sp) {
|
||||
sp->currentEvents = 0;
|
||||
}
|
||||
@@ -1008,7 +1008,7 @@ int socketDontBlock()
|
||||
int i;
|
||||
|
||||
for (i = 0; i < socketMax; i++) {
|
||||
if ((sp = socketList[i]) == NULL ||
|
||||
if ((sp = socketList[i]) == NULL ||
|
||||
(sp->handlerMask & SOCKET_READABLE) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* Posix Socket Module. This supports blocking and non-blocking buffered
|
||||
* Posix Socket Module. This supports blocking and non-blocking buffered
|
||||
* socket I/O.
|
||||
*/
|
||||
|
||||
@@ -162,7 +162,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
#else
|
||||
hostent = gethostbyname(host);
|
||||
if (hostent != NULL) {
|
||||
memcpy((char *) &sockaddr.sin_addr,
|
||||
memcpy((char *) &sockaddr.sin_addr,
|
||||
(char *) hostent->h_addr_list[0],
|
||||
(size_t) hostent->h_length);
|
||||
} else {
|
||||
@@ -220,7 +220,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
*/
|
||||
if (host) {
|
||||
/*
|
||||
* Connect to the remote server in blocking mode, then go into
|
||||
* Connect to the remote server in blocking mode, then go into
|
||||
* non-blocking mode if desired.
|
||||
*/
|
||||
if (!dgram) {
|
||||
@@ -249,7 +249,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
|
||||
}
|
||||
if ((rc = connect(sp->sock, (struct sockaddr *) &sockaddr,
|
||||
sizeof(sockaddr))) < 0 &&
|
||||
sizeof(sockaddr))) < 0 &&
|
||||
(rc = tryAlternateConnect(sp->sock,
|
||||
(struct sockaddr *) &sockaddr)) < 0) {
|
||||
#if WIN || CE
|
||||
@@ -271,7 +271,7 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
*/
|
||||
rc = 1;
|
||||
setsockopt(sp->sock, SOL_SOCKET, SO_REUSEADDR, (char *)&rc, sizeof(rc));
|
||||
if (bind(sp->sock, (struct sockaddr *) &sockaddr,
|
||||
if (bind(sp->sock, (struct sockaddr *) &sockaddr,
|
||||
sizeof(sockaddr)) < 0) {
|
||||
socketFree(sid);
|
||||
return -1;
|
||||
@@ -306,9 +306,9 @@ int socketOpenConnection(char *host, int port, socketAccept_t accept, int flags)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* If the connection failed, swap the first two bytes in the
|
||||
* If the connection failed, swap the first two bytes in the
|
||||
* sockaddr structure. This is a kludge due to a change in
|
||||
* VxWorks between versions 5.3 and 5.4, but we want the
|
||||
* VxWorks between versions 5.3 and 5.4, but we want the
|
||||
* product to run on either.
|
||||
*/
|
||||
|
||||
@@ -584,7 +584,7 @@ int socketReady(int sid)
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (sp->currentEvents & sp->handlerMask) {
|
||||
return 1;
|
||||
}
|
||||
@@ -604,7 +604,7 @@ int socketReady(int sid)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Wait for a handle to become readable or writable and return a number of
|
||||
* Wait for a handle to become readable or writable and return a number of
|
||||
* noticed events. Timeout is in milliseconds.
|
||||
*/
|
||||
|
||||
@@ -754,7 +754,7 @@ int socketSelect(int sid, int timeout)
|
||||
*/
|
||||
index = sp->sock / (NBBY * sizeof(fd_mask));
|
||||
bit = 1 << (sp->sock % (NBBY * sizeof(fd_mask)));
|
||||
|
||||
|
||||
/*
|
||||
* Set the appropriate bit in the ready masks for the sp->sock.
|
||||
*/
|
||||
@@ -874,11 +874,11 @@ static int socketDoEvent(socket_t *sp)
|
||||
|
||||
sid = sp->sid;
|
||||
if (sp->currentEvents & SOCKET_READABLE) {
|
||||
if (sp->flags & SOCKET_LISTENING) {
|
||||
if (sp->flags & SOCKET_LISTENING) {
|
||||
socketAccept(sp);
|
||||
sp->currentEvents = 0;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
/*
|
||||
@@ -910,11 +910,11 @@ static int socketDoEvent(socket_t *sp)
|
||||
* socket, so we must be very careful after calling the handler.
|
||||
*/
|
||||
if (sp->handler && (sp->handlerMask & sp->currentEvents)) {
|
||||
(sp->handler)(sid, sp->handlerMask & sp->currentEvents,
|
||||
(sp->handler)(sid, sp->handlerMask & sp->currentEvents,
|
||||
sp->handler_data);
|
||||
/*
|
||||
* Make sure socket pointer is still valid, then reset the currentEvents.
|
||||
*/
|
||||
*/
|
||||
if (socketList && sid < socketMax && socketList[sid] == sp) {
|
||||
sp->currentEvents = 0;
|
||||
}
|
||||
@@ -989,7 +989,7 @@ int socketDontBlock(void)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < socketMax; i++) {
|
||||
if ((sp = socketList[i]) == NULL ||
|
||||
if ((sp = socketList[i]) == NULL ||
|
||||
(sp->handlerMask & SOCKET_READABLE) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ void error(E_ARGS_DEC, int etype, char_t *fmt, ...)
|
||||
fmtAlloc(&buf, E_MAX_ERROR, T("%s\n"), fmtBuf);
|
||||
/*#ifdef DEV*/
|
||||
} else if (etype == E_ASSERT) {
|
||||
fmtAlloc(&buf, E_MAX_ERROR,
|
||||
T("Assertion %s, failed at %s %d\n"), fmtBuf, E_ARGS);
|
||||
fmtAlloc(&buf, E_MAX_ERROR,
|
||||
T("Assertion %s, failed at %s %d\n"), fmtBuf, E_ARGS);
|
||||
/*#endif*/
|
||||
} else if (etype == E_USER) {
|
||||
fmtAlloc(&buf, E_MAX_ERROR, T("%s\n"), fmtBuf);
|
||||
@@ -60,7 +60,7 @@ void error(E_ARGS_DEC, int etype, char_t *fmt, ...)
|
||||
* bugfix -- if etype is not E_LOG, E_ASSERT, or E_USER, the call to
|
||||
* bfreeSafe(B_L, buf) below will fail, because 'buf' is randomly
|
||||
* initialized. To be nice, we format a message saying that this is an
|
||||
* unknown message type, and in doing so give buf a valid value. Thanks
|
||||
* unknown message type, and in doing so give buf a valid value. Thanks
|
||||
* to Simon Byholm.
|
||||
*/
|
||||
else {
|
||||
@@ -129,7 +129,7 @@ void traceRaw(char_t *buf)
|
||||
* Replace the default trace handler. Return a pointer to the old handler.
|
||||
*/
|
||||
|
||||
void (*traceSetHandler(void (*function)(int level, char_t *buf)))
|
||||
void (*traceSetHandler(void (*function)(int level, char_t *buf)))
|
||||
(int level, char *buf)
|
||||
{
|
||||
void (*oldHandler)(int level, char_t *buf);
|
||||
@@ -188,7 +188,7 @@ char_t *strlower(char_t *string)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Convert a string to upper case
|
||||
*/
|
||||
|
||||
@@ -215,7 +215,7 @@ char_t *strupper(char_t *string)
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Convert integer to ascii string. Allow a NULL string in which case we
|
||||
* allocate a dynamic buffer.
|
||||
* allocate a dynamic buffer.
|
||||
*/
|
||||
|
||||
char_t *stritoa(int n, char_t *string, int width)
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
* GoAhead Web Server header. This defines the Web public APIs
|
||||
*/
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
#include <netinet/in.h>
|
||||
#endif /* NW */
|
||||
|
||||
#ifdef SCOV5
|
||||
#ifdef SCOV5
|
||||
#include <sys/types.h>
|
||||
#include <stdio.h>
|
||||
#include "sys/socket.h"
|
||||
@@ -279,8 +279,8 @@ struct timeval
|
||||
#endif /* NW */
|
||||
|
||||
/********************************** Unicode ***********************************/
|
||||
/*
|
||||
* Constants and limits. Also FNAMESIZE and PATHSIZE are currently defined
|
||||
/*
|
||||
* Constants and limits. Also FNAMESIZE and PATHSIZE are currently defined
|
||||
* in param.h to be 128 and 512
|
||||
*/
|
||||
#define TRACE_MAX (4096 - 48)
|
||||
@@ -312,8 +312,8 @@ typedef unsigned short char_t;
|
||||
typedef unsigned short uchar_t;
|
||||
|
||||
/*
|
||||
* Text size of buffer macro. A buffer bytes will hold (size / char size)
|
||||
* characters.
|
||||
* Text size of buffer macro. A buffer bytes will hold (size / char size)
|
||||
* characters.
|
||||
*/
|
||||
#define TSZ(x) (sizeof(x) / sizeof(char_t))
|
||||
|
||||
@@ -653,7 +653,7 @@ typedef struct {
|
||||
#endif /* __NO_PACK */
|
||||
|
||||
/*
|
||||
* Allocation flags
|
||||
* Allocation flags
|
||||
*/
|
||||
#define VALUE_ALLOCATE 0x1
|
||||
|
||||
@@ -691,7 +691,7 @@ typedef struct {
|
||||
* ^ ^ ^ ^
|
||||
* | | | |
|
||||
* rq->buf rq->servp rq->endp rq->enduf
|
||||
*
|
||||
*
|
||||
* The queue is empty when servp == endp. This means that the queue will hold
|
||||
* at most rq->buflen -1 bytes. It is the fillers responsibility to ensure
|
||||
* the ringq is never filled such that servp == endp.
|
||||
@@ -727,8 +727,8 @@ typedef struct {
|
||||
#endif /* B_STATS */
|
||||
|
||||
/*
|
||||
* Block classes are: 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192,
|
||||
* 16384, 32768, 65536
|
||||
* Block classes are: 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192,
|
||||
* 16384, 32768, 65536
|
||||
*/
|
||||
typedef struct {
|
||||
union {
|
||||
@@ -810,7 +810,7 @@ extern int cronFree(cron_t *cp);
|
||||
/* SOCKET */
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Socket flags
|
||||
* Socket flags
|
||||
*/
|
||||
|
||||
#if ((defined (WIN) || defined (CE)) && defined (WEBS))
|
||||
@@ -846,7 +846,7 @@ extern int cronFree(cron_t *cp);
|
||||
/*
|
||||
* Handler event masks
|
||||
*/
|
||||
#define SOCKET_READABLE 0x2 /* Make socket readable */
|
||||
#define SOCKET_READABLE 0x2 /* Make socket readable */
|
||||
#define SOCKET_WRITABLE 0x4 /* Make socket writable */
|
||||
#define SOCKET_EXCEPTION 0x8 /* Interested in exceptions */
|
||||
#define EMF_SOCKET_MESSAGE (WM_USER+13)
|
||||
@@ -858,7 +858,7 @@ extern int cronFree(cron_t *cp);
|
||||
#endif /* LITTLEFOOT */
|
||||
|
||||
typedef void (*socketHandler_t)(int sid, int mask, int data);
|
||||
typedef int (*socketAccept_t)(int sid, char *ipaddr, int port,
|
||||
typedef int (*socketAccept_t)(int sid, char *ipaddr, int port,
|
||||
int listenSid);
|
||||
typedef struct {
|
||||
char host[64]; /* Host name */
|
||||
@@ -1025,7 +1025,7 @@ extern int scriptEval(int engine, char_t *cmd, char_t **rslt, int chan);
|
||||
|
||||
extern void socketClose(void);
|
||||
extern void socketCloseConnection(int sid);
|
||||
extern void socketCreateHandler(int sid, int mask, socketHandler_t
|
||||
extern void socketCreateHandler(int sid, int mask, socketHandler_t
|
||||
handler, int arg);
|
||||
extern void socketDeleteHandler(int sid);
|
||||
extern int socketEof(int sid);
|
||||
@@ -1036,7 +1036,7 @@ extern int socketGets(int sid, char_t **buf);
|
||||
extern int socketGetPort(int sid);
|
||||
extern int socketInputBuffered(int sid);
|
||||
extern int socketOpen(void);
|
||||
extern int socketOpenConnection(char *host, int port,
|
||||
extern int socketOpenConnection(char *host, int port,
|
||||
socketAccept_t accept, int flags);
|
||||
extern void socketProcess(int hid);
|
||||
extern int socketRead(int sid, char *buf, int len);
|
||||
@@ -1047,7 +1047,7 @@ extern int socketSelect(int hid, int timeout);
|
||||
extern int socketGetHandle(int sid);
|
||||
extern int socketSetBlock(int sid, int flags);
|
||||
extern int socketGetBlock(int sid);
|
||||
extern int socketAlloc(char *host, int port, socketAccept_t accept,
|
||||
extern int socketAlloc(char *host, int port, socketAccept_t accept,
|
||||
int flags);
|
||||
extern void socketFree(int sid);
|
||||
extern int socketGetError(void);
|
||||
@@ -1074,9 +1074,9 @@ extern void symSubClose(void);
|
||||
|
||||
extern void trace(int lev, char_t *fmt, ...);
|
||||
extern void traceRaw(char_t *buf);
|
||||
extern void (*traceSetHandler(void (*function)(int level, char_t *buf)))
|
||||
extern void (*traceSetHandler(void (*function)(int level, char_t *buf)))
|
||||
(int level, char_t *buf);
|
||||
|
||||
|
||||
extern value_t valueInteger(long value);
|
||||
extern value_t valueString(char_t *value, int flags);
|
||||
extern value_t valueErrmsg(char_t *value);
|
||||
|
||||
@@ -128,12 +128,12 @@ dbTable_t accessTable = {
|
||||
};
|
||||
#endif /* #ifdef UEMF */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Database Identifier returned from dbOpen()
|
||||
*/
|
||||
static int didUM = -1;
|
||||
static int didUM = -1;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Configuration database persist filename
|
||||
*/
|
||||
static char_t *saveFilename = NULL;
|
||||
@@ -146,7 +146,7 @@ static bool_t umCheckName(char_t *name);
|
||||
|
||||
/*********************************** Code *************************************/
|
||||
/*
|
||||
* umOpen() registers the UM tables in the fake emf-database
|
||||
* umOpen() registers the UM tables in the fake emf-database
|
||||
*/
|
||||
|
||||
int umOpen(void)
|
||||
@@ -175,7 +175,7 @@ int umOpen(void)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* umClose() frees up the UM tables in the fake emf-database
|
||||
* umClose() frees up the UM tables in the fake emf-database
|
||||
*/
|
||||
|
||||
void umClose(void)
|
||||
@@ -213,7 +213,7 @@ int umCommit(char_t *filename)
|
||||
}
|
||||
|
||||
a_assert (saveFilename && *saveFilename);
|
||||
trace(3, T("UM: Writing User Configuration to file <%s>\n"),
|
||||
trace(3, T("UM: Writing User Configuration to file <%s>\n"),
|
||||
saveFilename);
|
||||
|
||||
return dbSave(didUM, saveFilename, 0);
|
||||
@@ -236,7 +236,7 @@ int umRestore(char_t *filename)
|
||||
|
||||
a_assert(saveFilename && *saveFilename);
|
||||
|
||||
trace(3, T("UM: Loading User Configuration from file <%s>\n"),
|
||||
trace(3, T("UM: Loading User Configuration from file <%s>\n"),
|
||||
saveFilename);
|
||||
|
||||
/*
|
||||
@@ -248,7 +248,7 @@ int umRestore(char_t *filename)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Encrypt/Decrypt a text string.
|
||||
* Encrypt/Decrypt a text string.
|
||||
* Returns the number of characters encrypted.
|
||||
*/
|
||||
|
||||
@@ -269,7 +269,7 @@ static int umEncryptString(char_t *textString)
|
||||
* Do not produce encrypted text with embedded linefeeds or tabs.
|
||||
* Simply use existing character.
|
||||
*/
|
||||
if (enChar && !gisspace(enChar))
|
||||
if (enChar && !gisspace(enChar))
|
||||
*textString = enChar;
|
||||
/*
|
||||
* Increment all pointers.
|
||||
@@ -305,11 +305,11 @@ static char_t *umGetFirstRowData(char_t *tableName, char_t *columnName)
|
||||
|
||||
row = 0;
|
||||
/*
|
||||
* Move through table until we retrieve the first row with non-null
|
||||
* Move through table until we retrieve the first row with non-null
|
||||
* column data.
|
||||
*/
|
||||
columnData = NULL;
|
||||
while ((check = dbReadStr(didUM, tableName, columnName, row++,
|
||||
while ((check = dbReadStr(didUM, tableName, columnName, row++,
|
||||
&columnData)) == 0 || (check == DB_ERR_ROW_DELETED)) {
|
||||
if (columnData && *columnData) {
|
||||
return columnData;
|
||||
@@ -321,11 +321,11 @@ static char_t *umGetFirstRowData(char_t *tableName, char_t *columnName)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* umGetNextRowData() - return a pointer to the first non-blank
|
||||
* umGetNextRowData() - return a pointer to the first non-blank
|
||||
* key value following the given one.
|
||||
*/
|
||||
|
||||
static char_t *umGetNextRowData(char_t *tableName, char_t *columnName,
|
||||
static char_t *umGetNextRowData(char_t *tableName, char_t *columnName,
|
||||
char_t *keyLast)
|
||||
{
|
||||
char_t *key;
|
||||
@@ -341,7 +341,7 @@ static char_t *umGetNextRowData(char_t *tableName, char_t *columnName,
|
||||
row = 0;
|
||||
key = NULL;
|
||||
|
||||
while ((((check = dbReadStr(didUM, tableName, columnName, row++,
|
||||
while ((((check = dbReadStr(didUM, tableName, columnName, row++,
|
||||
&key)) == 0) || (check == DB_ERR_ROW_DELETED)) &&
|
||||
((key == NULL) || (gstrcmp(key, keyLast) != 0))) {
|
||||
}
|
||||
@@ -354,7 +354,7 @@ static char_t *umGetNextRowData(char_t *tableName, char_t *columnName,
|
||||
/*
|
||||
* Move through table until we retrieve the next row with a non-null key
|
||||
*/
|
||||
while (((check = dbReadStr(didUM, tableName, columnName, row++, &key))
|
||||
while (((check = dbReadStr(didUM, tableName, columnName, row++, &key))
|
||||
== 0) || (check == DB_ERR_ROW_DELETED)) {
|
||||
if (key && *key && (gstrcmp(key, keyLast) != 0)) {
|
||||
return key;
|
||||
@@ -369,7 +369,7 @@ static char_t *umGetNextRowData(char_t *tableName, char_t *columnName,
|
||||
* umAddUser() - Adds a user to the "users" table.
|
||||
*/
|
||||
|
||||
int umAddUser(char_t *user, char_t *pass, char_t *group,
|
||||
int umAddUser(char_t *user, char_t *pass, char_t *group,
|
||||
bool_t prot, bool_t disabled)
|
||||
{
|
||||
int row;
|
||||
@@ -424,7 +424,7 @@ int umAddUser(char_t *user, char_t *pass, char_t *group,
|
||||
dbWriteStr(didUM, UM_USER_TABLENAME, UM_PASS, row, password);
|
||||
bfree(B_L, password);
|
||||
dbWriteStr(didUM, UM_USER_TABLENAME, UM_GROUP, row, group);
|
||||
dbWriteInt(didUM, UM_USER_TABLENAME, UM_PROT, row, prot);
|
||||
dbWriteInt(didUM, UM_USER_TABLENAME, UM_PROT, row, prot);
|
||||
dbWriteInt(didUM, UM_USER_TABLENAME, UM_DISABLE, row, disabled);
|
||||
|
||||
return 0;
|
||||
@@ -446,14 +446,14 @@ int umDeleteUser(char_t *user)
|
||||
*/
|
||||
if (umGetUserProtected(user)) {
|
||||
return UM_ERR_PROTECTED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* If found, delete the user from the database
|
||||
*/
|
||||
if ((row = dbSearchStr(didUM, UM_USER_TABLENAME, UM_NAME, user, 0)) >= 0) {
|
||||
return dbDeleteRow(didUM, UM_USER_TABLENAME, row);
|
||||
}
|
||||
}
|
||||
|
||||
return UM_ERR_NOT_FOUND;
|
||||
}
|
||||
@@ -472,7 +472,7 @@ char_t *umGetFirstUser(void)
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* umGetNextUser() Returns the next user found in the "users" table after
|
||||
* the given user.
|
||||
* the given user.
|
||||
*/
|
||||
|
||||
char_t *umGetNextUser(char_t *userLast)
|
||||
@@ -697,14 +697,14 @@ int umSetUserProtected(char_t *user, bool_t protect)
|
||||
* umAddGroup() adds a group to the "Group" table
|
||||
*/
|
||||
|
||||
int umAddGroup(char_t *group, short priv, accessMeth_t am,
|
||||
int umAddGroup(char_t *group, short priv, accessMeth_t am,
|
||||
bool_t prot, bool_t disabled)
|
||||
{
|
||||
int row;
|
||||
|
||||
a_assert(group && *group);
|
||||
trace(3, T("UM: Adding group <%s>\n"), group);
|
||||
|
||||
|
||||
/*
|
||||
* Do not allow duplicates
|
||||
*/
|
||||
@@ -761,14 +761,14 @@ int umDeleteGroup(char_t *group)
|
||||
*/
|
||||
if (umGetGroupInUse(group)) {
|
||||
return UM_ERR_IN_USE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check to see if the group is delete-protected
|
||||
*/
|
||||
if (umGetGroupProtected(group)) {
|
||||
return UM_ERR_PROTECTED;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Find the row of the group to delete
|
||||
@@ -812,14 +812,14 @@ bool_t umGetGroupInUse(char_t *group)
|
||||
*/
|
||||
if (dbSearchStr(didUM, UM_USER_TABLENAME, UM_GROUP, group, 0) >= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Second, check the access limit table
|
||||
*/
|
||||
if (dbSearchStr(didUM, UM_ACCESS_TABLENAME, UM_GROUP, group, 0) >= 0) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@@ -919,7 +919,7 @@ int umSetGroupPrivilege(char_t *group, short privilege)
|
||||
row = dbSearchStr(didUM, UM_GROUP_TABLENAME, UM_NAME, group, 0);
|
||||
|
||||
if (row >= 0) {
|
||||
return dbWriteInt(didUM, UM_GROUP_TABLENAME, UM_PRIVILEGE, row,
|
||||
return dbWriteInt(didUM, UM_GROUP_TABLENAME, UM_PRIVILEGE, row,
|
||||
(int)privilege);
|
||||
} else {
|
||||
return UM_ERR_NOT_FOUND;
|
||||
@@ -960,7 +960,7 @@ int umSetGroupEnabled(char_t *group, bool_t enabled)
|
||||
row = dbSearchStr(didUM, UM_GROUP_TABLENAME, UM_NAME, group, 0);
|
||||
|
||||
if (row >= 0) {
|
||||
return dbWriteInt(didUM, UM_GROUP_TABLENAME, UM_DISABLE, row,
|
||||
return dbWriteInt(didUM, UM_GROUP_TABLENAME, UM_DISABLE, row,
|
||||
(int) !enabled);
|
||||
} else {
|
||||
return UM_ERR_NOT_FOUND;
|
||||
@@ -1001,7 +1001,7 @@ int umSetGroupProtected(char_t *group, bool_t protect)
|
||||
row = dbSearchStr(didUM, UM_GROUP_TABLENAME, UM_NAME, group, 0);
|
||||
|
||||
if (row >= 0) {
|
||||
return dbWriteInt(didUM, UM_GROUP_TABLENAME, UM_PROT, row,
|
||||
return dbWriteInt(didUM, UM_GROUP_TABLENAME, UM_PROT, row,
|
||||
(int) protect);
|
||||
} else {
|
||||
return UM_ERR_NOT_FOUND;
|
||||
@@ -1085,7 +1085,7 @@ char_t *umGetFirstAccessLimit(void)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* umGetNextAccessLimit() - return a pointer to the first non-blank
|
||||
* umGetNextAccessLimit() - return a pointer to the first non-blank
|
||||
* access limit following the given one
|
||||
*/
|
||||
|
||||
@@ -1124,7 +1124,7 @@ accessMeth_t umGetAccessLimitMethod(char_t *url)
|
||||
|
||||
if (row >= 0) {
|
||||
dbReadInt(didUM, UM_ACCESS_TABLENAME, UM_METHOD, row, &am);
|
||||
}
|
||||
}
|
||||
|
||||
return (accessMeth_t) am;
|
||||
}
|
||||
@@ -1181,7 +1181,7 @@ int umSetAccessLimitSecure(char_t *url, short secure)
|
||||
row = dbSearchStr(didUM, UM_ACCESS_TABLENAME, UM_NAME, url, 0);
|
||||
|
||||
if (row >= 0) {
|
||||
return dbWriteInt(didUM, UM_ACCESS_TABLENAME, UM_SECURE, row,
|
||||
return dbWriteInt(didUM, UM_ACCESS_TABLENAME, UM_SECURE, row,
|
||||
(int)secure);
|
||||
} else {
|
||||
return UM_ERR_NOT_FOUND;
|
||||
@@ -1238,7 +1238,7 @@ char_t *umGetAccessLimit(char_t *url)
|
||||
{
|
||||
char_t *urlRet, *urlCheck, *lastChar;
|
||||
int len;
|
||||
|
||||
|
||||
a_assert(url && *url);
|
||||
urlRet = NULL;
|
||||
urlCheck = bstrdup(B_L, url);
|
||||
@@ -1257,13 +1257,13 @@ char_t *umGetAccessLimit(char_t *url)
|
||||
lastChar = urlCheck + len;
|
||||
lastChar--;
|
||||
|
||||
while ((lastChar >= urlCheck) && ((*lastChar == '/') ||
|
||||
while ((lastChar >= urlCheck) && ((*lastChar == '/') ||
|
||||
(*lastChar == '\\'))) {
|
||||
*lastChar = 0;
|
||||
lastChar--;
|
||||
}
|
||||
|
||||
while ((lastChar >= urlCheck) && (*lastChar != '/') &&
|
||||
while ((lastChar >= urlCheck) && (*lastChar != '/') &&
|
||||
(*lastChar != '\\')) {
|
||||
*lastChar = 0;
|
||||
lastChar--;
|
||||
@@ -1286,7 +1286,7 @@ accessMeth_t umGetAccessMethodForURL(char_t *url)
|
||||
{
|
||||
accessMeth_t amRet;
|
||||
char_t *urlHavingLimit, *group;
|
||||
|
||||
|
||||
urlHavingLimit = umGetAccessLimit(url);
|
||||
if (urlHavingLimit) {
|
||||
group = umGetAccessLimitGroup(urlHavingLimit);
|
||||
@@ -1315,7 +1315,7 @@ bool_t umUserCanAccessURL(char_t *user, char_t *url)
|
||||
accessMeth_t amURL;
|
||||
char_t *group, *usergroup, *urlHavingLimit;
|
||||
short priv;
|
||||
|
||||
|
||||
a_assert(user && *user);
|
||||
a_assert(url && *url);
|
||||
|
||||
@@ -1372,15 +1372,15 @@ bool_t umUserCanAccessURL(char_t *user, char_t *url)
|
||||
}
|
||||
|
||||
/*
|
||||
* If the access method for the URL is AM_NONE then
|
||||
* If the access method for the URL is AM_NONE then
|
||||
* the file "doesn't exist".
|
||||
*/
|
||||
if (amURL == AM_NONE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* If Access Limit has a group specified, then the user must be a
|
||||
* If Access Limit has a group specified, then the user must be a
|
||||
* member of that group
|
||||
*/
|
||||
if (group && *group) {
|
||||
@@ -1399,10 +1399,10 @@ bool_t umUserCanAccessURL(char_t *user, char_t *url)
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Otherwise, user can access the URL
|
||||
* Otherwise, user can access the URL
|
||||
*/
|
||||
return TRUE;
|
||||
|
||||
|
||||
@@ -30,22 +30,22 @@
|
||||
static void formAddUser(webs_t wp, char_t *path, char_t *query);
|
||||
static void formDeleteUser(webs_t wp, char_t *path, char_t *query);
|
||||
static void formDisplayUser(webs_t wp, char_t *path, char_t *query);
|
||||
static int aspGenerateUserList(int eid, webs_t wp,
|
||||
static int aspGenerateUserList(int eid, webs_t wp,
|
||||
int argc, char_t **argv);
|
||||
|
||||
static void formAddGroup(webs_t wp, char_t *path, char_t *query);
|
||||
static void formDeleteGroup(webs_t wp, char_t *path, char_t *query);
|
||||
static int aspGenerateGroupList(int eid, webs_t wp,
|
||||
static int aspGenerateGroupList(int eid, webs_t wp,
|
||||
int argc, char_t **argv);
|
||||
|
||||
static void formAddAccessLimit(webs_t wp, char_t *path, char_t *query);
|
||||
static void formDeleteAccessLimit(webs_t wp, char_t *path, char_t *query);
|
||||
static int aspGenerateAccessLimitList(int eid, webs_t wp,
|
||||
static int aspGenerateAccessLimitList(int eid, webs_t wp,
|
||||
int argc, char_t **argv);
|
||||
|
||||
static int aspGenerateAccessMethodList(int eid, webs_t wp,
|
||||
static int aspGenerateAccessMethodList(int eid, webs_t wp,
|
||||
int argc, char_t **argv);
|
||||
static int aspGeneratePrivilegeList(int eid, webs_t wp,
|
||||
static int aspGeneratePrivilegeList(int eid, webs_t wp,
|
||||
int argc, char_t **argv);
|
||||
|
||||
static void formSaveUserManagement(webs_t wp, char_t *path, char_t *query);
|
||||
@@ -92,12 +92,12 @@ static void formAddUser(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
userid = websGetVar(wp, T("user"), T(""));
|
||||
pass1 = websGetVar(wp, T("password"), T(""));
|
||||
pass2 = websGetVar(wp, T("passconf"), T(""));
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
enabled = websGetVar(wp, T("enabled"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
userid = websGetVar(wp, T("user"), T(""));
|
||||
pass1 = websGetVar(wp, T("password"), T(""));
|
||||
pass2 = websGetVar(wp, T("passconf"), T(""));
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
enabled = websGetVar(wp, T("enabled"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -163,8 +163,8 @@ static void formDeleteUser(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
userid = websGetVar(wp, T("user"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
userid = websGetVar(wp, T("user"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -198,8 +198,8 @@ static void formDisplayUser(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
userid = websGetVar(wp, T("user"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
userid = websGetVar(wp, T("user"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websWrite(wp, T("<body>"));
|
||||
@@ -234,14 +234,14 @@ static int aspGenerateUserList(int eid, webs_t wp, int argc, char_t **argv)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
nBytes = websWrite(wp,
|
||||
nBytes = websWrite(wp,
|
||||
T("<SELECT NAME=\"user\" SIZE=\"3\" TITLE=\"Select a User\">"));
|
||||
row = 0;
|
||||
userid = umGetFirstUser();
|
||||
nBytesSent = 0;
|
||||
|
||||
while (userid && (nBytes > 0)) {
|
||||
nBytes = websWrite(wp, T("<OPTION VALUE=\"%s\">%s\n"),
|
||||
nBytes = websWrite(wp, T("<OPTION VALUE=\"%s\">%s\n"),
|
||||
userid, userid);
|
||||
userid = umGetNextUser(userid);
|
||||
nBytesSent += nBytes;
|
||||
@@ -267,11 +267,11 @@ static void formAddGroup(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
method = websGetVar(wp, T("method"), T(""));
|
||||
enabled = websGetVar(wp, T("enabled"), T(""));
|
||||
privilege = websGetVar(wp, T("privilege"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
method = websGetVar(wp, T("method"), T(""));
|
||||
enabled = websGetVar(wp, T("enabled"), T(""));
|
||||
privilege = websGetVar(wp, T("privilege"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -319,7 +319,7 @@ static void formAddGroup(webs_t wp, char_t *path, char_t *query)
|
||||
websWrite(wp, T("Unable to add group, \"%s\", code: %d "),
|
||||
group, nCheck);
|
||||
} else {
|
||||
websWrite(wp, T("Group, \"%s\" was successfully added."),
|
||||
websWrite(wp, T("Group, \"%s\" was successfully added."),
|
||||
group);
|
||||
}
|
||||
}
|
||||
@@ -340,8 +340,8 @@ static void formDeleteGroup(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -379,7 +379,7 @@ static int aspGenerateGroupList(int eid, webs_t wp, int argc, char_t **argv)
|
||||
|
||||
row = 0;
|
||||
nBytesSent = 0;
|
||||
nBytes = websWrite(wp,
|
||||
nBytes = websWrite(wp,
|
||||
T("<SELECT NAME=\"group\" SIZE=\"3\" TITLE=\"Select a Group\">"));
|
||||
/*
|
||||
* Add a special "<NONE>" element to allow de-selection
|
||||
@@ -412,11 +412,11 @@ static void formAddAccessLimit(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
url = websGetVar(wp, T("url"), T(""));
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
method = websGetVar(wp, T("method"), T(""));
|
||||
secure = websGetVar(wp, T("secure"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
url = websGetVar(wp, T("url"), T(""));
|
||||
group = websGetVar(wp, T("group"), T(""));
|
||||
method = websGetVar(wp, T("method"), T(""));
|
||||
secure = websGetVar(wp, T("secure"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -466,8 +466,8 @@ static void formDeleteAccessLimit(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
url = websGetVar(wp, T("url"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
url = websGetVar(wp, T("url"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -475,10 +475,10 @@ static void formDeleteAccessLimit(webs_t wp, char_t *path, char_t *query)
|
||||
if (gstricmp(ok, T("ok")) != 0) {
|
||||
websWrite(wp, T("Delete Access Limit Cancelled"));
|
||||
} else if (umDeleteAccessLimit(url) != 0) {
|
||||
websWrite(wp, T("ERROR: Unable to delete Access Limit for [%s]"),
|
||||
websWrite(wp, T("ERROR: Unable to delete Access Limit for [%s]"),
|
||||
url);
|
||||
} else {
|
||||
websWrite(wp, T("Access Limit for [%s], was successfully deleted."),
|
||||
websWrite(wp, T("Access Limit for [%s], was successfully deleted."),
|
||||
url);
|
||||
}
|
||||
|
||||
@@ -492,7 +492,7 @@ static void formDeleteAccessLimit(webs_t wp, char_t *path, char_t *query)
|
||||
* Generate HTML to create a list box containing the access limits
|
||||
*/
|
||||
|
||||
static int aspGenerateAccessLimitList(int eid, webs_t wp,
|
||||
static int aspGenerateAccessLimitList(int eid, webs_t wp,
|
||||
int argc, char_t **argv)
|
||||
{
|
||||
char_t *url;
|
||||
@@ -502,7 +502,7 @@ static int aspGenerateAccessLimitList(int eid, webs_t wp,
|
||||
|
||||
row = nBytesSent = 0;
|
||||
url = umGetFirstAccessLimit();
|
||||
nBytes = websWrite(wp,
|
||||
nBytes = websWrite(wp,
|
||||
T("<SELECT NAME=\"url\" SIZE=\"3\" TITLE=\"Select a URL\">"));
|
||||
|
||||
while (url && (nBytes > 0)) {
|
||||
@@ -521,22 +521,22 @@ static int aspGenerateAccessLimitList(int eid, webs_t wp,
|
||||
* Generate HTML to create a list box containing the access methods
|
||||
*/
|
||||
|
||||
static int aspGenerateAccessMethodList(int eid, webs_t wp,
|
||||
static int aspGenerateAccessMethodList(int eid, webs_t wp,
|
||||
int argc, char_t **argv)
|
||||
{
|
||||
int nBytes;
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
nBytes = websWrite(wp,
|
||||
nBytes = websWrite(wp,
|
||||
T("<SELECT NAME=\"method\" SIZE=\"3\" TITLE=\"Select a Method\">"));
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">FULL ACCESS\n"),
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">FULL ACCESS\n"),
|
||||
AM_FULL);
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">BASIC ACCESS\n"),
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">BASIC ACCESS\n"),
|
||||
AM_BASIC);
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\" SELECTED>DIGEST ACCESS\n"),
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\" SELECTED>DIGEST ACCESS\n"),
|
||||
AM_DIGEST);
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">NO ACCESS\n"),
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">NO ACCESS\n"),
|
||||
AM_NONE);
|
||||
nBytes += websWrite(wp, T("</SELECT>"));
|
||||
|
||||
@@ -547,7 +547,7 @@ static int aspGenerateAccessMethodList(int eid, webs_t wp,
|
||||
* Generate HTML to create a list box containing privileges
|
||||
*/
|
||||
|
||||
static int aspGeneratePrivilegeList(int eid, webs_t wp,
|
||||
static int aspGeneratePrivilegeList(int eid, webs_t wp,
|
||||
int argc, char_t **argv)
|
||||
{
|
||||
int nBytes;
|
||||
@@ -558,7 +558,7 @@ static int aspGeneratePrivilegeList(int eid, webs_t wp,
|
||||
nBytes += websWrite(wp, T("MULTIPLE TITLE=\"Choose Privileges\">"));
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">READ\n"), PRIV_READ);
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">EXECUTE\n"), PRIV_WRITE);
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">ADMINISTRATE\n"),
|
||||
nBytes += websWrite(wp, T("<OPTION VALUE=\"%d\">ADMINISTRATE\n"),
|
||||
PRIV_ADMIN);
|
||||
nBytes += websWrite(wp, T("</SELECT>"));
|
||||
|
||||
@@ -576,7 +576,7 @@ static void formSaveUserManagement(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
@@ -605,7 +605,7 @@ static void formLoadUserManagement(webs_t wp, char_t *path, char_t *query)
|
||||
|
||||
a_assert(wp);
|
||||
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
ok = websGetVar(wp, T("ok"), T(""));
|
||||
|
||||
websHeader(wp);
|
||||
websMsgStart(wp);
|
||||
|
||||
@@ -47,7 +47,7 @@ char_t *websUrlType(char_t *url, char_t *buf, int charCnt)
|
||||
gstrcpy(buf, T("text/plain"));
|
||||
return buf;
|
||||
}
|
||||
if (websUrlParse(url, &parsebuf, NULL, NULL, NULL, NULL, NULL,
|
||||
if (websUrlParse(url, &parsebuf, NULL, NULL, NULL, NULL, NULL,
|
||||
NULL, &ext) < 0) {
|
||||
gstrcpy(buf, T("text/plain"));
|
||||
return buf;
|
||||
@@ -72,8 +72,8 @@ char_t *websUrlType(char_t *url, char_t *buf, int charCnt)
|
||||
* This must be freed by the caller. NOTE: tag is not yet fully supported.
|
||||
*/
|
||||
|
||||
int websUrlParse(char_t *url, char_t **pbuf, char_t **phost, char_t **ppath,
|
||||
char_t **pport, char_t **pquery, char_t **pproto, char_t **ptag,
|
||||
int websUrlParse(char_t *url, char_t **pbuf, char_t **phost, char_t **ppath,
|
||||
char_t **pport, char_t **pquery, char_t **pproto, char_t **ptag,
|
||||
char_t **pext)
|
||||
{
|
||||
char_t *tok, *cp, *host, *path, *port, *proto, *tag, *query, *ext;
|
||||
@@ -128,7 +128,7 @@ int websUrlParse(char_t *url, char_t **pbuf, char_t **phost, char_t **ppath,
|
||||
}
|
||||
if ((cp = gstrchr(tok, '/')) != NULL) {
|
||||
/*
|
||||
* If a full URL is supplied, we need to copy the host and port
|
||||
* If a full URL is supplied, we need to copy the host and port
|
||||
* portions into static buffers.
|
||||
*/
|
||||
c = *cp;
|
||||
@@ -155,7 +155,7 @@ int websUrlParse(char_t *url, char_t **pbuf, char_t **phost, char_t **ppath,
|
||||
query = cp;
|
||||
path = tok;
|
||||
tok = query;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse the fragment identifier
|
||||
|
||||
@@ -29,7 +29,7 @@ static char_t map64[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
@@ -83,7 +83,7 @@ int websDecode64(char_t *outbuf, char_t *string, int outlen)
|
||||
error(E_L, E_LOG, T("Bad string: %s at %c index %d"), string,
|
||||
c, i);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
shiftbuf = shiftbuf | (c << shift);
|
||||
shift -= 6;
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ static int compile(char_t *fileList, char_t *prefix)
|
||||
|
||||
time(&now);
|
||||
fprintf(stdout, "/*\n * webrom.c -- Compiled Web Pages\n *\n");
|
||||
fprintf(stdout, " * Compiled by GoAhead WebCompile: %s */\n\n",
|
||||
fprintf(stdout, " * Compiled by GoAhead WebCompile: %s */\n\n",
|
||||
gctime(&now));
|
||||
fprintf(stdout, "#include \"wsIntrn.h\"\n\n");
|
||||
fprintf(stdout, "#ifndef WEBS_PAGE_ROM\n");
|
||||
@@ -109,7 +109,7 @@ static int compile(char_t *fileList, char_t *prefix)
|
||||
}
|
||||
if (gstat(file, &sbuf) == 0 && sbuf.st_mode & S_IFDIR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if ((fd = gopen(file, O_RDONLY | O_BINARY)) < 0) {
|
||||
fprintf(stderr, "Can't open file %s\n", file);
|
||||
return -1;
|
||||
@@ -170,12 +170,12 @@ static int compile(char_t *fileList, char_t *prefix)
|
||||
fprintf(stdout, " { T(\"/%s\"), 0, 0 },\n", cp);
|
||||
continue;
|
||||
}
|
||||
fprintf(stdout, " { T(\"/%s\"), page_%d, %d },\n", cp, nFile,
|
||||
fprintf(stdout, " { T(\"/%s\"), page_%d, %d },\n", cp, nFile,
|
||||
sbuf.st_size);
|
||||
nFile++;
|
||||
}
|
||||
fclose(lp);
|
||||
|
||||
fclose(lp);
|
||||
|
||||
fprintf(stdout, " { 0, 0, 0 },\n");
|
||||
fprintf(stdout, "};\n");
|
||||
fprintf(stdout, "#endif /* WEBS_PAGE_ROM */\n");
|
||||
|
||||
@@ -57,7 +57,7 @@ typedef struct {
|
||||
|
||||
/* The following holds the pointer to an allocated websTimer_t structure .
|
||||
* Using this method only one timer can be active at a time, but
|
||||
* for the WebServer, this should be OK.
|
||||
* for the WebServer, this should be OK.
|
||||
*/
|
||||
websTimer_t *tp;
|
||||
|
||||
@@ -75,7 +75,7 @@ static void memLeaks(void);
|
||||
#endif
|
||||
static timer_t timer_id;
|
||||
static void rtems_httpd_daemon(rtems_task_argument args);
|
||||
|
||||
|
||||
/*********************************** Code *************************************/
|
||||
/*
|
||||
* Main -- entry point from RTEMS
|
||||
@@ -90,7 +90,7 @@ int rtems_initialize_webserver(void)
|
||||
* Default HTTPD priority.
|
||||
**********************************************************************/
|
||||
priority = 40;
|
||||
|
||||
|
||||
sc = rtems_task_create(rtems_build_name('H', 'T', 'P', 'D'),
|
||||
priority, 8*1024,
|
||||
RTEMS_PREEMPT | RTEMS_NO_TIMESLICE | RTEMS_NO_ASR |
|
||||
@@ -106,7 +106,7 @@ int rtems_initialize_webserver(void)
|
||||
if (sc != RTEMS_SUCCESSFUL)
|
||||
{
|
||||
return(RTEMS_UNSATISFIED);
|
||||
}
|
||||
}
|
||||
|
||||
return(RTEMS_SUCCESSFUL);
|
||||
|
||||
@@ -116,7 +116,7 @@ static void
|
||||
rtems_httpd_daemon(rtems_task_argument args)
|
||||
{
|
||||
/*
|
||||
* Initialize the memory allocator. Allow use of malloc and start with a
|
||||
* Initialize the memory allocator. Allow use of malloc and start with a
|
||||
* 10K heap.
|
||||
*/
|
||||
bopen(NULL, (10 * 1024), B_USE_MALLOC);
|
||||
@@ -185,14 +185,14 @@ static int initWebs(void)
|
||||
socketOpen();
|
||||
|
||||
/*
|
||||
* Define the local Ip address, host name, default home page and the
|
||||
* Define the local Ip address, host name, default home page and the
|
||||
* root web directory.
|
||||
*/
|
||||
if (gethostname(host, sizeof(host)) < 0) {
|
||||
error(E_L, E_LOG, T("Can't get hostname"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
/* intaddr.s_addr = (unsigned long) hostGetByName(host); */
|
||||
if ((hp = gethostbyname(host)) == NULL) {
|
||||
error(E_L, E_LOG, T("Can't get host address"));
|
||||
@@ -228,7 +228,7 @@ static int initWebs(void)
|
||||
#endif
|
||||
websSetPassword(password);
|
||||
|
||||
/*
|
||||
/*
|
||||
* Open the web server on the given port. If that port is taken, try
|
||||
* the next sequential port for up to "retries" attempts.
|
||||
*/
|
||||
@@ -236,14 +236,14 @@ static int initWebs(void)
|
||||
|
||||
/*
|
||||
* First create the URL handlers. Note: handlers are called in sorted order
|
||||
* with the longest path handler examined first. Here we define the security
|
||||
* with the longest path handler examined first. Here we define the security
|
||||
* handler, forms handler and the default web page handler.
|
||||
*/
|
||||
websUrlHandlerDefine(T(""), NULL, 0, websSecurityHandler,
|
||||
websUrlHandlerDefine(T(""), NULL, 0, websSecurityHandler,
|
||||
WEBS_HANDLER_FIRST);
|
||||
websUrlHandlerDefine(T("/goform"), NULL, 0, websFormHandler, 0);
|
||||
websUrlHandlerDefine(T(""), NULL, 0, websDefaultHandler,
|
||||
WEBS_HANDLER_LAST);
|
||||
websUrlHandlerDefine(T(""), NULL, 0, websDefaultHandler,
|
||||
WEBS_HANDLER_LAST);
|
||||
|
||||
/*
|
||||
* Now define two test procedures. Replace these with your application
|
||||
@@ -255,14 +255,14 @@ static int initWebs(void)
|
||||
/*
|
||||
* Create a handler for the default home page
|
||||
*/
|
||||
websUrlHandlerDefine(T("/"), NULL, 0, websHomePageHandler, 0);
|
||||
websUrlHandlerDefine(T("/"), NULL, 0, websHomePageHandler, 0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Test Javascript binding for ASP. This will be invoked when "aspTest" is
|
||||
* embedded in an ASP page. See web/asp.asp for usage. Set browser to
|
||||
* embedded in an ASP page. See web/asp.asp for usage. Set browser to
|
||||
* "localhost/asp.asp" to test.
|
||||
*/
|
||||
|
||||
@@ -286,8 +286,8 @@ static void formTest(webs_t wp, char_t *path, char_t *query)
|
||||
{
|
||||
char_t *name, *address;
|
||||
|
||||
name = websGetVar(wp, T("name"), T("Joe Smith"));
|
||||
address = websGetVar(wp, T("address"), T("1212 Milky Way Ave."));
|
||||
name = websGetVar(wp, T("name"), T("Joe Smith"));
|
||||
address = websGetVar(wp, T("address"), T("1212 Milky Way Ave."));
|
||||
|
||||
websHeader(wp);
|
||||
websWrite(wp, T("<body><h2>Name: %s, Address: %s</h2>\n"), name, address);
|
||||
@@ -342,7 +342,7 @@ void *emfCreateTimer(int delay, void (*routine)(long arg), long arg)
|
||||
bfree(B_L, tp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
act.sa_flags = 0;
|
||||
sigemptyset(&act.sa_mask);
|
||||
@@ -387,7 +387,7 @@ static void timerProc(int signo)
|
||||
websTimer_t wtp = *tp;
|
||||
|
||||
/* Copy the timer structure to a local first and delete it before calling
|
||||
* the function, since the function could create another timer. In this
|
||||
* the function, since the function could create another timer. In this
|
||||
* implementation, only one timer can be allocated at a time.
|
||||
*/
|
||||
|
||||
@@ -420,7 +420,7 @@ static int websHomePageHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
/******************************************************************************/
|
||||
|
||||
#if B_STATS
|
||||
static void memLeaks()
|
||||
static void memLeaks()
|
||||
{
|
||||
int fd=1;
|
||||
|
||||
|
||||
@@ -127,11 +127,11 @@ int websOpenServer(int port, int retries)
|
||||
/*
|
||||
* Optional request log support
|
||||
*/
|
||||
websLogFd = gopen(websLogname, O_CREAT | O_TRUNC | O_APPEND | O_WRONLY,
|
||||
websLogFd = gopen(websLogname, O_CREAT | O_TRUNC | O_APPEND | O_WRONLY,
|
||||
0666);
|
||||
a_assert(websLogFd >= 0);
|
||||
#endif
|
||||
|
||||
|
||||
return websOpenListen(port, retries);
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void websCloseServer(void)
|
||||
*/
|
||||
websCloseListen();
|
||||
|
||||
/*
|
||||
/*
|
||||
* Close each open browser connection and free all resources
|
||||
*/
|
||||
for (wid = websMax; webs && wid >= 0; wid--) {
|
||||
@@ -207,7 +207,7 @@ int websOpenListen(int port, int retries)
|
||||
error(E_L, E_USER, T("Couldn't open a socket on ports %d - %d"),
|
||||
orig, port - 1);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Determine the full URL address to access the home page for this web server
|
||||
@@ -222,7 +222,7 @@ int websOpenListen(int port, int retries)
|
||||
websIpaddrUrl = bstrdup(B_L, websIpaddr);
|
||||
} else {
|
||||
fmtAlloc(&websHostUrl, WEBS_MAX_URL + 80, T("%s:%d"), websHost, port);
|
||||
fmtAlloc(&websIpaddrUrl, WEBS_MAX_URL + 80, T("%s:%d"),
|
||||
fmtAlloc(&websIpaddrUrl, WEBS_MAX_URL + 80, T("%s:%d"),
|
||||
websIpaddr, port);
|
||||
}
|
||||
trace(0, T("webs: Listening for HTTP requests at address %s\n"),
|
||||
@@ -278,8 +278,8 @@ int websAccept(int sid, char *ipaddr, int port, int listenSid)
|
||||
* Check if this is a request from a browser on this system. This is useful
|
||||
* to know for permitting administrative operations only for local access
|
||||
*/
|
||||
if (gstrcmp(wp->ipaddr, T("127.0.0.1")) == 0 ||
|
||||
gstrcmp(wp->ipaddr, websIpaddr) == 0 ||
|
||||
if (gstrcmp(wp->ipaddr, T("127.0.0.1")) == 0 ||
|
||||
gstrcmp(wp->ipaddr, websIpaddr) == 0 ||
|
||||
gstrcmp(wp->ipaddr, websHost) == 0) {
|
||||
wp->flags |= WEBS_LOCAL_REQUEST;
|
||||
}
|
||||
@@ -317,18 +317,18 @@ static void websSocketEvent(int sid, int mask, int iwp)
|
||||
|
||||
if (mask & SOCKET_READABLE) {
|
||||
websReadEvent(wp);
|
||||
}
|
||||
}
|
||||
if (mask & SOCKET_WRITABLE) {
|
||||
if (websValid(wp) && wp->writeSocket) {
|
||||
(*wp->writeSocket)(wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* The webs read handler. This is the primary read event loop. It uses a
|
||||
* state machine to track progress while parsing the HTTP request.
|
||||
* state machine to track progress while parsing the HTTP request.
|
||||
* Note: we never block as the socket is always in non-blocking mode.
|
||||
*/
|
||||
|
||||
@@ -356,7 +356,7 @@ void websReadEvent(webs_t wp)
|
||||
|
||||
/*
|
||||
* Get more input into "text". Returns 0, if more data is needed
|
||||
* to continue, -1 if finished with the request, or 1 if all
|
||||
* to continue, -1 if finished with the request, or 1 if all
|
||||
* required data is available for current state.
|
||||
*/
|
||||
while ((rc = websGetInput(wp, &text, &nbytes)) == 0) {
|
||||
@@ -371,7 +371,7 @@ void websReadEvent(webs_t wp)
|
||||
}
|
||||
|
||||
/*
|
||||
* This is the state machine for the web server.
|
||||
* This is the state machine for the web server.
|
||||
*/
|
||||
switch(wp->state) {
|
||||
case WEBS_BEGIN:
|
||||
@@ -384,7 +384,7 @@ void websReadEvent(webs_t wp)
|
||||
}
|
||||
wp->state = WEBS_HEADER;
|
||||
break;
|
||||
|
||||
|
||||
case WEBS_HEADER:
|
||||
/*
|
||||
* Store more of the HTTP header. As we are doing line reads, we
|
||||
@@ -422,12 +422,12 @@ void websReadEvent(webs_t wp)
|
||||
*
|
||||
nbytes += 1;
|
||||
*/
|
||||
} else
|
||||
} else
|
||||
#endif
|
||||
if (wp->query) {
|
||||
if (wp->query[0] && !(wp->flags & WEBS_POST_DATA)) {
|
||||
/*
|
||||
* Special case where the POST request also had query data
|
||||
* Special case where the POST request also had query data
|
||||
* specified in the URL, ie. url?query_data. In this case
|
||||
* the URL query data is separated by a '&' from the posted
|
||||
* query data.
|
||||
@@ -533,18 +533,18 @@ void websReadEvent(webs_t wp)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Get input from the browser. Return TRUE (!0) if the request has been
|
||||
* handled. Return -1 on errors or if the request has been processed,
|
||||
* Get input from the browser. Return TRUE (!0) if the request has been
|
||||
* handled. Return -1 on errors or if the request has been processed,
|
||||
* 1 if input read, and 0 to instruct the caller to call again for more input.
|
||||
*
|
||||
* Note: socketRead will Return the number of bytes read if successful. This
|
||||
* may be less than the requested "bufsize" and may be zero. It returns -1 for
|
||||
* errors. It returns 0 for EOF. Otherwise it returns the number of bytes
|
||||
* read. Since this may be zero, callers should use socketEof() to
|
||||
* errors. It returns 0 for EOF. Otherwise it returns the number of bytes
|
||||
* read. Since this may be zero, callers should use socketEof() to
|
||||
* distinguish between this and EOF.
|
||||
*/
|
||||
|
||||
static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
|
||||
static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
|
||||
{
|
||||
char_t *text;
|
||||
char buf[WEBS_SOCKET_BUFSIZ+1];
|
||||
@@ -592,7 +592,7 @@ static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
|
||||
|
||||
} else { /* Valid data */
|
||||
/*
|
||||
* Convert to UNICODE if necessary. First be sure the string
|
||||
* Convert to UNICODE if necessary. First be sure the string
|
||||
* is NULL terminated.
|
||||
*/
|
||||
buf[nbytes] = '\0';
|
||||
@@ -621,7 +621,7 @@ static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
|
||||
#ifdef WEBS_SSL_SUPPORT
|
||||
if (wp->flags & WEBS_SECURE) {
|
||||
/*
|
||||
* If state is WEBS_BEGIN and the request is secure, a -1 will
|
||||
* If state is WEBS_BEGIN and the request is secure, a -1 will
|
||||
* usually indicate SSL negotiation
|
||||
*/
|
||||
if (wp->state == WEBS_BEGIN) {
|
||||
@@ -638,8 +638,8 @@ static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
|
||||
|
||||
if (eof) {
|
||||
/*
|
||||
* If this is a post request without content length, process
|
||||
* the request as we now have all the data. Otherwise just
|
||||
* If this is a post request without content length, process
|
||||
* the request as we now have all the data. Otherwise just
|
||||
* close the connection.
|
||||
*/
|
||||
if (wp->state == WEBS_POST) {
|
||||
@@ -666,7 +666,7 @@ static int websGetInput(webs_t wp, char_t **ptext, int *pnbytes)
|
||||
* because if we don't receive the entire header in the first pass
|
||||
* this code assumes we were only expecting a one line header, which
|
||||
* is not necessarily the case. So we weren't processing the whole
|
||||
* header and weren't fufilling requests properly.
|
||||
* header and weren't fufilling requests properly.
|
||||
*/
|
||||
#ifdef UNUSED
|
||||
if (wp->state == WEBS_HEADER && ringqLen(&wp->header) <= 0) {
|
||||
@@ -765,7 +765,7 @@ static int websParseFirst(webs_t wp, char_t *text)
|
||||
* at the start of the URL. Non-proxied will just be local path names.
|
||||
*/
|
||||
host = path = port = proto = query = ext = NULL;
|
||||
if (websUrlParse(url, &buf, &host, &path, &port, &query, &proto,
|
||||
if (websUrlParse(url, &buf, &host, &path, &port, &query, &proto,
|
||||
NULL, &ext) < 0) {
|
||||
websError(wp, 400, T("Bad URL format"));
|
||||
return -1;
|
||||
@@ -787,7 +787,7 @@ static int websParseFirst(webs_t wp, char_t *text)
|
||||
wp->path = bstrdup(B_L, path);
|
||||
wp->protocol = bstrdup(B_L, proto);
|
||||
wp->protoVersion = bstrdup(B_L, protoVer);
|
||||
|
||||
|
||||
if ((testPort = socketGetPort(wp->listenSid)) >= 0) {
|
||||
wp->port = testPort;
|
||||
} else {
|
||||
@@ -803,13 +803,13 @@ static int websParseFirst(webs_t wp, char_t *text)
|
||||
|
||||
#ifdef WEBS_PROXY_SUPPORT
|
||||
/*
|
||||
* Determine if this is a request for local webs data. If it is not a proxied
|
||||
* Determine if this is a request for local webs data. If it is not a proxied
|
||||
* request from the browser, we won't see the "http://" or the system name, so
|
||||
* we assume it must be talking to us directly for local webs data.
|
||||
* Note: not fully implemented yet.
|
||||
*/
|
||||
if (gstrstr(wp->url, T("http://")) == NULL ||
|
||||
((gstrcmp(wp->host, T("localhost")) == 0 ||
|
||||
if (gstrstr(wp->url, T("http://")) == NULL ||
|
||||
((gstrcmp(wp->host, T("localhost")) == 0 ||
|
||||
gstrcmp(wp->host, websHost) == 0) && (wp->port == websPort))) {
|
||||
wp->flags |= WEBS_LOCAL_PAGE;
|
||||
if (gstrcmp(wp->path, T("/")) == 0) {
|
||||
@@ -841,7 +841,7 @@ static void websParseRequest(webs_t wp)
|
||||
*/
|
||||
websSetVar(wp, T("HTTP_AUTHORIZATION"), T(""));
|
||||
|
||||
/*
|
||||
/*
|
||||
* Parse the header and create the Http header keyword variables
|
||||
* We rewrite the header as we go for non-local requests. NOTE: this
|
||||
* modifies the header string directly and tokenizes each line with '\0'.
|
||||
@@ -893,7 +893,7 @@ static void websParseRequest(webs_t wp)
|
||||
*/
|
||||
authType = bstrdup (B_L, value);
|
||||
a_assert (authType);
|
||||
/*
|
||||
/*
|
||||
* Truncate authType at the next non-alpha character
|
||||
*/
|
||||
cp = authType;
|
||||
@@ -1055,7 +1055,7 @@ static void websParseRequest(webs_t wp)
|
||||
wp->clen = gatoi(value);
|
||||
if (wp->clen > 0)
|
||||
{
|
||||
wp->flags |= WEBS_CLEN;
|
||||
wp->flags |= WEBS_CLEN;
|
||||
websSetVar(wp, T("CONTENT_LENGTH"), value);
|
||||
}
|
||||
else
|
||||
@@ -1172,7 +1172,7 @@ void websSetEnv(webs_t wp)
|
||||
|
||||
if (*keyword) {
|
||||
/*
|
||||
* If keyword has already been set, append the new value to what has
|
||||
* If keyword has already been set, append the new value to what has
|
||||
* been stored.
|
||||
*/
|
||||
if ((valCheck = websGetVar(wp, keyword, NULL)) != 0) {
|
||||
@@ -1197,7 +1197,7 @@ void websSetEnv(webs_t wp)
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Define a webs (CGI) variable for this connection. Also create in relevant
|
||||
* scripting engines. Note: the incoming value may be volatile.
|
||||
* scripting engines. Note: the incoming value may be volatile.
|
||||
*/
|
||||
|
||||
void websSetVar(webs_t wp, char_t *var, char_t *value)
|
||||
@@ -1250,7 +1250,7 @@ char_t *websGetVar(webs_t wp, char_t *var, char_t *defaultGetValue)
|
||||
|
||||
a_assert(websValid(wp));
|
||||
a_assert(var && *var);
|
||||
|
||||
|
||||
if ((sp = symLookup(wp->cgiVars, var)) != NULL) {
|
||||
a_assert(sp->content.type == string);
|
||||
if (sp->content.value.string) {
|
||||
@@ -1271,7 +1271,7 @@ int websCompareVar(webs_t wp, char_t *var, char_t *value)
|
||||
{
|
||||
a_assert(websValid(wp));
|
||||
a_assert(var && *var);
|
||||
|
||||
|
||||
if (gstrcmp(value, websGetVar(wp, var, T(" __UNDEF__ "))) == 0) {
|
||||
return 1;
|
||||
}
|
||||
@@ -1295,7 +1295,7 @@ void websTimeoutCancel(webs_t wp)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Output a HTTP response back to the browser. If redirect is set to a
|
||||
* Output a HTTP response back to the browser. If redirect is set to a
|
||||
* URL, the browser will be sent to this location.
|
||||
*/
|
||||
|
||||
@@ -1324,12 +1324,12 @@ void websResponse(webs_t wp, int code, char_t *message, char_t *redirect)
|
||||
websWrite(wp, T("HTTP/1.1 %d %s\r\n"), code, websErrorMsg(code));
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* By license terms the following line of code must not be modified.
|
||||
*/
|
||||
websWrite(wp, T("Server: %s\r\n"), WEBS_NAME);
|
||||
|
||||
/*
|
||||
/*
|
||||
* Timestamp/Date is usually the next to go
|
||||
*/
|
||||
if ((date = websGetDateString(NULL)) != NULL) {
|
||||
@@ -1341,23 +1341,23 @@ void websResponse(webs_t wp, int code, char_t *message, char_t *redirect)
|
||||
*/
|
||||
if (code == 401) {
|
||||
if (!(wp->flags & WEBS_AUTH_DIGEST)) {
|
||||
websWrite(wp, T("WWW-Authenticate: Basic realm=\"%s\"\r\n"),
|
||||
websWrite(wp, T("WWW-Authenticate: Basic realm=\"%s\"\r\n"),
|
||||
websGetRealm());
|
||||
#ifdef DIGEST_ACCESS_SUPPORT
|
||||
} else {
|
||||
char_t *nonce, *opaque;
|
||||
|
||||
/* $$$ before... (note commas instead of semicolons...)
|
||||
nonce = websCalcNonce(wp),
|
||||
opaque = websCalcOpaque(wp),
|
||||
nonce = websCalcNonce(wp),
|
||||
opaque = websCalcOpaque(wp),
|
||||
$$$ after */
|
||||
nonce = websCalcNonce(wp);
|
||||
opaque = websCalcOpaque(wp);
|
||||
opaque = websCalcOpaque(wp);
|
||||
/* ...$$$ end */
|
||||
websWrite(wp,
|
||||
websWrite(wp,
|
||||
T("WWW-Authenticate: Digest realm=\"%s\", domain=\"%s\",")
|
||||
T("qop=\"%s\", nonce=\"%s\", opaque=\"%s\",")
|
||||
T("algorithm=\"%s\", stale=\"%s\"\r\n"),
|
||||
T("algorithm=\"%s\", stale=\"%s\"\r\n"),
|
||||
websGetRealm(),
|
||||
websGetHostUrl(),
|
||||
T("auth"),
|
||||
@@ -1376,8 +1376,8 @@ void websResponse(webs_t wp, int code, char_t *message, char_t *redirect)
|
||||
websWrite(wp, T("Pragma: no-cache\r\nCache-Control: no-cache\r\n"));
|
||||
websWrite(wp, T("Content-Type: text/html\r\n"));
|
||||
/*
|
||||
* We don't do a string length here as the message may be multi-line.
|
||||
* Ie. <CR><LF> will count as only one and we will have a content-length
|
||||
* We don't do a string length here as the message may be multi-line.
|
||||
* Ie. <CR><LF> will count as only one and we will have a content-length
|
||||
* that is too short.
|
||||
*
|
||||
* websWrite(wp, T("Content-Length: %s\r\n"), message);
|
||||
@@ -1436,7 +1436,7 @@ void websRedirect(webs_t wp, char_t *url)
|
||||
/*
|
||||
* Add human readable message for completeness. Should not be required.
|
||||
*/
|
||||
fmtAlloc(&msgbuf, WEBS_MAX_URL + 80,
|
||||
fmtAlloc(&msgbuf, WEBS_MAX_URL + 80,
|
||||
T("<html><head></head><body>\r\n\
|
||||
This document has moved to a new <a href=\"%s\">location</a>.\r\n\
|
||||
Please update your documents to reflect the new location.\r\n\
|
||||
@@ -1449,7 +1449,7 @@ void websRedirect(webs_t wp, char_t *url)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Output an error message and cleanup
|
||||
*/
|
||||
|
||||
@@ -1478,7 +1478,7 @@ void websError(webs_t wp, int code, char_t *fmt, ...)
|
||||
#ifdef qRichErrorPage
|
||||
if (!reEntry)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* The dmfRichError function that we're about to call may very well call
|
||||
* websError() as part of its work. If that happens, we do NOT want to
|
||||
* get into a never-ending recursive call chain. When we get back here
|
||||
@@ -1506,7 +1506,7 @@ void websError(webs_t wp, int code, char_t *fmt, ...)
|
||||
* Ensure we have plenty of room
|
||||
*/
|
||||
buf = NULL;
|
||||
fmtAlloc(&buf, WEBS_BUFSIZE, msg, websErrorMsg(code),
|
||||
fmtAlloc(&buf, WEBS_BUFSIZE, msg, websErrorMsg(code),
|
||||
websErrorMsg(code), wp->url, userMsg);
|
||||
|
||||
websResponse(wp, code, buf, NULL);
|
||||
@@ -1544,7 +1544,7 @@ int websWrite(webs_t wp, char_t *fmt, ...)
|
||||
va_list vargs;
|
||||
char_t *buf;
|
||||
int rc;
|
||||
|
||||
|
||||
a_assert(websValid(wp));
|
||||
|
||||
va_start(vargs, fmt);
|
||||
@@ -1555,7 +1555,7 @@ int websWrite(webs_t wp, char_t *fmt, ...)
|
||||
if (fmtValloc(&buf, WEBS_BUFSIZE, fmt, vargs) >= WEBS_BUFSIZE) {
|
||||
trace(0, T("webs: websWrite lost data, buffer overflow\n"));
|
||||
}
|
||||
|
||||
|
||||
va_end(vargs);
|
||||
a_assert(buf);
|
||||
if (buf) {
|
||||
@@ -1568,9 +1568,9 @@ int websWrite(webs_t wp, char_t *fmt, ...)
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Write a block of data of length "nChars" to the user's browser. Public
|
||||
* write block procedure. If unicode is turned on this function expects
|
||||
* write block procedure. If unicode is turned on this function expects
|
||||
* buf to be a unicode string and it converts it to ASCII before writing.
|
||||
* See websWriteDataNonBlock to always write binary or ASCII data with no
|
||||
* See websWriteDataNonBlock to always write binary or ASCII data with no
|
||||
* unicode conversion. This returns the number of char_t's processed.
|
||||
* It spins until nChars are flushed to the socket. For non-blocking
|
||||
* behavior, use websWriteDataNonBlock.
|
||||
@@ -1594,7 +1594,7 @@ int websWriteBlock(webs_t wp, char_t *buf, int nChars)
|
||||
*/
|
||||
pBuf = asciiBuf = ballocUniToAsc(buf, nChars);
|
||||
|
||||
while (nChars > 0) {
|
||||
while (nChars > 0) {
|
||||
#ifdef WEBS_SSL_SUPPORT
|
||||
if (wp->flags & WEBS_SECURE) {
|
||||
if ((len = websSSLWrite(wp->wsp, pBuf, nChars)) < 0) {
|
||||
@@ -1669,7 +1669,7 @@ void websDecodeUrl(char_t *decoded, char_t *token, int len)
|
||||
{
|
||||
char_t *ip, *op;
|
||||
int num, i, c;
|
||||
|
||||
|
||||
a_assert(decoded);
|
||||
a_assert(token);
|
||||
|
||||
@@ -1731,10 +1731,10 @@ static void websLog(webs_t wp, int code)
|
||||
{
|
||||
*newLine = '\0';
|
||||
}
|
||||
fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%s\t%s\t%s\tcode = %d\n"),
|
||||
fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%s\t%s\t%s\tcode = %d\n"),
|
||||
timeStr, wp->ipaddr, wp->url, code);
|
||||
#else
|
||||
fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%d %s %d %d\n"), time(0),
|
||||
fmtAlloc(&buf, WEBS_MAX_URL + 80, T("%d %s %d %d\n"), time(0),
|
||||
wp->url, code, wp->written);
|
||||
#endif
|
||||
len = gstrlen(buf);
|
||||
@@ -1828,7 +1828,7 @@ void websDone(webs_t wp, int code)
|
||||
|
||||
/*
|
||||
* If using Keep Alive (HTTP/1.1) we keep the socket open for a period
|
||||
* while waiting for another request on the socket.
|
||||
* while waiting for another request on the socket.
|
||||
*/
|
||||
if (wp->flags & WEBS_KEEP_ALIVE) {
|
||||
if (socketFlush(wp->sid) == 0) {
|
||||
@@ -1837,7 +1837,7 @@ void websDone(webs_t wp, int code)
|
||||
if (wp->header.buf) {
|
||||
ringqFlush(&wp->header);
|
||||
}
|
||||
socketCreateHandler(wp->sid, SOCKET_READABLE, websSocketEvent,
|
||||
socketCreateHandler(wp->sid, SOCKET_READABLE, websSocketEvent,
|
||||
(int) wp);
|
||||
websTimeoutCancel(wp);
|
||||
wp->timeout = emfSchedCallback(WEBS_TIMEOUT, websTimeout,
|
||||
@@ -2242,7 +2242,7 @@ void websSetRequestPath(webs_t wp, char_t *dir, char_t *path)
|
||||
|
||||
a_assert(websValid(wp));
|
||||
|
||||
if (dir) {
|
||||
if (dir) {
|
||||
tmp = wp->dir;
|
||||
wp->dir = bstrdup(B_L, dir);
|
||||
if (tmp) {
|
||||
@@ -2372,17 +2372,17 @@ char_t *websGetRealm(void)
|
||||
|
||||
#ifdef WEBS_IF_MODIFIED_SUPPORT
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* These functions are intended to closely mirror the syntax for HTTP-date
|
||||
/*
|
||||
* These functions are intended to closely mirror the syntax for HTTP-date
|
||||
* from RFC 2616 (HTTP/1.1 spec). This code was submitted by Pete Bergstrom.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* RFC1123Date = wkday "," SP date1 SP time SP "GMT"
|
||||
* RFC850Date = weekday "," SP date2 SP time SP "GMT"
|
||||
* ASCTimeDate = wkday SP date3 SP time SP 4DIGIT
|
||||
*
|
||||
* Each of these functions tries to parse the value and update the index to
|
||||
* Each of these functions tries to parse the value and update the index to
|
||||
* the point it leaves off parsing.
|
||||
*/
|
||||
|
||||
@@ -2390,11 +2390,11 @@ typedef enum { JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG, SEP, OCT, NOV, DEC } Mont
|
||||
typedef enum { SUN, MON, TUE, WED, THU, FRI, SAT } WeekdayEnumeration;
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Parse an N-digit value
|
||||
*/
|
||||
|
||||
static int parseNDIGIT(char_t *buf, int digits, int *index)
|
||||
static int parseNDIGIT(char_t *buf, int digits, int *index)
|
||||
{
|
||||
int tmpIndex, returnValue;
|
||||
|
||||
@@ -2406,7 +2406,7 @@ static int parseNDIGIT(char_t *buf, int digits, int *index)
|
||||
}
|
||||
}
|
||||
*index = tmpIndex;
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -2415,10 +2415,10 @@ static int parseNDIGIT(char_t *buf, int digits, int *index)
|
||||
* Return an index into the month array
|
||||
*/
|
||||
|
||||
static int parseMonth(char_t *buf, int *index)
|
||||
static int parseMonth(char_t *buf, int *index)
|
||||
{
|
||||
/*
|
||||
* "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" |
|
||||
/*
|
||||
* "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" |
|
||||
* "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
|
||||
*/
|
||||
int tmpIndex, returnValue;
|
||||
@@ -2493,11 +2493,11 @@ static int parseMonth(char_t *buf, int *index)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Parse a year value (either 2 or 4 digits)
|
||||
*/
|
||||
|
||||
static int parseYear(char_t *buf, int *index)
|
||||
static int parseYear(char_t *buf, int *index)
|
||||
{
|
||||
int tmpIndex, returnValue;
|
||||
|
||||
@@ -2510,7 +2510,7 @@ static int parseYear(char_t *buf, int *index)
|
||||
returnValue = parseNDIGIT(buf, 2, &tmpIndex);
|
||||
if (returnValue >= 0) {
|
||||
/*
|
||||
* Assume that any year earlier than the start of the
|
||||
* Assume that any year earlier than the start of the
|
||||
* epoch for time_t (1970) specifies 20xx
|
||||
*/
|
||||
if (returnValue < 70) {
|
||||
@@ -2527,8 +2527,8 @@ static int parseYear(char_t *buf, int *index)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* The formulas used to build these functions are from "Calendrical Calculations",
|
||||
/*
|
||||
* The formulas used to build these functions are from "Calendrical Calculations",
|
||||
* by Nachum Dershowitz, Edward M. Reingold, Cambridge University Press, 1997.
|
||||
*/
|
||||
|
||||
@@ -2541,11 +2541,11 @@ const int GregorianEpoch = 1;
|
||||
* Determine if year is a leap year
|
||||
*/
|
||||
|
||||
int GregorianLeapYearP(long year)
|
||||
int GregorianLeapYearP(long year)
|
||||
{
|
||||
int result;
|
||||
long tmp;
|
||||
|
||||
|
||||
tmp = year % 400;
|
||||
|
||||
if ((year % 4 == 0) &&
|
||||
@@ -2565,14 +2565,14 @@ int GregorianLeapYearP(long year)
|
||||
* Return the fixed date from the gregorian date
|
||||
*/
|
||||
|
||||
long FixedFromGregorian(long month, long day, long year)
|
||||
long FixedFromGregorian(long month, long day, long year)
|
||||
{
|
||||
long fixedDate;
|
||||
|
||||
fixedDate = (long)(GregorianEpoch - 1 + 365 * (year - 1) +
|
||||
fixedDate = (long)(GregorianEpoch - 1 + 365 * (year - 1) +
|
||||
floor((year - 1) / 4.0) -
|
||||
floor((double)(year - 1) / 100.0) +
|
||||
floor((double)(year - 1) / 400.0) +
|
||||
floor((double)(year - 1) / 100.0) +
|
||||
floor((double)(year - 1) / 400.0) +
|
||||
floor((367.0 * ((double)month) - 362.0) / 12.0));
|
||||
|
||||
if (month <= 2) {
|
||||
@@ -2593,7 +2593,7 @@ long FixedFromGregorian(long month, long day, long year)
|
||||
* Return the gregorian year from a fixed date
|
||||
*/
|
||||
|
||||
long GregorianYearFromFixed(long fixedDate)
|
||||
long GregorianYearFromFixed(long fixedDate)
|
||||
{
|
||||
long result, d0, n400, d1, n100, d2, n4, d3, n1, d4, year;
|
||||
|
||||
@@ -2618,13 +2618,13 @@ long GregorianYearFromFixed(long fixedDate)
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Returns the Gregorian date from a fixed date
|
||||
* (not needed for this use, but included for completeness
|
||||
*/
|
||||
|
||||
#if 0
|
||||
GregorianFromFixed(long fixedDate, long *month, long *day, long *year)
|
||||
GregorianFromFixed(long fixedDate, long *month, long *day, long *year)
|
||||
{
|
||||
long priorDays, correction;
|
||||
|
||||
@@ -2645,14 +2645,14 @@ GregorianFromFixed(long fixedDate, long *month, long *day, long *year)
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
/*
|
||||
* Returns the difference between two Gregorian dates
|
||||
*/
|
||||
|
||||
long GregorianDateDifference( long month1, long day1, long year1,
|
||||
long month2, long day2, long year2)
|
||||
long month2, long day2, long year2)
|
||||
{
|
||||
return FixedFromGregorian(month2, day2, year2) -
|
||||
return FixedFromGregorian(month2, day2, year2) -
|
||||
FixedFromGregorian(month1, day1, year1);
|
||||
}
|
||||
|
||||
@@ -2664,9 +2664,9 @@ long GregorianDateDifference( long month1, long day1, long year1,
|
||||
|
||||
#define SECONDS_PER_DAY 24*60*60
|
||||
|
||||
static int parseTime(char_t *buf, int *index)
|
||||
static int parseTime(char_t *buf, int *index)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Format of buf is - 2DIGIT ":" 2DIGIT ":" 2DIGIT
|
||||
*/
|
||||
int returnValue, tmpIndex, hourValue, minuteValue, secondValue;
|
||||
@@ -2701,17 +2701,17 @@ static int parseTime(char_t *buf, int *index)
|
||||
* Return the equivalent of time() given a gregorian date
|
||||
*/
|
||||
|
||||
static time_t dateToTimet(int year, int month, int day)
|
||||
static time_t dateToTimet(int year, int month, int day)
|
||||
{
|
||||
long dayDifference;
|
||||
|
||||
/*
|
||||
* Bug fix by Jeff Reeder (Jun 14, 2002): The 'month' parameter is
|
||||
* numbered from 0 (Jan == 0), but FixedFromGregorian() takes
|
||||
* months numbered from 1 (January == 1). We need to add 1
|
||||
* to the month
|
||||
/*
|
||||
* Bug fix by Jeff Reeder (Jun 14, 2002): The 'month' parameter is
|
||||
* numbered from 0 (Jan == 0), but FixedFromGregorian() takes
|
||||
* months numbered from 1 (January == 1). We need to add 1
|
||||
* to the month
|
||||
*/
|
||||
dayDifference = FixedFromGregorian(month + 1, day, year) -
|
||||
dayDifference = FixedFromGregorian(month + 1, day, year) -
|
||||
FixedFromGregorian(1, 1, 1970);
|
||||
|
||||
return dayDifference * SECONDS_PER_DAY;
|
||||
@@ -2723,9 +2723,9 @@ static time_t dateToTimet(int year, int month, int day)
|
||||
* (corresponds to documentation for time() function)
|
||||
*/
|
||||
|
||||
static time_t parseDate1or2(char_t *buf, int *index)
|
||||
static time_t parseDate1or2(char_t *buf, int *index)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Format of buf is either
|
||||
* 2DIGIT SP month SP 4DIGIT
|
||||
* or
|
||||
@@ -2740,23 +2740,23 @@ static time_t parseDate1or2(char_t *buf, int *index)
|
||||
dayValue = monthValue = yearValue = -1;
|
||||
|
||||
if (buf[tmpIndex] == T(',')) {
|
||||
/*
|
||||
* Skip over the ", "
|
||||
/*
|
||||
* Skip over the ", "
|
||||
*/
|
||||
tmpIndex += 2;
|
||||
tmpIndex += 2;
|
||||
|
||||
dayValue = parseNDIGIT(buf, 2, &tmpIndex);
|
||||
if (dayValue >= 0) {
|
||||
/*
|
||||
* Skip over the space or hyphen
|
||||
*/
|
||||
tmpIndex++;
|
||||
tmpIndex++;
|
||||
monthValue = parseMonth(buf, &tmpIndex);
|
||||
if (monthValue >= 0) {
|
||||
/*
|
||||
* Skip over the space or hyphen
|
||||
*/
|
||||
tmpIndex++;
|
||||
tmpIndex++;
|
||||
yearValue = parseYear(buf, &tmpIndex);
|
||||
}
|
||||
}
|
||||
@@ -2765,17 +2765,17 @@ static time_t parseDate1or2(char_t *buf, int *index)
|
||||
(monthValue >= 0) &&
|
||||
(yearValue >= 0)) {
|
||||
if (yearValue < 1970) {
|
||||
/*
|
||||
* Allow for Microsoft IE's year 1601 dates
|
||||
/*
|
||||
* Allow for Microsoft IE's year 1601 dates
|
||||
*/
|
||||
returnValue = 0;
|
||||
returnValue = 0;
|
||||
} else {
|
||||
returnValue = dateToTimet(yearValue, monthValue, dayValue);
|
||||
}
|
||||
*index = tmpIndex;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -2784,7 +2784,7 @@ static time_t parseDate1or2(char_t *buf, int *index)
|
||||
* Return the number of seconds between Jan 1, 1970 and the parsed date
|
||||
*/
|
||||
|
||||
static time_t parseDate3Time(char_t *buf, int *index)
|
||||
static time_t parseDate3Time(char_t *buf, int *index)
|
||||
{
|
||||
/*
|
||||
* Format of buf is month SP ( 2DIGIT | ( SP 1DIGIT ))
|
||||
@@ -2799,25 +2799,25 @@ static time_t parseDate3Time(char_t *buf, int *index)
|
||||
|
||||
monthValue = parseMonth(buf, &tmpIndex);
|
||||
if (monthValue >= 0) {
|
||||
/*
|
||||
* Skip over the space
|
||||
/*
|
||||
* Skip over the space
|
||||
*/
|
||||
tmpIndex++;
|
||||
tmpIndex++;
|
||||
if (buf[tmpIndex] == T(' ')) {
|
||||
/*
|
||||
* Skip over this space too
|
||||
* Skip over this space too
|
||||
*/
|
||||
tmpIndex++;
|
||||
tmpIndex++;
|
||||
dayValue = parseNDIGIT(buf, 1, &tmpIndex);
|
||||
} else {
|
||||
dayValue = parseNDIGIT(buf, 2, &tmpIndex);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Now get the time and time SP 4DIGIT
|
||||
*/
|
||||
timeValue = parseTime(buf, &tmpIndex);
|
||||
if (timeValue >= 0) {
|
||||
/*
|
||||
/*
|
||||
* Now grab the 4DIGIT year value
|
||||
*/
|
||||
yearValue = parseYear(buf, &tmpIndex);
|
||||
@@ -2831,7 +2831,7 @@ static time_t parseDate3Time(char_t *buf, int *index)
|
||||
returnValue += timeValue;
|
||||
*index = tmpIndex;
|
||||
}
|
||||
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
@@ -2840,12 +2840,12 @@ static time_t parseDate3Time(char_t *buf, int *index)
|
||||
/*
|
||||
* Although this looks like a trivial function, I found I was replicating the implementation
|
||||
* seven times in the parseWeekday function. In the interests of minimizing code size
|
||||
* and redundancy, it is broken out into a separate function. The cost of an extra
|
||||
* and redundancy, it is broken out into a separate function. The cost of an extra
|
||||
* function call I can live with given that it should only be called once per HTTP request.
|
||||
*/
|
||||
|
||||
static int bufferIndexIncrementGivenNTest(char_t *buf, int testIndex, char_t testChar,
|
||||
int foundIncrement, int notfoundIncrement)
|
||||
static int bufferIndexIncrementGivenNTest(char_t *buf, int testIndex, char_t testChar,
|
||||
int foundIncrement, int notfoundIncrement)
|
||||
{
|
||||
if (buf[testIndex] == testChar) {
|
||||
return foundIncrement;
|
||||
@@ -2859,9 +2859,9 @@ static int bufferIndexIncrementGivenNTest(char_t *buf, int testIndex, char_t tes
|
||||
* Return an index into a logical weekday array
|
||||
*/
|
||||
|
||||
static int parseWeekday(char_t *buf, int *index)
|
||||
static int parseWeekday(char_t *buf, int *index)
|
||||
{
|
||||
/*
|
||||
/*
|
||||
* Format of buf is either
|
||||
* "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun"
|
||||
* or
|
||||
@@ -2939,7 +2939,7 @@ static time_t dateParse(time_t tip, char_t *cmd)
|
||||
*/
|
||||
timeValue = parseTime(cmd, &index);
|
||||
if (timeValue >= 0) {
|
||||
/*
|
||||
/*
|
||||
* Now match up that "GMT" string for completeness
|
||||
* Compute the final value if there were no problems in the parse
|
||||
*/
|
||||
@@ -2950,7 +2950,7 @@ static time_t dateParse(time_t tip, char_t *cmd)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
/*
|
||||
* Try the other form - wkday SP date3 SP time SP 4DIGIT
|
||||
*/
|
||||
tmpIndex = index;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* webs.h -- GoAhead Web public header
|
||||
*
|
||||
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
* GoAhead Web Server header. This defines the Web public APIs.
|
||||
* Include this header for files that contain ASP or Form procedures.
|
||||
* Include wsIntrn.h when creating URL handlers.
|
||||
@@ -45,18 +45,18 @@
|
||||
#define WEBS_HTTP_PORT T("httpPort")
|
||||
#define CGI_BIN T("cgi-bin")
|
||||
|
||||
/*
|
||||
/*
|
||||
* Request flags. Also returned by websGetRequestFlags().
|
||||
*/
|
||||
#define WEBS_LOCAL_PAGE 0x1 /* Request for local webs page */
|
||||
#define WEBS_LOCAL_PAGE 0x1 /* Request for local webs page */
|
||||
#define WEBS_KEEP_ALIVE 0x2 /* HTTP/1.1 keep alive */
|
||||
#define WEBS_DONT_USE_CACHE 0x4 /* Not implemented cache support */
|
||||
#define WEBS_COOKIE 0x8 /* Cookie supplied in request */
|
||||
#define WEBS_IF_MODIFIED 0x10 /* If-modified-since in request */
|
||||
#define WEBS_POST_REQUEST 0x20 /* Post request operation */
|
||||
#define WEBS_LOCAL_REQUEST 0x40 /* Request from this system */
|
||||
#define WEBS_HOME_PAGE 0x80 /* Request for the home page */
|
||||
#define WEBS_ASP 0x100 /* ASP request */
|
||||
#define WEBS_HOME_PAGE 0x80 /* Request for the home page */
|
||||
#define WEBS_ASP 0x100 /* ASP request */
|
||||
#define WEBS_HEAD_REQUEST 0x200 /* Head request */
|
||||
#define WEBS_CLEN 0x400 /* Request had a content length */
|
||||
#define WEBS_FORM 0x800 /* Request is a form */
|
||||
@@ -74,7 +74,7 @@
|
||||
#define WEBS_HANDLER_FIRST 0x1 /* Process this handler first */
|
||||
#define WEBS_HANDLER_LAST 0x2 /* Process this handler last */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Per socket connection webs structure
|
||||
*/
|
||||
typedef struct websRec {
|
||||
@@ -133,7 +133,7 @@ typedef websRec websType;
|
||||
|
||||
/******************************** Prototypes **********************************/
|
||||
extern int websAccept(int sid, char *ipaddr, int port, int listenSid);
|
||||
extern int websAspDefine(char_t *name,
|
||||
extern int websAspDefine(char_t *name,
|
||||
int (*fn)(int ejid, webs_t wp, int argc, char_t **argv));
|
||||
extern int websAspRequest(webs_t wp, char_t *lpath);
|
||||
extern void websCloseListen(void);
|
||||
@@ -145,7 +145,7 @@ extern void websError(webs_t wp, int code, char_t *msg, ...);
|
||||
/* function websErrorMsg() made extern 03 Jun 02 BgP */
|
||||
extern char_t *websErrorMsg(int code);
|
||||
extern void websFooter(webs_t wp);
|
||||
extern int websFormDefine(char_t *name, void (*fn)(webs_t wp,
|
||||
extern int websFormDefine(char_t *name, void (*fn)(webs_t wp,
|
||||
char_t *path, char_t *query));
|
||||
extern char_t *websGetDefaultDir(void);
|
||||
extern char_t *websGetDefaultPage(void);
|
||||
@@ -174,8 +174,8 @@ extern void websPageClose(webs_t wp);
|
||||
extern int websPublish(char_t *urlPrefix, char_t *path);
|
||||
extern void websRedirect(webs_t wp, char_t *url);
|
||||
extern void websSecurityDelete(void);
|
||||
extern int websSecurityHandler(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
extern int websSecurityHandler(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *query);
|
||||
extern void websSetDefaultDir(char_t *dir);
|
||||
extern void websSetDefaultPage(char_t *page);
|
||||
@@ -193,16 +193,16 @@ extern void websSetRequestWritten(webs_t wp, int written);
|
||||
extern void websSetVar(webs_t wp, char_t *var, char_t *value);
|
||||
extern int websTestVar(webs_t wp, char_t *var);
|
||||
extern void websTimeoutCancel(webs_t wp);
|
||||
extern int websUrlHandlerDefine(char_t *urlPrefix, char_t *webDir,
|
||||
int arg, int (*fn)(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
extern int websUrlHandlerDefine(char_t *urlPrefix, char_t *webDir,
|
||||
int arg, int (*fn)(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *query), int flags);
|
||||
extern int websUrlHandlerDelete(int (*fn)(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *query));
|
||||
extern int websUrlHandlerRequest(webs_t wp);
|
||||
extern int websUrlParse(char_t *url, char_t **buf, char_t **host,
|
||||
char_t **path, char_t **port, char_t **query,
|
||||
extern int websUrlParse(char_t *url, char_t **buf, char_t **host,
|
||||
char_t **path, char_t **port, char_t **query,
|
||||
char_t **proto, char_t **tag, char_t **ext);
|
||||
extern char_t *websUrlType(char_t *webs, char_t *buf, int charCnt);
|
||||
extern int websWrite(webs_t wp, char_t* fmt, ...);
|
||||
@@ -221,7 +221,7 @@ extern void websTimeout(void *arg, int id);
|
||||
extern void websReadEvent(webs_t wp);
|
||||
|
||||
/*
|
||||
* Prototypes for functions available when running as part of the
|
||||
* Prototypes for functions available when running as part of the
|
||||
* GoAhead Embedded Management Framework (EMF)
|
||||
*/
|
||||
#ifdef EMF
|
||||
|
||||
@@ -65,8 +65,8 @@ extern void SSLC_add_all_algorithms(void);
|
||||
|
||||
/*************************** Forward Declarations *****************************/
|
||||
|
||||
static int websSSLSetCertStuff(SSL_CTX *ctx,
|
||||
char *cert_file,
|
||||
static int websSSLSetCertStuff(SSL_CTX *ctx,
|
||||
char *cert_file,
|
||||
char *key_file);
|
||||
static int websSSLVerifyCallback(int ok, X509_STORE_CTX *ctx);
|
||||
static RSA *websSSLTempRSACallback(SSL *s, int is_export, int keylength);
|
||||
@@ -91,12 +91,12 @@ int websSSLOpen()
|
||||
{
|
||||
char *certFile, *keyFile, *CApath, *CAfile;
|
||||
SSL_METHOD *meth;
|
||||
|
||||
|
||||
/*
|
||||
* Install and initialize the SSL library
|
||||
*/
|
||||
apps_startup();
|
||||
trace(7, T("SSL: Initializing SSL\n"));
|
||||
trace(7, T("SSL: Initializing SSL\n"));
|
||||
|
||||
#ifdef SSLC
|
||||
SSL_library_init();
|
||||
@@ -117,7 +117,7 @@ int websSSLOpen()
|
||||
a_assert(sslctx);
|
||||
|
||||
if (sslctx == NULL) {
|
||||
trace(2, T("SSL: Unable to create SSL context!\n"));
|
||||
trace(2, T("SSL: Unable to create SSL context!\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ int websSSLOpen()
|
||||
CAfile = DEFAULT_CA_FILE;
|
||||
if ((!SSL_CTX_load_verify_locations(sslctx, CAfile, CApath)) ||
|
||||
(!SSL_CTX_set_default_verify_paths(sslctx))) {
|
||||
trace(2, T("SSL: Unable to set cert verification locations!\n"));
|
||||
trace(2, T("SSL: Unable to set cert verification locations!\n"));
|
||||
websSSLClose();
|
||||
return -1;
|
||||
}
|
||||
@@ -168,11 +168,11 @@ int websSSLOpen()
|
||||
/*
|
||||
* Open the socket
|
||||
*/
|
||||
sslListenSock = socketOpenConnection(NULL, SSL_PORT,
|
||||
sslListenSock = socketOpenConnection(NULL, SSL_PORT,
|
||||
websSSLAccept, SOCKET_BLOCK);
|
||||
|
||||
if (sslListenSock < 0) {
|
||||
trace(2, T("SSL: Unable to open SSL socket on port <%d>!\n"),
|
||||
trace(2, T("SSL: Unable to open SSL socket on port <%d>!\n"),
|
||||
SSL_PORT);
|
||||
return -1;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ int websSSLIsOpen()
|
||||
|
||||
void websSSLClose()
|
||||
{
|
||||
trace(7, T("SSL: Closing SSL\n"));
|
||||
trace(7, T("SSL: Closing SSL\n"));
|
||||
|
||||
if (sslctx != NULL) {
|
||||
SSL_CTX_free(sslctx);
|
||||
@@ -245,8 +245,8 @@ int websSSLAccept(int sid, char *ipaddr, int port, int listenSid)
|
||||
* Check if this is a request from a browser on this system. This is useful
|
||||
* to know for permitting administrative operations only for local access
|
||||
*/
|
||||
if (gstrcmp(wp->ipaddr, T("127.0.0.1")) == 0 ||
|
||||
gstrcmp(wp->ipaddr, websIpaddr) == 0 ||
|
||||
if (gstrcmp(wp->ipaddr, T("127.0.0.1")) == 0 ||
|
||||
gstrcmp(wp->ipaddr, websIpaddr) == 0 ||
|
||||
gstrcmp(wp->ipaddr, websHost) == 0) {
|
||||
wp->flags |= WEBS_LOCAL_REQUEST;
|
||||
}
|
||||
@@ -288,12 +288,12 @@ static void websSSLSocketEvent(int sid, int mask, int iwp)
|
||||
|
||||
if (mask & SOCKET_READABLE) {
|
||||
websSSLReadEvent(wp);
|
||||
}
|
||||
}
|
||||
if (mask & SOCKET_WRITABLE) {
|
||||
if (wp->writeSocket) {
|
||||
(*wp->writeSocket)(wp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -432,10 +432,10 @@ int websSSLSetCertStuff(SSL_CTX *ctx, char *certFile, char *keyFile)
|
||||
a_assert (certFile);
|
||||
|
||||
if (certFile != NULL) {
|
||||
if (SSL_CTX_use_certificate_file(ctx, certFile,
|
||||
if (SSL_CTX_use_certificate_file(ctx, certFile,
|
||||
SSL_FILETYPE_PEM) <= 0) {
|
||||
trace(2, T("SSL: Unable to set certificate file <%s>\n"),
|
||||
certFile);
|
||||
certFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -445,17 +445,17 @@ int websSSLSetCertStuff(SSL_CTX *ctx, char *certFile, char *keyFile)
|
||||
|
||||
if (SSL_CTX_use_PrivateKey_file(ctx, keyFile, SSL_FILETYPE_PEM) <= 0) {
|
||||
trace(2, T("SSL: Unable to set private key file <%s>\n"),
|
||||
keyFile);
|
||||
keyFile);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Now we know that a key and cert have been set against
|
||||
* the SSL context
|
||||
* the SSL context
|
||||
*/
|
||||
if (!SSL_CTX_check_private_key(ctx)) {
|
||||
trace(2, T("SSL: Check of private key file <%s> FAILED!\n"),
|
||||
keyFile);
|
||||
keyFile);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -477,11 +477,11 @@ int websSSLSetCertFile(char_t *certFile)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (SSL_CTX_use_certificate_file(sslctx, certFile,
|
||||
if (SSL_CTX_use_certificate_file(sslctx, certFile,
|
||||
SSL_FILETYPE_PEM) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Confirm that the certificate and the private key jive.
|
||||
*/
|
||||
if (!SSL_CTX_check_private_key(sslctx)) {
|
||||
@@ -508,7 +508,7 @@ int websSSLSetKeyFile(char_t *keyFile)
|
||||
if (SSL_CTX_use_PrivateKey_file(sslctx, keyFile, SSL_FILETYPE_PEM) <= 0) {
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
/*
|
||||
* Confirm that the certificate and the private key jive.
|
||||
*/
|
||||
if (!SSL_CTX_check_private_key(sslctx)) {
|
||||
@@ -548,7 +548,7 @@ static RSA *websSSLTempRSACallback(SSL *ssl, int isExport, int keyLength)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Free SSL resources
|
||||
* Free SSL resources
|
||||
*/
|
||||
|
||||
int websSSLFree(websSSL_t *wsp)
|
||||
@@ -557,7 +557,7 @@ int websSSLFree(websSSL_t *wsp)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
/*
|
||||
* Make sure we re-use sessions
|
||||
*/
|
||||
if (wsp->ssl != NULL) {
|
||||
@@ -584,7 +584,7 @@ int websSSLEof(websSSL_t *wsp)
|
||||
|
||||
if ((wsp == NULL) || (wsp->bio == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return BIO_eof(wsp->bio);
|
||||
}
|
||||
@@ -601,7 +601,7 @@ int websSSLRead(websSSL_t *wsp, char_t *buf, int len)
|
||||
|
||||
if ((wsp == NULL) || (wsp->bio == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return BIO_read(wsp->bio, buf, len);
|
||||
}
|
||||
@@ -626,14 +626,14 @@ int websSSLGets(websSSL_t *wsp, char_t **buf)
|
||||
|
||||
if ((wsp == NULL) || (wsp->bio == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
while (1) {
|
||||
|
||||
if ((rc = BIO_read(wsp->bio, &c, 1)) < 0) {
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
if (rc == 0) {
|
||||
/*
|
||||
* If there is a partial line and we are at EOF, pretend we saw a '\n'
|
||||
@@ -655,7 +655,7 @@ int websSSLGets(websSSL_t *wsp, char_t **buf)
|
||||
return len;
|
||||
} else if (c == '\r') {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Append character to buf
|
||||
*/
|
||||
@@ -682,7 +682,7 @@ int websSSLWrite(websSSL_t *wsp, char_t *buf, int len)
|
||||
|
||||
if ((wsp == NULL) || (wsp->bio == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return BIO_write(wsp->bio, buf, len);
|
||||
}
|
||||
@@ -698,7 +698,7 @@ int websSSLFlush(websSSL_t *wsp)
|
||||
|
||||
if ((wsp == NULL) || (wsp->bio == NULL)) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return BIO_flush(wsp->bio);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* websSSL.h -- SSL Patch header
|
||||
*
|
||||
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
|
||||
@@ -13,8 +13,8 @@
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* Header file for the GoAhead Patch for SSL. This defines the interface to
|
||||
/*
|
||||
* Header file for the GoAhead Patch for SSL. This defines the interface to
|
||||
* integrate SSL into the GoAhead Webserver.
|
||||
*/
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ char *websMD5binary(unsigned char *buf, int length)
|
||||
|
||||
/*****************************************************************************/
|
||||
/*
|
||||
* Convenience call to websMD5binary
|
||||
* Convenience call to websMD5binary
|
||||
* (Performs char_t to char conversion and back)
|
||||
*/
|
||||
|
||||
@@ -115,9 +115,9 @@ char_t *websMD5(char_t *string)
|
||||
|
||||
/******************************************************************************/
|
||||
/*
|
||||
* Get a Nonce value for passing along to the client. This function
|
||||
* composes the string "RANDOMKEY:timestamp:myrealm" and
|
||||
* calculates the MD5 digest placing it in output.
|
||||
* Get a Nonce value for passing along to the client. This function
|
||||
* composes the string "RANDOMKEY:timestamp:myrealm" and
|
||||
* calculates the MD5 digest placing it in output.
|
||||
*/
|
||||
|
||||
char_t *websCalcNonce(webs_t wp)
|
||||
@@ -141,10 +141,10 @@ char_t *websCalcNonce(webs_t wp)
|
||||
prenonce = NULL;
|
||||
#ifdef DIGEST_ACCESS_SUPPORT
|
||||
fmtAlloc(&prenonce, 256, T("%s:%s:%s"), RANDOMKEY, gasctime(newtime),
|
||||
wp->realm);
|
||||
wp->realm);
|
||||
#else
|
||||
fmtAlloc(&prenonce, 256, T("%s:%s:%s"), RANDOMKEY, gasctime(newtime),
|
||||
RANDOMKEY);
|
||||
fmtAlloc(&prenonce, 256, T("%s:%s:%s"), RANDOMKEY, gasctime(newtime),
|
||||
RANDOMKEY);
|
||||
#endif
|
||||
a_assert(prenonce);
|
||||
/*
|
||||
@@ -218,8 +218,8 @@ char_t *websCalcDigest(webs_t wp)
|
||||
if (!wp->qop) {
|
||||
fmtAlloc(&preDigest, 255, T("%s:%s:%s"), a1prime, wp->nonce, a2prime);
|
||||
} else {
|
||||
fmtAlloc(&preDigest, 255, T("%s:%s:%s:%s:%s:%s"),
|
||||
a1prime,
|
||||
fmtAlloc(&preDigest, 255, T("%s:%s:%s:%s:%s:%s"),
|
||||
a1prime,
|
||||
wp->nonce,
|
||||
wp->nc,
|
||||
wp->cnonce,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* websda.h -- GoAhead Digest Access Authentication public header
|
||||
*
|
||||
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
|
||||
@@ -13,9 +13,9 @@
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
* GoAhead Digest Access Authentication header. This defines the Digest
|
||||
* access authentication public APIs. Include this header for files that
|
||||
/*
|
||||
* GoAhead Digest Access Authentication header. This defines the Digest
|
||||
* access authentication public APIs. Include this header for files that
|
||||
* use DAA functions
|
||||
*/
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ void emfReschedCallback(int schedid, int delay)
|
||||
{
|
||||
sched_t *s;
|
||||
|
||||
if (sched == NULL || schedid == -1 || schedid >= schedMax ||
|
||||
if (sched == NULL || schedid == -1 || schedid >= schedMax ||
|
||||
(s = sched[schedid]) == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -160,7 +160,7 @@ void emfUnschedCallback(int schedid)
|
||||
{
|
||||
sched_t *s;
|
||||
|
||||
if (sched == NULL || schedid == -1 || schedid >= schedMax ||
|
||||
if (sched == NULL || schedid == -1 || schedid >= schedMax ||
|
||||
(s = sched[schedid]) == NULL) {
|
||||
return;
|
||||
}
|
||||
@@ -177,7 +177,7 @@ void emfSchedProcess(void)
|
||||
{
|
||||
sched_t *s;
|
||||
int schedid;
|
||||
static int next = 0;
|
||||
static int next = 0;
|
||||
|
||||
/*
|
||||
* If schedMax is 0, there are no tasks scheduled, so just return.
|
||||
@@ -206,7 +206,7 @@ void emfSchedProcess(void)
|
||||
}
|
||||
if (schedid == next) {
|
||||
/*
|
||||
* We've gone all the way through the queue without finding
|
||||
* We've gone all the way through the queue without finding
|
||||
* anything to do so just return.
|
||||
*/
|
||||
return;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/*
|
||||
/*
|
||||
* wsIntrn.h -- Internal GoAhead Web server header
|
||||
*
|
||||
* Copyright (c) GoAhead Software Inc., 1992-2000. All Rights Reserved.
|
||||
@@ -7,13 +7,13 @@
|
||||
*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _h_WEBS_INTERNAL
|
||||
#define _h_WEBS_INTERNAL 1
|
||||
|
||||
/******************************** Description *********************************/
|
||||
|
||||
/*
|
||||
/*
|
||||
* Internal GoAhead Web Server header. This defines the Web private APIs
|
||||
* Include this header when you want to create URL handlers.
|
||||
*/
|
||||
@@ -21,7 +21,7 @@
|
||||
/*********************************** Defines **********************************/
|
||||
|
||||
/*
|
||||
* Define this to enable logging of web accesses to a file
|
||||
* Define this to enable logging of web accesses to a file
|
||||
* #define WEBS_LOG_SUPPORT 1
|
||||
*
|
||||
* Define this to enable HTTP/1.1 keep alive support
|
||||
@@ -129,7 +129,7 @@
|
||||
#include "webs.h"
|
||||
|
||||
/********************************** Defines ***********************************/
|
||||
/*
|
||||
/*
|
||||
* Read handler flags and state
|
||||
*/
|
||||
#define WEBS_BEGIN 0x1 /* Beginning state */
|
||||
@@ -147,10 +147,10 @@
|
||||
/*
|
||||
* URL handler structure. Stores the leading URL path and the handler
|
||||
* function to call when the URL path is seen.
|
||||
*/
|
||||
*/
|
||||
typedef struct {
|
||||
int (*handler)(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
char_t *url, char_t *path,
|
||||
int (*handler)(webs_t wp, char_t *urlPrefix, char_t *webDir, int arg,
|
||||
char_t *url, char_t *path,
|
||||
char_t *query); /* Callback URL handler function */
|
||||
char_t *webDir; /* Web directory if required */
|
||||
char_t *urlPrefix; /* URL leading prefix */
|
||||
@@ -159,7 +159,7 @@ typedef struct {
|
||||
int flags; /* Flags */
|
||||
} websUrlHandlerType;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Webs statistics
|
||||
*/
|
||||
typedef struct {
|
||||
@@ -179,7 +179,7 @@ typedef struct {
|
||||
|
||||
extern websStatsType websStats; /* Web access stats */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Error code list
|
||||
*/
|
||||
typedef struct {
|
||||
@@ -187,7 +187,7 @@ typedef struct {
|
||||
char_t *msg; /* HTTP error message */
|
||||
} websErrorType;
|
||||
|
||||
/*
|
||||
/*
|
||||
* Mime type list
|
||||
*/
|
||||
typedef struct {
|
||||
@@ -244,8 +244,8 @@ extern void websFormOpen(void);
|
||||
extern void websFormClose(void);
|
||||
extern int websAspWrite(int ejid, webs_t wp, int argc, char_t **argv);
|
||||
extern void websDefaultClose(void);
|
||||
extern int websDefaultHandler(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
extern int websDefaultHandler(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *query);
|
||||
extern int websFormHandler(webs_t wp, char_t *urlPrefix, char_t *webDir,
|
||||
int arg, char_t *url, char_t *path, char_t *query);
|
||||
@@ -258,7 +258,7 @@ extern char_t *websGetCgiCommName(void);
|
||||
extern int websLaunchCgiProc(char_t *cgiPath, char_t **argp,
|
||||
char_t **envp, char_t *stdIn, char_t *stdOut);
|
||||
extern int websOpen(int sid);
|
||||
extern void websResponse(webs_t wp, int code, char_t *msg,
|
||||
extern void websResponse(webs_t wp, int code, char_t *msg,
|
||||
char_t *redirect);
|
||||
extern int websJavaScriptEval(webs_t wp, char_t *script);
|
||||
extern int websPageReadData(webs_t wp, char *buf, int nBytes);
|
||||
@@ -276,10 +276,10 @@ extern void websRomPageClose(int fd);
|
||||
extern int websRomPageReadData(webs_t wp, char *buf, int len);
|
||||
extern int websRomPageStat(char_t *path, websStatType *sbuf);
|
||||
extern long websRomPageSeek(webs_t wp, long offset, int origin);
|
||||
extern void websSetRequestSocketHandler(webs_t wp, int mask,
|
||||
extern void websSetRequestSocketHandler(webs_t wp, int mask,
|
||||
void (*fn)(webs_t wp));
|
||||
extern int websSolutionHandler(webs_t wp, char_t *urlPrefix,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *webDir, int arg, char_t *url, char_t *path,
|
||||
char_t *query);
|
||||
extern void websUrlHandlerClose(void);
|
||||
extern int websUrlHandlerOpen(void);
|
||||
@@ -290,7 +290,7 @@ extern char_t* websGetDateString(websStatType* sbuf);
|
||||
extern int strcmpci(char_t* s1, char_t* s2);
|
||||
|
||||
/*
|
||||
* Prototypes for functions available when running as part of the
|
||||
* Prototypes for functions available when running as part of the
|
||||
* GoAhead Embedded Management Framework (EMF)
|
||||
*/
|
||||
#ifdef EMF
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
/**
|
||||
* @file libfs/devfs/devfs.h
|
||||
*
|
||||
* This include file contains all constants and structures associated
|
||||
@@ -18,7 +18,7 @@ extern "C" {
|
||||
* This structure define the type of device table
|
||||
*/
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
/** This member points to device name which is a null-terminated string */
|
||||
char *device_name;
|
||||
@@ -44,7 +44,7 @@ extern int rtems_deviceio_errno(rtems_status_code code);
|
||||
|
||||
/**
|
||||
* The following defines the device table size. This values
|
||||
* is configured during application configuration time by
|
||||
* is configured during application configuration time by
|
||||
* the user. The default value is set to 4.
|
||||
*/
|
||||
|
||||
@@ -56,20 +56,20 @@ extern uint32_t rtems_device_table_size;
|
||||
* handlers.
|
||||
*/
|
||||
|
||||
extern rtems_filesystem_operations_table devFS_ops;
|
||||
extern rtems_filesystem_operations_table devFS_ops;
|
||||
|
||||
/**
|
||||
* The following defines the device-only filesystem operating
|
||||
* handlers.
|
||||
*/
|
||||
|
||||
extern rtems_filesystem_file_handlers_r devFS_file_handlers;
|
||||
extern rtems_filesystem_file_handlers_r devFS_file_handlers;
|
||||
|
||||
|
||||
/**
|
||||
* This handler maps open operation to rtems_io_open.
|
||||
* @param iop This is the RTEMS's internal representation of file.
|
||||
* @param pathname a null-terminated string that starts with /dev.
|
||||
* @param pathname a null-terminated string that starts with /dev.
|
||||
* @param flag access flags
|
||||
* @param mode access mode
|
||||
* @retval the same as open
|
||||
@@ -166,10 +166,10 @@ extern int devFS_stat(
|
||||
|
||||
/**
|
||||
* This routine is invoked upon determination of a node type.
|
||||
* Since this is a device-only filesystem, so there is only
|
||||
* Since this is a device-only filesystem, so there is only
|
||||
* one node type in the system.
|
||||
*
|
||||
* @param pathloc contains filesytem access information, this
|
||||
*
|
||||
* @param pathloc contains filesytem access information, this
|
||||
* parameter is ignored
|
||||
* @retval always returns RTEMS_FILESYSTEM_DEVICE
|
||||
*/
|
||||
@@ -182,14 +182,14 @@ extern int devFS_node_type(
|
||||
|
||||
/**
|
||||
* This routine is invoked to determine if 'pathname' exists.
|
||||
* This routine first check access flags, then it searches
|
||||
* This routine first check access flags, then it searches
|
||||
* the device table to get the information.
|
||||
*
|
||||
*
|
||||
* @param pathname device name to be searched
|
||||
* @param flags access flags
|
||||
* @param pathloc contains filesystem access information
|
||||
* @retval upon success(pathname exists), this routines
|
||||
* returns 0; if 'flag' is invalid, it returns -1 and errno
|
||||
* @retval upon success(pathname exists), this routines
|
||||
* returns 0; if 'flag' is invalid, it returns -1 and errno
|
||||
* is set to EIO; otherwise, it returns -1 and errno is set to ENOENT
|
||||
*/
|
||||
|
||||
@@ -202,19 +202,19 @@ extern int devFS_evaluate_path(
|
||||
|
||||
|
||||
/**
|
||||
* This routine is given a path to evaluate and a valid start
|
||||
* This routine is given a path to evaluate and a valid start
|
||||
* location. It is responsible for finding the parent node for
|
||||
* a requested make command, setting pathloc information to
|
||||
* identify the parent node, and setting the name pointer to
|
||||
* the first character of the name of the new node. In device
|
||||
* identify the parent node, and setting the name pointer to
|
||||
* the first character of the name of the new node. In device
|
||||
* only filesystem, devices do not has a tree hierarchy, there
|
||||
* are no parent-child relationship. So this routine is rather
|
||||
* are no parent-child relationship. So this routine is rather
|
||||
* simple, it just set *name to path and returns
|
||||
*
|
||||
* @param path device path to be evaluated
|
||||
* @param pathloc contains filesystem access information, this
|
||||
* @param pathloc contains filesystem access information, this
|
||||
* parameter is ignored
|
||||
* @param name
|
||||
* @param name
|
||||
* @retval always returns 0
|
||||
*/
|
||||
|
||||
@@ -228,9 +228,9 @@ extern int devFS_evaluate_for_make(
|
||||
|
||||
/**
|
||||
* This routine is invoked upon registration of a new device
|
||||
* file. It is responsible for creating a item in the main
|
||||
* device table. This routine searches the device table in
|
||||
* sequential order, when found a empty slot, it fills the slot
|
||||
* file. It is responsible for creating a item in the main
|
||||
* device table. This routine searches the device table in
|
||||
* sequential order, when found a empty slot, it fills the slot
|
||||
* with proper values.
|
||||
*
|
||||
* @param path the device file name to be registered
|
||||
@@ -239,15 +239,15 @@ extern int devFS_evaluate_for_make(
|
||||
* @param pathloc contains filesystem access information
|
||||
* @retval upon success, this routine returns 0; if 'path'
|
||||
* already exist, it returns -1 and errno is set to EEXIST;
|
||||
* if device table is full, it returns -1 and errno is set
|
||||
* if device table is full, it returns -1 and errno is set
|
||||
* to ENOMEM
|
||||
*/
|
||||
|
||||
extern int devFS_mknod(
|
||||
const char *path,
|
||||
mode_t mode,
|
||||
dev_t dev,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
mode_t mode,
|
||||
dev_t dev,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
);
|
||||
|
||||
|
||||
@@ -256,10 +256,10 @@ extern int devFS_mknod(
|
||||
* It is responsible for creating the main device table,
|
||||
* initializing it to a known state, and set device file operation
|
||||
* handlers. After this, the device-only filesytem is ready for use
|
||||
*
|
||||
*
|
||||
* @param temp_mt_entry
|
||||
* @retval upon success, this routine returns 0; otherwise it returns
|
||||
* -1 and errno is set to proper value. The only error is when malloc
|
||||
* -1 and errno is set to proper value. The only error is when malloc
|
||||
* failed, and errno is set to NOMEM.
|
||||
*/
|
||||
|
||||
@@ -272,15 +272,15 @@ extern int devFS_initialize(
|
||||
* This routine retrieves all the device registered in system, and
|
||||
* prints out their detail information. For example, on one system,
|
||||
* devFS_show will print out following message:
|
||||
*
|
||||
*
|
||||
* /dev/console 0 0
|
||||
* /dev/clock 1 0
|
||||
* /dev/tty0 0 0
|
||||
* /flash 2 0
|
||||
*
|
||||
* This routine is intended for debugging, and can be used by shell
|
||||
*
|
||||
* This routine is intended for debugging, and can be used by shell
|
||||
* program to provide user with the system information.
|
||||
*
|
||||
*
|
||||
* @param none
|
||||
* @retval 0
|
||||
*/
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <rtems/score/wkspace.h>
|
||||
#include "devfs.h"
|
||||
|
||||
rtems_filesystem_operations_table devFS_ops =
|
||||
rtems_filesystem_operations_table devFS_ops =
|
||||
{
|
||||
devFS_evaluate_path,
|
||||
devFS_evaluate_for_make,
|
||||
@@ -38,7 +38,7 @@ rtems_filesystem_operations_table devFS_ops =
|
||||
};
|
||||
|
||||
|
||||
rtems_filesystem_file_handlers_r devFS_file_handlers =
|
||||
rtems_filesystem_file_handlers_r devFS_file_handlers =
|
||||
{
|
||||
devFS_open,
|
||||
devFS_close,
|
||||
@@ -74,7 +74,7 @@ int devFS_initialize(
|
||||
rtems_set_errno_and_return_minus_one( ENOMEM );
|
||||
|
||||
memset(
|
||||
device_name_table, 0,
|
||||
device_name_table, 0,
|
||||
sizeof( rtems_device_name_t ) * ( rtems_device_table_size )
|
||||
);
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@
|
||||
|
||||
int devFS_mknod(
|
||||
const char *path,
|
||||
mode_t mode,
|
||||
dev_t dev,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
mode_t mode,
|
||||
dev_t dev,
|
||||
rtems_filesystem_location_info_t *pathloc
|
||||
)
|
||||
{
|
||||
int i;
|
||||
@@ -35,14 +35,14 @@ int devFS_mknod(
|
||||
ISR_Level level;
|
||||
|
||||
/*
|
||||
* This is a special case. In rtems_filesystem_initialize,
|
||||
* a special device '/dev' will be created. We check this
|
||||
* condition and do not create the '/dev' and the 'path'
|
||||
* This is a special case. In rtems_filesystem_initialize,
|
||||
* a special device '/dev' will be created. We check this
|
||||
* condition and do not create the '/dev' and the 'path'
|
||||
* actually passed in is 'dev', not '/dev'. Just return 0 to
|
||||
* indicate we are OK.
|
||||
*/
|
||||
|
||||
if ((path[0] == 'd') && (path[1] == 'e') &&
|
||||
if ((path[0] == 'd') && (path[1] == 'e') &&
|
||||
(path[2] == 'v') && (path[3] == '\0'))
|
||||
return 0;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ int devFS_node_type(
|
||||
)
|
||||
{
|
||||
/*
|
||||
* There is only one type of node: device
|
||||
* There is only one type of node: device
|
||||
*/
|
||||
|
||||
return RTEMS_FILESYSTEM_DEVICE;
|
||||
|
||||
@@ -26,7 +26,7 @@ int devFS_Show(void)
|
||||
|
||||
for (i = 0; i < rtems_device_table_size; i++){
|
||||
if (device_name_table[i].device_name){
|
||||
printk("/%s %d %d\n", device_name_table[i].device_name,
|
||||
printk("/%s %d %d\n", device_name_table[i].device_name,
|
||||
device_name_table[i].major, device_name_table[i].minor);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* Application interface to MSDOS filesystem.
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
* Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia
|
||||
* Author: Eugeny S. Mints <Eugeny.Mints@oktet.ru>
|
||||
@@ -14,7 +14,7 @@
|
||||
*
|
||||
* @(#) $Id$
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _RTEMS_DOSFS_H
|
||||
#define _RTEMS_DOSFS_H
|
||||
|
||||
|
||||
@@ -281,7 +281,7 @@ _fat_block_release(
|
||||
fat_fs_info_t *fs_info = mt_entry->fs_info;
|
||||
return fat_buf_release(fs_info);
|
||||
}
|
||||
|
||||
|
||||
/* fat_cluster_read --
|
||||
* wrapper for reading a whole cluster at once
|
||||
*
|
||||
@@ -398,9 +398,9 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
|
||||
/* Evaluate boot record */
|
||||
vol->bps = FAT_GET_BR_BYTES_PER_SECTOR(boot_rec);
|
||||
|
||||
if ( (vol->bps != 512) &&
|
||||
(vol->bps != 1024) &&
|
||||
|
||||
if ( (vol->bps != 512) &&
|
||||
(vol->bps != 1024) &&
|
||||
(vol->bps != 2048) &&
|
||||
(vol->bps != 4096))
|
||||
{
|
||||
@@ -443,7 +443,7 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
vol->fat_loc = FAT_GET_BR_RESERVED_SECTORS_NUM(boot_rec);
|
||||
|
||||
vol->rdir_entrs = FAT_GET_BR_FILES_PER_ROOT_DIR(boot_rec);
|
||||
|
||||
|
||||
/* calculate the count of sectors occupied by the root directory */
|
||||
vol->rdir_secs = ((vol->rdir_entrs * FAT_DIRENTRY_SIZE) + (vol->bps - 1)) /
|
||||
vol->bps;
|
||||
@@ -454,18 +454,18 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
vol->fat_length = FAT_GET_BR_SECTORS_PER_FAT(boot_rec);
|
||||
else
|
||||
vol->fat_length = FAT_GET_BR_SECTORS_PER_FAT32(boot_rec);
|
||||
|
||||
vol->data_fsec = vol->fat_loc + vol->fats * vol->fat_length +
|
||||
|
||||
vol->data_fsec = vol->fat_loc + vol->fats * vol->fat_length +
|
||||
vol->rdir_secs;
|
||||
|
||||
/* for FAT12/16 root dir starts at(sector) */
|
||||
vol->rdir_loc = vol->fat_loc + vol->fats * vol->fat_length;
|
||||
|
||||
|
||||
if ( (FAT_GET_BR_TOTAL_SECTORS_NUM16(boot_rec)) != 0)
|
||||
vol->tot_secs = FAT_GET_BR_TOTAL_SECTORS_NUM16(boot_rec);
|
||||
else
|
||||
vol->tot_secs = FAT_GET_BR_TOTAL_SECTORS_NUM32(boot_rec);
|
||||
|
||||
|
||||
data_secs = vol->tot_secs - vol->data_fsec;
|
||||
|
||||
vol->data_cls = data_secs / vol->spc;
|
||||
@@ -496,7 +496,7 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
if (vol->type == FAT_FAT32)
|
||||
{
|
||||
vol->rdir_cl = FAT_GET_BR_FAT32_ROOT_CLUSTER(boot_rec);
|
||||
|
||||
|
||||
vol->mirror = FAT_GET_BR_EXT_FLAGS(boot_rec) & FAT_BR_EXT_FLAGS_MIRROR;
|
||||
if (vol->mirror)
|
||||
vol->afat = FAT_GET_BR_EXT_FLAGS(boot_rec) & FAT_BR_EXT_FLAGS_FAT_NUM;
|
||||
@@ -517,9 +517,9 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
{
|
||||
rtems_disk_release(vol->dd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (FAT_GET_FSINFO_LEAD_SIGNATURE(fs_info_sector) !=
|
||||
}
|
||||
|
||||
if (FAT_GET_FSINFO_LEAD_SIGNATURE(fs_info_sector) !=
|
||||
FAT_FSINFO_LEAD_SIGNATURE_VALUE)
|
||||
{
|
||||
_fat_block_release(mt_entry);
|
||||
@@ -535,11 +535,11 @@ fat_init_volume_info(rtems_filesystem_mount_table_entry_t *mt_entry)
|
||||
_fat_block_release(mt_entry);
|
||||
rtems_disk_release(vol->dd);
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
vol->free_cls = FAT_GET_FSINFO_FREE_CLUSTER_COUNT(fs_info_sector);
|
||||
vol->next_cl = FAT_GET_FSINFO_NEXT_FREE_CLUSTER(fs_info_sector);
|
||||
rc = fat_fat32_update_fsinfo_sector(mt_entry, 0xFFFFFFFF,
|
||||
rc = fat_fat32_update_fsinfo_sector(mt_entry, 0xFFFFFFFF,
|
||||
0xFFFFFFFF);
|
||||
if ( rc != RC_OK )
|
||||
{
|
||||
|
||||
@@ -50,7 +50,7 @@ extern "C" {
|
||||
# define CF_LE_L(v) CPU_swap_u32((uint32_t)(v))
|
||||
# define CT_LE_W(v) CPU_swap_u16((uint16_t)(v))
|
||||
# define CT_LE_L(v) CPU_swap_u32((uint32_t)(v))
|
||||
#else
|
||||
#else
|
||||
# define CF_LE_W(v) (v)
|
||||
# define CF_LE_L(v) (v)
|
||||
# define CT_LE_W(v) (v)
|
||||
@@ -103,7 +103,7 @@ extern "C" {
|
||||
|
||||
#define FAT_GET_ADDR(x, ofs) ((uint8_t *)(x) + (ofs))
|
||||
|
||||
#define FAT_GET_VAL8(x, ofs) (uint8_t)(*((uint8_t *)(x) + (ofs)))
|
||||
#define FAT_GET_VAL8(x, ofs) (uint8_t)(*((uint8_t *)(x) + (ofs)))
|
||||
|
||||
#define FAT_GET_VAL16(x, ofs) \
|
||||
(uint16_t)( (*((uint8_t *)(x) + (ofs))) | \
|
||||
@@ -114,10 +114,10 @@ extern "C" {
|
||||
((uint32_t)(*((uint8_t *)(x) + (ofs) + 1)) << 8) | \
|
||||
((uint32_t)(*((uint8_t *)(x) + (ofs) + 2)) << 16) | \
|
||||
((uint32_t)(*((uint8_t *)(x) + (ofs) + 3)) << 24) )
|
||||
|
||||
|
||||
#define FAT_SET_VAL8(x, ofs,val) \
|
||||
(*((uint8_t *)(x)+(ofs))=(uint8_t)(val))
|
||||
|
||||
|
||||
#define FAT_SET_VAL16(x, ofs,val) do { \
|
||||
FAT_SET_VAL8((x),(ofs),(val)); \
|
||||
FAT_SET_VAL8((x),(ofs)+1,(val)>>8);\
|
||||
@@ -139,8 +139,8 @@ extern "C" {
|
||||
#define FAT_GET_BR_BYTES_PER_SECTOR(x) FAT_GET_VAL16(x, 11)
|
||||
#define FAT_SET_BR_BYTES_PER_SECTOR(x,val) FAT_SET_VAL16(x, 11,val)
|
||||
|
||||
#define FAT_GET_BR_SECTORS_PER_CLUSTER(x) FAT_GET_VAL8( x, 13)
|
||||
#define FAT_SET_BR_SECTORS_PER_CLUSTER(x,val)FAT_SET_VAL8( x, 13,val)
|
||||
#define FAT_GET_BR_SECTORS_PER_CLUSTER(x) FAT_GET_VAL8( x, 13)
|
||||
#define FAT_SET_BR_SECTORS_PER_CLUSTER(x,val)FAT_SET_VAL8( x, 13,val)
|
||||
|
||||
#define FAT_GET_BR_RESERVED_SECTORS_NUM(x) FAT_GET_VAL16(x, 14)
|
||||
#define FAT_SET_BR_RESERVED_SECTORS_NUM(x,val) FAT_SET_VAL16(x, 14,val)
|
||||
@@ -154,8 +154,8 @@ extern "C" {
|
||||
#define FAT_GET_BR_TOTAL_SECTORS_NUM16(x) FAT_GET_VAL16(x, 19)
|
||||
#define FAT_SET_BR_TOTAL_SECTORS_NUM16(x,val)FAT_SET_VAL16(x, 19,val)
|
||||
|
||||
#define FAT_GET_BR_MEDIA(x) FAT_GET_VAL8( x, 21)
|
||||
#define FAT_SET_BR_MEDIA(x,val) FAT_SET_VAL8( x, 21,val)
|
||||
#define FAT_GET_BR_MEDIA(x) FAT_GET_VAL8( x, 21)
|
||||
#define FAT_SET_BR_MEDIA(x,val) FAT_SET_VAL8( x, 21,val)
|
||||
|
||||
#define FAT_GET_BR_SECTORS_PER_FAT(x) FAT_GET_VAL16(x, 22)
|
||||
#define FAT_SET_BR_SECTORS_PER_FAT(x,val) FAT_SET_VAL16(x, 22,val)
|
||||
@@ -251,8 +251,8 @@ extern "C" {
|
||||
#define FAT_GET_FSINFO_TRAIL_SIGNATURE(x) FAT_GET_VAL32(x,508)
|
||||
#define FAT_SET_FSINFO_TRAIL_SIGNATURE(x,val) FAT_SET_VAL32(x,508,val)
|
||||
#define FAT_FSINFO_TRAIL_SIGNATURE_VALUE (0xAA550000)
|
||||
/*
|
||||
* I read FSInfo sector from offset 484 to access the information, so offsets
|
||||
/*
|
||||
* I read FSInfo sector from offset 484 to access the information, so offsets
|
||||
* of these fields a relative
|
||||
*/
|
||||
#define FAT_GET_FSINFO_FREE_CLUSTER_COUNT(x) FAT_GET_VAL32(x, 4)
|
||||
|
||||
@@ -115,7 +115,7 @@ fat_file_open(
|
||||
rtems_set_errno_and_return_minus_one( ENOMEM );
|
||||
|
||||
memset(lfat_fd, 0, sizeof(fat_file_fd_t));
|
||||
|
||||
|
||||
lfat_fd->links_num = 1;
|
||||
lfat_fd->flags &= ~FAT_FILE_REMOVED;
|
||||
lfat_fd->map.last_cln = FAT_UNDEFINED_VALUE;
|
||||
@@ -584,7 +584,7 @@ fat_file_extend(
|
||||
}
|
||||
|
||||
fat_fd->fat_file_size = new_length;
|
||||
|
||||
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +274,7 @@ msdos_filename_unix2dos(const char *un, int unlen, char *dn)
|
||||
un++;
|
||||
unlen--;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Copy the unix filename into the dos filename string upto the end
|
||||
* of string, a '.', or 8 characters. Whichever happens first stops
|
||||
|
||||
@@ -80,7 +80,7 @@ msdos_creat_node(rtems_filesystem_location_info_t *parent_loc,
|
||||
uint32_t byte = 0;
|
||||
|
||||
fat_dir_pos_init(&dir_pos);
|
||||
|
||||
|
||||
memset(short_node, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
memset(dot_dotdot, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE * 2);
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "config.h"
|
||||
#endif
|
||||
|
||||
#include <ctype.h>
|
||||
#include <ctype.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
@@ -258,7 +258,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
for (i = 0; i < ret; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
|
||||
{
|
||||
char* entry = (char*) fs_info->cl_buf + i;
|
||||
|
||||
|
||||
/*
|
||||
* Is this directory from here on empty ?
|
||||
*/
|
||||
@@ -288,7 +288,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
int o;
|
||||
char* p;
|
||||
int q;
|
||||
|
||||
|
||||
/*
|
||||
* Is this is the first entry of a LFN ?
|
||||
*/
|
||||
@@ -306,7 +306,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
*/
|
||||
lfn_start =
|
||||
((j * bts2rd) + i) / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE;
|
||||
|
||||
|
||||
/*
|
||||
* Get the number of entries so we can count down and
|
||||
* also the checksum of the short entry.
|
||||
@@ -330,7 +330,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
lfn_start = FAT_FILE_SHORT_NAME;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Extract the file name into the directory entry. The data is
|
||||
* stored in UNICODE characters (16bit). No translation is
|
||||
@@ -340,16 +340,16 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
* trailing nul character. We need to range check the length to
|
||||
* fit in the directory entry name field.
|
||||
*/
|
||||
|
||||
|
||||
lfn_entries--;
|
||||
p = entry + 1;
|
||||
o = lfn_entries * MSDOS_LFN_LEN_PER_ENTRY;
|
||||
|
||||
|
||||
for (q = 0; q < MSDOS_LFN_LEN_PER_ENTRY; q++)
|
||||
{
|
||||
if (o >= (sizeof(tmp_dirent.d_name) - 1))
|
||||
break;
|
||||
|
||||
|
||||
tmp_dirent.d_name[o++] = *p;
|
||||
|
||||
if (*p == '\0')
|
||||
@@ -372,7 +372,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
else
|
||||
{
|
||||
fat_dir_pos_t dir_pos;
|
||||
|
||||
|
||||
/*
|
||||
* Skip active entries until get the entry to start from.
|
||||
*/
|
||||
@@ -446,7 +446,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
{
|
||||
tmp_dirent.d_namlen = strlen(tmp_dirent.d_name);
|
||||
}
|
||||
|
||||
|
||||
memcpy(buffer + cmpltd, &tmp_dirent, sizeof(struct dirent));
|
||||
|
||||
iop->offset = iop->offset + sizeof(struct dirent);
|
||||
@@ -461,7 +461,7 @@ msdos_dir_read(rtems_libio_t *iop, void *buffer, size_t count)
|
||||
return rc;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (count <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ static int msdos_format_fill_sectors
|
||||
char *fill_buffer = NULL;
|
||||
uint32_t total_sectors = sector_cnt;
|
||||
int last_percent = -1;
|
||||
|
||||
|
||||
/*
|
||||
* allocate and fill buffer
|
||||
*/
|
||||
@@ -200,7 +200,7 @@ static int msdos_format_fill_sectors
|
||||
/*
|
||||
* write to consecutive sectors
|
||||
*/
|
||||
while ((ret_val == 0) &&
|
||||
while ((ret_val == 0) &&
|
||||
(sector_cnt > 0)) {
|
||||
int percent = (sector_cnt * 100) / total_sectors;
|
||||
if (percent != last_percent) {
|
||||
@@ -212,13 +212,13 @@ static int msdos_format_fill_sectors
|
||||
start_sector++;
|
||||
sector_cnt--;
|
||||
}
|
||||
|
||||
|
||||
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL, "\n");
|
||||
|
||||
if (ret_val)
|
||||
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_INFO,
|
||||
"filling error on sector: %d\n", start_sector);
|
||||
|
||||
|
||||
/*
|
||||
* cleanup
|
||||
*/
|
||||
@@ -301,7 +301,7 @@ static int msdos_format_eval_sectors_per_cluster
|
||||
while (MS_BYTES_PER_CLUSTER_LIMIT / bytes_per_sector < sectors_per_cluster) {
|
||||
sectors_per_cluster /= 2;
|
||||
}
|
||||
|
||||
|
||||
do {
|
||||
/*
|
||||
* compute number of data clusters for current data:
|
||||
@@ -320,7 +320,7 @@ static int msdos_format_eval_sectors_per_cluster
|
||||
fat_capacity = fatdata_cluster_cnt * 4;
|
||||
}
|
||||
|
||||
sectors_per_fat = ((fat_capacity
|
||||
sectors_per_fat = ((fat_capacity
|
||||
+ (bytes_per_sector - 1))
|
||||
/ bytes_per_sector);
|
||||
|
||||
@@ -341,7 +341,7 @@ static int msdos_format_eval_sectors_per_cluster
|
||||
/*
|
||||
* when maximum cluster size is exceeded, we have invalid data, abort...
|
||||
*/
|
||||
if ((sectors_per_cluster * bytes_per_sector)
|
||||
if ((sectors_per_cluster * bytes_per_sector)
|
||||
> MS_BYTES_PER_CLUSTER_LIMIT) {
|
||||
ret_val = EINVAL;
|
||||
finished = true;
|
||||
@@ -384,9 +384,9 @@ static int msdos_format_determine_fmt_params
|
||||
uint32_t onebit;
|
||||
uint32_t sectors_per_cluster_adj = 0;
|
||||
uint64_t total_size = 0;
|
||||
|
||||
|
||||
memset(fmt_params,0,sizeof(*fmt_params));
|
||||
/*
|
||||
/*
|
||||
* this one is fixed in this implementation.
|
||||
* At least one thing we don't have to magically guess...
|
||||
*/
|
||||
@@ -402,7 +402,7 @@ static int msdos_format_determine_fmt_params
|
||||
* determine number of FATs
|
||||
*/
|
||||
if (ret_val == 0) {
|
||||
if ((rqdata == NULL) ||
|
||||
if ((rqdata == NULL) ||
|
||||
(rqdata->fat_num == 0)) {
|
||||
fmt_params->fat_num = 2;
|
||||
}
|
||||
@@ -413,33 +413,33 @@ static int msdos_format_determine_fmt_params
|
||||
ret_val = EINVAL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ret_val == 0)
|
||||
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
|
||||
"number of fats: %d\n", fmt_params->fat_num);
|
||||
|
||||
|
||||
/*
|
||||
* Now we get sort of a loop when determining things:
|
||||
* The FAT type (FAT12/16/32) is determined ONLY from the
|
||||
* The FAT type (FAT12/16/32) is determined ONLY from the
|
||||
* data cluster count:
|
||||
* Disks with data cluster count < 4085 are FAT12.
|
||||
* Disks with data cluster count < 65525 are FAT16.
|
||||
* The rest is FAT32 (no FAT128 available yet :-)
|
||||
* The rest is FAT32 (no FAT128 available yet :-)
|
||||
*
|
||||
* The number of data clusters is the
|
||||
* total capacity
|
||||
* The number of data clusters is the
|
||||
* total capacity
|
||||
* minus reserved sectors
|
||||
* minus root directory ares
|
||||
* minus storage needed for the FAT (and its copy/copies).
|
||||
*
|
||||
*
|
||||
* The last item once again depends on the FAT type and the cluster count.
|
||||
*
|
||||
*
|
||||
* So here is what we do in this formatter:
|
||||
* - If a FAT type is requested from the caller, we try to modify
|
||||
* the cluster size, until the data cluster count is in range
|
||||
* - If no FAT type is given, we estimate a useful FAT type from
|
||||
* - If no FAT type is given, we estimate a useful FAT type from
|
||||
* the disk capacity and then adapt the cluster size
|
||||
*/
|
||||
*/
|
||||
|
||||
/*
|
||||
* determine characteristic values:
|
||||
@@ -450,19 +450,19 @@ static int msdos_format_determine_fmt_params
|
||||
*/
|
||||
/*
|
||||
* determine FAT type and sectors per cluster
|
||||
* depends on
|
||||
* depends on
|
||||
*/
|
||||
if (ret_val == 0) {
|
||||
fmt_params->sectors_per_cluster = 1;
|
||||
if ((rqdata != NULL) &&
|
||||
if ((rqdata != NULL) &&
|
||||
(rqdata->fattype == MSDOS_FMT_FAT12)) {
|
||||
fmt_params->fattype = FAT_FAT12;
|
||||
}
|
||||
else if ((rqdata != NULL) &&
|
||||
else if ((rqdata != NULL) &&
|
||||
(rqdata->fattype == MSDOS_FMT_FAT16)) {
|
||||
fmt_params->fattype = FAT_FAT16;
|
||||
}
|
||||
else if ((rqdata != NULL) &&
|
||||
else if ((rqdata != NULL) &&
|
||||
(rqdata->fattype == MSDOS_FMT_FAT32)) {
|
||||
fmt_params->fattype = FAT_FAT32;
|
||||
}
|
||||
@@ -477,17 +477,17 @@ static int msdos_format_determine_fmt_params
|
||||
* NOTE: maximum sect_per_clust is arbitrarily choosen with values that
|
||||
* are a compromise concerning capacity and efficency
|
||||
*/
|
||||
if (fmt_params->totl_sector_cnt
|
||||
if (fmt_params->totl_sector_cnt
|
||||
< ((uint32_t)FAT_FAT12_MAX_CLN)*8) {
|
||||
fmt_params->fattype = FAT_FAT12;
|
||||
/* start trying with small clusters */
|
||||
fmt_params->sectors_per_cluster = 2;
|
||||
fmt_params->sectors_per_cluster = 2;
|
||||
}
|
||||
else if (fmt_params->totl_sector_cnt
|
||||
else if (fmt_params->totl_sector_cnt
|
||||
< ((uint32_t)FAT_FAT16_MAX_CLN)*32) {
|
||||
fmt_params->fattype = FAT_FAT16;
|
||||
/* start trying with small clusters */
|
||||
fmt_params->sectors_per_cluster = 2;
|
||||
fmt_params->sectors_per_cluster = 2;
|
||||
}
|
||||
else {
|
||||
#define ONE_GB (1024L * 1024L * 1024L)
|
||||
@@ -504,10 +504,10 @@ static int msdos_format_determine_fmt_params
|
||||
/*
|
||||
* try to use user requested cluster size
|
||||
*/
|
||||
if ((rqdata != NULL) &&
|
||||
if ((rqdata != NULL) &&
|
||||
(rqdata->sectors_per_cluster > 0)) {
|
||||
fmt_params->sectors_per_cluster =
|
||||
rqdata->sectors_per_cluster;
|
||||
fmt_params->sectors_per_cluster =
|
||||
rqdata->sectors_per_cluster;
|
||||
}
|
||||
/*
|
||||
* check sectors per cluster.
|
||||
@@ -518,7 +518,7 @@ static int msdos_format_determine_fmt_params
|
||||
for (onebit = 128;onebit >= 1;onebit = onebit>>1) {
|
||||
if (fmt_params->sectors_per_cluster >= onebit) {
|
||||
fmt_params->sectors_per_cluster = onebit;
|
||||
if (fmt_params->sectors_per_cluster
|
||||
if (fmt_params->sectors_per_cluster
|
||||
<= 32768L/fmt_params->bytes_per_sector) {
|
||||
/* value is small enough so this value is ok */
|
||||
onebit = 1;
|
||||
@@ -530,7 +530,7 @@ static int msdos_format_determine_fmt_params
|
||||
if (ret_val == 0) {
|
||||
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
|
||||
"sectors per cluster: %d\n", fmt_params->sectors_per_cluster);
|
||||
|
||||
|
||||
if (fmt_params->fattype == FAT_FAT32) {
|
||||
/* recommended: for FAT32, always set reserved sector count to 32 */
|
||||
fmt_params->rsvd_sector_cnt = 32;
|
||||
@@ -548,7 +548,7 @@ static int msdos_format_determine_fmt_params
|
||||
/* recommended: for FAT16, set files per root directory to 512 */
|
||||
/* for FAT12/FAT16, set files per root directory */
|
||||
/* must fill up an even count of sectors */
|
||||
if ((rqdata != NULL) &&
|
||||
if ((rqdata != NULL) &&
|
||||
(rqdata->files_per_root_dir > 0)) {
|
||||
fmt_params->files_per_root_dir = rqdata->files_per_root_dir;
|
||||
}
|
||||
@@ -560,23 +560,23 @@ static int msdos_format_determine_fmt_params
|
||||
fmt_params->files_per_root_dir = 64;
|
||||
}
|
||||
}
|
||||
fmt_params->files_per_root_dir = (fmt_params->files_per_root_dir +
|
||||
fmt_params->files_per_root_dir = (fmt_params->files_per_root_dir +
|
||||
(2*fmt_params->bytes_per_sector/
|
||||
FAT_DIRENTRY_SIZE-1));
|
||||
fmt_params->files_per_root_dir -= (fmt_params->files_per_root_dir %
|
||||
fmt_params->files_per_root_dir -= (fmt_params->files_per_root_dir %
|
||||
(2*fmt_params->bytes_per_sector
|
||||
/FAT_DIRENTRY_SIZE));
|
||||
}
|
||||
fmt_params->root_dir_sectors =
|
||||
fmt_params->root_dir_sectors =
|
||||
(((fmt_params->files_per_root_dir * FAT_DIRENTRY_SIZE)
|
||||
+ fmt_params->bytes_per_sector - 1)
|
||||
+ fmt_params->bytes_per_sector - 1)
|
||||
/ fmt_params->bytes_per_sector);
|
||||
}
|
||||
if (ret_val == 0) {
|
||||
fatdata_sect_cnt = (fmt_params->totl_sector_cnt -
|
||||
fmt_params->rsvd_sector_cnt -
|
||||
fatdata_sect_cnt = (fmt_params->totl_sector_cnt -
|
||||
fmt_params->rsvd_sector_cnt -
|
||||
fmt_params->root_dir_sectors);
|
||||
|
||||
|
||||
/*
|
||||
* check values to get legal arrangement of FAT type and cluster count
|
||||
*/
|
||||
@@ -596,9 +596,9 @@ static int msdos_format_determine_fmt_params
|
||||
* determine media code
|
||||
*/
|
||||
if (ret_val == 0) {
|
||||
if ((rqdata != NULL) &&
|
||||
if ((rqdata != NULL) &&
|
||||
(rqdata->media != 0)) {
|
||||
const char valid_media_codes[] =
|
||||
const char valid_media_codes[] =
|
||||
{0xF0,0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF};
|
||||
if (NULL==memchr(valid_media_codes,
|
||||
rqdata->media,
|
||||
@@ -619,18 +619,18 @@ static int msdos_format_determine_fmt_params
|
||||
* for formatting
|
||||
*/
|
||||
if (fmt_params->root_dir_sectors > 0) {
|
||||
fmt_params->root_dir_start_sec =
|
||||
fmt_params->root_dir_start_sec =
|
||||
fmt_params->rsvd_sector_cnt
|
||||
+ (fmt_params-> fat_num*fmt_params->sectors_per_fat);
|
||||
+ (fmt_params-> fat_num*fmt_params->sectors_per_fat);
|
||||
fmt_params->root_dir_fmt_sec_cnt = fmt_params->root_dir_sectors;
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* for FAT32: root directory is in cluster 2
|
||||
*/
|
||||
fmt_params->root_dir_start_sec =
|
||||
fmt_params->root_dir_start_sec =
|
||||
fmt_params->rsvd_sector_cnt
|
||||
+ (fmt_params-> fat_num*fmt_params->sectors_per_fat);
|
||||
+ (fmt_params-> fat_num*fmt_params->sectors_per_fat);
|
||||
fmt_params->root_dir_fmt_sec_cnt = fmt_params->sectors_per_cluster;
|
||||
}
|
||||
/*
|
||||
@@ -653,8 +653,8 @@ static int msdos_format_determine_fmt_params
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* non-printable character in given name, so keep stuck
|
||||
* at that character and replace all following characters
|
||||
* non-printable character in given name, so keep stuck
|
||||
* at that character and replace all following characters
|
||||
* with a ' '
|
||||
*/
|
||||
*to++=' ';
|
||||
@@ -684,8 +684,8 @@ static int msdos_format_determine_fmt_params
|
||||
}
|
||||
else {
|
||||
/*
|
||||
* non-printable character in given name, so keep stuck
|
||||
* at that character and replace all following characters
|
||||
* non-printable character in given name, so keep stuck
|
||||
* at that character and replace all following characters
|
||||
* with a ' '
|
||||
*/
|
||||
*to++=' ';
|
||||
@@ -693,7 +693,7 @@ static int msdos_format_determine_fmt_params
|
||||
*to = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* determine usable Volume ID
|
||||
*/
|
||||
@@ -754,7 +754,7 @@ static int msdos_format_gen_mbr
|
||||
* with 0xEB,....
|
||||
*/
|
||||
/*
|
||||
* fill OEMName
|
||||
* fill OEMName
|
||||
*/
|
||||
memcpy(FAT_GET_ADDR_BR_OEMNAME(mbr),
|
||||
fmt_params->OEMName,
|
||||
@@ -762,7 +762,7 @@ static int msdos_format_gen_mbr
|
||||
FAT_SET_BR_BYTES_PER_SECTOR(mbr , fmt_params->bytes_per_sector);
|
||||
FAT_SET_BR_SECTORS_PER_CLUSTER(mbr , fmt_params->sectors_per_cluster);
|
||||
FAT_SET_BR_RESERVED_SECTORS_NUM(mbr, fmt_params->rsvd_sector_cnt);
|
||||
|
||||
|
||||
/* number of FATs on medium */
|
||||
FAT_SET_BR_FAT_NUM(mbr , 2); /* standard/recommended value */
|
||||
FAT_SET_BR_FILES_PER_ROOT_DIR(mbr , fmt_params->files_per_root_dir);
|
||||
@@ -778,13 +778,13 @@ static int msdos_format_gen_mbr
|
||||
FAT_SET_BR_SECTORS_PER_FAT(mbr ,fmt_params->sectors_per_fat);
|
||||
FAT_SET_BR_DRVNUM(mbr , 0); /* only needed for INT13... */
|
||||
FAT_SET_BR_RSVD1(mbr , 0); /* fill with zero */
|
||||
FAT_SET_BR_BOOTSIG(mbr , FAT_BR_BOOTSIG_VAL);
|
||||
FAT_SET_BR_BOOTSIG(mbr , FAT_BR_BOOTSIG_VAL);
|
||||
FAT_SET_BR_VOLID(mbr , fmt_params->vol_id); /* volume id */
|
||||
memcpy(FAT_GET_ADDR_BR_VOLLAB(mbr),
|
||||
fmt_params->VolLabel,
|
||||
FAT_BR_VOLLAB_SIZE);
|
||||
memcpy(FAT_GET_ADDR_BR_FILSYSTYPE(mbr),
|
||||
(fmt_params->fattype == FAT_FAT12)
|
||||
(fmt_params->fattype == FAT_FAT12)
|
||||
? "FAT12 "
|
||||
: "FAT16 ",
|
||||
FAT_BR_FILSYSTYPE_SIZE);
|
||||
@@ -800,7 +800,7 @@ static int msdos_format_gen_mbr
|
||||
|
||||
FAT_SET_BR_FAT32_DRVNUM(mbr , 0); /* only needed for INT13... */
|
||||
FAT_SET_BR_FAT32_RSVD1(mbr , 0); /* fill with zero */
|
||||
FAT_SET_BR_FAT32_BOOTSIG(mbr ,FAT_BR_FAT32_BOOTSIG_VAL);
|
||||
FAT_SET_BR_FAT32_BOOTSIG(mbr ,FAT_BR_FAT32_BOOTSIG_VAL);
|
||||
FAT_SET_BR_FAT32_VOLID(mbr , 0); /* not set */
|
||||
memset(FAT_GET_ADDR_BR_FAT32_VOLLAB(mbr) ,0,FAT_BR_VOLLAB_SIZE);
|
||||
memcpy(FAT_GET_ADDR_BR_FAT32_FILSYSTYPE(mbr),
|
||||
@@ -820,7 +820,7 @@ static int msdos_format_gen_mbr
|
||||
FAT_SET_VAL8(mbr,2,0x90);
|
||||
/*
|
||||
* FIXME: a nice little PC boot loader would be nice here.
|
||||
* but where can I get one for free?
|
||||
* but where can I get one for free?
|
||||
*/
|
||||
/*
|
||||
* Phuuu.... That's it.
|
||||
@@ -847,7 +847,7 @@ static int msdos_format_gen_fsinfo
|
||||
\*=========================================================================*/
|
||||
{
|
||||
/*
|
||||
* clear fsinfo sector data
|
||||
* clear fsinfo sector data
|
||||
*/
|
||||
memset(fsinfo,0,FAT_TOTAL_FSINFO_SIZE);
|
||||
/*
|
||||
@@ -856,8 +856,8 @@ static int msdos_format_gen_fsinfo
|
||||
FAT_SET_FSINFO_LEAD_SIGNATURE (fsinfo,FAT_FSINFO_LEAD_SIGNATURE_VALUE );
|
||||
FAT_SET_FSINFO_STRUC_SIGNATURE(fsinfo,FAT_FSINFO_STRUC_SIGNATURE_VALUE);
|
||||
FAT_SET_FSINFO_TRAIL_SIGNATURE(fsinfo,FAT_FSINFO_TRAIL_SIGNATURE_VALUE);
|
||||
/*
|
||||
* write "empty" values for free cluster count and next cluster number
|
||||
/*
|
||||
* write "empty" values for free cluster count and next cluster number
|
||||
*/
|
||||
FAT_SET_FSINFO_FREE_CLUSTER_COUNT(fsinfo+FAT_FSI_INFO,
|
||||
0xffffffff);
|
||||
@@ -889,7 +889,7 @@ int msdos_format
|
||||
{
|
||||
char tmp_sec[FAT_TOTAL_MBR_SIZE];
|
||||
int rc;
|
||||
rtems_disk_device *dd = NULL;
|
||||
rtems_disk_device *dd = NULL;
|
||||
struct stat stat_buf;
|
||||
int ret_val = 0;
|
||||
int fd = -1;
|
||||
@@ -907,14 +907,14 @@ int msdos_format
|
||||
rc = stat(devname, &stat_buf);
|
||||
ret_val = rc;
|
||||
}
|
||||
|
||||
/* rtems feature: no block devices, all are character devices */
|
||||
|
||||
/* rtems feature: no block devices, all are character devices */
|
||||
if ((ret_val == 0) &&
|
||||
(!S_ISCHR(stat_buf.st_mode))) {
|
||||
errno = ENOTTY;
|
||||
ret_val = -1;
|
||||
}
|
||||
|
||||
|
||||
/* check that device is registered as block device and lock it */
|
||||
if (ret_val == 0) {
|
||||
dd = rtems_disk_obtain(stat_buf.st_rdev);
|
||||
@@ -934,8 +934,8 @@ int msdos_format
|
||||
if (fd == -1)
|
||||
{
|
||||
ret_val= -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* compute formatting parameters
|
||||
@@ -958,7 +958,7 @@ int msdos_format
|
||||
0xe5);
|
||||
}
|
||||
/*
|
||||
* create master boot record
|
||||
* create master boot record
|
||||
*/
|
||||
if (ret_val == 0) {
|
||||
/*
|
||||
@@ -975,7 +975,7 @@ int msdos_format
|
||||
"generate MRB sector\n");
|
||||
ret_val = msdos_format_gen_mbr(tmp_sec,&fmt_params);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* write master boot record to disk
|
||||
* also write copy of MBR to disk
|
||||
@@ -983,20 +983,20 @@ int msdos_format
|
||||
if (ret_val == 0) {
|
||||
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
|
||||
"write MRB sector\n");
|
||||
ret_val = msdos_format_write_sec(fd,
|
||||
0,
|
||||
ret_val = msdos_format_write_sec(fd,
|
||||
0,
|
||||
fmt_params.bytes_per_sector,
|
||||
tmp_sec);
|
||||
}
|
||||
if ((ret_val == 0) &&
|
||||
if ((ret_val == 0) &&
|
||||
(fmt_params.mbr_copy_sec != 0)) {
|
||||
/*
|
||||
* write copy of MBR
|
||||
*/
|
||||
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
|
||||
"write back up MRB sector\n");
|
||||
ret_val = msdos_format_write_sec(fd,
|
||||
fmt_params.mbr_copy_sec ,
|
||||
ret_val = msdos_format_write_sec(fd,
|
||||
fmt_params.mbr_copy_sec ,
|
||||
fmt_params.bytes_per_sector,
|
||||
tmp_sec);
|
||||
}
|
||||
@@ -1004,7 +1004,7 @@ int msdos_format
|
||||
/*
|
||||
* for FAT32: initialize info sector on disk
|
||||
*/
|
||||
if ((ret_val == 0) &&
|
||||
if ((ret_val == 0) &&
|
||||
(fmt_params.fsinfo_sec != 0)) {
|
||||
ret_val = msdos_format_gen_fsinfo(tmp_sec);
|
||||
}
|
||||
@@ -1013,7 +1013,7 @@ int msdos_format
|
||||
*/
|
||||
if ((ret_val == 0) &&
|
||||
(fmt_params.fsinfo_sec != 0)) {
|
||||
ret_val = msdos_format_write_sec(fd,
|
||||
ret_val = msdos_format_write_sec(fd,
|
||||
fmt_params.fsinfo_sec,
|
||||
fmt_params.bytes_per_sector,
|
||||
tmp_sec);
|
||||
@@ -1058,7 +1058,7 @@ int msdos_format
|
||||
tmp_sec);
|
||||
}
|
||||
/*
|
||||
* write FAT entry 0 as (0xffffff00|Media_type)EOC,
|
||||
* write FAT entry 0 as (0xffffff00|Media_type)EOC,
|
||||
* write FAT entry 1 as EOC
|
||||
* allocate directory in a FAT32 FS
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ msdos_is_valid_name_char(const char ch)
|
||||
if ((ch == '.') || isalnum(ch) ||
|
||||
(strchr("$%'-_@~`!(){}^#&", ch) != NULL))
|
||||
return MSDOS_NAME_SHORT;
|
||||
|
||||
|
||||
return MSDOS_NAME_INVALID;
|
||||
}
|
||||
|
||||
@@ -143,19 +143,19 @@ msdos_name_type(const char *name, int name_len)
|
||||
uppercase = true;
|
||||
else if ((*name >= 'a') && (*name <= 'z'))
|
||||
lowercase = true;
|
||||
|
||||
|
||||
count++;
|
||||
name++;
|
||||
}
|
||||
|
||||
if (lowercase && uppercase)
|
||||
return MSDOS_NAME_LONG;
|
||||
|
||||
|
||||
return MSDOS_NAME_SHORT;
|
||||
}
|
||||
|
||||
/* msdos_long_to_short --
|
||||
* Routine to creates a short name from a long. Start the end of the
|
||||
* Routine to creates a short name from a long. Start the end of the
|
||||
*
|
||||
* PARAMETERS:
|
||||
* name - name to check
|
||||
@@ -183,7 +183,7 @@ msdos_long_to_short(const char *lfn, int lfn_len, char* sfn, int sfn_len)
|
||||
sfn[0] = '.';
|
||||
return MSDOS_NAME_SHORT;
|
||||
}
|
||||
|
||||
|
||||
if ((lfn[0] == '.') && (lfn[1] == '.') && (lfn_len == 2))
|
||||
{
|
||||
sfn[0] = sfn[1] = '.';
|
||||
@@ -203,14 +203,14 @@ msdos_long_to_short(const char *lfn, int lfn_len, char* sfn, int sfn_len)
|
||||
/*
|
||||
* Is this a short name ?
|
||||
*/
|
||||
|
||||
|
||||
type = msdos_name_type (lfn, lfn_len);
|
||||
|
||||
if (type == MSDOS_NAME_INVALID)
|
||||
return MSDOS_NAME_INVALID;
|
||||
|
||||
|
||||
msdos_filename_unix2dos (lfn, lfn_len, sfn);
|
||||
|
||||
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ msdos_get_token(const char *path,
|
||||
}
|
||||
|
||||
*ret_token = path;
|
||||
|
||||
|
||||
/*
|
||||
* If it is just a separator then it is the current dir.
|
||||
*/
|
||||
@@ -350,7 +350,7 @@ msdos_find_name(
|
||||
return rc;
|
||||
|
||||
fat_fd->dir_pos = dir_pos;
|
||||
|
||||
|
||||
/*
|
||||
* I don't like this if, but: we should do it, or should write new file
|
||||
* size and first cluster num to the disk after each write operation
|
||||
@@ -824,7 +824,7 @@ msdos_set_first_char4file_name(
|
||||
dir_block_size = fs_info->fat.vol.rdir_size;
|
||||
else
|
||||
dir_block_size = fs_info->fat.vol.bpc;
|
||||
|
||||
|
||||
if (dir_pos->lname.cln == FAT_FILE_SHORT_NAME)
|
||||
start = dir_pos->sname;
|
||||
|
||||
@@ -1001,16 +1001,16 @@ int msdos_find_name_in_fat_file(
|
||||
assert(name_len > 0);
|
||||
|
||||
fat_dir_pos_init(dir_pos);
|
||||
|
||||
|
||||
lfn_start.cln = lfn_start.ofs = FAT_FILE_SHORT_NAME;
|
||||
|
||||
|
||||
/*
|
||||
* If the file name is long how many short directory
|
||||
* entries are needed ?
|
||||
*/
|
||||
if (name_type == MSDOS_NAME_LONG)
|
||||
lfn_entries = ((name_len - 1) + MSDOS_LFN_LEN_PER_ENTRY) / MSDOS_LFN_LEN_PER_ENTRY;
|
||||
|
||||
|
||||
if (FAT_FD_OF_ROOT_DIR(fat_fd) &&
|
||||
(fs_info->fat.vol.type & (FAT_FAT12 | FAT_FAT16)))
|
||||
bts2rd = fat_fd->fat_file_size;
|
||||
@@ -1035,7 +1035,7 @@ int msdos_find_name_in_fat_file(
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[2] dir_offset:%li\n", dir_offset);
|
||||
#endif
|
||||
|
||||
|
||||
if (ret < MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
|
||||
rtems_set_errno_and_return_minus_one(EIO);
|
||||
|
||||
@@ -1111,7 +1111,7 @@ int msdos_find_name_in_fat_file(
|
||||
* Remainder is not empty so is this entry empty ?
|
||||
*/
|
||||
empty_space_count++;
|
||||
|
||||
|
||||
if (empty_space_count == (lfn_entries + 1))
|
||||
empty_space_found = true;
|
||||
}
|
||||
@@ -1176,7 +1176,7 @@ int msdos_find_name_in_fat_file(
|
||||
if (lfn_entries != (*MSDOS_DIR_ENTRY_TYPE(entry) &
|
||||
MSDOS_LAST_LONG_ENTRY_MASK))
|
||||
continue;
|
||||
|
||||
|
||||
/*
|
||||
* Get the checksum of the short entry.
|
||||
*/
|
||||
@@ -1184,7 +1184,7 @@ int msdos_find_name_in_fat_file(
|
||||
lfn_start.ofs = dir_entry;
|
||||
lfn_entry = lfn_entries;
|
||||
lfn_checksum = *MSDOS_DIR_LFN_CHECKSUM(entry);
|
||||
|
||||
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[4.3] lfn_checksum:%i\n",
|
||||
*MSDOS_DIR_LFN_CHECKSUM(entry));
|
||||
@@ -1211,7 +1211,7 @@ int msdos_find_name_in_fat_file(
|
||||
lfn_entry--;
|
||||
o = lfn_entry * MSDOS_LFN_LEN_PER_ENTRY;
|
||||
p = entry + 1;
|
||||
|
||||
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[5] lfne:%i\n", lfn_entry);
|
||||
#endif
|
||||
@@ -1233,7 +1233,7 @@ int msdos_find_name_in_fat_file(
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (((o + i) >= name_len) || (*p != name[o + i]))
|
||||
{
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
@@ -1256,7 +1256,7 @@ int msdos_find_name_in_fat_file(
|
||||
|
||||
lfn_matched = ((lfn_entry == 0) &&
|
||||
(lfn_start.cln != FAT_FILE_SHORT_NAME));
|
||||
|
||||
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[8.1] lfn_matched:%i\n", lfn_matched);
|
||||
#endif
|
||||
@@ -1309,7 +1309,7 @@ int msdos_find_name_in_fat_file(
|
||||
return rc;
|
||||
|
||||
dir_pos->sname.ofs = dir_entry;
|
||||
|
||||
|
||||
if (lfn_start.cln != FAT_FILE_SHORT_NAME)
|
||||
{
|
||||
rc = fat_file_ioctl(mt_entry, fat_fd, F_CLU_NUM,
|
||||
@@ -1318,7 +1318,7 @@ int msdos_find_name_in_fat_file(
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
dir_pos->lname.cln = lfn_start.cln;
|
||||
dir_pos->lname.ofs = lfn_start.ofs;
|
||||
|
||||
@@ -1326,7 +1326,7 @@ int msdos_find_name_in_fat_file(
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
return RC_OK;
|
||||
}
|
||||
|
||||
|
||||
lfn_start.cln = FAT_FILE_SHORT_NAME;
|
||||
lfn_matched = false;
|
||||
}
|
||||
@@ -1363,7 +1363,7 @@ int msdos_find_name_in_fat_file(
|
||||
int i;
|
||||
int slot = (((empty_space_offset * bts2rd) + empty_space_entry) /
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE) + lfn_entries + 1;
|
||||
|
||||
|
||||
msdos_short_name_hex(MSDOS_DIR_NAME(name_dir_entry), slot);
|
||||
|
||||
for (i = 0; i < 11; i++, p++)
|
||||
@@ -1408,7 +1408,7 @@ int msdos_find_name_in_fat_file(
|
||||
while (lfn_entry < (lfn_entries + 1))
|
||||
{
|
||||
int length = 0;
|
||||
|
||||
|
||||
if (read_cluster)
|
||||
{
|
||||
uint32_t new_length;
|
||||
@@ -1429,7 +1429,7 @@ int msdos_find_name_in_fat_file(
|
||||
#endif
|
||||
ret = fat_file_extend (mt_entry, fat_fd, empty_space_offset * bts2rd,
|
||||
&new_length);
|
||||
|
||||
|
||||
if (ret != RC_OK)
|
||||
return ret;
|
||||
|
||||
@@ -1451,11 +1451,11 @@ int msdos_find_name_in_fat_file(
|
||||
rtems_set_errno_and_return_minus_one(EIO);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[10] eso:%li\n", empty_space_offset);
|
||||
#endif
|
||||
|
||||
|
||||
for (dir_entry = empty_space_entry;
|
||||
dir_entry < bts2rd;
|
||||
dir_entry += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
|
||||
@@ -1467,7 +1467,7 @@ int msdos_find_name_in_fat_file(
|
||||
|
||||
length += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE;
|
||||
lfn_entry++;
|
||||
|
||||
|
||||
#if MSDOS_FIND_PRINT
|
||||
printf ("MSFS:[10] de:%li(%li) length:%i lfn_entry:%i\n",
|
||||
dir_entry, (dir_entry / MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE),
|
||||
@@ -1495,7 +1495,7 @@ int msdos_find_name_in_fat_file(
|
||||
if (rc != RC_OK)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
dir_pos->lname.cln = lfn_start.cln;
|
||||
dir_pos->lname.ofs = lfn_start.ofs;
|
||||
|
||||
@@ -1516,23 +1516,23 @@ int msdos_find_name_in_fat_file(
|
||||
lfn_start.cln = empty_space_offset;
|
||||
lfn_start.ofs = dir_entry;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Clear the entry before loading the data.
|
||||
*/
|
||||
memset (entry, 0, MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
|
||||
*MSDOS_DIR_LFN_CHECKSUM(entry) = lfn_checksum;
|
||||
|
||||
|
||||
p = entry + 1;
|
||||
n = name + (lfn_entries - lfn_entry) * MSDOS_LFN_LEN_PER_ENTRY;
|
||||
|
||||
|
||||
for (i = 0; i < MSDOS_LFN_LEN_PER_ENTRY; i++)
|
||||
{
|
||||
*p = *n;
|
||||
if (*n != 0)
|
||||
n++;
|
||||
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 4:
|
||||
@@ -1563,7 +1563,7 @@ int msdos_find_name_in_fat_file(
|
||||
empty_space_entry = 0;
|
||||
read_cluster = true;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1616,7 +1616,7 @@ int msdos_find_node_by_cluster_num_in_fat_file(
|
||||
for (i = 0; i < bts2rd; i += MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE)
|
||||
{
|
||||
char* entry = (char*) fs_info->cl_buf + i;
|
||||
|
||||
|
||||
/* if this and all rest entries are empty - return not-found */
|
||||
if ((*MSDOS_DIR_ENTRY_TYPE(entry)) ==
|
||||
MSDOS_THIS_DIR_ENTRY_AND_REST_EMPTY)
|
||||
@@ -1639,7 +1639,7 @@ int msdos_find_node_by_cluster_num_in_fat_file(
|
||||
dir_pos->sname.ofs = i;
|
||||
dir_pos->lname.cln = FAT_FILE_SHORT_NAME;
|
||||
dir_pos->lname.ofs = FAT_FILE_SHORT_NAME;
|
||||
|
||||
|
||||
memcpy(dir_entry, entry,
|
||||
MSDOS_DIRECTORY_ENTRY_STRUCT_SIZE);
|
||||
return RC_OK;
|
||||
|
||||
@@ -56,7 +56,7 @@ int msdos_mknod(
|
||||
rtems_status_code sc = RTEMS_SUCCESSFUL;
|
||||
msdos_fs_info_t *fs_info = pathloc->mt_entry->fs_info;
|
||||
msdos_token_types_t type = 0;
|
||||
|
||||
|
||||
/*
|
||||
* Figure out what type of msdos node this is.
|
||||
*/
|
||||
|
||||
@@ -110,7 +110,7 @@ int IMFS_evaluate_permission(
|
||||
else {
|
||||
/* must be other - do nothing */;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* If all of the flags are set we have permission
|
||||
* to do this.
|
||||
@@ -311,7 +311,7 @@ int IMFS_evaluate_for_make(
|
||||
/*
|
||||
* Evaluate all tokens until we are done or an error occurs.
|
||||
*/
|
||||
|
||||
|
||||
while( !done ) {
|
||||
|
||||
type = IMFS_get_token( &path[i], pathlen, token, &len );
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
|
||||
/* Till Straumann, <strauman@slac.stanford.edu>, 10/2002 */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software (NFS-2 client implementation for RTEMS) was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* The NFS-2 client implementation for RTEMS was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
@@ -25,18 +25,18 @@
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
@@ -45,9 +45,9 @@
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef __vxworks
|
||||
#include <vxWorks.h>
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
|
||||
/* Author: Till Straumann <strauman@slac.stanford.edu> 2002-2003 */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software (NFS-2 client implementation for RTEMS) was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* The NFS-2 client implementation for RTEMS was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
@@ -27,18 +27,18 @@
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
@@ -47,9 +47,9 @@
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
|
||||
@@ -4,19 +4,19 @@
|
||||
|
||||
/* Author: Till Straumann <strauman@slac.stanford.edu> 2002 */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software (NFS-2 client implementation for RTEMS) was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* The NFS-2 client implementation for RTEMS was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
@@ -25,18 +25,18 @@
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
@@ -45,9 +45,9 @@
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
@@ -105,7 +105,7 @@
|
||||
* variable 'nfsStBlksize'.
|
||||
* Thanks to Steven Johnson <sjohnson@sakuraindustries.com> for helping
|
||||
* working on this issue.
|
||||
*/
|
||||
*/
|
||||
#define DEFAULT_NFS_ST_BLKSIZE NFS_MAXDATA
|
||||
|
||||
/* dont change this without changing the maximal write size */
|
||||
@@ -139,7 +139,7 @@ static struct timeval _nfscalltimeout = { 10, 0 }; /* {secs, us } */
|
||||
* This has an impact on performance, as e.g. getcwd() stats() all
|
||||
* directory entries when it believes it has crossed a mount point
|
||||
* (a.st_dev != b.st_dev).
|
||||
*
|
||||
*
|
||||
* OTOH, it also might cause node comparison failure! E.g. 'getcwd()'
|
||||
* assumes that two nodes residing in the same directory must be located
|
||||
* on the same device and hence compares 'st_ino' only.
|
||||
@@ -194,7 +194,7 @@ static struct timeval _nfscalltimeout = { 10, 0 }; /* {secs, us } */
|
||||
rtems_semaphore_obtain((s), \
|
||||
RTEMS_WAIT, \
|
||||
RTEMS_NO_TIMEOUT); \
|
||||
} while (0)
|
||||
} while (0)
|
||||
|
||||
#define UNLOCK(s) do { rtems_semaphore_release((s)); \
|
||||
} while (0)
|
||||
@@ -219,7 +219,7 @@ xdr_strbuf(XDR *xdrs, strbuf *obj)
|
||||
}
|
||||
|
||||
/* Read 'readlink' results into a 'strbuf'.
|
||||
* This is convenient as it avoids
|
||||
* This is convenient as it avoids
|
||||
* one extra step of copying / lenght
|
||||
* checking.
|
||||
*/
|
||||
@@ -427,7 +427,7 @@ typedef struct serporid {
|
||||
} serporid_u;
|
||||
} serporid;
|
||||
|
||||
/* an XDR routine to encode/decode the inverted diropres
|
||||
/* an XDR routine to encode/decode the inverted diropres
|
||||
* into an nfsnodestat;
|
||||
*
|
||||
* NOTE: this routine only acts on
|
||||
@@ -435,7 +435,7 @@ typedef struct serporid {
|
||||
* - 'serporid.file'
|
||||
* - 'serporid.attributes'
|
||||
* and leaves the 'arg_u' alone.
|
||||
*
|
||||
*
|
||||
* The idea is that a 'diropres' is read into 'serporid'
|
||||
* which can then be used as an argument to subsequent
|
||||
* NFS-RPCs (after filling in the node's arg_u).
|
||||
@@ -448,7 +448,7 @@ xdr_serporidok(XDR *xdrs, serporidok *objp)
|
||||
if (!xdr_fattr (xdrs, &objp->attributes))
|
||||
return FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
static bool_t
|
||||
xdr_serporid(XDR *xdrs, serporid *objp)
|
||||
@@ -511,10 +511,10 @@ typedef struct NfsRec_ {
|
||||
*/
|
||||
u_short id;
|
||||
/* Our RTEMS filesystem mt_entry
|
||||
*/
|
||||
*/
|
||||
rtems_filesystem_mount_table_entry_t *mt_entry;
|
||||
/* Next NfsRec on a linked list who
|
||||
* is anchored at nfsGlob
|
||||
* is anchored at nfsGlob
|
||||
*/
|
||||
struct NfsRec_ *next;
|
||||
/* Who we pretend we are
|
||||
@@ -560,7 +560,7 @@ typedef struct NfsNodeRec_ {
|
||||
*****************************************/
|
||||
|
||||
static int nfs_readlink(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
char *buf, /* OUT */
|
||||
size_t len
|
||||
);
|
||||
@@ -608,7 +608,7 @@ rtems_filesystem_resolve_location(char *buf, int len, rtems_filesystem_location_
|
||||
|
||||
|
||||
/* * * * * * * * * * * * * * * * * *
|
||||
Trivial Operations on a NfsNode
|
||||
Trivial Operations on a NfsNode
|
||||
* * * * * * * * * * * * * * * * * */
|
||||
|
||||
/* determine if a location 'l' is an NFS root node */
|
||||
@@ -723,7 +723,7 @@ static struct nfsstats {
|
||||
* Global variable to tune the 'st_blksize' (stat(2)) value this nfs
|
||||
* client should report.
|
||||
* size on the server.
|
||||
*/
|
||||
*/
|
||||
#ifndef DEFAULT_NFS_ST_BLKSIZE
|
||||
#define DEFAULT_NFS_ST_BLKSIZE NFS_MAXDATA
|
||||
#endif
|
||||
@@ -1157,7 +1157,7 @@ int rval = -1;
|
||||
/* Check the 'age' of a node's stats
|
||||
* and read the attributes from the server
|
||||
* if necessary.
|
||||
*
|
||||
*
|
||||
* ARGS: node node to update
|
||||
* force enforce updating ignoring
|
||||
* the timestamp/age
|
||||
@@ -1188,7 +1188,7 @@ updateAttr(NfsNode node, int force)
|
||||
|
||||
node->age = nowSeconds();
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1352,7 +1352,7 @@ struct rtems_filesystem_location_info_tt
|
||||
* before passing control to the new FS' evalpath_h()
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
STATIC int nfs_do_evalpath(
|
||||
const char *pathname, /* IN */
|
||||
int pathnamelen, /* IN */
|
||||
@@ -1386,7 +1386,7 @@ unsigned long niu,siu;
|
||||
/* from here on, the NFS is protected from being unmounted
|
||||
* since the node refcount is > 1
|
||||
*/
|
||||
|
||||
|
||||
/* clone the node */
|
||||
if ( !node ) {
|
||||
/* nodeClone sets errno */
|
||||
@@ -1791,7 +1791,7 @@ sattr arg;
|
||||
arg.gid = group;
|
||||
|
||||
return nfs_sattr(pathloc->node_access, &arg, SATTR_UID | SATTR_GID);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* Cleanup the FS private info attached to pathloc->node_access */
|
||||
@@ -1802,7 +1802,7 @@ static int nfs_freenode(
|
||||
Nfs nfs = ((NfsNode)pathloc->node_access)->nfs;
|
||||
|
||||
#if DEBUG & DEBUG_COUNT_NODES
|
||||
/* print counts at entry where they are > 0 so 'nfs' is safe from being destroyed
|
||||
/* print counts at entry where they are > 0 so 'nfs' is safe from being destroyed
|
||||
* and there's no race condition
|
||||
*/
|
||||
fprintf(stderr,
|
||||
@@ -2058,7 +2058,7 @@ LOCK(nfsGlob.llock);
|
||||
|
||||
status = buildIpAddr(&uid, &gid, 0, &saddr, &path);
|
||||
assert( !status );
|
||||
|
||||
|
||||
stat = mntcall( &saddr,
|
||||
MOUNTPROC_UMNT,
|
||||
(xdrproc_t)xdr_dirpath, &path,
|
||||
@@ -2076,7 +2076,7 @@ LOCK(nfsGlob.llock);
|
||||
|
||||
nfsNodeDestroy(mt_entry->mt_fs_root.node_access);
|
||||
mt_entry->mt_fs_root.node_access = 0;
|
||||
|
||||
|
||||
nfsDestroy(mt_entry->fs_info);
|
||||
mt_entry->fs_info = 0;
|
||||
|
||||
@@ -2229,7 +2229,7 @@ NfsNode node = loc->node_access;
|
||||
}
|
||||
|
||||
static int nfs_do_readlink(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
strbuf *psbuf /* IN/OUT */
|
||||
)
|
||||
{
|
||||
@@ -2264,7 +2264,7 @@ int rval;
|
||||
}
|
||||
|
||||
static int nfs_readlink(
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
rtems_filesystem_location_info_t *loc, /* IN */
|
||||
char *buf, /* OUT */
|
||||
size_t len
|
||||
)
|
||||
@@ -2397,7 +2397,7 @@ int rval = RVAL_ERR_AND_DO_FREENODE;
|
||||
}
|
||||
} else {
|
||||
/* link points to an absolute path '/xxx' */
|
||||
|
||||
|
||||
/* release this node; filesystem_evaluate_path() will
|
||||
* lookup a new one.
|
||||
*/
|
||||
@@ -2864,7 +2864,7 @@ fattr *fa = &SERP_ATTR(node);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* done by caller
|
||||
/* done by caller
|
||||
memset(buf, 0, sizeof(*buf));
|
||||
*/
|
||||
|
||||
@@ -3007,7 +3007,7 @@ sattr arg;
|
||||
|
||||
arg.mode = mode;
|
||||
return nfs_sattr(loc->node_access, &arg, SATTR_MODE);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* just set the size attribute to 'length'
|
||||
@@ -3169,7 +3169,7 @@ rtems_device_driver nfs_initialize(
|
||||
* only reason for using this API was getting
|
||||
* a major number, after all).
|
||||
*
|
||||
* Something must be present, however, to
|
||||
* Something must be present, however, to
|
||||
* reserve a slot in the driver table.
|
||||
*/
|
||||
return RTEMS_SUCCESSFUL;
|
||||
@@ -3198,7 +3198,7 @@ Nfs nfs;
|
||||
fprintf(stderr,"nfsMountsShow(): no memory\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
fprintf(f,"Currently Mounted NFS:\n");
|
||||
|
||||
LOCK(nfsGlob.llock);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
void
|
||||
_cexpModuleInitialize(void *mod)
|
||||
{
|
||||
{
|
||||
#if defined(DEBUG)
|
||||
/* print load address (in case we crash while initializing) */
|
||||
unsigned lr;
|
||||
@@ -20,7 +20,7 @@ unsigned lr;
|
||||
|
||||
int
|
||||
_cexpModuleFinalize(void *mod)
|
||||
{
|
||||
{
|
||||
return nfsCleanup();
|
||||
}
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* reply to come back. Performance enhancement can be expected
|
||||
* by requesting multiple blocks in parallel rather than
|
||||
* sequentially.
|
||||
*
|
||||
*
|
||||
* rtems_interval
|
||||
* nfsTestRead(char *file_name, int chunk_size, int num_readers);
|
||||
*
|
||||
@@ -50,19 +50,19 @@
|
||||
* performed at 'big block' boundaries (num_readers * chunk_size).
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software (NFS-2 client implementation for RTEMS) was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* The NFS-2 client implementation for RTEMS was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
@@ -71,18 +71,18 @@
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
@@ -91,9 +91,9 @@
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
*/
|
||||
#include <rtems.h>
|
||||
#include <rtems/error.h>
|
||||
|
||||
@@ -181,7 +181,7 @@ rtems_id tid;
|
||||
rtems_build_name('n','t','t','0'+inst),
|
||||
nfsTestReaderPri,
|
||||
1400,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_MODES,
|
||||
RTEMS_DEFAULT_ATTRIBUTES,
|
||||
&tid);
|
||||
if ( RTEMS_SUCCESSFUL != sc ) {
|
||||
@@ -345,7 +345,7 @@ char *buf=0;
|
||||
if ( i < 0 ) {
|
||||
perror("reading");
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
now = rtems_clock_get_ticks_since_boot();
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
/* This code funnels arbitrary task's UDP/RPC requests
|
||||
* through one socket to arbitrary servers.
|
||||
* The replies are gathered and dispatched to the
|
||||
* The replies are gathered and dispatched to the
|
||||
* requestors.
|
||||
* One task handles all the sending and receiving
|
||||
* work including retries.
|
||||
@@ -15,20 +15,20 @@
|
||||
* of the results (except for the RPC header which
|
||||
* is handled by the daemon).
|
||||
*/
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software (NFS-2 client implementation for RTEMS) was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* The NFS-2 client implementation for RTEMS was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
@@ -37,18 +37,18 @@
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
@@ -57,9 +57,9 @@
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
*/
|
||||
|
||||
#include <rtems.h>
|
||||
#include <rtems/error.h>
|
||||
@@ -100,7 +100,7 @@
|
||||
* into different areas of the data.
|
||||
*
|
||||
* If undefined, the regular 'sendto()'
|
||||
* interface is used.
|
||||
* interface is used.
|
||||
*/
|
||||
|
||||
#undef REJECT_SERVERIP_MISMATCH
|
||||
@@ -136,7 +136,7 @@ static struct timeval _rpc_default_timeout = { 10 /* secs */, 0 /* usecs */ };
|
||||
* thread doing RPC IO (e.g. NFS)
|
||||
*/
|
||||
#define RTEMS_RPC_EVENT RTEMS_EVENT_30 /* THE event used by RPCIO. Every task doing
|
||||
* RPC IO will receive this - hence it is
|
||||
* RPC IO will receive this - hence it is
|
||||
* RESERVED
|
||||
*/
|
||||
#define RPCIOD_RX_EVENT RTEMS_EVENT_1 /* Events the RPCIOD is using/waiting for */
|
||||
@@ -347,7 +347,7 @@ typedef struct RpcUdpXactPoolRec_ {
|
||||
* objects are registered.
|
||||
* A number of bits in a transaction's XID maps 1:1 to
|
||||
* an index in this table. Hence, the XACT matching
|
||||
* an RPC/UDP reply packet can quickly be found
|
||||
* an RPC/UDP reply packet can quickly be found
|
||||
* The size of this table imposes a hard limit on the
|
||||
* number of all created transactions in the system.
|
||||
*/
|
||||
@@ -542,7 +542,7 @@ struct pmap pmaparg;
|
||||
/* dont use non-reentrant pmap_getport ! */
|
||||
|
||||
pmap_err = rpcUdpCallRp(
|
||||
paddr,
|
||||
paddr,
|
||||
PMAPPROG,
|
||||
PMAPVERS,
|
||||
PMAPPROC_GETPORT,
|
||||
@@ -564,7 +564,7 @@ struct pmap pmaparg;
|
||||
|
||||
if (0==paddr->sin_port) {
|
||||
return RPC_PROGNOTREGISTERED;
|
||||
}
|
||||
}
|
||||
|
||||
rval = (RpcUdpServer)MY_MALLOC(sizeof(*rval));
|
||||
memset(rval, 0, sizeof(*rval));
|
||||
@@ -576,7 +576,7 @@ struct pmap pmaparg;
|
||||
/* start with a long retransmission interval - it
|
||||
* will be adapted dynamically
|
||||
*/
|
||||
rval->retry_period = RPCIOD_RETX_CAP_S * ticksPerSec;
|
||||
rval->retry_period = RPCIOD_RETX_CAP_S * ticksPerSec;
|
||||
|
||||
rval->auth = auth;
|
||||
|
||||
@@ -670,7 +670,7 @@ register int i,j;
|
||||
rval = (RpcUdpXact)MY_CALLOC(1,sizeof(*rval) - sizeof(rval->obuf) + size);
|
||||
|
||||
if (rval) {
|
||||
|
||||
|
||||
header.rm_xid = 0;
|
||||
header.rm_direction = CALL;
|
||||
header.rm_call.cb_rpcvers = RPC_MSG_VERSION;
|
||||
@@ -688,7 +688,7 @@ register int i,j;
|
||||
rval->obuf.xid = (xidHashSeed++ ^ ((unsigned long)rval>>10)) & XACT_HASH_MSK;
|
||||
i=j=(rval->obuf.xid & XACT_HASH_MSK);
|
||||
if (msgQ) {
|
||||
/* if there's no message queue, refuse to
|
||||
/* if there's no message queue, refuse to
|
||||
* give them transactions; we might be in the process to
|
||||
* go away...
|
||||
*/
|
||||
@@ -896,7 +896,7 @@ rtems_event_set gotEvents;
|
||||
#ifndef MBUF_RX
|
||||
xact->ibufsize = 0;
|
||||
#endif
|
||||
|
||||
|
||||
if (refresh && locked_refresh(xact->server)) {
|
||||
rtems_task_ident(RTEMS_SELF, RTEMS_WHO_AM_I, &xact->requestor);
|
||||
if ( rtems_message_queue_send(msgQ, &xact, sizeof(xact)) ) {
|
||||
@@ -1036,7 +1036,7 @@ enum clnt_stat err;
|
||||
/* TODO: could maintain a server cache */
|
||||
|
||||
x->server = s;
|
||||
|
||||
|
||||
*pclnt = x;
|
||||
|
||||
return RPC_SUCCESS;
|
||||
@@ -1132,7 +1132,7 @@ nodeAppend(ListNode l, ListNode n)
|
||||
n->next->prev = n;
|
||||
l->next = n;
|
||||
n->prev = l;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* this code does the work */
|
||||
@@ -1161,7 +1161,7 @@ rtems_status_code status;
|
||||
if ( RTEMS_SUCCESSFUL !=
|
||||
(stat = rtems_event_receive(
|
||||
RPCIOD_RX_EVENT | RPCIOD_TX_EVENT | RPCIOD_KILL_EVENT,
|
||||
RTEMS_WAIT | RTEMS_EVENT_ANY,
|
||||
RTEMS_WAIT | RTEMS_EVENT_ANY,
|
||||
next_retrans,
|
||||
&events)) ) {
|
||||
ASSERT( RTEMS_TIMEOUT == stat );
|
||||
@@ -1316,13 +1316,13 @@ rtems_status_code status;
|
||||
__FILE__,
|
||||
__LINE__,
|
||||
xact->requestor);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
int len;
|
||||
|
||||
len = (int)XDR_GETPOS(&xact->xdrs);
|
||||
|
||||
|
||||
#ifdef MBUF_TX
|
||||
xact->refcnt = 1; /* sendto itself */
|
||||
#endif
|
||||
@@ -1438,7 +1438,7 @@ rtems_status_code status;
|
||||
* respect to 'then' - hence:
|
||||
*
|
||||
* abs_age == old_age + old_then == new_age + new_then
|
||||
*
|
||||
*
|
||||
* ==> new_age = old_age + old_then - new_then == old_age - 'now'
|
||||
*/
|
||||
((RpcUdpXact)n)->age -= now;
|
||||
@@ -1641,7 +1641,7 @@ int len = (int)XDR_GETPOS(&xact->xdrs);
|
||||
* The semantics of the 'pibuf' pointer are
|
||||
* as follows:
|
||||
*
|
||||
* MBUF_RX:
|
||||
* MBUF_RX:
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -6,19 +6,19 @@
|
||||
|
||||
/* Author: Till Straumann, <strauman@slac.stanford.edu>, 2002 */
|
||||
|
||||
/*
|
||||
/*
|
||||
* Authorship
|
||||
* ----------
|
||||
* This software (NFS-2 client implementation for RTEMS) was created by
|
||||
* Till Straumann <strauman@slac.stanford.edu>, 2002-2007,
|
||||
* Stanford Linear Accelerator Center, Stanford University.
|
||||
*
|
||||
*
|
||||
* Acknowledgement of sponsorship
|
||||
* ------------------------------
|
||||
* The NFS-2 client implementation for RTEMS was produced by
|
||||
* the Stanford Linear Accelerator Center, Stanford University,
|
||||
* under Contract DE-AC03-76SFO0515 with the Department of Energy.
|
||||
*
|
||||
*
|
||||
* Government disclaimer of liability
|
||||
* ----------------------------------
|
||||
* Neither the United States nor the United States Department of Energy,
|
||||
@@ -27,18 +27,18 @@
|
||||
* completeness, or usefulness of any data, apparatus, product, or process
|
||||
* disclosed, or represents that its use would not infringe privately owned
|
||||
* rights.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of liability
|
||||
* --------------------------------
|
||||
* Stanford University makes no representations or warranties, express or
|
||||
* implied, nor assumes any liability for the use of this software.
|
||||
*
|
||||
*
|
||||
* Stanford disclaimer of copyright
|
||||
* --------------------------------
|
||||
* Stanford University, owner of the copyright, hereby disclaims its
|
||||
* copyright and all other rights in this software. Hence, anyone may
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* freely use it for any purpose without restriction.
|
||||
*
|
||||
* Maintenance of notices
|
||||
* ----------------------
|
||||
* In the interest of clarity regarding the origin and status of this
|
||||
@@ -47,9 +47,9 @@
|
||||
* or distributed by the recipient and are to be affixed to any copy of
|
||||
* software made or distributed by the recipient that contains a copy or
|
||||
* derivative of this software.
|
||||
*
|
||||
*
|
||||
* ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
|
||||
*/
|
||||
*/
|
||||
|
||||
#ifdef __rtems
|
||||
#include <rtems.h>
|
||||
@@ -142,7 +142,7 @@ rpcUdpSend(
|
||||
caddr_t pres,
|
||||
xdrproc_t xargs,
|
||||
caddr_t pargs,
|
||||
... /* 0 terminated xdrproc/pobj additional argument list */
|
||||
... /* 0 terminated xdrproc/pobj additional argument list */
|
||||
);
|
||||
|
||||
/* wait for a transaction to complete */
|
||||
@@ -175,7 +175,7 @@ rpcUdpCallRp(
|
||||
* The pool is implemented by RTEMS message queues who manage
|
||||
* the required task synchronization.
|
||||
* A requestor has different options if the pool is empty:
|
||||
* - it can wait (block) for a XACT to become available
|
||||
* - it can wait (block) for a XACT to become available
|
||||
* - it can get an error status
|
||||
* - or it can malloc an extra XACT from the heap which
|
||||
* will eventually be released.
|
||||
|
||||
@@ -146,7 +146,7 @@ dummyproc(caddr_t ext_buf, u_int ext_size)
|
||||
* and 'free' procs. (The latter may call the
|
||||
* user back once the networking stack has
|
||||
* released the buffer).
|
||||
*
|
||||
*
|
||||
* The callbacks are provided with the 'closure'
|
||||
* pointer and the 'buflen' argument.
|
||||
*/
|
||||
@@ -200,7 +200,7 @@ sendto_nocpy (
|
||||
if (/*auio.uio_resid != len &&*/ (error == EINTR || error == EWOULDBLOCK))
|
||||
error = 0;
|
||||
}
|
||||
if (error)
|
||||
if (error)
|
||||
errno = error;
|
||||
else
|
||||
ret = buflen;
|
||||
@@ -244,7 +244,7 @@ recv_mbuf_from(int s, struct mbuf **ppm, long len, struct sockaddr *fromaddr, in
|
||||
auio.uio_offset = 0;
|
||||
*/
|
||||
auio.uio_resid = len;
|
||||
error = soreceive (so, &from, &auio, (struct mbuf **) ppm,
|
||||
error = soreceive (so, &from, &auio, (struct mbuf **) ppm,
|
||||
(struct mbuf **)NULL,
|
||||
NULL);
|
||||
if (error) {
|
||||
|
||||
@@ -41,7 +41,7 @@ static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_mem.c,v 1.8 1999/08/28 00:0
|
||||
|
||||
/*
|
||||
* xdr_mbuf, XDR implementation using mbuf buffers
|
||||
*
|
||||
*
|
||||
* derived from:
|
||||
*
|
||||
* xdr_mem.h, XDR implementation using memory buffers.
|
||||
@@ -49,7 +49,7 @@ static char *rcsid = "$FreeBSD: src/lib/libc/xdr/xdr_mem.c,v 1.8 1999/08/28 00:0
|
||||
* Copyright (C) 1984, Sun Microsystems, Inc.
|
||||
*
|
||||
* The MBUF stream is useful for BSDNET kernel (or RTEMS for that matter)
|
||||
* use.
|
||||
* use.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
@@ -168,7 +168,7 @@ MBPrivate mbp = (MBPrivate)xdrs->x_base;
|
||||
fprintf(stderr,"xdrmbuf: end of chain\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
return rval;
|
||||
}
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ extern int pipe_lseek(
|
||||
extern void rtems_pipe_initialize (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user