strcpy(new_name, name);
strncpy(new_name, name, sizeof(new_name)); new_name[sizeof(new_name)-1] = '\0';
XpmWriteFileFromXpmImage(filename, image, info)    char *filename;    XpmImage *image;    XpmInfo *info;{    xpmData mdata;    char *name, *dot, *s, new_name[BUFSIZ];    int ErrorStatus;    /* open file to write */    if ((ErrorStatus = OpenWriteFile(filename, &mdata)) != XpmSuccess)	return (ErrorStatus);    /* figure out a name */    if (filename) {#ifdef VMS	name = filename;#else	if (!(name = rindex(filename, '/'))#ifdef AMIGA	    && !(name = rindex(filename, ':'))#endif     )	    name = filename;	else	    name++;#endif	/* let's try to make a valid C syntax name */	if (index(name, '.')) {	    strcpy(new_name, name);	    /* change '.' to '_' */	    name = s = new_name;	    while ((dot = index(s, '.'))) {		*dot = '_';		s = dot;	    }	}	if (index(name, '-')) {	    if (name != new_name) {		strcpy(new_name, name);		name = new_name;	    }	    /* change '-' to '_' */	    s = name;	    while ((dot = index(s, '-'))) {		*dot = '_';		s = dot;	    }	}    } else	name = "image_name";    /* write the XpmData from the XpmImage */    if (ErrorStatus == XpmSuccess)	ErrorStatus = xpmWriteFile(mdata.stream.file, image, name, info);    xpmDataClose(&mdata);    return (ErrorStatus);}