| Line | Source | Count |
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | | - |
| 13 | | - |
| 14 | | - |
| 15 | | - |
| 16 | | - |
| 17 | | - |
| 18 | | - |
| 19 | | - |
| 20 | | - |
| 21 | #include <config.h> | - |
| 22 | | - |
| 23 | #include <stdio.h> | - |
| 24 | #include <errno.h> | - |
| 25 | | - |
| 26 | #include <bashtypes.h> | - |
| 27 | #include <posixstat.h> | - |
| 28 | #include <posixdir.h> | - |
| 29 | #include <bashansi.h> | - |
| 30 | | - |
| 31 | #if defined (HAVE_SYS_PARAM_H) | - |
| 32 | # include <sys/param.h> | - |
| 33 | #endif | - |
| 34 | | - |
| 35 | #include <maxpath.h> | - |
| 36 | | - |
| 37 | | - |
| 38 | | - |
| 39 | | - |
| 40 | | - |
| 41 | | - |
| 42 | | - |
| 43 | | - |
| 44 | | - |
| 45 | | - |
| 46 | | - |
| 47 | | - |
| 48 | | - |
| 49 | | - |
| 50 | | - |
| 51 | | - |
| 52 | | - |
| 53 | | - |
| 54 | int | - |
| 55 | mailstat(path, st) | - |
| 56 | const char *path; | - |
| 57 | struct stat *st; | - |
| 58 | { | - |
| 59 | static struct stat st_new_last, st_ret_last; | - |
| 60 | struct stat st_ret, st_tmp; | - |
| 61 | DIR *dd; | - |
| 62 | struct dirent *fn; | - |
| 63 | char dir[PATH_MAX * 2], file[PATH_MAX * 2]; | - |
| 64 | int i, l; | - |
| 65 | time_t atime, mtime; | - |
| 66 | | - |
| 67 | atime = mtime = 0; | - |
| 68 | | - |
| 69 | | - |
| 70 | if ((i = stat(path, st)) != 0 || S_ISDIR(st->st_mode) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 71 | return i; never executed: return i; | 0 |
| 72 | | - |
| 73 | if (strlen(path) > sizeof(dir) - 5)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 74 | { | - |
| 75 | #ifdef ENAMETOOLONG | - |
| 76 | errno = ENAMETOOLONG; | - |
| 77 | #else | - |
| 78 | errno = EINVAL; | - |
| 79 | #endif | - |
| 80 | return -1; never executed: return -1; | 0 |
| 81 | } | - |
| 82 | | - |
| 83 | st_ret = *st; | - |
| 84 | st_ret.st_nlink = 1; | - |
| 85 | st_ret.st_size = 0; | - |
| 86 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS | - |
| 87 | st_ret.st_blocks = 0; | - |
| 88 | #else | - |
| 89 | st_ret.st_nlink = 0; | - |
| 90 | #endif | - |
| 91 | st_ret.st_mode &= ~S_IFDIR; | - |
| 92 | st_ret.st_mode |= S_IFREG; | - |
| 93 | | - |
| 94 | | - |
| 95 | sprintf(dir, "%s/cur", path); | - |
| 96 | if (stat(dir, &st_tmp) || S_ISDIR(st_tmp.st_mode) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 97 | return 0; never executed: return 0; | 0 |
| 98 | st_ret.st_atime = st_tmp.st_atime; | - |
| 99 | | - |
| 100 | | - |
| 101 | sprintf(dir, "%s/tmp", path); | - |
| 102 | if (stat(dir, &st_tmp) || S_ISDIR(st_tmp.st_mode) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 103 | return 0; never executed: return 0; | 0 |
| 104 | st_ret.st_mtime = st_tmp.st_mtime; | - |
| 105 | | - |
| 106 | | - |
| 107 | sprintf(dir, "%s/new", path); | - |
| 108 | if (stat(dir, &st_tmp) || S_ISDIR(st_tmp.st_mode) == 0)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 109 | return 0; never executed: return 0; | 0 |
| 110 | st_ret.st_mtime = st_tmp.st_mtime; | - |
| 111 | | - |
| 112 | | - |
| 113 | if (st_tmp.st_dev == st_new_last.st_dev &&| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 114 | st_tmp.st_ino == st_new_last.st_ino &&| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 115 | st_tmp.st_atime == st_new_last.st_atime &&| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 116 | st_tmp.st_mtime == st_new_last.st_mtime)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 117 | { | - |
| 118 | *st = st_ret_last; | - |
| 119 | return 0; never executed: return 0; | 0 |
| 120 | } | - |
| 121 | st_new_last = st_tmp; | - |
| 122 | | - |
| 123 | | - |
| 124 | for (i = 0; i < 2; i++)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 125 | { | - |
| 126 | sprintf(dir, "%s/%s", path, i ? "cur" : "new"); | - |
| 127 | sprintf(file, "%s/", dir); | - |
| 128 | l = strlen(file); | - |
| 129 | if ((dd = opendir(dir)) == NULL)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 130 | return 0; never executed: return 0; | 0 |
| 131 | while ((fn = readdir(dd)) != NULL)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 132 | { | - |
| 133 | if (fn->d_name[0] == '.' || strlen(fn->d_name) + l >= sizeof(file))| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 134 | continue; never executed: continue; | 0 |
| 135 | strcpy(file + l, fn->d_name); | - |
| 136 | if (stat(file, &st_tmp) != 0)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 137 | continue; never executed: continue; | 0 |
| 138 | st_ret.st_size += st_tmp.st_size; | - |
| 139 | #ifdef HAVE_STRUCT_STAT_ST_BLOCKS | - |
| 140 | st_ret.st_blocks++; | - |
| 141 | #else | - |
| 142 | st_ret.st_nlink++; | - |
| 143 | #endif | - |
| 144 | if (st_tmp.st_atime != st_tmp.st_mtime && st_tmp.st_atime > atime)| TRUE | never evaluated | | FALSE | never evaluated |
| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 145 | atime = st_tmp.st_atime; never executed: atime = st_tmp. st_atim.tv_sec ; | 0 |
| 146 | if (st_tmp.st_mtime > mtime)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 147 | mtime = st_tmp.st_mtime; never executed: mtime = st_tmp. st_mtim.tv_sec ; | 0 |
| 148 | } never executed: end of block | 0 |
| 149 | closedir(dd); | - |
| 150 | } never executed: end of block | 0 |
| 151 | | - |
| 152 | | - |
| 153 | st_ret.st_atime = atime; | - |
| 154 | if (mtime)| TRUE | never evaluated | | FALSE | never evaluated |
| 0 |
| 155 | st_ret.st_mtime = mtime; never executed: st_ret. st_mtim.tv_sec = mtime; | 0 |
| 156 | | - |
| 157 | *st = st_ret_last = st_ret; | - |
| 158 | return 0; never executed: return 0; | 0 |
| 159 | } | - |
| | |