home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1994 March / Source_Code_CD-ROM_Walnut_Creek_March_1994.iso / compsrcs / misc / volume34 / vmsrtlkb / part02 < prev    next >
Encoding:
Text File  |  1992-12-18  |  30.0 KB  |  1,013 lines

  1. Newsgroups: comp.sources.misc
  2. From: vicente@cenaath.cena.dgac.fr (Martin VICENTE)
  3. Subject: v34i082:  vms_rtl_kbd - single keypress under VMS, Part02/02
  4. Message-ID: <1992Dec18.214433.15695@sparky.imd.sterling.com>
  5. X-Md4-Signature: 3358da1ae4451d7614f06e922e1fa384
  6. Date: Fri, 18 Dec 1992 21:44:33 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: vicente@cenaath.cena.dgac.fr (Martin VICENTE)
  10. Posting-number: Volume 34, Issue 82
  11. Archive-name: vms_rtl_kbd/part02
  12. Environment: VMS, C, Pascal, ADA
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then feed it
  16. # into a shell via "sh file" or similar.  To overwrite existing files,
  17. # type "sh file -c".
  18. # Contents:  LISEZ-MOI demo_kbd$routines.c demo_kbd$routines.pas
  19. #   demo_kbd_routines.ada kbd$routines.h link_cc.opt
  20. # Wrapped by kent@sparky on Fri Dec 18 15:30:49 1992
  21. PATH=/bin:/usr/bin:/usr/ucb:/usr/local/bin:/usr/lbin ; export PATH
  22. echo If this archive is complete, you will see the following message:
  23. echo '          "shar: End of archive 2 (of 2)."'
  24. if test -f 'LISEZ-MOI' -a "${1}" != "-c" ; then 
  25.   echo shar: Will not clobber existing file \"'LISEZ-MOI'\"
  26. else
  27.   echo shar: Extracting \"'LISEZ-MOI'\" \(3816 characters\)
  28.   sed "s/^X//" >'LISEZ-MOI' <<'END_OF_FILE'
  29. XLISEZ-MOI                                   18/12/92
  30. X
  31. X
  32. X                            K B D $ R O U T I N E S
  33. X
  34. X
  35. X             << Single keypress under VMS in C, Pascal and Ada >>
  36. X
  37. X
  38. X Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne.
  39. X   Author: Martin VICENTE (DGAC/CENA/SID)
  40. X   E-mail: vicente@cenaath.cena.dgac.fr
  41. X   Mail:   C.E.N.A. - Orly Sud 205 - 94 542 ORLY AEROGARE CEDEX, FRANCE
  42. X
  43. X
  44. XComment lire "a la volee" des caracteres du clavier sous VMS ?
  45. X**************************************************************
  46. X
  47. X    Peut-etre certains d'entre vous ont-ils ete confronte a ce probleme,
  48. X    et trouve certaines solutions: librairie SMG$, appels systeme.
  49. X
  50. X    L'appel a une routine de la Run-Time Library SMG permet effectivement
  51. X    de s'en sortir (polling sur SMG$READ_KEYSTROKE avec un time-out nul), mais
  52. X    avec des consequences desastreuses sur la consommation CPU!
  53. X
  54. X    La solution de l'appel systeme est certainement la meilleure, mais
  55. X    necessite d'etre initie.
  56. X
  57. X    Nous avons donc developpe cette extension de la RTL offrant
  58. X    ainsi a l'utilisateur une interface beaucoup plus simple a manier.
  59. X    Elle est accessible au developeur C, Pascal et Ada.
  60. X
  61. X
  62. XLa distribution contient les fichiers suivant:
  63. X**********************************************
  64. X
  65. X    Pour C:
  66. X
  67. X        KBD$ROUTINES.H          Fichier header
  68. X        DEMO_KBD$ROUTINES.C      Programme de demo
  69. X
  70. X    Pour Pascal:
  71. X
  72. X        PASCAL$KBD_ROUTINES.PAS      Declaration des routines
  73. X        DEMO_KBD$ROUTINES.PAS      Programme de demo
  74. X
  75. X    Pour Ada:
  76. X
  77. X        KBD_.ADA          Declaration des specifications.
  78. X        DEMO_KBD_ROUTINES.ADA      Programme de demo
  79. X
  80. X
  81. XLa bibliotheque KBD contient 6 routines:
  82. X****************************************
  83. X
  84. X    KBD$CLOSE_KEYBOARD:     Libere la memoire des structures de donnees associees
  85. X             a ce module.
  86. X
  87. X    KBD$CVT_ANSI_SMG:     Convertit la sequence ANSI d'une touche en un code
  88. X             SMG.
  89. X
  90. X    KBD$FLUSH_KEYBOARD:  Vide le tampon clavier.
  91. X
  92. X    KBD$KEY_PRESSED:     Indique si au moins une touche est presente dans le
  93. X             tampon.
  94. X
  95. X    KBD$OPEN_KEYBOARD:     Creation et initialisation des structures de donnees
  96. X             associees au module.
  97. X
  98. X    KBD$READ_KEYSTROKE:  Extrait la touche suivante du tampon; si ce dernier
  99. X             est vide, se met en attente d'une action au clavier.
  100. X
  101. X
  102. XDescription de l'implementation:
  103. X********************************
  104. X
  105. X    Le module repose sur l'algorithme producteur-consommateur,
  106. X    l'utilisation de primitives de VAX/VMS (System Services: $GETDVI, $QIO,
  107. X    etc), d'un sous-programme d'interruption (AST) et de la librairie
  108. X    PASCAL$PPL_ROUTINES.
  109. X
  110. X    Le producteur est un sous-programme d'interruption active par une
  111. X    action au clavier, alimentant une memoire tampon. Le consommateur est la
  112. X    fonction KBD$READ_KEYSTROKE qui preleve a chaque appel une sequence ANSI
  113. X    de la memoire tampon. Le tampon clavier est gere circulairement.
  114. X
  115. X    Lorsque le tampon est plein, l'utilisateur est prevenu par un beep
  116. X    sonore.
  117. X
  118. XUTILISATION PRATIQUE:
  119. X*********************
  120. X
  121. X    1/ Creez votre bibliotheque d'objets:
  122. X
  123. X        $ LIBRARY/CREATE/OBJECT MYLIB
  124. X
  125. X       Si vous voulez donner un autre nom a la bibliotheque, ou bien si vous
  126. X       avez deja une bibliotheque, vous devez modifiez la variable "LIB" dans
  127. X       le fichier BUILD.COM.
  128. X
  129. X    2/ Compilez et inserez le module KBD$ROUTINES dans la bibliotheque:
  130. X
  131. X        $ @BUILD
  132. X        $ @BUILD 3  (ou KP3)
  133. X
  134. X    3/ Compilez et inserez les messages d'erreurs dans la bibliotheque:
  135. X
  136. X        $ MESSAGE KBDMSG
  137. X        $ LIBRARY/REPLACE MYLIB KBDMSG
  138. X
  139. X    4/ En Pascal
  140. X
  141. X        $ PASCAL DEMO_KBD$ROUTINES
  142. X        $ LINK DEMO_KBD$ROUTINES, MYLIB/LIBRARY
  143. X        $ RUN DEMO_KBD$ROUTINES
  144. X
  145. X    5/ En C
  146. X
  147. X        $ CC DEMO_KBD$ROUTINES
  148. X        $ LINK DEMO_KBD$ROUTINES, MYLIB/LIBRARY, LINK_CC.OPT/OPTION
  149. X        $ RUN DEMO_KBD$ROUTINES
  150. X
  151. X    6/ En Ada
  152. X
  153. X        $ ACS SET LIBRARY MYLIBADA
  154. X        $ ADA KBD_
  155. X        $ ADA DEMO_KBD_ROUTINES
  156. X        $ DEFINE LNK$LIBRARY MYLIB
  157. X        $ ACS LINK DEMO_KBD_ROUTINES
  158. X        $ DEASSIGN LNK$LIBRARY
  159. END_OF_FILE
  160.   if test 3816 -ne `wc -c <'LISEZ-MOI'`; then
  161.     echo shar: \"'LISEZ-MOI'\" unpacked with wrong size!
  162.   fi
  163.   # end of 'LISEZ-MOI'
  164. fi
  165. if test -f 'demo_kbd$routines.c' -a "${1}" != "-c" ; then 
  166.   echo shar: Will not clobber existing file \"'demo_kbd$routines.c'\"
  167. else
  168.   echo shar: Extracting \"'demo_kbd$routines.c'\" \(4884 characters\)
  169.   sed "s/^X//" >'demo_kbd$routines.c' <<'END_OF_FILE'
  170. X/*
  171. X------------------ Distribution and Copyright -----------------
  172. X--
  173. X-- This software is copyright by the CENA/DGAC/FRANCE
  174. X-- All rights reserved.
  175. X--
  176. X-- No part of the material protected by this copyright notice
  177. X-- may be reproduced or utilized for commercial use in any form
  178. X-- without written permission of the copyright owner.
  179. X--
  180. X-- It may be reproduced or utilized for R&D use in Non Profit
  181. X-- Organization
  182. X--
  183. X---------------------------------------------------------------
  184. X
  185. X
  186. X------------------ Disclaimer ---------------------------------
  187. X--
  188. X-- This software and its documentation are provided "AS IS" and
  189. X-- without any expressed or implied warranties whatsoever.
  190. X-- No warranties as to performance, merchantability, or fitness
  191. X-- for a particular purpose exist.
  192. X--
  193. X-- Because of the diversity of conditions and hardware under
  194. X-- which this software may be used, no warranty of fitness for
  195. X-- a particular purpose is offered.  The user is advised to
  196. X-- test the software thoroughly before relying on it.  The user
  197. X-- must assume the entire risk and liability of using this
  198. X-- software.
  199. X--
  200. X-- In no event shall any person or organization of people be
  201. X-- held responsible for any direct, indirect, consequential
  202. X-- or inconsequential damages or lost profits.
  203. X--                                                           
  204. X-------------------END-PROLOGUE--------------------------------
  205. X*/
  206. X
  207. X
  208. X
  209. X
  210. X/*****************************************************************************
  211. X *****************************************************************************
  212. X **                                        **
  213. X **               D E M O   D E S   R O U T I N E S   K B D $               **
  214. X **                                        **
  215. X ******* Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne ********
  216. X *****************************************************************************/
  217. X
  218. X
  219. X
  220. X
  221. X/*
  222. X * Titre:       DEMO DES ROUTINES KBD$
  223. X *
  224. X * Sujet:       Single keypress under VMS.
  225. X *
  226. X * Version:       1.0-00
  227. X *
  228. X * Description:       Programme de demonstration des routines kbd$.
  229. X *
  230. X *               Ce programme de demonstration met en oeuvre la fonction
  231. X *           kbd$read_keystroke permettant d'attendre une action au
  232. X *           clavier et renvoyant la sequence ANSI correspondant a la
  233. X *           touche actionnee.
  234. X *
  235. X *               Lorsque le tampon est plein, l'utilisateur est prevenu
  236. X *                 par un beep sonore emit par le sous-programme d'IT.
  237. X *
  238. X *               Afin de pouvoir recuperer les codes emis par CTRL/C,
  239. X *                 CTRL/O, CTRL/Q, CTRL/S, CTRL/T, CTRL/X, CTRL/Y et F6, il est
  240. X *                 necessaire d'entrer la commande DCL "SET TERMINAL/PASTHRU
  241. X *                 /NOTTSYNC".
  242. X *
  243. X *                     Pour utiliser kbd$read_keystroke, vous devez appeler au
  244. X *           prealable la fonction kbd$open_keyboard et terminer par
  245. X *           kbd$close_keyboard.
  246. X *                 La routine kbd$open_keyboard permet, entre autres, de ne
  247. X *           creer la zone tampon que si l'on desire reellement utiliser
  248. X *                 kbd$read_keystroke.
  249. X *
  250. X * Langage:       C ANSI
  251. X *
  252. X * Fichier:       DEMO_KBD$ROUTINES.C
  253. X *
  254. X * Environnement:  Machine cible:          VAX
  255. X *                 Systeme d'exploitation: VAX/VMS Version 5.4-3
  256. X *                 Compilateur:            VAX C Version 3.2-044
  257. X *
  258. X * Auteur:       Martin VICENTE (DGAC/CENA/SID)
  259. X *
  260. X *           E-mail: vicente@cenaath.cena.dgac.fr
  261. X *
  262. X *           Mail:   C.E.N.A.
  263. X *               Div. Support Informatique & Developpement
  264. X *               Orly Sud 205
  265. X *               94 542 ORLY AEROGARE CEDEX, FRANCE
  266. X *
  267. X * Creation:       23/05/92
  268. X *
  269. X * Modification:   26/05/92
  270. X *
  271. X */
  272. X
  273. X
  274. X
  275. X
  276. X#include <stdio.h>
  277. X#include <lib$routines.h>
  278. X#include "kbd$routines.h"
  279. X
  280. X
  281. Xconst float  second = 1.0;
  282. X
  283. Xstatic void  perform();
  284. X
  285. X
  286. Xmain() 
  287. X{
  288. X    char                 yes;
  289. X    int                  i;
  290. X    kbd$t_ansi_sequence  key;
  291. X
  292. X
  293. X    perform(kbd$open_keyboard());
  294. X
  295. X    (void) printf("Press a key.\n");
  296. X
  297. X    do {
  298. X    (void) kbd$key_pressed(&yes);
  299. X    } while (!yes);
  300. X
  301. X    (void) printf("Five loop...\n");
  302. X
  303. X    for (i = 0; i < 5; i++) {
  304. X        (void) printf("Programme principal (loop): %d\n", i);
  305. X        (void) lib$wait(&second);
  306. X    }
  307. X
  308. X    (void) printf("Five readkey...\n");
  309. X
  310. X    for (i = 0; i < 5; i++) {
  311. X        (void) printf("Programme principal (SMG code): ");
  312. X        perform(kbd$read_keystroke(&key));
  313. X        (void) printf("%d\n", kbd$cvt_ansi_smg(&key));
  314. X    }
  315. X
  316. X    (void) printf("Five loop...\n");
  317. X
  318. X    for (i = 0; i < 5; i++) {
  319. X        (void) printf("Programme principal (loop): %d\n", i);
  320. X        (void) lib$wait(&second);
  321. X    }
  322. X
  323. X    (void) printf("Flush keyboard.\n");
  324. X
  325. X    perform(kbd$flush_keyboard());
  326. X
  327. X    (void) printf("Five loop...\n");
  328. X
  329. X    for (i = 0; i < 5; i++) {
  330. X        (void) printf("Programme principal (loop): %d\n", i);
  331. X        (void) lib$wait(&second);
  332. X    }
  333. X
  334. X    (void) printf("End\n");
  335. X
  336. X    perform(kbd$close_keyboard());
  337. X}
  338. X
  339. X
  340. Xstatic void perform(unsigned cond_value)
  341. X{
  342. X    if (!(cond_value & 1)) (void) lib$stop(cond_value);
  343. X}
  344. END_OF_FILE
  345.   if test 4884 -ne `wc -c <'demo_kbd$routines.c'`; then
  346.     echo shar: \"'demo_kbd$routines.c'\" unpacked with wrong size!
  347.   fi
  348.   # end of 'demo_kbd$routines.c'
  349. fi
  350. if test -f 'demo_kbd$routines.pas' -a "${1}" != "-c" ; then 
  351.   echo shar: Will not clobber existing file \"'demo_kbd$routines.pas'\"
  352. else
  353.   echo shar: Extracting \"'demo_kbd$routines.pas'\" \(4931 characters\)
  354.   sed "s/^X//" >'demo_kbd$routines.pas' <<'END_OF_FILE'
  355. X(*
  356. X------------------ Distribution and Copyright -----------------
  357. X--
  358. X-- This software is copyright by the CENA/DGAC/FRANCE
  359. X-- All rights reserved.
  360. X--
  361. X-- No part of the material protected by this copyright notice
  362. X-- may be reproduced or utilized for commercial use in any form
  363. X-- without written permission of the copyright owner.
  364. X--
  365. X-- It may be reproduced or utilized for R&D use in Non Profit
  366. X-- Organization
  367. X--
  368. X---------------------------------------------------------------
  369. X
  370. X
  371. X------------------ Disclaimer ---------------------------------
  372. X--
  373. X-- This software and its documentation are provided "AS IS" and
  374. X-- without any expressed or implied warranties whatsoever.
  375. X-- No warranties as to performance, merchantability, or fitness
  376. X-- for a particular purpose exist.
  377. X--
  378. X-- Because of the diversity of conditions and hardware under
  379. X-- which this software may be used, no warranty of fitness for
  380. X-- a particular purpose is offered.  The user is advised to
  381. X-- test the software thoroughly before relying on it.  The user
  382. X-- must assume the entire risk and liability of using this
  383. X-- software.
  384. X--
  385. X-- In no event shall any person or organization of people be
  386. X-- held responsible for any direct, indirect, consequential
  387. X-- or inconsequential damages or lost profits.
  388. X--                                                           
  389. X-------------------END-PROLOGUE--------------------------------
  390. X*)
  391. X
  392. X
  393. X
  394. X
  395. X(*****************************************************************************)
  396. X(*****************************************************************************)
  397. X(**                                                                         **)
  398. X(**               D E M O   D E S   R O U T I N E S   K B D $               **)
  399. X(**                                                                         **)
  400. X(******** Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne *******)
  401. X(*****************************************************************************)
  402. X
  403. X
  404. X
  405. X
  406. X(*
  407. X * Titre:       DEMO DES ROUTINES KBD$
  408. X *
  409. X * Sujet:       Programme de demonstration des routines KBD$.
  410. X *
  411. X * Version:       1.0
  412. X *
  413. X * Description:           Ce programme de demonstration met en oeuvre la fonction
  414. X *           KBD$READ_KEYSTROKE permettant d'attendre une action au
  415. X *           clavier et renvoyant la sequence ANSI correspondant a la
  416. X *           touche actionnee.
  417. X *
  418. X *               Lorsque le tampon est plein, l'utilisateur est prevenu
  419. X *                 par un beep sonore emit par le sous-programme d'IT.
  420. X *
  421. X *               Afin de pouvoir recuperer les codes emis par CTRL/C,
  422. X *                 CTRL/O, CTRL/Q, CTRL/S, CTRL/T, CTRL/X, CTRL/Y et F6, il est
  423. X *                 necessaire d'entrer la commande DCL "SET TERMINAL/PASTHRU
  424. X *                 /NOTTSYNC".
  425. X *
  426. X *                     Pour utiliser KBD$READ_KEYSTROKE, vous devez appeler au
  427. X *           prealable la fonction KBD$OPEN_KEYBOARD et terminer par
  428. X *           KBD$CLOSE_KEYBOARD.
  429. X *                 La routine KBD$OPEN_KEYBOARD permet, entre autres, de ne
  430. X *           creer la zone tampon que si l'on desire reellement utiliser
  431. X *                 KBD$READ_KEYSTROKE.
  432. X *
  433. X * Langage:       PASCAL QUASI STANDARD
  434. X *
  435. X * Fichier:       DEMO_PASCAL$KBD_ROUTINES.PAS
  436. X *                       
  437. X * Environnement:  Machine cible:          VAX
  438. X *           Systeme d'exploitation: VAX/VMS Version 5.4-3
  439. X *           Compilateur:            VAX Pascal Version 4.3
  440. X *
  441. X * Auteur:       Martin VICENTE (DGAC/CENA/SID)
  442. X *
  443. X *           E-mail: vicente@cenaath.cena.dgac.fr
  444. X *
  445. X *           Mail:   C.E.N.A.
  446. X *               Div. Support Informatique & Developpement
  447. X *               Orly Sud 205
  448. X *               94 542 ORLY AEROGARE CEDEX, FRANCE
  449. X *
  450. X * Creation:       19/05/92
  451. X *
  452. X * Modification:   26/05/92
  453. X *
  454. X *)
  455. X
  456. X
  457. X
  458. X
  459. X[INHERIT( 'sys$library:pascal$lib_routines',
  460. X      'vic$library:pascal$kbd_routines'  )]
  461. X
  462. X
  463. XPROGRAM  demo_kbd$routines (output);
  464. X
  465. X
  466. XPROCEDURE  perform (cond_value : UNSIGNED);
  467. X
  468. XBEGIN
  469. X
  470. X   IF NOT Odd (cond_value) THEN LIB$STOP (cond_value)
  471. X
  472. XEND (* perform *);
  473. X
  474. X
  475. XVAR
  476. X
  477. X   yes : BOOLEAN;
  478. X   i   : INTEGER;
  479. X   key : KBD$T_ANSI_SEQUENCE;
  480. X
  481. X
  482. XBEGIN
  483. X
  484. X   perform (KBD$OPEN_KEYBOARD);
  485. X
  486. X   Writeln ('Press a key.');
  487. X
  488. X   REPEAT
  489. X      perform (KBD$KEY_PRESSED (yes))
  490. X   UNTIL yes;
  491. X
  492. X   Writeln ('Five loop...');
  493. X
  494. X   FOR i := 1 TO 5 DO BEGIN
  495. X      Writeln ('Programme principal (loop): ', i:2);
  496. X      perform (LIB$WAIT (1))
  497. X   END {FOR};
  498. X
  499. X   Writeln ('Five readkey...');
  500. X
  501. X   FOR i := 1 TO 5 DO BEGIN
  502. X      Write ('Programme principal (SMG code): ');
  503. X      perform (KBD$READ_KEYSTROKE (key));
  504. X      Writeln (KBD$CVT_ANSI_SMG (key):5)
  505. X   END {FOR};
  506. X
  507. X   Writeln ('Five loop...');
  508. X
  509. X   FOR i := 1 TO 5 DO BEGIN
  510. X      Writeln ('Programme principal (loop): ', i:2);
  511. X      perform (LIB$WAIT (1))
  512. X   END {FOR};
  513. X
  514. X   Writeln ('Flush keyboard.');
  515. X
  516. X   perform (KBD$FLUSH_KEYBOARD);
  517. X
  518. X   Writeln ('Five loop...');
  519. X
  520. X   FOR i := 1 TO 5 DO BEGIN
  521. X      Writeln ('Programme principal (loop): ', i:2);
  522. X      perform (LIB$WAIT (1))
  523. X   END {FOR};
  524. X
  525. X   Writeln ('End');
  526. X
  527. X   perform (KBD$CLOSE_KEYBOARD)
  528. X
  529. XEND (* DEMO PASCAL$KBD_ROUTINES *).
  530. END_OF_FILE
  531.   if test 4931 -ne `wc -c <'demo_kbd$routines.pas'`; then
  532.     echo shar: \"'demo_kbd$routines.pas'\" unpacked with wrong size!
  533.   fi
  534.   # end of 'demo_kbd$routines.pas'
  535. fi
  536. if test -f 'demo_kbd_routines.ada' -a "${1}" != "-c" ; then 
  537.   echo shar: Will not clobber existing file \"'demo_kbd_routines.ada'\"
  538. else
  539.   echo shar: Extracting \"'demo_kbd_routines.ada'\" \(5771 characters\)
  540.   sed "s/^X//" >'demo_kbd_routines.ada' <<'END_OF_FILE'
  541. X
  542. X------------------ Distribution and Copyright -----------------
  543. X--
  544. X-- This software is copyright by the CENA/DGAC/FRANCE
  545. X-- All rights reserved.
  546. X--
  547. X-- No part of the material protected by this copyright notice
  548. X-- may be reproduced or utilized for commercial use in any form
  549. X-- without written permission of the copyright owner.
  550. X--
  551. X-- It may be reproduced or utilized for R&D use in Non Profit
  552. X-- Organization
  553. X--
  554. X---------------------------------------------------------------
  555. X
  556. X
  557. X------------------ Disclaimer ---------------------------------
  558. X--
  559. X-- This software and its documentation are provided "AS IS" and
  560. X-- without any expressed or implied warranties whatsoever.
  561. X-- No warranties as to performance, merchantability, or fitness
  562. X-- for a particular purpose exist.
  563. X--
  564. X-- Because of the diversity of conditions and hardware under
  565. X-- which this software may be used, no warranty of fitness for
  566. X-- a particular purpose is offered.  The user is advised to
  567. X-- test the software thoroughly before relying on it.  The user
  568. X-- must assume the entire risk and liability of using this
  569. X-- software.
  570. X--
  571. X-- In no event shall any person or organization of people be
  572. X-- held responsible for any direct, indirect, consequential
  573. X-- or inconsequential damages or lost profits.
  574. X--                                                           
  575. X-------------------END-PROLOGUE--------------------------------
  576. X
  577. X
  578. X
  579. X
  580. X--*****************************************************************************
  581. X--*****************************************************************************
  582. X--**                                                                         **
  583. X--**               D E M O   D E S   R O U T I N E S   K B D $               **
  584. X--**                                                                         **
  585. X--******** Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne *******
  586. X--*****************************************************************************
  587. X
  588. X
  589. X
  590. X
  591. X-- ++
  592. X--
  593. X-- Titre:       DEMO DES ROUTINES KBD$
  594. X--
  595. X-- Sujet:       Programme de demonstration des routines KBD$.
  596. X--
  597. X-- Version:       1.0
  598. X--
  599. X-- Description:           Ce programme de demonstration met en oeuvre la fonction
  600. X--           KBD$READ_KEYSTROKE permettant d'attendre une action au
  601. X--           clavier et renvoyant la sequence ANSI correspondant a la
  602. X--           touche actionnee.
  603. X--
  604. X--               Lorsque le tampon est plein, l'utilisateur est prevenu
  605. X--                 par un beep sonore emit par le sous-programme d'IT.
  606. X--
  607. X--               Afin de pouvoir recuperer les codes emis par CTRL/C,
  608. X--                 CTRL/O, CTRL/Q, CTRL/S, CTRL/T, CTRL/X, CTRL/Y et F6, il est
  609. X--                 necessaire d'entrer la commande DCL "SET TERMINAL/PASTHRU
  610. X--                 /NOTTSYNC".
  611. X--
  612. X--                     Pour utiliser KBD$READ_KEYSTROKE, vous devez appeler au
  613. X--           prealable la fonction KBD$OPEN_KEYBOARD et terminer par
  614. X--           KBD$CLOSE_KEYBOARD.
  615. X--                 La routine KBD$OPEN_KEYBOARD permet, entre autres, de ne
  616. X--           creer la zone tampon que si l'on desire reellement utiliser
  617. X--                 KBD$READ_KEYSTROKE.
  618. X--
  619. X-- Langage:       ADA
  620. X--
  621. X-- Fichier:       DEMO_KBD_ROUTINES.ADA
  622. X--                       
  623. X-- Environnement:  Machine cible:          VAX
  624. X--           Systeme d'exploitation: VAX/VMS Version 5.4
  625. X--           Compilateur:            VAX Ada Version 2.1-28
  626. X--
  627. X-- Auteur:       Martin VICENTE (DGAC/CENA/SID)
  628. X--
  629. X--           E-mail: vicente@cenaath.cena.dgac.fr
  630. X--
  631. X--           Mail:   C.E.N.A.
  632. X--               Div. Support Informatique & Developpement
  633. X--               Orly Sud 205
  634. X--               94 542 ORLY AEROGARE CEDEX, FRANCE
  635. X--
  636. X-- Creation:       25/05/92
  637. X--
  638. X-- Modification:   25/05/92
  639. X--
  640. X-- --
  641. X
  642. X
  643. X
  644. X
  645. Xwith CONDITION_HANDLING;
  646. Xwith SYSTEM;
  647. Xwith LIB;
  648. Xwith KBD;
  649. Xwith TEXT_IO;
  650. X
  651. Xuse CONDITION_HANDLING;
  652. Xuse SYSTEM;
  653. Xuse KBD;
  654. Xuse TEXT_IO;
  655. X
  656. X
  657. Xprocedure DEMO_KBD_ROUTINES is
  658. X
  659. X
  660. X    COND_VALUE : COND_VALUE_TYPE;
  661. X    YES        : BOOLEAN;
  662. X    I          : INTEGER;
  663. X    KEY        : T_ANSI_SEQUENCE;
  664. X    CODE       : UNSIGNED_WORD;
  665. X
  666. X
  667. X    procedure CHECK (COND_VALUE : in COND_VALUE_TYPE) is
  668. X    begin
  669. X        if not SUCCESS (COND_VALUE) then
  670. X        STOP (COND_VALUE);
  671. X        end if;
  672. X    end CHECK;
  673. X
  674. X
  675. X    package LOCAL_INTEGER_IO is new TEXT_IO.INTEGER_IO(INTEGER);
  676. X    use LOCAL_INTEGER_IO;
  677. X
  678. X
  679. Xbegin
  680. X
  681. X    OPEN_KEYBOARD (COND_VALUE => COND_VALUE);
  682. X    CHECK (COND_VALUE => COND_VALUE);
  683. X
  684. X    PUT_LINE ("Press a key.");
  685. X
  686. X    loop
  687. X        KEY_PRESSED (COND_VALUE => COND_VALUE, YES => YES);
  688. X        CHECK (COND_VALUE => COND_VALUE);
  689. X    exit when YES;
  690. X    end loop;
  691. X
  692. X    PUT_LINE ("Five loop...");
  693. X
  694. X    for I in 1..5 loop
  695. X        PUT ("Programme principal (loop): ");
  696. X    PUT (I);
  697. X    NEW_LINE;
  698. X        LIB.WAIT (STATUS => COND_VALUE, SECONDS => 1.0);
  699. X        CHECK (COND_VALUE => COND_VALUE);
  700. X    end loop;
  701. X
  702. X    PUT_LINE ("Five readkey...");
  703. X
  704. X    for I in 1..5 loop
  705. X        PUT ("Programme principal (SMG code): ");
  706. X        READ_KEYSTROKE (COND_VALUE => COND_VALUE, KEY => KEY);
  707. X        CHECK (COND_VALUE => COND_VALUE);
  708. X        CVT_ANSI_SMG (SMG_CODE => CODE, SEQUENCE => KEY);
  709. X        PUT (natural (CODE));
  710. X    NEW_LINE;
  711. X    end loop;
  712. X
  713. X    PUT_LINE ("Five loop...");
  714. X
  715. X    for I in 1..5 loop
  716. X        PUT ("Programme principal (loop): ");
  717. X    PUT (I);
  718. X    NEW_LINE;
  719. X    delay 1.0;
  720. X--      LIB.WAIT (STATUS => COND_VALUE, SECONDS => 1.0);
  721. X--      CHECK (COND_VALUE => COND_VALUE);
  722. X    end loop;
  723. X
  724. X    PUT_LINE ("Flush keyboard.");
  725. X
  726. X    FLUSH_KEYBOARD (COND_VALUE => COND_VALUE);
  727. X    CHECK (COND_VALUE => COND_VALUE);
  728. X
  729. X    PUT_LINE ("Five loop...");
  730. X
  731. X    for I in 1..5 loop
  732. X        PUT ("Programme principal (loop): ");
  733. X    PUT (I);
  734. X    NEW_LINE;
  735. X    delay 1.0;
  736. X--      LIB.WAIT (STATUS => COND_VALUE, SECONDS => 1.0);
  737. X--      CHECK (COND_VALUE => COND_VALUE);
  738. X    end loop;
  739. X
  740. X    PUT_LINE ("End");
  741. X
  742. X    CLOSE_KEYBOARD (COND_VALUE => COND_VALUE);
  743. X    CHECK (COND_VALUE => COND_VALUE);
  744. X
  745. Xend DEMO_KBD_ROUTINES;
  746. END_OF_FILE
  747.   if test 5771 -ne `wc -c <'demo_kbd_routines.ada'`; then
  748.     echo shar: \"'demo_kbd_routines.ada'\" unpacked with wrong size!
  749.   fi
  750.   # end of 'demo_kbd_routines.ada'
  751. fi
  752. if test -f 'kbd$routines.h' -a "${1}" != "-c" ; then 
  753.   echo shar: Will not clobber existing file \"'kbd$routines.h'\"
  754. else
  755.   echo shar: Extracting \"'kbd$routines.h'\" \(6249 characters\)
  756.   sed "s/^X//" >'kbd$routines.h' <<'END_OF_FILE'
  757. X#ifndef __KBD$ROUTINES_LOADED
  758. X#define __KBD$ROUTINES_LOADED  1
  759. X
  760. X
  761. X/*
  762. X------------------ Distribution and Copyright -----------------
  763. X--
  764. X-- This software is copyright by the CENA/DGAC/FRANCE
  765. X-- All rights reserved.
  766. X--
  767. X-- No part of the material protected by this copyright notice
  768. X-- may be reproduced or utilized for commercial use in any form
  769. X-- without written permission of the copyright owner.
  770. X--
  771. X-- It may be reproduced or utilized for R&D use in Non Profit
  772. X-- Organization
  773. X--
  774. X---------------------------------------------------------------
  775. X
  776. X
  777. X------------------ Disclaimer ---------------------------------
  778. X--
  779. X-- This software and its documentation are provided "AS IS" and
  780. X-- without any expressed or implied warranties whatsoever.
  781. X-- No warranties as to performance, merchantability, or fitness
  782. X-- for a particular purpose exist.
  783. X--
  784. X-- Because of the diversity of conditions and hardware under
  785. X-- which this software may be used, no warranty of fitness for
  786. X-- a particular purpose is offered.  The user is advised to
  787. X-- test the software thoroughly before relying on it.  The user
  788. X-- must assume the entire risk and liability of using this
  789. X-- software.
  790. X--
  791. X-- In no event shall any person or organization of people be
  792. X-- held responsible for any direct, indirect, consequential
  793. X-- or inconsequential damages or lost profits.
  794. X--                                                           
  795. X-------------------END-PROLOGUE--------------------------------
  796. X*/
  797. X
  798. X
  799. X
  800. X
  801. X/*****************************************************************************
  802. X *****************************************************************************
  803. X **                                        **
  804. X **               D E M O   D E S   R O U T I N E S   K B D $               **
  805. X **                                        **
  806. X ******* Copyright (C) 1992 Centre d'Etudes de la Navigation Aerienne ********
  807. X *****************************************************************************/
  808. X
  809. X
  810. X
  811. X
  812. X/*
  813. X * Titre:       HEADER KBD$ROUTINES
  814. X *
  815. X * Sujet:       Fichier d'en-tete pour le module KBD$ROUTINES.
  816. X *
  817. X * Version:       1.0
  818. X *
  819. X * Description:           Ce module contient la declaration de la fonction
  820. X *                 kbd$read_keystroke permettant d'attendre une action au
  821. X *           clavier et renvoyant la sequence ANSI correspondant a la
  822. X *           touche actionnee.
  823. X *
  824. X *                     Pour utiliser kbd$read_keystroke, il necessaire
  825. X *           d'appeler au prealable la fonction kbd$open_keyboard et de
  826. X *           terminer par kbd$close_keyboard.
  827. X *                 La routine kbd$open_keyboard permet, entre autres, de ne
  828. X *           creer le tampon clavier que si l'on desire reellement
  829. X *           utiliser kbd$read_keystroke.
  830. X *
  831. X *                     Lorsque le tampon est plein, l'utilisateur est prevenu
  832. X *                 par un beep sonore.
  833. X *
  834. X *               La fonction kbd$flush_keyboard permet de vider le
  835. X *           tampon clavier.
  836. X *
  837. X *                    Afin de pouvoir recuperer les codes emis par CTRL/C,
  838. X *                 CTRL/O, CTRL/Q, CTRL/S, CTRL/T, CTRL/X, CTRL/Y et F6, il est
  839. X *                 necessaire d'entrer la commande DCL "SET TERMINAL/PASTHRU
  840. X *                 /NOTTSYNC".
  841. X *
  842. X * Langage:       C ANSI
  843. X *
  844. X * Fichier:       KBD$ROUTINES.H
  845. X *
  846. X * Environnement:  Machine cible:          VAX
  847. X *                 Systeme d'exploitation: VAX/VMS Version 5.4-3
  848. X *                 Compilateur:            VAX C Version 3.2-044
  849. X *
  850. X * Auteur:       Martin VICENTE (DGAC/CENA/SID)
  851. X *
  852. X *           E-mail: vicente@cenaath.cena.dgac.fr
  853. X *
  854. X *           Mail:   C.E.N.A.
  855. X *               Div. Support Informatique & Developpement
  856. X *               Orly Sud 205
  857. X *               94 542 ORLY AEROGARE CEDEX, FRANCE
  858. X *
  859. X * Creation:       23/05/92
  860. X *
  861. X * Modification:   26/05/92
  862. X *
  863. X */
  864. X
  865. X
  866. X
  867. X
  868. X/*****************************************************************************
  869. X *    TYPE DEFINITIONS                             *
  870. X *****************************************************************************/
  871. X
  872. X
  873. Xtypedef unsigned char  kbd$t_escape_overflow_buffer[4];
  874. X
  875. Xtypedef struct {
  876. X    unsigned char                 ascii;
  877. X    kbd$t_escape_overflow_buffer  escOverBuffer;
  878. X} kbd$t_ansi_sequence;
  879. X
  880. X
  881. X
  882. X
  883. X/*****************************************************************************
  884. X *****************************************************************************
  885. X **                        KBD$ FUNCTION DECLARATION                        **
  886. X *****************************************************************************
  887. X *****************************************************************************/
  888. X
  889. X
  890. X
  891. X
  892. X/*
  893. X * kbd$close_keyboard
  894. X *
  895. X *   Libere la memoire des structures de donnees associees a ce module.
  896. X */
  897. X
  898. Xunsigned kbd$close_keyboard();
  899. X
  900. X
  901. X/*
  902. X * kbd$cvt_ansi_smg
  903. X *
  904. X *   Convertit la sequence ANSI d'une touche en un code SMG.
  905. X *
  906. X *   Liste des codes pouvant etre renvoyes (ils sont definis dans
  907. X *   SYS$LIBRARY:SMGDEF.H):
  908. X *
  909. X *    ascii (0 - 255)        SMG$K_TRM_UP        SMG$K_TRM_DOWN
  910. X *    SMG$K_TRM_RIGHT        SMG$K_TRM_LEFT        SMG$K_TRM_ENTER
  911. X *    SMG$K_TRM_PF1        SMG$K_TRM_PF2        SMG$K_TRM_PF3
  912. X *    SMG$K_TRM_PF4        SMG$K_TRM_COMMA        SMG$K_TRM_MINUS
  913. X *    SMG$K_TRM_PERIOD    SMG$K_TRM_KP0        SMG$K_TRM_KP1
  914. X *    SMG$K_TRM_KP2        SMG$K_TRM_KP3        SMG$K_TRM_KP4
  915. X *    SMG$K_TRM_KP5        SMG$K_TRM_KP6        SMG$K_TRM_KP7
  916. X *    SMG$K_TRM_KP8        SMG$K_TRM_KP9        SMG$K_TRM_FIND
  917. X *    SMG$K_TRM_INSERT_HERE    SMG$K_TRM_REMOVE    SMG$K_TRM_SELECT
  918. X *    SMG$K_TRM_PREV_SCREEN    SMG$K_TRM_NEXT_SCREEN    SMG$K_TRM_F6
  919. X *    SMG$K_TRM_F7        SMG$K_TRM_F8        SMG$K_TRM_F9
  920. X *    SMG$K_TRM_F10        SMG$K_TRM_F11        SMG$K_TRM_F12
  921. X *    SMG$K_TRM_F13        SMG$K_TRM_F14        SMG$K_TRM_HELP
  922. X *    SMG$K_TRM_DO        SMG$K_TRM_F17        SMG$K_TRM_F18
  923. X *    SMG$K_TRM_F19        SMG$K_TRM_F20        SMG$K_TRM_UP
  924. X *    SMG$K_TRM_DOWN        SMG$K_TRM_RIGHT        SMG$K_TRM_LEFT
  925. X *    SMG$K_TRM_UNKNOWN
  926. X */
  927. X
  928. Xunsigned kbd$cvt_ansi_smg();
  929. X
  930. X
  931. X/*
  932. X * kbd$flush_keyboard
  933. X *
  934. X *   Vide le tampon clavier.
  935. X */
  936. X
  937. Xunsigned kbd$flush_keyboard();
  938. X
  939. X
  940. X/*
  941. X * kbd$key_pressed
  942. X *
  943. X *   Indique si au moins une touche est presente dans le tampon.
  944. X */
  945. X
  946. Xunsigned kbd$key_pressed();
  947. X
  948. X
  949. X/*
  950. X * kbd$open_keyboard
  951. X *
  952. X *   Creation et initialisation des structures de donnees associees au module.
  953. X */
  954. X
  955. Xunsigned kbd$open_keyboard();
  956. X
  957. X
  958. X/*
  959. X * kbd$read_keystroke
  960. X *
  961. X *   Extrait la touche suivante du tampon; si ce dernier est vide, se met en
  962. X *   attente d'une action au clavier.
  963. X */
  964. X
  965. Xunsigned kbd$read_keystroke();
  966. X
  967. X
  968. X
  969. X
  970. X/*****************************************************************************/
  971. X
  972. X#endif  /* __KBD$ROUTINES_LOADED */
  973. END_OF_FILE
  974.   if test 6249 -ne `wc -c <'kbd$routines.h'`; then
  975.     echo shar: \"'kbd$routines.h'\" unpacked with wrong size!
  976.   fi
  977.   # end of 'kbd$routines.h'
  978. fi
  979. if test -f 'link_cc.opt' -a "${1}" != "-c" ; then 
  980.   echo shar: Will not clobber existing file \"'link_cc.opt'\"
  981. else
  982.   echo shar: Extracting \"'link_cc.opt'\" \(235 characters\)
  983.   sed "s/^X//" >'link_cc.opt' <<'END_OF_FILE'
  984. X! Fichier d'options pour le linker VAX/VMS
  985. X! A utiliser pour du code genere par le compilateur CC natif
  986. X!
  987. XSYS$LIBRARY:VAXCRTLG.OLB/LIBRARY                ! C Library
  988. XSYS$LIBRARY:VAXCRTL.EXE/SHAREABLE               ! C Run Time Library
  989. END_OF_FILE
  990.   if test 235 -ne `wc -c <'link_cc.opt'`; then
  991.     echo shar: \"'link_cc.opt'\" unpacked with wrong size!
  992.   fi
  993.   # end of 'link_cc.opt'
  994. fi
  995. echo shar: End of archive 2 \(of 2\).
  996. cp /dev/null ark2isdone
  997. MISSING=""
  998. for I in 1 2 ; do
  999.     if test ! -f ark${I}isdone ; then
  1000.     MISSING="${MISSING} ${I}"
  1001.     fi
  1002. done
  1003. if test "${MISSING}" = "" ; then
  1004.     echo You have unpacked both archives.
  1005.     rm -f ark[1-9]isdone
  1006. else
  1007.     echo You still must unpack the following archives:
  1008.     echo "        " ${MISSING}
  1009. fi
  1010. exit 0
  1011. exit 0 # Just in case...
  1012.