Home | History | Annotate | Download | only in gptfdisk
      1 /*
      2  * Copyright (C) 2015 The Android Open Source Project
      3  *
      4  * This software is licensed under the terms of the GNU General Public
      5  * License version 2, as published by the Free Software Foundation, and
      6  * may be copied, distributed, and modified under those terms.
      7  *
      8  * This program is distributed in the hope that it will be useful,
      9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
     10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11  * GNU General Public License for more details.
     12  */
     13 
     14 #ifndef ANDROID_POPT_H
     15 #define ANDROID_POPT_H
     16 
     17 /*
     18  * popt has been deprecated for some time, and is replaced by GNOME's glib
     19  * option parser. Instead of pulling in either of those dependencies, this
     20  * stub implements just enough of popt to get things working.
     21  */
     22 
     23 #include <stdio.h>
     24 #include <stdlib.h>
     25 #include <string.h>
     26 #include <getopt.h>
     27 
     28 #define POPT_ARG_NONE		 0U
     29 #define POPT_ARG_STRING		 1U
     30 #define POPT_ARG_INT		 2U
     31 
     32 #define POPT_AUTOHELP
     33 
     34 #pragma pack(push)
     35 #pragma pack(0)
     36 
     37 struct poptOption {
     38     const char *longName;
     39     char shortName;
     40     unsigned int argInfo;
     41     void *arg;
     42     int val;
     43     const char *descrip;
     44     const char *argDescrip;
     45 };
     46 
     47 struct _poptContext {
     48     int argc;
     49     const char **argv;
     50     const struct poptOption *options;
     51     struct option *long_options;
     52     const char *otherHelp;
     53 };
     54 
     55 typedef struct _poptContext *poptContext;
     56 
     57 #pragma pack(pop)
     58 
     59 poptContext poptGetContext(const char *name, int argc, const char **argv,
     60         const struct poptOption *options, unsigned int flags);
     61 poptContext poptFreeContext(poptContext con);
     62 void poptResetContext(poptContext con);
     63 
     64 void poptSetOtherOptionHelp(poptContext con, const char *text);
     65 void poptPrintUsage(poptContext con, FILE *fp, int flags);
     66 
     67 int poptGetNextOpt(poptContext con);
     68 const char *poptGetArg(poptContext con);
     69 
     70 #endif
     71