+
+static char *
+amindexd_nicedate(
+ char * datestamp)
+{
+ static char nice[20];
+ int year, month, day;
+ int hours, minutes, seconds;
+ char date[9], atime[7];
+ int numdate, numtime;
+
+ strncpy(date, datestamp, 8);
+ date[8] = '\0';
+ numdate = atoi(date);
+ year = numdate / 10000;
+ month = (numdate / 100) % 100;
+ day = numdate % 100;
+
+ if(strlen(datestamp) <= 8) {
+ snprintf(nice, SIZEOF(nice), "%4d-%02d-%02d",
+ year, month, day);
+ }
+ else {
+ strncpy(atime, &(datestamp[8]), 6);
+ atime[6] = '\0';
+ numtime = atoi(atime);
+ hours = numtime / 10000;
+ minutes = (numtime / 100) % 100;
+ seconds = numtime % 100;
+
+ snprintf(nice, SIZEOF(nice), "%4d-%02d-%02d-%02d-%02d-%02d",
+ year, month, day, hours, minutes, seconds);
+ }
+
+ return nice;
+}
+
+static int
+cmp_date(
+ const char * date1,
+ const char * date2)
+{
+ return strncmp(date1, date2, strlen(date2));
+}
+
+static char *
+clean_backslash(
+ char *line)
+{
+ char *s = line, *s1, *s2;
+ char *p = line;
+ int i;
+
+ while(*s != '\0') {
+ if (*s == '\\') {
+ s++;
+ s1 = s+1;
+ s2 = s+2;
+ if (*s != '\0' && isdigit(*s) &&
+ *s1 != '\0' && isdigit(*s1) &&
+ *s2 != '\0' && isdigit(*s2)) {
+ /* this is \000, an octal value */
+ i = ((*s)-'0')*64 + ((*s1)-'0')*8 + ((*s2)-'0');
+ *p++ = i;
+ s += 3;
+ } else if (*s == '\\') { /* we remove one / */
+ *p++ = *s++;
+ } else { /* we keep the / */
+ *p++ = '\\';
+ *p++ = *s++;
+ }
+ } else {
+ *p++ = *s++;
+ }
+ }
+ *p = '\0';
+
+ return line;
+}