...on a Unix box.

As the subject states, I am re-writing the ls -F command in C++, but I am having trouble adding some of the Formatting characters to the files names. Here is my code:

Code:
 if (strcmp(buff, "-F")==0)
  {
     struct stat s;
     stat(direntp->d_name,&s);
     cout<<direntp->d_name;
     if(s.st_mode & S_IFDIR)
          cout<<"/"<<endl;
   else
     if(s.st_mode & S_IFIFO)
         cout<<"|"<<endl;
   else
     if(s.st_mode & S_IFLNK)
         cout<<" "<<endl;
   else
     if(s.st_mode & S_IFDOOR)
         cout<<">"<<endl;
   else
     if(s.st_mode & S_IFSOCK)
         cout<<"="<<endl;
   else
     if((s.st_mode & S_IXUSR) && (s.st_mode & S_IFLNK))
           cout<<"*"<<endl;
     else
       cout<<"?"<<endl;
  }//end if
It is adding the correct formatting character ("/") for directories, but not for my execuatble files such as "a.out" and "paige_sh" which should have an asterick (*). Here is a sample run:

Code:
mars:$ a.out
-F
./
../
shell1.cpp
env.c
core

a.out
modshell2.1.cpp
read_command
shell.sh
shell
test.sh
ansipr
shell2.c.save
paige_sh
modshell1.2.cpp
modshell1.3.cpp
gid.c
modshell2.3.cpp
1814shell.cpp
cpplist
uid.c
listfile.txt
listDir.cpp
modshell2.cpp
modshell2.2.cpp
rewritels.cpp
writels2.cpp
justafile.txt
justafile2.txt
justadir/
justadir2/
can anyone help?? Thanks.