00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #include <ctype.h>
00024 #include <stdlib.h>
00025 #include <stdio.h>
00026 #include <string.h>
00027
00031 void add_space(FILE * f, const int exists, const int todo)
00032 {
00033 int i;
00034
00035 for (i = exists; i < todo; i++)
00036 fputc(' ', f);
00037 }
00038
00039 static char *ttBuf = NULL;
00040 static int ttBuflen = 0;
00046 char *trimtext(const char *s) {
00047 char *dp;
00048 const char *sp;
00049
00050 if (! s)
00051 return "";
00052
00053 if (ttBuflen < (strlen(s) + 1)) {
00054 if (ttBuf)
00055 free(ttBuf);
00056
00057 ttBuflen = strlen(s)+1;
00058 ttBuf = malloc(ttBuflen);
00059 }
00060 sp = s;
00061 dp = ttBuf;
00062
00063
00064 while ((*sp) && (isspace(*sp)))
00065 sp++;
00066
00067
00068 while (*sp) {
00069 *dp = *sp;
00070 dp++;
00071 sp++;
00072 }
00073
00074 *dp = '\0';
00075 return ttBuf;
00076 }
00077
00082 char *get_short_filename(char *fn) {
00083 char *sfn;
00084 char *p;
00085 if (fn == NULL)
00086 return NULL;
00087
00088 sfn = fn;
00089 p = strchr(sfn, '/');
00090 while (p != NULL) {
00091 sfn = p;
00092 sfn++;
00093 p = strchr(sfn, '/');
00094 }
00095
00096
00097
00098 return sfn;
00099 }