moved headers to extern
authorAaron Marcher <info@nulltime.net>
Sat, 17 Sep 2016 16:07:03 +0000 (18:07 +0200)
committerAaron Marcher (drkhsh) <info@nulltime.net>
Sat, 17 Sep 2016 16:07:03 +0000 (18:07 +0200)
arg.h [deleted file]
concat.h [deleted file]
extern/arg.h [new file with mode: 0644]
extern/concat.h [new file with mode: 0644]
extern/strlcat.h [new file with mode: 0644]
extern/strlcpy.h [new file with mode: 0644]
slstatus.c
strlcat.h [deleted file]
strlcpy.h [deleted file]

diff --git a/arg.h b/arg.h
deleted file mode 100644 (file)
index 2b189fe..0000000
--- a/arg.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copy me if you can.
- * by 20h
- */
-
-#ifndef __ARG_H__
-#define __ARG_H__
-
-extern char *argv0;
-
-#define USED(x)                ((void)(x))
-
-/* use main(int argc, char *argv[]) */
-#define ARGBEGIN       for (argv0 = *argv, argv++, argc--;\
-                                       argv[0] && argv[0][1]\
-                                       && argv[0][0] == '-';\
-                                       argc--, argv++) {\
-                               char _argc;\
-                               char **_argv;\
-                               int brk;\
-                               if (argv[0][1] == '-' && argv[0][2] == '\0') {\
-                                       argv++;\
-                                       argc--;\
-                                       break;\
-                               }\
-                               for (brk = 0, argv[0]++, _argv = argv;\
-                                               argv[0][0] && !brk;\
-                                               argv[0]++) {\
-                                       if (_argv != argv)\
-                                               break;\
-                                       _argc = argv[0][0];\
-                                       switch (_argc)
-
-#define ARGEND                 }\
-                               USED(_argc);\
-                       }\
-                       USED(argv);\
-                       USED(argc);
-
-#define ARGC()         _argc
-
-#define EARGF(x)       ((argv[0][1] == '\0' && argv[1] == NULL)?\
-                               ((x), abort(), (char *)0) :\
-                               (brk = 1, (argv[0][1] != '\0')?\
-                                       (&argv[0][1]) :\
-                                       (argc--, argv++, argv[0])))
-
-#define ARGF()         ((argv[0][1] == '\0' && argv[1] == NULL)?\
-                               (char *)0 :\
-                               (brk = 1, (argv[0][1] != '\0')?\
-                                       (&argv[0][1]) :\
-                                       (argc--, argv++, argv[0])))
-
-#endif
-
diff --git a/concat.h b/concat.h
deleted file mode 100644 (file)
index 7f2ea46..0000000
--- a/concat.h
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
- * Thanks to lloyd for contribution
- */
-
-extern char concat[8192];
-
-extern void
-ccat(const unsigned short int count, ...)
-{
-       va_list ap;
-       unsigned short int i;
-       concat[0] = '\0';
-
-       va_start(ap, count);
-       for(i = 0; i < count; i++)
-               strlcat(concat, va_arg(ap, char *), sizeof(concat));
-       va_end(ap);
-       return;
-}
diff --git a/extern/arg.h b/extern/arg.h
new file mode 100644 (file)
index 0000000..2b189fe
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copy me if you can.
+ * by 20h
+ */
+
+#ifndef __ARG_H__
+#define __ARG_H__
+
+extern char *argv0;
+
+#define USED(x)                ((void)(x))
+
+/* use main(int argc, char *argv[]) */
+#define ARGBEGIN       for (argv0 = *argv, argv++, argc--;\
+                                       argv[0] && argv[0][1]\
+                                       && argv[0][0] == '-';\
+                                       argc--, argv++) {\
+                               char _argc;\
+                               char **_argv;\
+                               int brk;\
+                               if (argv[0][1] == '-' && argv[0][2] == '\0') {\
+                                       argv++;\
+                                       argc--;\
+                                       break;\
+                               }\
+                               for (brk = 0, argv[0]++, _argv = argv;\
+                                               argv[0][0] && !brk;\
+                                               argv[0]++) {\
+                                       if (_argv != argv)\
+                                               break;\
+                                       _argc = argv[0][0];\
+                                       switch (_argc)
+
+#define ARGEND                 }\
+                               USED(_argc);\
+                       }\
+                       USED(argv);\
+                       USED(argc);
+
+#define ARGC()         _argc
+
+#define EARGF(x)       ((argv[0][1] == '\0' && argv[1] == NULL)?\
+                               ((x), abort(), (char *)0) :\
+                               (brk = 1, (argv[0][1] != '\0')?\
+                                       (&argv[0][1]) :\
+                                       (argc--, argv++, argv[0])))
+
+#define ARGF()         ((argv[0][1] == '\0' && argv[1] == NULL)?\
+                               (char *)0 :\
+                               (brk = 1, (argv[0][1] != '\0')?\
+                                       (&argv[0][1]) :\
+                                       (argc--, argv++, argv[0])))
+
+#endif
+
diff --git a/extern/concat.h b/extern/concat.h
new file mode 100644 (file)
index 0000000..7f2ea46
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Thanks to lloyd for contribution
+ */
+
+extern char concat[8192];
+
+extern void
+ccat(const unsigned short int count, ...)
+{
+       va_list ap;
+       unsigned short int i;
+       concat[0] = '\0';
+
+       va_start(ap, count);
+       for(i = 0; i < count; i++)
+               strlcat(concat, va_arg(ap, char *), sizeof(concat));
+       va_end(ap);
+       return;
+}
diff --git a/extern/strlcat.h b/extern/strlcat.h
new file mode 100644 (file)
index 0000000..2596420
--- /dev/null
@@ -0,0 +1,55 @@
+/*     $OpenBSD: strlcat.c,v 1.16 2015/08/31 02:53:57 guenther Exp $   */
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Appends src to string dst of size dsize (unlike strncat, dsize is the
+ * full size of dst, not space left).  At most dsize-1 characters
+ * will be copied.  Always NUL terminates (unless dsize <= strlen(dst)).
+ * Returns strlen(src) + MIN(dsize, strlen(initial dst)).
+ * If retval >= dsize, truncation occurred.
+ */
+size_t
+strlcat(char *dst, const char *src, size_t dsize)
+{
+       const char *odst = dst;
+       const char *osrc = src;
+       size_t n = dsize;
+       size_t dlen;
+
+       /* Find the end of dst and adjust bytes left but don't go past end. */
+       while (n-- != 0 && *dst != '\0')
+               dst++;
+       dlen = dst - odst;
+       n = dsize - dlen;
+
+       if (n-- == 0)
+               return(dlen + strlen(src));
+       while (*src != '\0') {
+               if (n != 0) {
+                       *dst++ = *src;
+                       n--;
+               }
+               src++;
+       }
+       *dst = '\0';
+
+       return(dlen + (src - osrc));    /* count does not include NUL */
+}
diff --git a/extern/strlcpy.h b/extern/strlcpy.h
new file mode 100644 (file)
index 0000000..6301674
--- /dev/null
@@ -0,0 +1,50 @@
+/*     $OpenBSD: strlcpy.c,v 1.13 2015/08/31 02:53:57 guenther Exp $   */
+
+/*
+ * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <string.h>
+
+/*
+ * Copy string src to buffer dst of size dsize.  At most dsize-1
+ * chars will be copied.  Always NUL terminates (unless dsize == 0).
+ * Returns strlen(src); if retval >= dsize, truncation occurred.
+ */
+size_t
+strlcpy(char *dst, const char *src, size_t dsize)
+{
+       const char *osrc = src;
+       size_t nleft = dsize;
+
+       /* Copy as many bytes as will fit. */
+       if (nleft != 0) {
+               while (--nleft != 0) {
+                       if ((*dst++ = *src++) == '\0')
+                               break;
+               }
+       }
+
+       /* Not enough room in dst, add NUL and traverse rest of src. */
+       if (nleft == 0) {
+               if (dsize != 0)
+                       *dst = '\0';            /* NUL-terminate dst */
+               while (*src++)
+                       ;
+       }
+
+       return(src - osrc - 1); /* count does not include NUL */
+}
index babcb89539a97d2b3c04a7d5e17afed1ce6131fb..99ef72089a4f49e07979708d56e6205c9b6dfb4c 100644 (file)
 #undef strlcat
 #undef strlcpy
 
