LCOV - code coverage report
Current view: top level - Modules/clinic - termios.c.h (source / functions) Hit Total Coverage
Test: CPython 3.12 LCOV report [commit 5e6661bce9] Lines: 0 80 0.0 %
Date: 2023-03-20 08:15:36 Functions: 0 8 0.0 %
Branches: 0 62 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*[clinic input]
       2                 :            : preserve
       3                 :            : [clinic start generated code]*/
       4                 :            : 
       5                 :            : #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
       6                 :            : #  include "pycore_gc.h"            // PyGC_Head
       7                 :            : #  include "pycore_runtime.h"       // _Py_ID()
       8                 :            : #endif
       9                 :            : 
      10                 :            : 
      11                 :            : PyDoc_STRVAR(termios_tcgetattr__doc__,
      12                 :            : "tcgetattr($module, fd, /)\n"
      13                 :            : "--\n"
      14                 :            : "\n"
      15                 :            : "Get the tty attributes for file descriptor fd.\n"
      16                 :            : "\n"
      17                 :            : "Returns a list [iflag, oflag, cflag, lflag, ispeed, ospeed, cc]\n"
      18                 :            : "where cc is a list of the tty special characters (each a string of\n"
      19                 :            : "length 1, except the items with indices VMIN and VTIME, which are\n"
      20                 :            : "integers when these fields are defined).  The interpretation of the\n"
      21                 :            : "flags and the speeds as well as the indexing in the cc array must be\n"
      22                 :            : "done using the symbolic constants defined in this module.");
      23                 :            : 
      24                 :            : #define TERMIOS_TCGETATTR_METHODDEF    \
      25                 :            :     {"tcgetattr", (PyCFunction)termios_tcgetattr, METH_O, termios_tcgetattr__doc__},
      26                 :            : 
      27                 :            : static PyObject *
      28                 :            : termios_tcgetattr_impl(PyObject *module, int fd);
      29                 :            : 
      30                 :            : static PyObject *
      31                 :          0 : termios_tcgetattr(PyObject *module, PyObject *arg)
      32                 :            : {
      33                 :          0 :     PyObject *return_value = NULL;
      34                 :            :     int fd;
      35                 :            : 
      36         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(arg, &fd)) {
      37                 :          0 :         goto exit;
      38                 :            :     }
      39                 :          0 :     return_value = termios_tcgetattr_impl(module, fd);
      40                 :            : 
      41                 :          0 : exit:
      42                 :          0 :     return return_value;
      43                 :            : }
      44                 :            : 
      45                 :            : PyDoc_STRVAR(termios_tcsetattr__doc__,
      46                 :            : "tcsetattr($module, fd, when, attributes, /)\n"
      47                 :            : "--\n"
      48                 :            : "\n"
      49                 :            : "Set the tty attributes for file descriptor fd.\n"
      50                 :            : "\n"
      51                 :            : "The attributes to be set are taken from the attributes argument, which\n"
      52                 :            : "is a list like the one returned by tcgetattr(). The when argument\n"
      53                 :            : "determines when the attributes are changed: termios.TCSANOW to\n"
      54                 :            : "change immediately, termios.TCSADRAIN to change after transmitting all\n"
      55                 :            : "queued output, or termios.TCSAFLUSH to change after transmitting all\n"
      56                 :            : "queued output and discarding all queued input.");
      57                 :            : 
      58                 :            : #define TERMIOS_TCSETATTR_METHODDEF    \
      59                 :            :     {"tcsetattr", _PyCFunction_CAST(termios_tcsetattr), METH_FASTCALL, termios_tcsetattr__doc__},
      60                 :            : 
      61                 :            : static PyObject *
      62                 :            : termios_tcsetattr_impl(PyObject *module, int fd, int when, PyObject *term);
      63                 :            : 
      64                 :            : static PyObject *
      65                 :          0 : termios_tcsetattr(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
      66                 :            : {
      67                 :          0 :     PyObject *return_value = NULL;
      68                 :            :     int fd;
      69                 :            :     int when;
      70                 :            :     PyObject *term;
      71                 :            : 
      72   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tcsetattr", nargs, 3, 3)) {
                   #  # ]
      73                 :          0 :         goto exit;
      74                 :            :     }
      75         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
      76                 :          0 :         goto exit;
      77                 :            :     }
      78                 :          0 :     when = _PyLong_AsInt(args[1]);
      79   [ #  #  #  # ]:          0 :     if (when == -1 && PyErr_Occurred()) {
      80                 :          0 :         goto exit;
      81                 :            :     }
      82                 :          0 :     term = args[2];
      83                 :          0 :     return_value = termios_tcsetattr_impl(module, fd, when, term);
      84                 :            : 
      85                 :          0 : exit:
      86                 :          0 :     return return_value;
      87                 :            : }
      88                 :            : 
      89                 :            : PyDoc_STRVAR(termios_tcsendbreak__doc__,
      90                 :            : "tcsendbreak($module, fd, duration, /)\n"
      91                 :            : "--\n"
      92                 :            : "\n"
      93                 :            : "Send a break on file descriptor fd.\n"
      94                 :            : "\n"
      95                 :            : "A zero duration sends a break for 0.25-0.5 seconds; a nonzero duration\n"
      96                 :            : "has a system dependent meaning.");
      97                 :            : 
      98                 :            : #define TERMIOS_TCSENDBREAK_METHODDEF    \
      99                 :            :     {"tcsendbreak", _PyCFunction_CAST(termios_tcsendbreak), METH_FASTCALL, termios_tcsendbreak__doc__},
     100                 :            : 
     101                 :            : static PyObject *
     102                 :            : termios_tcsendbreak_impl(PyObject *module, int fd, int duration);
     103                 :            : 
     104                 :            : static PyObject *
     105                 :          0 : termios_tcsendbreak(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     106                 :            : {
     107                 :          0 :     PyObject *return_value = NULL;
     108                 :            :     int fd;
     109                 :            :     int duration;
     110                 :            : 
     111   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tcsendbreak", nargs, 2, 2)) {
                   #  # ]
     112                 :          0 :         goto exit;
     113                 :            :     }
     114         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
     115                 :          0 :         goto exit;
     116                 :            :     }
     117                 :          0 :     duration = _PyLong_AsInt(args[1]);
     118   [ #  #  #  # ]:          0 :     if (duration == -1 && PyErr_Occurred()) {
     119                 :          0 :         goto exit;
     120                 :            :     }
     121                 :          0 :     return_value = termios_tcsendbreak_impl(module, fd, duration);
     122                 :            : 
     123                 :          0 : exit:
     124                 :          0 :     return return_value;
     125                 :            : }
     126                 :            : 
     127                 :            : PyDoc_STRVAR(termios_tcdrain__doc__,
     128                 :            : "tcdrain($module, fd, /)\n"
     129                 :            : "--\n"
     130                 :            : "\n"
     131                 :            : "Wait until all output written to file descriptor fd has been transmitted.");
     132                 :            : 
     133                 :            : #define TERMIOS_TCDRAIN_METHODDEF    \
     134                 :            :     {"tcdrain", (PyCFunction)termios_tcdrain, METH_O, termios_tcdrain__doc__},
     135                 :            : 
     136                 :            : static PyObject *
     137                 :            : termios_tcdrain_impl(PyObject *module, int fd);
     138                 :            : 
     139                 :            : static PyObject *
     140                 :          0 : termios_tcdrain(PyObject *module, PyObject *arg)
     141                 :            : {
     142                 :          0 :     PyObject *return_value = NULL;
     143                 :            :     int fd;
     144                 :            : 
     145         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(arg, &fd)) {
     146                 :          0 :         goto exit;
     147                 :            :     }
     148                 :          0 :     return_value = termios_tcdrain_impl(module, fd);
     149                 :            : 
     150                 :          0 : exit:
     151                 :          0 :     return return_value;
     152                 :            : }
     153                 :            : 
     154                 :            : PyDoc_STRVAR(termios_tcflush__doc__,
     155                 :            : "tcflush($module, fd, queue, /)\n"
     156                 :            : "--\n"
     157                 :            : "\n"
     158                 :            : "Discard queued data on file descriptor fd.\n"
     159                 :            : "\n"
     160                 :            : "The queue selector specifies which queue: termios.TCIFLUSH for the input\n"
     161                 :            : "queue, termios.TCOFLUSH for the output queue, or termios.TCIOFLUSH for\n"
     162                 :            : "both queues.");
     163                 :            : 
     164                 :            : #define TERMIOS_TCFLUSH_METHODDEF    \
     165                 :            :     {"tcflush", _PyCFunction_CAST(termios_tcflush), METH_FASTCALL, termios_tcflush__doc__},
     166                 :            : 
     167                 :            : static PyObject *
     168                 :            : termios_tcflush_impl(PyObject *module, int fd, int queue);
     169                 :            : 
     170                 :            : static PyObject *
     171                 :          0 : termios_tcflush(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     172                 :            : {
     173                 :          0 :     PyObject *return_value = NULL;
     174                 :            :     int fd;
     175                 :            :     int queue;
     176                 :            : 
     177   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tcflush", nargs, 2, 2)) {
                   #  # ]
     178                 :          0 :         goto exit;
     179                 :            :     }
     180         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
     181                 :          0 :         goto exit;
     182                 :            :     }
     183                 :          0 :     queue = _PyLong_AsInt(args[1]);
     184   [ #  #  #  # ]:          0 :     if (queue == -1 && PyErr_Occurred()) {
     185                 :          0 :         goto exit;
     186                 :            :     }
     187                 :          0 :     return_value = termios_tcflush_impl(module, fd, queue);
     188                 :            : 
     189                 :          0 : exit:
     190                 :          0 :     return return_value;
     191                 :            : }
     192                 :            : 
     193                 :            : PyDoc_STRVAR(termios_tcflow__doc__,
     194                 :            : "tcflow($module, fd, action, /)\n"
     195                 :            : "--\n"
     196                 :            : "\n"
     197                 :            : "Suspend or resume input or output on file descriptor fd.\n"
     198                 :            : "\n"
     199                 :            : "The action argument can be termios.TCOOFF to suspend output,\n"
     200                 :            : "termios.TCOON to restart output, termios.TCIOFF to suspend input,\n"
     201                 :            : "or termios.TCION to restart input.");
     202                 :            : 
     203                 :            : #define TERMIOS_TCFLOW_METHODDEF    \
     204                 :            :     {"tcflow", _PyCFunction_CAST(termios_tcflow), METH_FASTCALL, termios_tcflow__doc__},
     205                 :            : 
     206                 :            : static PyObject *
     207                 :            : termios_tcflow_impl(PyObject *module, int fd, int action);
     208                 :            : 
     209                 :            : static PyObject *
     210                 :          0 : termios_tcflow(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     211                 :            : {
     212                 :          0 :     PyObject *return_value = NULL;
     213                 :            :     int fd;
     214                 :            :     int action;
     215                 :            : 
     216   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tcflow", nargs, 2, 2)) {
                   #  # ]
     217                 :          0 :         goto exit;
     218                 :            :     }
     219         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
     220                 :          0 :         goto exit;
     221                 :            :     }
     222                 :          0 :     action = _PyLong_AsInt(args[1]);
     223   [ #  #  #  # ]:          0 :     if (action == -1 && PyErr_Occurred()) {
     224                 :          0 :         goto exit;
     225                 :            :     }
     226                 :          0 :     return_value = termios_tcflow_impl(module, fd, action);
     227                 :            : 
     228                 :          0 : exit:
     229                 :          0 :     return return_value;
     230                 :            : }
     231                 :            : 
     232                 :            : PyDoc_STRVAR(termios_tcgetwinsize__doc__,
     233                 :            : "tcgetwinsize($module, fd, /)\n"
     234                 :            : "--\n"
     235                 :            : "\n"
     236                 :            : "Get the tty winsize for file descriptor fd.\n"
     237                 :            : "\n"
     238                 :            : "Returns a tuple (ws_row, ws_col).");
     239                 :            : 
     240                 :            : #define TERMIOS_TCGETWINSIZE_METHODDEF    \
     241                 :            :     {"tcgetwinsize", (PyCFunction)termios_tcgetwinsize, METH_O, termios_tcgetwinsize__doc__},
     242                 :            : 
     243                 :            : static PyObject *
     244                 :            : termios_tcgetwinsize_impl(PyObject *module, int fd);
     245                 :            : 
     246                 :            : static PyObject *
     247                 :          0 : termios_tcgetwinsize(PyObject *module, PyObject *arg)
     248                 :            : {
     249                 :          0 :     PyObject *return_value = NULL;
     250                 :            :     int fd;
     251                 :            : 
     252         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(arg, &fd)) {
     253                 :          0 :         goto exit;
     254                 :            :     }
     255                 :          0 :     return_value = termios_tcgetwinsize_impl(module, fd);
     256                 :            : 
     257                 :          0 : exit:
     258                 :          0 :     return return_value;
     259                 :            : }
     260                 :            : 
     261                 :            : PyDoc_STRVAR(termios_tcsetwinsize__doc__,
     262                 :            : "tcsetwinsize($module, fd, winsize, /)\n"
     263                 :            : "--\n"
     264                 :            : "\n"
     265                 :            : "Set the tty winsize for file descriptor fd.\n"
     266                 :            : "\n"
     267                 :            : "The winsize to be set is taken from the winsize argument, which\n"
     268                 :            : "is a two-item tuple (ws_row, ws_col) like the one returned by tcgetwinsize().");
     269                 :            : 
     270                 :            : #define TERMIOS_TCSETWINSIZE_METHODDEF    \
     271                 :            :     {"tcsetwinsize", _PyCFunction_CAST(termios_tcsetwinsize), METH_FASTCALL, termios_tcsetwinsize__doc__},
     272                 :            : 
     273                 :            : static PyObject *
     274                 :            : termios_tcsetwinsize_impl(PyObject *module, int fd, PyObject *winsz);
     275                 :            : 
     276                 :            : static PyObject *
     277                 :          0 : termios_tcsetwinsize(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
     278                 :            : {
     279                 :          0 :     PyObject *return_value = NULL;
     280                 :            :     int fd;
     281                 :            :     PyObject *winsz;
     282                 :            : 
     283   [ #  #  #  #  :          0 :     if (!_PyArg_CheckPositional("tcsetwinsize", nargs, 2, 2)) {
                   #  # ]
     284                 :          0 :         goto exit;
     285                 :            :     }
     286         [ #  # ]:          0 :     if (!_PyLong_FileDescriptor_Converter(args[0], &fd)) {
     287                 :          0 :         goto exit;
     288                 :            :     }
     289                 :          0 :     winsz = args[1];
     290                 :          0 :     return_value = termios_tcsetwinsize_impl(module, fd, winsz);
     291                 :            : 
     292                 :          0 : exit:
     293                 :          0 :     return return_value;
     294                 :            : }
     295                 :            : /*[clinic end generated code: output=d286a3906a051869 input=a9049054013a1b77]*/

Generated by: LCOV version 1.14