* List
* String
* Machine
+ * Subnet
* Cluster
* Filesystem
* then we will have to rework the code that only looks at the first
{
register struct item *i, *t;
EXEC SQL BEGIN DECLARE SECTION;
- char iname[128];
+ char *iname;
int j, rowcount;
EXEC SQL END DECLARE SECTION;
+ char key;
int h, ctr;
- undouble_single_quotes(iname,name);
-
- h = hashname(iname, type);
+ h = hashname(name, type);
for (i = cachehead.next; i != &cachehead; i = i->next) {
if (i->nhash != h ||
- strcmp(iname, i->name) ||
+ strcmp(name, i->name) ||
strcasecmp(type, i->type))
continue;
*id = i->id;
}
cachemisses++;
+ iname = name;
+ key = *type;
+
+ if (!strcasecmp(type, "subnet"))
+ key = 'N';
- switch (*type) {
+ switch (key) {
case 'U':
case 'u':
- if (index(iname, '@')) {
+ if (index(iname, '@') || (strlen(iname) > 8)) {
sqlca.sqlcode = 100;
break;
}
case 'm':
EXEC SQL SELECT mach_id INTO :j FROM machine WHERE name=UPPERCASE(:iname);
break;
+ case 'N':
+ case 'n':
+ EXEC SQL SELECT snet_id INTO :j FROM subnet WHERE name=UPPERCASE(:iname);
+ break;
case 'C':
case 'c':
EXEC SQL SELECT clu_id INTO :j FROM cluster WHERE name=:iname;
if (sqlca.sqlcode != 0)
return(MR_INGRES_ERR);
*id = j;
- if (iname[0] == '#' && !strcasecmp(type, "USER"))
+ if (name[0] == '#' && !strcasecmp(type, "USER"))
return(MR_SUCCESS);
if (cachesize < CACHESIZE) {
i = (struct item *) malloc(sizeof(struct item));
cachehead.prev = i->prev;
i->prev->next = &cachehead;
}
- strcpy(i->name, iname);
+ strcpy(i->name, name);
strcpy(i->type, type);
i->nhash = h;
i->id = j;
}
-undouble_single_quotes(to, from)
-char *to;
-char *from;
-{
- register char *t,*f;
-
- for(t=to,f=from; *f; ) {
- if(*f=='\'' && f[1]=='\'') f++;
- *t++ = *f++;
- }
- *t='\0';
-}
-
-
/* Perform an ID to name mapping. name should be a pointer to a pointer to
* malloc'ed data. The buffer it refers to will be freed, and a new buffer
* allocated with the answer.
char iname[NAMESZ];
int j, rowcount;
EXEC SQL END DECLARE SECTION;
+ char key;
int ctr;
for (i = cachehead.next; i != &cachehead; i = i->next) {
cachemisses++;
j = id;
+ key = *type;
+ if (!strcasecmp(type, "subnet"))
+ key = 'N';
- switch (*type) {
+ switch (key) {
case 'U':
case 'u':
EXEC SQL SELECT CHAR(login) INTO :iname FROM users WHERE users_id=:j;
case 'm':
EXEC SQL SELECT CHAR(name) INTO :iname FROM machine WHERE mach_id=:j;
break;
+ case 'N':
+ case 'n':
+ EXEC SQL SELECT CHAR(name) INTO :iname FROM subnet WHERE snet_id=:j;
+ break;
case 'C':
case 'c':
EXEC SQL SELECT CHAR(name) INTO :iname FROM cluster WHERE clu_id=:j;