]> andersk Git - moira.git/blobdiff - server/qvalidate.pc
punt mrgdb
[moira.git] / server / qvalidate.pc
index fa25f891bd29018260c1811db9082dbd8c1064ef..797980f63cb96df6030c0fa3005299b4b12906f3 100644 (file)
@@ -1,27 +1,26 @@
-/*
- *     $Source$
- *     $Author$
- *     $Header$
+/* $Id$
  *
- *     Copyright (C) 1987 by the Massachusetts Institute of Technology
- *     For copying and distribution information, please see the file
- *     <mit-copyright.h>.
+ * Argument validation routines
  *
+ * Copyright (C) 1987-1998 by the Massachusetts Institute of Technology
+ * For copying and distribution information, please see the file
+ * <mit-copyright.h>.
  */
 
-#ifndef lint
-static char *rcsid_qsupport_dc = "$Header$";
-#endif lint
-
 #include <mit-copyright.h>
-#include <unistd.h>
 #include "mr_server.h"
 #include "query.h"
+#include "qrtn.h"
+
 #include <ctype.h>
+#include <stdlib.h>
 #include <string.h>
+#include <unistd.h>
+
 EXEC SQL INCLUDE sqlca;
 EXEC SQL INCLUDE sqlda;
-#include "qrtn.h"
+
+RCSID("$Header$");
 
 extern char *whoami, *table_name[], *sqlbuffer[QMAXARGS];
 extern int dbms_errno, mr_errcode;
@@ -42,6 +41,7 @@ int readlock_table(struct valobj *vo);
 int convert_wildcards_uppercase(char *arg);
 
 extern SQLDA *sqlald(int, int, int);
+SQLDA *mr_alloc_sqlda(void);
 
 EXEC SQL WHENEVER SQLERROR DO dbmserr();
 
@@ -57,10 +57,6 @@ int validate_row(struct query *q, char *argv[], struct validate *v)
   /* build where clause */
   build_qual(v->qual, v->argc, argv, qual);
 
-  if (log_flags & LOG_VALID)
-    /* tell the logfile what we're doing */
-    com_err(whoami, 0, "validating row: %s", qual);
-
   /* look for the record */
   sprintf(stmt_buf, "SELECT COUNT (*) FROM %s WHERE %s",
          table_name[q->rtable], qual);
@@ -85,59 +81,30 @@ int validate_fields(struct query *q, char *argv[], struct valobj *vo, int n)
       switch (vo->type)
        {
        case V_NAME:
-         if (log_flags & LOG_VALID)
-           {
-             com_err(whoami, 0, "validating %s in %s: %s",
-                     vo->namefield, table_name[vo->table], argv[vo->index]);
-           }
          status = validate_name(argv, vo);
          break;
 
        case V_ID:
-         if (log_flags & LOG_VALID)
-           {
-             com_err(whoami, 0, "validating %s in %s: %s",
-                     vo->idfield, table_name[vo->table], argv[vo->index]);
-           }
          status = validate_id(q, argv, vo);
          break;
 
        case V_TYPE:
-         if (log_flags & LOG_VALID)
-           {
-             com_err(whoami, 0, "validating %s type: %s",
-                     table_name[vo->table], argv[vo->index]);
-           }
          status = validate_type(argv, vo);
          break;
 
        case V_TYPEDATA:
-         if (log_flags & LOG_VALID)
-           {
-             com_err(whoami, 0, "validating typed data (%s): %s",
-                     argv[vo->index - 1], argv[vo->index]);
-           }
          status = validate_typedata(q, argv, vo);
          break;
 
        case V_RENAME:
-         if (log_flags & LOG_VALID)
-           {
-             com_err(whoami, 0, "validating rename %s in %s",
-                     argv[vo->index], table_name[vo->table]);
-           }
          status = validate_rename(argv, vo);
          break;
 
        case V_CHAR:
-         if (log_flags & LOG_VALID)
-           com_err(whoami, 0, "validating chars: %s", argv[vo->index]);
          status = validate_chars(argv, vo);
          break;
 
        case V_LEN:
-         if (log_flags & LOG_VALID)
-           com_err(whoami, 0, "validating length: %s", argv[vo->index]);
          status = validate_len(argv, vo);
          break;
 
@@ -200,7 +167,6 @@ static int illegalchars[] = {
 int validate_chars(char *argv[], struct valobj *vo)
 {
   char *s = argv[vo->index];
-  int arg;
   EXEC SQL BEGIN DECLARE SECTION;
   int len;
   char *tname, *cname;
@@ -209,7 +175,7 @@ int validate_chars(char *argv[], struct valobj *vo)
   /* check for bad characters */
   while (*s)
     {
-      if (illegalchars[*s++])
+      if (illegalchars[(int)*s++])
        return MR_BAD_CHAR;
     }
 
@@ -221,7 +187,7 @@ int validate_chars(char *argv[], struct valobj *vo)
 
   if ((strlen(argv[vo->index]) > len) &&
       strcmp(argv[vo->index], UNIQUE_LOGIN)) /* kludge... sigh */
-    argv[vo->index][len] = '\0'; /* truncate */
+    return MR_ARG_TOO_LONG;
 
   return MR_EXISTS;
 }
@@ -373,7 +339,7 @@ int validate_type(char *argv[], struct valobj *vo)
   c = val = argv[vo->index];
   while (*c)
     {
-      if (illegalchars[*c++])
+      if (illegalchars[(int)*c++])
        return MR_BAD_CHAR;
     }
 
@@ -516,7 +482,7 @@ int validate_len(char *argv[], struct valobj *vo)
 
   if ((strlen(argv[vo->index]) > len) &&
       strcmp(argv[vo->index], UNIQUE_LOGIN)) /* kludge... sigh */
-    argv[vo->index][len] = '\0'; /* truncate */
+    return MR_ARG_TOO_LONG;
 
   return MR_EXISTS;
 }
@@ -586,7 +552,7 @@ void sanity_check_database(void)
 char *sqlbuffer[QMAXARGS];
 
 /* Dynamic SQL support routines */
-SQLDA *mr_alloc_sqlda()
+SQLDA *mr_alloc_sqlda(void)
 {
   SQLDA *it;
   int j;
@@ -698,7 +664,7 @@ int convert_wildcards_uppercase(char *arg)
 int add_string(char *nm)
 {
   EXEC SQL BEGIN DECLARE SECTION;
-  char buf[256], *name = nm;
+  char *name = nm;
   int id;
   EXEC SQL END DECLARE SECTION;
 
@@ -706,7 +672,7 @@ int add_string(char *nm)
   id++;
   EXEC SQL UPDATE numvalues SET value = :id WHERE name = 'strings_id';
 
-  EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :nm);
+  EXEC SQL INSERT INTO strings (string_id, string) VALUES (:id, :name);
 
   return id;
 }
This page took 0.038617 seconds and 4 git commands to generate.