/**********************************************************************
*
*  projet   : DilibPro
*  module   : Dam  (Dilib Acces Method)
*  fichier  : DamName.c
*  Auteur   : Jacques DUCLOY
*  Date     : Fevrier 94
*  $Id: DamName.c,v 1.2 2004/01/20 17:10:05 parmentf Exp $
*
***********************************************************************
* 
*     Copyright (C) 1975 CRIN - CNRS & INRIA Lorraine
*
***********************************************************************/
/**
   @file

   @brief Functions for DamName testing
   
   @author &copy; 1994 INIST-CNRS
   @author Jacques DUCLOY <DilibMaster@inist.fr>
 */

#include <stdio.h>
#include <string.h>

#include "DamHfd.h"

/**
   Says wether a @a name is a DamNameDir.

   @param name name of a directory to test
   @return 0 if @a name is not a Dam Directory Name 
                          (should end with .hfd (?))
 */
int DamNameIsDir(char *name)
{
  char *suff;
  int l;

  l=strlen(name);
  suff=name+l-1;
  if (l<4)return 0;
  if (*suff-- != 'd')return 0;
  switch (*suff--)
    {
    case 'd':
    case 'h':
      if (*suff-- == '.') return 1;
      return 0;
    case 'f':
      if (*suff-- != 'h') return 0;
      if (l<5) return 0;
      if (*suff !='.') return 0;
      return 1;
    default:
      return 0;
    }
}


/**
   Says wether a @a name is a DamNameFile.

   @param name name of a file to test
   @return 0 if @a name is not a Dam File Name (should end with .df)
 */
int DamNameIsFile(char *name)
{
  char *suff;
  int l;

  l=strlen(name);
  suff=name+l-1;
  if (l<4)return 0;
  if (*suff-- != 'f')return 0;
  if (*suff-- != 'd')return 0;
  if (*suff != '.') return 0;
  return 1;
}

