将特定于AIX的C函数调用迁移到Linux [英] Migrating AIX specific C function calls to Linux

查看:348
本文介绍了将特定于AIX的C函数调用迁移到Linux的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从IBM AIX上的一个应用程序中获取了源文件,我正在尝试在Linux上构建它们.但是,Linux上不存在AIX上名为usersec.huserpw.h的头文件.因此,在Linux上,这些功能会导致编译器错误:

I have got source files from an application on IBM AIX and I am trying to build them on Linux. However, header files named usersec.hand userpw.h which are there on AIX are not present on Linux. Hence, on Linux I am getting compiler error for these functions:

usersec.h

int     getuserattr (char *, char *, void *, int);

有关getuserattr的更多信息是userpw.h

struct userpw
{
        char    *upw_passwd;            /* user's passwd */
        unsigned int    upw_flags;      /* flags of restrictions */
        time_t  upw_lastupdate;         /* date of last passwd update */
        char    upw_name[PW_NAMELEN];   /* user's name */
};

struct userpw   *getuserpw (); 
int setpwdb ();  
int endpwdb ();

请查找更多信息: getuserpw setpwdb和endpwdb

如果任何人都知道如何在Linux上编写等效的函数,那真是太好了.

If anyone knows how to write equivalent functions on Linux, it would be really great.

推荐答案

您可能想使用 getpwent 及其相关功能.

You likely want to use getpwent, and its related functions.

getpwent()函数返回指向包含以下内容的结构的指针 密码数据库中记录的细分字段(例如, 本地密码文件/etc/passwd,NIS和LDAP).第一次 getpwent()被调用,它返回第一个条目;之后,它 返回连续的条目.

The getpwent() function returns a pointer to a structure containing the broken-out fields of a record from the password database (e.g., the local password file /etc/passwd, NIS, and LDAP). The first time getpwent() is called, it returns the first entry; thereafter, it returns successive entries.

setpwent()函数后退到密码的开头 数据库.

The setpwent() function rewinds to the beginning of the password database.

endpwent()函数用于在之后关闭密码数据库 所有处理都已执行.

The endpwent() function is used to close the password database after all processing has been performed.

如果要获取特定用户的密码条目,可以使用

If you want to get the password entry of a particular user, you can use getpwnam or one of its variants.

getpwnam()函数返回指向包含以下内容的结构的指针 密码数据库中记录的细分字段(例如, 本地密码文件/etc/passwd,NIS和LDAP)与 用户名名称.

The getpwnam() function returns a pointer to a structure containing the broken-out fields of the record in the password database (e.g., the local password file /etc/passwd, NIS, and LDAP) that matches the username name.

这篇关于将特定于AIX的C函数调用迁移到Linux的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