
/******************************************************************************
 *
 * RCS ID
 * $Id: stubs,v 1.12 2002/11/17 16:43:22 david Exp $
 *
 * HISTORY
 * $Log: stubs,v $
 * Revision 1.12  2002/11/17 16:43:22  david
 * Updates to compiler with new 32-bit compiler
 *
 * Revision 1.11  2000/04/22 14:50:49  david
 * Updates for nmbd module debugging.
 * Updates for integrating nmbd with main smbserver application
 *
 * Revision 1.10  2000/04/17 17:02:47  david
 * *** empty log message ***
 *
 * Revision 1.9  2000/04/17 16:46:01  david
 * updates after testing event poll word non zero stuff
 *
 * Revision 1.8  2000/02/17 22:07:16  david
 * Added saved_challenge and challenge_sent to tClients for encryption
 * negprot - changed a DEBUG 0 to 1
 *
 * C
 *
 * CVS:
 *
 * Revision 1.7  2000/02/08 21:37:45  david
 * Removed functions now in core code.
 *
 * Revision 1.6  2000/02/08 20:16:25  david
 * Tidied up exit calls
 *
 * Revision 1.5  2000/01/29 17:19:52  david
 * Updates to support passwords
 * upped to version 0.06
 *
 * Revision 1.4  1999/11/23 22:00:16  david
 * Updates for long filename support.
 * Added files for Coreplus, Lanman1, Lanman2 and NT protorocols.
 *
 * Revision 1.3  1999/08/08 17:27:56  david
 * Removed check_access from stubs
 *
 * Revision 1.2  1999/06/20 13:45:45  david
 * Added some more stubs!
 *
 * Revision 1.1  1999/05/16 12:00:07  david
 * Initial revision
 *
 *
 *****************************************************************************/
 

#include "includes.h"
#include "kernel.h"
#include "swis.h"


void remove_pending_lock_requests_by_fid(files_struct *fsp)
{

}

void remove_pending_lock_requests_by_mid(int mid)
{

}


struct passwd guestPasswd;
int get_pwname_count=0;

struct passwd *stub_Get_Pwnam(char *user,BOOL allow_change)
{ 
  if (get_pwname_count==0)
  { 
    get_pwname_count++;
    guestPasswd.pw_name=(char*) malloc(strlen(user)+1);
    strcpy(guestPasswd.pw_name,user);
    guestPasswd.pw_passwd=(char*) malloc(strlen("hello")+1);
    strcpy(guestPasswd.pw_passwd,"hello");
    guestPasswd.pw_uid=500;
    guestPasswd.pw_gid=500;              
    guestPasswd.pw_gecos=(char*) malloc(sizeof("Guest")+1);
    strcpy(guestPasswd.pw_gecos,"Guest");
    guestPasswd.pw_dir=(char *) malloc(sizeof("\\")+1);
    strcpy(guestPasswd.pw_dir,"\\");                   
    guestPasswd.pw_shell=(char *) malloc(sizeof("RISCOS")+1);
    strcpy(guestPasswd.pw_shell,"RISCOS");                     
  }

  return &guestPasswd;
}    
                                  

void init_uid(void)
{
}

BOOL become_guest(void)
{
  return True;
}

BOOL become_user(connection_struct *conn, uint16 vuid)
{             
  return True;
}

BOOL unbecome_user(void )
{
  return True;
}             

void become_root(BOOL save_dir)
{
}

void unbecome_root(BOOL restore_dir)
{

}


                

void release_file_oplock(files_struct *fsp)
{
}



extern tpClients clients;

fstring *remoteMachine(int fd)
{
   tpClients aclient=clients;
   fstring   *result=NULL;
          
   while (aclient!=NULL)
   {
      if (fd==aclient->clientFd)
      {
        result=&aclient->remote_machine;
        break;
      }  
      aclient=aclient->next;
   }                                  

   return result;
}                           

fstring *localMachine(int fd)
{
   tpClients aclient=clients;
   fstring   *result=NULL;
          
   while (aclient!=NULL)
   {
      if (fd==aclient->clientFd)
      {
        result=&aclient->local_machine;
        break;
      }  
      aclient=aclient->next;
   }                                  

   return result;
}               

