| Title: | DIGITAL UNIX (FORMERLY KNOWN AS DEC OSF/1) | 
| Notice: | Welcome to the Digital UNIX Conference | 
| Moderator: | SMURF::DENHAM | 
| Created: | Thu Mar 16 1995 | 
| Last Modified: | Fri Jun 06 1997 | 
| Last Successful Update: | Fri Jun 06 1997 | 
| Number of topics: | 10068 | 
| Total number of notes: | 35879 | 
    
    
    The following routine compiles fine under 4.0*, but under 3.2*
    returns:
    
    #  cc   iz1.c  -o iz1
    ld:
    Unresolved:
    setpwent_r
    getpwent_r
    endpwent_r
    
    Here's the code:
    
    #include <pwd.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <sys/types.h>
    main(argc, argv)
    int argc;
    char *argv[];
    {
    struct passwd pwbuf;
    char buffer[1024];
    int len;
    int count=0;
    FILE *pwf = NULL;
    setpwent_r(&pwf);
    while (getpwent_r(&pwbuf, buffer, 1024, &pwf) != -1){
       count++;
       printf("%s\n",buffer);
       }
    endpwent_r(&pwf);
    printf("lines=%d\n",count);
    }
    
| T.R | Title | User | Personal Name | Date | Lines | 
|---|---|---|---|---|---|
| 9504.1 | COL01::LINNARTZ | Tue Apr 15 1997 06:38 | 4 | ||
|     with V4.0 ther was a major cleanup with libc to make it thread safe
    and rentrant. before V4.0 you had to add -lc_r to your commandline
    
    Pit
 | |||||
| 9504.2 | Eureka | TAV02::JEREMY | Tue Apr 15 1997 08:30 | 1 | |
| Thanks a lot that did the trick! (And an answer within ten minutes!) | |||||
| 9504.3 | TAV02::JEREMY | Wed Apr 16 1997 02:06 | 2 | ||
|     Spoke too soon. It compiles OK, but puts out just blank lines.
    Any more ideas?
 | |||||
| 9504.4 | take a look at pwbuf :-) | COL01::LINNARTZ | Thu Apr 17 1997 16:31 | 1 | |
| 9504.5 | don't assume working buffer has valid data | TAV02::GOVER | Kobi Gover | Thu Apr 24 1997 01:34 | 16 | 
| >> <<< Note 9504.4 by COL01::LINNARTZ >>> >> -< take a look at pwbuf :-) >- Damn assumptions, the buffer parameter in getpwent_r is just a working area, and just because if have some valid content in unix 4.0 shouldn't lead us to think it's content in unix 3.2C will be valid. in the call getpwent_r(&pwbuf,buffer, 1024, &pwf) valid data is only in the pwbuf thanks to Pit Linnartz for hinting us on this. Kobi. | |||||