The system data files and information password files are stored in etcpasswd. you can use the following function to obtain the password file items. Include & lt; sys system data file and information password file
Stored in/etc/passwd. use the following function to obtain the password file.
# Include
# Include
Struct passwd * getpwnam (const char * name );
Struct passwd * getpwuid (uid_t uid );
If you want to view only the login name or user ID, the above two functions can meet the requirements, but some programs want to view the entire password file. The following three functions can be used for this purpose.
# Include
# Include
Struct passwd * getpwent (void );
Void setpwent (void );
Void endpwent (void );
Shadow password
Shadow password file: stores the encryption password
Use the following function to access the shadow password file:
# Include
Struct spwd * getspnam (const char * name );
Struct spwd * getspent (void );
Void setspent (void );
Void endspent (void );
Group files
The following functions are used to view the group name or value group ID.
# Include
# Include
Struct group * getgrnam (const char * name );
Struct group * getgrgid (gid_t gid );
To search the entire group of files, you can use the following three functions:
# Include
# Include
Struct group * getgrent (void );
Void setgrent (void );
Void endgrent (void );
Additional group ID
You can use the following three functions to obtain and set additional group IDs:
# Include
# Include
Int getgroups (int size, gid_t list []);
# Include
# Include
Int setgroups (size_t size, const gid_t * list );
# Include
# Include
Int initgroups (const char * user, gid_tgroup );
Time and date routines
# Include
Time_t time (time_t * t );
Returns the current time and date.
# Include
Int gettimeofday (struct timeval * TV, structtimezone * tz );
The above functions are also used to obtain the current time and date, but the resolution is higher (up to microseconds ).
# Include
Double difftime (time_t time1, time_ttime0 );
Calculate the difference between two time values and return the value of the time1-time2 as a floating point number.