-#include "arg.h"
-#include "strlcat.h"
-#include "strlcpy.h"
-#include "concat.h"
+#include "extern/arg.h"
+#include "extern/strlcat.h"
+#include "extern/strlcpy.h"
+#include "extern/concat.h"
 
 struct arg {
        char *(*func)();
diff --git a/strlcat.h b/strlcat.h
deleted file mode 100644 (file)
index 2596420..0000000
--- a/strlcat.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/*     $OpenBSD: strlcat.c,v 1.16 2015/08/31 02:53:57 guenther Exp $   */
-
-/*
- * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Appends src to string dst of size dsize (unlike strncat, dsize is the
- * full size of dst, not space left).  At most dsize-1 characters
- * will be copied.  Always NUL terminates (unless dsize <= strlen(dst)).
- * Returns strlen(src) + MIN(dsize, strlen(initial dst)).
- * If retval >= dsize, truncation occurred.
- */
-size_t
-strlcat(char *dst, const char *src, size_t dsize)
-{
-       const char *odst = dst;
-       const char *osrc = src;
-       size_t n = dsize;
-       size_t dlen;
-
-       /* Find the end of dst and adjust bytes left but don't go past end. */
-       while (n-- != 0 && *dst != '\0')
-               dst++;
-       dlen = dst - odst;
-       n = dsize - dlen;
-
-       if (n-- == 0)
-               return(dlen + strlen(src));
-       while (*src != '\0') {
-               if (n != 0) {
-                       *dst++ = *src;
-                       n--;
-               }
-               src++;
-       }
-       *dst = '\0';
-
-       return(dlen + (src - osrc));    /* count does not include NUL */
-}
diff --git a/strlcpy.h b/strlcpy.h
deleted file mode 100644 (file)
index 6301674..0000000
--- a/strlcpy.h
+++ /dev/null
@@ -1,50 +0,0 @@
-/*     $OpenBSD: strlcpy.c,v 1.13 2015/08/31 02:53:57 guenther Exp $   */
-
-/*
- * Copyright (c) 1998, 2015 Todd C. Miller <Todd.Miller@courtesan.com>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/types.h>
-#include <string.h>
-
-/*
- * Copy string src to buffer dst of size dsize.  At most dsize-1
- * chars will be copied.  Always NUL terminates (unless dsize == 0).
- * Returns strlen(src); if retval >= dsize, truncation occurred.
- */
-size_t
-strlcpy(char *dst, const char *src, size_t dsize)
-{
-       const char *osrc = src;
-       size_t nleft = dsize;
-
-       /* Copy as many bytes as will fit. */
-       if (nleft != 0) {
-               while (--nleft != 0) {
-                       if ((*dst++ = *src++) == '\0')
-                               break;
-               }
-       }
-
-       /* Not enough room in dst, add NUL and traverse rest of src. */
-       if (nleft == 0) {
-               if (dsize != 0)
-                       *dst = '\0';            /* NUL-terminate dst */
-               while (*src++)
-                       ;
-       }
-
-       return(src - osrc - 1); /* count does not include NUL */
-}