Main Page   Alphabetical List   Data Structures   File List   Data Fields   Globals   Examples  

test_basename.c

This file shows how to use the function base_dir_name().

#include <stdio.h>
#include "my_dir.h"

int main (int argc, char *argv[])
{
  int   cr;
  char  *bname;



  if (argc != 2)
  {
    fprintf (stderr, "\nUsage: basename.test <file name>\n");
    return 1;
  }

  cr =  base_dir_name (argv[1], &bname);

  switch (cr)
  {
    case BASE_DIR_NOT_FOUND:
         fprintf (stdout, "\nbase name not found\n");
         return 0;
    case BASE_DIR_NO_MEM:
         fprintf (stderr, "\nCan not allocate memory\n");
         return 1;
  }

  if (bname != NULL)
  { 
    fprintf (stdout, "\nbase name found: %s\n\n", bname);
    free (bname);
    return 0;
  }

  fprintf (stderr, "\nNULL pointer ! ==> ERROR !!!");

  return 1;
}

Generated on Thu Apr 3 16:23:40 2003 for Common_C_libraries by doxygen1.3-rc1