加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

在linux上读取c程序时如何找到结构的定义?

发布时间:2020-12-13 18:48:12 所属栏目:Linux 来源:网络整理
导读:我正在阅读xl2tpd的源代码,并在阅读此代码时遇到很多问题.例如,我找不到结构lac的定义.我如何找到这个结构的定义? 我使用ctags和vim来读取此代码,但未能找到结构.我用Google搜索,找不到结构.有没有什么方法可以让代码阅读过程更舒服?也就是说,我可以跳到大
我正在阅读xl2tpd的源代码,并在阅读此代码时遇到很多问题.例如,我找不到结构lac的定义.我如何找到这个结构的定义?

我使用ctags和vim来读取此代码,但未能找到结构.我用Google搜索,找不到结构.有没有什么方法可以让代码阅读过程更舒服?也就是说,我可以跳到大多数变量,函数和结构的定义?

解决方法

用vim试试cscope.按照以下步骤 –
1)在xl2tpd目录中运行cscope -R.它将创建文件cscope.out
2)使用vim打开文件,其中使用结构lac
3)使用:cs f g< lac> .现在它将显示定义lac的文件.
4)选择file.h.它包含定义.
如果您对struct lac的定义非常感兴趣,那么它是 –
struct lac
{
    struct lac *next;
    struct host *lns;           /* LNS's we can connect to */
    struct schedule_entry *rsched;
    int tun_rws;                /* Receive window size (tunnel) */
    int call_rws;               /* Call rws */
    int rxspeed;                /* Tunnel rx speed */
    int txspeed;                /* Tunnel tx speed */
    int active;                 /* Is this connection in active use? */
    int hbit;                   /* Permit hidden AVP's? */
    int lbit;                   /* Use the length field? */
    int challenge;              /* Challenge authenticate the peer? */
    unsigned int localaddr;     /* Local IP address */    
    unsigned int remoteaddr;    /* Force remote address to this */
    char authname[STRLEN];      /* Who we authenticate as */
    char password[STRLEN];      /* Password to authenticate with */
    char peername[STRLEN];      /* Force peer name to this */
    char hostname[STRLEN];      /* Hostname to report */
    char entname[STRLEN];       /* Name of this entry */
    int authpeer;               /* Authenticate our peer? */
    int authself;               /* Authenticate ourselves? */
    int pap_require;            /* Require PAP auth for PPP */
    int chap_require;           /* Require CHAP auth for PPP */
    int pap_refuse;             /* Refuse PAP authentication for us */
    int chap_refuse;            /* Refuse CHAP authentication for us */
    int idle;                   /* Idle timeout in seconds */
    int autodial;               /* Try to dial immediately? */
    int defaultroute;           /* Use as default route? */
    int redial;                 /* Redial if disconnected */
    int rmax;                   /* Maximum # of consecutive redials */
    int rtries;                 /* # of tries so far */
    int rtimeout;               /* Redial every this many # of seconds */
    char pppoptfile[STRLEN];    /* File containing PPP options */
    int debug;
    struct tunnel *t;           /* Our tunnel */
    struct call *c;             /* Our call */
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读