Пример #1
0
globle void *ImplodeMultifield(
  void *theEnv,
  DATA_OBJECT *value)
  {
   size_t strsize = 0;
   long i, j;
   const char *tmp_str;
   char *ret_str;
   void *rv;
   struct multifield *theMultifield;
   DATA_OBJECT tempDO;

   /*===================================================*/
   /* Determine the size of the string to be allocated. */
   /*===================================================*/

   theMultifield = (struct multifield *) GetpValue(value);
   for (i = GetpDOBegin(value) ; i <= GetpDOEnd(value) ; i++)
     {
      if (GetMFType(theMultifield,i) == FLOAT)
        {
         tmp_str = FloatToString(theEnv,ValueToDouble(GetMFValue(theMultifield,i)));
         strsize += strlen(tmp_str) + 1;
        }
      else if (GetMFType(theMultifield,i) == INTEGER)
        {
         tmp_str = LongIntegerToString(theEnv,ValueToLong(GetMFValue(theMultifield,i)));
         strsize += strlen(tmp_str) + 1;
        }
      else if (GetMFType(theMultifield,i) == STRING)
        {
         strsize += strlen(ValueToString(GetMFValue(theMultifield,i))) + 3;
         tmp_str = ValueToString(GetMFValue(theMultifield,i));
         while(*tmp_str)
           {
            if (*tmp_str == '"')
              { strsize++; }
            else if (*tmp_str == '\\') /* GDR 111599 #835 */
              { strsize++; }           /* GDR 111599 #835 */
            tmp_str++;
           }
        }
#if OBJECT_SYSTEM
      else if (GetMFType(theMultifield,i) == INSTANCE_NAME)
        { strsize += strlen(ValueToString(GetMFValue(theMultifield,i))) + 3; }
      else if (GetMFType(theMultifield,i) == INSTANCE_ADDRESS)
        { strsize += strlen(ValueToString(((INSTANCE_TYPE *)
                            GetMFValue(theMultifield,i))->name)) + 3; }
#endif

      else
        { 
         SetType(tempDO,GetMFType(theMultifield,i));
         SetValue(tempDO,GetMFValue(theMultifield,i));
         strsize += strlen(DataObjectToString(theEnv,&tempDO)) + 1; 
        }
     }

   /*=============================================*/
   /* Allocate the string and copy all components */
   /* of the MULTIFIELD variable to it.           */
   /*=============================================*/

   if (strsize == 0) return(EnvAddSymbol(theEnv,""));
   ret_str = (char *) gm2(theEnv,strsize);
   for(j=0, i=GetpDOBegin(value); i <= GetpDOEnd(value) ; i++)
     {
      /*============================*/
      /* Convert numbers to strings */
      /*============================*/

      if (GetMFType(theMultifield,i) == FLOAT)
        {
         tmp_str = FloatToString(theEnv,ValueToDouble(GetMFValue(theMultifield,i)));
         while(*tmp_str)
           {
            *(ret_str+j) = *tmp_str;
            j++, tmp_str++;
           }
        }
      else if (GetMFType(theMultifield,i) == INTEGER)
        {
         tmp_str = LongIntegerToString(theEnv,ValueToLong(GetMFValue(theMultifield,i)));
         while(*tmp_str)
           {
            *(ret_str+j) = *tmp_str;
            j++, tmp_str++;
           }
        }

      /*=======================================*/
      /* Enclose strings in quotes and preceed */
      /* imbedded quotes with a backslash      */
      /*=======================================*/

      else if (GetMFType(theMultifield,i) == STRING)
        {
         tmp_str = ValueToString(GetMFValue(theMultifield,i));
         *(ret_str+j) = '"';
         j++;
         while(*tmp_str)
           {
            if (*tmp_str == '"')
              {
               *(ret_str+j) = '\\';
               j++;
              }
            else if (*tmp_str == '\\') /* GDR 111599 #835 */
              {                        /* GDR 111599 #835 */
               *(ret_str+j) = '\\';    /* GDR 111599 #835 */
               j++;                    /* GDR 111599 #835 */
              }                        /* GDR 111599 #835 */
              
            *(ret_str+j) = *tmp_str;
            j++, tmp_str++;
           }
         *(ret_str+j) = '"';
         j++;
        }
#if OBJECT_SYSTEM
      else if (GetMFType(theMultifield,i) == INSTANCE_NAME)
        {
         tmp_str = ValueToString(GetMFValue(theMultifield,i));
         *(ret_str + j++) = '[';
         while(*tmp_str)
           {
            *(ret_str+j) = *tmp_str;
            j++, tmp_str++;
           }
         *(ret_str + j++) = ']';
        }
      else if (GetMFType(theMultifield,i) == INSTANCE_ADDRESS)
        {
         tmp_str = ValueToString(((INSTANCE_TYPE *) GetMFValue(theMultifield,i))->name);
         *(ret_str + j++) = '[';
         while(*tmp_str)
           {
            *(ret_str+j) = *tmp_str;
            j++, tmp_str++;
           }
         *(ret_str + j++) = ']';
        }
#endif
      else
        {
         SetType(tempDO,GetMFType(theMultifield,i));
         SetValue(tempDO,GetMFValue(theMultifield,i));
         tmp_str = DataObjectToString(theEnv,&tempDO);
         while(*tmp_str)
           {
            *(ret_str+j) = *tmp_str;
            j++, tmp_str++;
           }
         }
      *(ret_str+j) = ' ';
      j++;
     }
   *(ret_str+j-1) = '\0';

   /*====================*/
   /* Return the string. */
   /*====================*/

   rv = EnvAddSymbol(theEnv,ret_str);
   rm(theEnv,ret_str,strsize);
   return(rv);
  }
