const time_t now = time(NULL);
int i;
- if (glob("README*", 0, NULL, &pglob) == 0) {
- for (i = 0; i < pglob.gl_pathc; i++) {
- const char * const temp = pglob.gl_pathv[i];
- struct stat buf;
- char str[2048];
+ if (glob("README*", 0, NULL, &pglob) != 0) return;
- char *tm;
+ for (i = 0; i < pglob.gl_pathc; i++) {
+ const char * const temp = pglob.gl_pathv[i];
+ struct stat buf;
+ char str[256];
- if (stat(temp, &buf) == -1) continue;
+ char *tm;
- /* remove trailing LF */
- tm = ctime(&buf.st_mtime);
- tm[strlen(tm) - 1] = 0;
+ if (stat(temp, &buf) == -1) continue;
- sprintf(str, "250-Please read the file %s\r\n"
- "250-\tIt was last modified %s - %ld days ago\r\n",
- temp, tm,
- (now - buf.st_mtime) / 86400);
- send(c->sock, str, strlen(str), 0);
- }
- globfree(&pglob);
- }
+ /* remove trailing LF */
+ tm = ctime(&buf.st_mtime);
+ tm[strlen(tm) - 1] = 0;
+
+ snprintf(str, 256, "250-Please read the file %s\r\n"
+ "250-\tIt was last modified %s - %ld days ago\r\n",
+ temp, tm,
+ (now - buf.st_mtime) / 86400);
+ send(c->sock, str, strlen(str), 0);
+ }
+ globfree(&pglob);
}
#endif