void Ident() { int rc; char name[9]; char buf[256]; TPB tpb; getchoice(0, " Ident ", "Identification tape", NULL, NULL, NULL, NULL); TapeStill ts("/dev/ravt0"); rc = ts.Ident(); endmesg(); if (rc != TSOK) { getchoice(0, " Ident ", "Error identification.", NULL, NULL, NULL, NULL); getchar(); endmesg(); return; } ts.GetTape(&tpb); bzero(name, sizeof(name)); switch(tpb.format) { case FORMAT_K4: case FORMAT_K7: case FORMAT_K7CRC: case FORMAT_RS: strncpy(name, tpb.name, 8); } getchoice(0, " Ident ", name, NULL, NULL, NULL, NULL); // printf("Format:\t%02X\n", tpb.format); getchar(); endmesg(); };
void big_menu (m) { struct b_field *b; register i, j = 1; BOX *left_box; b = batch_entry[batch_n]; lines = cols = wid_h = wid_e = 0; for (i = 0; b[i].header != NULL; i++) { lines++; wid_h = max( wid_h, (int) strlen( b[i].header )); wid_e = max( wid_e, b[i].width ); } cols = wid_h + 2 + wid_e; cols = max (cols, (int) strlen(batch_name[batch_n])); r = (LINES - lines) - 5; c = m ? 3 : (COLS - cols) - 5; endmesg (); if (m) { if (lines == 0) return; left_box = VGetBox (r - 1, c - 1, lines + 4, cols + 4); } else { if (right_box != 0) { VUngetBox (right_box); VFreeBox (right_box); } right_box = VGetBox (r - 1, c - 1, lines + 4, cols + 4); } VStandOut (); VFillBox (r - 1, c - 1, lines + 4, cols + 4, ' '); VStandEnd (); VDrawBox (r, c, lines+2, cols+2); VMPutString (r, (c + (cols + 2 - strlen(batch_name[batch_n])) / 2), batch_name[batch_n]); if (lines == 0) return; drawhdr (b); if (m) { for (i = 0; j != 0; i += j) { if (i >= lines) i = 0; else if (i < 0) i = lines - 1; j = editval1 (b + i, i); VStandOut (); printval (b + i, i); VStandEnd (); } VUngetBox (left_box); VFreeBox (left_box); } VSync (); }
void writeinitfile () { register fd; char fname [NAMESZ]; char buf [BUFSZ]; /* look for ~/.decoini */ snprintf (fname, sizeof(fname), "%s/%s", home, INITFILE); fd = creat (fname, 0600); if (fd < 0) { error ("Cannot create %s", fname); return; } bufp = buf; if (left.view == VIEW_LONG) *bufp++ = 'l', *bufp++ = 'l', *bufp++ = '\n'; else if (left.view == VIEW_WIDE) *bufp++ = 'l', *bufp++ = 'w', *bufp++ = '\n'; else if (left.view == VIEW_FULL) *bufp++ = 'l', *bufp++ = 'f', *bufp++ = '\n'; else if (left.view == VIEW_INFO) *bufp++ = 'l', *bufp++ = 'i', *bufp++ = '\n'; if (right.view == VIEW_LONG) *bufp++ = 'r', *bufp++ = 'l', *bufp++ = '\n'; else if (right.view == VIEW_WIDE) *bufp++ = 'r', *bufp++ = 'w', *bufp++ = '\n'; else if (right.view == VIEW_FULL) *bufp++ = 'r', *bufp++ = 'f', *bufp++ = '\n'; else if (right.view == VIEW_INFO) *bufp++ = 'r', *bufp++ = 'i', *bufp++ = '\n'; if (left.status) *bufp++ = 'l', *bufp++ = 's', *bufp++ = '\n'; if (right.status) *bufp++ = 'r', *bufp++ = 's', *bufp++ = '\n'; switch (left.sort) { case SORTEXT: break; case SORTNAME: *bufp++ = 'l'; *bufp++ = 'o'; *bufp++ = 'n'; *bufp++ = '\n'; break; case SORTTIME: *bufp++ = 'l'; *bufp++ = 'o'; *bufp++ = 't'; *bufp++ = '\n'; break; case SORTSIZE: *bufp++ = 'l'; *bufp++ = 'o'; *bufp++ = 'z'; *bufp++ = '\n'; break; default: *bufp++ = 'l'; *bufp++ = 'o'; *bufp++ = 'u'; *bufp++ = '\n'; break; } switch (right.sort) { case SORTEXT: break; case SORTNAME: *bufp++ = 'r'; *bufp++ = 'o'; *bufp++ = 'n'; *bufp++ = '\n'; break; case SORTTIME: *bufp++ = 'r'; *bufp++ = 'o'; *bufp++ = 't'; *bufp++ = '\n'; break; case SORTSIZE: *bufp++ = 'r'; *bufp++ = 'o'; *bufp++ = 'z'; *bufp++ = '\n'; break; default: *bufp++ = 'r'; *bufp++ = 'o'; *bufp++ = 'u'; *bufp++ = '\n'; break; } if (left.pattern [0]) { *bufp++ = 'l'; *bufp++ = 'p'; strcpy (bufp, left.pattern); while (*bufp++); bufp [-1] = '\n'; } if (right.pattern [0]) { *bufp++ = 'r'; *bufp++ = 'p'; strcpy (bufp, right.pattern); while (*bufp++); bufp [-1] = '\n'; } if (usecshell) *bufp++ = 'c', *bufp++ = '\n'; if (H == LINES-7) *bufp++ = 'f', *bufp++ = '\n'; if (widewin) *bufp++ = 'w', *bufp++ = '\n'; if (! showhidden) *bufp++ = 'h', *bufp++ = '\n'; if (viewraw) *bufp++ = 'e', *bufp++ = 'r', *bufp++ = '\n'; if (viewhex) *bufp++ = 'e', *bufp++ = 'h', *bufp++ = '\n'; if (viewtabs) *bufp++ = 'e', *bufp++ = 't', *bufp++ = '\n'; if (userview) *bufp++ = 'v', *bufp++ = 'b', *bufp++ = '\n'; if (useredit) *bufp++ = 'e', *bufp++ = 'b', *bufp++ = '\n'; if (! left.alignext) *bufp++ = 'l', *bufp++ = 'a', *bufp++ = '\n'; if (! right.alignext) *bufp++ = 'r', *bufp++ = 'a', *bufp++ = '\n'; if (! left.typesort) *bufp++ = 'l', *bufp++ = 't', *bufp++ = '\n'; if (! right.typesort) *bufp++ = 'r', *bufp++ = 't', *bufp++ = '\n'; if (left.revsort) *bufp++ = 'l', *bufp++ = 'r', *bufp++ = '\n'; if (right.revsort) *bufp++ = 'r', *bufp++ = 'r', *bufp++ = '\n'; if (viewname [0]) { *bufp++ = 'v'; *bufp++ = 'n'; strcpy (bufp, viewname); while (*bufp++); bufp [-1] = '\n'; } if (editname [0]) { *bufp++ = 'e'; *bufp++ = 'n'; strcpy (bufp, editname); while (*bufp++); bufp [-1] = '\n'; } if (palette.fg != dflt_palette.fg) { *bufp++ = 'p'; *bufp++ = 'n'; *bufp++ = 'f'; *bufp++ = '0' + palette.fg / 10; *bufp++ = '0' + palette.fg % 10; *bufp++ = '\n'; } if (palette.bg != dflt_palette.bg) { *bufp++ = 'p'; *bufp++ = 'n'; *bufp++ = 'b'; *bufp++ = '0' + palette.bg / 10; *bufp++ = '0' + palette.bg % 10; *bufp++ = '\n'; } if (palette.revfg != dflt_palette.revfg) { *bufp++ = 'p'; *bufp++ = 'n'; *bufp++ = 'r'; *bufp++ = 'f'; *bufp++ = '0' + palette.revfg / 10; *bufp++ = '0' + palette.revfg % 10; *bufp++ = '\n'; } if (palette.revbg != dflt_palette.revbg) { *bufp++ = 'p'; *bufp++ = 'n'; *bufp++ = 'r'; *bufp++ = 'b'; *bufp++ = '0' + palette.revbg / 10; *bufp++ = '0' + palette.revbg % 10; *bufp++ = '\n'; } if (palette.boldfg != dflt_palette.boldfg) { *bufp++ = 'p'; *bufp++ = 'b'; *bufp++ = 'f'; *bufp++ = '0' + palette.boldfg / 10; *bufp++ = '0' + palette.boldfg % 10; *bufp++ = '\n'; } if (palette.boldbg != dflt_palette.boldbg) { *bufp++ = 'p'; *bufp++ = 'b'; *bufp++ = 'b'; *bufp++ = '0' + palette.boldbg / 10; *bufp++ = '0' + palette.boldbg % 10; *bufp++ = '\n'; } if (palette.boldrevfg != dflt_palette.boldrevfg) { *bufp++ = 'p'; *bufp++ = 'b'; *bufp++ = 'r'; *bufp++ = 'f'; *bufp++ = '0' + palette.boldrevfg / 10; *bufp++ = '0' + palette.boldrevfg % 10; *bufp++ = '\n'; } if (palette.boldrevbg != dflt_palette.boldrevbg) { *bufp++ = 'p'; *bufp++ = 'b'; *bufp++ = 'r'; *bufp++ = 'b'; *bufp++ = '0' + palette.boldrevbg / 10; *bufp++ = '0' + palette.boldrevbg % 10; *bufp++ = '\n'; } if (palette.dimfg != dflt_palette.dimfg) { *bufp++ = 'p'; *bufp++ = 'd'; *bufp++ = 'f'; *bufp++ = '0' + palette.dimfg / 10; *bufp++ = '0' + palette.dimfg % 10; *bufp++ = '\n'; } if (palette.dimbg != dflt_palette.dimbg) { *bufp++ = 'p'; *bufp++ = 'd'; *bufp++ = 'b'; *bufp++ = '0' + palette.dimbg / 10; *bufp++ = '0' + palette.dimbg % 10; *bufp++ = '\n'; } if (palette.dimrevfg != dflt_palette.dimrevfg) { *bufp++ = 'p'; *bufp++ = 'd'; *bufp++ = 'r'; *bufp++ = 'f'; *bufp++ = '0' + palette.dimrevfg / 10; *bufp++ = '0' + palette.dimrevfg % 10; *bufp++ = '\n'; } if (palette.dimrevbg != dflt_palette.dimrevbg) { *bufp++ = 'p'; *bufp++ = 'd'; *bufp++ = 'r'; *bufp++ = 'b'; *bufp++ = '0' + palette.dimrevbg / 10; *bufp++ = '0' + palette.dimrevbg % 10; *bufp++ = '\n'; } message (" Setup ", "Saving setup in %s ...", fname); write (fd, buf, (unsigned) (bufp - buf)); close (fd); endmesg (); }
/* main, menu */ void renmove (void) { char buf [MAXPATHLEN+20]; char *name; register struct file *p; register c; int done, all, ch; int exd, exf; if (c = tagged ()) { /* move group of files */ sprintf (buf, "Rename or move %d file%s to", c, c>1 ? "s" : ""); if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf))) return; runset (name); exd = exist (name); all = 0; for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p) if (p->tag) { sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (buf) : 0; if (exd=='f' || exf=='f') { if (! all) { ch = getchoice (1, " Rename ", "File exists", exf=='f' ? buf : name, " Overwrite ", " All ", " Cancel "); switch (ch) { default: case 2: /* cancel */ continue; case 1: /* all */ all = 1; } } } else if (exf == 'd') { error ("%s is a directory", buf); continue; } runarg (p->name); } message (" Move ", "Moving %d file%s to %s ...", c, c>1 ? "s" : "", name); done = rundone ("/bin/mv", "mv"); if (done) { endmesg (); message (" Move ", "Done"); } else error ("Error while moving %d file%s to %s", c, c>1 ? "s" : "", name); endmesg (); name = 0; } else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) { /* rename directory */ sprintf (buf, "Rename \"%s\" to", strtail (p->name, '/', 60)); if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf))) return; exd = exist (name); sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (buf) : 0; if (exd=='f' || exf=='f') { if (getchoice (1, " Rename ", "File exists", exf=='f' ? buf : name, " Overwrite ", " Cancel ", NULL)) return; } else if (exf == 'd') { error ("Directory %s exists", buf); return; } if (runl(1, "/bin/mv", "mv", p->name, name, NULL)) { error ("Cannot move %s to %s", p->name, name); return; } } else if (c == S_IFREG) { /* move regular file */ sprintf (buf, "Rename or move \"%s\" to", p->name); if (! (name = getstring (60, (cur==left?right:left)->cwd, " Rename ", buf))) return; exd = exist (name); sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (buf) : 0; if (exd=='f' || exf=='f') { if (getchoice (1, " Rename ", "File exists", exf=='f' ? buf : name, " Overwrite ", " Cancel ", NULL)) return; } else if (exf == 'd') { error ("%s is a directory", buf); return; } if (runl(1, "/bin/mv", "mv", p->name, name, NULL)) { error ("Cannot move %s to %s", p->name, name); return; } } setdir (cur == left ? right : left, NULL); setdir (cur, NULL); if (name) findfile (cur, name); }
/* menu */ void makeslink (void) { char buf [80]; char *name; register struct file *p; register c; int done; int exd, exf; if (c = tagged ()) { /* symlink group of files */ sprintf (buf, "Symlink %d file%s to", c, c>1 ? "s" : ""); if (! (name = getstring (60, (cur==left?right:left)->cwd, " Symlink ", buf))) return; runset (name); exd = exist (name); for (p=cur->d.cat; p<cur->d.cat+cur->d.num; ++p) if (p->tag) { sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (buf) : 0; if (exd=='f' || exf=='f') { if (getchoice (1, " Symlink ", "File exists", exf=='f' ? buf : name, " Overwrite ", " Cancel ", NULL)) continue; } else if (exf == 'd') { error ("%s is a directory", buf); continue; } runarg (p->name); p->tag = 0; } runarg ("-s"); message (" Symlink ", "Linking %d file%s to %s ...", c, c>1 ? "s" : "", name); done = rundone ("/bin/ln", "ln"); if (done) { endmesg (); message (" Symlink ", "Done"); } else error ("Error while linking %d file%s to %s", c, c>1 ? "s" : "", name); endmesg (); } else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) { /* symlinking directory */ } else if (c == S_IFREG) { /* symlink regular file */ sprintf (buf, "Symlink \"%s\" to", p->name); if (! (name = getstring (60, (cur==left?right:left)->cwd, " Symlink ", buf))) return; exd = exist (name); sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (buf) : 0; if (exd=='f' || exf=='f') { if (getchoice (1, " Symlink ", "File exists", exf=='f' ? buf : name, " Overwrite ", " Cancel ", NULL)) return; } else if (exf == 'd') { error ("%s is a directory", buf); return; } if (runl(1, "/bin/ln", "ln", "-s", p->name, name, NULL)) { error ("Cannot symlink %s to %s", p->name, name); return; } } setdir (cur == left ? right : left, NULL); setdir (cur, NULL); }
/* main, menu */ void copy (void) { char buf [80]; char *name; register struct file *p; register c; int done, all, ch; int exd, exf; if (c = tagged ()) { /* copy group of files */ sprintf (buf, "Copy %d file%s to", c, c>1 ? "s" : ""); if (! (name = getstring (60, (cur==left?right:left)->d.cwd, " Copy ", buf))) return; #if 0 runset (name); exd = exist (name); all = 0; for (p = cur->d.cat; p < cur->d.cat + cur->d.num; ++p) if (p->tag) { sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (buf) : 0; if (exd=='f' || exf=='f') { if (! all) { ch = getchoice (1, " Copy ", "File exists", exf=='f' ? buf : name, " Overwrite ", " All ", " Cancel "); switch (ch) { case 2: /* cancel */ --c; continue; case 1: /* all */ all = 1; case 0: /* all */ break; default: runcancel (); return; } } } else if (exf == 'd') { error ("%s is a directory", buf); continue; } runarg (p->name); p->tag = 0; } if (c <= 0) { runcancel (); return; } message (" Copy ", "Copying %d file%s to %s ...", c, c>1 ? "s" : "", name); done = rundone ("/bin/cp", "cp"); if (done) { endmesg (); message (" Copy ", "Done"); } else error ("Error while copying %d file%s to %s", c, c>1 ? "s" : "", name); endmesg (); #endif } else if ((c = (p = &cur->d.cat[cur->d.curfile])->mode & S_IFMT) == S_IFDIR) { /* copying directory */ } else if (c == S_IFREG) { /* copy regular file */ sprintf (buf, "Copy \"%s\" to", p->name); if (! (name = getstring (60, (cur==left?right:left)->d.cwd, " Copy ", buf))) return; exd = exist (cur==left?right:left, name); sprintf (buf, "%s/%s", name, p->name); exf = exd=='d' ? exist (cur==left?right:left, buf) : 0; if (exd=='f' || exf=='f') { if (getchoice (1, " Copy ", "File exists", exf=='f' ? buf : name, " Overwrite ", " Cancel ", NULL)) return; } else if (exf == 'd') { error ("%s is a directory", buf); return; } /* copying */ ReadWrite rf; strncpy(rf.from, cur->d.cwd, sizeof(rf.from)); strncat(rf.from, "/", sizeof(rf.from)); strncat(rf.from, p->name, sizeof(rf.from)); strncpy(rf.to, buf, sizeof(rf.to)); rfiles.AddReadFile(&rf); } setdir (cur == left ? right : left, NULL); setdir (cur, NULL); }