247{
249 char cmd[100], tape_name[256],
file_name[256];
250
251
252
253#ifdef OS_WINNT
254 strcpy(tape_name, "\\\\.\\tape0");
255#elif defined(OS_UNIX)
256 strcpy(tape_name, "/dev/tape");
257#elif defined(OS_VMS)
258 strcpy(tape_name, "mka0:");
259#else
260#error This program cannot be compiled under this operating system
261#endif
262
263
265 cmd[0] = 0;
266 count1 = -100;
267 count2 = 0;
268
269
270 if (getenv("TAPE") != NULL)
271 strcpy(tape_name, getenv("TAPE"));
272
273
274 for (
i = 1;
i < argc;
i++) {
275 if (argv[
i][0] ==
'-' && argv[
i][1] ==
'v')
277 else if (argv[
i][0] ==
'-') {
278 if (
i + 1 >= argc || argv[
i + 1][0] ==
'-')
280 if (argv[
i][1] ==
'f')
281 strcpy(tape_name, argv[++
i]);
282 else if (argv[
i][1] ==
'd')
284 else
286 } else if (cmd[0] == 0)
287 strcpy(cmd, argv[
i]);
288 else if (count1 == -100)
289 count1 = atoi(argv[
i]);
290 else
291 count2 = atoi(argv[
i]);
292 }
293
294 if (count1 == -100)
295 count1 = 1;
296
297
299
300 if (strcmp(cmd, "status") == 0) {
302 return 0;
303 }
304
305
307 printf("Cannot open tape %s.\n", tape_name);
308 return 0;
309 }
310
311 if (strcmp(cmd, "rewind") == 0)
313
314 else if (strcmp(cmd, "online") == 0)
316
317 else if (strcmp(cmd, "offline") == 0)
319
320 else if (strcmp(cmd, "eof") == 0 || strcmp(cmd, "weof") == 0) {
321
324 printf("Cannot open tape %s.\n", tape_name);
325 return 0;
326 }
327
328 for (
i = 0;
i < count1;
i++)
330 }
331
332 else if (strcmp(cmd, "fsf") == 0 || strcmp(cmd, "ff") == 0)
334
335 else if (strcmp(cmd, "fsr") == 0 || strcmp(cmd, "fr") == 0)
337
338 else if (strcmp(cmd, "bsf") == 0 || strcmp(cmd, "bf") == 0)
340
341 else if (strcmp(cmd, "bsr") == 0 || strcmp(cmd, "br") == 0)
343
344 else if (strcmp(cmd, "seod") == 0)
346
347 else if (strcmp(cmd, "dir") == 0)
349
350 else if (strcmp(cmd, "backup") == 0) {
351
354 printf("Cannot open tape %s.\n", tape_name);
355 return 0;
356 }
358 }
359
360 else if (strcmp(cmd, "restore") == 0)
362
363 else {
365 printf("usage: mtape [-f tape_device] [-d file] [-v] command [count] [last]\n\n");
366 printf("Following commands are available:\n");
367 printf(" status Print status information about tape\n");
368 printf(" rewind Rewind tape\n");
369 printf
370 (" eof,weof Write <count> End-of-File marks at the current tape position\n");
371 printf(" fsf,ff Forward spaces <count> files\n");
372 printf(" fsr,fr Forward spaces <count> records\n");
373 printf(" bsf,bf Backspaces <count> files\n");
374 printf(" bsr,br Backspaces <count> records\n");
375 printf(" rewind Rewind tape\n");
376 printf(" offline Places the tape offline (unload)\n");
377 printf(" online Places the tape online (load)\n");
378 printf(" seod Space to end of recorded data\n\n");
379 printf("Following commands only work with tapes written in MIDAS format:\n");
380 printf(" dir List next [count] runs on MIDAS tape\n");
381 printf(" backup\n");
382 printf
383 (" Copy runs with numbers [count] to [last] from disk to tape.\n");
384 printf(" If [-d file] is not given, runxxxxx.mid is used where\n");
385 printf(" xxxxx is the run number. If [file] contains %%05d, it\n");
386 printf(" is replaced by the run number.\n");
387 printf(" restore\n");
388 printf(" Copy next [count] files from tape to disk.\n");
389 printf(" If [-d file] is not given, runxxxxx.mid is used where\n");
390 printf(" xxxxx is the run number. If [file] contains %%05d, it\n");
391 printf(" is replaced by the run number.\n");
392 return 0;
393 }
394
396 printf("Error performing operation\n");
398 printf(
"Error performing operation, status code = %d\n",
status);
399
401
402 return 0;
403}
INT ss_tape_rskip(INT channel, INT count)
INT ss_tape_rewind(INT channel)
INT ss_tape_fskip(INT channel, INT count)
INT ss_tape_close(INT channel)
INT ss_tape_status(char *path)
INT ss_tape_mount(INT channel)
INT ss_tape_spool(INT channel)
INT ss_tape_unmount(INT channel)
INT ss_tape_write_eof(INT channel)
INT ss_tape_open(char *path, INT oflag, INT *channel)
INT cm_set_msg_print(INT system_mask, INT user_mask, int(*func)(const char *))
INT tape_dir(INT channel, INT count)
INT tape_backup(INT channel, INT count1, INT count2, char *file_name)
INT tape_restore(INT channel, INT count, char *file_name)