paul@294 | 1 | /* |
paul@294 | 2 | * Session utilities. |
paul@294 | 3 | * |
paul@294 | 4 | * Copyright (C) 2022 Paul Boddie <paul@boddie.org.uk> |
paul@294 | 5 | * |
paul@294 | 6 | * This program is free software; you can redistribute it and/or |
paul@294 | 7 | * modify it under the terms of the GNU General Public License as |
paul@294 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@294 | 9 | * the License, or (at your option) any later version. |
paul@294 | 10 | * |
paul@294 | 11 | * This program is distributed in the hope that it will be useful, |
paul@294 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@294 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@294 | 14 | * GNU General Public License for more details. |
paul@294 | 15 | * |
paul@294 | 16 | * You should have received a copy of the GNU General Public License |
paul@294 | 17 | * along with this program; if not, write to the Free Software |
paul@294 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@294 | 19 | * Boston, MA 02110-1301, USA |
paul@294 | 20 | */ |
paul@294 | 21 | |
paul@294 | 22 | #include <stdio.h> |
paul@294 | 23 | #include <stdlib.h> |
paul@294 | 24 | #include <string.h> |
paul@294 | 25 | #include <unistd.h> |
paul@294 | 26 | |
paul@294 | 27 | #include "session.h" |
paul@294 | 28 | |
paul@294 | 29 | |
paul@294 | 30 | |
paul@294 | 31 | /* Alternative metadata set by options. */ |
paul@294 | 32 | |
paul@294 | 33 | struct metadata md; |
paul@294 | 34 | |
paul@294 | 35 | |
paul@294 | 36 | |
paul@294 | 37 | /* Parse program options. */ |
paul@294 | 38 | |
paul@294 | 39 | int parse_options(int argc, char *argv[]) |
paul@294 | 40 | { |
paul@294 | 41 | int opt; |
paul@294 | 42 | |
paul@294 | 43 | md.mask = 0000; |
paul@294 | 44 | |
paul@294 | 45 | while ((opt = getopt(argc, argv, "m:")) != -1) |
paul@294 | 46 | { |
paul@294 | 47 | switch (opt) |
paul@294 | 48 | { |
paul@294 | 49 | case 'm': |
paul@294 | 50 | md.mask = strtol(optarg, NULL, 0); |
paul@294 | 51 | break; |
paul@294 | 52 | |
paul@294 | 53 | default: |
paul@294 | 54 | fprintf(stderr, "Option not recognised: %s\n", argv[optind]); |
paul@294 | 55 | return -1; |
paul@294 | 56 | } |
paul@294 | 57 | } |
paul@294 | 58 | |
paul@294 | 59 | return 0; |
paul@294 | 60 | } |
paul@294 | 61 | |
paul@294 | 62 | /* vim: tabstop=4 expandtab shiftwidth=4 |
paul@294 | 63 | */ |