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 /nslcd/protocol.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 'nslcd/protocol.c')
-rw-r--r-- | nslcd/protocol.c | 124 |
1 files changed, 60 insertions, 64 deletions
diff --git a/nslcd/protocol.c b/nslcd/protocol.c index 88813ad..317e9f1 100644 --- a/nslcd/protocol.c +++ b/nslcd/protocol.c @@ -63,49 +63,45 @@ const char *attmap_protocol_ipProtocolNumber = "ipProtocolNumber"; static const char *protocol_attrs[3]; static int mkfilter_protocol_byname(const char *name, - char *buffer,size_t buflen) + char *buffer, size_t buflen) { char safename[300]; /* escape attribute */ - if (myldap_escape(name,safename,sizeof(safename))) + if (myldap_escape(name, safename, sizeof(safename))) return -1; /* build filter */ - return mysnprintf(buffer,buflen, - "(&%s(%s=%s))", - protocol_filter, - attmap_protocol_cn,safename); + return mysnprintf(buffer, buflen, "(&%s(%s=%s))", + protocol_filter, attmap_protocol_cn, safename); } /* create a search filter for searching a protocol entry by uid, return -1 on errors */ static int mkfilter_protocol_bynumber(int protocol, - char *buffer,size_t buflen) + char *buffer, size_t buflen) { - return mysnprintf(buffer,buflen, - "(&%s(%s=%d))", - protocol_filter, - attmap_protocol_ipProtocolNumber,protocol); + return mysnprintf(buffer, buflen, "(&%s(%s=%d))", + protocol_filter, attmap_protocol_ipProtocolNumber, protocol); } void protocol_init(void) { int i; /* set up search bases */ - if (protocol_bases[0]==NULL) - for (i=0;i<NSS_LDAP_CONFIG_MAX_BASES;i++) - protocol_bases[i]=nslcd_cfg->ldc_bases[i]; + if (protocol_bases[0] == NULL) + for (i = 0; i < NSS_LDAP_CONFIG_MAX_BASES; i++) + protocol_bases[i] = nslcd_cfg->ldc_bases[i]; /* set up scope */ - if (protocol_scope==LDAP_SCOPE_DEFAULT) - protocol_scope=nslcd_cfg->ldc_scope; + if (protocol_scope == LDAP_SCOPE_DEFAULT) + protocol_scope = nslcd_cfg->ldc_scope; /* set up attribute list */ - protocol_attrs[0]=attmap_protocol_cn; - protocol_attrs[1]=attmap_protocol_ipProtocolNumber; - protocol_attrs[2]=NULL; + protocol_attrs[0] = attmap_protocol_cn; + protocol_attrs[1] = attmap_protocol_ipProtocolNumber; + protocol_attrs[2] = NULL; } -static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname) +static int write_protocol(TFILE *fp, MYLDAP_ENTRY *entry, const char *reqname) { - int32_t tmpint32,tmp2int32,tmp3int32; + int32_t tmpint32, tmp2int32, tmp3int32; const char *name; const char **aliases; const char **protos; @@ -113,89 +109,89 @@ static int write_protocol(TFILE *fp,MYLDAP_ENTRY *entry,const char *reqname) long proto; int i; /* get the most canonical name */ - name=myldap_get_rdn_value(entry,attmap_protocol_cn); + name = myldap_get_rdn_value(entry, attmap_protocol_cn); /* get the other names for the protocol */ - aliases=myldap_get_values(entry,attmap_protocol_cn); - if ((aliases==NULL)||(aliases[0]==NULL)) + aliases = myldap_get_values(entry, attmap_protocol_cn); + if ((aliases == NULL) || (aliases[0] == NULL)) { - log_log(LOG_WARNING,"%s: %s: missing", - myldap_get_dn(entry),attmap_protocol_cn); + log_log(LOG_WARNING, "%s: %s: missing", + myldap_get_dn(entry), attmap_protocol_cn); return 0; } /* if the protocol name is not yet found, get the first entry */ - if (name==NULL) - name=aliases[0]; + if (name == NULL) + name = aliases[0]; /* check case of returned protocol entry */ - if ((reqname!=NULL)&&(STR_CMP(reqname,name)!=0)) + if ((reqname != NULL) && (STR_CMP(reqname, name) != 0)) { - for (i=0;(aliases[i]!=NULL)&&(STR_CMP(reqname,aliases[i])!=0);i++) - /* nothing here */ ; - if (aliases[i]==NULL) + for (i = 0; (aliases[i] != NULL) && (STR_CMP(reqname, aliases[i]) != 0); i++) + /* nothing */ ; + if (aliases[i] == NULL) return 0; /* neither the name nor any of the aliases matched */ } /* get the protocol number */ - protos=myldap_get_values(entry,attmap_protocol_ipProtocolNumber); - if ((protos==NULL)||(protos[0]==NULL)) + protos = myldap_get_values(entry, attmap_protocol_ipProtocolNumber); + if ((protos == NULL) || (protos[0] == NULL)) { - log_log(LOG_WARNING,"%s: %s: missing", - myldap_get_dn(entry),attmap_protocol_ipProtocolNumber); + log_log(LOG_WARNING, "%s: %s: missing", + myldap_get_dn(entry), attmap_protocol_ipProtocolNumber); return 0; } - else if (protos[1]!=NULL) + else if (protos[1] != NULL) { - log_log(LOG_WARNING,"%s: %s: multiple values", - myldap_get_dn(entry),attmap_protocol_ipProtocolNumber); + log_log(LOG_WARNING, "%s: %s: multiple values", + myldap_get_dn(entry), attmap_protocol_ipProtocolNumber); } - errno=0; - proto=strtol(protos[0],&tmp,10); - if ((*(protos[0])=='\0')||(*tmp!='\0')) + errno = 0; + proto = strtol(protos[0], &tmp, 10); + if ((*(protos[0]) == '\0') || (*tmp != '\0')) { - log_log(LOG_WARNING,"%s: %s: non-numeric", - myldap_get_dn(entry),attmap_protocol_ipProtocolNumber); + log_log(LOG_WARNING, "%s: %s: non-numeric", + myldap_get_dn(entry), attmap_protocol_ipProtocolNumber); return 0; } - else if ((errno!=0)||(proto<0)||(proto>UINT8_MAX)) + else if ((errno != 0) || (proto < 0) || (proto > UINT8_MAX)) { - log_log(LOG_WARNING,"%s: %s: out of range", - myldap_get_dn(entry),attmap_protocol_ipProtocolNumber); + log_log(LOG_WARNING, "%s: %s: out of range", + myldap_get_dn(entry), attmap_protocol_ipProtocolNumber); return 0; } /* write entry */ - WRITE_INT32(fp,NSLCD_RESULT_BEGIN); - WRITE_STRING(fp,name); - WRITE_STRINGLIST_EXCEPT(fp,aliases,name); + WRITE_INT32(fp, NSLCD_RESULT_BEGIN); + WRITE_STRING(fp, name); + WRITE_STRINGLIST_EXCEPT(fp, aliases, name); /* proto number is actually an 8-bit value but we write 32 bits anyway */ - WRITE_INT32(fp,proto); + WRITE_INT32(fp, proto); return 0; } NSLCD_HANDLE( - protocol,byname, + protocol, byname, char name[256]; char filter[4096]; - READ_STRING(fp,name); - log_setrequest("protocol=\"%s\"",name);, + READ_STRING(fp, name); + log_setrequest("protocol=\"%s\"", name);, NSLCD_ACTION_PROTOCOL_BYNAME, - mkfilter_protocol_byname(name,filter,sizeof(filter)), - write_protocol(fp,entry,name) + mkfilter_protocol_byname(name, filter, sizeof(filter)), + write_protocol(fp, entry, name) ) NSLCD_HANDLE( - protocol,bynumber, + protocol, bynumber, int protocol; char filter[4096]; - READ_INT32(fp,protocol); - log_setrequest("protocol=%lu",(unsigned long int)protocol);, + READ_INT32(fp, protocol); + log_setrequest("protocol=%lu", (unsigned long int)protocol);, NSLCD_ACTION_PROTOCOL_BYNUMBER, - mkfilter_protocol_bynumber(protocol,filter,sizeof(filter)), - write_protocol(fp,entry,NULL) + mkfilter_protocol_bynumber(protocol, filter, sizeof(filter)), + write_protocol(fp, entry, NULL) ) NSLCD_HANDLE( - protocol,all, + protocol, all, const char *filter; log_setrequest("protocol(all)");, NSLCD_ACTION_PROTOCOL_ALL, - (filter=protocol_filter,0), - write_protocol(fp,entry,NULL) + (filter = protocol_filter, 0), + write_protocol(fp, entry, NULL) ) |