00001
00002
00003 #include "interfdde.h"
00004 #include "win_mem_alloc.h"
00005
00006 #define MSG_ERROR14 "parameter(s) type incorrect.\r\n"
00007 #define MSG_ERROR15 "2 parameters required.\r\n"
00008
00009 int InterfaceWindowsDDEopen _PARAMS((char *fname))
00010 {
00011 static int l1,n1,m1;
00012 Rhs=Max(0,Rhs);
00013 CheckRhs(2,2);
00014 CheckLhs(0,1);
00015
00016 if (Rhs == 2)
00017 {
00018 int TypeVar1=GetType(1);
00019 int TypeVar2=GetType(2);
00020
00021 if ( (TypeVar1 == sci_strings) && (TypeVar2 == sci_strings) )
00022 {
00023 char *param1=NULL,*param2=NULL;
00024
00025 GetRhsVar(1,"c",&m1,&n1,&l1);
00026 param1=cstk(l1);
00027
00028 GetRhsVar(2,"c",&m1,&n1,&l1);
00029 param2=cstk(l1);
00030
00031 if ( DDEOpenConnection(param1,param2) )
00032 {
00033 int *paramoutINT=(int*)MALLOC(sizeof(int));
00034 *paramoutINT=(int)(TRUE);
00035 n1=1;
00036 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00037 LhsVar(1)=1;
00038 FREE(paramoutINT);
00039 }
00040 else
00041 {
00042 int *paramoutINT=(int*)MALLOC(sizeof(int));
00043 *paramoutINT=(int)(FALSE);
00044 n1=1;
00045 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00046 LhsVar(1)=1;
00047 FREE(paramoutINT);
00048 }
00049 }
00050 else
00051 {
00052 Scierror(999,MSG_ERROR14);
00053 }
00054 }
00055 else
00056 {
00057 Scierror(999,MSG_ERROR15);
00058 }
00059 return 0;
00060 }
00061
00062 int InterfaceWindowsDDEclose _PARAMS((char *fname))
00063 {
00064 static int n1;
00065 Rhs=Max(0,Rhs);
00066 CheckRhs(0,0);
00067 CheckLhs(0,1);
00068
00069 if ( DDECloseConnection() )
00070 {
00071 int *paramoutINT=(int*)MALLOC(sizeof(int));
00072 *paramoutINT=(int)TRUE;
00073 n1=1;
00074 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00075 LhsVar(1)=1;
00076 FREE(paramoutINT);
00077 }
00078 else
00079 {
00080 int *paramoutINT=(int*)MALLOC(sizeof(int));
00081 *paramoutINT=(int)FALSE;
00082 n1=1;
00083 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00084 LhsVar(1)=1;
00085 FREE(paramoutINT);
00086 }
00087
00088 return 0;
00089 }
00090
00091 int InterfaceWindowsDDEexec _PARAMS((char *fname))
00092 {
00093 static int l1,n1,m1;
00094 int *param2=NULL;
00095
00096 int TypeVar1=GetType(1);
00097
00098 Rhs=Max(0,Rhs);
00099 CheckRhs(1,2);
00100 CheckLhs(0,1);
00101
00102 if (Rhs == 2)
00103 {
00104 int TypeVar2=GetType(2);
00105 if (TypeVar2 == sci_matrix)
00106 {
00107 GetRhsVar(2,"i",&m1,&n1,&l1);
00108 if ( (m1 == 1) && (n1 == 1) )
00109 {
00110 param2=istk(l1);
00111 }
00112 else
00113 {
00114 Scierror(999,MSG_ERROR14);
00115 return 0;
00116 }
00117 }
00118 else
00119 {
00120 Scierror(999,MSG_ERROR14);
00121 return 0;
00122 }
00123 }
00124
00125 if (Rhs == 1)
00126 {
00127 param2=MALLOC(sizeof(int));
00128 *param2=-1;
00129 }
00130
00131 if (TypeVar1 == sci_strings)
00132 {
00133 char *param1=NULL;
00134
00135 GetRhsVar(1,"c",&m1,&n1,&l1);
00136 param1=cstk(l1);
00137
00138 if ( DDEExecute(param1,*param2) )
00139 {
00140 int *paramoutINT=(int*)MALLOC(sizeof(int));
00141 *paramoutINT=(int)TRUE;
00142 n1=1;
00143 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00144 LhsVar(1)=1;
00145 FREE(paramoutINT);
00146 }
00147 else
00148 {
00149 int *paramoutINT=(int*)MALLOC(sizeof(int));
00150 *paramoutINT=(int)FALSE;
00151 n1=1;
00152 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00153 LhsVar(1)=1;
00154 FREE(paramoutINT);
00155 }
00156
00157 }
00158 else
00159 {
00160 Scierror(999,MSG_ERROR14);
00161 return 0;
00162 }
00163
00164 if (Rhs == 1)
00165 {
00166 if (param2) FREE(param2);
00167 param2=NULL;
00168 }
00169
00170 return 0;
00171 }
00172
00173 int InterfaceWindowsDDEpoke _PARAMS((char *fname))
00174 {
00175 static int l1,n1,m1;
00176 int *param3=NULL;
00177
00178 int TypeVar1=GetType(1);
00179 int TypeVar2=GetType(2);
00180
00181 Rhs=Max(0,Rhs);
00182 CheckRhs(2,3);
00183 CheckLhs(0,1);
00184
00185 if (Rhs == 3)
00186 {
00187 int TypeVar3=GetType(3);
00188 if (TypeVar3 == sci_matrix)
00189 {
00190 GetRhsVar(3,"i",&m1,&n1,&l1);
00191 if ( (m1 == 1) && (n1 == 1) )
00192 {
00193 param3=istk(l1);
00194 }
00195 else
00196 {
00197 Scierror(999,MSG_ERROR14);
00198 return 0;
00199 }
00200 }
00201 else
00202 {
00203 Scierror(999,MSG_ERROR14);
00204 return 0;
00205 }
00206 }
00207
00208 if (Rhs == 2)
00209 {
00210 param3=(int*)MALLOC(sizeof(int));
00211 *param3=-1;
00212 }
00213
00214 if ( (TypeVar1 == sci_strings) && (TypeVar2 == sci_strings))
00215 {
00216 char *param1=NULL,*param2=NULL;
00217
00218 GetRhsVar(1,"c",&m1,&n1,&l1);
00219 param1=cstk(l1);
00220
00221 GetRhsVar(2,"c",&m1,&n1,&l1);
00222 param2=cstk(l1);
00223
00224 if ( DDEPoke(param1,param2,*param3) )
00225 {
00226 int *paramoutINT=(int*)MALLOC(sizeof(int));
00227 *paramoutINT=(int)TRUE;
00228 n1=1;
00229 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00230 LhsVar(1)=1;
00231 FREE(paramoutINT);
00232 }
00233 else
00234 {
00235 int *paramoutINT=(int*)MALLOC(sizeof(int));
00236 *paramoutINT=(int)FALSE;
00237 n1=1;
00238 CreateVarFromPtr(1, "i", &n1, &n1, ¶moutINT);
00239 LhsVar(1)=1;
00240 FREE(paramoutINT);
00241 }
00242 }
00243 else
00244 {
00245 Scierror(999,MSG_ERROR14);
00246 return 0;
00247 }
00248
00249 if (Rhs == 2)
00250 {
00251 if (param3) FREE(param3);
00252 param3=NULL;
00253 }
00254
00255 return 0;
00256 }
00257
00258 int InterfaceWindowsDDEreq _PARAMS((char *fname))
00259 {
00260 static int l1,n1,m1;
00261 int *param2=NULL;
00262
00263 int TypeVar1=GetType(1);
00264
00265 Rhs=Max(0,Rhs);
00266 CheckRhs(1,2);
00267 CheckLhs(0,1);
00268
00269 if (Rhs == 2)
00270 {
00271 int TypeVar2=GetType(2);
00272 if (TypeVar2 == sci_matrix)
00273 {
00274 GetRhsVar(2,"i",&m1,&n1,&l1);
00275 if ( (m1 == 1) && (n1 == 1) )
00276 {
00277 param2=istk(l1);
00278 }
00279 else
00280 {
00281 Scierror(999,MSG_ERROR14);
00282 return 0;
00283 }
00284 }
00285 else
00286 {
00287 Scierror(999,MSG_ERROR14);
00288 return 0;
00289 }
00290 }
00291
00292 if (Rhs == 1)
00293 {
00294 param2=(int*)MALLOC(sizeof(int));
00295 *param2=-1;
00296 }
00297
00298 if (TypeVar1 == sci_strings)
00299 {
00300 char Buffer[512];
00301 char *param1=NULL;
00302
00303 GetRhsVar(1,"c",&m1,&n1,&l1);
00304 param1=cstk(l1);
00305
00306 if ( DDERequest(param1,*param2,Buffer) )
00307 {
00308 char *output=NULL ;
00309 output=(char*)MALLOC((strlen(Buffer)+1)*sizeof(char));
00310 wsprintf(output,"%s",Buffer);
00311 CreateVarFromPtr( 1, "c",(m1=(int)strlen(output), &m1),&n1,&output);
00312 FREE(output);
00313 LhsVar(1)=1;
00314 }
00315 else
00316 {
00317 m1=0;
00318 n1=0;
00319 l1=0;
00320 CreateVar(1,"d", &m1, &n1, &l1);
00321 LhsVar(1)=1;
00322 }
00323 }
00324 else
00325 {
00326 Scierror(999,MSG_ERROR14);
00327 return 0;
00328 }
00329
00330 if (Rhs == 1)
00331 {
00332 if (param2) FREE(param2);
00333 param2=NULL;
00334 }
00335
00336 return 0;
00337 }
00338
00339 int InterfaceWindowsDDEIsOpen _PARAMS((char *fname))
00340 {
00341 static int l1,n1,m1;
00342
00343 Rhs=Max(0,Rhs);
00344 CheckRhs(0,0);
00345 CheckLhs(0,1);
00346
00347 m1=n1=1;
00348
00349 CreateVar(1,"b",&m1,&n1,&l1);
00350
00351 if ( DDEIsOpen() )
00352 {
00353 *istk(l1)=TRUE;
00354 }
00355 else
00356 {
00357 *istk(l1)=FALSE;
00358 }
00359
00360
00361
00362 LhsVar(1)= 1;
00363 return 0;
00364 }
00365