Differenze tra le versioni di "Conoscere il file-devide pts associato ad un Terminale o console con la funzione esterna ttyname()"
Da Gambas-it.org - Wikipedia.
(Creata pagina con "La funzione esterna ''ttyname( )'', dichiarata nel file header "''/usr/include/unistd.h''", consente di conoscere il nome del file-device ''pts'' associato ad un Terminale o a...") |
|||
Riga 7: | Riga 7: | ||
Mostriamo un semplice esempio: | Mostriamo un semplice esempio: | ||
Library "libc:6" | Library "libc:6" | ||
+ | |||
+ | Private Enum STDIN_FILENO = 0, STDOUT_FILENO, STDERR_FILENO | ||
<FONT Color=gray>' ''char * ttyname (int filedes)'' | <FONT Color=gray>' ''char * ttyname (int filedes)'' | ||
Riga 17: | Riga 19: | ||
Dim s As String | Dim s As String | ||
− | s = ttyname( | + | s = ttyname(STDOUT_FILENO) |
Print "Il file pts associato al terminale/console è: "; s | Print "Il file pts associato al terminale/console è: "; s |
Versione delle 17:34, 17 lug 2016
La funzione esterna ttyname( ), dichiarata nel file header "/usr/include/unistd.h", consente di conoscere il nome del file-device pts associato ad un Terminale o alla console utilizzati dall'applicazione Gambas.
E' necessario richiamare in Gambas la libreria dinamica considivisa: "libc.so.6"
Mostriamo un semplice esempio:
Library "libc:6" Private Enum STDIN_FILENO = 0, STDOUT_FILENO, STDERR_FILENO ' char * ttyname (int filedes) ' Return the pathname of the terminal FD is open on, or NULL on errors. Private Extern ttyname(filedes As Integer) As String Public Sub Main() Dim s As String s = ttyname(STDOUT_FILENO) Print "Il file pts associato al terminale/console è: "; s End
Riferimenti
- http://man7.org/linux/man-pages/man3/ttyname.3.html
- https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_node/libc_345.html#SEC354
- https://en.wikipedia.org/wiki/Device_file
- https://www.ibm.com/support/knowledgecenter/SSLTBW_2.1.0/com.ibm.zos.v2r1.bpxbd00/rttty.htm
- http://pubs.opengroup.org/onlinepubs/009695399/functions/ttyname.html