interactive.c (187828) | interactive.c (203155) |
---|---|
1/* 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 30#ifndef lint 31#if 0 32static char sccsid[] = "@(#)interactive.c 8.5 (Berkeley) 5/1/95"; 33#endif 34#endif /* not lint */ 35 36#include <sys/cdefs.h> | 1/* 2 * Copyright (c) 1985, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 20 unchanged lines hidden (view full) --- 29 30#ifndef lint 31#if 0 32static char sccsid[] = "@(#)interactive.c 8.5 (Berkeley) 5/1/95"; 33#endif 34#endif /* not lint */ 35 36#include <sys/cdefs.h> |
37__FBSDID("$FreeBSD: head/sbin/restore/interactive.c 187828 2009-01-28 16:23:21Z imp $"); | 37__FBSDID("$FreeBSD: head/sbin/restore/interactive.c 203155 2010-01-29 10:00:42Z jh $"); |
38 39#include <sys/param.h> 40#include <sys/stat.h> 41 42#include <ufs/ufs/dinode.h> 43#include <ufs/ufs/dir.h> 44#include <protocols/dumprestore.h> 45 --- 32 unchanged lines hidden (view full) --- 78 int argcnt; /* next globbed argument to return */ 79 glob_t glob; /* globbing information */ 80 char *cmd; /* the current command */ 81}; 82 83static char *copynext(char *, char *); 84static int fcmp(const void *, const void *); 85static void formatf(struct afile *, int); | 38 39#include <sys/param.h> 40#include <sys/stat.h> 41 42#include <ufs/ufs/dinode.h> 43#include <ufs/ufs/dir.h> 44#include <protocols/dumprestore.h> 45 --- 32 unchanged lines hidden (view full) --- 78 int argcnt; /* next globbed argument to return */ 79 glob_t glob; /* globbing information */ 80 char *cmd; /* the current command */ 81}; 82 83static char *copynext(char *, char *); 84static int fcmp(const void *, const void *); 85static void formatf(struct afile *, int); |
86static void getcmd(char *, char *, char *, int, struct arglist *); | 86static void getcmd(char *, char *, char *, size_t, struct arglist *); |
87struct dirent *glob_readdir(void *); 88static int glob_stat(const char *, struct stat *); 89static void mkentry(char *, struct direct *, struct afile *); 90static void printlist(char *, char *); 91 92/* 93 * Read and execute commands from the terminal. 94 */ --- 201 unchanged lines hidden (view full) --- 296 * is returned as the argument. If there are arguments 297 * on the line they are returned one at a time on each 298 * successive call to getcmd. Each argument is first assigned 299 * to "name". If it does not start with "/" the pathname in 300 * "curdir" is prepended to it. Finally "canon" is called to 301 * eliminate any embedded ".." components. 302 */ 303static void | 87struct dirent *glob_readdir(void *); 88static int glob_stat(const char *, struct stat *); 89static void mkentry(char *, struct direct *, struct afile *); 90static void printlist(char *, char *); 91 92/* 93 * Read and execute commands from the terminal. 94 */ --- 201 unchanged lines hidden (view full) --- 296 * is returned as the argument. If there are arguments 297 * on the line they are returned one at a time on each 298 * successive call to getcmd. Each argument is first assigned 299 * to "name". If it does not start with "/" the pathname in 300 * "curdir" is prepended to it. Finally "canon" is called to 301 * eliminate any embedded ".." components. 302 */ 303static void |
304getcmd(char *curdir, char *cmd, char *name, int size, struct arglist *ap) | 304getcmd(char *curdir, char *cmd, char *name, size_t size, struct arglist *ap) |
305{ 306 char *cp; 307 static char input[BUFSIZ]; 308 char output[BUFSIZ]; 309# define rawname input /* save space by reusing input buffer */ 310 311 /* 312 * Check to see if still processing arguments. --- 123 unchanged lines hidden (view full) --- 436 return (cp); 437} 438 439/* 440 * Canonicalize file names to always start with ``./'' and 441 * remove any embedded "." and ".." components. 442 */ 443void | 305{ 306 char *cp; 307 static char input[BUFSIZ]; 308 char output[BUFSIZ]; 309# define rawname input /* save space by reusing input buffer */ 310 311 /* 312 * Check to see if still processing arguments. --- 123 unchanged lines hidden (view full) --- 436 return (cp); 437} 438 439/* 440 * Canonicalize file names to always start with ``./'' and 441 * remove any embedded "." and ".." components. 442 */ 443void |
444canon(char *rawname, char *canonname, int len) | 444canon(char *rawname, char *canonname, size_t len) |
445{ 446 char *cp, *np; 447 448 if (strcmp(rawname, ".") == 0 || strncmp(rawname, "./", 2) == 0) 449 (void) strcpy(canonname, ""); 450 else if (rawname[0] == '/') 451 (void) strcpy(canonname, "."); 452 else --- 316 unchanged lines hidden --- | 445{ 446 char *cp, *np; 447 448 if (strcmp(rawname, ".") == 0 || strncmp(rawname, "./", 2) == 0) 449 (void) strcpy(canonname, ""); 450 else if (rawname[0] == '/') 451 (void) strcpy(canonname, "."); 452 else --- 316 unchanged lines hidden --- |