* file named AUTHORS, in the root directory of this distribution.
*/
/*
- * $Id: set_commands.c,v 1.11.2.3.4.2.2.5.2.2 2004/02/11 13:15:24 martinea Exp $
+ * $Id: set_commands.c,v 1.26 2006/07/05 13:14:58 martinea Exp $
*
* implements the "set" commands in amrecover
*/
#endif /* SAMBA_CLIENT */
/* sets a date, mapping given date into standard form if needed */
-int set_date(date)
-char *date;
+int
+set_date(
+ char * date)
{
char *cmd = NULL;
}
}
amfree(cmd);
-
return 0;
}
-void set_host(host)
-char *host;
+void
+set_host(
+ const char *host)
{
char *cmd = NULL;
struct hostent *hp;
amfree(cmd);
}
+void
+list_host(void)
+{
+ char *cmd = NULL;
+
+ cmd = stralloc("LISTHOST");
+ if (converse(cmd) == -1)
+ exit(1);
+ amfree(cmd);
+}
-void set_disk(dsk, mtpt)
-char *dsk;
-char *mtpt;
+void
+set_disk(
+ char * dsk,
+ char * mtpt)
{
char *cmd = NULL;
}
}
-void list_disk(amdevice)
-char *amdevice;
+void
+list_disk(
+ char * amdevice)
{
char *cmd = NULL;
}
}
-void cd_glob(glob)
-char *glob;
+void
+cd_glob(
+ char * glob)
{
char *regex;
char *regex_path;
amfree(path_on_disk);
}
-void cd_regex(regex)
-char *regex;
+void
+cd_regex(
+ char * regex)
{
char *s;
amfree(path_on_disk);
}
-void cd_dir(path_on_disk, default_dir)
-char *path_on_disk;
-char *default_dir;
+void
+cd_dir(
+ char * path_on_disk,
+ char * default_dir)
{
char *path_on_disk_slash = NULL;
char *dir = NULL;
dir[strlen(dir)-1] = '\0'; /* remove last / */
/* remove everything before the last / */
dir1 = rindex(dir,'/');
- dir1++;
- dir2 = stralloc(dir1);
- amfree(dir);
- dir = dir2;
+ if (dir1) {
+ dir1++;
+ dir2 = stralloc(dir1);
+ amfree(dir);
+ dir = dir2;
+ }
}
}
}
amfree(dir);
}
-void set_directory(dir)
-char *dir;
+void
+set_directory(
+ char * dir)
{
char *cmd = NULL;
char *new_dir = NULL;
if(strcmp(dir,".")==0) {
show_directory(); /* say where we are */
return;
+ /*NOTREACHED*/
}
if (disk_name == NULL) {
printf("Must select disk before setting directory\n");
return;
+ /*NOTREACHED*/
}
ldir = stralloc(dir);
mount_point);
amfree(ldir);
return;
+ /*NOTREACHED*/
}
new_dir = stralloc(ldir+strlen(mount_point));
if (strlen(new_dir) == 0) {
/* at top of disk */
printf("Invalid directory - Can't cd outside mount point \"%s\"\n",
mount_point);
+ /*@ignore@*/
amfree(new_dir);
+ /*@end@*/
amfree(ldir);
return;
+ /*NOTREACHED*/
}
de = strrchr(new_dir, '/'); /* always at least 1 */
if (de == new_dir)
*de = '\0';
}
} else {
+ /*@ignore@*/
if (strcmp(new_dir, "/") != 0) {
strappend(new_dir, "/");
}
strappend(new_dir, ldir);
+ /*@end@*/
}
}
cmd = stralloc2("OISD ", new_dir);
- if (exchange(cmd) == -1)
+ if (exchange(cmd) == -1) {
exit(1);
+ /*NOTREACHED*/
+ }
amfree(cmd);
+
if (server_happy())
{
disk_path = newstralloc(disk_path, new_dir);
printf("Invalid directory - %s\n", dir);
}
+ /*@ignore@*/
amfree(new_dir);
amfree(ldir);
+ /*@end@*/
}
/* prints the current working directory */
-void show_directory P((void))
+void
+show_directory(void)
{
if (mount_point == NULL || disk_path == NULL)
printf("Must select disk first\n");
/* set the tape server and device */
-void set_tape (tape)
- char *tape;
+void
+set_tape(
+ char * tape)
{
char *tapedev = strchr(tape, ':');
server_name);
}
-void set_mode (mode)
-int mode;
+void
+set_mode(
+ int mode)
{
#ifdef SAMBA_CLIENT
if (mode == SAMBA_SMBCLIENT) {
samba_extract_method = SAMBA_TAR;
}
}
+#else
+ (void)mode; /* Quiet unused parameter warning */
#endif /* SAMBA_CLIENT */
}
-void show_mode (void)
+void
+show_mode(void)
{
#ifdef SAMBA_CLIENT
printf ("SAMBA dumps are extracted ");