From: hchen3@uwo.ca Sent: Tuesday, February 12, 2002 3:54 PM To: Info-VAX@Mvb.Saic.Com Subject: Re: Question about Group ID Hi ALL: Thanks for the help on this particular topic. I learn a lot from all you guys (yeah, and the manual too -> a great read). I post the source code below and if there is any mistakes, please point out. Thanks again for all the great insight. Sammy int main(int argc, char* argv[]) { if (argc != 2) { cout << "invalid parameter count" << endl; return 1; } unsigned int context = 0; unsigned short int length = 0;; unsigned int resid = 0; unsigned int attibute = 0; char name[1024]; struct dsc$descriptor_s grp; grp.dsc$w_length = 1024; grp.dsc$b_dtype = DSC$K_DTYPE_T; grp.dsc$b_class = DSC$K_CLASS_S; grp.dsc$a_pointer = name; int status; struct stat statBuf; int stat_rc; double shift = pow(2.0, 16.0); if ((stat_rc = stat((char *) "fun.cpp", &statBuf)) != 0) { cerr << "stat failed" << endl; return -1; } if (!S_ISREG(statBuf.st_mode)) // only regular file allowed { cerr << "file is not regular" << endl; return -1; } unsigned int id = statBuf.st_gid * ((int) shift); // look up group name status = SYS$IDTOASC(id, &length, &grp, &resid, &attibute, &context); switch(status) { case SS$_ACCVIO: cout << "access violation" << endl; break; case SS$_INSFMEM: cout << "insufficient dynamic memory" << endl; break; case SS$_IVCHAN: cout << "invalid content in context" << endl; break; case SS$_IVIDENT: cout << "invalid format for identifier" << endl; break; case SS$_NOIOCHAN: cout << "No more rights database context streams are available." << endl; break; case SS$_NORIGHTSDB: cout << "The rights database does not exist" << endl; break; case SS$_NOSUCHID: cout << "The specified identifier name does not exist in the rights database, or the entire rights database has been searched if the ID is --1." << endl; break; default: if(strcasecmp(argv[1], name) == 0) { cout << "Group name matched" << endl; } else cout << "Group name mismatched" << endl; break; } return 0; }