aboutsummaryrefslogtreecommitdiff
path: root/printf.c
diff options
context:
space:
mode:
Diffstat (limited to 'printf.c')
-rw-r--r--printf.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/printf.c b/printf.c
new file mode 100644
index 0000000..3f90130
--- /dev/null
+++ b/printf.c
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: BSD-3-Clause */
+/*
+ * Copyright (C) 2022, 2023 Ferass El Hafidi <vitali64pmemail@protonmail.com>
+ */
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+#define REQ_PRINT_USAGE /* Require print_usage() from common.h */
+#define REQ_ERRPRINT /* Require print_usage() from common.h */
+#define DESCRIPTION "Write formatted strings to standard output."
+#define OPERANDS "format [string]"
+#include "common.h"
+
+#ifdef FASESBOX
+int printf_main(int argc, char *argv[]) {
+#else
+int main(int argc, char *argv[]) {
+#endif
+ if (argc == 1) {
+ print_usage(argv[0], DESCRIPTION, OPERANDS, VERSION);
+ return 1;
+ }
+ printf(argv[1], argv[2] ? argv[2] : "");
+ return errprint(argv[0], NULL, errno);
+}