...
In this non-compliant code example, the string literal "localhost"
and integer constant 1234
are embedded directly in program logic, and are consequently difficult to change.
Code Block | ||
---|---|---|
| ||
ifLDAP ( (*ld = ldap_init("localhost", 1234)); if ( ld == NULL) { perror("ldap_init"); return(1); } |
...
Code Block | ||
---|---|---|
| ||
#ifndef PORTNUMBER /* might be passed on compile line */ # define PORTNUMBER 1234 #endif #ifndef HOSTNAME /* might be passed on compile line */ # define HOSTNAME "localhost" #endif /* ... */ ifLDAP ( (*ld = ldap_init(HOSTNAME"localhost", PORTNUMBER ))1234); if ( ld == NULL) { perror("ldap_init"); return(1); } |
...