cls.c revision 09fe0b69d3d1e8c8041c9ce99ee77b8b44b5e3b1
#include <ctype.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
/*
* Compare a string to a mask
* Mask characters:
* @ - uppercase letter
* # - lowercase letter
* & - hex digit
* # - digit
* * - swallow remaining characters
* <x> - exact match for any other character
*/
{
int i, ch, d;
d = data[i];
if (ch == '@') {
if (!isupper(d))
return 0;
}
else if (ch == '$') {
if (!islower(d))
return 0;
}
else if (ch == '#') {
if (!isdigit(d))
return 0;
}
else if (ch == '&') {
if (!isxdigit(d))
return 0;
}
else if (ch != d)
return 0;
}
if (mask[i] == '*')
return 1;
else
return (data[i] == '\0');
}
/*
* Converts 8 hex digits to a time integer
*/
static int hex2sec(const char *x)
{
int i, ch;
unsigned int j;
for (i = 0, j = 0; i < 8; i++) {
ch = x[i];
j <<= 4;
j |= ch - '0';
else
}
if (j == 0xffffffff)
return -1; /* so that it works with 8-byte ints */
else
return j;
}
{
int i, ver;
DIR *d;
struct dirent *e;
const char *s;
char line[1035];
unsigned int len;
const char time_format[] = "%e %b %Y %R";
if (argc != 2) {
printf("Usage: cls directory\n");
exit(0);
}
if (d == NULL) {
perror("opendir");
exit(1);
}
for (;;) {
e = readdir(d);
if (e == NULL)
break;
s = e->d_name;
if (s[0] == '.' || s[0] == '#')
continue;
perror("fopen");
continue;
}
perror("fgets");
continue;
}
continue;
}
perror("fgets");
continue;
}
continue;
}
if (date != -1) {
}
else
if (lmod != -1) {
}
else
if (expire != -1) {
}
else
}
closedir(d);
return 0;
}