#include "request.h"

/* Diese Funktion ist nur fuer DOS-Filenamen (xxxxxxxx.xxx) geeignet */

char *make_name( char *input_name )
{
  char out_name[FILENAME_MAX], extracted_name[FILENAME_MAX];
  char node[5], net[5], tmp[5];
  int counter = 0, len, i;

  /* extract filename from path */
  len = strlen( input_name ) - 1;
  while ( (*(input_name+len) != '/') && (len-- !=0) );
  if ( len != 0 )
    len+=1;

  for ( i=len; i < strlen(input_name); i++ )
    extracted_name[counter++] = *(input_name+i);

  extracted_name[counter] = '\0';
  strcpy( filename, extracted_name );

  /* make output filename from filelistname */
  strncpy( tmp, filename, 4 );
  sprintf( net, "%04x", atoi( tmp ) );
  strncpy( tmp, filename+4, 4 );
  sprintf( node, "%04x", atoi( tmp ) );
  strcpy( out_name, net );
  strcat( out_name, node );
  strcat( out_name, ".req" );
  
  return out_name;

}
