diff options
author | Jakob Kaivo <jkk@ung.org> | 2019-11-20 16:35:46 -0500 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2019-11-20 16:35:46 -0500 |
commit | bc4ca8f73ece3cb3d6d3538ea182b078142c65c9 (patch) | |
tree | ce3de06069b5d21bf5c65a71c4f19efcf5492de0 /cpio.c | |
parent | f1cdf4f5ff99255c12347b214853bf68835b6a9c (diff) |
add rough outlines of cpio and tar interfaces
Diffstat (limited to 'cpio.c')
-rw-r--r-- | cpio.c | 85 |
1 files changed, 85 insertions, 0 deletions
@@ -24,10 +24,12 @@ #define _XOPEN_SOURCE 700 #include <cpio.h> +#include <locale.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sys/stat.h> +#include <unistd.h> #include "pax.h" @@ -112,3 +114,86 @@ int cpio_list(FILE *input, size_t firstlen, void *firstblock) return 0; } + +int cpio_main(int argc, char *argv[]) +{ + setlocale(LC_ALL, ""); + int c; + + while ((c = getopt(argc, argv, "oip")) != -1) { + switch (c) { + case 'o': + // create + break; + + case 'i': + // extract + break; + + case 'p': + // copy? + break; + + default: + return 1; + } + + break; + } + + for (size_t i = 2; argv[optind][i] != '\0'; i++) { + printf("checking %c\n", argv[optind][i]); + switch (argv[optind][i]) { + case 'a': + // reset atimes + break; + + case 'B': + // blocksize 5120 + break; + + case 'd': + // create directories + break; + + case 'c': + // read and write in character form for portability + break; + + case 'r': + // interactively rename files + break; + + case 't': + // list table of contents + break; + + case 'u': + // copy unconditionally + break; + + case 'v': + // verbose + break; + + case 'l': + // link instead of copy, requires -p + break; + + case 'm': + // reset mtime + break; + + case 'f': + // ignore files in pattern + break; + + default: + fprintf(stderr, "cpio: unknown option '%c'\n", + argv[optind][i]); + return 1; + } + } + + return 0; +} |