This module provides the EWSAPI module programmer with miscellaneous utility functions.
![]() |
The current implementation of EWSAPI is under review and feedback is welcomed. |
decode_base64(Base64String) -> ASCIIString
Base64String = ASCIIString = string()decode_base64/1 converts Base64String to the
plain ascii string (ASCIIString). The string
"BAD!" is returned if Base64String is not base64
encoded. Read more about base64 encoding in RFC 1521.
decode_hex(HexValue) -> DecValue
HexValue = DecValue = string()Converts the hexadecimal value HexValue into its
decimal equivalent (DecValue).
day(NthDayOfWeek) -> DayOfWeek
NthDayOfWeek = 1-7DayOfWeek = string()day/1 converts the day of the week
(NthDayOfWeek) as an integer (1-7) to an abbreviated
string, that is:
1 = "Mon", 2 = "Tue", ..., 7 = "Sat".
encode_base64(ASCIIString) -> Base64String
ASCIIString = string()Base64String = string()encode_base64 encodes a plain ascii string to a Base64 encoded string.
See RFC 1521 for a description of Base64 encoding.
header(StatusCode,Date)
header(StatusCode,MimeType,Date) -> HTTPHeader
StatusCode = integer()Date = rfc1123_date()MimeType = string()header returns a HTTP 1.0 header string. The
StatusCode is one of the status codes defined in RFC
1945 and the Date string is RFC 1123
compliant. (See rfc1123_date/0).
flatlength(NestedList) -> Size
NestedList = list()Size = integer()flatlength/1 computes the size of the possibly nested
list NestedList. Which may contain binaries.
key1search(TupleList,Key)
key1search(TupleList,Key,Undefined) -> Result
TupleList = [tuple()]Key = term()Result = term() | undefined | UndefinedUndefined = term()key1search searches the TupleList for a tuple
whose first element is Key. key1search/2
returns undefined and key1search/3 returns
Undefined if no tuple is found.
lookup(ETSTable,Key) -> Result
lookup(ETSTable,Key,Undefined) -> Result
ETSTable = ets_table()Key = term()Result = term() | undefined | UndefinedUndefined = term()lookup extracts {Key,Value} tuples from
ETSTable and returns the Value associated
with Key. If ETSTable is of type bag
only the first Value associated with Key is
returned. lookup/2 returns undefined and
lookup/3 returns Undefined if no Value
is found.
lookup_mime(ConfigDB,Suffix)
lookup_mime(ConfigDB,Suffix,Undefined) -> MimeType
ConfigDB = ets_table()Suffix = string()MimeType = string() | undefined | UndefinedUndefined = term()lookup_mime returns the mime type associated with a
specific file suffix as specified in the mime.types
file (located in the config directory (UNIX: $SERVER_ROOT/conf/mime.types, Windows: %SERVER_ROOT%\conf\mime.types)).
lookup_mime_default(ConfigDB,Suffix)
lookup_mime_default(ConfigDB,Suffix,Undefined) -> MimeType
ConfigDB = ets_table()Suffix = string()MimeType = string() | undefined | UndefinedUndefined = term()lookup_mime_default returns the mime type associated
with a specific file suffix as specified in the
mime.types file (located in the
config
directory (UNIX: $SERVER_ROOT/conf/mime.types, Windows: %SERVER_ROOT%\conf\mime.types)). If no appropriate association can be found
the value of
DefaultType is
returned.
message(StatusCode,PhraseArgs,ConfigDB) -> Message
StatusCode = 301 | 400 | 403 | 404 | 500 | 501 | 504PhraseArgs = term()ConfigDB = ets_tableMessage = string()message/3 returns an informative HTTP 1.0 status
string in HTML. Each StatusCode requires a specific
PhraseArgs:
301
string(): A URL pointing at the new document
position.
400 | 401 | 500
none (No PhraseArgs)
403 | 404
string(): A Request-URI as described in
RFC 1945.
501
{Method,RequestURI,HTTPVersion}: The HTTP
Method, Request-URI and HTTP-Version
as defined in RFC 1945.
504
string(): A string describing why the service
was unavailable.
NthMonth = 1-12Month = string()month/1 converts the month NthMonth as an
integer (1-12) to an abbreviated string, that is:
1 = "Jan", 2 = "Feb", ..., 12 = "Dec".
multi_lookup(ETSTable,Key) -> Result
ETSTable = ets_table()Key = term()Result = [term()]multi_lookup extracts all {Key,Value} tuples
from an ETSTable and returns all
Values associated with the Key in a list.
reason_phrase(StatusCode) -> Description
StatusCode = 200 | 201 | 204 | 301 | 302 | 304 | 400 | 401
| 403 | 404 | 500 | 501 | 502 | 504Description = string()reason_phrase returns the Description of an
HTTP 1.0 StatusCode, for example 200 is "OK" and 201
is "Created". Read RFC 1945 for further information.
RFC1123Date = string()rfc1123_date/0 returns the current date in RFC 1123
format.
split(String,RegExp,N) -> SplitRes
String = RegExp = string()SplitRes = {ok, FieldList} | {error, errordesc()}Fieldlist = [string()]N = integersplit/3 splits the String in N chunks
using the RegExp. split/3 is is equivalent to
regexp:split/2 with one exception, that is N
defines the number of maximum number of fields in the
FieldList.
split_script_path(RequestLine) -> Splitted
RequestLine = string()Splitted = not_a_script | {Path, PathInfo, QueryString}Path = QueryString = PathInfo = string()split_script_path/1 is equivalent to
split_path/1 with one exception. If the longest
possible path is not a regular, accessible and executable
file not_a_script is returned.
split_path(RequestLine) -> {Path,QueryStringOrPathInfo}
RequestLine = Path = QueryStringOrPathInfo = string()split_path/1 splits the RequestLine in a file
reference (Path) and a QueryString or a
PathInfo string as specified in RFC 1945. A
QueryString is isolated from the Path with a
question mark (?) and PathInfo with a slash
(/). In the case of a QueryString, everything before
the ? is a Path and everything after a
QueryString. In the case of a PathInfo the
RequestLine is scanned from left-to-right on the hunt
for longest possible Path being a file or a
directory. Everything after the longest possible
Path, isolated with a /, is regarded as
PathInfo. The resulting Path is decoded using
decode_hex/1 before delivery.
FileName = Suffix = string()suffix/1 is equivalent to
filename:extension/1 with one exception, that is
Suffix is returned without a leading dot (.).
to_lower(String) -> ConvertedString
String = ConvertedString = string()to_lower/1 converts upper-case letters to
lower-case.
to_upper(String) -> ConvertedString
String = ConvertedString = string()to_upper/1 converts lower-case letters to
upper-case.