diff --git a/files/ffuncs.c b/files/ffuncs.c new file mode 100644 index 0000000..064b19a --- /dev/null +++ b/files/ffuncs.c @@ -0,0 +1,60 @@ +/* + * various functions + */ + +#include +#include +#include +#include +#include + +#include "ffuncs.h" + +/* --------------------------------------------------------------------- */ +extern int verbosity; + +/* --------------------------------------------------------------------- */ +void dump(unsigned char *ptr) +{ +int foo; + +for (foo=0; foo<24; foo++) fprintf(stderr, "%02x ", ptr[foo]); +fputs("\n", stderr); +for (foo=0; foo<24; foo++) fprintf(stderr, "%c ", + isgraph(ptr[foo])?ptr[foo]:' '); +fputs("\n", stderr); + +} +/* --------------------------------------------------------------------- */ +char *rtrim(char *src) +{ +int foo = strlen(src)-1; + +for (foo; src[foo]==' '|| src[foo]=='\t'; foo--) { + src[foo] = '\0'; + } + +return src; +} +/* --------------------------------------------------------------------- */ +char *ltrim(char *src) +{ +int foo, bar; +char *tmp; + +tmp = alloca(strlen(src)); + +for (foo=0; src[foo]==' ' || src[foo]=='\t'; foo++); + +bar = 0; +while (src[foo]!='\0') { + tmp[bar]=src[foo]; + foo++; + bar++; + } + +strcpy(src,tmp); + +return src; +} +/* --------------------------------------------------------------------- */ diff --git a/files/ffuncs.h b/files/ffuncs.h new file mode 100644 index 0000000..06dbcee --- /dev/null +++ b/files/ffuncs.h @@ -0,0 +1,10 @@ +/* + * various functions + */ + +void dump(unsigned char *ptr); + +char *rtrim(char *src); +char *ltrim(char *src); + +/* --------------------------------------------------------------------- */