static int badlistchars[] = {
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^@ - ^O */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* ^P - ^_ */
- 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* SPACE - / */
+ 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, /* SPACE - / */
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, /* 0 - ? */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, /* @ - O */
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0, /* P - _ */
SELECT nfsphys_id, TRIM (dir) FROM nfsphys
WHERE mach_id = :mach_id
ORDER BY 2 DESC;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr101;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr101 INTO :var_phys_id, :dir;
if(sqlca.sqlcode != 0) break;
id = *(int *)argv[0];
dir = argv[1];
- EXEC SQL REPEATED SELECT label INTO :cnt FROM filesys fs, nfsphys np
+ EXEC SQL REPEATED SELECT fs.tid INTO :cnt FROM filesys fs, nfsphys np
WHERE fs.mach_id = :id AND fs.phys_id = np.nfsphys_id
AND np.mach_id = :id AND np.dir = :dir;
if (cnt > 0)
name = argv[1];
if (name_to_id(name, "STRING", &id) != MR_SUCCESS) {
if (q->type != APPEND) return(MR_STRING);
- EXEC SQL SELECT value INTO :id FROM numvalues
- WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id
- WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
+ id=add_string(name);
cache_entry(name, "STRING", id);
}
if (ingres_errno) return(mr_errcode);
#ifdef GDSS
if (q->vcnt == U_END && *argv[U_SIGNATURE]) {
+ /* unquote ' chars in signature */
+ for (dst = src = argv[U_SIGNATURE]; *src; ) {
+ if (*src == '\'')
+ src++;
+ *dst++ = *src++;
+ }
+ *dst = 0;
sprintf(databuf, "%s:%s", argv[U_NAME], argv[U_MITID]);
/* skip bytes for timestamp & kname */
si.rawsig = (unsigned char *) rawsig;
name = kname_unparse(si.pname, si.pinst, si.prealm);
status = name_to_id(name, "STRING", &sigwho);
if (status == MR_NO_MATCH) {
- EXEC SQL REPEATED SELECT value INTO :sigwho FROM numvalues
- WHERE name='strings_id';
- sigwho++;
- EXEC SQL REPEATED UPDATE numvalues SET value = :sigwho
- WHERE name='strings_id';
- EXEC SQL INSERT INTO strings (string_id, string)
- VALUES (:sigwho, :name);
+ sigwho=add_string(name);
} else if (status)
return(status);
timestamp = si.timestamp;
{
EXEC SQL BEGIN DECLARE SECTION;
int who, status, id;
- char *entity, *name;
+ char *entity, *name, *src, *dst;
EXEC SQL END DECLARE SECTION;
#ifdef GDSS
char databuf[32], *kname_unparse();
#ifdef GDSS
if (q->vcnt == U_MODTIME && *argv[U_SIGNATURE + 1]) {
+ /* unquote ' chars in signature */
+ for (dst = src = argv[U_SIGNATURE+1]; *src; ) {
+ if (*src == '\'')
+ src++;
+ *dst++ = *src++;
+ }
+ *dst = 0;
login = malloc(1);
status = id_to_name(id, "USER", &login);
sprintf(databuf, "%s:%s", login, argv[U_MITID+1]);
name = kname_unparse(si.pname, si.pinst, si.prealm);
status = name_to_id(name, "STRING", &sigwho);
if (status == MR_NO_MATCH) {
- EXEC SQL REPEATED SELECT value INTO :sigwho FROM numvalues
- WHERE name='strings_id';
- sigwho++;
- EXEC SQL REPEATED UPDATE numvalues SET value = :sigwho
- WHERE name='strings_id';
- EXEC SQL INSERT INTO strings (string_id, string)
- VALUES (:sigwho, :name);
+ sigwho=add_string(name);
} else if (status)
return(status);
timestamp = si.timestamp;
return(MR_BAD_CHAR);
status = name_to_id(box, "STRING", &id);
if (status == MR_NO_MATCH) {
- EXEC SQL REPEATED SELECT value INTO :id FROM numvalues
- WHERE name='strings_id';
- id++;
- EXEC SQL REPEATED UPDATE numvalues SET value = :id
- WHERE name='strings_id';
- EXEC SQL INSERT INTO strings (string_id, string)
- VALUES (:id, :box);
+ id=add_string(box);
} else if (status)
return(status);
EXEC SQL REPEATED UPDATE users SET potype='SMTP', box_id = :id
optimize_sql_stmt(qual);
EXEC SQL DECLARE csr102 CURSOR FOR SELECT list_id FROM list
WHERE :qual;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr102;
+ if (ingres_errno)
+ return(mr_errcode);
while(1)
{
EXEC SQL FETCH csr102 INTO :id;
EXEC SQL DECLARE csr103 CURSOR FOR
SELECT list_id, ref_count FROM imembers
WHERE member_id = :lid AND member_type='LIST';
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr103;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr103 INTO :id, :ref;
if(sqlca.sqlcode != 0) break;
SELECT member_id, member_type, ref_count
FROM imembers
WHERE list_id = :mid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr104;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr104 INTO :id, :dtype, :ref;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr105 CURSOR FOR
SELECT list_id, ref_count FROM imembers
WHERE member_id = :lid AND member_type = 'LIST';
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr105;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr105 INTO :id, :ref;
if(sqlca.sqlcode!=0) break;
EXEC SQL DECLARE csr106 CURSOR FOR
SELECT member_id, member_type, ref_count FROM imembers
WHERE list_id = :mid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr106;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr106 INTO :id, :dtype, :ref;
if(sqlca.sqlcode!=0) break;
EXEC SQL DECLARE csr107 CURSOR FOR
SELECT list_id FROM imembers
WHERE member_type='LIST' AND member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr107;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr107 INTO :listid;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr108 CURSOR FOR
SELECT list_id FROM imembers
WHERE member_type='USER' AND member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr108;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr108 INTO :listid;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr109 CURSOR FOR
SELECT list_id FROM imembers
WHERE member_type='KERBEROS' AND member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr109;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr109 INTO :listid;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr110 CURSOR FOR
SELECT label FROM filesys
WHERE owners = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr110;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr110 INTO :name;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr111 CURSOR FOR
SELECT capability FROM capacls
WHERE list_id = :aid ;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr111;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr111 INTO :name ;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr112 CURSOR FOR
SELECT label FROM filesys
WHERE owner = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr112;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr112 INTO :name ;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr113 CURSOR FOR
SELECT name FROM list
WHERE acl_type = :atype AND acl_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr113;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr113 INTO :name;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr114 CURSOR FOR
SELECT name FROM servers
WHERE acl_type = :atype AND acl_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr114;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr114 INTO :name;
if(sqlca.sqlcode != 0) break;
SELECT name FROM machine m, hostaccess ha
WHERE m.mach_id = ha.mach_id AND ha.acl_type = :atype
AND ha.acl_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr115;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr115 INTO :name;
if(sqlca.sqlcode != 0) break;
OR z.sub_type = :atype AND z.sub_id = :aid
OR z.iws_type = :atype AND z.iws_id = :aid
OR z.iui_type = :atype AND z.iui_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr116;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr116 INTO :name;
if(sqlca.sqlcode != 0) break;
FROM list l, imembers im
WHERE l.list_id = im.list_id AND im.direct = 1
AND im.member_type = :atype AND im.member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr117a;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr117a
INTO :name, :active, :public, :hidden, :maillist, :grouplist;
FROM list l, imembers im
WHERE l.list_id = im.list_id
AND im.member_type = :atype AND im.member_id = :aid;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr117b;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr117b
INTO :name, :active, :public, :hidden, :maillist, :grouplist;
EXEC SQL DECLARE csr118 CURSOR FOR
SELECT member_type, member_id FROM imembers
WHERE list_id = :list_id AND direct > :direct;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr118;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr118 INTO :member_type, :member_id;
if (sqlca.sqlcode != 0) break;
WHERE im.list_id = :list_id AND im.member_type = 'USER'
AND im.member_id = u.users_id AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr119;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr119 INTO :member_name;
if(sqlca.sqlcode != 0) break;
WHERE im.list_id = :list_id AND im.member_type='LIST'
AND im.member_id = l.list_id AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr120;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr120 INTO :member_name;
if(sqlca.sqlcode != 0) break;
WHERE im.list_id = :list_id AND im.member_type='STRING'
AND im.member_id = str.string_id AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr121;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr121 INTO :member_name;
if(sqlca.sqlcode != 0) break;
AND im.member_id = str.string_id
AND im.direct > :direct
ORDER BY 1;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr122;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr122 INTO :member_name;
if(sqlca.sqlcode != 0) break;
EXEC SQL DECLARE csr124 CURSOR FOR
SELECT sh.service, m.name FROM serverhosts sh, machine m
WHERE :qual;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr124;
+ if (ingres_errno)
+ return(mr_errcode);
while(1) {
EXEC SQL FETCH csr124 INTO :sname, :mname;
if(sqlca.sqlcode != 0) break;
/* check new login name */
EXEC SQL REPEATED SELECT COUNT(login) INTO :rowcount FROM users
- WHERE login = LEFT(:login,SIZE(login)) AND users_id != :users_id;
+ WHERE login = :login AND users_id != :users_id;
if (ingres_errno) return(mr_errcode);
if (rowcount > 0) return(MR_IN_USE);
EXEC SQL REPEATED SELECT COUNT(name) INTO :rowcount FROM list
- WHERE name = LEFT(:login,SIZE(name));
+ WHERE name = :login;
if (ingres_errno) return(mr_errcode);
if (rowcount > 0) return(MR_IN_USE);
EXEC SQL REPEATED SELECT COUNT(label) INTO :rowcount FROM filesys
- WHERE label = LEFT(:login,SIZE(label));
+ WHERE label = :login;
if (ingres_errno) return(mr_errcode);
if (rowcount > 0) return(MR_IN_USE);
com_err(whoami, 0, "login name OK");
AND sh.value2 - sh.value1 =
(SELECT MAX(value2 - value1) FROM serverhosts
WHERE service = 'POP');
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL OPEN csr130;
+ if (ingres_errno)
+ return(mr_errcode);
EXEC SQL FETCH csr130 INTO :mid, :machname;
if (sqlca.sqlerrd[2] == 0) {
EXEC SQL CLOSE csr130;
return(MR_EXISTS);
} else if (status == MR_NO_MATCH && !strcmp(tbl, "strings") &&
(q->type == APPEND || q->type == UPDATE)) {
- EXEC SQL SELECT value INTO :id FROM numvalues
- WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
+ id=add_string(name);
cache_entry(name, "STRING", id);
*(int *)argv[vo->index] = id;
return(MR_EXISTS);
*index(data_type, ' ') = 0;
if (!strcmp(data_type, "user")) {
/* USER */
+ if (index(name, '@'))
+ return(MR_USER);
status = name_to_id(name, data_type, &id);
if (status && (status == MR_NO_MATCH || status == MR_NOT_UNIQUE))
return(MR_USER);
return(MR_STRING);
if (status == MR_NO_MATCH) {
if (q->type != APPEND && q->type != UPDATE) return(MR_STRING);
- EXEC SQL SELECT value INTO :id FROM numvalues WHERE name = 'strings_id';
- id++;
- EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
- EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
+ id=add_string(name);
cache_entry(name, "STRING", id);
} else if (status) return(status);
} else if (!strcmp(data_type, "none")) {
}
for(j=0; j<QMAXARGS; j++) {
- if((it->sqlvar[j].sqldata=malloc(sizeof(short)+QMAXARGSIZE))==NULL) {
+ if((it->sqlvar[j].sqldata=malloc(sizeof(short)+ARGLEN))==NULL) {
com_err(whoami, MR_NO_MEM, "setting up SQLDA variables");
exit(1);
}
- it->sqlvar[j].sqllen=QMAXARGSIZE;
+ it->sqlvar[j].sqllen=ARGLEN;
it->sqlvar[j].sqlind=null_indicators+j;
null_indicators[j]=0;
}
convert_wildcards(arg)
char *arg;
{
- static char buffer[QMAXARGSIZE];
+ static char buffer[ARGLEN];
register char *s, *d;
for(d=buffer,s=arg;*s;s++) {
convert_wildcards_uppercase(arg)
char *arg;
{
- static char buffer[QMAXARGSIZE];
+ static char buffer[ARGLEN];
register char *s, *d;
for(d=buffer,s=arg;*s;s++) {
}
}
+
+
+/* Adds a string to the string table. Returns the id number.
+ *
+ */
+int add_string(name)
+ EXEC SQL BEGIN DECLARE SECTION;
+ char *name;
+ EXEC SQL END DECLARE SECTION;
+{
+ EXEC SQL BEGIN DECLARE SECTION;
+ char buf[256];
+ int id;
+ EXEC SQL END DECLARE SECTION;
+
+ EXEC SQL SELECT value INTO :id FROM numvalues WHERE name = 'strings_id';
+ id++;
+ EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
+
+ /* Use sprintf to get around problem with doubled single quotes */
+ sprintf(buf,"INSERT INTO strings (string_id, string) VALUES (%d, '%s')",id,name);
+ EXEC SQL EXECUTE IMMEDIATE :buf;
+
+ return(id);
+}
+
+
/* eof:qsupport.dc */