Skip to content
Snippets Groups Projects
Select Git revision
  • c0ec05c3bb4342b32381e0d849333ad27d92f76d
  • master default protected
  • rednatco-v2
  • base-pairs-ladder
  • rednatco
  • test
  • ntc-tube-uniform-color
  • ntc-tube-missing-atoms
  • restore-vertex-array-per-program
  • watlas2
  • dnatco_new
  • cleanup-old-nodejs
  • webmmb
  • fix_auth_seq_id
  • update_deps
  • ext_dev
  • ntc_balls
  • nci-2
  • plugin
  • bugfix-0.4.5
  • nci
  • v0.5.0-dev.1
  • v0.4.5
  • v0.4.4
  • v0.4.3
  • v0.4.2
  • v0.4.1
  • v0.4.0
  • v0.3.12
  • v0.3.11
  • v0.3.10
  • v0.3.9
  • v0.3.8
  • v0.3.7
  • v0.3.6
  • v0.3.5
  • v0.3.4
  • v0.3.3
  • v0.3.2
  • v0.3.1
  • v0.3.0
41 results

location.ts

Blame
  • yopt.h 5.11 KiB
    /* ncdu - NCurses Disk Usage
    
      Copyright (c) 2007-2012 Yoran Heling
    
      Permission is hereby granted, free of charge, to any person obtaining
      a copy of this software and associated documentation files (the
      "Software"), to deal in the Software without restriction, including
      without limitation the rights to use, copy, modify, merge, publish,
      distribute, sublicense, and/or sell copies of the Software, and to
      permit persons to whom the Software is furnished to do so, subject to
      the following conditions:
    
      The above copyright notice and this permission notice shall be included
      in all copies or substantial portions of the Software.
    
      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
      EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    
    */
    
    /* This is a simple command-line option parser. Operation is similar to
     * getopt_long(), except with a cleaner API.
     *
     * This is implemented in a single header file, as it's pretty small and you
     * generally only use an option parser in a single .c file in your program.
     *
     * Supports (examples from GNU tar(1)):
     *   "--gzip"
     *   "--file <arg>"
     *   "--file=<arg>"
     *   "-z"
     *   "-f <arg>"
     *   "-f<arg>"
     *   "-zf <arg>"
     *   "-zf<arg>"
     *   "--" (To stop looking for futher options)
     *   "<arg>" (Non-option arguments)
     *
     * Issues/non-features:
     * - An option either requires an argument or it doesn't.
     * - No way to specify how often an option can/should be used.
     * - No way to specify the type of an argument (filename/integer/enum/whatever)
     */
    
    
    
    #include <stdarg.h>
    #include <stdlib.h>
    #include <stdio.h>
    
    
    typedef struct {
      /* Value yopt_next() will return for this option */
      int val;
      /* Whether this option needs an argument */
      int needarg;
      /* Name(s) of this option, prefixed with '-' or '--' and separated by a
       * comma. E.g. "-z", "--gzip", "-z,--gzip".
       * An option can have any number of aliasses.
       */
      const char *name;
    } yopt_opt_t;
    
    
    typedef struct {