Пример #2
0
HDDEDATA CALLBACK DDECallBack(  
  UINT uType,
  UINT uFmt,
  HCONV hconv,
  HSZ hsz1,
  HSZ hsz2,
  HDDEDATA hData,
  DWORD dwData1,
  DWORD dwData2)
  {  
#if MAC_MCW || WIN_MCW || MAC_XCD
#pragma unused(hconv)
#pragma unused(dwData1)
#pragma unused(dwData2)
#endif

   extern HSZ hszService; 
   extern char CompleteString[255];
   DWORD size;
   HWND hWnd;
   char *TheData;
   char *Data;
   char *theString;
   void *theEnv = GetCurrentEnvironment();
   
   /* 
   char theBuffer[100];
   DWORD cb; 
   PSTR pszTopicName; 
   */
      
   switch (uType)
     {  
      case XTYP_ADVDATA:
      case XTYP_POKE:
        return ((HDDEDATA) DDE_FNOTPROCESSED);
        
      case XTYP_ADVREQ:
      case XTYP_WILDCONNECT:
        return ((HDDEDATA) NULL);
        
      case XTYP_ADVSTART:
      case XTYP_ADVSTOP:
      case XTYP_CONNECT_CONFIRM:
      case XTYP_DISCONNECT:
      case XTYP_ERROR:
      case XTYP_REGISTER:
      case XTYP_UNREGISTER:
      case XTYP_XACT_COMPLETE:
        return ((HDDEDATA) FALSE);
        
      case XTYP_MONITOR:
        return ((HDDEDATA) TRUE);
                        
      case XTYP_CONNECT:
/*
        cb = DdeQueryString(idInst,hsz1,(LPSTR) NULL, 0,CP_WINANSI) + 1; 
        pszTopicName = (PSTR) LocalAlloc(LPTR, (UINT) cb); 
        DdeQueryString(idInst,hsz1, pszTopicName,cb,CP_WINANSI); 
        
        cb = DdeQueryString(idInst,hsz2,(LPSTR) NULL, 0,CP_WINANSI) + 1; 
        pszTopicName = (PSTR) LocalAlloc(LPTR, (UINT) cb); 
        DdeQueryString(idInst,hsz2, pszTopicName,cb,CP_WINANSI); 
*/
        DDE_RV.type = RVOID;
        if (hsz2 != hszService)
          { return ((HDDEDATA) FALSE); }
          
        return((HDDEDATA) TRUE);
        
      /*--------------------------------------------------+
      | Get completed command and return result to client |
      +--------------------------------------------------*/
      
      case XTYP_REQUEST:

        if (uFmt != CF_TEXT)
          { return(NULL); }
        
        /* sprintf(theBuffer,"XTYP_REQUEST uFmt = %d\n",(int) uFmt);
        PrintRouter(WDISPLAY,theBuffer); */
       
        hData = NULL;

        if (hsz1 == hszCommand)
          {
           theString = DataObjectToString(GetCurrentEnvironment(),&DDE_RV);

           hData = DdeCreateDataHandle (idInst,
                                        (unsigned char *) theString,
                                        strlen(theString)+1,
                                        0L, hsz2,CF_TEXT,0);
          }
          
        return (hData);
      
      case XTYP_EXECUTE:
        SetFocus(DialogWindow);

        if (CommandLineData(GetCurrentEnvironment())->EvaluatingTopLevelCommand || 
            BatchActive(GetCurrentEnvironment()) )
          { return ((HDDEDATA) DDE_FBUSY  ); }

        Data = (char *) DdeAccessData ( hData, NULL);
        size = strlen((char *) Data) + 1;

        TheData = (char *) genalloc ( GetCurrentEnvironment(),(unsigned) size );
        DdeGetData ( hData, (LPBYTE)TheData, size, 0L );
        
        EnvPrintRouter(theEnv,WPROMPT,TheData);
        EnvPrintRouter(theEnv,WPROMPT,"\n");
        
        EnvEval(theEnv,TheData,&DDE_RV);
        
        if (DDE_RV.type != RVOID)
          {
           PrintDataObject(GetCurrentEnvironment(),"stdout",&DDE_RV);
           EnvPrintRouter(theEnv,"stdout","\n");
          }
        
        PrintPrompt(theEnv);
        
        DdeUnaccessData(hData);
       
        hWnd = FindWindow("ClipsEditWClass", NULL);
        SetFocus (hWnd);
        return ((HDDEDATA) DDE_FACK);

   }
   
   return ( (HDDEDATA) TRUE );
}