]> andersk Git - moira.git/blobdiff - server/queries2.c
Add queries for manipulating the listsids and usersids tables.
[moira.git] / server / queries2.c
index f69616aa5d417f721655a645f643f5c566fd1f7d..aed9240960004a28609650e72fc912ce1aadb88c 100644 (file)
@@ -775,6 +775,14 @@ static char *ghst_fields[] = {
   "inuse", "modtime", "modby", "modwith",
 };
 
+static char *ghbh_fields[] = {
+  "hwaddr",
+  "name", "vendor", "model", "os", "location", "contact", "use",
+  "status", "status_change", "network", "address", "ace_type",
+  "ace_name", "admin_comment", "ops_comment", "created", "creator",
+  "inuse", "modtime", "modby", "modwith",
+};
+
 static struct validate ghst_validate = {
   0,
   0,
@@ -2937,6 +2945,75 @@ static struct validate _sdl_validate =
   _sdl_followup,
 };
 
+static char *gusl_fields[] = {
+  "login",
+  "login", "sid", "created",
+};
+
+static struct validate gusl_validate =
+{
+  VOuser0,
+  1,
+  NULL,
+  NULL,
+  0,
+  0,
+  0,
+  0,
+  0,
+};
+
+static char *glsn_fields[] = {
+  "name",
+  "name", "sid", "created",
+};
+
+static struct validate glsn_validate = 
+{
+  VOlist0,
+  1,
+  NULL,
+  NULL,
+  0,
+  0,
+  0,
+  0,
+  0,
+};
+
+static char *ausl_fields[] = {
+  "login", "sid",
+};
+
+static struct validate ausl_validate =
+{
+  VOuser0,
+  1,
+  "sid",
+  "sid = '%s'",
+  1,
+  0,
+  0,
+  0,
+  0,
+};
+
+static char *alsn_fields[] = {
+  "name", "sid",
+};
+
+static struct validate alsn_validate =
+{
+  VOlist0,
+  1,
+  "sid",
+  "sid = '%s'",
+  1,
+  0,
+  0,
+  0,
+  0,
+};
 
 \f
 /* Generalized Query Definitions */
@@ -3902,12 +3979,12 @@ struct query Queries[] = {
     "m",
     MACHINE_TABLE,
     "m.name, m.vendor, m.model, m.os, m.location, m.contact, m.use, m.status, TO_CHAR(m.statuschange, 'DD-mon-YYYY HH24:MI:SS'), s.name, m.address, m.owner_type, m.owner_id, m.acomment, m.ocomment, TO_CHAR(m.created, 'DD-mon-YYYY HH24:MI:SS'), m.creator, TO_CHAR(m.inuse, 'DD-mon-YYYY HH24:MI:SS'), TO_CHAR(m.modtime, 'DD-mon-YYYY HH24:MI:SS'), m.modby, m.modwith FROM machine m, subnet s",
-    ghst_fields,
+    ghbh_fields,
     21,
     "m.hwaddr LIKE LOWER('%s') AND m.mach_id != 0 AND s.snet_id = m.snet_id",
     1,
     "m.name",
-    NULL,
+    &ghst_validate,
   },
 
   {
@@ -6103,6 +6180,74 @@ struct query Queries[] = {
     &_sdl_validate,
   },
 
+  {
+    /* Q_GUSL - GET_USER_SIDS_BY_LOGIN, v4 */
+    "get_user_sids_by_login",
+    "gusl",
+    4,
+    RETRIEVE,
+    "s",
+    USERSIDS_TABLE,
+    "u.login, us.sid, TO_CHAR(us.created, 'YYYY-MM-DD HH24:MI:SS') FROM users u, usersids us",
+    gusl_fields,
+    3,
+    "us.users_id = %d AND u.users_id = us.users_id",
+    1,
+    "us.created",
+    &gusl_validate,
+  },
+
+  {
+    /* Q_AUSL - ADD_USER_SID_BY_LOGIN, v4 */
+    "add_user_sid_by_login",
+    "ausl",
+    4,
+    APPEND,
+    "s",
+    USERSIDS_TABLE,
+    "INTO usersids (users_id, sid) VALUES (%d, '%s')",
+    ausl_fields,
+    2,
+    NULL,
+    0,
+    NULL,
+    &ausl_validate,
+  },
+  
+  {
+    /* Q_GLSN - GET_LIST_SIDS_BY_NAME, v4 */
+    "get_list_sids_by_name",
+    "glsn",
+    4,
+    RETRIEVE,
+    "s",
+    LISTSIDS_TABLE,
+    "l.name, ls.sid, TO_CHAR(ls.created, 'YYYY-MM-DD HH24:MI:SS') FROM list l, listsids ls",
+    glsn_fields,
+    3,
+    "ls.list_id = %d AND l.list_id = ls.list_id",
+    1,
+    "created",
+    &glsn_validate,
+  },
+
+  {
+    /* Q_ALSN - ADD_LIST_SID_BY_NAME, v4 */
+    "add_list_sid_by_name",
+    "alsn",
+    4,
+    APPEND,
+    "s",
+    LISTSIDS_TABLE,
+    "INTO listsids (list_id, sid) VALUES (%d, '%s')",
+    alsn_fields,
+    2,
+    NULL,
+    0,
+    NULL,
+    &alsn_validate,
+  },
+
 };
 
 int QueryCount = (sizeof(Queries) / sizeof(struct query));
This page took 0.070477 seconds and 4 git commands to generate.