diff options
author | Arthur de Jong <arthur@arthurdejong.org> | 2012-12-22 22:38:26 +0100 |
---|---|---|
committer | Arthur de Jong <arthur@arthurdejong.org> | 2012-12-22 22:38:26 +0100 |
commit | c7bb19c55c7a902e25bdd33b0d49a2ddcf62e07a (patch) | |
tree | b3a75ef2719bc2f334041460fd21fbdf86a23a82 /nss/passwd.c | |
parent | d336cd6b429f8ce40c58ea287f79bbc7c23d0966 (diff) |
update C coding style to a more commonly used style
git-svn-id: http://arthurdejong.org/svn/nss-pam-ldapd/nss-pam-ldapd@1873 ef36b2f9-881f-0410-afb5-c4e39611909c
Diffstat (limited to 'nss/passwd.c')
-rw-r--r-- | nss/passwd.c | 88 |
1 files changed, 43 insertions, 45 deletions
diff --git a/nss/passwd.c b/nss/passwd.c index e996536..59014cd 100644 --- a/nss/passwd.c +++ b/nss/passwd.c @@ -31,23 +31,22 @@ #include "compat/attrs.h" /* read a passwd entry from the stream */ -static nss_status_t read_passwd( - TFILE *fp,struct passwd *result, - char *buffer,size_t buflen,int *errnop) +static nss_status_t read_passwd(TFILE *fp, struct passwd *result, + char *buffer, size_t buflen, int *errnop) { int32_t tmpint32; - size_t bufptr=0; - memset(result,0,sizeof(struct passwd)); - READ_BUF_STRING(fp,result->pw_name); - READ_BUF_STRING(fp,result->pw_passwd); - READ_INT32(fp,result->pw_uid); - READ_INT32(fp,result->pw_gid); - READ_BUF_STRING(fp,result->pw_gecos); - READ_BUF_STRING(fp,result->pw_dir); - READ_BUF_STRING(fp,result->pw_shell); + size_t bufptr = 0; + memset(result, 0, sizeof(struct passwd)); + READ_BUF_STRING(fp, result->pw_name); + READ_BUF_STRING(fp, result->pw_passwd); + READ_INT32(fp, result->pw_uid); + READ_INT32(fp, result->pw_gid); + READ_BUF_STRING(fp, result->pw_gecos); + READ_BUF_STRING(fp, result->pw_dir); + READ_BUF_STRING(fp, result->pw_shell); #ifdef HAVE_STRUCT_PASSWD_PW_CLASS /* set the user access class to an empty string */ - result->pw_class=result->pw_name+strlen(result->pw_name); + result->pw_class = result->pw_name + strlen(result->pw_name); #endif /* HAVE_STRUCT_PASSWD_PW_CLASS */ return NSS_STATUS_SUCCESS; } @@ -55,23 +54,21 @@ static nss_status_t read_passwd( #ifdef NSS_FLAVOUR_GLIBC /* get a single passwd entry by name */ -nss_status_t _nss_ldap_getpwnam_r( - const char *name,struct passwd *result, - char *buffer,size_t buflen,int *errnop) +nss_status_t _nss_ldap_getpwnam_r(const char *name, struct passwd *result, + char *buffer, size_t buflen, int *errnop) { NSS_BYNAME(NSLCD_ACTION_PASSWD_BYNAME, name, - read_passwd(fp,result,buffer,buflen,errnop)); + read_passwd(fp, result, buffer, buflen, errnop)); } /* get a single passwd entry by uid */ -nss_status_t _nss_ldap_getpwuid_r( - uid_t uid,struct passwd *result, - char *buffer,size_t buflen,int *errnop) +nss_status_t _nss_ldap_getpwuid_r(uid_t uid, struct passwd *result, + char *buffer, size_t buflen, int *errnop) { NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID, uid, - read_passwd(fp,result,buffer,buflen,errnop)); + read_passwd(fp, result, buffer, buflen, errnop)); } /* thread-local file pointer to an ongoing request */ @@ -84,12 +81,11 @@ nss_status_t _nss_ldap_setpwent(int UNUSED(stayopen)) } /* read password data from an opened stream */ -nss_status_t _nss_ldap_getpwent_r( - struct passwd *result, - char *buffer,size_t buflen,int *errnop) +nss_status_t _nss_ldap_getpwent_r(struct passwd *result, + char *buffer, size_t buflen, int *errnop) { - NSS_GETENT(pwentfp,NSLCD_ACTION_PASSWD_ALL, - read_passwd(pwentfp,result,buffer,buflen,errnop)); + NSS_GETENT(pwentfp, NSLCD_ACTION_PASSWD_ALL, + read_passwd(pwentfp, result, buffer, buflen, errnop)); } /* close the stream opened with setpwent() above */ @@ -103,57 +99,58 @@ nss_status_t _nss_ldap_endpwent(void) #ifdef NSS_FLAVOUR_SOLARIS #ifdef HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN -static char *passwd2str(struct passwd *result,char *buffer,size_t buflen) +static char *passwd2str(struct passwd *result, char *buffer, size_t buflen) { int res; - res=snprintf(buffer,buflen,"%s:%s:%d:%d:%s:%s:%s", - result->pw_name,result->pw_passwd,(int)result->pw_uid,(int)result->pw_gid, - result->pw_gecos,result->pw_dir,result->pw_shell); - if ((res<0)||(res>=buflen)) + res = snprintf(buffer, buflen, "%s:%s:%d:%d:%s:%s:%s", + result->pw_name, result->pw_passwd, (int)result->pw_uid, + (int)result->pw_gid, result->pw_gecos, result->pw_dir, + result->pw_shell); + if ((res < 0) || (res >= buflen)) return NULL; return buffer; } #endif /* HAVE_STRUCT_NSS_XBYY_ARGS_RETURNLEN */ -static nss_status_t read_result(TFILE *fp,nss_XbyY_args_t *args) +static nss_status_t read_result(TFILE *fp, nss_XbyY_args_t *args) { - READ_RESULT(passwd,&args->erange); + READ_RESULT(passwd, &args->erange); } -static nss_status_t passwd_getpwnam(nss_backend_t UNUSED(*be),void *args) +static nss_status_t passwd_getpwnam(nss_backend_t UNUSED(*be), void *args) { NSS_BYNAME(NSLCD_ACTION_PASSWD_BYNAME, NSS_ARGS(args)->key.name, - read_result(fp,args)); + read_result(fp, args)); } -static nss_status_t passwd_getpwuid(nss_backend_t UNUSED(*be),void *args) +static nss_status_t passwd_getpwuid(nss_backend_t UNUSED(*be), void *args) { NSS_BYINT32(NSLCD_ACTION_PASSWD_BYUID, NSS_ARGS(args)->key.uid, - read_result(fp,args)); + read_result(fp, args)); } /* open a connection to the nslcd and write the request */ -static nss_status_t passwd_setpwent(nss_backend_t *be,void UNUSED(*args)) +static nss_status_t passwd_setpwent(nss_backend_t *be, void UNUSED(*args)) { NSS_SETENT(LDAP_BE(be)->fp); } /* read password data from an opened stream */ -static nss_status_t passwd_getpwent(nss_backend_t *be,void *args) +static nss_status_t passwd_getpwent(nss_backend_t *be, void *args) { - NSS_GETENT(LDAP_BE(be)->fp,NSLCD_ACTION_PASSWD_ALL, - read_result(LDAP_BE(be)->fp,args)); + NSS_GETENT(LDAP_BE(be)->fp, NSLCD_ACTION_PASSWD_ALL, + read_result(LDAP_BE(be)->fp, args)); } /* close the stream opened with setpwent() above */ -static nss_status_t passwd_endpwent(nss_backend_t *be,void UNUSED(*args)) +static nss_status_t passwd_endpwent(nss_backend_t *be, void UNUSED(*args)) { NSS_ENDENT(LDAP_BE(be)->fp); } -static nss_backend_op_t passwd_ops[]={ +static nss_backend_op_t passwd_ops[] = { nss_ldap_destructor, passwd_endpwent, passwd_setpwent, @@ -163,9 +160,10 @@ static nss_backend_op_t passwd_ops[]={ }; nss_backend_t *_nss_ldap_passwd_constr(const char UNUSED(*db_name), - const char UNUSED(*src_name),const char UNUSED(*cfg_args)) + const char UNUSED(*src_name), + const char UNUSED(*cfg_args)) { - return nss_ldap_constructor(passwd_ops,sizeof(passwd_ops)); + return nss_ldap_constructor(passwd_ops, sizeof(passwd_ops)); } #endif /* NSS_FLAVOUR_SOLARIS */ |