df_make_name()

Purpose

constructs the file name from its component parts

Old name

#define _nmfl df_make_name

Syntax

char* df_make_name(prefix, name, suffix, suff_over_ride)

Parameters

char* prefix

Prefix to use in constructed file name

 

char* name

Name of file

 

char* suffix

Suffix to use in constructed file name

 

int suff_over_ride

Indicates whether suffix in file name should be overidden

Description

The df_make_name function constructs a file name from a prefix, a name and a suffix. The prefix indicates the disk and overrides that given in the name. The suffix contains 3 characters or less (except with UNIX). Typical suffixes used in DP4 are .PRN, .RLB, .DAT and .IND

Return values

Returns null-terminated pointer to the constructed name

See also

/*
C Functions Reference Manual
----------------------------
Filename: DF_MAKE_.C
Example: df_make_name
Purpose: program illustrates df_make_name by asking
user to specify prefix, name and suffix
strings, and generating the result
*/

/*
#db salesord
#c
#end
*/
#include "dp4.h"
#include "userdata.h"
#include "df_make_.h"
/* generate this file by running LIBMAKE */

static char suffix[12];
static char prefix[4];
static char name[32];
static boolean suff_over_ride;
/* prototypes */
void nmfl_inner(int,int*);
void zero_term(char*,int);
void demo_nmfl(void);
void process()
{
trm_read_user();
/* only required if using Microsoft C: a bug in
the linker causes an unresolved external error
in the DP4 library */
map_draw(1,RETAIN);
while (map_get_inputs(20,1,nmfl_inner,
CLEAR|GI_GLOBALS) != 0);
}

static void zero_term(char* name,int max_len)
{
register int i = 0;
while (*name != ' ' && i < max_len)
{
i++; name++;
}
*name = '\0';
}

static void nmfl_inner(int m,int* f)
{
/* get entries - forget about bad entries */
switch (*f)
{
case 1:
inpm_c(prefix);
break;
case 2:
inpm_c(name);
break;
case 3:
inpm_c(suffix);
break;
case 4:
inpm_y(&suff_over_ride);
break;
case 5:
/* null terminate all names used */
zero_term(prefix,sizeof(prefix) - 1);
zero_term(name,sizeof(name) - 1);
zero_term(suffix,sizeof(suffix) - 1);
showc(m,*f,df_make_name(prefix,name,suffix,
suff_over_ride));
/* Fall through to omit */
default:
inpm_omit();
break;
}
}