]> Joshua Wise's Git repositories - netwatch.git/blobdiff - lib/minilib.c
Slightly permute the USB_LEGKEY stuff.
[netwatch.git] / lib / minilib.c
index 56090ed9389f9a8e1d0657649ca73438fc70203d..935d0c40bc5fb25f62dd5d30bac40e09ec1d6b24 100644 (file)
@@ -1,12 +1,23 @@
+/* minilib.c
+ * General-purpose C library routines.
+ * NetWatch system management mode administration console
+ *
+ * Copyright (c) 2008 Jacob Potter and Joshua Wise.  All rights reserved.
+ * This program is free software; you can redistribute and/or modify it under
+ * the terms found in the file LICENSE in the root of this source tree.
+ *
+ */
+
 #include "console.h"
 #include <minilib.h>
 #include <output.h>
 
+
 /* We have both _memcpy and memcpy, because gcc might be able to do better in lwip.
  * For small things, gcc inlines its memcpy, but for large things, we call out
  * to this memcpy.
  */
-inline void _memcpy(void *dest, const void *src, int bytes)
+void _memcpy(void *dest, const void *src, int bytes)
 {
        /* I hate everyone */
        /* Since we otherwise compile with -O0, we might as well manually speed this up a bit. */
@@ -63,6 +74,17 @@ void memset(void *dest, int data, int bytes)
                *(cdest++) = (unsigned char)data;
 }
 
+void *memchr(const void *buf, char c, int maxlen)
+{
+       const char * cbuf = buf;
+       while (maxlen--)
+       {
+               if (*cbuf == c) return (void *)cbuf;
+               cbuf++;
+       }
+       return 0;
+}
+
 void memmove(void *dest, void *src, int bytes)
 {
        char * cdest = dest;
@@ -146,6 +168,12 @@ void tohex(char *s, unsigned long l)
        }
 }
 
+void btohex(char *s, unsigned char c)
+{
+       s[0] = hexarr[c >> 4];
+       s[1] = hexarr[c & 0xF];
+}
+
 void puthex(unsigned long l)
 {
        char d[9];
This page took 0.023849 seconds and 4 git commands to generate.