Nife version Beta
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

648 lines
17 KiB

  1. /* Copyright (C) 2011-2014 Patrick H. E. Foubet - S.E.R.I.A.N.E.
  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 3 of the License, or any
  5. later version.
  6. This program is distributed in the hope that it will be useful,
  7. but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  9. GNU General Public License for more details.
  10. You should have received a copy of the GNU General Public License
  11. along with this program. If not, see <http://www.gnu.org/licenses/>
  12. *******************************************************************/
  13. #include "conf.h"
  14. /* lib.c librairie de base */
  15. #include <stdio.h>
  16. #include <stdlib.h>
  17. #include <string.h>
  18. #include "nife.h"
  19. #include "mth.h"
  20. #include "err.h"
  21. #include "histo.h"
  22. #include "foncs.h"
  23. #include "tasks.h"
  24. #include "stackN.h"
  25. #include "stackL.h"
  26. #include "stackC.h"
  27. #include "stackF.h"
  28. #include "stackV.h"
  29. #include "libmath.h"
  30. #include "help.h"
  31. #include "dev.h"
  32. #include "i2c.h"
  33. #include "net.h"
  34. #include "gplot.h"
  35. #include "debug.h"
  36. /* familles des fonctions */
  37. #define F_CORE 1 /* Core */
  38. #define F_MATH 2 /* Mathematiques */
  39. #define F_PROG 4 /* Programmation, variables, tasks, ... */
  40. #define F_TOOL 8 /* External Tools Graphical or others */
  41. #define F_DEV 16 /* devices, comedi interfaces, ... */
  42. #define F_NET 32 /* networking functions */
  43. #define F_USR 64 /* user system functions */
  44. struct fonction {
  45. char * nam;
  46. void (* fct)(void);
  47. short typ; /* 0 fct, 1 instruction, 2 externe, 3 usr fct */
  48. short fam; /* cf F_xxx ci-dessus */
  49. };
  50. #define NBFONC 400
  51. #define NBCMOY 12 /* nb de car. en moyenne */
  52. static char Libelles[NBFONC*NBCMOY], *pLibs=Libelles;
  53. static struct fonction Fonctions[NBFONC];
  54. static int NBFonc=0;
  55. int InstallOn=0;
  56. static void IF_INSTALL(void) { InstallOn=1; }
  57. static void IF_INSTALLF(void) { InstallOn=2; }
  58. static void IF_INSTALLV(void) { InstallOn=3; }
  59. /* for dynamic functions */
  60. static void IF_DF_INIT(void) { InstallOn=8; }
  61. static void IF_DF_START(void) { InstallOn=9; }
  62. static void IF_DF_STOP(void) { InstallOn=10; }
  63. static void addFoncT(char *l, void (*f)(void), short T, short F)
  64. {
  65. char *LMax;
  66. if (NBFonc >= NBFONC) stopErr("addFonc : NBFONC !",NULL);
  67. LMax = Libelles + (NBFONC*NBCMOY);
  68. if (pLibs + strlen(l) + 1 >= LMax) stopErr("addFonc : Libelles !",NULL);
  69. Fonctions[NBFonc].nam = pLibs;
  70. Fonctions[NBFonc].typ = T;
  71. Fonctions[NBFonc].fam = F;
  72. Fonctions[NBFonc++].fct = f;
  73. strcpy(pLibs,l);
  74. pLibs += strlen(l);
  75. *pLibs++ = '\0';
  76. }
  77. static void addFonc(char *l, void (*f)(void))
  78. {
  79. addFoncT(l,f,0,F_CORE);
  80. }
  81. static void addFonM(char *l, void (*f)(void))
  82. {
  83. addFoncT(l,f,0,F_MATH);
  84. }
  85. static void addFonP(char *l, void (*f)(void))
  86. {
  87. addFoncT(l,f,0,F_PROG);
  88. }
  89. static void addFonG(char *l, void (*f)(void))
  90. {
  91. addFoncT(l,f,0,F_TOOL);
  92. }
  93. static void addFonD(char *l, void (*f)(void))
  94. {
  95. addFoncT(l,f,0,F_DEV);
  96. }
  97. static void addFonN(char *l, void (*f)(void))
  98. {
  99. addFoncT(l,f,0,F_NET);
  100. }
  101. void addFonU(char *l, void *A)
  102. {
  103. PFV f;
  104. f = (PFV)A;
  105. addFoncT(l,f,0,F_USR);
  106. }
  107. static void addFonE(char *l, void (*f)(void), short F) /* External functions */
  108. { /* not beetween : and ;*/
  109. addFoncT(l,f,2,F);
  110. }
  111. static void addInst(char *l, void (*f)(void))
  112. {
  113. addFoncT(l,f,1,F_PROG);
  114. }
  115. static char **ListFonc = (char**)NULL;
  116. static void Show_library(int NbF)
  117. {
  118. int i,j=0;
  119. for (i=0;i<NbF;i++) {
  120. /* printf("%-13s",Fonctions[i].nam);*/
  121. printf("%-13s",ListFonc[i]);
  122. j++;
  123. if (j == 6) {
  124. j=0;
  125. printf("\n");
  126. }
  127. }
  128. if (j) printf("\n");
  129. }
  130. static int triList(short F)
  131. {
  132. void * M;
  133. char * T;
  134. int i,j, NbF;
  135. if (ListFonc != (char**)NULL) free((void*)ListFonc);
  136. if ((M = malloc(sizeof(char*)* NBFonc)) == NULL) stopErr("triList","malloc");
  137. ListFonc = (char**)M;
  138. j=0;
  139. for(i=0;i<NBFonc;i++) {
  140. if (Fonctions[i].fam & F) ListFonc[j++]=Fonctions[i].nam;
  141. }
  142. NbF = j;
  143. for(i=0; i<NbF-1; i++) /* avant NbF-2 */
  144. for(j=i+1; j<NbF; j++)
  145. if(strcmp(ListFonc[j],ListFonc[i]) < 0) {
  146. T=ListFonc[i]; ListFonc[i]=ListFonc[j]; ListFonc[j]=T;
  147. }
  148. return NbF;
  149. }
  150. void listLibBegin(char * b)
  151. {
  152. int i,j=0,l,n;
  153. l=strlen(b);
  154. n=triList(0xFF);
  155. for(i=0;i<n;i++) {
  156. if (strncmp(ListFonc[i],b,l)==0){
  157. printf("%-13s",ListFonc[i]);
  158. j++;
  159. if (j == 6) {
  160. j=0;
  161. printf("\n");
  162. }
  163. } else
  164. if (strncmp(ListFonc[i],b,l)>0) break;
  165. }
  166. if (j) printf("\n");
  167. }
  168. char * getLibBegin(char * b)
  169. {
  170. int i,l;
  171. l=strlen(b);
  172. for(i=0;i<NBFonc;i++) {
  173. if (strncmp(Fonctions[i].nam,b,l)==0) break;
  174. }
  175. if (i==NBFonc) return NULL;
  176. return Fonctions[i].nam;
  177. }
  178. static char Rac[20]; /* longueur maxi d'une commande */
  179. int nbLibBegin(char * b, char ** r)
  180. {
  181. int i,n, first=1;
  182. unsigned int j, l,t=0;
  183. n=triList(0xFF);
  184. l=strlen(b);
  185. *Rac='\0';
  186. for (i=0;i<n;i++) {
  187. if (strncmp(ListFonc[i],b,l)>0) break;
  188. if (strncmp(ListFonc[i],b,l)==0) {
  189. t++;
  190. if (first) {
  191. strcpy(Rac,ListFonc[i]);
  192. first=0;
  193. } else {
  194. if (strlen(Rac) > l) {
  195. for(j=l;j<strlen(Rac);j++)
  196. if (strncmp(Rac,ListFonc[i],j) != 0) break;
  197. if (j!=strlen(Rac)) Rac[j-1]='\0';
  198. else
  199. if (Rac[j-1] != ListFonc[i][j-1]) Rac[j-1]='\0';
  200. }
  201. }
  202. }
  203. }
  204. if (strlen(Rac) > l) *r = Rac;
  205. else *r = NULL;
  206. return(t);
  207. }
  208. void IF_show_liball(void)
  209. {
  210. Show_library(triList(0xFF));
  211. }
  212. void IF_show_libstd(void)
  213. {
  214. Show_library(triList(F_CORE));
  215. }
  216. void IF_show_libmath(void)
  217. {
  218. Show_library(triList(F_MATH));
  219. }
  220. void IF_show_libprog(void)
  221. {
  222. Show_library(triList(F_PROG));
  223. }
  224. void IF_show_libtools(void)
  225. {
  226. Show_library(triList(F_TOOL));
  227. }
  228. void IF_show_libdev(void)
  229. {
  230. Show_library(triList(F_DEV));
  231. }
  232. void IF_show_libnet(void)
  233. {
  234. Show_library(triList(F_NET));
  235. }
  236. void IF_show_libusr(void)
  237. {
  238. Show_library(triList(F_USR));
  239. }
  240. void initLib(void)
  241. {
  242. addFonc(".",IF_point);
  243. addFonc("+",IF_plus);
  244. addFonc("-",IF_moins);
  245. addFonc("=",IF_Legal);
  246. addFonc("<>",IF_Ldiff);
  247. addFonc(">",IF_Lsup);
  248. addFonc("<",IF_Linf);
  249. addFonc(">=",IF_Lsupeg);
  250. addFonc("<=",IF_Linfeg);
  251. addFonc("*",IF_mult);
  252. addFonc("/",IF_div);
  253. addFonc("neg",IF_neg);
  254. addFonc("min",IF_min);
  255. addFonc("max",IF_max);
  256. addFonc("modulo",IF_modulo);
  257. addFonc("**",IF_puiss);
  258. addFonc("[]-sub",IF_subTab);
  259. addFonc("[]sub",IF_subTabR);
  260. addFonc("*[]-sub",IF_NsubTab);
  261. addFonc("*[]sub",IF_NsubTabR);
  262. addFonc("[]rev",IF_TabRev);
  263. addFonc("*[]rev",IF_NTabRev);
  264. addFonc("[]crot",IF_TabTransp);
  265. addFonc("[]transp",IF_TabTranspN);
  266. addFonc("[]trot",IF_TabTranspT);
  267. addFonc("[]>>",IF_TNShiftR);
  268. addFonc("[]<<",IF_TNShiftL);
  269. addFonc("*[]>>",IF_NTNShiftR);
  270. addFonc("*[]<<",IF_NTNShiftL);
  271. addFonc("[]>",IF_TShiftR);
  272. addFonc("[]<",IF_TShiftL);
  273. addFonc("*[]>",IF_NTShiftR);
  274. addFonc("*[]<",IF_NTShiftL);
  275. addFonc("[]min",IF_TABMin);
  276. addFonc("[]max",IF_TABMax);
  277. addFonc("[]sum",IF_TABSum);
  278. addFonc("[]prod",IF_TABProd);
  279. addFonc("[]min/max",IF_TABMinMax);
  280. addFonc(">array",IF_toArray);
  281. addFonc(">scalar",IF_toScalar);
  282. addFonc(">-scalar",IF_toScalarR);
  283. addFonc("\"",IF_debString);
  284. addFonc("\"drop",IF_dropC);
  285. addFonc("\"dup",IF_dupC);
  286. addFonc("\"over",IF_overC);
  287. addFonc("\"swap",IF_swapC);
  288. addFonc("\"type",IF_typeC);
  289. addFonc("\"cat",IF_catC);
  290. addFonc("\"cats",IF_catsC);
  291. addFonc("cr",IF_crC);
  292. addFonc("\"time",IF_timeC);
  293. addFonc("\"date",IF_dateC);
  294. addFonc("sleep",IF_sleep);
  295. addFonc("sh",IF_sh);
  296. addFonc("?drop",IF_dropL);
  297. addFonc("?dup",IF_dupL);
  298. addFonc("?swap",IF_swapL);
  299. addFonc("?over",IF_overL);
  300. addFonc("?t/f",IF_typeL);
  301. addFonc("and",IF_andL);
  302. addFonc("or",IF_orL);
  303. addFonc("xor",IF_xorL);
  304. addFonP("fdrop",rmLastFct);
  305. addFonE("del_func",IF_delFct, F_PROG);
  306. addFonE("del_afunc",IF_delAFct, F_PROG);
  307. addFonE("del_ofunc",IF_delOFct, F_PROG);
  308. addFonE("fscan",IF_scanFct, F_PROG);
  309. addFonc("?cs",IF_show_stackC);
  310. addFonP("?f",IF_show_stackF);
  311. /* addFonP("?l",IF_showFD); for debugging */
  312. addFonP("?v",IF_show_stackV);
  313. addFonE("del_var",IF_delVar,F_PROG);
  314. addFonP("vdrop",rmLastVar);
  315. addFonP("reset_var",IF_setVarI);
  316. addFonP(">v",IF_setVarN);
  317. addFonP("?>v",IF_setVarB);
  318. addFonP("\">v",IF_setVarC);
  319. addFonP("in",IF_setVarLF);
  320. addFonP("install",IF_INSTALL);
  321. addFonP("install_f",IF_INSTALLF);
  322. addFonP("install_v",IF_INSTALLV);
  323. addFonP("df_init",IF_DF_INIT);
  324. addFonP("df_start",IF_DF_START);
  325. addFonP("df_stop",IF_DF_STOP);
  326. addFonc("?ls",IF_show_stackL);
  327. addFonc("?s",IF_show_stack);
  328. addFonc("?libs",IF_show_liball);
  329. addFonc("?lib",IF_show_libstd);
  330. addFonc("?libM",IF_show_libmath);
  331. addFonc("?libT",IF_show_libtools);
  332. addFonc("?libP",IF_show_libprog);
  333. addFonc("?libD",IF_show_libdev);
  334. addFonc("?libN",IF_show_libnet);
  335. addFonc("?libU",IF_show_libusr);
  336. addFonc("?lasterr",IF_showError);
  337. addFonc("?err",IF_IsError);
  338. addFonc("noerr",IF_NoError);
  339. addFonc("messerr",IF_LibError);
  340. addFonc("ls_clear",IF_stackL_clear);
  341. addFonc("cs_clear",IF_stackC_clear);
  342. addFonc("REAL",IF_REAL);
  343. addFonc("INTEGER",IF_INTEGER);
  344. addFonc("echo_on",IF_ECHOON);
  345. addFonc("echo_off",IF_ECHOFF);
  346. addFonc("DEBUG_I/O",D_Update);
  347. addFonc("NBTAB",IF_NBTAB);
  348. addFonc("NBLIG",IF_NBLIG);
  349. addFonE("Var",IF_debVar, F_PROG);
  350. addFonc("\"Var",IF_debVarCS);
  351. addFonP("var_off",IF_VAROFF);
  352. addFonP("var_up",IF_VARUP);
  353. addFonP("var_down",IF_VARDOWN);
  354. addFonc("?vars",IF_vars);
  355. addFonc("drop",IF_drop);
  356. addFonc("dup",IF_dup);
  357. addFonc("swap",IF_swap);
  358. addFonc("over",IF_over);
  359. addFonc("pick",IF_pick);
  360. addFonc("rot",IF_rot);
  361. addFonc("unrot",IF_unrot);
  362. addFonc("roll",IF_roll);
  363. addFonc("unroll",IF_unroll);
  364. addFonc("*drop",IF_Ndrop);
  365. addFonc("*dup",IF_Ndup);
  366. addFonc("depth",IF_depth);
  367. addFonc("exit",IF_exit);
  368. addFonc("false",IF_false);
  369. addFonc("not",negBool);
  370. addFonc("ramp",IF_ramp);
  371. addFonc("dramp",IF_dramp);
  372. addFonc("rusage",IF_resUsage);
  373. addFonc("s_clear",IF_stack_clear);
  374. addFonM("inv",IF_inv);
  375. addFonM("sqrt",IF_sqrt);
  376. addFonM("cbrt",IF_cbrt);
  377. addFonM("round",IF_round);
  378. addFonM("floor",IF_floor);
  379. addFonM("ceil",IF_ceil);
  380. addFonM("sgn",IF_sgn);
  381. addFonM("abs",IF_abs);
  382. addFonM("pi",IF_pi);
  383. addFonM("sin",IF_sin);
  384. addFonM("cos",IF_cos);
  385. addFonM("tan",IF_tan);
  386. addFonM("asin",IF_asin);
  387. addFonM("acos",IF_acos);
  388. addFonM("atan",IF_atan);
  389. addFonM("sinh",IF_sinh);
  390. addFonM("cosh",IF_cosh);
  391. addFonM("tanh",IF_tanh);
  392. addFonM("asinh",IF_asinh);
  393. addFonM("acosh",IF_acosh);
  394. addFonM("atanh",IF_atanh);
  395. addFonM("ln",IF_ln);
  396. addFonM("log",IF_log);
  397. addFonM("exp",IF_exp);
  398. addFonM("j0",IF_j0);
  399. addFonM("j1",IF_j1);
  400. addFonM("y0",IF_y0);
  401. addFonM("y1",IF_y1);
  402. addFonc("time",IF_time);
  403. addFonc("true",IF_true);
  404. addFonc("about",IF_about);
  405. addFonc("vers",IF_vers);
  406. addFonE("load",IF_Load, F_PROG);
  407. addFonP("\"load",IF_LoadCS);
  408. addFonP("\"exec",IF_ExecCS);
  409. addFonP("\"execf",IF_ExecCSf);
  410. addInst("\"execk",IF_EXEK);
  411. addFonG(">csv",IF_toCsv);
  412. addFonG("y_xgraph",IF_yXgraph);
  413. addFonG("yt_xgraph",IF_ytXgraph);
  414. addFonG("xy_xgraph",IF_xyXgraph);
  415. addFonG("xyt_xgraph",IF_xytXgraph);
  416. addFonG("?gp",IF_show_stackGP);
  417. addFonG("gplot",IF_gplot_new);
  418. addFonG("gplotM",IF_gplot_newM);
  419. addFonG("gplotRaz",IF_delAllGP);
  420. addFonG("gplotCmd",IF_gplot_commapp);
  421. addFonG("gplotAdd",IF_gplot_append);
  422. addFonG("gplotRepl",IF_gplot_replace);
  423. addFonG("del_gplot",IF_gplot_del);
  424. addFonG("gplotClear",IF_gplot_clear);
  425. addFonP(":",IF_debFct);
  426. addFonP(":!",IF_debFctS);
  427. addFonP("Task",IF_NewTask);
  428. addFonP("?t",IF_show_Tasks);
  429. addFonP("?task_run",IF_statusTask);
  430. addFonP("del_task",IF_delTask);
  431. addFonP("\"f",IF_execCS);
  432. addFonP("\"v",IF_execCSv);
  433. addFonP("\"f?",IF_execCSl);
  434. addFonP("\"v?",IF_execCSvl);
  435. addFonP("stop_task",IF_stopTask);
  436. addFonP("?console",IF_showCons);
  437. addInst(";",IF_finFct);
  438. addInst("'",IF_debBackC);
  439. addInst("`",IF_debBackC1);
  440. addInst("return",IF_RET);
  441. addInst("if",IF_IF);
  442. addInst("else",IF_ELSE);
  443. addInst("then",IF_THEN);
  444. addInst("begin",IF_BEGIN);
  445. addInst("again",IF_AGAIN);
  446. addInst("until",IF_UNTIL);
  447. addInst("while",IF_WHILE);
  448. addInst("repeat",IF_REPEAT);
  449. addInst("do",IF_DO);
  450. addFonc("do_leave",IF_DO_Leave);
  451. addFonc("*do_leave",IF_DO_MLeave);
  452. addFonc("do_next",IF_DO_Next);
  453. /* addFonc("?do",IF_DO_Show); for debugging */
  454. addFonc("ndo",IF_nDO);
  455. addInst("loop",IF_LOOP);
  456. addInst("+loop",IF_PLOOP);
  457. addInst("I",IF_I_DO);
  458. addInst("J",IF_J_DO);
  459. addInst("K",IF_K_DO);
  460. addInst("break",IF_BREAK);
  461. addInst("myself",IF_MYSELF);
  462. addInst("onerr:",IF_ONERR);
  463. addInst("end:",IF_END);
  464. addInst("goto_end",IF_JEND);
  465. addFonE("help",IF_help, F_CORE);
  466. addFonD("?dev",IF_listDev);
  467. addFonD("dev_info",IF_showDev);
  468. addFonD("dev_read",IF_devRead);
  469. addFonD("dev_write",IF_devWrite);
  470. addFonD("dev_dflt",IF_devDflt);
  471. addFonD("?dev_dflt",IF_devShowDflt);
  472. addFonD("dev_dflW",IF_devDflW);
  473. addFonD("dev_dflR",IF_devDflR);
  474. addFonD("?i2c",IF_listI2C);
  475. addFonD("i2c_info",IF_showI2C);
  476. addFonD("i2c_read",IF_I2CRead);
  477. addFonD("i2c_write",IF_I2CWrite);
  478. addFonN("?n",IF_netList);
  479. addFonN("netOn",IF_netOn);
  480. addFonN("netOff",IF_netOff);
  481. addFonN("netDt>",IF_netDt);
  482. addFonN("netExec",IF_netExec);
  483. addFonN("netCompile",IF_netCompile);
  484. addFonN("ndepth",IF_netDepth);
  485. addFonN("stopServer",IF_netStopS);
  486. addFonN("NetServer",IF_NetServer);
  487. addFonN("srusage",IF_netRusage);
  488. addFonN("NetKey",IF_NetKey);
  489. addFonN("NetErr",IF_NetErrVal);
  490. addFonN("Me",IF_Me);
  491. addFonN("?ns",IF_netStackList);
  492. addFonN(">net",IF_netU2S);
  493. addFonN("net>",IF_netS2U);
  494. addFonN("ndrop",IF_netDropS);
  495. /* triList(); */
  496. }
  497. void * libByName(char * L)
  498. {
  499. int i;
  500. for (i=0;i<NBFonc;i++) {
  501. if (strcmp(L,Fonctions[i].nam) == 0) {
  502. if (Fonctions[i].typ) break;
  503. else return((void*)Fonctions[i].fct);
  504. }
  505. }
  506. return VIDE;
  507. }
  508. int execLibNrpc(char *C)
  509. {
  510. int i;
  511. if (sigsetjmp(ENV_INT,1)) {
  512. return 0;
  513. }
  514. if (IF_execFct(C)) return 1;
  515. for (i=0;i<NBFonc;i++) {
  516. if (strcmp(C,Fonctions[i].nam) == 0) {
  517. switch (Fonctions[i].typ) {
  518. case 1:
  519. case 3: /* usr fct */
  520. return 0;
  521. break;
  522. default: /* typ = 0 et 2 */
  523. Fonctions[i].fct();
  524. break;
  525. }
  526. return 1;
  527. }
  528. }
  529. if (IF_execVar(C)) return 1; /* VARS DOWN */
  530. return 0;
  531. }
  532. int execLib(char *C)
  533. {
  534. int i;
  535. void * A;
  536. short T=0;
  537. InExec = C;
  538. D_Trace(C);
  539. if (sigsetjmp(ENV_INT,1)) {
  540. interInfos("execLib",C);
  541. return 1;
  542. }
  543. if (InstallOn) {
  544. switch (InstallOn) {
  545. case 1 : /* lib first */
  546. A=libByName(C);
  547. if (A==VIDE) {
  548. A=fctByName(C);
  549. if (A!=VIDE) T=2;
  550. } else T=1;
  551. break;
  552. case 2 : /* user functions first */
  553. A=fctByName(C);
  554. if (A==VIDE) {
  555. A=libByName(C);
  556. if (A!=VIDE) T=1;
  557. } else T=2;
  558. break;
  559. case 3 : /* variables only */
  560. A=varByName(C);
  561. if (A!=VIDE) T=3;
  562. break;
  563. case 8 : /* df_init */
  564. A=fctByName(C);
  565. updDynFct(A,0);
  566. break;
  567. case 9 : /* df_start */
  568. A=fctByName(C);
  569. updDynFct(A,1);
  570. break;
  571. case 10 : /* df_stop */
  572. A=fctByName(C);
  573. updDynFct(A,2);
  574. break;
  575. default :
  576. break;
  577. }
  578. _MODIF_FCT_INST_(A);
  579. _MODIF_FCT_TYP_(T);
  580. InstallOn=0;
  581. return 1;
  582. }
  583. if ((VARS==2) && (IF_execVar(C))) return 1; /* VARS UP */
  584. if (IF_execFct(C)) return 1;
  585. for (i=0;i<NBFonc;i++) {
  586. /* printf("execLib : teste %s !\n", Fonctions[i].nam); */
  587. if (strcmp(C,Fonctions[i].nam) == 0) {
  588. switch (Fonctions[i].typ) {
  589. case 1:
  590. if (fctEnCours) Fonctions[i].fct();
  591. else messErr(13);
  592. break;
  593. case 2:
  594. if (fctEnCours) messErr(25);
  595. else Fonctions[i].fct();
  596. break;
  597. case 3: /* usr fct */
  598. break;
  599. default: /* typ = 0 */
  600. if (fctEnCours) {
  601. if (strcmp(C,":") == 0) messErr(15);
  602. else {
  603. if (strcmp(C,"\"") == 0) Fonctions[i].fct();
  604. else makeFct(T_LIB,(void*)Fonctions[i].fct);
  605. }
  606. } else Fonctions[i].fct();
  607. break;
  608. }
  609. return 1;
  610. }
  611. }
  612. if ((VARS==1) && (IF_execVar(C))) return 1; /* VARS DOWN */
  613. /* printf("execLib : appel putVal(%s)\n",C); */
  614. return(putVal(C));
  615. }
  616. char * libByAddr(void *A)
  617. {
  618. PFC f;
  619. int i;
  620. f = (PFC)A;
  621. for (i=0;i<NBFonc;i++) {
  622. if (f == (PFC)(Fonctions[i].fct)) return Fonctions[i].nam;
  623. }
  624. return NULL;
  625. }