Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Utility routines. |
| 3 | * |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame^] | 4 | * Copyright (C) tons of folks. Tracking down who wrote what |
| 5 | * isn't something I'm going to worry about... If you wrote something |
| 6 | * here, please feel free to acknowledge your work. |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 7 | * |
| 8 | * This program is free software; you can redistribute it and/or modify |
| 9 | * it under the terms of the GNU General Public License as published by |
| 10 | * the Free Software Foundation; either version 2 of the License, or |
| 11 | * (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 16 | * General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | * |
| 22 | * Based in part on code from sash, Copyright (c) 1999 by David I. Bell |
| 23 | * Permission has been granted to redistribute this code under the GPL. |
| 24 | * |
| 25 | */ |
| 26 | |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 27 | #include "internal.h" |
| 28 | #include <stdio.h> |
| 29 | #include <string.h> |
| 30 | #include <errno.h> |
| 31 | #include <fcntl.h> |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 32 | #include <dirent.h> |
| 33 | #include <time.h> |
| 34 | #include <utime.h> |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 35 | #include <sys/stat.h> |
| 36 | #include <unistd.h> |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 37 | #include <ctype.h> |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 38 | |
Eric Andersen | b0e9a70 | 1999-10-18 22:28:26 +0000 | [diff] [blame] | 39 | /* volatile so gcc knows this is the enod of the line */ |
| 40 | volatile void usage(const char *usage) |
| 41 | { |
| 42 | fprintf(stderr, "Usage: %s\n", usage); |
| 43 | exit(FALSE); |
| 44 | } |
| 45 | |
| 46 | |
Eric Andersen | d23f9ba | 1999-10-20 19:18:15 +0000 | [diff] [blame] | 47 | #if defined (BB_INIT) || defined (BB_PS) |
| 48 | |
| 49 | /* Returns kernel version encoded as major*65536 + minor*256 + patch, |
| 50 | * so, for example, to check if the kernel is greater than 2.2.11: |
| 51 | * if (get_kernel_revision() <= 2*65536+2*256+11) { <stuff> } |
| 52 | */ |
| 53 | int |
| 54 | get_kernel_revision() |
| 55 | { |
| 56 | FILE *f; |
| 57 | int major=0, minor=0, patch=0; |
| 58 | |
| 59 | f = fopen("/proc/sys/kernel/osrelease","r"); |
| 60 | fscanf(f,"%d.%d.%d",&major,&minor,&patch); |
| 61 | fclose(f); |
| 62 | return major*65536 + minor*256 + patch; |
| 63 | } |
| 64 | |
| 65 | #endif |
| 66 | |
| 67 | |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 68 | |
| 69 | #if defined (BB_CP) || defined (BB_MV) |
| 70 | /* |
| 71 | * Return TRUE if a fileName is a directory. |
| 72 | * Nonexistant files return FALSE. |
| 73 | */ |
| 74 | int isDirectory(const char *name) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 75 | { |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 76 | struct stat statBuf; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 77 | |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 78 | if (stat(name, &statBuf) < 0) |
| 79 | return FALSE; |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 80 | if (S_ISDIR(statBuf.st_mode)) |
| 81 | return TRUE; |
| 82 | return(FALSE); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 83 | } |
| 84 | |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 85 | |
| 86 | /* |
| 87 | * Copy one file to another, while possibly preserving its modes, times, |
| 88 | * and modes. Returns TRUE if successful, or FALSE on a failure with an |
| 89 | * error message output. (Failure is not indicted if the attributes cannot |
| 90 | * be set.) |
Eric Andersen | c499601 | 1999-10-20 22:08:37 +0000 | [diff] [blame^] | 91 | * -Erik Andersen |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 92 | */ |
| 93 | int |
Eric Andersen | 3c16382 | 1999-10-14 22:16:57 +0000 | [diff] [blame] | 94 | copyFile( const char *srcName, const char *destName, |
| 95 | int setModes, int followLinks) |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 96 | { |
| 97 | int rfd; |
| 98 | int wfd; |
| 99 | int rcc; |
| 100 | int result; |
| 101 | char buf[BUF_SIZE]; |
| 102 | struct stat srcStatBuf; |
| 103 | struct stat dstStatBuf; |
| 104 | struct utimbuf times; |
| 105 | |
| 106 | if (followLinks == FALSE) |
| 107 | result = stat(srcName, &srcStatBuf); |
| 108 | else |
| 109 | result = lstat(srcName, &srcStatBuf); |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 110 | if (result < 0) { |
| 111 | perror(srcName); |
| 112 | return FALSE; |
| 113 | } |
| 114 | |
| 115 | if (followLinks == FALSE) |
| 116 | result = stat(destName, &dstStatBuf); |
| 117 | else |
| 118 | result = lstat(destName, &dstStatBuf); |
| 119 | if (result < 0) { |
| 120 | dstStatBuf.st_ino = -1; |
| 121 | dstStatBuf.st_dev = -1; |
| 122 | } |
| 123 | |
| 124 | if ((srcStatBuf.st_dev == dstStatBuf.st_dev) && |
| 125 | (srcStatBuf.st_ino == dstStatBuf.st_ino)) { |
| 126 | fprintf(stderr, "Copying file \"%s\" to itself\n", srcName); |
| 127 | return FALSE; |
| 128 | } |
| 129 | |
| 130 | if (S_ISDIR(srcStatBuf.st_mode)) { |
| 131 | //fprintf(stderr, "copying directory %s to %s\n", srcName, destName); |
| 132 | /* Make sure the directory is writable */ |
| 133 | if (mkdir(destName, 0777777 ^ umask(0))) { |
| 134 | perror(destName); |
| 135 | return (FALSE); |
| 136 | } |
| 137 | } else if (S_ISLNK(srcStatBuf.st_mode)) { |
| 138 | char *link_val; |
| 139 | int link_size; |
| 140 | |
| 141 | //fprintf(stderr, "copying link %s to %s\n", srcName, destName); |
| 142 | link_val = (char *) alloca(PATH_MAX + 2); |
| 143 | link_size = readlink(srcName, link_val, PATH_MAX + 1); |
| 144 | if (link_size < 0) { |
| 145 | perror(srcName); |
| 146 | return (FALSE); |
| 147 | } |
| 148 | link_val[link_size] = '\0'; |
Eric Andersen | 3c16382 | 1999-10-14 22:16:57 +0000 | [diff] [blame] | 149 | link_size = symlink(link_val, destName); |
| 150 | if (link_size != 0) { |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 151 | perror(destName); |
| 152 | return (FALSE); |
| 153 | } |
| 154 | } else if (S_ISFIFO(srcStatBuf.st_mode)) { |
| 155 | //fprintf(stderr, "copying fifo %s to %s\n", srcName, destName); |
| 156 | if (mkfifo(destName, 644)) { |
| 157 | perror(destName); |
| 158 | return (FALSE); |
| 159 | } |
| 160 | } else if (S_ISBLK(srcStatBuf.st_mode) || S_ISCHR(srcStatBuf.st_mode) |
| 161 | || S_ISSOCK (srcStatBuf.st_mode)) { |
| 162 | //fprintf(stderr, "copying soc, blk, or chr %s to %s\n", srcName, destName); |
| 163 | if (mknod(destName, srcStatBuf.st_mode, srcStatBuf.st_rdev)) { |
| 164 | perror(destName); |
| 165 | return (FALSE); |
| 166 | } |
| 167 | } else if (S_ISREG(srcStatBuf.st_mode)) { |
| 168 | //fprintf(stderr, "copying regular file %s to %s\n", srcName, destName); |
| 169 | rfd = open(srcName, O_RDONLY); |
| 170 | if (rfd < 0) { |
| 171 | perror(srcName); |
| 172 | return FALSE; |
| 173 | } |
| 174 | |
| 175 | wfd = creat(destName, srcStatBuf.st_mode); |
| 176 | if (wfd < 0) { |
| 177 | perror(destName); |
| 178 | close(rfd); |
| 179 | return FALSE; |
| 180 | } |
| 181 | |
| 182 | while ((rcc = read(rfd, buf, sizeof(buf))) > 0) { |
| 183 | if (fullWrite(wfd, buf, rcc) < 0) |
| 184 | goto error_exit; |
| 185 | } |
| 186 | if (rcc < 0) { |
| 187 | goto error_exit; |
| 188 | } |
| 189 | |
| 190 | close(rfd); |
| 191 | if (close(wfd) < 0) { |
| 192 | return FALSE; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | if (setModes == TRUE) { |
| 197 | //fprintf(stderr, "Setting permissions for %s\n", destName); |
| 198 | chmod(destName, srcStatBuf.st_mode); |
| 199 | if (followLinks == TRUE) |
| 200 | chown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); |
| 201 | else |
| 202 | lchown(destName, srcStatBuf.st_uid, srcStatBuf.st_gid); |
| 203 | |
| 204 | times.actime = srcStatBuf.st_atime; |
| 205 | times.modtime = srcStatBuf.st_mtime; |
| 206 | |
| 207 | utime(destName, ×); |
| 208 | } |
| 209 | |
| 210 | return TRUE; |
| 211 | |
| 212 | |
| 213 | error_exit: |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 214 | perror(destName); |
| 215 | close(rfd); |
| 216 | close(wfd); |
| 217 | |
| 218 | return FALSE; |
| 219 | } |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 220 | #endif |
| 221 | |
| 222 | |
| 223 | |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame] | 224 | #ifdef BB_TAR |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 225 | /* |
| 226 | * Return the standard ls-like mode string from a file mode. |
| 227 | * This is static and so is overwritten on each call. |
| 228 | */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 229 | const char *modeString(int mode) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 230 | { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 231 | static char buf[12]; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 232 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 233 | strcpy(buf, "----------"); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 234 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 235 | /* |
| 236 | * Fill in the file type. |
| 237 | */ |
| 238 | if (S_ISDIR(mode)) |
| 239 | buf[0] = 'd'; |
| 240 | if (S_ISCHR(mode)) |
| 241 | buf[0] = 'c'; |
| 242 | if (S_ISBLK(mode)) |
| 243 | buf[0] = 'b'; |
| 244 | if (S_ISFIFO(mode)) |
| 245 | buf[0] = 'p'; |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 246 | if (S_ISLNK(mode)) |
| 247 | buf[0] = 'l'; |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 248 | if (S_ISSOCK(mode)) |
| 249 | buf[0] = 's'; |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 250 | /* |
| 251 | * Now fill in the normal file permissions. |
| 252 | */ |
| 253 | if (mode & S_IRUSR) |
| 254 | buf[1] = 'r'; |
| 255 | if (mode & S_IWUSR) |
| 256 | buf[2] = 'w'; |
| 257 | if (mode & S_IXUSR) |
| 258 | buf[3] = 'x'; |
| 259 | if (mode & S_IRGRP) |
| 260 | buf[4] = 'r'; |
| 261 | if (mode & S_IWGRP) |
| 262 | buf[5] = 'w'; |
| 263 | if (mode & S_IXGRP) |
| 264 | buf[6] = 'x'; |
| 265 | if (mode & S_IROTH) |
| 266 | buf[7] = 'r'; |
| 267 | if (mode & S_IWOTH) |
| 268 | buf[8] = 'w'; |
| 269 | if (mode & S_IXOTH) |
| 270 | buf[9] = 'x'; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 271 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 272 | /* |
| 273 | * Finally fill in magic stuff like suid and sticky text. |
| 274 | */ |
| 275 | if (mode & S_ISUID) |
| 276 | buf[3] = ((mode & S_IXUSR) ? 's' : 'S'); |
| 277 | if (mode & S_ISGID) |
| 278 | buf[6] = ((mode & S_IXGRP) ? 's' : 'S'); |
| 279 | if (mode & S_ISVTX) |
| 280 | buf[9] = ((mode & S_IXOTH) ? 't' : 'T'); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 281 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 282 | return buf; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 283 | } |
| 284 | |
| 285 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 286 | /* |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 287 | * Get the time string to be used for a file. |
| 288 | * This is down to the minute for new files, but only the date for old files. |
| 289 | * The string is returned from a static buffer, and so is overwritten for |
| 290 | * each call. |
| 291 | */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 292 | const char *timeString(time_t timeVal) |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 293 | { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 294 | time_t now; |
| 295 | char *str; |
| 296 | static char buf[26]; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 297 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 298 | time(&now); |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 299 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 300 | str = ctime(&timeVal); |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 301 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 302 | strcpy(buf, &str[4]); |
| 303 | buf[12] = '\0'; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 304 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 305 | if ((timeVal > now) || (timeVal < now - 365 * 24 * 60 * 60L)) { |
| 306 | strcpy(&buf[7], &str[20]); |
| 307 | buf[11] = '\0'; |
| 308 | } |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 309 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 310 | return buf; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 311 | } |
| 312 | |
| 313 | |
| 314 | /* |
| 315 | * Routine to see if a text string is matched by a wildcard pattern. |
| 316 | * Returns TRUE if the text is matched, or FALSE if it is not matched |
| 317 | * or if the pattern is invalid. |
| 318 | * * matches zero or more characters |
| 319 | * ? matches a single character |
| 320 | * [abc] matches 'a', 'b' or 'c' |
| 321 | * \c quotes character c |
| 322 | * Adapted from code written by Ingo Wilken. |
| 323 | */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 324 | int match(const char *text, const char *pattern) |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 325 | { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 326 | const char *retryPat; |
| 327 | const char *retryText; |
| 328 | int ch; |
| 329 | int found; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 330 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 331 | retryPat = NULL; |
| 332 | retryText = NULL; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 333 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 334 | while (*text || *pattern) { |
| 335 | ch = *pattern++; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 336 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 337 | switch (ch) { |
| 338 | case '*': |
| 339 | retryPat = pattern; |
| 340 | retryText = text; |
| 341 | break; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 342 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 343 | case '[': |
| 344 | found = FALSE; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 345 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 346 | while ((ch = *pattern++) != ']') { |
| 347 | if (ch == '\\') |
| 348 | ch = *pattern++; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 349 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 350 | if (ch == '\0') |
| 351 | return FALSE; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 352 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 353 | if (*text == ch) |
| 354 | found = TRUE; |
| 355 | } |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 356 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 357 | if (!found) { |
| 358 | pattern = retryPat; |
| 359 | text = ++retryText; |
| 360 | } |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 361 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 362 | /* fall into next case */ |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 363 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 364 | case '?': |
| 365 | if (*text++ == '\0') |
| 366 | return FALSE; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 367 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 368 | break; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 369 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 370 | case '\\': |
| 371 | ch = *pattern++; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 372 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 373 | if (ch == '\0') |
| 374 | return FALSE; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 375 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 376 | /* fall into next case */ |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 377 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 378 | default: |
| 379 | if (*text == ch) { |
| 380 | if (*text) |
| 381 | text++; |
| 382 | break; |
| 383 | } |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 384 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 385 | if (*text) { |
| 386 | pattern = retryPat; |
| 387 | text = ++retryText; |
| 388 | break; |
| 389 | } |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 390 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 391 | return FALSE; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 392 | } |
| 393 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 394 | if (pattern == NULL) |
| 395 | return FALSE; |
| 396 | } |
| 397 | |
| 398 | return TRUE; |
Eric Andersen | 17d49ef | 1999-10-06 20:25:32 +0000 | [diff] [blame] | 399 | } |
| 400 | |
| 401 | |
| 402 | /* |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 403 | * Write all of the supplied buffer out to a file. |
| 404 | * This does multiple writes as necessary. |
| 405 | * Returns the amount written, or -1 on an error. |
| 406 | */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 407 | int fullWrite(int fd, const char *buf, int len) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 408 | { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 409 | int cc; |
| 410 | int total; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 411 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 412 | total = 0; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 413 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 414 | while (len > 0) { |
| 415 | cc = write(fd, buf, len); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 416 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 417 | if (cc < 0) |
| 418 | return -1; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 419 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 420 | buf += cc; |
| 421 | total += cc; |
| 422 | len -= cc; |
| 423 | } |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 424 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 425 | return total; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 426 | } |
| 427 | |
| 428 | |
| 429 | /* |
| 430 | * Read all of the supplied buffer from a file. |
| 431 | * This does multiple reads as necessary. |
| 432 | * Returns the amount read, or -1 on an error. |
| 433 | * A short read is returned on an end of file. |
| 434 | */ |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 435 | int fullRead(int fd, char *buf, int len) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 436 | { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 437 | int cc; |
| 438 | int total; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 439 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 440 | total = 0; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 441 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 442 | while (len > 0) { |
| 443 | cc = read(fd, buf, len); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 444 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 445 | if (cc < 0) |
| 446 | return -1; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 447 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 448 | if (cc == 0) |
| 449 | break; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 450 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 451 | buf += cc; |
| 452 | total += cc; |
| 453 | len -= cc; |
| 454 | } |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 455 | |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 456 | return total; |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 457 | } |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 458 | #endif |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 459 | |
| 460 | |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 461 | #if defined (BB_CHOWN) || defined (BB_CP) || defined (BB_FIND) || defined (BB_LS) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 462 | /* |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 463 | * Walk down all the directories under the specified |
| 464 | * location, and do something (something specified |
| 465 | * by the fileAction and dirAction function pointers). |
Eric Andersen | b7a1a75 | 1999-10-19 23:37:14 +0000 | [diff] [blame] | 466 | * |
| 467 | * TODO: check if ftw(3) can replace this to reduce code size... |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 468 | */ |
| 469 | int |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame] | 470 | recursiveAction(const char *fileName, int recurse, int followLinks, int delayDirAction, |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 471 | int (*fileAction) (const char *fileName, struct stat* statbuf), |
| 472 | int (*dirAction) (const char *fileName, struct stat* statbuf)) |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 473 | { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 474 | int status; |
| 475 | struct stat statbuf; |
| 476 | struct dirent *next; |
Eric Andersen | 9d3aba7 | 1999-10-06 09:04:55 +0000 | [diff] [blame] | 477 | |
Eric Andersen | 3c16382 | 1999-10-14 22:16:57 +0000 | [diff] [blame] | 478 | if (followLinks == FALSE) |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 479 | status = stat(fileName, &statbuf); |
Eric Andersen | 3c16382 | 1999-10-14 22:16:57 +0000 | [diff] [blame] | 480 | else |
| 481 | status = lstat(fileName, &statbuf); |
| 482 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 483 | if (status < 0) { |
| 484 | perror(fileName); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 485 | return (FALSE); |
| 486 | } |
| 487 | |
| 488 | if (recurse == FALSE) { |
| 489 | if (S_ISDIR(statbuf.st_mode)) { |
Eric Andersen | 3c16382 | 1999-10-14 22:16:57 +0000 | [diff] [blame] | 490 | if (dirAction != NULL) |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 491 | return (dirAction(fileName, &statbuf)); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 492 | else |
Eric Andersen | 3c16382 | 1999-10-14 22:16:57 +0000 | [diff] [blame] | 493 | return (TRUE); |
| 494 | } |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 495 | } |
| 496 | |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 497 | if (S_ISDIR(statbuf.st_mode)) { |
| 498 | DIR *dir; |
| 499 | dir = opendir(fileName); |
| 500 | if (!dir) { |
| 501 | perror(fileName); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 502 | return (FALSE); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 503 | } |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame] | 504 | if (dirAction != NULL && delayDirAction == FALSE) { |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 505 | status = dirAction(fileName, &statbuf); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 506 | if (status == FALSE) { |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 507 | perror(fileName); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 508 | return (FALSE); |
| 509 | } |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 510 | } |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 511 | while ((next = readdir(dir)) != NULL) { |
| 512 | char nextFile[NAME_MAX]; |
| 513 | if ((strcmp(next->d_name, "..") == 0) |
| 514 | || (strcmp(next->d_name, ".") == 0)) { |
| 515 | continue; |
| 516 | } |
| 517 | sprintf(nextFile, "%s/%s", fileName, next->d_name); |
| 518 | status = |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame] | 519 | recursiveAction(nextFile, TRUE, followLinks, delayDirAction, |
| 520 | fileAction, dirAction); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 521 | if (status < 0) { |
| 522 | closedir(dir); |
| 523 | return (FALSE); |
| 524 | } |
| 525 | } |
| 526 | status = closedir(dir); |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 527 | if (status < 0) { |
| 528 | perror(fileName); |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 529 | return (FALSE); |
Eric Andersen | 2b69c40 | 1999-10-05 22:58:32 +0000 | [diff] [blame] | 530 | } |
Eric Andersen | bed30e9 | 1999-10-18 19:02:32 +0000 | [diff] [blame] | 531 | if (dirAction != NULL && delayDirAction == TRUE) { |
| 532 | status = dirAction(fileName, &statbuf); |
| 533 | if (status == FALSE) { |
| 534 | perror(fileName); |
| 535 | return (FALSE); |
| 536 | } |
| 537 | } |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 538 | } else { |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 539 | if (fileAction == NULL) |
| 540 | return (TRUE); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 541 | else |
Eric Andersen | 9b58718 | 1999-10-17 05:43:39 +0000 | [diff] [blame] | 542 | return (fileAction(fileName, &statbuf)); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 543 | } |
Eric Andersen | f811e07 | 1999-10-09 00:25:00 +0000 | [diff] [blame] | 544 | return (TRUE); |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 545 | } |
| 546 | |
Eric Andersen | c6cb79d | 1999-10-13 18:01:10 +0000 | [diff] [blame] | 547 | #endif |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 548 | |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 549 | |
| 550 | |
| 551 | #if defined (BB_TAR) || defined (BB_MKDIR) |
| 552 | /* |
| 553 | * Attempt to create the directories along the specified path, except for |
| 554 | * the final component. The mode is given for the final directory only, |
| 555 | * while all previous ones get default protections. Errors are not reported |
| 556 | * here, as failures to restore files can be reported later. |
| 557 | */ |
| 558 | extern void createPath (const char *name, int mode) |
| 559 | { |
| 560 | char *cp; |
| 561 | char *cpOld; |
| 562 | char buf[NAME_MAX]; |
| 563 | |
| 564 | strcpy (buf, name); |
| 565 | |
| 566 | cp = strchr (buf, '/'); |
| 567 | |
| 568 | while (cp) { |
| 569 | cpOld = cp; |
| 570 | cp = strchr (cp + 1, '/'); |
| 571 | |
| 572 | *cpOld = '\0'; |
| 573 | |
| 574 | if (mkdir (buf, cp ? 0777 : mode) == 0) |
| 575 | printf ("Directory \"%s\" created\n", buf); |
| 576 | |
| 577 | *cpOld = '/'; |
| 578 | } |
| 579 | } |
| 580 | #endif |
| 581 | |
| 582 | |
| 583 | |
| 584 | #if defined (BB_CHMOD_CHOWN_CHGRP) || defined (BB_MKDIR) |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 585 | /* [ugoa]{+|-|=}[rwxst] */ |
| 586 | |
| 587 | |
| 588 | |
| 589 | extern int |
| 590 | parse_mode( const char* s, mode_t* theMode) |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 591 | { |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 592 | mode_t andMode = S_ISVTX|S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
| 593 | mode_t orMode = 0; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 594 | mode_t mode = 0; |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 595 | mode_t groups = 0; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 596 | char type; |
| 597 | char c; |
| 598 | |
| 599 | do { |
| 600 | for ( ; ; ) { |
| 601 | switch ( c = *s++ ) { |
| 602 | case '\0': |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 603 | return -1; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 604 | case 'u': |
| 605 | groups |= S_ISUID|S_IRWXU; |
| 606 | continue; |
| 607 | case 'g': |
| 608 | groups |= S_ISGID|S_IRWXG; |
| 609 | continue; |
| 610 | case 'o': |
| 611 | groups |= S_IRWXO; |
| 612 | continue; |
| 613 | case 'a': |
| 614 | groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
| 615 | continue; |
| 616 | case '+': |
| 617 | case '=': |
| 618 | case '-': |
| 619 | type = c; |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 620 | if ( groups == 0 ) /* The default is "all" */ |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 621 | groups |= S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO; |
| 622 | break; |
| 623 | default: |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 624 | if ( isdigit(c) && c >= '0' && c <= '7' && mode == 0 && groups == 0 ) { |
| 625 | andMode = 0; |
| 626 | orMode = strtol(--s, NULL, 8); |
| 627 | *theMode &= andMode; |
| 628 | *theMode |= orMode; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 629 | return (TRUE); |
| 630 | } |
| 631 | else |
| 632 | return (FALSE); |
| 633 | } |
| 634 | break; |
| 635 | } |
| 636 | |
| 637 | while ( (c = *s++) != '\0' ) { |
| 638 | switch ( c ) { |
| 639 | case ',': |
| 640 | break; |
| 641 | case 'r': |
| 642 | mode |= S_IRUSR|S_IRGRP|S_IROTH; |
| 643 | continue; |
| 644 | case 'w': |
| 645 | mode |= S_IWUSR|S_IWGRP|S_IWOTH; |
| 646 | continue; |
| 647 | case 'x': |
| 648 | mode |= S_IXUSR|S_IXGRP|S_IXOTH; |
| 649 | continue; |
| 650 | case 's': |
| 651 | mode |= S_IXGRP|S_ISUID|S_ISGID; |
| 652 | continue; |
| 653 | case 't': |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 654 | mode |= 0; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 655 | continue; |
| 656 | default: |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 657 | *theMode &= andMode; |
| 658 | *theMode |= orMode; |
| 659 | return( TRUE); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 660 | } |
| 661 | break; |
| 662 | } |
| 663 | switch ( type ) { |
| 664 | case '=': |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 665 | andMode &= ~(groups); |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 666 | /* fall through */ |
| 667 | case '+': |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 668 | orMode |= mode & groups; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 669 | break; |
| 670 | case '-': |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 671 | andMode &= ~(mode & groups); |
| 672 | orMode &= andMode; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 673 | break; |
| 674 | } |
| 675 | } while ( c == ',' ); |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 676 | *theMode &= andMode; |
| 677 | *theMode |= orMode; |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 678 | return (TRUE); |
| 679 | } |
Eric Andersen | ce8f3b9 | 1999-10-20 07:03:36 +0000 | [diff] [blame] | 680 | |
| 681 | |
Eric Andersen | f6be944 | 1999-10-13 21:12:06 +0000 | [diff] [blame] | 682 | #endif |
| 683 | |
Eric Andersen | e674eb7 | 1999-10-19 20:52:57 +0000 | [diff] [blame] | 684 | |
| 685 | |
Eric Andersen | d23f9ba | 1999-10-20 19:18:15 +0000 | [diff] [blame] | 686 | |
| 687 | |
| 688 | |
| 689 | |
| 690 | #if defined (BB_CHMOD_CHOWN_CHGRP) || defined (BB_PS) |
| 691 | |
| 692 | /* Use this to avoid needing the glibc NSS stuff |
| 693 | * This uses storage buf to hold things. |
| 694 | * */ |
| 695 | uid_t |
| 696 | my_getid(const char *filename, char *name, uid_t id) |
| 697 | { |
| 698 | FILE *stream; |
| 699 | char *rname, *start, *end, buf[128]; |
| 700 | uid_t rid; |
| 701 | |
| 702 | stream=fopen(filename,"r"); |
| 703 | |
| 704 | while (fgets (buf, 128, stream) != NULL) { |
| 705 | if (buf[0] == '#') |
| 706 | continue; |
| 707 | |
| 708 | start = buf; |
| 709 | end = strchr (start, ':'); |
| 710 | if (end == NULL) |
| 711 | continue; |
| 712 | *end = '\0'; |
| 713 | rname = start; |
| 714 | |
| 715 | start = end + 1; |
| 716 | end = strchr (start, ':'); |
| 717 | if (end == NULL) |
| 718 | continue; |
| 719 | |
| 720 | start = end + 1; |
| 721 | rid = (uid_t) strtol (start, &end, 10); |
| 722 | if (end == start) |
| 723 | continue; |
| 724 | |
| 725 | if (name) { |
| 726 | if (0 == strcmp(rname, name)) |
| 727 | return( rid); |
| 728 | } |
| 729 | if ( id != -1 && id == rid ) { |
| 730 | strncpy(name, rname, 8); |
| 731 | return( TRUE); |
| 732 | } |
| 733 | } |
| 734 | fclose(stream); |
| 735 | return (-1); |
| 736 | } |
| 737 | |
| 738 | uid_t |
| 739 | my_getpwnam(char *name) |
| 740 | { |
| 741 | return my_getid("/etc/passwd", name, -1); |
| 742 | } |
| 743 | |
| 744 | gid_t |
| 745 | my_getgrnam(char *name) |
| 746 | { |
| 747 | return my_getid("/etc/group", name, -1); |
| 748 | } |
| 749 | |
| 750 | void |
| 751 | my_getpwuid(char* name, uid_t uid) |
| 752 | { |
| 753 | my_getid("/etc/passwd", name, uid); |
| 754 | } |
| 755 | |
| 756 | void |
| 757 | my_getgrgid(char* group, gid_t gid) |
| 758 | { |
| 759 | my_getid("/etc/group", group, gid); |
| 760 | } |
| 761 | |
| 762 | |
| 763 | #endif |
| 764 | |
| 765 | |
Eric Andersen | cc8ed39 | 1999-10-05 16:24:54 +0000 | [diff] [blame] | 766 | /* END CODE */ |