@@@ much mess, mostly manpages
[mLib] / test / example / exfunc.c
diff --git a/test/example/exfunc.c b/test/example/exfunc.c
new file mode 100644 (file)
index 0000000..396f909
--- /dev/null
@@ -0,0 +1,52 @@
+/* -*-c-*-
+ *
+ * Example functionality to test
+ *
+ * (c) 2024 Straylight/Edgeware
+ */
+
+/*----- Licensing notice --------------------------------------------------*
+ *
+ * This file is part of the mLib utilities library.
+ *
+ * mLib is free software: you can redistribute it and/or modify it under
+ * the terms of the GNU Library General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or (at
+ * your option) any later version.
+ *
+ * mLib is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with mLib.  If not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+ * USA.
+ */
+
+/*----- Header files ------------------------------------------------------*/
+
+#include <stdio.h>
+#include <string.h>
+
+#include "example.h"
+
+/*----- Main code ---------------------------------------------------------*/
+
+/* Return the sum X + Y. */
+int add(int x, int y)
+  { return (x + y); }
+
+/* Generate a personalized greeting, mentioning NAME.  The greeting is
+ * written to the output buffer BUF, which has space for SZ characters.
+ * Return zero on success, or -1 on error.
+ */
+int greet(char *buf, size_t sz, const char *name)
+{
+  if (sz < strlen(name) + 9) return (-1);
+  sprintf(buf, "Hello, %s!", name);
+  return (0);
+}
+
+/*----- That's all, folks -------------------------------------------------*/