diff options
-rw-r--r-- | StdLib/BsdSocketLib/ns_print.c | 1278 | ||||
-rw-r--r-- | StdLib/BsdSocketLib/res_debug.c | 2 | ||||
-rw-r--r-- | StdLib/EfiSocketLib/Socket.c | 176 | ||||
-rw-r--r-- | StdLib/Include/errno.h | 3 | ||||
-rw-r--r-- | StdLib/Include/sys/EfiCdefs.h | 6 | ||||
-rw-r--r-- | StdLib/Include/sys/errno.h | 3 | ||||
-rw-r--r-- | StdLib/Include/sys/fcntl.h | 4 | ||||
-rw-r--r-- | StdLib/Include/sys/stat.h | 39 | ||||
-rw-r--r-- | StdLib/Include/wchar.h | 4 | ||||
-rw-r--r-- | StdLib/Include/x86/float.h | 24 | ||||
-rw-r--r-- | StdLib/LibC/Containers/Queues/Fifo.c | 92 | ||||
-rw-r--r-- | StdLib/LibC/StdLib/realpath.c | 26 |
12 files changed, 835 insertions, 822 deletions
diff --git a/StdLib/BsdSocketLib/ns_print.c b/StdLib/BsdSocketLib/ns_print.c index a5d8ad3d7d..60ea89775f 100644 --- a/StdLib/BsdSocketLib/ns_print.c +++ b/StdLib/BsdSocketLib/ns_print.c @@ -16,31 +16,31 @@ */
/*
- * Portions copyright (c) 1999, 2000
+ * Portions copyright (c) 1999, 2000 - 2014
* Intel Corporation.
* All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
- *
+ *
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
- *
+ *
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
- *
+ *
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
- *
+ *
* This product includes software developed by Intel Corporation and
* its contributors.
- *
+ *
* 4. Neither the name of Intel Corporation or its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION AND CONTRIBUTORS ``AS IS''
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -52,7 +52,7 @@ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
- *
+ *
*/
/* Import. */
@@ -74,545 +74,545 @@ /* Forward. */
-static size_t prune_origin(const char *name, const char *origin);
-static int charstr(const u_char *rdata, const u_char *edata,
- char **buf, size_t *buflen);
-static int addname(const u_char *msg, size_t msglen,
- const u_char **p, const char *origin,
- char **buf, size_t *buflen);
-static void addlen(size_t len, char **buf, size_t *buflen);
-static int addstr(const char *src, size_t len,
- char **buf, size_t *buflen);
-static int addtab(size_t len, size_t target, int spaced,
- char **buf, size_t *buflen);
+static size_t prune_origin(const char *name, const char *origin);
+static int charstr(const u_char *rdata, const u_char *edata,
+ char **buf, size_t *buflen);
+static int addname(const u_char *msg, size_t msglen,
+ const u_char **p, const char *origin,
+ char **buf, size_t *buflen);
+static void addlen(size_t len, char **buf, size_t *buflen);
+static int addstr(const char *src, size_t len,
+ char **buf, size_t *buflen);
+static int addtab(size_t len, size_t target, int spaced,
+ char **buf, size_t *buflen);
/* Macros. */
-#define T(x) \
- do { \
- if ((ssize_t)(x) < 0) \
- return (-1); \
- } while (0)
+#define T(x) \
+ do { \
+ if ((ssize_t)(x) < 0) \
+ return (-1); \
+ } while (0)
/* Public. */
/*
* int
* ns_sprintrr(handle, rr, name_ctx, origin, buf, buflen)
- * Convert an RR to presentation format.
+ * Convert an RR to presentation format.
* return:
- * Number of characters written to buf, or -1 (check errno).
+ * Number of characters written to buf, or -1 (check errno).
*/
int
ns_sprintrr(const ns_msg *handle, const ns_rr *rr,
- const char *name_ctx, const char *origin,
- char *buf, size_t buflen)
+ const char *name_ctx, const char *origin,
+ char *buf, size_t buflen)
{
- int n;
+ int n;
- n = ns_sprintrrf(ns_msg_base(*handle), ns_msg_size(*handle),
- ns_rr_name(*rr), ns_rr_class(*rr), ns_rr_type(*rr),
- ns_rr_ttl(*rr), ns_rr_rdata(*rr), ns_rr_rdlen(*rr),
- name_ctx, origin, buf, buflen);
- return (n);
+ n = ns_sprintrrf(ns_msg_base(*handle), ns_msg_size(*handle),
+ ns_rr_name(*rr), ns_rr_class(*rr), ns_rr_type(*rr),
+ ns_rr_ttl(*rr), ns_rr_rdata(*rr), ns_rr_rdlen(*rr),
+ name_ctx, origin, buf, buflen);
+ return (n);
}
/*
* int
* ns_sprintrrf(msg, msglen, name, class, type, ttl, rdata, rdlen,
- * name_ctx, origin, buf, buflen)
- * Convert the fields of an RR into presentation format.
+ * name_ctx, origin, buf, buflen)
+ * Convert the fields of an RR into presentation format.
* return:
- * Number of characters written to buf, or -1 (check errno).
+ * Number of characters written to buf, or -1 (check errno).
*/
int
ns_sprintrrf(const u_char *msg, size_t msglen,
- const char *name, ns_class class, ns_type type,
- u_long ttl, const u_char *rdata, size_t rdlen,
- const char *name_ctx, const char *origin,
- char *buf, size_t buflen)
+ const char *name, ns_class class, ns_type type,
+ u_long ttl, const u_char *rdata, size_t rdlen,
+ const char *name_ctx, const char *origin,
+ char *buf, size_t buflen)
{
- const char *obuf = buf;
- const u_char *edata = rdata + rdlen;
- int spaced = 0;
-
- const char *comment;
- char tmp[100];
- int x;
- size_t len;
-
- static char base64_key[NS_MD5RSA_MAX_BASE64];
- static char t[255*3];
-
- /*
- * Owner.
- */
- if (name_ctx != NULL && strcasecmp(name_ctx, name) == 0) {
- T(addstr("\t\t\t", 3, &buf, &buflen));
- } else {
- len = prune_origin(name, origin);
- if (len == 0) {
- T(addstr("@\t\t\t", 4, &buf, &buflen));
- } else {
- T(addstr(name, len, &buf, &buflen));
- /* Origin not used and no trailing dot? */
- if ((!origin || !origin[0] || name[len] == '\0') &&
- name[len - 1] != '.') {
- T(addstr(".", 1, &buf, &buflen));
- len++;
- }
- T(spaced = addtab(len, 24, spaced, &buf, &buflen));
- }
- }
-
- /*
- * TTL, Class, Type.
- */
- T(x = ns_format_ttl(ttl, buf, buflen));
- addlen(x, &buf, &buflen);
- len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type)));
- T(addstr(tmp, len, &buf, &buflen));
- T(spaced = addtab(x + len, 16, spaced, &buf, &buflen));
-
- /*
- * RData.
- */
- switch (type) {
- case ns_t_a:
- if (rdlen != NS_INADDRSZ)
- goto formerr;
- (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen);
- addlen(strlen(buf), &buf, &buflen);
- break;
-
- case ns_t_cname:
- case ns_t_mb:
- case ns_t_mg:
- case ns_t_mr:
- case ns_t_ns:
- case ns_t_ptr:
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- break;
-
- case ns_t_hinfo:
- case ns_t_isdn:
- /* First word. */
- T(len = charstr(rdata, edata, &buf, &buflen));
- if (len == 0)
- goto formerr;
- rdata += len;
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Second word. */
- T(len = charstr(rdata, edata, &buf, &buflen));
- if (len == 0)
- goto formerr;
- rdata += len;
- break;
-
- case ns_t_soa: {
- u_long t;
-
- /* Server name. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Administrator name. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- T(addstr(" (\n", 3, &buf, &buflen));
- spaced = 0;
-
- if ((edata - rdata) != 5*NS_INT32SZ)
- goto formerr;
-
- /* Serial number. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
- len = SPRINTF((tmp, "%Lu", t));
- T(addstr(tmp, len, &buf, &buflen));
- T(spaced = addtab(len, 16, spaced, &buf, &buflen));
- T(addstr("; serial\n", 9, &buf, &buflen));
- spaced = 0;
-
- /* Refresh interval. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
- T(len = ns_format_ttl(t, buf, buflen));
- addlen(len, &buf, &buflen);
- T(spaced = addtab(len, 16, spaced, &buf, &buflen));
- T(addstr("; refresh\n", 10, &buf, &buflen));
- spaced = 0;
-
- /* Retry interval. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
- T(len = ns_format_ttl(t, buf, buflen));
- addlen(len, &buf, &buflen);
- T(spaced = addtab(len, 16, spaced, &buf, &buflen));
- T(addstr("; retry\n", 8, &buf, &buflen));
- spaced = 0;
-
- /* Expiry. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
- T(len = ns_format_ttl(t, buf, buflen));
- addlen(len, &buf, &buflen);
- T(spaced = addtab(len, 16, spaced, &buf, &buflen));
- T(addstr("; expiry\n", 9, &buf, &buflen));
- spaced = 0;
-
- /* Minimum TTL. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
- T(len = ns_format_ttl(t, buf, buflen));
- addlen(len, &buf, &buflen);
- T(addstr(" )", 2, &buf, &buflen));
- T(spaced = addtab(len, 16, spaced, &buf, &buflen));
- T(addstr("; minimum\n", 10, &buf, &buflen));
-
- break;
- }
-
- case ns_t_mx:
- case ns_t_afsdb:
- case ns_t_rt: {
- u_int t;
-
- if (rdlen < NS_INT16SZ)
- goto formerr;
-
- /* Priority. */
- t = ns_get16(rdata);
- rdata += NS_INT16SZ;
- len = SPRINTF((tmp, "%u ", (unsigned int)t));
- T(addstr(tmp, len, &buf, &buflen));
-
- /* Target. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
-
- break;
- }
-
- case ns_t_px: {
- u_int t;
-
- if (rdlen < NS_INT16SZ)
- goto formerr;
-
- /* Priority. */
- t = ns_get16(rdata);
- rdata += NS_INT16SZ;
- len = SPRINTF((tmp, "%u ", (unsigned int)t));
- T(addstr(tmp, len, &buf, &buflen));
-
- /* Name1. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Name2. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
-
- break;
- }
-
- case ns_t_x25:
- T(len = charstr(rdata, edata, &buf, &buflen));
- if (len == 0)
- goto formerr;
- rdata += len;
- break;
-
- case ns_t_txt:
- while (rdata < edata) {
- T(len = charstr(rdata, edata, &buf, &buflen));
- if (len == 0)
- goto formerr;
- rdata += len;
- if (rdata < edata)
- T(addstr(" ", 1, &buf, &buflen));
- }
- break;
-
- case ns_t_nsap: {
-
- (void) inet_nsap_ntoa((int)rdlen, rdata, t);
- T(addstr(t, strlen(t), &buf, &buflen));
- break;
- }
-
- case ns_t_aaaa:
- if (rdlen != NS_IN6ADDRSZ)
- goto formerr;
- (void) inet_ntop(AF_INET6, rdata, buf, (socklen_t)buflen);
- addlen(strlen(buf), &buf, &buflen);
- break;
-
- case ns_t_loc: {
- /* XXX protocol format checking? */
- (void) loc_ntoa(rdata, t);
- T(addstr(t, strlen(t), &buf, &buflen));
- break;
- }
-
- case ns_t_naptr: {
- u_int order, preference;
-
- if (rdlen < 2*NS_INT16SZ)
- goto formerr;
-
- /* Order, Precedence. */
- order = ns_get16(rdata); rdata += NS_INT16SZ;
- preference = ns_get16(rdata); rdata += NS_INT16SZ;
- len = SPRINTF((t, "%u %u ", (unsigned int)order, (unsigned int)preference));
- T(addstr(t, len, &buf, &buflen));
-
- /* Flags. */
- T(len = charstr(rdata, edata, &buf, &buflen));
- if (len == 0)
- goto formerr;
- rdata += len;
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Service. */
- T(len = charstr(rdata, edata, &buf, &buflen));
- if (len == 0)
- goto formerr;
- rdata += len;
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Regexp. */
- T(len = charstr(rdata, edata, &buf, &buflen));
- if ((ssize_t)len < 0)
- return (-1);
- if (len == 0)
- goto formerr;
- rdata += len;
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Server. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- break;
- }
-
- case ns_t_srv: {
- u_int priority, weight, port;
-
- if (rdlen < NS_INT16SZ*3)
- goto formerr;
-
- /* Priority, Weight, Port. */
- priority = ns_get16(rdata); rdata += NS_INT16SZ;
- weight = ns_get16(rdata); rdata += NS_INT16SZ;
- port = ns_get16(rdata); rdata += NS_INT16SZ;
- len = SPRINTF((t, "%u %u %u ", (unsigned int)priority, (unsigned int)weight, (unsigned int)port));
- T(addstr(t, len, &buf, &buflen));
-
- /* Server. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- break;
- }
-
- case ns_t_minfo:
- case ns_t_rp:
- /* Name1. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
- T(addstr(" ", 1, &buf, &buflen));
-
- /* Name2. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
-
- break;
-
- case ns_t_wks: {
- int n, lcnt;
-
- if (rdlen < NS_INT32SZ + 1)
- goto formerr;
-
- /* Address. */
- (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen);
- addlen(strlen(buf), &buf, &buflen);
- rdata += NS_INADDRSZ;
-
- /* Protocol. */
- len = SPRINTF((tmp, " %u ( ", *rdata));
- T(addstr(tmp, len, &buf, &buflen));
- rdata += NS_INT8SZ;
-
- /* Bit map. */
- n = 0;
- lcnt = 0;
- while (rdata < edata) {
- u_int c = *rdata++;
- do {
- if (c & 0200) {
- if (lcnt == 0) {
- T(addstr("\n\t\t\t\t", 5,
- &buf, &buflen));
- lcnt = 10;
- spaced = 0;
- }
- len = SPRINTF((tmp, "%d ", n));
- T(addstr(tmp, len, &buf, &buflen));
- lcnt--;
- }
- c <<= 1;
- } while (++n & 07);
- }
- T(addstr(")", 1, &buf, &buflen));
-
- break;
- }
-
- case ns_t_key: {
- u_int keyflags, protocol, algorithm;
- const char *leader;
- int n;
-
- if (rdlen < NS_INT16SZ + NS_INT8SZ + NS_INT8SZ)
- goto formerr;
-
- /* Key flags, Protocol, Algorithm. */
- keyflags = ns_get16(rdata); rdata += NS_INT16SZ;
- protocol = *rdata++;
- algorithm = *rdata++;
- len = SPRINTF((tmp, "0x%04x %u %u",
- (unsigned int)keyflags, (unsigned int)protocol, (unsigned int)algorithm));
- T(addstr(tmp, len, &buf, &buflen));
-
- /* Public key data. */
- len = b64_ntop(rdata, edata - rdata,
- base64_key, sizeof base64_key);
- if ((ssize_t)len < 0)
- goto formerr;
- if (len > 15) {
- T(addstr(" (", 2, &buf, &buflen));
- leader = "\n\t\t";
- spaced = 0;
- } else
- leader = " ";
- for (n = 0; n < (int)len; n += 48) {
- T(addstr(leader, strlen(leader), &buf, &buflen));
- T(addstr(base64_key + n, MIN(len - n, 48),
- &buf, &buflen));
- }
- if (len > 15)
- T(addstr(" )", 2, &buf, &buflen));
-
- break;
- }
-
- case ns_t_sig: {
- u_int type, algorithm, labels, footprint;
- const char *leader;
- u_long t;
- int n;
-
- if (rdlen < 22)
- goto formerr;
-
- /* Type covered, Algorithm, Label count, Original TTL. */
- type = ns_get16(rdata); rdata += NS_INT16SZ;
- algorithm = *rdata++;
- labels = *rdata++;
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- len = SPRINTF((tmp, " %s %d %Lu ",
- p_type((int)type), (int)algorithm, t));
- T(addstr(tmp, len, &buf, &buflen));
- if (labels != (u_int)dn_count_labels(name))
- goto formerr;
-
- /* Signature expiry. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- len = SPRINTF((tmp, "%s ", p_secstodate(t)));
- T(addstr(tmp, len, &buf, &buflen));
-
- /* Time signed. */
- t = ns_get32(rdata); rdata += NS_INT32SZ;
- len = SPRINTF((tmp, "%s ", p_secstodate(t)));
- T(addstr(tmp, len, &buf, &buflen));
-
- /* Signature Footprint. */
- footprint = ns_get16(rdata); rdata += NS_INT16SZ;
- len = SPRINTF((tmp, "%u ", (unsigned int)footprint));
- T(addstr(tmp, len, &buf, &buflen));
-
- /* Signer's name. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
-
- /* Signature. */
- len = b64_ntop(rdata, edata - rdata,
- base64_key, sizeof base64_key);
- if (len > 15) {
- T(addstr(" (", 2, &buf, &buflen));
- leader = "\n\t\t";
- spaced = 0;
- } else
- leader = " ";
- if ((ssize_t)len < 0)
- goto formerr;
- for (n = 0; n < (int)len; n += 48) {
- T(addstr(leader, strlen(leader), &buf, &buflen));
- T(addstr(base64_key + n, MIN(len - n, 48),
- &buf, &buflen));
- }
- if (len > 15)
- T(addstr(" )", 2, &buf, &buflen));
-
- break;
- }
-
- case ns_t_nxt: {
- int n, c;
-
- /* Next domain name. */
- T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
-
- /* Type bit map. */
- n = (int)(edata - rdata);
- for (c = 0; c < n*8; c++)
- if (NS_NXT_BIT_ISSET(c, rdata)) {
- len = SPRINTF((tmp, " %s", p_type(c)));
- T(addstr(tmp, len, &buf, &buflen));
- }
- break;
- }
-
- default:
- comment = "unknown RR type";
- goto hexify;
- }
- return ((int)(buf - obuf));
+ const char *obuf = buf;
+ const u_char *edata = rdata + rdlen;
+ int spaced = 0;
+
+ const char *comment;
+ char tmp[100];
+ int x;
+ size_t len;
+
+ static char base64_key[NS_MD5RSA_MAX_BASE64];
+ static char t[255*3];
+
+ /*
+ * Owner.
+ */
+ if (name_ctx != NULL && strcasecmp(name_ctx, name) == 0) {
+ T(addstr("\t\t\t", 3, &buf, &buflen));
+ } else {
+ len = prune_origin(name, origin);
+ if (len == 0) {
+ T(addstr("@\t\t\t", 4, &buf, &buflen));
+ } else {
+ T(addstr(name, len, &buf, &buflen));
+ /* Origin not used and no trailing dot? */
+ if ((!origin || !origin[0] || name[len] == '\0') &&
+ name[len - 1] != '.') {
+ T(addstr(".", 1, &buf, &buflen));
+ len++;
+ }
+ T(spaced = addtab(len, 24, spaced, &buf, &buflen));
+ }
+ }
+
+ /*
+ * TTL, Class, Type.
+ */
+ T(x = ns_format_ttl(ttl, buf, buflen));
+ addlen(x, &buf, &buflen);
+ len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type)));
+ T(addstr(tmp, len, &buf, &buflen));
+ T(spaced = addtab(x + len, 16, spaced, &buf, &buflen));
+
+ /*
+ * RData.
+ */
+ switch (type) {
+ case ns_t_a:
+ if (rdlen != NS_INADDRSZ)
+ goto formerr;
+ (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen);
+ addlen(strlen(buf), &buf, &buflen);
+ break;
+
+ case ns_t_cname:
+ case ns_t_mb:
+ case ns_t_mg:
+ case ns_t_mr:
+ case ns_t_ns:
+ case ns_t_ptr:
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ break;
+
+ case ns_t_hinfo:
+ case ns_t_isdn:
+ /* First word. */
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Second word. */
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ break;
+
+ case ns_t_soa: {
+ u_long t;
+
+ /* Server name. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Administrator name. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ T(addstr(" (\n", 3, &buf, &buflen));
+ spaced = 0;
+
+ if ((edata - rdata) != 5*NS_INT32SZ)
+ goto formerr;
+
+ /* Serial number. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
+ len = SPRINTF((tmp, "%lu", t));
+ T(addstr(tmp, len, &buf, &buflen));
+ T(spaced = addtab(len, 16, spaced, &buf, &buflen));
+ T(addstr("; serial\n", 9, &buf, &buflen));
+ spaced = 0;
+
+ /* Refresh interval. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
+ T(len = ns_format_ttl(t, buf, buflen));
+ addlen(len, &buf, &buflen);
+ T(spaced = addtab(len, 16, spaced, &buf, &buflen));
+ T(addstr("; refresh\n", 10, &buf, &buflen));
+ spaced = 0;
+
+ /* Retry interval. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
+ T(len = ns_format_ttl(t, buf, buflen));
+ addlen(len, &buf, &buflen);
+ T(spaced = addtab(len, 16, spaced, &buf, &buflen));
+ T(addstr("; retry\n", 8, &buf, &buflen));
+ spaced = 0;
+
+ /* Expiry. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
+ T(len = ns_format_ttl(t, buf, buflen));
+ addlen(len, &buf, &buflen);
+ T(spaced = addtab(len, 16, spaced, &buf, &buflen));
+ T(addstr("; expiry\n", 9, &buf, &buflen));
+ spaced = 0;
+
+ /* Minimum TTL. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ T(addstr("\t\t\t\t\t", 5, &buf, &buflen));
+ T(len = ns_format_ttl(t, buf, buflen));
+ addlen(len, &buf, &buflen);
+ T(addstr(" )", 2, &buf, &buflen));
+ T(spaced = addtab(len, 16, spaced, &buf, &buflen));
+ T(addstr("; minimum\n", 10, &buf, &buflen));
+
+ break;
+ }
+
+ case ns_t_mx:
+ case ns_t_afsdb:
+ case ns_t_rt: {
+ u_int t;
+
+ if (rdlen < NS_INT16SZ)
+ goto formerr;
+
+ /* Priority. */
+ t = ns_get16(rdata);
+ rdata += NS_INT16SZ;
+ len = SPRINTF((tmp, "%u ", (unsigned int)t));
+ T(addstr(tmp, len, &buf, &buflen));
+
+ /* Target. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+
+ break;
+ }
+
+ case ns_t_px: {
+ u_int t;
+
+ if (rdlen < NS_INT16SZ)
+ goto formerr;
+
+ /* Priority. */
+ t = ns_get16(rdata);
+ rdata += NS_INT16SZ;
+ len = SPRINTF((tmp, "%u ", (unsigned int)t));
+ T(addstr(tmp, len, &buf, &buflen));
+
+ /* Name1. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Name2. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+
+ break;
+ }
+
+ case ns_t_x25:
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ break;
+
+ case ns_t_txt:
+ while (rdata < edata) {
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ if (rdata < edata)
+ T(addstr(" ", 1, &buf, &buflen));
+ }
+ break;
+
+ case ns_t_nsap: {
+
+ (void) inet_nsap_ntoa((int)rdlen, rdata, t);
+ T(addstr(t, strlen(t), &buf, &buflen));
+ break;
+ }
+
+ case ns_t_aaaa:
+ if (rdlen != NS_IN6ADDRSZ)
+ goto formerr;
+ (void) inet_ntop(AF_INET6, rdata, buf, (socklen_t)buflen);
+ addlen(strlen(buf), &buf, &buflen);
+ break;
+
+ case ns_t_loc: {
+ /* XXX protocol format checking? */
+ (void) loc_ntoa(rdata, t);
+ T(addstr(t, strlen(t), &buf, &buflen));
+ break;
+ }
+
+ case ns_t_naptr: {
+ u_int order, preference;
+
+ if (rdlen < 2*NS_INT16SZ)
+ goto formerr;
+
+ /* Order, Precedence. */
+ order = ns_get16(rdata); rdata += NS_INT16SZ;
+ preference = ns_get16(rdata); rdata += NS_INT16SZ;
+ len = SPRINTF((t, "%u %u ", (unsigned int)order, (unsigned int)preference));
+ T(addstr(t, len, &buf, &buflen));
+
+ /* Flags. */
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Service. */
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Regexp. */
+ T(len = charstr(rdata, edata, &buf, &buflen));
+ if ((ssize_t)len < 0)
+ return (-1);
+ if (len == 0)
+ goto formerr;
+ rdata += len;
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Server. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ break;
+ }
+
+ case ns_t_srv: {
+ u_int priority, weight, port;
+
+ if (rdlen < NS_INT16SZ*3)
+ goto formerr;
+
+ /* Priority, Weight, Port. */
+ priority = ns_get16(rdata); rdata += NS_INT16SZ;
+ weight = ns_get16(rdata); rdata += NS_INT16SZ;
+ port = ns_get16(rdata); rdata += NS_INT16SZ;
+ len = SPRINTF((t, "%u %u %u ", (unsigned int)priority, (unsigned int)weight, (unsigned int)port));
+ T(addstr(t, len, &buf, &buflen));
+
+ /* Server. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ break;
+ }
+
+ case ns_t_minfo:
+ case ns_t_rp:
+ /* Name1. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+ T(addstr(" ", 1, &buf, &buflen));
+
+ /* Name2. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+
+ break;
+
+ case ns_t_wks: {
+ int n, lcnt;
+
+ if (rdlen < NS_INT32SZ + 1)
+ goto formerr;
+
+ /* Address. */
+ (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen);
+ addlen(strlen(buf), &buf, &buflen);
+ rdata += NS_INADDRSZ;
+
+ /* Protocol. */
+ len = SPRINTF((tmp, " %u ( ", (unsigned int)*rdata));
+ T(addstr(tmp, len, &buf, &buflen));
+ rdata += NS_INT8SZ;
+
+ /* Bit map. */
+ n = 0;
+ lcnt = 0;
+ while (rdata < edata) {
+ u_int c = *rdata++;
+ do {
+ if (c & 0200) {
+ if (lcnt == 0) {
+ T(addstr("\n\t\t\t\t", 5,
+ &buf, &buflen));
+ lcnt = 10;
+ spaced = 0;
+ }
+ len = SPRINTF((tmp, "%d ", n));
+ T(addstr(tmp, len, &buf, &buflen));
+ lcnt--;
+ }
+ c <<= 1;
+ } while (++n & 07);
+ }
+ T(addstr(")", 1, &buf, &buflen));
+
+ break;
+ }
+
+ case ns_t_key: {
+ u_int keyflags, protocol, algorithm;
+ const char *leader;
+ int n;
+
+ if (rdlen < NS_INT16SZ + NS_INT8SZ + NS_INT8SZ)
+ goto formerr;
+
+ /* Key flags, Protocol, Algorithm. */
+ keyflags = ns_get16(rdata); rdata += NS_INT16SZ;
+ protocol = *rdata++;
+ algorithm = *rdata++;
+ len = SPRINTF((tmp, "0x%04x %u %u",
+ (unsigned int)keyflags, (unsigned int)protocol, (unsigned int)algorithm));
+ T(addstr(tmp, len, &buf, &buflen));
+
+ /* Public key data. */
+ len = b64_ntop(rdata, edata - rdata,
+ base64_key, sizeof base64_key);
+ if ((ssize_t)len < 0)
+ goto formerr;
+ if (len > 15) {
+ T(addstr(" (", 2, &buf, &buflen));
+ leader = "\n\t\t";
+ spaced = 0;
+ } else
+ leader = " ";
+ for (n = 0; n < (int)len; n += 48) {
+ T(addstr(leader, strlen(leader), &buf, &buflen));
+ T(addstr(base64_key + n, MIN(len - n, 48),
+ &buf, &buflen));
+ }
+ if (len > 15)
+ T(addstr(" )", 2, &buf, &buflen));
+
+ break;
+ }
+
+ case ns_t_sig: {
+ u_int type, algorithm, labels, footprint;
+ const char *leader;
+ u_long t;
+ int n;
+
+ if (rdlen < 22)
+ goto formerr;
+
+ /* Type covered, Algorithm, Label count, Original TTL. */
+ type = ns_get16(rdata); rdata += NS_INT16SZ;
+ algorithm = *rdata++;
+ labels = *rdata++;
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ len = SPRINTF((tmp, " %s %d %lu ",
+ p_type((int)type), (int)algorithm, t));
+ T(addstr(tmp, len, &buf, &buflen));
+ if (labels != (u_int)dn_count_labels(name))
+ goto formerr;
+
+ /* Signature expiry. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ len = SPRINTF((tmp, "%s ", p_secstodate(t)));
+ T(addstr(tmp, len, &buf, &buflen));
+
+ /* Time signed. */
+ t = ns_get32(rdata); rdata += NS_INT32SZ;
+ len = SPRINTF((tmp, "%s ", p_secstodate(t)));
+ T(addstr(tmp, len, &buf, &buflen));
+
+ /* Signature Footprint. */
+ footprint = ns_get16(rdata); rdata += NS_INT16SZ;
+ len = SPRINTF((tmp, "%u ", (unsigned int)footprint));
+ T(addstr(tmp, len, &buf, &buflen));
+
+ /* Signer's name. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+
+ /* Signature. */
+ len = b64_ntop(rdata, edata - rdata,
+ base64_key, sizeof base64_key);
+ if (len > 15) {
+ T(addstr(" (", 2, &buf, &buflen));
+ leader = "\n\t\t";
+ spaced = 0;
+ } else
+ leader = " ";
+ if ((ssize_t)len < 0)
+ goto formerr;
+ for (n = 0; n < (int)len; n += 48) {
+ T(addstr(leader, strlen(leader), &buf, &buflen));
+ T(addstr(base64_key + n, MIN(len - n, 48),
+ &buf, &buflen));
+ }
+ if (len > 15)
+ T(addstr(" )", 2, &buf, &buflen));
+
+ break;
+ }
+
+ case ns_t_nxt: {
+ int n, c;
+
+ /* Next domain name. */
+ T(addname(msg, msglen, &rdata, origin, &buf, &buflen));
+
+ /* Type bit map. */
+ n = (int)(edata - rdata);
+ for (c = 0; c < n*8; c++)
+ if (NS_NXT_BIT_ISSET(c, rdata)) {
+ len = SPRINTF((tmp, " %s", p_type(c)));
+ T(addstr(tmp, len, &buf, &buflen));
+ }
+ break;
+ }
+
+ default:
+ comment = "unknown RR type";
+ goto hexify;
+ }
+ return ((int)(buf - obuf));
formerr:
- comment = "RR format error";
+ comment = "RR format error";
hexify: {
- int n, m;
- char *p;
-
- len = SPRINTF((tmp, "\\#(\t\t; %s", comment));
- T(addstr(tmp, len, &buf, &buflen));
- while (rdata < edata) {
- p = tmp;
- p += SPRINTF((p, "\n\t"));
- spaced = 0;
- n = MIN(16, (int)(edata - rdata));
- for (m = 0; m < n; m++)
- p += SPRINTF((p, "%02x ", rdata[m]));
- T(addstr(tmp, (u_int)(p - tmp), &buf, &buflen));
- if (n < 16) {
- T(addstr(")", 1, &buf, &buflen));
- T(addtab((u_int)(p - tmp) + 1, 48, spaced, &buf, &buflen));
- }
- p = tmp;
- p += SPRINTF((p, "; "));
- for (m = 0; m < n; m++)
- *p++ = (isascii(rdata[m]) && isprint(rdata[m]))
- ? rdata[m]
- : '.';
- T(addstr(tmp, (u_int)(p - tmp), &buf, &buflen));
- rdata += n;
- }
- return ((int)(buf - obuf));
+ int n, m;
+ char *p;
+
+ len = SPRINTF((tmp, "\\#(\t\t; %s", comment));
+ T(addstr(tmp, len, &buf, &buflen));
+ while (rdata < edata) {
+ p = tmp;
+ p += SPRINTF((p, "\n\t"));
+ spaced = 0;
+ n = MIN(16, (int)(edata - rdata));
+ for (m = 0; m < n; m++)
+ p += SPRINTF((p, "%02x ", rdata[m]));
+ T(addstr(tmp, (u_int)(p - tmp), &buf, &buflen));
+ if (n < 16) {
+ T(addstr(")", 1, &buf, &buflen));
+ T(addtab((u_int)(p - tmp) + 1, 48, spaced, &buf, &buflen));
+ }
+ p = tmp;
+ p += SPRINTF((p, "; "));
+ for (m = 0; m < n; m++)
+ *p++ = (isascii(rdata[m]) && isprint(rdata[m]))
+ ? rdata[m]
+ : '.';
+ T(addstr(tmp, (u_int)(p - tmp), &buf, &buflen));
+ rdata += n;
+ }
+ return ((int)(buf - obuf));
}
}
@@ -621,156 +621,156 @@ ns_sprintrrf(const u_char *msg, size_t msglen, /*
* size_t
* prune_origin(name, origin)
- * Find out if the name is at or under the current origin.
+ * Find out if the name is at or under the current origin.
* return:
- * Number of characters in name before start of origin,
- * or length of name if origin does not match.
+ * Number of characters in name before start of origin,
+ * or length of name if origin does not match.
* notes:
- * This function should share code with samedomain().
+ * This function should share code with samedomain().
*/
static size_t
prune_origin(const char *name, const char *origin) {
- const char *oname = name;
-
- while (*name != '\0') {
- if (origin != NULL && strcasecmp(name, origin) == 0)
- return ((size_t)(name - oname) - (name > oname));
- while (*name != '\0') {
- if (*name == '\\') {
- name++;
- /* XXX need to handle \nnn form. */
- if (*name == '\0')
- break;
- } else if (*name == '.') {
- name++;
- break;
- }
- name++;
- }
- }
- return ((size_t)(name - oname));
+ const char *oname = name;
+
+ while (*name != '\0') {
+ if (origin != NULL && strcasecmp(name, origin) == 0)
+ return ((size_t)(name - oname) - (name > oname));
+ while (*name != '\0') {
+ if (*name == '\\') {
+ name++;
+ /* XXX need to handle \nnn form. */
+ if (*name == '\0')
+ break;
+ } else if (*name == '.') {
+ name++;
+ break;
+ }
+ name++;
+ }
+ }
+ return ((size_t)(name - oname));
}
/*
* int
* charstr(rdata, edata, buf, buflen)
- * Format a <character-string> into the presentation buffer.
+ * Format a <character-string> into the presentation buffer.
* return:
- * Number of rdata octets consumed
- * 0 for protocol format error
- * -1 for output buffer error
+ * Number of rdata octets consumed
+ * 0 for protocol format error
+ * -1 for output buffer error
* side effects:
- * buffer is advanced on success.
+ * buffer is advanced on success.
*/
static int
charstr(const u_char *rdata, const u_char *edata, char **buf, size_t *buflen) {
- const u_char *odata = rdata;
- size_t save_buflen = *buflen;
- char *save_buf = *buf;
-
- if (addstr("\"", 1, buf, buflen) < 0)
- goto enospc;
- if (rdata < edata) {
- int n = *rdata;
-
- if (rdata + 1 + n <= edata) {
- rdata++;
- while (n-- > 0) {
- if (strchr("\n\"\\", *rdata) != NULL)
- if (addstr("\\", 1, buf, buflen) < 0)
- goto enospc;
- if (addstr((const char *)rdata, 1,
- buf, buflen) < 0)
- goto enospc;
- rdata++;
- }
- }
- }
- if (addstr("\"", 1, buf, buflen) < 0)
- goto enospc;
- return ((int)(rdata - odata));
+ const u_char *odata = rdata;
+ size_t save_buflen = *buflen;
+ char *save_buf = *buf;
+
+ if (addstr("\"", 1, buf, buflen) < 0)
+ goto enospc;
+ if (rdata < edata) {
+ int n = *rdata;
+
+ if (rdata + 1 + n <= edata) {
+ rdata++;
+ while (n-- > 0) {
+ if (strchr("\n\"\\", *rdata) != NULL)
+ if (addstr("\\", 1, buf, buflen) < 0)
+ goto enospc;
+ if (addstr((const char *)rdata, 1,
+ buf, buflen) < 0)
+ goto enospc;
+ rdata++;
+ }
+ }
+ }
+ if (addstr("\"", 1, buf, buflen) < 0)
+ goto enospc;
+ return ((int)(rdata - odata));
enospc:
- errno = ENOSPC;
- *buf = save_buf;
- *buflen = save_buflen;
- return (-1);
+ errno = ENOSPC;
+ *buf = save_buf;
+ *buflen = save_buflen;
+ return (-1);
}
static int
addname(const u_char *msg, size_t msglen,
- const u_char **pp, const char *origin,
- char **buf, size_t *buflen)
+ const u_char **pp, const char *origin,
+ char **buf, size_t *buflen)
{
- size_t newlen, save_buflen = *buflen;
- char *save_buf = *buf;
- int n;
-
- n = dn_expand(msg, msg + msglen, *pp, *buf, (int)(*buflen));
- if (n < 0)
- goto enospc; /* Guess. */
- newlen = prune_origin(*buf, origin);
- if ((origin == NULL || origin[0] == '\0' || (*buf)[newlen] == '\0') &&
- (newlen == 0 || (*buf)[newlen - 1] != '.')) {
- /* No trailing dot. */
- if (newlen + 2 > *buflen)
- goto enospc; /* No room for ".\0". */
- (*buf)[newlen++] = '.';
- (*buf)[newlen] = '\0';
- }
- if (newlen == 0) {
- /* Use "@" instead of name. */
- if (newlen + 2 > *buflen)
- goto enospc; /* No room for "@\0". */
- (*buf)[newlen++] = '@';
- (*buf)[newlen] = '\0';
- }
- *pp += n;
- addlen(newlen, buf, buflen);
- **buf = '\0';
- return ((int)newlen);
+ size_t newlen, save_buflen = *buflen;
+ char *save_buf = *buf;
+ int n;
+
+ n = dn_expand(msg, msg + msglen, *pp, *buf, (int)(*buflen));
+ if (n < 0)
+ goto enospc; /* Guess. */
+ newlen = prune_origin(*buf, origin);
+ if ((origin == NULL || origin[0] == '\0' || (*buf)[newlen] == '\0') &&
+ (newlen == 0 || (*buf)[newlen - 1] != '.')) {
+ /* No trailing dot. */
+ if (newlen + 2 > *buflen)
+ goto enospc; /* No room for ".\0". */
+ (*buf)[newlen++] = '.';
+ (*buf)[newlen] = '\0';
+ }
+ if (newlen == 0) {
+ /* Use "@" instead of name. */
+ if (newlen + 2 > *buflen)
+ goto enospc; /* No room for "@\0". */
+ (*buf)[newlen++] = '@';
+ (*buf)[newlen] = '\0';
+ }
+ *pp += n;
+ addlen(newlen, buf, buflen);
+ **buf = '\0';
+ return ((int)newlen);
enospc:
- errno = ENOSPC;
- *buf = save_buf;
- *buflen = save_buflen;
- return (-1);
+ errno = ENOSPC;
+ *buf = save_buf;
+ *buflen = save_buflen;
+ return (-1);
}
static void
addlen(size_t len, char **buf, size_t *buflen) {
- assert(len <= *buflen);
- *buf += len;
- *buflen -= len;
+ assert(len <= *buflen);
+ *buf += len;
+ *buflen -= len;
}
static int
addstr(const char *src, size_t len, char **buf, size_t *buflen) {
- if (len > *buflen) {
- errno = ENOSPC;
- return (-1);
- }
- memcpy(*buf, src, len);
- addlen(len, buf, buflen);
- **buf = '\0';
- return (0);
+ if (len > *buflen) {
+ errno = ENOSPC;
+ return (-1);
+ }
+ memcpy(*buf, src, len);
+ addlen(len, buf, buflen);
+ **buf = '\0';
+ return (0);
}
static int
addtab(size_t len, size_t target, int spaced, char **buf, size_t *buflen) {
- size_t save_buflen = *buflen;
- char *save_buf = *buf;
- int t;
-
- if (spaced || len >= target - 1) {
- T(addstr(" ", 2, buf, buflen));
- spaced = 1;
- } else {
- for (t = (int)(target - len - 1) / 8; t >= 0; t--)
- if (addstr("\t", 1, buf, buflen) < 0) {
- *buflen = save_buflen;
- *buf = save_buf;
- return (-1);
- }
- spaced = 0;
- }
- return (spaced);
+ size_t save_buflen = *buflen;
+ char *save_buf = *buf;
+ int t;
+
+ if (spaced || len >= target - 1) {
+ T(addstr(" ", 2, buf, buflen));
+ spaced = 1;
+ } else {
+ for (t = (int)(target - len - 1) / 8; t >= 0; t--)
+ if (addstr("\t", 1, buf, buflen) < 0) {
+ *buflen = save_buflen;
+ *buf = save_buf;
+ return (-1);
+ }
+ spaced = 0;
+ }
+ return (spaced);
}
diff --git a/StdLib/BsdSocketLib/res_debug.c b/StdLib/BsdSocketLib/res_debug.c index 5dc0302eec..4adef6e545 100644 --- a/StdLib/BsdSocketLib/res_debug.c +++ b/StdLib/BsdSocketLib/res_debug.c @@ -536,7 +536,7 @@ p_option(u_long option) { case RES_DNSRCH: return "dnsrch";
case RES_INSECURE1: return "insecure1";
case RES_INSECURE2: return "insecure2";
- default: sprintf(nbuf, "?0x%Lx?", (u_long)option);
+ default: sprintf(nbuf, "?0x%lx?", (u_long)option);
return (nbuf);
}
}
diff --git a/StdLib/EfiSocketLib/Socket.c b/StdLib/EfiSocketLib/Socket.c index 49c288d90a..d53473e9c9 100644 --- a/StdLib/EfiSocketLib/Socket.c +++ b/StdLib/EfiSocketLib/Socket.c @@ -5,10 +5,10 @@ * Bound - pSocket->PortList is not NULL
* Listen - AcceptWait event is not NULL
- Copyright (c) 2011, Intel Corporation
- All rights reserved. This program and the accompanying materials
- are licensed and made available under the terms and conditions of the BSD License
- which accompanies this distribution. The full text of the license may be found at
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
+ This program and the accompanying materials are licensed and made available under
+ the terms and conditions of the BSD License that accompanies this distribution.
+ The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
@@ -19,26 +19,26 @@ <code><pre>
- +-------------+ +-------------+ +-------------+
+ +---------------+ +-------------+ +-------------+
Service Lists | ::ESL_SERVICE |-->| ESL_SERVICE |-->| ESL_SERVICE |--> NULL (pNext)
- +-------------+ +-------------+ +-------------+
+ +---------------+ +-------------+ +-------------+
^ | (pPortList) |
pUdp4List ^ | pTcp4List | |
| | | |
^ | | | |
pIp4List | | | | |
+---------------+ | |
- | ::ESL_LAYER | ::mEslLayer | |
+ | ::ESL_LAYER | ::mEslLayer | |
+---------------+ | |
| (pSocketList) | |
Socket List V V V
- +-------------+ +-------------+ +-------------+
- | ::ESL_SOCKET |-->| ::ESL_PORT |-->| ESL_PORT |--> NULL (pLinkSocket)
- +-------------+ +-------------+ +-------------+
+ +---------------+ +-------------+ +-------------+
+ | ::ESL_SOCKET |-->| ::ESL_PORT |-->| ESL_PORT |--> NULL (pLinkSocket)
+ +---------------+ +-------------+ +-------------+
| | |
| | V
V V NULL
- +-------------+ +-------------+
+ +-------------+ +-------------+
| ESL_SOCKET |-->| ESL_PORT |--> NULL
+-------------+ +-------------+
| | | | | |
@@ -53,9 +53,9 @@ | `---------------. | |
pTxOobPacketListHead | | | |
V V V V
- +------------+ +------------+ +------------+ +------------+
+ +--------------+ +------------+ +------------+ +------------+
| ::ESL_PACKET | | ESL_PACKET | | ESL_PACKET | | ESL_PACKET |
- +------------+ +------------+ +------------+ +------------+
+ +--------------+ +------------+ +------------+ +------------+
| | | |
V V V V
+------------+ +------------+ +------------+ +------------+
@@ -154,7 +154,7 @@ ::EslTcp4PortCloseOp.
</li>
<li>State: PORT_STATE_CLOSE_TX_DONE</li>
- <li>Arc: ::EslSocketPortCloseComplete - Called when the close operation is
+ <li>Arc: ::EslSocketPortCloseComplete - Called when the close operation is
complete. After the transition to PORT_STATE_CLOSE_DONE,
this routine calls ::EslSocketRxCancel to abort the pending receive operations.
</li>
@@ -220,13 +220,13 @@ pPort->pRxActive
|
V
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
Active | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
Free | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
^
|
pPort->pRxFree
@@ -250,7 +250,7 @@ <code><pre>
- +------------+ +------------+
+ +------------+ +------------+
High .----->| ESL_PACKET |-->| ESL_PACKET |--> NULL (pNext)
Priority | +------------+ +------------+
|
@@ -260,14 +260,14 @@ +------------+
| pRxPacketListHead
Low |
- Priority | +------------+ +------------+ +------------+
+ Priority | +------------+ +------------+ +------------+
`----->| ::ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL
- +------------+ +------------+ +------------+
+ +------------+ +------------+ +------------+
</pre></code>
::EslSocketRxStart connects an ::ESL_PACKET structure to the ::ESL_IO_MGMT structure
- and then calls the network layer to start the receive operation. Upon
+ and then calls the network layer to start the receive operation. Upon
receive completion, ::EslSocketRxComplete breaks the connection between these
structrues and places the ESL_IO_MGMT structure onto the ESL_PORT::pRxFree list to
make token and event available for another receive operation. EslSocketRxComplete
@@ -371,9 +371,9 @@ *ppQueueHead: pSocket->pRxPacketListHead or pSocket->pRxOobPacketListHead
|
V
- +------------+ +------------+ +------------+
+ +------------+ +------------+ +------------+
Data | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL
- +------------+ +------------+ +------------+
+ +------------+ +------------+ +------------+
^
|
*ppQueueTail: pSocket->pRxPacketListTail or pSocket->pRxOobPacketListTail
@@ -414,13 +414,13 @@ pPort->pTxActive or pTxOobActive
|
V
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
Active | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
Free | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- +-------------+ +-------------+ +-------------+
+ +-------------+ +-------------+ +-------------+
^
|
pPort->pTxFree or pTxOobFree
@@ -956,7 +956,7 @@ EslSocketAccept ( /**
Allocate and initialize a ESL_SOCKET structure.
-
+
This support function allocates an ::ESL_SOCKET structure
and installs a protocol on ChildHandle. If pChildHandle is a
pointer to NULL, then a new handle is created and returned in
@@ -965,7 +965,7 @@ EslSocketAccept ( @param [in, out] pChildHandle Pointer to the handle of the child to create.
If it is NULL, then a new handle is created.
- If it is a pointer to an existing UEFI handle,
+ If it is a pointer to an existing UEFI handle,
then the protocol is added to the existing UEFI
handle.
@param [in] DebugFlags Flags for debug messages
@@ -976,7 +976,7 @@ EslSocketAccept ( @retval EFI_OUT_OF_RESOURCES There are not enough resources available to create
the child
@retval other The child handle was not created
-
+
**/
EFI_STATUS
EFIAPI
@@ -1644,15 +1644,15 @@ EslSocketCloseStart ( connection with the specified remote system. This routine
is designed to be polled by the connect routine for completion
of the network connection.
-
+
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
@param [in] pSockAddr Network address of the remote system.
-
+
@param [in] SockAddrLength Length in bytes of the network address.
-
+
@param [out] pErrno Address to receive the errno value upon completion.
-
+
@retval EFI_SUCCESS The connection was successfully established.
@retval EFI_NOT_READY The connection is in progress, call this routine again.
@retval Others The connection attempt failed.
@@ -1671,7 +1671,7 @@ EslSocketConnect ( ESL_SOCKET * pSocket;
EFI_STATUS Status;
EFI_TPL TplPrevious;
-
+
DEBUG (( DEBUG_CONNECT, "Entering SocketConnect\r\n" ));
//
@@ -1964,7 +1964,7 @@ EslSocketCopyFragmentedBuffer ( handle.
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
-
+
@param [out] pErrno Address to receive the errno value upon completion.
@retval EFI_SUCCESS The socket resources were returned successfully.
@@ -2126,7 +2126,7 @@ EslSocketFree ( address associated with the local host connection point.
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
-
+
@param [out] pAddress Network address to receive the local system address
@param [in,out] pAddressLength Length of the local network address structure
@@ -2149,14 +2149,14 @@ EslSocketGetLocalAddress ( ESL_SOCKET * pSocket;
EFI_STATUS Status;
EFI_TPL TplPrevious;
-
+
DBG_ENTER ( );
-
+
//
// Assume success
//
Status = EFI_SUCCESS;
-
+
//
// Validate the socket
//
@@ -2195,7 +2195,7 @@ EslSocketGetLocalAddress ( // Verify the address length
//
LengthInBytes = pSocket->pApi->AddressLength;
- if (( LengthInBytes <= *pAddressLength )
+ if (( LengthInBytes <= *pAddressLength )
&& ( 255 >= LengthInBytes )) {
//
// Return the local address and address length
@@ -2216,7 +2216,7 @@ EslSocketGetLocalAddress ( pSocket->errno = ENOTCONN;
Status = EFI_NOT_STARTED;
}
-
+
//
// Release the socket layer synchronization
//
@@ -2236,7 +2236,7 @@ EslSocketGetLocalAddress ( pSocket->errno = EADDRNOTAVAIL;
}
}
-
+
//
// Return the operation status
//
@@ -2264,7 +2264,7 @@ EslSocketGetLocalAddress ( address of the remote connection point.
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
-
+
@param [out] pAddress Network address to receive the remote system address
@param [in,out] pAddressLength Length of the remote network address structure
@@ -2287,14 +2287,14 @@ EslSocketGetPeerAddress ( ESL_SOCKET * pSocket;
EFI_STATUS Status;
EFI_TPL TplPrevious;
-
+
DBG_ENTER ( );
-
+
//
// Assume success
//
Status = EFI_SUCCESS;
-
+
//
// Validate the socket
//
@@ -2970,7 +2970,7 @@ EslSocketOptionGet ( pOptionData = (CONST UINT8 *)&pSocket->RxTimeout;
LengthInBytes = sizeof ( pSocket->RxTimeout );
break;
-
+
case SO_RCVBUF:
//
// Return the maximum receive buffer size
@@ -2986,7 +2986,7 @@ EslSocketOptionGet ( pOptionData = (UINT8 *)&pSocket->bReUseAddr;
LengthInBytes = sizeof ( pSocket->bReUseAddr );
break;
-
+
case SO_SNDBUF:
//
// Return the maximum transmit buffer size
@@ -3088,9 +3088,9 @@ EslSocketOptionSet ( UINT8 * pOptionData;
ESL_SOCKET * pSocket;
EFI_STATUS Status;
-
+
DBG_ENTER ( );
-
+
//
// Assume failure
//
@@ -3149,7 +3149,7 @@ EslSocketOptionSet ( errno = ENOPROTOOPT;
Status = EFI_INVALID_PARAMETER;
break;
-
+
case SOL_SOCKET:
switch ( OptionName ) {
default:
@@ -3462,13 +3462,13 @@ EslSocketPoll ( // Synchronize with the socket layer
//
RAISE_TPL ( TplPrevious, TPL_SOCKETS );
-
+
//
// Increase the network performance by extending the
// polling (idle) loop down into the LAN driver
//
EslSocketRxPoll ( pSocket );
-
+
//
// Release the socket layer synchronization
//
@@ -3844,7 +3844,7 @@ EslSocketPortAllocate ( <li>::EslTcp4ConnectComplete - Connection failure and reducing the port list to a single port</li>
</ul>
See the \ref PortCloseStateMachine section.
-
+
@param [in] pPort Address of an ::ESL_PORT structure.
@retval EFI_SUCCESS The port is closed
@@ -3865,7 +3865,7 @@ EslSocketPortClose ( CONST ESL_SOCKET_BINDING * pSocketBinding;
ESL_SOCKET * pSocket;
EFI_STATUS Status;
-
+
DBG_ENTER ( );
//
@@ -4460,13 +4460,13 @@ EslSocketPortCloseTxDone ( ::recv and ::read are layered on top of ::recvfrom.
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
-
+
@param [in] Flags Message control flags
-
+
@param [in] BufferLength Length of the the buffer
-
+
@param [in] pBuffer Address of a buffer to receive the data.
-
+
@param [in] pDataLength Number of received data bytes in the buffer.
@param [out] pAddress Network address to receive the remote system address
@@ -4577,7 +4577,7 @@ EslSocketReceive ( pRemoteAddress->sa_family = pSocket->pApi->AddressFamily;
pRemoteAddress->sa_len = (UINT8)pSocket->pApi->AddressLength;
}
-
+
//
// Synchronize with the socket layer
//
@@ -4789,7 +4789,7 @@ EslSocketReceive ( }
}
-
+
}
else {
//
@@ -4915,13 +4915,13 @@ EslSocketRxComplete ( // pPort->pRxActive
// |
// V
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
// Active | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
//
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
// Free | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
// ^
// |
// pPort->pRxFree
@@ -4955,13 +4955,13 @@ EslSocketRxComplete ( // pRxOobPacketListHead pRxOobPacketListTail
// | |
// V V
- // +------------+ +------------+ +------------+
+ // +------------+ +------------+ +------------+
// Urgent Data | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL
- // +------------+ +------------+ +------------+
+ // +------------+ +------------+ +------------+
//
- // +------------+ +------------+ +------------+
+ // +------------+ +------------+ +------------+
// Normal Data | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL
- // +------------+ +------------+ +------------+
+ // +------------+ +------------+ +------------+
// ^ ^
// | |
// pRxPacketListHead pRxPacketListTail
@@ -5247,13 +5247,13 @@ EslSocketRxStart ( // Allocate the receive control structure
//
pPort->pRxFree = pIo->pNext;
-
+
//
// Mark this receive as pending
//
pIo->pNext = pPort->pRxActive;
pPort->pRxActive = pIo;
-
+
}
else {
DEBUG (( DEBUG_RX | DEBUG_INFO,
@@ -5315,9 +5315,9 @@ EslSocketRxStart ( operations on the socket.
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
-
+
@param [in] How Which operations to stop
-
+
@param [out] pErrno Address to receive the errno value upon completion.
@retval EFI_SUCCESS - Socket operations successfully shutdown
@@ -5335,9 +5335,9 @@ EslSocketShutdown ( ESL_SOCKET * pSocket;
EFI_STATUS Status;
EFI_TPL TplPrevious;
-
+
DBG_ENTER ( );
-
+
//
// Assume success
//
@@ -5454,13 +5454,13 @@ EslSocketShutdown ( system. Note that ::send and ::write are layered on top of ::sendto.
@param [in] pSocketProtocol Address of an ::EFI_SOCKET_PROTOCOL structure.
-
+
@param [in] Flags Message control flags
-
+
@param [in] BufferLength Length of the the buffer
-
+
@param [in] pBuffer Address of a buffer containing the data to send
-
+
@param [in] pDataLength Address to receive the number of data bytes sent
@param [in] pAddress Network address of the remote system address
@@ -5827,9 +5827,9 @@ EslSocketTxStart ( // *ppQueueHead: pSocket->pRxPacketListHead or pSocket->pRxOobPacketListHead
// |
// V
- // +------------+ +------------+ +------------+
+ // +------------+ +------------+ +------------+
// Data | ESL_PACKET |-->| ESL_PACKET |-->| ESL_PACKET |--> NULL
- // +------------+ +------------+ +------------+
+ // +------------+ +------------+ +------------+
// ^
// |
// *ppQueueTail: pSocket->pRxPacketListTail or pSocket->pRxOobPacketListTail
@@ -5900,9 +5900,9 @@ EslSocketTxStart ( pIo->pPacket = pPacket;
//
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
// Free | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
// ^
// |
// *ppFree: pPort->pTxFree or pTxOobFree
@@ -5911,14 +5911,14 @@ EslSocketTxStart ( // Remove the IO structure from the queue
//
*ppFree = pIo->pNext;
-
+
//
// *ppActive: pPort->pTxActive or pTxOobActive
// |
// V
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
// Active | ESL_IO_MGMT |-->| ESL_IO_MGMT |-->| ESL_IO_MGMT |--> NULL
- // +-------------+ +-------------+ +-------------+
+ // +-------------+ +-------------+ +-------------+
//
//
// Mark this packet as active
diff --git a/StdLib/Include/errno.h b/StdLib/Include/errno.h index db2eb3c71c..a819d0849c 100644 --- a/StdLib/Include/errno.h +++ b/StdLib/Include/errno.h @@ -26,7 +26,7 @@ All macro definitions in this list must begin with the letter 'E'
and be followed by a digit or an uppercase letter.
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -46,6 +46,7 @@ extern RETURN_STATUS EFIerrno; // Define error number in terms of the ENUM in <sys/errno.h>
#define ERESTART -1 /* restart syscall */
+#define ESUCCESS __ESUCCESS /* No Problems */
#define EMINERRORVAL __EMINERRORVAL /* 1 The lowest valid error value */
diff --git a/StdLib/Include/sys/EfiCdefs.h b/StdLib/Include/sys/EfiCdefs.h index c436ff3659..2fa7ba6ae5 100644 --- a/StdLib/Include/sys/EfiCdefs.h +++ b/StdLib/Include/sys/EfiCdefs.h @@ -22,7 +22,7 @@ This file and its contents are inspired by the <sys/cdefs.h> files in Berkeley
Unix. They have been re-implemented to be specific to the EFI environment.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -360,8 +360,8 @@ typedef UINTN EFI_ULONG_T; #if defined(__GNUC__)
#if __GNUC_PREREQ__(4,4)
/* GCC 4.4 or later */
- typedef INT64 LONGN;
- typedef UINT64 ULONGN;
+ typedef INTN LONGN;
+ typedef UINTN ULONGN;
#else
/* minGW gcc variant */
typedef INT32 LONGN;
diff --git a/StdLib/Include/sys/errno.h b/StdLib/Include/sys/errno.h index 53c9e6903b..50c5af6630 100644 --- a/StdLib/Include/sys/errno.h +++ b/StdLib/Include/sys/errno.h @@ -7,7 +7,7 @@ directives. These default values are specified as an enum in order to ease
the maintenance of the values.
- Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -22,6 +22,7 @@ /* Define the error numbers, sequentially, beginning at 1. */
enum {
+ __ESUCCESS = 0, /* 0 For those rare times one needs to say all is OK */
__EMINERRORVAL = 1, /* The lowest valid error value */
__EPERM = __EMINERRORVAL, /* 1 Operation not permitted */
__ENOENT, /* 2 No such file or directory */
diff --git a/StdLib/Include/sys/fcntl.h b/StdLib/Include/sys/fcntl.h index 819461b492..dba4d2471e 100644 --- a/StdLib/Include/sys/fcntl.h +++ b/StdLib/Include/sys/fcntl.h @@ -2,7 +2,7 @@ This file includes the definitions for open and fcntl described by POSIX
for <fcntl.h>; it also includes related kernel definitions.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made
available under the terms and conditions of the BSD License which
accompanies this distribution. The full text of the license may be found
@@ -70,7 +70,7 @@ #define O_APPEND 0x00000008 ///< set append mode
#define O_CREAT 0x00000200 ///< create if nonexistent
#define O_TRUNC 0x00000400 ///< truncate to zero length
-#define O_EXCL 0x00000800 ///< error if already exists
+#define O_EXCL 0x00000800 ///< Grant EXCLusive access, or error if already exists and O_CREAT
#define O_DIRECTORY 0x00001000 ///< error if path is not a directory
#define O_NOCTTY 0x00002000 ///< Don't make this the controlling TTY
diff --git a/StdLib/Include/sys/stat.h b/StdLib/Include/sys/stat.h index 12520be83a..83fc58025a 100644 --- a/StdLib/Include/sys/stat.h +++ b/StdLib/Include/sys/stat.h @@ -1,6 +1,6 @@ /** @file
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made
available under the terms and conditions of the BSD License that
accompanies this distribution. The full text of the license may be found at
@@ -119,21 +119,24 @@ struct stat { #define S_EFISHIFT 20 // LS bit of the UEFI attributes
-#define S_IFMT _S_IFMT
-#define S_IFBLK _S_IFBLK
-#define S_IFREG _S_IFREG
-#define S_IFIFO _S_IFIFO
-#define S_IFCHR _S_IFCHR
-#define S_IFDIR _S_IFDIR
-#define S_IFSOCK _S_IFSOCK
+#define S_IFMT _S_IFMT
+#define S_IFIFO _S_IFIFO
+#define S_IFCHR _S_IFCHR
+#define S_IFDIR _S_IFDIR
+#define S_IFBLK _S_IFBLK
+#define S_IFREG _S_IFREG
+#define S_IFSOCK _S_IFSOCK
+#define S_ITTY _S_ITTY
+#define S_IWTTY _S_IWTTY
+#define S_ICONSOLE _S_ICONSOLE
-#define S_ISDIR(m) ((m & _S_IFMT) == _S_IFDIR) ///< directory
+#define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO) ///< fifo
#define S_ISCHR(m) ((m & _S_IFMT) == _S_IFCHR) ///< char special
-#define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG) ///< regular file
+#define S_ISDIR(m) ((m & _S_IFMT) == _S_IFDIR) ///< directory
#define S_ISBLK(m) ((m & _S_IFMT) == _S_IFBLK) ///< block special
+#define S_ISREG(m) ((m & _S_IFMT) == _S_IFREG) ///< regular file
#define S_ISSOCK(m) ((m & _S_IFMT) == _S_IFSOCK) ///< socket
-#define S_ISFIFO(m) ((m & _S_IFMT) == _S_IFIFO) ///< fifo
/* The following three macros have been changed to reflect
access permissions that better reflect the UEFI FAT file system.
@@ -191,8 +194,18 @@ __BEGIN_DECLS **/
int lstat (const char *, struct stat *);
- /**
- **/
+/** Obtains information about the file pointed to by path.
+
+ Opens the file pointed to by path, calls _EFI_FileInfo with the file's handle,
+ then closes the file.
+
+ @param[in] path Path to the file to obtain information about.
+ @param[out] statbuf Buffer in which the file status is put.
+
+ @retval 0 Successful Completion.
+ @retval -1 An error has occurred and errno has been set to
+ identify the error.
+**/
int stat (const char *, struct stat *);
/**
diff --git a/StdLib/Include/wchar.h b/StdLib/Include/wchar.h index 2c9ec6e5e7..3acc2a4b8d 100644 --- a/StdLib/Include/wchar.h +++ b/StdLib/Include/wchar.h @@ -150,7 +150,7 @@ - WEOF might not be negative.
- mbstate_t objects are not intended to be inspected by programs.
- Copyright (c) 2010 - 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -1089,7 +1089,7 @@ by the value of base, and a final wide string of one or more unrecognized wide characters, including the terminating null wide character of the input wide string. Then,
they attempt to convert the subject sequence to an integer, and return the result.
- @param[in] Nptr Pointer to the string to convert to a floating-point value.
+ @param[in] Nptr Pointer to the string to convert.
@param[in] EndPtr Optional pointer to an object in which to store a pointer
to the final wide string.
@param[in] Base Base, 0 to 36, of the value represented by the string
diff --git a/StdLib/Include/x86/float.h b/StdLib/Include/x86/float.h index 72ed758718..5086dfadcb 100644 --- a/StdLib/Include/x86/float.h +++ b/StdLib/Include/x86/float.h @@ -1,5 +1,5 @@ /** @file
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
@@ -13,22 +13,22 @@ #ifndef _X86_FLOAT_H_
#define _X86_FLOAT_H_
-#if 0 /* Force all compilers to have the same limits */
-/* long double and double are the same in Microsoft compilers. */
+/* long double and double are the same in Microsoft compilers.
+ In GCC long double is fully supported.
+*/
#if !defined(_MSC_VER) /* Non-Microsoft compiler specifics. */
- #define LDBL_MANT_DIG 64
- #define LDBL_EPSILON 1.0842021724855044340E-19L
- #define LDBL_DIG 18
- #define LDBL_MIN_EXP (-16381)
- #define LDBL_MIN 3.3621031431120935063E-4932L
+ #define LDBL_MANT_DIG 64
+ #define LDBL_EPSILON 1.0842021724855044340E-19L
+ #define LDBL_DIG 18
+ #define LDBL_MIN_EXP (-16381)
+ #define LDBL_MIN 3.3621031431120935063E-4932L
#define LDBL_MIN_10_EXP (-4931)
- #define LDBL_MAX_EXP 16384
- #define LDBL_MAX 1.1897314953572317650E+4932L
+ #define LDBL_MAX_EXP 16384
+ #define LDBL_MAX 1.1897314953572317650E+4932L
#define LDBL_MAX_10_EXP 4932
- #define DECIMAL_DIG 21
+ #define DECIMAL_DIG 21
#endif // !defined(_MSC_VER)
-#endif // if 0
#include <sys/float_ieee754.h>
diff --git a/StdLib/LibC/Containers/Queues/Fifo.c b/StdLib/LibC/Containers/Queues/Fifo.c index 996498e1d9..73254d2e56 100644 --- a/StdLib/LibC/Containers/Queues/Fifo.c +++ b/StdLib/LibC/Containers/Queues/Fifo.c @@ -15,7 +15,7 @@ One element of the FIFO is always reserved as the "terminator" element. Thus,
the capacity of a FIFO is actually NumElements-1.
- Copyright (c) 2012, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2012 - 2014, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available
under the terms and conditions of the BSD License which accompanies this
distribution. The full text of the license may be found at
@@ -102,10 +102,10 @@ FIFO_FreeSpace ( WDex = Self->WriteIndex;
if(RDex <= WDex) {
- Count = Self->NumElements - ((WDex - RDex) - 1);
+ Count = (Self->NumElements - (WDex - RDex)) - 1;
}
else {
- Count = (RDex - WDex);
+ Count = (RDex - WDex)-1;
}
if(As == AsBytes) {
Count *= Self->ElementSize;
@@ -221,32 +221,31 @@ FIFO_Enqueue ( assert(Self != NULL);
assert(pElement != NULL);
- if(FIFO_IsFull(Self)) {
- Count = 0;
+ if(FIFO_IsFull(Self)) { // FIFO is full so can't add to it
+ Count = 0; // Zero characters added
}
- else {
- Count = MIN(Count, Self->FreeSpace(Self, AsElements));
- SizeOfElement = Self->ElementSize;
- Windex = Self->WriteIndex;
-
- ElemPtr = (uintptr_t)pElement;
-
- QPtr = (uintptr_t)Self->Queue + (SizeOfElement * Windex);
- for(i = 0; i < Count; ++i) {
- (void)CopyMem((void *)QPtr, (const void *)ElemPtr, SizeOfElement);
- Windex = (UINT32)ModuloIncrement(Windex, Self->NumElements);
- if(Windex == 0) { // If the index wrapped
- QPtr = (uintptr_t)Self->Queue;
+ else { // Otherwise, FIFO is not full...
+ Count = MIN(Count, Self->FreeSpace(Self, AsElements)); // Smaller of requested or available space
+ SizeOfElement = Self->ElementSize; // Size of Elements, in bytes
+ Windex = Self->WriteIndex; // Index of first writable slot in FIFO
+
+ ElemPtr = (uintptr_t)pElement; // Addr. of element to add, as an integer
+ QPtr = (uintptr_t)Self->Queue + (SizeOfElement * Windex); // Addr. in FIFO to write, as an integer
+
+ for(i = 0; i < Count; ++i) { // For Count elements...
+ (void)CopyMem((void *)QPtr, (const void *)ElemPtr, SizeOfElement); // Copy an element into the FIFO
+ Windex = (UINT32)ModuloIncrement(Windex, Self->NumElements); // Increment the Write index, wrap if necessary
+ if(Windex == 0) { // If the index wrapped
+ QPtr = (uintptr_t)Self->Queue; // Go to the beginning
}
else {
- QPtr += SizeOfElement;
+ QPtr += SizeOfElement; // Otherwise, point to next in FIFO
}
- ElemPtr += SizeOfElement;
+ ElemPtr += SizeOfElement; // And also point to next Element to add
}
- (void)ZeroMem((void*)QPtr, SizeOfElement);
- Self->WriteIndex = Windex;
+ Self->WriteIndex = Windex; // Finally, save the new Write Index
}
- return Count;
+ return Count; // Number of elements added to FIFO
}
/** Read or copy elements from the FIFO.
@@ -277,7 +276,6 @@ FIFO_Dequeue ( BOOLEAN Consume
)
{
- UINTN ElemPtr;
UINTN QPtr;
UINT32 RDex;
UINT32 SizeOfElement;
@@ -285,38 +283,40 @@ FIFO_Dequeue ( assert(Self != NULL);
assert(pElement != NULL);
- assert(Count != 0);
if(FIFO_IsEmpty(Self)) {
Count = 0;
}
else {
- RDex = Self->ReadIndex;
- SizeOfElement = Self->ElementSize;
- ElemPtr = (UINTN)pElement;
- Count = MIN(Count, Self->Count(Self, AsElements));
-
- QPtr = (UINTN)Self->Queue + (RDex * Self->ElementSize);
- for(i = 0; i < Count; ++i) {
- (void)CopyMem((void *)ElemPtr, (const void *)QPtr, Self->ElementSize);
- RDex = (UINT32)ModuloIncrement(RDex, Self->NumElements);
- if(RDex == 0) { // If the index wrapped
- QPtr = (UINTN)Self->Queue;
+ RDex = Self->ReadIndex; // Get this FIFO's Read Index
+ SizeOfElement = Self->ElementSize; // Get size of this FIFO's elements
+ Count = MIN(Count, Self->Count(Self, AsElements)); // Lesser of requested or actual
+
+ QPtr = (UINTN)Self->Queue + (RDex * Self->ElementSize); // Point to Read location in FIFO
+ for(i = 0; i < Count; ++i) { // Iterate Count times...
+ (void)CopyMem(pElement, (const void *)QPtr, Self->ElementSize); // Copy element from FIFO to caller's buffer
+ RDex = (UINT32)ModuloIncrement(RDex, Self->NumElements); // Increment Read Index
+ if(RDex == 0) { // If the index wrapped
+ QPtr = (UINTN)Self->Queue; // Point back to beginning of data
}
- else {
- QPtr += Self->ElementSize;
+ else { // Otherwise
+ QPtr += Self->ElementSize; // Point to the next element in FIFO
}
- ElemPtr += Self->ElementSize;
- }
- if(Consume) {
- Self->ReadIndex = RDex;
+ pElement = (char*)pElement + Self->ElementSize; // Point to next element in caller's buffer
+ } // Iterate: for loop
+ if(Consume) { // If caller requests data consumption
+ Self->ReadIndex = RDex; // Set FIFO's Read Index to new Index
}
}
- return Count;
+ return Count; // Return number of elements actually read
}
/** Read elements from the FIFO.
+ Read the specified number of elements from the FIFO, removing each element read.
+ The number of elements actually read from the FIFO is returned. This number can differ
+ from the Count requested if more elements are requested than are in the FIFO.
+
@param[in] Self Pointer to the FIFO instance.
@param[out] pElement Pointer to where to store the element read from the FIFO.
@param[in] Count Number of elements to dequeue.
@@ -338,7 +338,7 @@ FIFO_Read ( /** Make a copy of the FIFO's data.
The contents of the FIFO is copied out and linearized without affecting the
- FIFO contents.
+ FIFO contents. This function is idempotent.
@param[in] Self Pointer to the FIFO instance.
@param[out] pElement Pointer to where to store the elements copied from the FIFO.
@@ -435,7 +435,7 @@ FIFO_Flush ( assert(Self != NULL);
- NumInQ = FIFO_FreeSpace(Self, AsElements);
+ NumInQ = FIFO_NumInQueue(Self, AsElements);
if(NumToFlush >= NumInQ) {
Self->ReadIndex = 0;
Self->WriteIndex = 0;
@@ -464,7 +464,7 @@ FIFO_Truncate ( assert(Self != NULL);
- Remainder = Self->Count(Self, AsElements);
+ Remainder = FIFO_NumInQueue(Self, AsElements);
if(Remainder > 0) {
Self->WriteIndex = (UINT32)ModuloDecrement(Self->WriteIndex, Self->NumElements);
--Remainder;
diff --git a/StdLib/LibC/StdLib/realpath.c b/StdLib/LibC/StdLib/realpath.c index b9f674dbce..a7186184c9 100644 --- a/StdLib/LibC/StdLib/realpath.c +++ b/StdLib/LibC/StdLib/realpath.c @@ -1,7 +1,7 @@ /** @file
Implement the realpath function.
- Copyright (c) 2011, Intel Corporation
+ Copyright (c) 2011 - 2014, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -9,24 +9,22 @@ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
**/
-
#include <LibConfig.h>
#include <Library/BaseLib.h>
-#include <Library/PathLib.h>
#include <Library/MemoryAllocationLib.h>
+#include <Library/PathLib.h>
#include <errno.h>
-/**
- The realpath() function shall derive, from the pathname pointed to by
- file_name, an absolute pathname that names the same file, whose resolution
- does not involve '.', '..', or symbolic links. The generated pathname shall
- be stored as a null-terminated string, up to a maximum of {PATH_MAX} bytes,
- in the buffer pointed to by resolved_name.
+/** The realpath() function shall derive, from the pathname pointed to by
+ file_name, an absolute pathname that names the same file, whose resolution
+ does not involve '.', '..', or symbolic links.
+
+ The generated pathname shall be stored as a null-terminated string, up to a
+ maximum of {PATH_MAX} bytes, in the buffer pointed to by resolved_name.
- If resolved_name is a null pointer, the behavior of realpath() is
- implementation-defined.
+ If resolved_name is a null pointer, the behavior of realpath() is
+ implementation-defined.
@param[in] file_name The filename to convert.
@param[in,out] resolved_name The resultant name.
@@ -36,7 +34,7 @@ **/
char *
realpath(
- char *file_name,
+ char *file_name,
char *resolved_name
)
{
@@ -54,4 +52,4 @@ realpath( PathCleanUpDirectories(Temp);
UnicodeStrToAsciiStr(Temp, resolved_name);
return (resolved_name);
-}
\ No newline at end of file +}
|