fstring *clientNativeOs(int fd)
{
   tpClients aclient=clients;
   fstring   *result=NULL;
          
   while (aclient!=NULL)
   {
      if (fd==aclient->clientFd)
      {
        result=&aclient->nativeOs;
        break;
      }  
      aclient=aclient->next;
   }                                  

   return result;
}       

void generateNextChallenge(int fd,unsigned char *buf)
{                
   BOOL      result=False;
   tpClients aclient=clients;
          
   while (aclient!=NULL)
   {
      if (fd==aclient->clientFd)
      {
        memcpy(aclient->saved_challenge, buf, 8);
        aclient->challenge_sent = True; 
        result=True;     

        DEBUG(5,("generateNextChallenge %d\n",fd)); 
        break;
      }  
      aclient=aclient->next;
   }                

   if (result==False)
   {
     DEBUG(0,("Failed to find %fd\n",fd));
   }
}

BOOL setChallenge(int fd,unsigned char *buf)
{                
   BOOL      result=False;
   tpClients aclient=clients;
          
   while (aclient!=NULL)
   {
      if (fd==aclient->clientFd)
      {
        memcpy(aclient->saved_challenge, buf, 8);
        aclient->challenge_sent = True; 
        result=True;                    

        DEBUG(5,("setChallenge %d\n",fd)); 
        break;
      }  
      aclient=aclient->next;
   }                

   if (result==False)
   {
     DEBUG(0,("Failed to find %fd\n",fd));
   }

   return result;
}

BOOL lastChallenge(int fd,unsigned char *buf)
{                
   BOOL      result=False;
   tpClients aclient=clients;
          
   while (aclient!=NULL)
   {
      if (fd==aclient->clientFd)
      {
        if (!aclient->challenge_sent) 
           return(False);

        memcpy(buf, aclient->saved_challenge, 8);
 
        result=True;                         

        DEBUG(5,("lastChallenge %d\n",fd));    
        break;
      }  
      aclient=aclient->next;
   }                

   if (result==False)
   {
     DEBUG(0,("Failed to find %fd\n",fd));
   }

   return result;
}

int smbrun(char *cmd,char *outfile,BOOL shared)
{
  _kernel_swi_regs r;               
  _kernel_oserror *e=NULL;    
  char comm[256];
  int  result=-1;   

  if (outfile!=NULL)
  {
    sprintf(comm,"%s { > %s }",cmd ,outfile); 
    r.r[0] = (int) comm;      
    DEBUG(5,("smbrun %s\n", comm));
  }                    
  else                     
  {
    r.r[0] = (int) cmd;
    DEBUG(5,("smbrun %s\n", cmd));
  }                                    
  
 
  
  e = _kernel_swi(OS_CLI, &r, &r);                     
                    
  if (e==NULL)
  {          
    /* success */
    result=0;
  }            

  return result;
}




/*******************************************************************
check a files mod time
********************************************************************/
time_t file_modtime(char *fname)
{ 

  SMB_STRUCT_STAT st;
  
  if (sys_stat(fname,&st) != 0) 
    return(0);

  return(st.st_mtime); 

}

mode_t umask(mode_t mask)
{
   return mask;
}


/* no in lib.c.replace
char *strdup(const char *s)
{
  int i;
  char *r;

  if (!s)
    return (0);

  i = strlen (s) + 1;
  if (!(r = malloc (i)))
    return (0);
  memcpy ((void *) r, (void *) s, i);
  return (r);
}
*/

char *gidtoname(gid_t gid)
{
   return "group";
}
  
  

    
 
BOOL attempt_close_oplocked_file(files_struct *fsp)
{
  return False;
}

BOOL push_blocking_lock_request( char *inbuf, int length, int lock_timeout, int lock_num)
{
  return True;
}


BOOL reload_services(BOOL test)
{
  return (True);  
}



int dup2(int oldfd, int newfd)
{
  return oldfd;
}              

void BlockSignals(BOOL block,int signum)
{

}

void fault_setup(void (*fn)(void *))
{

}

BOOL process_exists(int pid)
{
  return False;
}


void pidfile_create(char *name)
{

}








