namecheck.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
/*
* Copyright (c) 1985 AT&T
* All Rights Reserved
*/
#ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.17 */
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#include <ctype.h>
#include <time.h>
#include <errno.h>
#include "mio.h"
#include "wish.h"
#include "typetab.h"
#include "partabdefs.h"
#include "message.h"
#include "sizes.h"
bool
bool is_new;
{
int len;
char *p;
int span;
int fs_max_fix;
int maxchar;
int maxpath;
int retval;
struct opt_entry *obj_to_parts();
struct ott_entry *dname_to_ott();
extern char * part_construct();
extern char * path_to_fstype();
extern char Opwd[];
#ifdef _DEBUG
#endif
*errstr = "Object name must have at least 1 character";
return(FALSE);
}
/* miked k17 */
/* for (p = name; *p; p++) */ /* convert spaces and tabs to underlines */
/* if (*p == ' ' || *p == '\t')
*p = '_';
*/
for (p = name; *p; p++) /* check for spaces and tabs */
if (*p == ' ' || *p == '\t') {
return(FALSE);
}
if (objtype)
else
/* if ( path && ! strcmp(path_to_fstype(path),"s5") ) */
/*
* this mess sets the maximum object name size depending on the
* file system type of the path arguement or, if path is null,
* on the value of Opwd, a global containing the pathname of
* the last filefolder made current. The mechanations with
* fs_max_fix are because the is a table in Parts that contains
* max object lengths that are based on 255. This table cannot
* be changed to reflect s5 .vs. ufs so the kluge is made here.
*/
else
fs_max_fix = 0;
if (opt) {
} else {
}
/*
* changed 12 to 14 here. miked .. upped 14 to FILE_NAME_SIZ. abs
*/
return(FALSE);
}
/* check if total pathsize to big */
if (opt)
else
"Can't create object: folder path length exceeds %d characters\n"
return(FALSE);
}
/* if ((span=strcspn(name, "!@#$^&*(){}[]|\\`~;\"'<>/?")) < len) {
miked */
return(FALSE);
}
for (p = name; *p; p++) /* test for only printable characters. miked */
if ( iscntrl( *p ) ) {
"Object name cannot contain the special character ^%c",
(*p + '@'));
return(FALSE);
}
return(FALSE);
}
if (!is_new) {
#ifdef _DEBUG
#endif
return(TRUE);
}
if (path) {
} else
pathbuf[0] = '\0';
if (template)
else
#ifdef _DEBUG
#endif
#ifndef WISH
/* check if the object is in the wastebasket */
} else
oldpath[0] = '\0';
else
*errstr = "An object with that name already exists";
} else
if (oldpath[0]) { /* restore old ott */
}
#else
} else
#endif
#ifdef _DEBUG
#endif
return(retval);
}
static int
char *template;
{
int max_len;
register char *p = template;
while (*p && *p != '%')
p++;
if (*p == '\0')
return(FILE_NAME_SIZ -1);
p++;
if (*p != '.')
return(FILE_NAME_SIZ -1);
p++;
return(FILE_NAME_SIZ -1);
return(max_len);
}