On Mon, Feb 04, 2002 at 03:08:45PM -0800, Jamie Harrell wrote:
> Here's the trick...
>
> Say you create 2 characters under your account....
> dumb & bumm - for the sake of argument...
>
> say your account name is Jason
>
> So you'd have 2 pfiles:
>
> Baggins.Jason
> Jessie.Jason
>
> Now, if you were to try to login under either of those, I need
> to make sure Baggins.Jason exists, no biggy there, access() would
> work fine...
>
> But say then you tried to login under a name that is not yours, say for
> instance: Penthral
>
> So it would look for Penthral.Jason
>
> No biggie there, if that character isn't created, however, if that
> happens to be under another name, say the pfile Penthral.Weirdo
> already exists, well, I need to make sure that you dont create
> that character... Hence the reason I'm checking against Penthral.*
>
> So, I guess my real question is, to the best of my knowledge,
> access() doesn't allow wildcards, am I mistaken in this?
it does not.
> And to the other repliers, thank you, I've been working on getting
> this fixed for a while now, and that's actually the reason I went with this
> less-effective ls method, as I could think of no other way to check to see
> if a character exists under ANY account...
something like this:
#include <sys/types.h>
#include <dirent.h>
bool does_char_exist ( char * try )
{
int n = strlen(try);
DIR * dot;
struct dirent * item;
dot = opendir("../player");
if ( ! dot ) {
perror("does_char_exist? hell no, can't even open the dirctory!");
exit(1);
}
while ( item = readdir(dot) )
{
if ( ! strncmp( item->d_name, try, n) )
{
/* uhoh... we -may- have a match... note this believes that
Foofoo.Fred makes 'Foo' taken (since we only compare the
first three characters... it also doesn't do case
consideration... it would probably be best to just hack
your own string compare here.
*/
}
}
closedir(dot);
return FALSE;
}