AJAX: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
Line 17: Line 17:
= jset =
= jset =


TBW
* JSONP: no
* parameters:
** ?pnam=<code>xxx</code> - cookie_cpwd to match value of ODB /Custon/Pwd/xxx. How is this supposed to work??? How to use it???
<pre>
      if (*getparam("pnam")) {
        sprintf(ppath, "/Custom/Pwd/%s", getparam("pnam"));
        str[0] = 0;
        db_get_value(hDB, 0, ppath, str, &size, TID_STRING, TRUE);
        if (!equal_ustring(cookie_cpwd, str)) {
            show_text_header();
            rsprintf("Invalid password!");
            return;
        }
      }
</pre>
** ?odb=<code>ODB path</code>
** ?value=<code>data</code>
** ?type=<code>integer</code> - if ODB path does not exist, it is created, with "type" MIDAS TID_xxx data type
** ?len=<code>integer</code> - when ODB path is created, if "len" is not zero, it is made an array of "len" size, with all values set to "value". Except if "type" is TID_STRING, there is no array created, but "len" is used as the ODB string length.
 
* ODB path encoding for arrays:
** /path/array[i] - write array element [i]
** /path/array - write array element [0]
** /path/array[*] - write as many array elements as there are comma-separated values in <code>data</code>
 
* example: TBW


= jget =
= jget =

Revision as of 08:13, 21 August 2013

About

This page will document the MIDAS AJAX functions accessible through special the mhttpd URLs.

Audit of URI encoding

Failed:

  • jkey: "?odb=" not encoded
  • jgenmsg: "?msg=" not encoded

Ok:

  • jalm
  • jmsg

jset

  • JSONP: no
  • parameters:
    • ?pnam=xxx - cookie_cpwd to match value of ODB /Custon/Pwd/xxx. How is this supposed to work??? How to use it???
      if (*getparam("pnam")) {
         sprintf(ppath, "/Custom/Pwd/%s", getparam("pnam"));
         str[0] = 0;
         db_get_value(hDB, 0, ppath, str, &size, TID_STRING, TRUE);
         if (!equal_ustring(cookie_cpwd, str)) {
            show_text_header();
            rsprintf("Invalid password!");
            return;
         }
      }
    • ?odb=ODB path
    • ?value=data
    • ?type=integer - if ODB path does not exist, it is created, with "type" MIDAS TID_xxx data type
    • ?len=integer - when ODB path is created, if "len" is not zero, it is made an array of "len" size, with all values set to "value". Except if "type" is TID_STRING, there is no array created, but "len" is used as the ODB string length.
  • ODB path encoding for arrays:
    • /path/array[i] - write array element [i]
    • /path/array - write array element [0]
    • /path/array[*] - write as many array elements as there are comma-separated values in data
  • example: TBW

jget

TBW

jcopy

TBW

jkey

  • JSONP: no
  • parameters:
    • ?odb=ODB path
  • returns:
   if (equal_ustring(getparam("cmd"), "jkey")) {
      show_text_header();
      if (isparam("odb") && db_find_key(hDB, 0, getparam("odb"), &hkey) == DB_SUCCESS) {
         db_get_key(hDB, hkey, &key);
         rsprintf("%s\n", key.name);
         rsprintf("TID_%s\n", rpc_tid_name(key.type));
         rsprintf("%d\n", key.num_values);
         rsprintf("%d\n", key.item_size);
         rsprintf("%d", key.last_written);
      } else
         rsputs("<DB_NO_KEY>");
      return;
   }
  • example: TBW

jmsg

  • JSONP: no
  • parameters:
    • ?n=number of messages to return
  • returns: output of cm_msg_retrieve()
   if (equal_ustring(getparam("cmd"), "jmsg")) {
      i = 1;
      if (*getparam("n"))
         i = atoi(getparam("n"));
      
      show_text_header();
      cm_msg_retrieve(i, str, sizeof(str));
      rsputs(str);
      return;
   }
  • example: TBW

jgenmsg

  • JSONP: no
  • parameters:
    • ?msg=message text
  • returns: ???
   if (equal_ustring(getparam("cmd"), "jalm")) {
      show_text_header();
      al_get_alarms(str, sizeof(str));
      rsputs(str);
      return;
   }
  • example: TBW

jalm

  • JSONP: no
  • parameters: no
  • returns: text from al_get_alarms()
   if (equal_ustring(getparam("cmd"), "jalm")) {
      show_text_header();
      al_get_alarms(str, sizeof(str));
      rsputs(str);
      return;
   }
  • example: TBW