zoukankan      html  css  js  c++  java
  • 2010912 双模机顶盒学习记录

    双模机顶盒 直播走igmp/rtsp组播协议 单播走hls(OTT)协议。

    系统调用

    getopt

      位于 unistd.h 系统头文件,原型:

      int getopt( int argc, char *const argv[], const char *optstring );

    #include <unistd.h>
           extern char *optarg;  //选项的参数指针
           extern int optind,   //下一次调用getopt的时,从optind存储的位置处重新开始检查选项。 
           extern int opterr,  //当opterr=0时,getopt不向stderr输出错误信息。
           extern int optopt;  //当命令行选项字符不包括在optstring中或者选项缺少必要的参数时,该选项存储在optopt中,getopt返回'?’、
           int getopt(int argc, char * const argv[], const char *optstring);

      optstring是一段自己规定的选项串,例如本例中的"a:b::cde",表示可以有,-a,-b,-c,-d,-e这几个参数。

      “:”表示必须该选项带有额外的参数,全域变量optarg会指向此额外参数,“::”标识该额外的参数可选(有些Uinx可能不支持“::”)。

      getopt() 所设置的全局变量包括:

    • optarg——字符串, 指向当前选项参数(如果有)的指针。   选项的参数指针
    • optind——整型, 再次调用 getopt() 时的下一个 argv 指针的索引。下一次调用getopt的时,从optind存储的位置处重新开始检查选项。在argv[optind]至argv[argc-1]中可以找到。
        • argv的当前索引值。当getopt()在while循环中使用时,循环结束后,剩下的字串视为操作数,在argv[optind]至argv[argc-1]中可以找到。
    • optopt——整型, 最后一个已知选项。当命令行选项字符不包括在optstring中或者选项缺少必要的参数时,该选项存储在optopt中,getopt返回'?’、当发现无效选项字符之时,getopt()函数或返回'?'字 符,或返回':'字符,并且optopt包含了所发现的无效选项字符。
    • opterr        整型, 当opterr=0时,getopt不向stderr输出错误信息。 这个变量非零时,getopt()函数为“无效选项”和“缺少参数选项,并输出其错误信息。

      

      https://www.ibm.com/developerworks/cn/aix/library/au-unix-getopt.html

           http://blog.csdn.net/baixue6269/article/details/7550184

      http://vopit.blog.51cto.com/2400931/440453

      http://www.cnblogs.com/qingergege/p/5914218.html

  • 相关阅读:
    25. Spring Boot与缓存 JSR-107、Spring缓存抽象
    24. Spring Boot 自定义Starter (未整理,待续)
    UGUI 锚点
    UGUI Button控件
    UGUI Image控件
    UGUI Text控件
    Unity 角色复活和重新开始游戏
    Unity 读取Excel
    IOS使用C#预处理命令,多种SDK共存
    Unity扩展 四种Menu的区别
  • 原文地址:https://www.cnblogs.com/doscho/p/7515189.html
Copyright © 2011-2022 走看看