GOAHEAD - GoAhead API Native API
Components
Webs | GoAhead request structure. |
WebsAuth | GoAhead Authentication. |
WebsBuf | A WebsBuf (ring queue) allows maximum utilization of memory for data storage and is ideal for input/output buffering. |
WebsHash | Hash table entry structure. |
WebsRoute | Request route structure. |
WebsRuntime | GoAhead Web Server Runtime. |
WebsSession | Session state storage. |
WebsSocket | Socket control structure. |
WebsUpload | File upload structure. |
Functions
void | assert(bool cond) |
Assure that an assert condition is true. | |
void | bufAddNull(WebsBuf *bp) |
Add a trailing null to the buffer. | |
void | bufAdjustEnd(WebsBuf *bp, ssize size) |
Adjust the endp pointer by the specified size. | |
void | bufAdjustStart(WebsBuf *bp, ssize count) |
Adjust the start (servp) reference. | |
void | bufCompact(WebsBuf *bp) |
Compact the data in the buffer and move to the start of the buffer. | |
int | bufCreate(WebsBuf *bp, int increment, int maxsize) |
Create a buffer. | |
void | bufFlush(WebsBuf *bp) |
Flush all data in the buffer and reset the pointers. | |
void | bufFree(WebsBuf *bp) |
Free allocated storage for the buffer. | |
ssize | bufGetBlk(WebsBuf *bp, char *blk, ssize len) |
Copy a block of from the buffer and adjust the servp. | |
ssize | bufGetBlkMax(WebsBuf *bp) |
Return the maximum number of bytes the buffer can provide via a single block copy. | |
int | bufGetc(WebsBuf *bp) |
Get a character from the buffer and increment the servp. | |
bool | bufGrow(WebsBuf *bp, ssize room) |
Grow the buffer by at least the required amount of room. | |
int | bufInsertc(WebsBuf *bp, char c) |
Insert a character to the buffer before the servp position and decrement the servp. | |
ssize | bufLen(WebsBuf *bp) |
Get the length of available data in the buffer. | |
ssize | bufPutBlk(WebsBuf *bp, char *blk, ssize len) |
Put a block to the buffer. | |
ssize | bufPutStr(WebsBuf *bp, char *str) |
Append a string to the buffer at the endp position and increment the endp. | |
int | bufPutc(WebsBuf *bp, char c) |
Append a character to the buffer at the endp position and increment the endp. | |
void | bufReset(WebsBuf *bp) |
Reset the buffer pointers to the start of the buffer if empty. | |
ssize | bufRoom(WebsBuf *bp) |
Determine the room available in the buffer. | |
char* | bufStart(WebsBuf *bp) |
Get a reference to the start of buffer data. | |
void | error(char *fmt, ...) |
Emit an error message. | |
char* | fmt(char *buf, ssize maxSize, char *format, ...) |
Format a string into a static buffer. | |
WebsHash | hashCreate(int size) |
Create a hash table. | |
int | hashDelete(WebsHash id, char *name) |
Delete a key by name. | |
WebsKey* | hashEnter(WebsHash id, char *name, WebsValue value, int arg) |
Enter a new key and value into the hash table. | |
WebsKey* | hashFirst(WebsHash id) |
Start walking the hash keys by returning the first key entry in the hash. | |
void | hashFree(WebsHash id) |
Free a hash table. | |
WebsKey* | hashLookup(WebsHash id, char *name) |
Lookup a name in the hash table. | |
WebsKey* | hashNext(WebsHash id, WebsKey *last) |
Continue walking the hash keys by returning the next key entry in the hash. | |
uint | hextoi(char *str) |
Convert a hex string to an integer. | |
char* | itosbuf(char *buf, ssize size, int64 value, int radix) |
Convert an integer to a string buffer. | |
void | logClose() |
Close the log logging module. | |
int | logOpen() |
Open the log logging module. | |
WebsLogHandler | logSetHandler(WebsLogHandler handler) |
Set a log callback. | |
void | logSetPath(char *path) |
Set the filename to save logging output. | |
void | logmsgProc(int level, char *fmt, ...) |
Emit a message to the log. | |
int | scaselesscmp(char *s1, char *s2) |
Compare strings ignoring case. | |
bool | scaselessmatch(char *s1, char *s2) |
Compare strings ignoring case. | |
char* | sclone(char *str) |
Clone a string. | |
int | scmp(char *s1, char *s2) |
Compare strings. | |
ssize | scopy(char *dest, ssize destMax, char *src) |
Copy a string. | |
char* | sfmt(char *format, ...) |
Format a string. | |
char* | sfmtv(char *format, va_list args) |
Format a string with varargs. | |
ssize | slen(char *str) |
Return the length of a string. | |
char* | slower(char *str) |
Convert a string to lower case. | |
bool | smatch(char *s1, char *s2) |
Compare strings. | |
int | sncaselesscmp(char *s1, char *s2, ssize len) |
Compare strings ignoring case. | |
int | sncmp(char *s1, char *s2, ssize len) |
Compare strings. | |
ssize | sncopy(char *dest, ssize destMax, char *src, ssize count) |
Copy characters from a string. | |
int | socketAddress(struct sockaddr *addr, int addrlen, char *ipbuf, int ipLen, int *port) |
Extract the numerical IP address and port for the given socket info. | |
bool | socketAddressIsV6(char *ip) |
Determine if an IP address is an IPv6 address. | |
int | socketAlloc(char *host, int port, SocketAccept accept, int flags) |
Allocate a socket object. | |
void | socketClose() |
Close the socket module. | |
void | socketCloseConnection(int sid) |
Close a socket connection. | |
int | socketConnect(char *host, int port, int flags) |
Connect to a server and create a new socket. | |
void | socketCreateHandler(int sid, int mask, SocketHandler handler, void *arg) |
Create a socket handler that will be invoked when I/O events occur. | |
void | socketDeleteHandler(int sid) |
Delete a socket handler created via socketCreateHandler. | |
bool | socketEof(int sid) |
Determine if the socket is at end-of-file for input. | |
void | socketFree(int sid) |
Free (and close) the socket. | |
int | socketGetBlock(int sid) |
Get the current blocking mode. | |
int | socketGetError() |
Get the error code for the last socket operation on this thread. | |
Socket | socketGetHandle(int sid) |
Get the underlying socket operating system socket/file handle. | |
int | socketGetPort(int sid) |
Get the IP port associated with this socket. | |
bool | socketHasDualNetworkStack() |
Indicate if the system has a dual IPv4 and IPv6 stack. | |
bool | socketHasIPv6() |
Indicate if the system has IPv6 support. | |
void | socketHiddenData(WebsSocket *sp, ssize len, int dir) |
Indicate that the application layer has buffered data for the socket. | |
int | socketInfo(char *ip, int port, int *family, int *protocol, struct sockaddr_storage *addr, Socklen *addrlen) |
Get a socket address structure for the specified IP:Port. | |
bool | socketIsV6(int sid) |
Determine if a socket is bound to an IPv6 address. | |
int | socketListen(char *host, int port, SocketAccept accept, int flags) |
Open a listening socket. | |
int | socketOpen() |
Open the socket module. | |
int | socketParseAddress(char *ipAddrPort, char **pip, int *pport, int *secure, int defaultPort) |
Parse an IP address into its constituent parts. | |
void | socketProcess() |
Process pending socket I/O events. | |
WebsSocket* | socketPtr(int sid) |
Return the socket object for the socket ID. | |
ssize | socketRead(int sid, void *buf, ssize len) |
Read data from a socket. | |
void | socketRegisterInterest(int sid, int mask) |
Register interest in socket I/OEvents. | |
void | socketReservice(int sid) |
Request that the socket be reserviced. | |
int | socketSelect(int sid, WebsTime timeout) |
Wait for I/O on a socket. | |
int | socketSetBlock(int sid, int on) |
Set the socket blocking mode. | |
int | socketSetNoDelay(int sid, bool on) |
Set the socket delay mode. | |
int | socketWaitForEvent(WebsSocket *sp, int mask) |
Wait for a socket I/O event. | |
ssize | socketWrite(int sid, void *buf, ssize len) |
Write data to the socket. | |
void | sslClose() |
Close the ssl module. | |
void | sslFree(Webs *wp) |
Free a ssl connection associated with a request. | |
int | sslOpen() |
Open the ssl module. | |
ssize | sslRead(Webs *wp, void *buf, ssize len) |
Read data from a secure socket. | |
int | sslUpgrade(Webs *wp) |
Upgrade a request connection to utilize SSL. | |
ssize | sslWrite(Webs *wp, void *buf, ssize len) |
WRite data to a secure socket. | |
char* | stok(char *str, char *delim, char **last) |
Tokenize a string. | |
char* | strim(char *str, char *set, int where) |
Trim a string. | |
char* | supper(char *str) |
Convert a string to upper case. | |
void | traceProc(int level, char *fmt, ...) |
Emit a debug trace message to the log. | |
void | valueFree(WebsValue *value) |
Free any allocated string in a value. | |
WebsValue | valueInteger(long value) |
Create an integer value. | |
WebsValue | valueString(char *value, int flags) |
Create an string value. | |
WebsValue | valueSymbol(void *value) |
Create an symbol value containing an object reference. | |
int | wallocHandle(void *map) |
Allocate a handle from a map. | |
int | wallocObject(void *map, int *max, int size) |
Allocate an object in a halloc map. | |
int | websAccept(int sid, char *ipaddr, int port, int listenSid) |
Accept a new connection. | |
void | websActionOpen() |
Open the action handler. | |
WebsRole* | websAddRole(char *role, WebsHash abilities) |
Add a role. | |
WebsRoute* | websAddRoute(char *uri, char *handler, int pos) |
Add a route to the routing tables. | |
WebsUser* | websAddUser(char *username, char *password, char *roles) |
Add a user. | |
int | websAlloc(int sid) |
Allocate a new Webs object. | |
WebsSession* | websAllocSession(Webs *wp, char *id, WebsTime lifespan) |
Test if a user possesses the required ability. | |
bool | websAuthenticate(Webs *wp) |
Authenticate a user. | |
bool | websCan(Webs *wp, WebsHash ability) |
Test if a user possesses the required ability. | |
void | websCancelTimeout(Webs *wp) |
Cancel the request timeout. | |
int | websCgiHandler(Webs *wp) |
CGI handler service callback. | |
int | websCgiOpen() |
Open the CGI handler. | |
WebsTime | websCgiPoll() |
Poll for output from CGI processes and output. | |
void | websClose() |
Close the core GoAhead web server module. | |
void | websCloseAuth() |
Close the authentication module. | |
void | websCloseFile(int fd) |
Close an open file. | |
void | websCloseRoute() |
Close the route module. | |
int | websCompareVar(Webs *wp, char *var, char *value) |
Compare a request variable. | |
void | websComputeAllUserAbilities() |
Compute the abilities for all users by resolving roles into abilities. | |
void | websConsumeInput(Webs *wp, ssize nbytes) |
Consume input from the request input buffer. | |
char* | websDecode64(char *str) |
Decode the string using base-64 encoding. | |
char* | websDecode64Block(char *str, ssize *len, int flags) |
Decode a block using base-46 encoding. | |
void | websDecodeUrl(char *decoded, char *input, ssize len) |
Decode a URL expanding NN encoding. | |
int | websDefineAction(char *name, void *fun) |
Define an action callback for use with the action handler. | |
int | websDefineHandler(char *name, WebsHandlerProc service, WebsHandlerClose close, int flags) |
Define a request handler. | |
int | websDefineJst(char *name, WebsJstProc fn) |
Define a Javscript native function. | |
void | websDone(Webs *wp) |
Complete a request. | |
char* | websEncode64(char *str) |
Encode a string using base-64 encoding. | |
char* | websEncode64Block(char *str, ssize len) |
Encode a block using base-64 encoding. | |
void | websError(Webs *wp, int code, char *fmt, ...) |
Complete a request with an error response. | |
char* | websErrorMsg(int code) |
Get a message for a HTTP status code. | |
char* | websEscapeHtml(char *str) |
Escape unsafe characters in a string. | |
void | websFileOpen() |
Open and initialize the file handler. | |
bool | websFlush(Webs *wp) |
Flush buffered transmit data and compact the transmit buffer to make room for more data. | |
void | websFree(Webs *wp) |
Free the webs request object. | |
void | websFreeUpload(Webs *wp) |
Free file upload data structures. | |
void | websFsClose() |
Close the file system module. | |
int | websFsOpen() |
Open the file system module. | |
int | websGetBackground() |
Get the background execution flag. | |
char* | websGetCgiCommName() |
Get a unique temporary filename for CGI communications. | |
char* | websGetCookie(Webs *wp) |
Get the request cookie if supplied. | |
char* | websGetDateString(WebsFileInfo *sbuf) |
Get a date as a string. | |
int | websGetDebug() |
Get the debug flag. | |
char* | websGetDir(Webs *wp) |
Get the base file directory for a request. | |
char* | websGetDocuments() |
Get the GoAhead base documents directory. | |
int | websGetEof(Webs *wp) |
Get the request EOF status. | |
char* | websGetExt(Webs *wp) |
Get the request URI extension. | |
char* | websGetFilename(Webs *wp) |
Get the request filename. | |
char* | websGetHost(Webs *wp) |
Get the request host. | |
char* | websGetIfaddr(Webs *wp) |
Get the request interface address. | |
char* | websGetIndex() |
Get the default index document name. | |
int | websGetLogLevel() |
Get the current trace log level. | |
char* | websGetMethod(Webs *wp) |
Get the request method. | |
char* | websGetPassword(Webs *wp) |
Get the request password. | |
WebsVerify | websGetPasswordStoreVerify() |
Set the password store verify callback. | |
char* | websGetPath(Webs *wp) |
Get the request path. | |
int | websGetPort(Webs *wp) |
Get the request TCP/IP port. | |
char* | websGetProtocol(Webs *wp) |
Get the request HTTP protocol. | |
char* | websGetQuery(Webs *wp) |
Get the request query component. | |
WebsHash | websGetRoles() |
Get the roles hash. | |
char* | websGetServer() |
Get the server host name. | |
char* | websGetServerAddress() |
Get the server IP address. | |
char* | websGetServerAddressUrl() |
Get the server IP address with port number. | |
char* | websGetServerUrl() |
Get the server host name with port number. | |
WebsSession* | websGetSession(Webs *wp, int create) |
Get the session state object for the current request. | |
char* | websGetSessionID(Webs *wp) |
Get the session ID. | |
char* | websGetSessionVar(Webs *wp, char *name, char *defaultValue) |
Get a session variable. | |
WebsHash | websGetUpload(struct Webs *wp) |
Get the hash of uploaded files for the request. | |
char* | websGetUrl(Webs *wp) |
Get the request URI. | |
char* | websGetUserAgent(Webs *wp) |
Get the client User-Agent HTTP header. | |
char* | websGetUsername(Webs *wp) |
Get the request username. | |
WebsHash | websGetUsers() |
Get the users hash. | |
char* | websGetVar(Webs *wp, char *name, char *defaultValue) |
Get a request variable. | |
int | websJstOpen() |
Open the Javascript module. | |
int | websJstWrite(int jid, Webs *wp, int argc, char **argv) |
Write data to the response. | |
int | websListen(char *endpoint) |
Listen on a TCP/IP address endpoint. | |
int | websLoad(char *path) |
Load routing tables from the specified filename. | |
bool | websLoginUser(Webs *wp, char *username, char *password) |
Login a user by verifying the login credentials. | |
WebsUpload* | websLookupUpload(struct Webs *wp, char *key) |
Open the file upload filter. | |
WebsUser* | websLookupUser(char *username) |
Lookup if a user exists. | |
char* | websMD5(char *str) |
Get an MD5 digest of a string. | |
char* | websMD5Block(char *buf, ssize length, char *prefix) |
Get an MD5 digest of a block and optionally prepend a prefix. | |
char* | websNormalizeUriPath(char *path) |
Normalize a URI path. | |
void | websNoteRequestActivity(Webs *wp) |
Take not of the request activity and mark the time. | |
int | websOpen(char *documents, char *routes) |
Open the web server. | |
int | websOpenAuth(int minimal) |
Open the authentication module. | |
int | websOpenFile(char *path, int flags, int mode) |
Open the web page document for the current request. | |
int | websOpenRoute() |
Open the routing module. | |
int | websOptionsOpen() |
Open the options handler. | |
void | websOsClose() |
Close the O/S dependant code. | |
int | websOsOpen() |
Open the O/S dependant code. | |
void | websPageClose(Webs *wp) |
Close the document page. | |
int | websPageIsDirectory(Webs *wp) |
Test if the document page for the request corresponds to a directory. | |
int | websPageOpen(Webs *wp, int mode, int perms) |
Open a web page document for a request. | |
ssize | websPageReadData(Webs *wp, char *buf, ssize size) |
Read data from the request page document. | |
void | websPageSeek(Webs *wp, Offset offset, int origin) |
Seek to a position in the request page document. | |
int | websPageStat(Webs *wp, WebsFileInfo *sbuf) |
Get file status for the current request document. | |
int | websProcessCgiData(Webs *wp) |
Process CGI request body data. | |
int | websProcessUploadData(Webs *wp) |
Process upload data for form, multipart mime file upload. | |
void | websPump(Webs *wp) |
Pump the state machine. | |
ssize | websReadFile(int fd, char *buf, ssize size) |
Read data from an open file. | |
char* | websReadWholeFile(char *path) |
Read all the data from a file. | |
void | websRedirect(Webs *wp, char *url) |
Redirect the client to a new URL. | |
int | websRedirectByStatus(Webs *wp, int status) |
Redirect the client to a new URI. | |
int | websRemoveRole(char *role) |
Remove a role from the system. | |
int | websRemoveRoute(char *uri) |
Remove a route from the routing tables. | |
void | websRemoveSessionVar(Webs *wp, char *name) |
Remove a session variable. | |
int | websRemoveUser(char *name) |
Remove a user from the system. | |
void | websResponse(Webs *wp, int status, char *msg) |
Create and send a request response. | |
void | websRestartEvent(int id, int delay) |
Restart an event. | |
int | websRewriteRequest(Webs *wp, char *url) |
Rewrite a request. | |
void | websRouteRequest(Webs *wp) |
Route a request. | |
WebsTime | websRunEvents() |
Run due events. | |
void | websRuntimeClose() |
Close the runtime code. | |
int | websRuntimeOpen() |
Open the runtime code. | |
Offset | websSeekFile(int fd, Offset offset, int origin) |
Seek to a position in the current request page document. | |
int | websServer(char *endpoint, char *documents) |
One line embedding API. | |
void | websServiceEvents(int *finished) |
Service I/O events until finished. | |
void | websSetBackground(int on) |
Set the background processing flag. | |
void | websSetBackgroundWriter(Webs *wp, WebsWriteProc proc) |
Define a background write I/O event callback. | |
void | websSetCookie(Webs *wp, char *name, char *value, char *path, char *domain, WebsTime lifespan, int flags) |
Define a cookie to include in the response. | |
void | websSetDebug(int on) |
Set the debug processing flag. | |
void | websSetDocuments(char *dir) |
Set the web documents directory. | |
void | websSetEnv(Webs *wp) |
Create the CGI environment variables for the current request. | |
void | websSetFormVars(Webs *wp) |
Create request variables for query and POST body data. | |
void | websSetHost(char *host) |
Define the host name for the server. | |
void | websSetIndex(char *filename) |
Create and send a request response. | |
void | websSetIpAddr(char *ipaddr) |
Define the host IP address. | |
void | websSetPasswordStoreVerify(WebsVerify verify) |
Set the password store verify callback. | |
void | websSetQueryVars(Webs *wp) |
Create request variables for query string data. | |
int | websSetRouteAuth(WebsRoute *route, char *authType) |
Set route authentication scheme. | |
int | websSetRouteMatch(WebsRoute *route, char *dir, char *protocol, WebsHash methods, WebsHash extensions, WebsHash abilities, WebsHash redirects) |
Configure a route by adding matching criteria. | |
int | websSetSessionVar(Webs *wp, char *name, char *value) |
Set a session variable name value. | |
void | websSetStatus(Webs *wp, int status) |
Set the response HTTP status code. | |
void | websSetTxLength(Webs *wp, ssize length) |
Set the response body content length. | |
int | websSetUserRoles(char *username, char *roles) |
Define the set of roles for a user. | |
void | websSetVar(Webs *wp, char *name, char *value) |
Set a request variable to a string value. | |
void | websSetVarFmt(Webs *wp, char *name, char *fmt, ...) |
Set a request variable to a formatted string value. | |
int | websStartEvent(int delay, WebsEventProc proc, void *data) |
Start a callback event. | |
int | websStatFile(char *path, WebsFileInfo *sbuf) |
Get file status for a file. | |
void | websStopEvent(int id) |
Stop an event. | |
char* | websTempFile(char *dir, char *prefix) |
Create a temporary filename This does not guarantee the filename is unique or that it is not already in use by another application. | |
bool | websTestVar(Webs *wp, char *name) |
Test if a request variable is defined. | |
void | websUploadOpen() |
Open the file upload filter. | |
int | websUrlParse(char *url, char **buf, char **protocol, char **host, char **port, char **path, char **ext, char **reference, char **query) |
Parse a URL into its components. | |
bool | websValid(Webs *wp) |
Test if a webs object is valid. | |
bool | websVerifyPasswordFromCustom(Webs *wp) |
User password verification routine from a custom password back-end store. | |
bool | websVerifyPasswordFromFile(Webs *wp) |
User password verification routine from auth.txt. | |
ssize | websWrite(Webs *wp, char *fmt, ...) |
Write data to the response. | |
ssize | websWriteBlock(Webs *wp, char *buf, ssize size) |
Write a block of data to the response. | |
void | websWriteEndHeaders(Webs *wp) |
Signify the end of the response headers. | |
ssize | websWriteFile(int fd, char *buf, ssize size) |
Write data to the open file. | |
int | websWriteHeader(Webs *wp, char *key, char *fmt, ...) |
Write a response header. | |
void | websWriteHeaders(Webs *wp, ssize contentLength, char *redirect) |
Write a set of standard response headers. | |
ssize | websWriteSocket(Webs *wp, char *buf, ssize size) |
Write a block of data to the network. | |
int | wfreeHandle(void *map, int handle) |
Free a handle in the map. |
Typedefs
SocketAccept | Socket accept callback. |
SocketHandler | Socket I/O callback. |
WebsAction | Action callback. |
WebsAskLogin | Callback to prompt the user for their password. |
WebsError | Error code list. |
WebsEventProc | Callback function for events. |
WebsFileInfo | File information structure. |
WebsHandler | GoAhead handler object. |
WebsHandlerClose | GoAhead handler close to release memory prior to shutdown. |
WebsHandlerProc | GoAhead handler service callback. |
WebsHash | Hash table ID returned by hashCreate. |
WebsJstProc | Javascript native function. |
WebsLogHandler | Callback for emitting trace log output. |
WebsMime | Mime type list. |
WebsParseAuth | Callback to parse authentication details submitted with the web request. |
WebsRole | Role definition structure. |
WebsRomIndex | Compiled Rom Page Index. |
WebsStat | File status structure. |
WebsTime | System native time type. |
WebsUser | User definition structure. |
WebsValue | Value union to store primitive value types. |
WebsVerify | Callback to verify the username and password. |
WebsWriteProc | Callback for write I/O events. |
Defines
#define | HTTP_CODE_ACCEPTED 202 |
The request has been accepted and processing is continuing. | |
#define | HTTP_CODE_BAD_GATEWAY 502 |
The server cannot act as a gateway for the given request. | |
#define | HTTP_CODE_BAD_METHOD 405 |
The request HTTP method was not supported by the resource. | |
#define | HTTP_CODE_BAD_REQUEST 400 |
The request is malformed. | |
#define | HTTP_CODE_BAD_VERSION 505 |
The server does not support the HTTP protocol version. | |
#define | HTTP_CODE_COMMS_ERROR 550 |
The server had a communicationss error responding to the client. | |
#define | HTTP_CODE_CONFLICT 409 |
The request had a conflict in the request headers and URI. | |
#define | HTTP_CODE_CONTINUE 100 |
Continue with request, only partial content transmitted. | |
#define | HTTP_CODE_CREATED 201 |
The request has completed and a new resource was created. | |
#define | HTTP_CODE_EXPECTATION_FAILED 417 |
The server cannot satisfy the Expect header requirements. | |
#define | HTTP_CODE_FORBIDDEN 403 |
The request was legal, but the server refuses to process. | |
#define | HTTP_CODE_GATEWAY_TIMEOUT 504 |
The server gateway timed out waiting for the upstream server. | |
#define | HTTP_CODE_GONE 410 |
The requested resource is no longer available. | |
#define | HTTP_CODE_INSUFFICIENT_STORAGE 507 |
The server has insufficient storage to complete the request. | |
#define | HTTP_CODE_INTERNAL_SERVER_ERROR 500 |
Server processing or configuration error. | |
#define | HTTP_CODE_LENGTH_REQUIRED 411 |
The request did not specify a required content length. | |
#define | HTTP_CODE_MOVED_PERMANENTLY 301 |
The requested URI has moved permanently to a new location. | |
#define | HTTP_CODE_MOVED_TEMPORARILY 302 |
The URI has moved temporarily to a new location. | |
#define | HTTP_CODE_NO_CONTENT 204 |
The request has completed and there is no response to send. | |
#define | HTTP_CODE_NO_RESPONSE 444 |
The connection was closed with no response to the client. | |
#define | HTTP_CODE_NOT_ACCEPTABLE 406 |
The requested resource cannot generate the required content. | |
#define | HTTP_CODE_NOT_AUTHORITATIVE 203 |
The request has completed but content may be from another source. | |
#define | HTTP_CODE_NOT_FOUND 404 |
The requested resource was not found. | |
#define | HTTP_CODE_NOT_IMPLEMENTED 501 |
The server does not recognize the request or method. | |
#define | HTTP_CODE_NOT_MODIFIED 304 |
The requested resource has changed since the last request. | |
#define | HTTP_CODE_OK 200 |
The request completed successfully. | |
#define | HTTP_CODE_PARTIAL 206 |
The request has completed and is returning partial content. | |
#define | HTTP_CODE_PAYMENT_REQUIRED 402 |
Reserved for future use. | |
#define | HTTP_CODE_PRECOND_FAILED 412 |
The server cannot satisfy one of the request preconditions. | |
#define | HTTP_CODE_RANGE_NOT_SATISFIABLE 416 |
The request content range does not exist for the resource. | |
#define | HTTP_CODE_REQUEST_TIMEOUT 408 |
The server timed out waiting for the request to complete. | |
#define | HTTP_CODE_REQUEST_TOO_LARGE 413 |
The request is too large for the server to process. | |
#define | HTTP_CODE_REQUEST_URL_TOO_LARGE 414 |
The request URI is too long for the server to process. | |
#define | HTTP_CODE_RESET 205 |
The request has completed with no content. | |
#define | HTTP_CODE_SEE_OTHER 303 |
The requested URI can be found at another URI location. | |
#define | HTTP_CODE_SERVICE_UNAVAILABLE 503 |
The server is currently unavailable or overloaded. | |
#define | HTTP_CODE_TEMPORARY_REDIRECT 307 |
The request should be repeated at another URI location. | |
#define | HTTP_CODE_UNAUTHORIZED 401 |
Authentication for the request has failed. | |
#define | HTTP_CODE_UNSUPPORTED_MEDIA_TYPE 415 |
The request media type is not supported by the server or resource. | |
#define | HTTP_CODE_USE_PROXY 305 |
The requested resource must be accessed via the location proxy. | |
#define | SOCKET_AGAIN 4 |
Issue the request again. | |
#define | SOCKET_ASYNC 0x8 |
Use async connect. | |
#define | SOCKET_BLOCK 0x10 |
Use blocking I/O. | |
#define | SOCKET_BUFFERED_READ 0x200 |
Message pending on this socket. | |
#define | SOCKET_BUFFERED_WRITE 0x400 |
Message pending on this socket. | |
#define | SOCKET_CLOSING 0x40 |
Socket is closing. | |
#define | SOCKET_CONNECTING 0x2 |
Connect in progress. | |
#define | SOCKET_CONNRESET 0x80 |
Socket connection was reset. | |
#define | SOCKET_EOF 0x1 |
Seen end of file. | |
#define | SOCKET_EXCEPTION 0x8 |
Interested in exceptions. | |
#define | SOCKET_HANDSHAKING 0x100 |
Doing SSL handshake. | |
#define | SOCKET_INTR 5 |
Call was interrupted. | |
#define | SOCKET_INVAL 6 |
Invalid. | |
#define | SOCKET_LISTENING 0x20 |
Socket is server listener. | |
#define | SOCKET_NETDOWN 3 |
Network is down. | |
#define | SOCKET_NODELAY 0x800 |
Disable Nagle algorithm. | |
#define | SOCKET_READABLE 0x2 |
Make socket readable. | |
#define | SOCKET_RESERVICE 0x4 |
Socket needs re-servicing. | |
#define | SOCKET_RESET 2 |
Socket has been reset. | |
#define | SOCKET_WOULDBLOCK 1 |
Socket would block on I/O. | |
#define | SOCKET_WRITABLE 0x4 |
Make socket writable. | |
#define | VALUE_ALLOCATE 0x1 |
Allocate strings using malloc. | |
#define | value_numeric (t >= byteint && t <= big) |
The value is a numeric type. | |
#define | value_ok (t > undefined && t <= symbol) |
The value is valid supported type. | |
#define | value_str (t >= string && t <= bytes) |
The value is a string type. | |
#define | WEBS_ACCEPTED 0x1 |
TLS connection accepted. | |
#define | WEBS_ASSERT_MSG 0x10 |
Originated from assert. | |
#define | WEBS_BEGIN 0x0 |
Beginning state. | |
#define | WEBS_CHUNK_DATA 3 |
Start of chunk data. | |
#define | WEBS_CHUNK_HEADER 2 |
Preparing tx chunk header. | |
#define | WEBS_CHUNK_START 1 |
Start of a new chunk. | |
#define | WEBS_CHUNK_UNCHUNKED 0 |
Data is not transfer-chunk encoded. | |
#define | WEBS_CHUNKING 0x2 |
Currently chunking output body data. | |
#define | WEBS_CLOSE 0x20000 |
Close connection. | |
#define | WEBS_CLOSED 0x4 |
Connection closed, ready to free. | |
#define | WEBS_COMPLETE 0x8 |
Request complete. | |
#define | WEBS_CONFIG 2 |
Configuration settings trace level. | |
#define | WEBS_CONTENT 0x1 |
Ready for body data. | |
#define | WEBS_COOKIE 0x8 |
Cookie supplied in request. | |
#define | WEBS_COOKIE_HTTP 0x2 |
Flag for websSetCookie for http cookies (http only). | |
#define | WEBS_COOKIE_SECURE 0x1 |
Flag for websSetCookie for secure cookies (https only). | |
#define | WEBS_DECODE_TOKEQ 1 |
Decode base 64 blocks up to a NULL or equals. | |
#define | WEBS_ERROR 1 |
Standard logging trace levels are 0 to 9 with 0 being the most verbose. | |
#define | WEBS_ERROR_MSG 0x20 |
Originated from error. | |
#define | WEBS_FINALIZED 0x10 |
Output is finalized. | |
#define | WEBS_FORM 0x20 |
Request is a form (url encoded data). | |
#define | WEBS_HEADERS_CREATED 0x40 |
Headers have been created and buffered. | |
#define | WEBS_HTTP11 0x80 |
Request is using HTTP/1.1. | |
#define | WEBS_KEEP_ALIVE 0x100 |
HTTP/1.1 keep alive. | |
#define | WEBS_LEVEL_MASK 0xF |
Level mask. | |
#define | WEBS_LOG_MSG 0x100 |
Originated from logmsg. | |
#define | WEBS_MAX_LISTEN 8 |
Maximum number of listen endpoints. | |
#define | WEBS_NOLOG 0x40000 |
Don't write error to log. | |
#define | WEBS_RAW_MSG 0x200 |
Raw message output. | |
#define | WEBS_READY 0x2 |
Ready to route and start handler. | |
#define | WEBS_REROUTE 0x1000 |
Restart route matching. | |
#define | WEBS_RESPONSE_TRACED 0x200 |
Started tracing the response. | |
#define | WEBS_RUNNING 0x4 |
Processing request. | |
#define | WEBS_SECURE 0x400 |
Connection uses SSL. | |
#define | WEBS_SMALL_HASH 31 |
General small hash size. | |
#define | WEBS_TRACE_MSG 0x400 |
Originated from trace. | |
#define | WEBS_TRIM_BOTH 0x3 |
Flag for strim to trim from both the start and the end of the string. | |
#define | WEBS_TRIM_END 0x2 |
Flag for strim to trim from the end of the string. | |
#define | WEBS_TRIM_START 0x1 |
Flag for strim to trim from the start of the string. | |
#define | WEBS_UPLOAD 0x800 |
Multipart-mime file upload. | |
#define | WEBS_VARS_ADDED 0x8000 |
Query and body form vars added. | |
#define | WEBS_VERBOSE 9 |
Highest level of trace. | |
#define | WEBS_WARN 2 |
Soft warning trace level. |
Webs
GoAhead request structure.
- Fields:
-
char * authDetails Http header auth details. char * authResponse Outgoing auth header. char * authType Authorization type (Basic/DAA). char * boundary Mime boundary (static). ssize boundaryLen Boundary length. int cgifd File handle for CGI program input. char * cgiStdin Filename for CGI program input. WebsBuf chunkbuf Pre-chunking data buffer. char * clientFilename Current file filename. char * cnonce check nonce. int code Response status code. char * contentType Body content type. char * cookie Request cookie string. WebsUpload * currentFile Current file context. char * decodedQuery Decoded request query. char * digest Password digest. char * digestUri URI found in digest header. int docfd File descriptor for document being served. int encoded True if the password is MD5(username:realm:password). bool eof If at the end of the request content. char * ext Path extension. char * filename Document path name. WebsHash files Uploaded files. int flags Current flags see above. char * host Requested host. char ifaddr[64] Local interface ipaddress. WebsBuf input Receive buffer after de-chunking. char * inputFile File name to write input body data. char ipaddr[64] Connecting ipaddress. ssize lastRead Number of bytes last read from the socket. int listenSid Listen Socket id. char * method HTTP request method. char * nc nonce count. char * nonce opaque-to-client string sent by server. char * opaque opaque value passed from server. WebsBuf output Transmit buffer after chunking. char * password Authorization password. char * path Path name without query. This is decoded. int port Request port number. char * protocol Protocol scheme (normally http|https). char * protoVersion Protocol version (HTTP/1.1). ssize putLen Bytes read by a PUT request. char * putname PUT temporary filename. char * qop quality operator. char * query Request query. This is decoded. char * realm Realm field supplied in auth header. char * referrer The referring page. char * responseCookie Outgoing cookie. struct WebsRoute * route Request route. WebsBuf rxbuf Raw receive buffer. ssize rxChunkSize Rx chunk size. int rxChunkState Rx chunk encoding state. char * rxEndp Pointer to end of raw data in input beyond endp. ssize rxLen Rx content length. ssize rxRemaining Remaining content to read from client. struct WebsSession * session Session record. int sid Socket id (handler). WebsTime since Parsed if-modified-since time. void * ssl SSL context. int state Current state. int timeout Timeout handle. WebsTime timestamp Last transaction with browser. ssize txChunkLen Length of the chunk. char txChunkPrefix[16] Transmit chunk prefix. ssize txChunkPrefixLen Length of prefix. char * txChunkPrefixNext Current I/O pos in txChunkPrefix. int txChunkState Transmit chunk state. ssize txLen Tx content length header value. int upfd Upload file handle. int uploadState Current file upload state. char * uploadTmp Current temp filename for upload data. char * uploadVar Current upload form variable name. char * url Full request url. This is not decoded. struct WebsUser * user User auth record. char * userAgent User agent (browser). char * username Authorization username. WebsHash vars CGI standard variables. int wid Index into webs. WebsWriteProc writeData Handler write I/O event callback. Used by fileHandler. ssize written Bytes actually transferred.
Close the ssl module.
- See Also:
Free a ssl connection associated with a request.
- Parameters:
-
wp Webs request object.
- See Also:
Open the ssl module.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Read data from a secure socket.
- Parameters:
-
wp Webs request object. buf Buffer into which to read data. len Size of buf.
- Returns:
- Count of bytes read if successful, otherwise -1.
- See Also:
Upgrade a request connection to utilize SSL.
- Description:
- This routine is invoked on a connection received on a secure listening socket.
- Parameters:
-
wp Webs request object.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
WRite data to a secure socket.
- Parameters:
-
wp Webs request object. buf Buffer from which to write data. len Size of buf.
- Returns:
- Count of bytes written if successful, otherwise -1.
- See Also:
Accept a new connection.
- Parameters:
-
sid Socket ID handle for the newly accepted socket. ipaddr IP address originating the connection. port Port number originating the connection. listenSid Socket ID of the listening socket.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Open the action handler.
- See Also:
Allocate a new Webs object.
- Parameters:
-
sid Socket ID handle for the newly accepted socket.
- Returns:
- The webs[] handle index for the allocated Webs object.
- See Also:
Cancel the request timeout.
- Description:
- Handlers may choose to manually manage the request timeout. This routine will disable the centralized management of the timeout for this request.
- Parameters:
-
wp Webs request object.
- See Also:
CGI handler service callback.
- Parameters:
-
wp Webs object.
- Returns:
- Returns 1 if the request was handled.
- See Also:
Open the CGI handler.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Poll for output from CGI processes and output.
- Returns:
- Time delay till next poll.
- See Also:
Close the core GoAhead web server module.
- Description:
- Invoked when GoAhead is shutting down.
- See Also:
Close an open file.
- Parameters:
-
fd Open file handle returned by websOpenFile.
- See Also:
Compare a request variable.
- Parameters:
-
wp Webs request object. var Variable name. value Value to compare with.
- Returns:
- True if the value matches. Otherwise return 0.
- See Also:
Consume input from the request input buffer.
- Description:
- This is called by handlers when consuming data from the request input buffer. This call updates the input service pointers and compacts the input buffer if required.
- Parameters:
-
wp Webs request object. nbytes Number of bytes the handler has consumed from the input buffer.
- See Also:
Decode the string using base-64 encoding.
- Description:
- This modifies the original string.
- Parameters:
-
str String to decode.
- Returns:
- The original string.
- See Also:
Decode a block using base-46 encoding.
- Parameters:
-
str String to decode. The string must be null terminated. len Reference to an integer holding the length of the decoded string. flags Reserved.
- Returns:
- The original string.
- See Also:
Decode a URL expanding NN encoding.
- Description:
- Supports insitu decoding. i.e. Input and output buffers may be the same.
- Parameters:
-
decoded Buffer to hold the decoded URL. input Input URL or buffer to decode. len Length of the decoded buffer.
- See Also:
Define an action callback for use with the action handler.
- Description:
- The action handler binds a C function to a URI under "/action".
- Parameters:
-
name URI path suffix. This suffix is added to "/action" to form the bound URI path. fun Callback function. The signature is void (*WebsAction)(Webs *wp);.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Define a request handler.
- Parameters:
-
name Name of the handler. service Handler callback service procedure. Invoked to service each relevant request. close Handler callback close procedure. Called when GoAhead is shutting down. flags Set to WEBS_LEGACY_HANDLER to support the legacy handler API calling sequence.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Define a Javscript native function.
- Description:
- This routine binds a C function to a Javascript function. When the Javascript function is called, the C function is invoked.
- Parameters:
-
name Javascript function name. fn C function to invoke.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Complete a request.
- Description:
- A handler should call websDone() to complete the request.
- Parameters:
-
wp Webs request object.
- See Also:
Encode a string using base-64 encoding.
- Description:
- The string is encoded insitu.
- Parameters:
-
str String to encode.
- Returns:
- The original string.
- See Also:
Encode a block using base-64 encoding.
- Description:
- The string is encoded insitu.
- Parameters:
-
str String to encode. len Length of string to encode.
- Returns:
- The original string.
- See Also:
Complete a request with an error response.
- Parameters:
-
wp Webs request object. code HTTP status code. fmt Message printf style format. ... Format args.
- See Also:
Get a message for a HTTP status code.
- Parameters:
-
code HTTP status code.
- Returns:
- Http status message.
- See Also:
Escape unsafe characters in a string.
- Parameters:
-
str String to escape.
- Returns:
- An allocated block containing the escaped string. Caller must free.
- See Also:
Open and initialize the file handler.
- See Also:
Flush buffered transmit data and compact the transmit buffer to make room for more data.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the contents of the transmit buffer are fully written and the buffer is now empty.
- See Also:
Free the webs request object.
- Description:
- Callers should call websDone to complete requests prior to invoking websFree.
- Parameters:
-
wp Webs request object.
- See Also:
Free file upload data structures.
- Parameters:
-
wp Webs request object.
- See Also:
Close the file system module.
- See Also:
Open the file system module.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Get the background execution flag.
- Description:
- If GoAhead is invoked with
background, it will run as a daemon in the background.
- Returns:
- True if GoAhead is running in the background.
- See Also:
Get a unique temporary filename for CGI communications.
- Returns:
- Filename string.
- See Also:
Get the request cookie if supplied.
- Parameters:
-
wp Webs request object.
- Returns:
- Cookie string if defined, otherwise null.
- See Also:
Get a date as a string.
- Description:
- If sbuf is supplied, it is used to calculate the date. Otherwise, the current time is used.
- Parameters:
-
sbuf File info object.
- Returns:
- An allocated date string. Caller should free.
- See Also:
Get the debug flag.
- Description:
- If GoAhead is invoked with
debugger, the debug flag will be set to true.
- Returns:
- True if GoAhead is running in debug mode.
- See Also:
Get the base file directory for a request.
- Description:
- Returns the request route directory if defined, otherwise returns the documents directory.
- Parameters:
-
wp Webs request object.
- Returns:
- Path name string. Caller should not free.
- See Also:
Get the GoAhead base documents directory.
- Description:
- The documents directory is defined at build time and may be overridden by the GoAhead command line.
- Returns:
- Path string for the documents directory.
- See Also:
Get the request EOF status.
- Description:
- The request EOF status is set to true when all the request body (POST|PUT) data has been received.
- Parameters:
-
wp Webs request object.
- Returns:
- True if all the request body data has been received.
- See Also:
Get the request URI extension.
- Parameters:
-
wp Webs request object.
- Returns:
- The URI filename extension component. Caller should not free.
- See Also:
Get the request filename.
- Description:
- The URI is mapped to a filename by decoding and prepending with the request directory.
- Parameters:
-
wp Webs request object.
- Returns:
- Filename string. Caller should not free.
- See Also:
Get the request host.
- Description:
- The request host is set to the Host HTTP header value if it is present. Otherwise it is set to the request URI hostname.
- Parameters:
-
wp Webs request object.
- Returns:
- Host string. Caller should not free.
- See Also:
Get the request interface address.
- Parameters:
-
wp Webs request object.
- Returns:
- Network interface string. Caller should not free.
- See Also:
Get the default index document name.
- Description:
- The default index is "index.html" and can be updated via websSetIndex.
- Returns:
- Index name string. Caller should not free.
- See Also:
Get the current trace log level.
- Returns:
- Number between 0 and 9.
- See Also:
Get the request method.
- Parameters:
-
wp Webs request object.
- Returns:
- HTTP method string. Caller should not free.
- See Also:
Get the request password.
- Description:
- The request password may be encoded depending on the authentication scheme. See wp->encoded to test if it is encoded.
- Parameters:
-
wp Webs request object.
- Returns:
- Password string. Caller should not free.
- See Also:
Get the request path.
- Description:
- The URI path component excludes the http protocol, hostname, port, reference and query components. It always beings with "/".
- Parameters:
-
wp Webs request object.
- Returns:
- Request path string. Caller should not free.
- See Also:
Get the request TCP/IP port.
- Parameters:
-
wp Webs request object.
- Returns:
- TCP/IP Port integer.
- See Also:
Get the request HTTP protocol.
- Description:
- This will be set to either "http" or "https".
- Parameters:
-
wp Webs request object.
- Returns:
- Protocol string. Caller should not free.
- See Also:
Get the request query component.
- Parameters:
-
wp Webs request object.
- Returns:
- Request query string. Caller should not free.
- See Also:
Get the server host name.
- Returns:
- Host name string. Caller should not free.
- See Also:
Get the server IP address.
- Returns:
- Server IP address string. Caller should not free.
- See Also:
Get the server IP address with port number.
- Returns:
- Server IP:PORT address string. Caller should not free.
- See Also:
Get the server host name with port number.
- Returns:
- Host name string with port number. Caller should not free.
- See Also:
Get the request URI.
- Description:
- This returns the request URI. This may be modified if the request is rewritten via websRewrite.
- Parameters:
-
wp Webs request object.
- Returns:
- URI string. Caller should not free.
- See Also:
Get the client User-Agent HTTP header.
- Parameters:
-
wp Webs request object.
- Returns:
- User-Agent string. Caller should not free.
- See Also:
Get the request username.
- Description:
- If the request is authenticated, this call returns the username supplied during authentication.
- Parameters:
-
wp Webs request object.
- Returns:
- Username string if defined, otherwise null. Caller should not free.
- See Also:
Get a request variable.
- Description:
- Request variables are defined for HTTP headers of the form HTTP_*. Some request handlers also define their own variables. For example: CGI environment variables.
- Parameters:
-
wp Webs request object. name Variable name. defaultValue Default value to return if the variable is not defined.
- Returns:
- Variable value string. Caller should not free.
- See Also:
Open the Javascript module.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Write data to the response.
- Parameters:
-
jid Javascript ID handle. wp Webs request object. argc Count of arguments. argv Array arguments.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Listen on a TCP/IP address endpoint.
- Description:
- The URI is mapped to a filename by decoding and prepending with the request directory. For IPv6 addresses, use the format: [aaaa:bbbb:cccc:dddd:eeee:ffff:gggg:hhhh:iiii]:port.
- Parameters:
-
endpoint IPv4 or IPv6 address on which to listen.
- Returns:
- Positive integer holding a Socket ID handle if successful, otherwise -1.
- See Also:
Get an MD5 digest of a string.
- Parameters:
-
str String to analyze.
- Returns:
- Allocated MD5 checksum. Caller should free.
- See Also:
Get an MD5 digest of a block and optionally prepend a prefix.
- Parameters:
-
buf Block to analyze. length Length of block. prefix Optional prefix to prepend to the MD5 sum.
- Returns:
- Allocated MD5 checksum. Caller should free.
- See Also:
Normalize a URI path.
- Description:
- This removes "./", "../" and redundant separators.
- Parameters:
-
path URI path to normalize.
- Returns:
- A normalized URI path. Caller should not free.
- See Also:
Take not of the request activity and mark the time.
- Description:
- This is used to defer the request timeout whenever there is request I/O activity.
- Parameters:
-
wp Webs request object.
- See Also:
Open the web server.
- Description:
- This initializes the web server and defines the documents directory.
- Parameters:
-
documents Optional web documents directory. If set to null, the build time BIT_GOAHEAD_DOCUMENTS value is used for the documents directory. routes Optional filename for a route configuration file to load. Additional route or authentication configuration files can be loaded via websLoad. routes Webs request object.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Open the web page document for the current request.
- Parameters:
-
path Filename path to open. flags File open flags. mode Permissions mask.
- Returns:
- Positive file handle if successful, otherwise -1.
- See Also:
Open the options handler.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Close the O/S dependant code.
- Description:
- Called from websClose.
- See Also:
Open the O/S dependant code.
- Description:
- Called from websOpen.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Close the document page.
- Parameters:
-
wp Webs request object.
- See Also:
Test if the document page for the request corresponds to a directory.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the filename is a directory.
- See Also:
Open a web page document for a request.
- Parameters:
-
wp Webs request object. mode File open mode. Select from O_RDONLY and O_BINARY. Rom files systems ignore this argument. perms Ignored.
- Returns:
- File handle if successful, otherwise -1.
- See Also:
Read data from the request page document.
- Parameters:
-
wp Webs request object. buf Buffer for the read data. size Size of buf.
- Returns:
- Count of bytes read if successful, otherwise -1.
- See Also:
Seek to a position in the request page document.
- Parameters:
-
wp Webs request object. offset Offset of location in the file to seek to. This is relative to the specified origin. origin Set to SEEK_CUR, SEEK_SET or SEEK_END to position relative to the current position, beginning or end of the document.
- See Also:
Get file status for the current request document.
- Parameters:
-
wp Webs request object. sbuf File information structure to modify with file status.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Process CGI request body data.
- Parameters:
-
wp Webs request object.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Process upload data for form, multipart mime file upload.
- Parameters:
-
wp Webs request object.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Pump the state machine.
- Description:
- This routine will advance the connection state machine in response to events.
- Parameters:
-
wp Webs request object.
- See Also:
Read data from an open file.
- Parameters:
-
fd Open file handle returned by websOpenFile. buf Buffer for the read data. size Size of buf.
- Returns:
- Count of bytes read if successful, otherwise -1.
- See Also:
Read all the data from a file.
- Parameters:
-
path File path to read from.
- Returns:
- An allocated buffer containing the file data with an appended null. Caller must free.
- See Also:
Redirect the client to a new URL.
- Description:
- This creates a response to the client with a Location header directing the client to a new location. The response uses a 302 HTTP status code.
- Parameters:
-
wp Webs request object. url URL to direct the client to.
- See Also:
Redirect the client to a new URI.
- Description:
- The routing configuration file can define redirection routes for various HTTP status codes. This routine will utilize the appropriate route redirection based on the request route and specified status code.
- Parameters:
-
wp Webs request object. status HTTP status code to use in selecting the route redirection.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Create and send a request response.
- Description:
- This creates a response for the current request using the specified HTTP status code and the supplied message.
- Parameters:
-
wp Webs request object. status HTTP status code. msg Response message body.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Rewrite a request.
- Description:
- Handlers may choose to not process a request but rather rewrite requests and then reroute.
- Parameters:
-
wp Webs request object. url New request URL.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Close the runtime code.
- Description:
- Called from websClose.
- See Also:
Open the runtime code.
- Description:
- Called from websOpen.
- Returns:
- Zero if successful.
- See Also:
Seek to a position in the current request page document.
- Parameters:
-
fd Open file handle returned by websOpenFile. offset Location in the file to seek to. origin Set to SEEK_CUR, SEEK_SET or SEEK_END to position relative to the current position, beginning or end of the document.
- See Also:
One line embedding API.
- Description:
- This call will also open auth.txt and route.txt for authentication and routing configuration.
- Parameters:
-
endpoint IP:PORT address on which to listen. documents Directory containing web documents to serve.
- See Also:
Service I/O events until finished.
- Description:
- This will wait for socket events and service those until *finished is set to true.
- Parameters:
-
finished Integer location to test. If set to true, then exit. Note: setting finished will not automatically wake up the service routine.
- See Also:
Set the background processing flag.
- Parameters:
-
on Value to set the background flag to.
- See Also:
Define a cookie to include in the response.
- Parameters:
-
wp Webs request object. name Cookie name. value Cookie value. path URI path prefix applicable for this cookie. domain Domain applicable for this cookie. lifespan Cookie lifespan in secons. flags Set to WEBS_COOKIE_SECURE for https only. Set to WEBS_COOKIE_HTTP for http only. Otherwise the cookie applies to both http and https requests.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Set the debug processing flag.
- Parameters:
-
on Value to set the debug flag to.
- See Also:
Set the web documents directory.
- Description:
- The web documents directory is used when resolving request URIs into filenames.
- Parameters:
-
dir Directory path to use.
- See Also:
Create the CGI environment variables for the current request.
- Parameters:
-
wp Webs request object.
- See Also:
Create request variables for query and POST body data.
- Description:
- This creates request variables if the request is a POST form (has a Content-Type of application/x-www-form-urlencoded). The POST body data is consumed from the input buffer.
- Parameters:
-
wp Webs request object.
- See Also:
Define the host name for the server.
- Parameters:
-
host String host name.
- See Also:
Create and send a request response.
- Description:
- This creates a response for the current request using the specified HTTP status code and the supplied message.
- Parameters:
-
filename Web document name to use as the index. This should not contain any directory components.
- See Also:
Define the host IP address.
- Parameters:
-
ipaddr Host IP address.
- See Also:
Create request variables for query string data.
- Parameters:
-
wp Webs request object.
- See Also:
Set the response HTTP status code.
- Parameters:
-
wp Webs request object. status HTTP status code.
- See Also:
Set the response body content length.
- Parameters:
-
wp Webs request object. length Length value to use.
- See Also:
Set a request variable to a string value.
- Description:
- Request variables are defined for HTTP headers of the form HTTP_*. Some request handlers also define their own variables. For example: CGI environment variables.
- Parameters:
-
wp Webs request object. name Variable name to set. value Value to set.
- See Also:
Set a request variable to a formatted string value.
- Description:
- Request variables are defined for HTTP headers of the form HTTP_*. Some request handlers also define their own variables. For example: CGI environment variables.
- Parameters:
-
wp Webs request object. name Variable name to set. fmt Value format string. ... Args to format.
- See Also:
Get file status for a file.
- Parameters:
-
path Filename path. sbuf File information structure to modify with file status.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Create a temporary filename This does not guarantee the filename is unique or that it is not already in use by another application.
- Parameters:
-
dir Directory to locate the temp file. Defaults to the O/S default temporary directory (usually /tmp). prefix Filename prefix.
- Returns:
- An allocated filename string.
- See Also:
Test if a request variable is defined.
- Parameters:
-
wp Webs request object. name Variable name.
- Returns:
- True if the variable is defined.
- See Also:
Parse a URL into its components.
- Parameters:
-
url URL to parse. buf Buffer to hold storage for various parsed components. Caller must free. NOTE: the parsed components may point to locations in this buffer. protocol Parsed URL protocol component. host Parsed hostname. port Parsed URL port. path Parsed URL path component. ext Parsed URL extension. reference Parsed URL reference portion (#reference). query Parsed URL query component.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Test if a webs object is valid.
- Description:
- After calling websDone, the websFree routine will have been called and the memory for the webs object will be released. Call websValid to test an object hand for validity.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the webs object is still valid and the request has not been completed.
- See Also:
Write data to the response.
- Description:
- The data is buffered and will be sent to the client when the buffer is full or websFlush is called.
- Parameters:
-
wp Webs request object. fmt Printf style format string. ... Arguments to the format string.
- Returns:
- Count of bytes written.
- See Also:
Write a block of data to the response.
- Description:
- The data is buffered and will be sent to the client when the buffer is full or websFlush is called.
- Parameters:
-
wp Webs request object. buf Buffer of data to write. size Length of buf.
- Returns:
- Count of bytes written. This will always equal size if there are not errors.
- See Also:
Signify the end of the response headers.
- Description:
- This call concludes the response headers and writes a blank line to the response.
- Parameters:
-
wp Webs request object.
- See Also:
Write data to the open file.
- Parameters:
-
fd Open file handle returned by websOpenFile. buf Buffer for the read data. size Size of buf.
- Returns:
- Count of bytes read if successful, otherwise -1.
- See Also:
Write a response header.
- Description:
- This routine writes a response header. It should be invoked after calling websWriteHeaders to write the standard headers and before websWriteEndHeaders. This routine differs from websWrite in that it traces header values to the log.
- Parameters:
-
wp Webs request object. key Header key value. fmt Header value format string. ... Arguments to the format string.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Write a set of standard response headers.
- Parameters:
-
wp Webs request object. contentLength Value for the Content-Length header which describes the length of the response body. redirect Value for the Location header which redirects the client to a new URL.
- See Also:
- websSetStatus
Write a block of data to the network.
- Description:
- This bypassed output buffering and is the lowest level write.
- Parameters:
-
wp Webs request object. buf Buffer of data to write. size Length of buf.
- Returns:
- Count of bytes written. Returns -1 on errors. May return having written less than requested.
- See Also:
WebsAuth
GoAhead Authentication.
- Fields:
-
Add a role.
- Description:
- The role is added to the list of roles.
- Parameters:
-
role Role name. abilities Hash of abilities for the role.
- Returns:
- The allocated role.
- See Also:
Add a user.
- Description:
- The user is added to the list of users.
- Parameters:
-
username User name. password User password (encrypted). roles Space separated list of roles. This may also contain abilities.
- Returns:
- User object.
- See Also:
Authenticate a user.
- Description:
- The user is authenticated if required by the selected request route.
- Returns:
- True if the route does not require authentication or the user is authenticated successfully.
- See Also:
Test if a user possesses the required ability.
- Parameters:
-
wp Webs request object. ability Set of required abilities.
- Returns:
- True if the user has the required ability.
- See Also:
Close the authentication module.
- See Also:
Compute the abilities for all users by resolving roles into abilities.
- See Also:
Set the password store verify callback.
- Returns:
- Verify WebsVerify callback function.
- See Also:
Get the roles hash.
- Returns:
- The roles hash object.
- See Also:
Get the users hash.
- Returns:
- The users hash object.
- See Also:
Login a user by verifying the login credentials.
- Description:
- This may be called by handlers to manually authenticate a user.
- Parameters:
-
wp Webs request object. username User name. password User password (encrypted).
- Returns:
- True if the user can be authenticated.
- See Also:
Lookup if a user exists.
- Parameters:
-
username User name to search for.
- Returns:
- User object or null if the user cannot be found.
- See Also:
Open the authentication module.
- Parameters:
-
minimal Reserved. Set to zero.
- Returns:
- True if the user has the required ability.
- See Also:
Remove a role from the system.
- Parameters:
-
role Role name.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Remove a user from the system.
- Parameters:
-
name User name.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Set the password store verify callback.
- Parameters:
-
verify WebsVerify callback function.
- See Also:
Define the set of roles for a user.
- Parameters:
-
username User name. roles Space separated list of roles or abilities.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
User password verification routine from a custom password back-end store.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the user password verifies.
- See Also:
User password verification routine from auth.txt.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the user password verifies.
- See Also:
WebsBuf
A WebsBuf (ring queue) allows maximum utilization of memory for data storage and is ideal for input/output buffering.
- Fields:
-
char * buf Holding buffer for data. ssize buflen Length of ring queue. char * endbuf Pointer to end of buffer. char * endp Pointer to end of data. int increment Growth increment. ssize maxsize Maximum size. char * servp Pointer to start of data.
Add a trailing null to the buffer.
The end pointer is not changed- Parameters:
-
bp Buffer reference.
- See Also:
Adjust the endp pointer by the specified size.
- Description:
- This is useful after manually copying data into the buffer and needing to adjust the end pointer.
- Parameters:
-
bp Buffer reference. size Size of adjustment. May be positive or negative value.
- See Also:
Adjust the start (servp) reference.
- Parameters:
-
bp Buffer reference. count Number of bytes to adjust.
- See Also:
Compact the data in the buffer and move to the start of the buffer.
- Parameters:
-
bp Buffer reference.
- See Also:
Create a buffer.
- Parameters:
-
bp Buffer reference. increment Incremental size to grow the buffer. This will be increased by a power of two each time the buffer grows. maxsize Maximum size of the buffer.
- Returns:
- Zero if successful.
- See Also:
Flush all data in the buffer and reset the pointers.
- Parameters:
-
bp Buffer reference.
- See Also:
Free allocated storage for the buffer.
- Parameters:
-
bp Buffer reference.
- Returns:
- Zero if successful.
- See Also:
Copy a block of from the buffer and adjust the servp.
- Parameters:
-
bp Buffer reference. blk Block into which to place the data. len Length of the block.
- Returns:
- Number of bytes copied.
- See Also:
Return the maximum number of bytes the buffer can provide via a single block copy.
- Description:
- Useful if the user is doing their own data retrieval.
- Parameters:
-
bp Buffer reference.
- Returns:
- Number of bytes available for copying.
- See Also:
Get a character from the buffer and increment the servp.
- Parameters:
-
bp Buffer reference.
- Returns:
- The next character or -1 if the buffer is empty.
- See Also:
Grow the buffer by at least the required amount of room.
- Parameters:
-
bp Buffer reference. room Available size required after growing the buffer.
- Returns:
- True if the buffer can be grown to have the required amount of room.
- See Also:
Insert a character to the buffer before the servp position and decrement the servp.
- Parameters:
-
bp Buffer reference. c Character to insert.
- Returns:
- Zero if successful.
- See Also:
Get the length of available data in the buffer.
- Parameters:
-
bp Buffer reference.
- Returns:
- Size of available data in bytes.
- See Also:
Put a block to the buffer.
- Parameters:
-
bp Buffer reference. blk Block to append to the buffer. len Size of the block.
- Returns:
- Length of data appended. Should equal len.
- See Also:
Append a character to the buffer at the endp position and increment the endp.
- Parameters:
-
bp Buffer reference. c Character to append.
- Returns:
- Zero if successful.
- See Also:
Append a string to the buffer at the endp position and increment the endp.
- Parameters:
-
bp Buffer reference. str String to append.
- Returns:
- Count of characters appended. Returns negative if there is an allocation error.
- See Also:
Reset the buffer pointers to the start of the buffer if empty.
- Parameters:
-
bp Buffer reference.
- See Also:
Determine the room available in the buffer.
- Description:
- This returns the maximum number of bytes the buffer can absorb in a single block copy.
- Parameters:
-
bp Buffer reference.
- Returns:
- Number of bytes of availble space.
- See Also:
Get a reference to the start of buffer data.
- Parameters:
-
bp Buffer reference.
- Returns:
- A string pointer.
- See Also:
WebsHash
Hash table entry structure.
- Description:
- The hash structure supports growable hash tables with high performance, collision resistant hashes. Each hash entry has a descriptor entry. This is used to manage the hash table link chains.
- See Also:
- hashCreate, hashDelete, hashEnter, hashFirst, hashFree, hashLookup, hashNext
- Fields:
-
Create a hash table.
- Parameters:
-
size Minimum size of the hash index.
- Returns:
- Hash table ID.
- See Also:
- hashDelete, hashEnter, hashFirst, hashFree, hashLookup, hashNext
Delete a key by name.
- Parameters:
-
id Hash table id returned by hashCreate. name Key name to delete.
- Returns:
- Zero if the delete was successful. Otherwise -1 if the key was not found.
- See Also:
- hashCreate, hashEnter, hashFirst, hashFree, hashLookup, hashNext
Enter a new key and value into the hash table.
- Parameters:
-
id Hash table id returned by hashCreate. name Key name to create. value Key value to enter. arg Optional extra argument to store with the value.
- Returns:
- Reference to the WebKey object storing the key and value.
- See Also:
- hashCreate, hashDelete, hashFirst, hashFree, hashLookup, hashNext
Start walking the hash keys by returning the first key entry in the hash.
- Parameters:
-
id Hash table id returned by hashCreate.
- Returns:
- Reference to the first WebKey object. Return null if there are no keys in the hash.
- See Also:
- hashCreate, hashDelete, hashEnter, hashFree, hashLookup, hashNext
Free a hash table.
- Parameters:
-
id Hash table id returned by hashCreate.
- See Also:
- hashCreate, hashDelete, hashEnter, hashFirst, hashLookup, hashNext
Lookup a name in the hash table.
- Parameters:
-
id Hash table id returned by hashCreate. name Key name to search for.
- Returns:
- Reference to the WebKey object storing the key and value.
- See Also:
- hashCreate, hashDelete, hashEnter, hashFirst, hashFree, hashNext
Continue walking the hash keys by returning the next key entry in the hash.
- Parameters:
-
id Hash table id returned by hashCreate. last Reference to a WebsKey to hold the current traversal key state.
- Returns:
- Reference to the next WebKey object. Returns null if no more keys exist to be traversed.
- See Also:
- hashCreate, hashDelete, hashEnter, hashFirst, hashFree, hashLookup
WebsRoute
Request route structure.
- Fields:
-
WebsHash abilities Required user abilities. WebsAskLogin askLogin Route path prefix. char * authType Authentication type. char * dir Filesystem base directory for route documents. WebsHash extensions Permissible URI extensions. int flags Route control flags. WebsHandler * handler Request handler to service requests. WebsHash methods Supported HTTP methods. WebsParseAuth parseAuth Parse authentication details callback. char * prefix Route path prefix. ssize prefixLen Prefix length. char * protocol HTTP protocol to use for this route. WebsHash redirects Response redirections. WebsVerify verify Verify password callback.
Add a route to the routing tables.
- Parameters:
-
uri Matching URI prefix. handler Request handler to service routed requests. pos Position in the list of routes. Zero inserts at the front of the list. A value of -1 will append to the end of the list.
- Returns:
- A route object.
- See Also:
Close the route module.
- See Also:
Load routing tables from the specified filename.
- Parameters:
-
path Route configuration filename.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Open the routing module.
- See Also:
Remove a route from the routing tables.
- Parameters:
-
uri Matching URI prefix.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Route a request.
- Description:
- This routine will select a matching route and will invoke the selected route handler to service the request. In the process, authentication and request rewriting may take place.
- Parameters:
-
wp Webs request object.
- See Also:
Set route authentication scheme.
- Parameters:
-
route Route to modify. authType Set to "basic", "digest" or "form".
- Returns:
- Zero if successful, otherwise -1.
- See Also:
Configure a route by adding matching criteria.
- Parameters:
-
route Route to modify. dir Set the route documents directory filename. protocol Set the matching HTTP protocol (http or https). methods Hash of permissible HTTP methods. (GET, HEAD, POST, PUT). extensions Hash of permissible URI filename extensions. abilities Required user abilities. The user must be authenticated. abilities Required user abilities. If abilities are required, the user must be authenticated. redirects Set of applicable response redirections when completing the request.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
WebsRuntime
GoAhead Web Server Runtime.
- Description:
- GoAhead provides a secure runtime environment for safe string manipulation and to help prevent buffer overflows and other potential security traps.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
- Fields:
-
Format a string into a static buffer.
- Description:
- This call format a string using printf style formatting arguments. A trailing null will always be appended. The call returns the size of the allocated string excluding the null.
- Parameters:
-
buf Pointer to the buffer. maxSize Size of the buffer. format Printf style format string. ... Variable arguments to format.
- Returns:
- The buffer.
- See Also:
- hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Convert a hex string to an integer.
- Description:
- This call converts the supplied string to an integer using base 16.
- Parameters:
-
str Pointer to the string to parse.
- Returns:
- The integer equivalent value of the string.
- See Also:
- fmt, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Convert an integer to a string buffer.
- Description:
- This call converts the supplied 64 bit integer into a string formatted into the supplied buffer according to the specified radix.
- Parameters:
-
buf Pointer to the buffer that will hold the string. size Size of the buffer. value Integer value to convert. radix The base radix to use when encoding the number.
- Returns:
- Returns a reference to the string.
- See Also:
- fmt, hextoi, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Compare strings ignoring case.
This is a safe replacement for strcasecmp. It can handle NULL args- Description:
- Compare two strings ignoring case differences. This call operates similarly to strcmp.
- Parameters:
-
s1 First string to compare. s2 Second string to compare.
- Returns:
- Returns zero if the strings are equivalent, < 0 if s1 sorts lower than s2 in the collating sequence or > 0 if it sorts higher.
- See Also:
- fmt, hextoi, itosbuf, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Compare strings ignoring case.
This is similar to scaselesscmp but it returns a boolean- Description:
- Compare two strings ignoring case differences.
- Parameters:
-
s1 First string to compare. s2 Second string to compare.
- Returns:
- Returns true if the strings are equivalent, otherwise false.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Clone a string.
- Description:
- Copy a string into a newly allocated block.
- Parameters:
-
str Pointer to the block to duplicate.
- Returns:
- Returns a newly allocated string.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Compare strings.
- Description:
- Compare two strings. This is a safe replacement for strcmp. It can handle null args.
- Parameters:
-
s1 First string to compare. s2 Second string to compare.
- Returns:
- Returns zero if the strings are identical. Return -1 if the first string is less than the second. Return 1 if the first string is greater than the second.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Copy a string.
- Description:
- Safe replacement for strcpy. Copy a string and ensure the destination buffer is not overflowed. The call returns the length of the resultant string or an error code if it will not fit into the target string. This is similar to strcpy, but it will enforce a maximum size for the copied string and will ensure it is always terminated with a null.
- Parameters:
-
dest Pointer to a pointer that will hold the address of the allocated block. destMax Maximum size of the target string in characters. src String to copy.
- Returns:
- The number of characters in the target string.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Format a string.
This is a secure verion of printf that can handle null args- Description:
- Format the given arguments according to the printf style format. See fmt() for a full list of the format specifies. This is a secure replacement for sprintf, it can handle null arguments without crashes.
- Parameters:
-
format Printf style format string. ... Variable arguments for the format string.
- Returns:
- Returns a newly allocated string.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Format a string with varargs.
This is a secure verion of printf that can handle null args- Description:
- Format the given arguments according to the printf style format. See fmt() for a full list of the format specifies. This is a secure replacement for sprintf, it can handle null arguments without crashes.
- Parameters:
-
format Printf style format string. args Varargs argument obtained from va_start.
- Returns:
- Returns a newly allocated string.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Return the length of a string.
- Description:
- Safe replacement for strlen. This call returns the length of a string and tests if the length is less than a given maximum. It will return zero for NULL args.
- Parameters:
-
str String to measure.
- Returns:
- The length of the string.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Convert a string to lower case.
- Description:
- Convert a string to its lower case equivalent.
- Parameters:
-
str String to convert. This string is modified.
- Returns:
- Reference to the supplied str.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Compare strings.
- Description:
- Compare two strings. This is similar to scmp but it returns a boolean.
- Parameters:
-
s1 First string to compare. s2 Second string to compare.
- Returns:
- Returns true if the strings are equivalent, otherwise false.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Compare strings ignoring case.
- Description:
- Compare two strings ignoring case differences for a given string length. This call operates similarly to strncasecmp.
- Parameters:
-
s1 First string to compare. s2 Second string to compare. len Length of characters to compare.
- Returns:
- Returns zero if the strings are equivalent, < 0 if s1 sorts lower than s2 in the collating sequence or > 0 if it sorts higher.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Compare strings.
- Description:
- Compare two strings for a given string length. This call operates similarly to strncmp.
- Parameters:
-
s1 First string to compare. s2 Second string to compare. len Length of characters to compare.
- Returns:
- Returns zero if the strings are equivalent, < 0 if s1 sorts lower than s2 in the collating sequence or > 0 if it sorts higher.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Copy characters from a string.
- Description:
- Safe replacement for strncpy. Copy bytes from a string and ensure the target string is not overflowed. The call returns the length of the resultant string or an error code if it will not fit into the target string. This is similar to strcpy, but it will enforce a maximum size for the copied string and will ensure it is terminated with a null.
- Parameters:
-
dest Pointer to a pointer that will hold the address of the allocated block. destMax Maximum size of the target string in characters. src String to copy. count Maximum count of characters to copy.
- Returns:
- Returns a reference to the destination if successful or NULL if the string won't fit.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, stok, supper, wallocHandle, wallocObject, wfreeHandle
Tokenize a string.
- Description:
- Split a string into tokens.
- Parameters:
-
str String to tokenize. delim String of characters to use as token separators. last Last token pointer.
- Returns:
- Returns a pointer to the next token.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, supper, wallocHandle, wallocObject, wfreeHandle
Convert a string to upper case.
- Description:
- Convert a string to its upper case equivalent.
- Parameters:
-
str String to convert. This string is modified.
- Returns:
- Returns a pointer to the converted string. Will always equal str.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, wallocHandle, wallocObject, wfreeHandle
Allocate a handle from a map.
- Parameters:
-
map Reference to a location holding the map reference. On the first call, the map is allocated.
- Returns:
- Integer handle index. Otherwise return -1 on allocation errors.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocObject, wfreeHandle
Allocate an object in a halloc map.
- Parameters:
-
map Reference to a location holding the map reference. On the first call, the map is allocated. max Reference to an integer that holds the maximum handle in the map. size Size of the object to allocate.
- Returns:
- Integer handle index. Otherwise return -1 on allocation errors.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wfreeHandle
Restart an event.
- Parameters:
-
id Event id allocated by websStartEvent. delay Delay in milliseconds till the event next runs.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Run due events.
- Returns:
- Time till the next event.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Start a callback event.
- Description:
- This schedules an event to run once. The event can be rescheduled in the callback by invoking websRestartEvent.
- Parameters:
-
delay Delay in milliseconds in which to run the callback. proc Callback procedure function. Signature is: void (*fn)(void *data, int id). data Data reference to pass to the callback.
- Returns:
- A positive integer event ID.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Stop an event.
- Parameters:
-
id Event id allocated by websStartEvent.
- Returns:
- Integer handle index. Otherwise return -1 on allocation errors.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Free a handle in the map.
- Parameters:
-
map Reference to a location to hold the map reference. handle Handle to free in the map.
- Returns:
- Integer handle index. Otherwise return -1 on allocation errors.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject
WebsSession
Session state storage.
- Fields:
-
WebsHash cache Cache of session variables. WebsTime expires When the session expires. char * id Session ID key. WebsTime lifespan Session inactivity timeout (msecs).
Test if a user possesses the required ability.
- Parameters:
-
wp Webs request object. id Session ID to use. Set to null to allocate a new session ID. lifespan Lifespan of the session in seconds.
- Returns:
- Allocated session object.
- See Also:
Get the session state object for the current request.
- Parameters:
-
wp Webs request object. create Set to true to create a new session if one does not already exist.
- Returns:
- Session object.
- See Also:
Get the session ID.
- Parameters:
-
wp Webs request object.
- Returns:
- The session ID if session state storage is defined for this request.
- See Also:
Get a session variable.
- Parameters:
-
wp Webs request object. name Session variable name. defaultValue Default value to return if the variable does not exist.
- Returns:
- Session variable value or default value if it does not exist.
- See Also:
Remove a session variable.
- Parameters:
-
wp Webs request object. name Session variable name.
- See Also:
Set a session variable name value.
- Parameters:
-
wp Webs request object. name Session variable name. value Value to set the variable to.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
WebsSocket
Socket control structure.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
- Fields:
-
SocketAccept accept Accept handler. int currentEvents Mask of ready events (FD_xx). int error Last error. int fileHandle ID of the file handler. int flags Current state flags. SocketHandler handler User I/O handler. void * handler_data User handler data. int handlerMask Handler events of interest. int interestEvents Mask of events to watch for. char * ip Server listen address or remote client address. WebsBuf lineBuf Line ring queue. int port Port to listen on. int saveMask saved Mask for socketFlush. int secure Socket is using SSL. int selectEvents Events being selected. int sid Index into socket[]. Socket sock Actual socket handle.
Extract the numerical IP address and port for the given socket info.
- Parameters:
-
addr Reference to the socket address. addrlen Length of the socket address. ipbuf Buffer to contain the parsed IP address. ipLen Size of ipbuf. port Reference to an integer to hold the parsed port.
- Returns:
- Zero if successful. Otherwise -1 for parse errors.
- See Also:
- socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Determine if an IP address is an IPv6 address.
- Parameters:
-
ip String IP address.
- Returns:
- True if the address is an IPv6 address.
- See Also:
- socketAddress, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Allocate a socket object.
- Parameters:
-
host String host IP address. port Socket port. accept Optional SocketAccept accept callback function. flags Control flags.
- Returns:
- Socket ID handle to use with other APIs.
- See Also:
- socketAddress, socketAddressIsV6, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Close the socket module.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Close a socket connection.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Connect to a server and create a new socket.
- Parameters:
-
host Host IP address. port Port number to connect to. flags Set to SOCKET_BLOCK for blocking I/O. Otherwise non-blocking I/O is used.
- Returns:
- True if the address is an IPv6 address.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Create a socket handler that will be invoked when I/O events occur.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. mask Mask of events of interest. Set to SOCKET_READABLE | SOCKET_WRITABLE | SOCKET_EXCEPTION. handler Socket handler function. arg Arbitrary object reference to pass to the SocketHandler callback function.
- Returns:
- True if the address is an IPv6 address.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Delete a socket handler created via socketCreateHandler.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Determine if the socket is at end-of-file for input.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- Returns:
- True if the address is at EOF.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Free (and close) the socket.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Get the current blocking mode.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- Returns:
- True if the socket is in blocking mode.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Get the error code for the last socket operation on this thread.
- Returns:
- Integer error code. See errno or GetLastError() on windows.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Get the underlying socket operating system socket/file handle.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- Returns:
- The socket handle.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Get the IP port associated with this socket.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- Returns:
- The TCP/IP port for this socket.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Indicate if the system has a dual IPv4 and IPv6 stack.
- Returns:
- True if IPv4 and IPv6 are supported on a single stack.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Indicate if the system has IPv6 support.
- Returns:
- True if IPv6 is supported on this system.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Indicate that the application layer has buffered data for the socket.
- Description:
- This is used by SSL and other network stacks that buffer pending data.
- Parameters:
-
sp Socket object returned from socketPtr len Length of buffered data in bytes. dir Buffer direction. Set to MPR_READABLE for buffered read data and MPR_WRITABLE for buffered write data.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Get a socket address structure for the specified IP:Port.
- Description:
- This returns address details in *family, *protocol, *addr, and *addrlen.
- Parameters:
-
ip IP address to parse. port TCP/IP port number. family Reference to an integer to hold the address family. protocol Reference to an integer to hold the address protocol. addr Reference to an integer to hold the address structure. addrlen Reference to an integer to hold the address structure length.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Determine if a socket is bound to an IPv6 address.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- Returns:
- True if the socket is using IPv6.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Open a listening socket.
- Parameters:
-
host Host IP address on which to listen. Set to NULL to listen on all interfaces. port TCP/IP port on which to listen. accept SocketAccept callback function to invoke to receive incoming connections. flags Reserved.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Open the socket module.
- Returns:
- Zerof if successful, otherwise -1.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Parse an IP address into its constituent parts.
- Description:
- Parse the IP address and return the IP address and port components. Handles ipv4 and ipv6 addresses. If the IP portion is absent, pip is set to null. If the port portion is absent, port is set to the defaultPort. If a ":</em>" port specifier is used, *pport is set to -1; When an address contains an ipv6 port it should be written as aaaa:bbbb:cccc:dddd:eeee:ffff:gggg:hhhh:iiii or If supplied an IPv6 address, the backets are stripped in the returned IP address.
- Parameters:
-
ipAddrPort IP address which may contain an optional ":port" component. pip Returns a reference to an allocated string containing the IP address portion. Caller must free. pport Reference to an integer to hold the port component. secure Reference to an integer to be set to true if the address is using SSL/TLS. defaultPort Default port number to use if no port specifier is included in ipAddrPort.
- Returns:
- Zero if successful, otherwise -1.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Process pending socket I/O events.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Return the socket object for the socket ID.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- Returns:
- Corresponding socket object.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Read data from a socket.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. buf Buffer to hold read data. len Size of the buffer.
- Returns:
- Count of bytes actually read. Returns -1 for errors and EOF. Distinguish between errors and EOF via socketEof()
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Register interest in socket I/OEvents.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. mask Mask of events of interest. Set to SOCKET_READABLE | SOCKET_WRITABLE | SOCKET_EXCEPTION.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Request that the socket be reserviced.
- Description:
- This routine is useful when upper layers have unprocessed, buffered data for the socket. This routine will cause the socket I/O callback handler to be invoked soon in the future.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Wait for I/O on a socket.
- Description:
- This call uses the mask of events of interest defined by socketRegisterInterest. It blocks the caller until a suitable I/O event or timeout occurs.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. timeout Timeout in milliseconds.
- Returns:
- Number of I/O events.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSetBlock, socketWaitForEvent, socketWrite
Set the socket blocking mode.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. on Set to 1 to enable blocking.
- Returns:
- The previous blocking mode.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketWaitForEvent, socketWrite
Set the socket delay mode.
- Description:
- This is used to enable or disable the TCP Nagle algorithm.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. on Set to 1 to disable the Nagle algorithm.
- Returns:
- The previous blocking mode.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Wait for a socket I/O event.
- Parameters:
-
sp Socket object. mask Mask of events of interest. Set to SOCKET_READABLE | SOCKET_WRITABLE | SOCKET_EXCEPTION.
- Returns:
- Zero if successful in waiting for the desired event, othewise return -1.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWrite
Write data to the socket.
- Parameters:
-
sid Socket ID handle returned from socketConnect or socketAccept. buf Buffer containing data to write. len Size of buf.
- Returns:
- Count of bytes written. May be less than len if the socket is in non-blocking mode. Returns -1 for errors.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent
WebsUpload
File upload structure.
- See Also:
- websGetUpload, websLookupUpload, websUploadOpen
- Fields:
-
char * clientFilename Client side name of the file. char * contentType Content type. char * filename Local (temp) name of the file. ssize size Uploaded file size.
Get the hash of uploaded files for the request.
- Parameters:
-
wp Webs request object.
- Returns:
- Hash table of uploaded files.
- See Also:
- websLookupUpload, websUploadOpen
Open the file upload filter.
- Parameters:
-
wp Webs request object. key Form upload name.
- Returns:
- Upload object for the uploaded file.
- See Also:
- websGetUpload, websUploadOpen
Open the file upload filter.
- See Also:
- websGetUpload, websLookupUpload
Functions
Assure that an assert condition is true.
- Parameters:
-
cond Boolean result of a conditional test.
Emit an error message.
- Returns:
- Zero if successful.
Close the log logging module.
Emit a message to the log.
- Description:
- This emits a message at the specified level. GoAhead filters logging messages by defining a verbosity level at startup. Level 0 is the least verbose where only the most important messages will be output. Level 9 is the Logging support is enabled by the Bit setting: "logging: true" which creates the BIT_GOAHEAD_LOGGING define in bit.h most verbose. Level 2-4 are the most useful for debugging.
- Parameters:
-
level Integer verbosity level (0-9). fmt Printf style format string. ... Arguments for the format string.
Open the log logging module.
- Returns:
- Zero if successful.
Set a log callback.
- Parameters:
-
handler Callback handler function of type WebsLogHandler.
- Returns:
- The previous callback function.
Set the filename to save logging output.
- Parameters:
-
path Filename path to use.
Trim a string.
- Description:
- Trim leading and trailing characters off a string.
- Parameters:
-
str String to trim. set String of characters to remove. where Flags to indicate trim from the start, end or both. Use WEBS_TRIM_START, WEBS_TRIM_END, WEBS_TRIM_BOTH.
- Returns:
- Returns a pointer to the trimmed string. May not equal str.
Emit a debug trace message to the log.
- Description:
- This emits a message at the specified level. GoAhead filters logging messages by defining a verbosity level at startup. Level 0 is the least verbose where only the most important messages will be output. Level 9 is the most verbose. Level 2-4 are the most useful for debugging. Debug trace support is enabled by the Bit setting: "tracing: true" which creates the BIT_GOAHEAD_TRACING define in bit.h.
- Parameters:
-
level Integer verbosity level (0-9). fmt Printf style format string. ... Arguments for the format string.
Free any allocated string in a value.
- Parameters:
-
value Value object.
Create an integer value.
- Parameters:
-
value Integer long value.
- Returns:
- Value object containing the integer.
Create an string value.
- Parameters:
-
value String long value. flags Set to VALUE_ALLOCATE to store a copy of the string reference.
- Returns:
- Value object containing the string.
Create an symbol value containing an object reference.
- Parameters:
-
value Value reference.
- Returns:
- Value object containing the symbol reference.
Define a background write I/O event callback.
- Parameters:
-
wp Webs request object. proc Write callback.
Typedefs
Hash table ID returned by hashCreate.
Callback for emitting trace log output.
- Parameters:
-
level Integer between 0 and 9. Zero is the lowest trace level used for the most important messages. msg Message to log.
- Returns:
- Zero if successful.
File status structure.
System native time type.
Callback for write I/O events.
Action callback.
- Parameters:
-
wp Webs request object.
- See Also:
Callback to prompt the user for their password.
- Parameters:
-
wp Webs request object.
- See Also:
GoAhead handler close to release memory prior to shutdown.
- Description:
- This callback is invoked when GoAhead is shutting down.
- See Also:
GoAhead handler service callback.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the handler serviced the request.
- See Also:
Javascript native function.
- Parameters:
-
jid JavaScript engine ID. wp Webs request object. argc Count of function arguments. argv Array of function arguments. defaultValue Default value to return if the variable is not defined.
- Returns:
- Return zero if successful, otherwise -1.
- See Also:
Callback to parse authentication details submitted with the web request.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the details can be parsed.
- See Also:
Callback to verify the username and password.
- Parameters:
-
wp Webs request object.
- Returns:
- True if the password is verified.
- See Also:
Callback function for events.
- Parameters:
-
data Opaque data argument. id Event ID.
- See Also:
- fmt, hextoi, itosbuf, scaselesscmp, scaselessmatch, sclone, scmp, scopy, sfmt, sfmtv, slen, slower, smatch, sncaselesscmp, sncmp, sncopy, stok, supper, wallocHandle, wallocObject, wfreeHandle
Socket accept callback.
- Parameters:
-
sid Socket ID handle for the newly accepted socket. ipaddr IP address of the connecting client. port Port of the connecting client. listenSid Socket ID for the listening socket.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Socket I/O callback.
- Parameters:
-
sid Socket ID handle returned from socketConnect or when a new socket is passed to a SocketAccept callback. mask Mask of events of interest. Set to SOCKET_READABLE | SOCKET_WRITABLE | SOCKET_EXCEPTION. data Data argument to pass to the callback function.
- See Also:
- socketAddress, socketAddressIsV6, socketAlloc, socketClose, socketCloseConnection, socketCreateHandler, socketEof, socketFree, socketGetBlock, socketGetError, socketGetHandle, socketGetPort, socketInfo, socketIsV6, socketListen, socketOpen, socketParseAddress, socketProcess, socketPtr, socketRead, socketRegisterInterest, socketReservice, socketSelect, socketSetBlock, socketWaitForEvent, socketWrite
Error code list.
- Fields:
-
int code HTTP error code. char * msg HTTP error message.
File information structure.
- Fields:
-
int isDir Set if directory. WebsTime mtime Modified time. ulong size File length.
GoAhead handler object.
- Fields:
-
WebsHandlerClose close Handler close callback. int flags Handler control flags. char * name Handler name. WebsHandlerProc service Handler service callback.
Mime type list.
- Fields:
-
char * ext File extension. char * type Mime type.
Role definition structure.
- Fields:
-
WebsHash abilities Resolved role abilities.
Compiled Rom Page Index.
- Fields:
-
uchar * page Web page data. char * path Web page URL path. Offset pos Current read position. int size Size of web page in bytes.
User definition structure.
- Fields:
-
WebsHash abilities Resolved user abilities. char * name User name. char * password User password (encrypted). char * roles User roles.
Value union to store primitive value types.
- Fields:
-