免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1288 | 回复: 1
打印 上一主题 下一主题

[函数] 请解释如下的复杂带有结构体为函数指针的指针数组的意思 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2003-11-18 22:20 |只看该作者 |倒序浏览
如下的代码请高手解释:struct authstaticinfo {
        const char *auth_name;
        char * (*auth_func)(const char *, const char *, char *, int,
                        void (*)(struct authinfo *, void *),
                        void *);
        int (*auth_prefunc)(const char *, const char *,
                        int (*)(struct authinfo *, void *),
                        void *);
        void (*auth_cleanupfunc)();
        int (*auth_changepwd)(const char *, /* service */
                              const char *, /* userid */
                              const char *, /* oldpassword */
                              const char *); /* new password */

        void (*auth_idle)();
        /* Not null - gets called every 5 mins when we're idle */

        } ;

extern int auth_syspasswd(const char *,
                          const char *,
                          const char *,
                          const char *);

extern struct authstaticinfo *authstaticmodulelist[];



for (i=0; authstaticmodulelist; i++)
                {
                        char *uid;

                        if (strcmp(authstaticmodulelist->;auth_name,
                                   namebuf))
                                continue;


                        uid=(*authstaticmodulelist->;
                             auth_func)(service,
                                        authtype,
                                        strcpy(authdata_cpy, authdata),
                                        issession,
                                        callback_func,
                                        callback_arg);


我想问:
指针数组中的函数指针是如何定义的,在什么地方实现?

论坛徽章:
0
2 [报告]
发表于 2003-11-19 03:57 |只看该作者

请解释如下的复杂带有结构体为函数指针的指针数组的意思

感觉你的问题不是很清楚,不知下面是否能回答你的问题。
函数指针auth_func是结构authstaticinfo的一个成员。显然这段程序没有初始化auth_func,而且有extern struct authstaticinfo *authstaticmodulelist[]; 所以这个数组多半是在其他程序初始化的。
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP