config.h
This commit is contained in:
parent
2e79541d3b
commit
8ee0a82786
|
@ -10,6 +10,6 @@ const char *objects[] = {
|
||||||
/* "sysutils" */
|
/* "sysutils" */
|
||||||
};
|
};
|
||||||
|
|
||||||
#define CFLAGS "-Wall", "-Werror", "-Wextra", "-pedantic", "-flto", "-Os", "-s", "-I", "../libmu"
|
#define CFLAGS "-Wall", "-Werror", "-Wextra", "-pedantic", "-flto", "-Os", "-s", "-I", "../libmu", "-I", "../"
|
||||||
#define CC "cc"
|
#define CC "cc"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
#ifndef _CONFIG_H
|
||||||
|
#define _CONFIG_H
|
||||||
|
|
||||||
|
/* Depends: cat tee wc */
|
||||||
|
#define BUF_SIZE 4096
|
||||||
|
|
||||||
|
/* Random source for shred */
|
||||||
|
#define RAND_SOURCE "/dev/urandom"
|
||||||
|
|
||||||
|
/* Options. To disable, comment line */
|
||||||
|
/* Add escape-char support in echo */
|
||||||
|
#define ECHO_FANCY
|
||||||
|
|
||||||
|
#endif
|
|
@ -3,9 +3,10 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
void cat(const int fd) {
|
void cat(const int fd) {
|
||||||
char buf[4096];
|
char buf[BUF_SIZE + 1];
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
|
|
||||||
while ((len = read(fd, buf, sizeof(buf))) > 0)
|
while ((len = read(fd, buf, sizeof(buf))) > 0)
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
#include <libgen.h>
|
#include <libgen.h>
|
||||||
|
|
||||||
int main(const int argc, char **argv) {
|
int main(const int argc, char **argv) {
|
||||||
|
|
||||||
if (argc <= 1) {
|
if (argc <= 1) {
|
||||||
printf("dirname [dirname]\n");
|
printf("dirname [dirname]\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
void format(char *str) {
|
void format(char *str) {
|
||||||
|
#ifdef ECHO_FANCY
|
||||||
for (size_t i = 0; i < strlen(str); i++) {
|
for (size_t i = 0; i < strlen(str); i++) {
|
||||||
unsigned int c = str[i];
|
unsigned int c = str[i];
|
||||||
if (c == '\\') {
|
if (c == '\\') {
|
||||||
|
@ -51,6 +53,11 @@ void format(char *str) {
|
||||||
|
|
||||||
putchar(c);
|
putchar(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
fputs(str, stdout);
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
|
@ -20,7 +20,6 @@ int ln(const char *src, const char *dst) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
|
||||||
int opt;
|
int opt;
|
||||||
while ((opt = getopt(argc, argv, "sf")) != -1) {
|
while ((opt = getopt(argc, argv, "sf")) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
|
|
@ -6,8 +6,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include "config.h"
|
||||||
#define RAND_SOURCE "/dev/urandom"
|
|
||||||
|
|
||||||
unsigned int f_flag;
|
unsigned int f_flag;
|
||||||
unsigned int u_flag;
|
unsigned int u_flag;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
int flag = O_TRUNC;
|
int flag = O_TRUNC;
|
||||||
|
@ -38,11 +39,11 @@ int main(int argc, char **argv) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char in[4096];
|
char buf[BUF_SIZE + 1];
|
||||||
off_t bytes = 0;
|
off_t bytes = 0;
|
||||||
while ((bytes = read(STDIN_FILENO, in, sizeof(in)))) {
|
while ((bytes = read(STDIN_FILENO, buf, sizeof(buf)))) {
|
||||||
write(STDOUT_FILENO, in, bytes);
|
write(STDOUT_FILENO, buf, bytes);
|
||||||
write(fd, in, bytes);
|
write(fd, buf, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include "config.h"
|
||||||
|
|
||||||
/* cmd arguments l - lines c - bytes w - words */
|
/* cmd arguments l - lines c - bytes w - words */
|
||||||
unsigned int l_flag;
|
unsigned int l_flag;
|
||||||
|
@ -20,7 +21,7 @@ unsigned int tbytes;
|
||||||
unsigned int tlines;
|
unsigned int tlines;
|
||||||
|
|
||||||
void count(const int fd) {
|
void count(const int fd) {
|
||||||
char buf[4096];
|
char buf[BUF_SIZE + 1];
|
||||||
off_t n = 0;
|
off_t n = 0;
|
||||||
|
|
||||||
int in_word = 1;
|
int in_word = 1;
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
Loading…
Reference in New Issue