2 /* This program is free software; you can redistribute it and/or modify
3 * it under the terms of the GNU General Public License as published by
4 * the Free Software Foundation; either version 2 of the License, or
5 * (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software
14 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 #include "libs/fvwmsignal.h"
21 #include "libs/ftime.h"
22 #include "libs/FGettext.h"
23 #include "libs/Bindings.h"
24 #include "libs/charmap.h"
25 #include "libs/wcontext.h"
26 #include "libs/modifiers.h"
27 #include "libs/Module.h"
28 #include "libs/ColorUtils.h"
29 #include "libs/Strings.h"
37 void (*TabCom
[29]) (int NbArg
,long *TabArg
);
38 char *(*TabFunc
[27]) (int *NbArg
, long *TabArg
);
39 int (*TabComp
[7]) (char *arg1
,char *arg2
);
43 extern X11base
*x11base
;
44 extern int grab_serve
;
45 extern struct XObj
*tabxobj
[1000];
46 extern Binding
*BindingsList
;
47 extern void LoadIcon(struct XObj
*xobj
);
50 extern char **TabVVar
;
51 extern int TabIdObj
[1001];
52 extern char *ScriptName
;
53 extern ModuleArgs
*module
;
54 extern TypeBuffSend BuffSend
;
55 extern Atom propriete
;
56 extern char *LastString
;
57 char *FvwmUserDir
= NULL
;
59 char Command
[255]="None";
65 void setFvwmUserDir(void)
69 if (FvwmUserDir
!= NULL
)
72 /* Figure out user's home directory */
73 home_dir
= getenv("HOME");
75 if (home_dir
== NULL
) {
76 struct passwd
* pw
= getpwuid(getuid());
78 home_dir
= safestrdup(pw
->pw_dir
);
82 home_dir
= "/"; /* give up and use root dir */
84 /* Figure out where to read and write user's data files. */
85 FvwmUserDir
= getenv("FVWM_USERDIR");
86 if (FvwmUserDir
== NULL
)
88 FvwmUserDir
= safestrdup(CatString2(home_dir
, "/.fvwm"));
93 * Ensemble de fonction de comparaison de deux entiers
95 static int Inf(char *arg1
,char *arg2
)
103 static int InfEq(char *arg1
,char *arg2
)
111 static int Equal(char *arg1
,char *arg2
)
116 return (strcmp(arg1
,arg2
)==0);
119 static int SupEq(char *arg1
,char *arg2
)
127 static int Sup(char *arg1
,char *arg2
)
135 static int Diff(char *arg1
,char *arg2
)
140 return (strcmp(arg1
,arg2
)!=0);
144 * Fonction qui retourne la valeur d'un argument
146 static char *CalcArg (long *TabArg
,int *Ix
)
151 if (TabArg
[*Ix
]>100000) /* Cas du codage d'un nombre */
153 i
= (int)TabArg
[*Ix
] - 200000;
154 TmpStr
= (char*)safecalloc(1,sizeof(char)*10);
155 sprintf(TmpStr
,"%d",i
);
157 else if (TabArg
[*Ix
] < -200000)/* Cas d'un id de fonction de comparaison */
159 i
= TabArg
[*Ix
]+250000;
160 TmpStr
= (char*)safecalloc(1,sizeof(char)*10);
161 sprintf(TmpStr
,"%d",i
);
163 else if (TabArg
[*Ix
] < -100000) /* Cas d'un id de fonction */
165 TmpStr
= TabFunc
[TabArg
[*Ix
]+150000](Ix
,TabArg
);
167 else /* Cas d'une variable */
169 TmpStr
=safestrdup(TabVVar
[TabArg
[*Ix
]]);
175 * Ensemble des fonctions pour recuperer les prop d'un objet
179 static char *FuncGetValue(int *NbArg
, long *TabArg
)
184 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
185 tmp
= CalcArg(TabArg
,NbArg
);
188 tmp
= (char*)safecalloc(1,sizeof(char)*10);
189 sprintf(tmp
,"%d",tabxobj
[TabIdObj
[Id
]]->value
);
194 static char *FuncGetMinValue(int *NbArg
, long *TabArg
)
199 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
200 tmp
= CalcArg(TabArg
,NbArg
);
203 tmp
= (char*)safecalloc(1,sizeof(char)*10);
204 sprintf(tmp
,"%d",tabxobj
[TabIdObj
[Id
]]->value2
);
209 static char *FuncGetMaxValue(int *NbArg
, long *TabArg
)
214 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
215 tmp
= CalcArg(TabArg
,NbArg
);
218 tmp
= (char*)safecalloc(1,sizeof(char)*10);
219 sprintf(tmp
,"%d",tabxobj
[TabIdObj
[Id
]]->value3
);
224 static char *FuncGetFore(int *NbArg
, long *TabArg
)
230 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
231 tmp
= CalcArg(TabArg
,NbArg
);
234 tmp
= (char*)safecalloc(1,sizeof(char)*7);
235 color
.pixel
= tabxobj
[TabIdObj
[Id
]]->TabColor
[fore
];
236 XQueryColor(dpy
, Pcmap
, &color
);
237 sprintf(tmp
, "%02x%02x%02x",
238 color
.red
>> 8, color
.green
>> 8, color
.blue
>> 8);
243 static char *FuncGetBack(int *NbArg
, long *TabArg
)
249 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
250 tmp
= CalcArg(TabArg
,NbArg
);
253 tmp
= (char*)safecalloc(1,sizeof(char)*7);
254 color
.pixel
= tabxobj
[TabIdObj
[Id
]]->TabColor
[back
];
255 XQueryColor(dpy
, Pcmap
, &color
);
256 sprintf(tmp
, "%02x%02x%02x",
257 color
.red
>> 8, color
.green
>> 8, color
.blue
>> 8);
262 static char *FuncGetHili(int *NbArg
, long *TabArg
)
268 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
269 tmp
= CalcArg(TabArg
,NbArg
);
272 tmp
= (char*)safecalloc(1,sizeof(char)*7);
273 color
.pixel
= tabxobj
[TabIdObj
[Id
]]->TabColor
[hili
];
274 XQueryColor(dpy
, Pcmap
, &color
);
275 sprintf(tmp
, "%02x%02x%02x",
276 color
.red
>> 8, color
.green
>> 8, color
.blue
>> 8);
281 static char *FuncGetShad(int *NbArg
, long *TabArg
)
287 (*NbArg
)++; /* La fonction GetValue n'a qu'un seul argument */
288 tmp
= CalcArg(TabArg
,NbArg
);
291 tmp
= (char*)safecalloc(1,sizeof(char)*7);
292 color
.pixel
= tabxobj
[TabIdObj
[Id
]]->TabColor
[shad
];
293 XQueryColor(dpy
, Pcmap
, &color
);
294 sprintf(tmp
, "%02x%02x%02x",
295 color
.red
>> 8, color
.green
>> 8, color
.blue
>> 8);
299 /* Fonction qui retourne le titre d'un objet */
300 static char *FuncGetTitle(int *NbArg
, long *TabArg
)
306 tmp
= CalcArg(TabArg
,NbArg
);
309 if (TabIdObj
[Id
] != -1)
310 tmp
=safestrdup(tabxobj
[TabIdObj
[Id
]]->title
);
313 fprintf(stderr
,"[%s][GetTitle]: <<WARNING>> Widget %d doesn't exist\n",
314 ScriptName
, (int)Id
);
315 tmp
=(char*)safecalloc(1,sizeof(char));
321 /* Fonction qui retourne la sortie d'une commande */
322 static char *FuncGetOutput(int *NbArg
, long *TabArg
)
326 int line
,index
,i
=2,j
=0,k
,NewWord
;
332 cmndbuf
=CalcArg(TabArg
,NbArg
);
334 str
=CalcArg(TabArg
,NbArg
);
338 str
=CalcArg(TabArg
,NbArg
);
342 if ((strcmp(Command
,cmndbuf
)) || ((time(NULL
)-TimeCom
) > 1) || (TimeCom
== 0))
344 if ((f
= popen(cmndbuf
,"r")) == NULL
)
346 fprintf(stderr
,"[%s][GetOutput]: can't run %s\n",ScriptName
,cmndbuf
);
347 str
= (char*)safecalloc(sizeof(char),10);
353 if (strcmp(Command
,"None"))
355 BufCom
= (char*)safecalloc(sizeof(char),maxsize
);
356 size
= fread(BufCom
,1,maxsize
,f
);
358 strncpy(Command
,cmndbuf
,255);
363 /* Recherche de la ligne */
364 while ((i
<= line
) && (BufCom
[j
] != '\0'))
367 if (BufCom
[j
] == '\n')
371 /* Recherche du mot */
377 while ((i
< index
) && (BufCom
[j
] != '\n') && (BufCom
[j
] != '\0'))
380 if (BufCom
[j
] == ' ')
389 if (!NewWord
) NewWord
= 1;
391 str
= (char*)safecalloc(sizeof(char),255);
392 sscanf(&BufCom
[j
],"%s",str
);
394 else /* Lecture de la ligne complete */
398 while ((BufCom
[k
] != '\n') && (BufCom
[k
] != '\0'))
400 str
= (char*)safecalloc(sizeof(char),k
-j
+1);
401 memmove(str
,&BufCom
[j
],k
-j
);
409 /* Convertion decimal vers hexadecimal */
410 static char *FuncNumToHex(int *NbArg
, long *TabArg
)
417 str
= CalcArg(TabArg
,NbArg
);
421 str
= CalcArg(TabArg
,NbArg
);
425 str
= (char*)safecalloc(1,nbchar
+10);
426 sprintf(str
,"%X",value
);
430 memmove(&str
[nbchar
-j
],str
,j
);
431 for (i
=0; i
< (nbchar
-j
); i
++)
438 /* Convertion hexadecimal vers decimal */
439 static char *FuncHexToNum(int *NbArg
, long *TabArg
)
445 str
= CalcArg(TabArg
,NbArg
);
447 memmove(str
,&str
[1],strlen(str
));
448 k
= (int)strtol(str
,NULL
,16);
451 str2
= (char*)safecalloc(1,20);
452 sprintf(str2
,"%d",k
);
457 static char *FuncAdd(int *NbArg
, long *TabArg
)
463 str
= CalcArg(TabArg
,NbArg
);
467 str
= CalcArg(TabArg
,NbArg
);
470 str
= (char*)safecalloc(1,20);
471 sprintf(str
,"%d",val1
+val2
);
476 static char *FuncMult(int *NbArg
, long *TabArg
)
482 str
= CalcArg(TabArg
,NbArg
);
486 str
= CalcArg(TabArg
,NbArg
);
489 str
= (char*)safecalloc(1,20);
490 sprintf(str
,"%d",val1
*val2
);
495 static char *FuncDiv(int *NbArg
, long *TabArg
)
501 str
= CalcArg(TabArg
,NbArg
);
505 str
= CalcArg(TabArg
,NbArg
);
508 str
= (char*)safecalloc(1,20);
509 sprintf(str
,"%d",val1
/val2
);
514 static char *RemainderOfDiv(int *NbArg
, long *TabArg
)
517 return safestrdup("Unsupported function: div");
524 str
= CalcArg(TabArg
,NbArg
);
528 str
= CalcArg(TabArg
,NbArg
);
531 str
= (char*)safecalloc(1,20);
532 res
= div(val1
,val2
);
533 sprintf(str
,"%d",res
.rem
);
540 static char *FuncStrCopy(int *NbArg
, long *TabArg
)
546 strsrc
= CalcArg(TabArg
,NbArg
);
548 str
= CalcArg(TabArg
,NbArg
);
553 str
= CalcArg(TabArg
,NbArg
);
558 if ((i1
<= i2
) &&( i1
<= strlen(strsrc
)))
560 if (i2
> strlen(strsrc
))
562 str
= (char*)safecalloc(1,i2
- i1
+ 2);
563 memmove(str
,&strsrc
[i1
-1],i2
- i1
+ 1);
567 str
= (char*)safecalloc(1,1);
574 /* Lancement d'un script avec pipe */
575 static char *LaunchScript (int *NbArg
,long *TabArg
)
577 char *arg
,*execstr
,*str
,*scriptarg
,*scriptname
;
582 /* Lecture des arguments */
584 arg
= CalcArg(TabArg
,NbArg
);
586 str
= (char*)safecalloc(100,sizeof(char));
588 /* Calcul du nom du script fils */
589 x11base
->TabScriptId
[x11base
->NbChild
+2] =
590 (char*)safecalloc(strlen(x11base
->TabScriptId
[1])+4,sizeof(char));
592 if (x11base
->NbChild
<98)
597 sprintf(x11base
->TabScriptId
[x11base
->NbChild
+ 2],"%s%x",
598 x11base
->TabScriptId
[1],i
);
599 MyAtom
= XInternAtom(dpy
,x11base
->TabScriptId
[x11base
->NbChild
+ 2],False
);
602 while (XGetSelectionOwner(dpy
,MyAtom
)!=None
);
606 fprintf(stderr
,"[%s][LaunchScript]: Too many launched script\n", ScriptName
);
611 /* Construction de la commande */
612 execstr
= (char*)safecalloc(strlen(module
->name
) + strlen(arg
) +
613 strlen(x11base
->TabScriptId
[x11base
->NbChild
+ 2]) + 5,sizeof(char));
614 scriptname
= (char*)safecalloc(sizeof(char),100);
615 sscanf(arg
,"%s",scriptname
);
616 scriptarg
= (char*)safecalloc(sizeof(char),strlen(arg
));
617 scriptarg
= (char*)strncpy(scriptarg
, &arg
[strlen(scriptname
)],
618 strlen(arg
) - strlen(scriptname
));
619 sprintf(execstr
,"%s %s %s %s",module
->name
,scriptname
,
620 x11base
->TabScriptId
[x11base
->NbChild
+ 2],scriptarg
);
625 /* Envoi de la commande */
626 write(fd
[0], &ref
, sizeof(Window
));
627 leng
= strlen(execstr
);
628 write(fd
[0], &leng
, sizeof(unsigned long));
629 write(fd
[0], execstr
, leng
);
631 write(fd
[0], &leng
, sizeof(unsigned long));
634 /* Retourne l'id du fils */
635 sprintf(str
,"%d",x11base
->NbChild
+2);
640 /* GetScriptFather */
641 static char *GetScriptFather (int *NbArg
,long *TabArg
)
645 str
= (char*)safecalloc(10,sizeof(char));
651 static char *GetTime (int *NbArg
,long *TabArg
)
656 str
= (char*)safecalloc(20,sizeof(char));
658 sprintf(str
,"%ld",(long)t
-x11base
->BeginTime
);
663 static char *GetScriptArg (int *NbArg
,long *TabArg
)
669 str
= CalcArg(TabArg
,NbArg
);
673 if (x11base
->TabArg
[val1
] != NULL
)
675 str
= (char*)safecalloc(strlen(x11base
->TabArg
[val1
])+1,sizeof(char));
676 str
= strcpy(str
,x11base
->TabArg
[val1
]);
680 str
= (char*)safecalloc(1,sizeof(char));
681 str
= strcpy(str
,"");
687 /* ReceivFromScript */
688 static char *ReceivFromScript (int *NbArg
,long *TabArg
)
692 Atom AReceiv
,ASend
,type
;
694 unsigned long longueur
,octets_restant
;
695 unsigned char *donnees
= (unsigned char *)"";
700 arg
= CalcArg(TabArg
,NbArg
);
701 send
= (int)atoi(arg
);
704 msg
= (char*)safecalloc(256,sizeof(char));
705 sprintf(msg
,"No message");
707 /* Recuperation des atomes */
708 AReceiv
= XInternAtom(dpy
,x11base
->TabScriptId
[1],True
);
711 fprintf(stderr
,"[%s][ReceivFromScript]: <<WARNING>> Error with atome\n",
716 if ( (send
>=0 ) && (send
< 99))
718 if (x11base
->TabScriptId
[send
]!=NULL
)
720 ASend
=XInternAtom(dpy
,x11base
->TabScriptId
[send
],True
);
723 "[%s][ReceivFromScript]: <<WARNING>> Error with atome\n",
732 /* Recuperation du message */
733 XConvertSelection(dpy
,ASend
,AReceiv
,propriete
,x11base
->win
,CurrentTime
);
734 while ((!FCheckTypedEvent(dpy
,SelectionNotify
,&event
)) && (NbEssai
< 10))
739 if (event
.xselection
.property
!=None
)
740 if (event
.xselection
.selection
==ASend
)
742 XGetWindowProperty(dpy
,event
.xselection
.requestor
,
743 event
.xselection
.property
,
744 0L,8192L,False
,event
.xselection
.target
,&type
,&format
,
745 &longueur
,&octets_restant
,&donnees
);
748 msg
= (char*)saferealloc((void*)msg
, (longueur
+1) * sizeof(char));
749 msg
= strcpy(msg
,(char *)donnees
);
750 XDeleteProperty(dpy
,event
.xselection
.requestor
,
751 event
.xselection
.property
);
759 static char *FuncGetPid(int *NbArg
,long *TabArg
)
765 str
= (char*)safecalloc(1,20);
766 sprintf(str
,"%d",pid
);
771 #define IN_FIFO_NBR_OF_TRY 200
772 #define IN_FIFO_TIMEOUT 100000 /* usec: 0.1 sec (20 sec) */
773 #define OUT_FIFO_NBR_OF_TRY 400
774 #define OUT_FIFO_TIMEOUT 50000 /* usec: 0.05 sec (20 sec) */
775 static char *FuncSendMsgAndGet(int *NbArg
,long *TabArg
)
777 char *com_name
, *cmd
, *tmp
, *out_fifo
, *in_fifo
, *str
;
784 struct timeval timeout
;
786 /* comunication name */
788 com_name
=CalcArg(TabArg
,NbArg
);
789 /* the command send to the receiver */
791 cmd
=CalcArg(TabArg
,NbArg
);
792 /* 0: no answer (so no locking) from the receiver *
793 * 1: real send and get mode */
795 tmp
=CalcArg(TabArg
,NbArg
);
801 (char*)safecalloc(strlen(com_name
)+strlen(FvwmUserDir
)+14, sizeof(char));
802 sprintf(in_fifo
,"%s/.tmp-com-in-%s",FvwmUserDir
,com_name
);
804 /* unlock the receiver, wait IN_FIFO_TIMEOUT * IN_FIFO_NBR_OF_TRY so that *
805 * the receiver has the time to go in its communication loop at startup *
806 * or if it do an other job than waiting for a cmd */
810 if (access(in_fifo
,W_OK
) == 0)
812 if ((filedes
= open(in_fifo
,O_WRONLY
)) == 0)
815 "[%s][GetMsgAndGet]: <<WARNING>> cannot open the in fifo %s\n",
823 if ((j
= write(filedes
, cmd
+i
, l
-i
)) == -1) {
825 "[%s][GetMsgAndGet]: <<WARNING>> write error on %s\n",
837 timeout
.tv_usec
= IN_FIFO_TIMEOUT
;
838 select(None
,NULL
,NULL
,NULL
,&timeout
);
840 if (i
> IN_FIFO_NBR_OF_TRY
)
843 "[%s][GetMsgAndGet]: <<WARNING>> No in fifo %s for comunication %s\n",
844 ScriptName
,in_fifo
,com_name
);
853 /* no msg to read from the receiver (or an error occur): return */
858 str
=(char*)safecalloc(2,sizeof(char));
859 sprintf(str
,(err
) ? "0" : "1");
863 /* get the answer from the receiver. *
864 * we wait OUT_FIFO_TIMEOUT * OUT_FIFO_NBR_OF_TRY for this answer */
866 (char*)safecalloc(strlen(com_name
)+strlen(FvwmUserDir
)+15,sizeof(char));
867 sprintf(out_fifo
,"%s/.tmp-com-out-%s",FvwmUserDir
,com_name
);
871 if (access(out_fifo
,R_OK
) == 0)
873 if ((f
= fopen (out_fifo
, "r")) != NULL
)
875 buf
=(char*)safecalloc(sizeof(char),maxsize
);
876 fread(buf
,1,maxsize
,f
);
882 "[%s][GetMsgAndGet]: <<WARNING>> cannot open the out fifo %s\n",
883 ScriptName
,out_fifo
);
891 timeout
.tv_usec
= OUT_FIFO_TIMEOUT
;
892 select(None
,NULL
,NULL
,NULL
,&timeout
);
894 if (i
> OUT_FIFO_NBR_OF_TRY
)
897 "[%s][GetMsgAndGet]: <<WARNING>>: No out fifo %s for comunication %s\n",
898 ScriptName
,out_fifo
,com_name
);
913 str
=(char*)safecalloc(2,sizeof(char));
918 str
=(char*)safecalloc(l
+1,sizeof(char));
919 memmove(str
,&buf
[0],l
);
926 static char *FuncParse(int *NbArg
,long *TabArg
)
936 /* the string to parse */
938 string
=CalcArg(TabArg
,NbArg
);
939 /* the substring to return */
941 str
=CalcArg(TabArg
,NbArg
);
947 memmove(num
,&string
[i
],4);
959 if (end
> l
|| end
<= start
)
961 str
=(char*)safecalloc(1,sizeof(char));
966 str
=(char*)safecalloc(end
-start
+1,sizeof(char));
967 memmove(str
,&string
[start
],end
-start
);
968 str
[end
-start
] ='\0';
975 static char *FuncGetLastString(int *NbArg
,long *TabArg
)
979 if (LastString
== NULL
) {
980 str
= (char*)safecalloc(1,sizeof(char));
985 CopyString(&str
,LastString
);
991 * Ensemble des commandes possible pour un obj
995 static void Exec (int NbArg
,long *TabArg
)
997 unsigned long leng
= 0;
1002 for (i
=0; i
< NbArg
; i
++)
1003 leng
+= strlen(CalcArg(TabArg
,&i
));
1007 fprintf(stderr
, "[%s][Do]: too long command %i chars max 998\n",
1008 ScriptName
,(int)leng
);
1012 execstr
= (char*)safecalloc(1,leng
+1);
1013 for (i
=0; i
< NbArg
; i
++)
1015 tempstr
= CalcArg(TabArg
,&i
);
1016 execstr
= strcat(execstr
,tempstr
);
1020 write(fd
[0], &ref
, sizeof(Window
));
1021 leng
= strlen(execstr
);
1022 write(fd
[0], &leng
, sizeof(unsigned long));
1023 write(fd
[0], execstr
, leng
);
1025 write(fd
[0], &leng
, sizeof(unsigned long));
1030 static void HideObj (int NbArg
,long *TabArg
)
1036 arg
[0] = CalcArg(TabArg
,&i
);
1037 IdItem
= TabIdObj
[atoi(arg
[0])];
1040 tabxobj
[IdItem
]->flags
[0] = True
;
1041 /* On cache la fentre pour la faire disparaitre */
1042 XUnmapWindow(dpy
,tabxobj
[IdItem
]->win
);
1047 static void ShowObj (int NbArg
,long *TabArg
)
1053 arg
[0] = CalcArg(TabArg
,&i
);
1054 IdItem
= TabIdObj
[atoi(arg
[0])];
1056 tabxobj
[IdItem
]->flags
[0] = False
;
1057 XMapWindow(dpy
,tabxobj
[IdItem
]->win
);
1058 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
], NULL
);
1063 static void ChangeValue (int NbArg
,long *TabArg
)
1068 arg
[0] =CalcArg(TabArg
,&i
);
1070 arg
[1] =CalcArg(TabArg
,&i
);
1072 tabxobj
[TabIdObj
[atoi(arg
[0])]]->value
= atoi(arg
[1]);
1073 /* On redessine l'objet pour le mettre a jour */
1074 if (tabxobj
[TabIdObj
[atoi(arg
[0])]]->TypeWidget
!= SwallowExec
)
1075 XClearWindow(dpy
, tabxobj
[TabIdObj
[atoi(arg
[0])]]->win
);
1076 tabxobj
[TabIdObj
[atoi(arg
[0])]]->DrawObj(tabxobj
[TabIdObj
[atoi(arg
[0])]],NULL
);
1081 /* ChangeValueMax */
1082 static void ChangeValueMax (int NbArg
,long *TabArg
)
1088 arg
[0] = CalcArg(TabArg
,&i
);
1091 arg
[1] = CalcArg(TabArg
,&i
);
1093 tabxobj
[TabIdObj
[j
]]->value3
= atoi(arg
[1]);
1094 /* On redessine l'objet pour le mettre a jour */
1095 if (tabxobj
[TabIdObj
[j
]]->value
> tabxobj
[TabIdObj
[j
]]->value3
)
1097 tabxobj
[TabIdObj
[j
]]->value
= atoi(arg
[1]);
1098 if (tabxobj
[TabIdObj
[j
]]->TypeWidget
!= SwallowExec
)
1099 XClearWindow(dpy
, tabxobj
[TabIdObj
[j
]]->win
);
1100 tabxobj
[TabIdObj
[j
]]->DrawObj(tabxobj
[TabIdObj
[j
]],NULL
);
1106 /* ChangeValueMin */
1107 static void ChangeValueMin (int NbArg
,long *TabArg
)
1113 arg
[0] = CalcArg(TabArg
,&i
);
1115 arg
[1] = CalcArg(TabArg
,&i
);
1118 tabxobj
[TabIdObj
[j
]]->value2
= atoi(arg
[1]);
1119 /* On redessine l'objet pour le mettre a jour */
1120 if (tabxobj
[TabIdObj
[j
]]->value
< tabxobj
[TabIdObj
[j
]]->value2
)
1122 tabxobj
[TabIdObj
[j
]]->value
= atoi(arg
[1]);
1123 if (tabxobj
[TabIdObj
[j
]]->TypeWidget
!= SwallowExec
)
1124 XClearWindow(dpy
, tabxobj
[TabIdObj
[j
]]->win
);
1125 tabxobj
[TabIdObj
[j
]]->DrawObj(tabxobj
[TabIdObj
[j
]],NULL
);
1131 /* ChangePosition */
1132 static void ChangePos (int NbArg
,long *TabArg
)
1139 arg
[0] = CalcArg(TabArg
,&i
);
1141 arg
[1] = CalcArg(TabArg
,&i
);
1143 arg
[2] = CalcArg(TabArg
,&i
);
1145 IdItem
= TabIdObj
[atoi(arg
[0])];
1147 an
[i
] = atoi(arg
[i
]);
1148 tabxobj
[IdItem
]->x
= an
[1];
1149 tabxobj
[IdItem
]->y
= an
[2];
1150 XMoveWindow(dpy
,tabxobj
[IdItem
]->win
,an
[1],an
[2]);
1158 static void ChangeFont (int NbArg
,long *TabArg
)
1165 arg
[0] = CalcArg(TabArg
,&i
);
1167 arg
[1] = CalcArg(TabArg
,&i
);
1168 IdItem
= TabIdObj
[atoi(arg
[0])];
1169 if (tabxobj
[IdItem
]->font
)
1170 free(tabxobj
[IdItem
]->font
);
1171 tabxobj
[IdItem
]->font
= safestrdup(arg
[1]);
1174 FlocaleLoadFont(dpy
, tabxobj
[IdItem
]->font
, ScriptName
)) == NULL
) {
1175 fprintf(stderr
, "[%s][ChangeFont]: Couldn't load font %s\n",
1176 ScriptName
,tabxobj
[IdItem
]->font
);
1180 FlocaleUnloadFont(dpy
, tabxobj
[IdItem
]->Ffont
);
1181 tabxobj
[IdItem
]->Ffont
= Ffont
;
1182 if (Ffont
->font
!= NULL
)
1183 XSetFont(dpy
,tabxobj
[IdItem
]->gc
,tabxobj
[IdItem
]->Ffont
->font
->fid
);
1186 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
)
1187 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1188 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1194 static void ChangeSize (int NbArg
,long *TabArg
)
1201 arg
[0] = CalcArg(TabArg
,&i
);
1203 arg
[1] = CalcArg(TabArg
,&i
);
1205 arg
[2] = CalcArg(TabArg
,&i
);
1207 IdItem
= TabIdObj
[atoi(arg
[0])];
1208 for (i
=1; i
<3; i
++) {
1209 an
[i
] = atoi(arg
[i
]);
1211 tabxobj
[IdItem
]->width
= an
[1];
1212 tabxobj
[IdItem
]->height
= an
[2];
1213 XResizeWindow(dpy
,tabxobj
[IdItem
]->win
,an
[1],an
[2]);
1214 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1221 static void ChangeTitle (int NbArg
,long *TabArg
)
1227 arg
[0] = CalcArg(TabArg
,&i
);
1229 arg
[1] = CalcArg(TabArg
,&i
);
1230 IdItem
= TabIdObj
[atoi(arg
[0])];
1232 if (tabxobj
[IdItem
]->title
)
1233 free(tabxobj
[IdItem
]->title
);
1234 tabxobj
[IdItem
]->title
=safestrdup(arg
[1]);
1235 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
)
1236 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1237 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1242 /* ChangeLocaleTitle */
1243 static void ChangeLocaleTitle (int NbArg
,long *TabArg
)
1249 arg
[0] = CalcArg(TabArg
,&i
);
1251 arg
[1] = CalcArg(TabArg
,&i
);
1252 IdItem
= TabIdObj
[atoi(arg
[0])];
1254 if (tabxobj
[IdItem
]->title
)
1255 free(tabxobj
[IdItem
]->title
);
1256 tabxobj
[IdItem
]->title
=safestrdup(FGettext(arg
[1]));
1257 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
)
1258 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1259 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1265 static void ChangeIcon (int NbArg
,long *TabArg
)
1271 arg
[0] = CalcArg(TabArg
,&i
);
1273 arg
[1] = CalcArg(TabArg
,&i
);
1274 IdItem
= TabIdObj
[atoi(arg
[0])];
1275 if (tabxobj
[IdItem
]->icon
)
1277 free(tabxobj
[IdItem
]->icon
);
1279 tabxobj
[IdItem
]->icon
= safestrdup(arg
[1]);
1280 LoadIcon(tabxobj
[IdItem
]);
1281 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
)
1283 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1285 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1290 /* ChangeForeColor */
1291 static void ChangeForeColor (int NbArg
,long *TabArg
)
1297 arg
[0] = CalcArg(TabArg
,&i
);
1299 arg
[1] = CalcArg(TabArg
,&i
);
1300 IdItem
= TabIdObj
[atoi(arg
[0])];
1302 /* Liberation de la couleur */
1303 if (tabxobj
[IdItem
]->colorset
< 0)
1305 dpy
,Pcmap
,(void*)(&(tabxobj
[IdItem
])->TabColor
[fore
]),1,0, True
);
1307 if (tabxobj
[IdItem
]->forecolor
)
1309 free(tabxobj
[IdItem
]->forecolor
);
1311 tabxobj
[IdItem
]->forecolor
= safestrdup(arg
[1]);
1313 tabxobj
[IdItem
]->TabColor
[fore
] = GetColor(tabxobj
[IdItem
]->forecolor
);
1314 if (tabxobj
[IdItem
]->colorset
>= 0) {
1315 tabxobj
[IdItem
]->TabColor
[back
] = GetColor(tabxobj
[IdItem
]->backcolor
);
1316 tabxobj
[IdItem
]->TabColor
[hili
] = GetColor(tabxobj
[IdItem
]->hilicolor
);
1317 tabxobj
[IdItem
]->TabColor
[shad
] = GetColor(tabxobj
[IdItem
]->shadcolor
);
1319 tabxobj
[IdItem
]->colorset
= -1;
1321 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
)
1322 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1323 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1330 /* ChangeBackColor */
1331 static void ChangeBackColor (int NbArg
,long *TabArg
)
1337 arg
[0] = CalcArg(TabArg
,&i
);
1339 arg
[1] = CalcArg(TabArg
,&i
);
1340 IdItem
= TabIdObj
[atoi(arg
[0])];
1342 /* Liberation de la couleur */
1343 if (tabxobj
[IdItem
]->colorset
< 0)
1345 dpy
,Pcmap
,(void*)(&(tabxobj
[IdItem
])->TabColor
[back
]),1,0,True
);
1347 if (tabxobj
[IdItem
]->backcolor
)
1349 free(tabxobj
[IdItem
]->backcolor
);
1351 tabxobj
[IdItem
]->backcolor
= safestrdup(arg
[1]);
1353 tabxobj
[IdItem
]->TabColor
[back
] = GetColor(tabxobj
[IdItem
]->backcolor
);
1354 if (tabxobj
[IdItem
]->colorset
>= 0) {
1355 tabxobj
[IdItem
]->TabColor
[fore
] = GetColor(tabxobj
[IdItem
]->forecolor
);
1356 tabxobj
[IdItem
]->TabColor
[hili
] = GetColor(tabxobj
[IdItem
]->hilicolor
);
1357 tabxobj
[IdItem
]->TabColor
[shad
] = GetColor(tabxobj
[IdItem
]->shadcolor
);
1359 tabxobj
[IdItem
]->colorset
= -1;
1361 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
) {
1362 XSetWindowBackground(dpy
,
1363 tabxobj
[IdItem
]->win
,
1364 tabxobj
[IdItem
]->TabColor
[back
]);
1365 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1367 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1373 /* ChangeMainColorset */
1374 static void ChangeMainColorset (int i
)
1376 /* Liberation de la couleur */
1377 if (x11base
->colorset
< 0) {
1378 PictureFreeColors(dpy
,Pcmap
,&x11base
->TabColor
[fore
],1,0,True
);
1379 PictureFreeColors(dpy
,Pcmap
,&x11base
->TabColor
[back
],1,0,True
);
1380 PictureFreeColors(dpy
,Pcmap
,&x11base
->TabColor
[hili
],1,0,True
);
1381 PictureFreeColors(dpy
,Pcmap
,&x11base
->TabColor
[shad
],1,0,True
);
1383 x11base
->colorset
= i
;
1385 x11base
->TabColor
[fore
] = Colorset
[i
].fg
;
1386 x11base
->TabColor
[back
] = Colorset
[i
].bg
;
1387 x11base
->TabColor
[hili
] = Colorset
[i
].hilite
;
1388 x11base
->TabColor
[shad
] = Colorset
[i
].shadow
;
1389 SetWindowBackground(dpy
, x11base
->win
,x11base
->size
.width
,x11base
->size
.height
,
1390 &Colorset
[i
], Pdepth
, x11base
->gc
, True
);
1393 /* ChangeMainColorset */
1394 static void ChangeColorset (int NbArg
,long *TabArg
)
1400 arg
[0] = CalcArg(TabArg
,&i
);
1402 arg
[1] = CalcArg(TabArg
,&i
);
1403 if (atoi(arg
[0]) == 0) {
1404 ChangeMainColorset(atoi(arg
[1]));
1409 IdItem
= TabIdObj
[atoi(arg
[0])];
1411 /* Liberation de la couleur */
1412 if (tabxobj
[IdItem
]->colorset
< 0) {
1413 PictureFreeColors(dpy
,Pcmap
,&tabxobj
[IdItem
]->TabColor
[fore
],1,0,True
);
1414 PictureFreeColors(dpy
,Pcmap
,&tabxobj
[IdItem
]->TabColor
[back
],1,0,True
);
1415 PictureFreeColors(dpy
,Pcmap
,&tabxobj
[IdItem
]->TabColor
[hili
],1,0,True
);
1416 PictureFreeColors(dpy
,Pcmap
,&tabxobj
[IdItem
]->TabColor
[shad
],1,0,True
);
1418 sscanf(arg
[1], "%d", &i
);
1419 tabxobj
[IdItem
]->colorset
= i
;
1421 tabxobj
[IdItem
]->TabColor
[fore
] = Colorset
[i
].fg
;
1422 tabxobj
[IdItem
]->TabColor
[back
] = Colorset
[i
].bg
;
1423 tabxobj
[IdItem
]->TabColor
[hili
] = Colorset
[i
].hilite
;
1424 tabxobj
[IdItem
]->TabColor
[shad
] = Colorset
[i
].shadow
;
1426 if (tabxobj
[IdItem
]->TypeWidget
!= SwallowExec
) {
1427 SetWindowBackground(dpy
, tabxobj
[IdItem
]->win
, tabxobj
[IdItem
]->width
,
1428 tabxobj
[IdItem
]->height
, &Colorset
[i
], Pdepth
,
1429 tabxobj
[IdItem
]->gc
, False
);
1430 XClearWindow(dpy
, tabxobj
[IdItem
]->win
);
1432 tabxobj
[IdItem
]->DrawObj(tabxobj
[IdItem
],NULL
);
1438 /* ChangeWindowTitle */
1439 static void ChangeWindowTitle(int NbArg
,long * TabArg
){
1444 arg
=CalcArg(TabArg
,&tmpVal
);
1446 dpy
, x11base
->win
, XA_WM_NAME
, XA_STRING
, 8, PropModeReplace
,
1447 (unsigned char*)arg
, strlen(arg
));
1452 /* ChangeWindowTitleFromArg */
1453 static void ChangeWindowTitleFromArg(int NbArg
,long * TabArg
){
1459 arg
=CalcArg(TabArg
,&tmpVal
);
1463 if(x11base
->TabArg
[argVal
]!=NULL
){
1464 arg
= (char*)safecalloc(strlen(x11base
->TabArg
[argVal
])+1,sizeof(char));
1465 arg
= strcpy(arg
,x11base
->TabArg
[argVal
]);
1467 arg
= (char*)safecalloc(1,sizeof(char));
1468 arg
= strcpy(arg
,"");
1472 dpy
, x11base
->win
, XA_WM_NAME
, XA_STRING
, 8, PropModeReplace
,
1473 (unsigned char*)arg
, strlen(arg
));
1479 static void SetVar (int NbArg
,long *TabArg
)
1484 str
=(char*)safecalloc(sizeof(char),1);
1485 for (i
=1; i
<NbArg
; i
++)
1487 tempstr
= CalcArg(TabArg
,&i
);
1488 str
= (char*)saferealloc((void*)str
,
1489 sizeof(char) * (1 + strlen(str
) + strlen(tempstr
)));
1490 str
= strcat(str
,tempstr
);
1494 free(TabVVar
[TabArg
[0]]);
1495 TabVVar
[TabArg
[0]] = str
;
1499 static void SendSign (int NbArg
,long *TabArg
)
1506 arg
[0] = CalcArg(TabArg
,&i
);
1508 arg
[1] = CalcArg(TabArg
,&i
);
1509 IdItem
= TabIdObj
[atoi(arg
[0])];
1510 TypeMsg
= atoi(arg
[1]);
1511 SendMsg(tabxobj
[IdItem
],TypeMsg
);
1517 static void MyWarpPointer(int NbArg
,long *TabArg
)
1523 arg
=CalcArg(TabArg
,&i
);
1524 IdItem
= TabIdObj
[atoi(arg
)];
1525 /* Deplacement du pointeur sur l'objet */
1526 FWarpPointer(dpy
, None
, tabxobj
[IdItem
]->win
, 0, 0, 0, 0,
1527 tabxobj
[IdItem
]->width
/ 2, tabxobj
[IdItem
]->height
+ 10);
1532 void Quit (int NbArg
,long *TabArg
)
1538 static void IfThen (int NbArg
,long *TabArg
)
1545 /* Verification de la condition */
1546 for (j
=0; j
<NbArg
-2; j
++)
1548 if (TabArg
[j
] > 100000) /* Cas du codage d'un nombre */
1550 i
= (int)TabArg
[j
] - 200000;
1551 arg
[CurrArg
] = (char*)safecalloc(1,sizeof(char)*10);
1552 sprintf(arg
[CurrArg
],"%d",i
);
1555 else if (TabArg
[j
] < -200000)/* Cas d'un id de fonction de comparaison */
1557 IdFuncComp
= TabArg
[j
] + 250000;
1559 else if (TabArg
[j
] < -100000) /* Cas d'un id de fonction */
1561 arg
[CurrArg
] = TabFunc
[TabArg
[j
]+150000](&j
,TabArg
);
1564 else /* Cas d'une variable */
1566 arg
[CurrArg
] = safestrdup(TabVVar
[TabArg
[j
]]);
1571 /* Comparaison des arguments */
1572 if (TabComp
[IdFuncComp
](arg
[0],arg
[1]))
1573 ExecBloc((Bloc
*)TabArg
[NbArg
-2]);
1574 else if (TabArg
[NbArg
-1]!=0)
1575 ExecBloc((Bloc
*)TabArg
[NbArg
-1]);
1581 /* Instruction boucle **/
1582 static void Loop (int NbArg
,long *TabArg
)
1590 /* le premier argument est une variable */
1592 /*On ajuste la taille de la var pour contenir un nombre */
1593 TabVVar
[TabArg
[0]] = (char*)saferealloc(TabVVar
[TabArg
[0]],sizeof(char)*10);
1594 /* Calcul des 2 autres arguments */
1595 for (i
=1; i
<NbArg
; i
++)
1597 if (TabArg
[i
] > 100000) /* Cas du codage d'un nombre */
1600 x
= (int)TabArg
[i
] - 200000;
1601 arg
[CurrArg
] = (char*)safecalloc(1,sizeof(char)*10);
1602 sprintf(arg
[CurrArg
],"%d",x
);
1604 else if (TabArg
[i
] < -100000) /* Cas d'un id de fonction */
1606 arg
[CurrArg
] = TabFunc
[TabArg
[i
]+150000](&i
,TabArg
);
1608 else /* Cas d'une variable */
1610 arg
[CurrArg
] = safestrdup(TabVVar
[TabArg
[i
]]);
1614 limit
[0] = atoi(arg
[0]);
1615 limit
[1] = atoi(arg
[1]);
1616 if (limit
[0] < limit
[1])
1618 for (i
=limit
[0]; i
<=limit
[1]; i
++)
1620 /* On met a jour la variable */
1621 sprintf(TabVVar
[TabArg
[0]],"%d",i
);
1622 ExecBloc((Bloc
*)TabArg
[NbArg
-1]);
1627 for (i
=limit
[0]; i
<=limit
[1]; i
++)
1629 sprintf(TabVVar
[TabArg
[0]],"%d",i
);
1630 ExecBloc((Bloc
*)TabArg
[NbArg
-1]);
1638 /** Instruction While **/
1639 static void While (int NbArg
,long *TabArg
)
1649 arg
[0] = CalcArg(TabArg
,&i
);
1651 str
= CalcArg(TabArg
,&i
);
1652 IdFuncComp
= atoi(str
);
1655 arg
[1] = CalcArg(TabArg
,&i
);
1657 Loop
=TabComp
[IdFuncComp
](arg
[0],arg
[1]);
1658 if (Loop
) ExecBloc((Bloc
*)TabArg
[NbArg
-1]);
1665 static void WriteToFile (int NbArg
,long *TabArg
)
1668 char *arg
[2],str
[50],*tempstr
,*home
,*file
;
1675 int CurrPos
=0,CurrPos2
;
1678 arg
[0] = CalcArg(TabArg
,&i
);
1679 arg
[1]=(char*)safecalloc(1,256);
1680 for (i
=1; i
<NbArg
; i
++)
1682 tempstr
= CalcArg(TabArg
,&i
);
1683 arg
[1] = strcat(arg
[1],tempstr
);
1686 if (arg
[1][strlen(arg
[1])-1] != '\n')
1689 arg
[1] = (char*)saferealloc(arg
[1],strlen(arg
[1])+2);
1694 sprintf(StrEnd
,"#end\n");
1695 sprintf(StrBegin
,"#%s,",ScriptName
);
1697 buf
=(char*)safecalloc(1,maxsize
);
1699 if (arg
[0][0] != '/')
1701 file
= safestrdup(arg
[0]);
1702 home
= getenv("HOME");
1703 arg
[0] = (char*)saferealloc(arg
[0],
1704 sizeof(char) * (strlen(arg
[0]) + 4 +strlen(home
)));
1705 sprintf(arg
[0],"%s/%s",home
,file
);
1708 f
= fopen(arg
[0],"a+");
1709 fseek(f
, 0, SEEK_SET
);
1710 size
= fread(buf
, 1 ,maxsize
,f
);
1711 while(((strncmp(StrBegin
, &buf
[CurrPos
], strlen(StrBegin
))) !=0) &&
1718 sprintf(buf
,"%s\n%s%d\n",buf
,StrBegin
,getpid());
1719 sprintf(buf
,"%s%s",buf
,arg
[1]);
1720 sprintf(buf
,"%s%s\n",buf
,StrEnd
);
1724 sscanf(&buf
[CurrPos
+strlen(StrBegin
)],"%d",&OldPID
);
1725 if (OldPID
== getpid())
1727 sprintf(str
,"%d\n",OldPID
);
1728 while(((strncmp(StrEnd
,&buf
[CurrPos
],strlen(StrEnd
))) != 0) &&
1733 memmove(&buf
[CurrPos
+strlen(arg
[1])],&buf
[CurrPos
],strlen(buf
)-CurrPos
);
1734 memmove(&buf
[CurrPos
],arg
[1],strlen(arg
[1]));
1736 else /* Remplacement des anciennes commandes */
1738 CurrPos
= CurrPos
+strlen(StrBegin
);
1740 while(((strncmp(StrEnd
,&buf
[CurrPos2
],strlen(StrEnd
))) != 0) &&
1745 sprintf(str
,"%d\n%s",getpid(),arg
[1]);
1746 memmove(&buf
[CurrPos
+strlen(str
)], &buf
[CurrPos2
], strlen(buf
)-CurrPos2
);
1747 buf
[strlen(buf
)-((CurrPos2
-CurrPos
)-strlen(str
))] = '\0';
1748 memmove(&buf
[CurrPos
],str
,strlen(str
));
1753 f
= fopen(arg
[0],"w");
1756 fprintf(stderr
,"[%s][WriteToFile]: Unable to open file %s\n",
1760 fwrite(buf
,1,strlen(buf
),f
);
1768 static void SendToScript (int NbArg
,long *TabArg
)
1770 char *tempstr
,*Msg
,*R
;
1775 /* Calcul destinataire */
1776 tempstr
=CalcArg(TabArg
,&j
);
1777 dest
=(int)atoi(tempstr
);
1780 /* Calcul contenu */
1781 Msg
=(char*)safecalloc(256,sizeof(char));
1782 for (j
=1;j
<NbArg
;j
++)
1784 tempstr
=CalcArg(TabArg
,&j
);
1785 Msg
=(char*)saferealloc((void*)Msg
,strlen(Msg
)+strlen(tempstr
)+1);
1786 Msg
=strcat(Msg
,tempstr
);
1790 /* Calcul recepteur */
1791 R
=(char*)safecalloc(strlen(x11base
->TabScriptId
[dest
])+1,sizeof(char));
1792 sprintf(R
,"%s",x11base
->TabScriptId
[dest
]);
1793 myatom
=XInternAtom(dpy
,R
,True
);
1795 if ((BuffSend
.NbMsg
<40)&&(XGetSelectionOwner(dpy
,myatom
)!=None
))
1797 /* Enregistrement dans le buffer du message */
1798 BuffSend
.TabMsg
[BuffSend
.NbMsg
].Msg
=Msg
;
1799 /* Enregistrement dans le buffer du destinataire */
1800 BuffSend
.TabMsg
[BuffSend
.NbMsg
].R
=R
;
1801 /* Enregistrement du message */
1804 /* Reveil du destinataire */
1805 XConvertSelection(dpy
,
1806 XInternAtom(dpy
,x11base
->TabScriptId
[dest
],True
),
1807 propriete
, propriete
, x11base
->win
, CurrentTime
);
1811 fprintf(stderr
,"[%s][SendToScript]: Too many messages sended\n",
1818 static void Key (int NbArg
,long *TabArg
)
1820 char *key_string
,*in_modifier
,*action
,*str
,*tmp
,*widget
,*sig
;
1824 KeySym keysym
= NoSymbol
;
1827 key_string
= CalcArg(TabArg
,&j
);
1830 in_modifier
= CalcArg(TabArg
,&j
);
1833 widget
= CalcArg(TabArg
,&j
);
1836 sig
= CalcArg(TabArg
,&j
);
1839 str
= (char*)safecalloc(256,sizeof(char));
1840 for (i
=j
+1; i
<NbArg
; i
++)
1842 tmp
= CalcArg(TabArg
,&i
);
1843 str
= (char*)saferealloc((void*)str
, strlen(str
) + strlen(tmp
) + 1);
1844 str
= strcat(str
, tmp
);
1848 tmp
= safestrdup(CatString3(widget
, " ", sig
));
1849 action
= safestrdup(CatString3(tmp
, " ", str
));
1855 keysym
= FvwmStringToKeysym(dpy
, key_string
);
1858 fprintf(stderr
, "[%s][Key]: No such key: %s", ScriptName
, key_string
);
1862 if (modifiers_string_to_modmask(in_modifier
, &modifier
)) {
1863 fprintf(stderr
,"[%s][Key]: bad modifier: %s\n",
1864 ScriptName
,in_modifier
);
1876 dpy
, &BindingsList
, BIND_KEYPRESS
, STROKE_ARG(0) 0, keysym
,
1877 key_string
, modifier
, C_WINDOW
, (void *)action
, NULL
, NULL
);
1886 static char *FuncGettext(int *NbArg
,long *TabArg
)
1892 str
= CalcArg(TabArg
,NbArg
);
1894 string
= FGettextCopy(str
);
1895 if (str
&& string
!= str
)
1899 return (char *)string
;
1903 * Fonction d'initialisation de TabCom et TabFunc
1911 TabCom
[4]=ChangeValue
;
1912 TabCom
[5]=ChangePos
;
1913 TabCom
[6]=ChangeSize
;
1914 TabCom
[7]=ChangeIcon
;
1915 TabCom
[8]=ChangeTitle
;
1916 TabCom
[9]=ChangeFont
;
1917 TabCom
[10]=ChangeForeColor
;
1919 TabCom
[12]=SendSign
;
1924 TabCom
[17]=MyWarpPointer
;
1925 TabCom
[18]=WriteToFile
;
1926 TabCom
[19]=ChangeBackColor
;
1927 TabCom
[21]=ChangeValueMax
;
1928 TabCom
[22]=ChangeValueMin
;
1929 TabCom
[23]=SendToScript
;
1930 TabCom
[24]=ChangeColorset
;
1932 TabCom
[26]=ChangeLocaleTitle
;
1933 TabCom
[27]=ChangeWindowTitle
;
1934 TabCom
[28]=ChangeWindowTitleFromArg
;
1937 TabFunc
[1]=FuncGetValue
;
1938 TabFunc
[2]=FuncGetTitle
;
1939 TabFunc
[3]=FuncGetOutput
;
1940 TabFunc
[4]=FuncNumToHex
;
1941 TabFunc
[5]=FuncHexToNum
;
1943 TabFunc
[7]=FuncMult
;
1945 TabFunc
[9]=FuncStrCopy
;
1946 TabFunc
[10]=LaunchScript
;
1947 TabFunc
[11]=GetScriptFather
;
1948 TabFunc
[12]=ReceivFromScript
;
1949 TabFunc
[13]=RemainderOfDiv
;
1950 TabFunc
[14]=GetTime
;
1951 TabFunc
[15]=GetScriptArg
;
1952 TabFunc
[16]=FuncGetFore
;
1953 TabFunc
[17]=FuncGetBack
;
1954 TabFunc
[18]=FuncGetHili
;
1955 TabFunc
[19]=FuncGetShad
;
1956 TabFunc
[20]=FuncGetMinValue
;
1957 TabFunc
[21]=FuncGetMaxValue
;
1958 TabFunc
[22]=FuncGetPid
;
1959 TabFunc
[23]=FuncSendMsgAndGet
;
1960 TabFunc
[24]=FuncParse
;
1961 TabFunc
[25]=FuncGetLastString
;
1962 TabFunc
[26]=FuncGettext
;
1964 /* Fonction de comparaison */