John Summerfield wrote:
> 
> I have a code fragment:
>                 struct group *grp = getgrnam(group.data());
>                 if (grp == NULL)
>                   {
>                         int E=errno;
>                         cerr << "error=" << E << ": " << strerror(E) << " " << 
>ENOMEM<< endl;;
>                         cerr << "group " << group << " is unknown on this system." 
><< endl;
>                         err=max(1,err);
>                   }
>                 else
>                   {
>                         gid = grp->gr_gid;
>                   }

I tried it using C, and it worked fine.

-------------
#include <stdio.h>
#include <string.h>
#include <grp.h>
#include <sys/types.h>
#include <errno.h>

main ( int argv, char *argc[])
{
   struct group *grp;
   char *gum;

   gum=argc[1];
   grp=getgrnam(gum);
   if (grp == NULL)
   {
      printf("error %d : %s \n", errno, strerror(errno));
      printf(" group %s\n", gum);
   }
   else
      printf ("group %s : gid %d\n",gum, grp->gr_gid);
}
---------------

This returned the correct results for /etc/group
and the NIS group entries.

What does group.data() return?
Is it a char* or a C++ string?
Is there an auto cast for this?

In the error message you use group
as the string. should you i]use it instead of
the data() method?

        -Thomas



_______________________________________________
Redhat-devel-list mailing list
[EMAIL PROTECTED]
https://listman.redhat.com/mailman/listinfo/redhat-devel-list

Reply via email to