Esempio n. 1
0
int	TdiFindImageSymbol(
struct descriptor_d	*image,
struct descriptor_d	*entry,
int			(**symbol)()) {
	LibEstablish(LibSigToRet);
	return LibFindImageSymbol(image, entry, symbol);
}
Esempio n. 2
0
int DoMessage(int id) {
  int status=0;
  static Message *(*processMessage)(Connection *,Message *) = 0;
  Connection *c=FindConnection(id,0);
  if (processMessage == 0) {
    DESCRIPTOR(MdsIpSrvShr,"MdsIpSrvShr");
    DESCRIPTOR(procmsg,"ProcessMessage");
    status = LibFindImageSymbol(&MdsIpSrvShr,&procmsg,&processMessage);
  }
  if (c && processMessage) {
    Message *msgptr = GetMdsMsg(id,&status);
    Message *ans=0;
    if (status & 1) {
      ans = (*processMessage)(c, msgptr);
      if (ans) {
	status = SendMdsMsg(id, ans, 0);
	free(ans);
      }
    }
    else
      CloseConnection(id);
    if (msgptr)
      free(msgptr);
  }
  return status;
}
int   mdsdcl_set_command(		/* Return: status		*/
    struct _mdsdcl_ctrl  *ctrl		/* <m> the control structure	*/
   )
   {
    int   sts;
    void  *newTable;
    static DYNAMIC_DESCRIPTOR(dsc_table);

		/*------------------------------------------------------
		 * Get tablename and find its address in shared library ...
		 *-----------------------------------------------------*/
    sts = cli_get_value("TABLE",&dsc_table);
    if (sts & 1)
       {
        int i;
        for (i=0;i<dsc_table.dscW_length;i++)
          dsc_table.dscA_pointer[i] = _tolower(dsc_table.dscA_pointer[i]);
        if (!strstr(dsc_table.dscA_pointer,"_commands"))
          str_concat(&dsc_table,&dsc_table,"_commands",0);
        sts = LibFindImageSymbol(&dsc_table,&dsc_table,&newTable);
        if (~sts & 1)
            return(MdsMsg(sts,"Failed to open table %s",
                dsc_table.dscA_pointer));

		/*------------------------------------------------------
		 *... add newTable address to "tbladr[]" list
		 *-----------------------------------------------------*/
        for (i=0 ; i<ctrl->tables ; i++)
            if (newTable == ctrl->tbladr[i])  break;
        if (i == ctrl->tables)
           {
            if (ctrl->tables >= MAX_TABLES)
               {
                fprintf(stderr,"set_command: *WARN* Max_tables exceeded\n");
                return(0);
               }
            ctrl->tbladr[ctrl->tables++] = newTable;
           }
       }

		/*------------------------------------------------------
		 * Check for other qualifiers ...
		 *-----------------------------------------------------*/
    if (cli_present("HELPLIB") & 1)
        cli_get_value("HELPLIB",&ctrl->helplib);

    if (cli_present("PROMPT") & 1)
        cli_get_value("PROMPT",&ctrl->prompt);

    if (cli_present("DEF_FILE") & 1)
        cli_get_value("DEF_FILE",&ctrl->def_file);

    return(1);
   }
Esempio n. 4
0
	/*****************************************************************
	 * MdsGetMsg:
	 *****************************************************************/
char  *MdsGetMsg(	/* Return: addr of "status" string	*/
    int   sts			/* <r> sts value			*/
   )
   {
     STATIC_CONSTANT DESCRIPTOR(msg_files,"MDSMSG_PATH:*Msg.*");
     STATIC_CONSTANT DESCRIPTOR(getmsg_nam,"getmsg");
     struct descriptor_d filnam = {0, DTYPE_T, CLASS_D, 0};
     int   i;
     char  *facnam, *msgnam, *msgtext;
     int status = 0;
     void *ctx = 0;
     const STATIC_CONSTANT char *severity[] = {"W","S","E","I","F","?","?","?"};
     int (*getmsg)(int,char **,char **,char **);
     int   max;
     struct stsText  *stsText;

     if (sts == 1)
     {
       strcpy((MdsShrGetThreadStatic())->MdsGetMsg_text,"%SS-S-SUCCESS, Success");
       return (MdsShrGetThreadStatic())->MdsGetMsg_text;
     }
     max = getFacility(sts,&facnam,&stsText);
     if (max > 0)
     {
       for (i=0 ; i<max ; i++)
       {
         if ((sts & 0xfffffff8) == (stsText[i].stsL_num & 0xfffffff8))
         {
           sprintf((MdsShrGetThreadStatic())->MdsGetMsg_text,"%%%s-%s-%s, %s",facnam,severity[sts&0x7],stsText[i].stsA_name,stsText[i].stsA_text);
           break;
         }
       }
       if (i == max)
         sprintf((MdsShrGetThreadStatic())->MdsGetMsg_text,"%%%s-%s-NOMSG, Message number 0x%08x",facnam,severity[sts&0x7],sts);
       status = 1;
     }
     while (!(status & 1) && (LibFindFile(&msg_files,&filnam,&ctx)&1))
     {
       status = LibFindImageSymbol(&filnam,&getmsg_nam,&getmsg);
       if (status & 1)
       {
         status = (*getmsg)(sts,&facnam,&msgnam,&msgtext);
         if (status & 1)
           sprintf((MdsShrGetThreadStatic())->MdsGetMsg_text,"%%%s-%s-%s, %s",facnam,severity[sts&0x7],msgnam,msgtext);
       }
     }
     LibFindFileEnd(&ctx);
     if (!(status & 1))
       sprintf((MdsShrGetThreadStatic())->MdsGetMsg_text,"%%NONAME-%s-NOMSG, Message number 0x%08X",severity[sts&0x7],sts);
     return (MdsShrGetThreadStatic())->MdsGetMsg_text;
   }
Esempio n. 5
0
int CloseConnection(int id) {
  int status=0;
  static int (*removeConnection)(int) = 0;
  Connection *c=FindConnection(id,0);
  if (c) {
    if (removeConnection == 0) {
      DESCRIPTOR(MdsIpSrvShr,"MdsIpSrvShr");
      DESCRIPTOR(rmcon,"RemoveConnection");
      status = LibFindImageSymbol(&MdsIpSrvShr,&rmcon,&removeConnection);
    } else
      status=1;
    if (status & 1) {
      status = (*removeConnection)(id);
    }
  }
  return status;
}