X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/tripe/blobdiff_plain/53a941d3f97a50964587c6e9533b1e43e74a57a8..62b5e3ecc77424add00ad4e5dc86e7248751cdf6:/server/servutil.c diff --git a/server/servutil.c b/server/servutil.c index c95b23fd..dbca451d 100644 --- a/server/servutil.c +++ b/server/servutil.c @@ -30,7 +30,7 @@ /*----- Global variables --------------------------------------------------*/ -octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ]; +octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ], buf_u[PKBUFSZ]; /*----- Main code ---------------------------------------------------------*/ @@ -41,14 +41,14 @@ octet buf_i[PKBUFSZ], buf_o[PKBUFSZ], buf_t[PKBUFSZ]; * Returns: A pointer to the integer's textual representation. * * Use: Converts a multiprecision integer to a string. Corrupts - * @buf_t@. + * @buf_u@. */ const char *mpstr(mp *m) { - if (mp_writestring(m, (char *)buf_t, sizeof(buf_t), 10)) + if (mp_writestring(m, (char *)buf_u, sizeof(buf_u), 10)) return (""); - return ((const char *)buf_t); + return ((const char *)buf_u); } /* --- @gestr@ --- * @@ -59,14 +59,14 @@ const char *mpstr(mp *m) * Returns: A pointer to the element's textual representation. * * Use: Converts a group element to a string. Corrupts - * @buf_t@. + * @buf_u@. */ const char *gestr(group *g, ge *x) { - if (group_writestring(g, x, (char *)buf_t, sizeof(buf_t))) + if (group_writestring(g, x, (char *)buf_u, sizeof(buf_u))) return (""); - return ((const char *)buf_t); + return ((const char *)buf_u); } /* --- @timestr@ --- * @@ -76,7 +76,7 @@ const char *gestr(group *g, ge *x) * Returns: A pointer to a textual representation of the time. * * Use: Converts a time to a textual representation. Corrupts - * @buf_t@. + * @buf_u@. */ const char *timestr(time_t t) @@ -85,8 +85,25 @@ const char *timestr(time_t t) if (!t) return ("NEVER"); tm = localtime(&t); - strftime((char *)buf_t, sizeof(buf_t), "%Y-%m-%dT%H:%M:%S", tm); - return ((const char *)buf_t); + strftime((char *)buf_u, sizeof(buf_u), "%Y-%m-%dT%H:%M:%S", tm); + return ((const char *)buf_u); +} + +/* --- @mystrieq@ --- * + * + * Arguments: @const char *x, *y@ = two strings + * + * Returns: True if @x@ and @y are equal, up to case. + */ + +int mystrieq(const char *x, const char *y) +{ + for (;;) { + if (!*x && !*y) return (1); + if (tolower((unsigned char)*x) != tolower((unsigned char)*y)) + return (0); + x++; y++; + } } /* --- @seq_reset@ --- *