简体   繁体   English

popt库使用

[英]popt Library usage

I am trying to get my head around how the popt library functions for parsing command line arguments to a program. 我试图弄清楚popt库如何用于解析程序的命令行参数。 I am stuck right at the start! 我一开始就陷入困境! For instance wha is the purpose of the structure poptOptions and how does poptGetCoontext() work? 例如,wha是结构poptOptions的目的,poptGetCoontext()如何工作?

I know that there is a bit to cover, so does anyone have any advice on where I can get more info on this library? 我知道这里有一些要讲的内容,所以有人对我在哪里可以获得有关此库的更多信息有任何建议吗? A tutorial, official documentation, or any source of information to get me started. 入门指南,官方文档或任何信息来源。

A brief of what I am trying to do: 我正在尝试做的简介:

Currently an application is set up to accept arguments in the format 当前,已将应用程序设置为接受以下格式的参数

bin/app_name string1 string2 string3 < file_name bin / app_name字符串1字符串2字符串3 <文件名

What I intend to do is 我打算做的是

bin/app_name string1 string2 string3 string4 < file_name1 bin / app_name字符串1字符串2字符串3字符串4 <文件名1

and depending on string4, the file (file_name1) will need to be formatted. 并取决于string4,将需要格式化文件(file_name1)。

Any help on this will be much appreciated. 任何帮助,将不胜感激。

Thanks 谢谢

In any Linux system, install popt developer package eg, Fedora: 在任何Linux系统中,安装popt开发人员软件包,例如Fedora:

sudo dnf install popt-dev

In Debian and Ubuntu it probably is: 在Debian和Ubuntu中,可能是:

sudo apt-get install libpopt-dev

after a successful installation do: 成功安装后,请执行以下操作:

man popt.3

or 要么

man 3 popt

I believe the manual and library are extensive enough. 我相信手册和库足够广泛。 If they aren't for you or you feel out of luck, try to download rpm source code as it relies heavily in this library for command line processing. 如果它们不适合您或者您感到不走运,请尝试下载rpm 源代码,因为它在此库中非常依赖命令行处理。

I hope this was useful. 我希望这是有用的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM