2015-10-02 7 views
1

Я смотрел файл заголовка в моей Linux-системе. Он имеет макрокоманду, определенную как:Macro in C непонятен

#define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 

Я не понимаю, что это значит? Это не побег/восьмеричный/ничего, что я мог бы легко найти. Пожалуйста помоги.

+0

Какой файл заголовка точно? Может быть, вы можете искать 'INIT_C_CC' в файле, чтобы понять, что это лучше. – rootkea

+0

@rootkea, я сначала ссылался только на это, вы также можете проверить это. http://lxr.oss.org.cn/plain/source/arch/cris/include/asm/termios.h?a=ppc#L13 – user5400132

+6

Re: "Это не [...]/восьмеричное": Конечно да. Что заставляет вас думать, что это не так? – ruakh

ответ

5

Этот макрос определяет набор специальных символов, используемых для инициализации массива cc в структуре termios. На странице termios man вы можете увидеть их значение:

Макрос представляет собой последовательность символов в восьмеричном представлении. https://en.wikipedia.org/wiki/Escape_sequences_in_C

Здесь вы можете найти в ASCII код восьмеричных представлений: https://courses.engr.illinois.edu/ece390/books/labmanual/ascii-code-table.html

От: http://man7.org/linux/man-pages/man3/termios.3.html

c_cc массив определяет терминальные специальные символы. Символические индексы (начальные значения) и значение являются:

VDISCARD 
      (not in POSIX; not supported under Linux; 017, SI, Ctrl-O) 
      Toggle: start/stop discarding pending output. Recognized when 
      IEXTEN is set, and then not passed as input. 

    VDSUSP (not in POSIX; not supported under Linux; 031, EM, Ctrl-Y) 
      Delayed suspend character (DSUSP): send SIGTSTP signal when 
      the character is read by the user program. Recognized when 
      IEXTEN and ISIG are set, and the system supports job control, 
      and then not passed as input. 

    VEOF (004, EOT, Ctrl-D) End-of-file character (EOF). More 
      precisely: this character causes the pending tty buffer to be 
      sent to the waiting user program without waiting for end-of- 
      line. If it is the first character of the line, the read(2) 
      in the user program returns 0, which signifies end-of-file. 
      Recognized when ICANON is set, and then not passed as input. 

    VEOL (0, NUL) Additional end-of-line character (EOL). Recognized 
      when ICANON is set. 

    VEOL2 (not in POSIX; 0, NUL) Yet another end-of-line character 
      (EOL2). Recognized when ICANON is set. 

    VERASE (0177, DEL, rubout, or 010, BS, Ctrl-H, or also #) Erase 
      character (ERASE). This erases the previous not-yet-erased 
      character, but does not erase past EOF or beginning-of-line. 
      Recognized when ICANON is set, and then not passed as input. 

    VINTR (003, ETX, Ctrl-C, or also 0177, DEL, rubout) Interrupt 
      character (INTR). Send a SIGINT signal. Recognized when ISIG 
      is set, and then not passed as input. 

    VKILL (025, NAK, Ctrl-U, or Ctrl-X, or also @) Kill character 
      (KILL). This erases the input since the last EOF or 
      beginning-of-line. Recognized when ICANON is set, and then 
      not passed as input. 

    VLNEXT (not in POSIX; 026, SYN, Ctrl-V) Literal next (LNEXT). Quotes 
      the next input character, depriving it of a possible special 
      meaning. Recognized when IEXTEN is set, and then not passed 
      as input. 

    VMIN Minimum number of characters for noncanonical read (MIN). 

    VQUIT (034, FS, Ctrl-\) Quit character (QUIT). Send SIGQUIT signal. 
      Recognized when ISIG is set, and then not passed as input. 

    VREPRINT 
      (not in POSIX; 022, DC2, Ctrl-R) Reprint unread characters 
      (REPRINT). Recognized when ICANON and IEXTEN are set, and 
      then not passed as input. 

    VSTART (021, DC1, Ctrl-Q) Start character (START). Restarts output 
      stopped by the Stop character. Recognized when IXON is set, 
      and then not passed as input. 

    VSTATUS 
      (not in POSIX; not supported under Linux; status request: 024, 
      DC4, Ctrl-T). Status character (STATUS). Display status 
      information at terminal, including state of foreground process 
      and amount of CPU time it has consumed. Also sends a SIGINFO 
      signal (not supported on Linux) to the foreground process 
      group. 

    VSTOP (023, DC3, Ctrl-S) Stop character (STOP). Stop output until 
      Start character typed. Recognized when IXON is set, and then 
      not passed as input. 

    VSUSP (032, SUB, Ctrl-Z) Suspend character (SUSP). Send SIGTSTP 
      signal. Recognized when ISIG is set, and then not passed as 
      input. 

    VSWTCH (not in POSIX; not supported under Linux; 0, NUL) Switch 
      character (SWTCH). Used in System V to switch shells in shell 
      layers, a predecessor to shell job control. 

    VTIME Timeout in deciseconds for noncanonical read (TIME). 

    VWERASE 
      (not in POSIX; 027, ETB, Ctrl-W) Word erase (WERASE). 
      Recognized when ICANON and IEXTEN are set, and then not passed 
      as input. 

    An individual terminal special character can be disabled by setting 
    the value of the corresponding c_cc element to _POSIX_VDISABLE. 

    The above symbolic subscript values are all different, except that 
    VTIME, VMIN may have the same value as VEOL, VEOF, respectively. In 
    noncanonical mode the special character meaning is replaced by the 
    timeout meaning. For an explanation of VMIN and VTIME, see the 
    description of noncanonical mode below. 
+0

не могли бы вы рассказать, что это за обратная косая черта? Разве это расширяется как одна строка или несколько строк или что? Я видел переменное присвоенное значение, равное INIT_C_CC, что это значит? Какое значение имеет эта переменная? – user5400132

+1

Это последовательность символов в восьмеричном представлении. https://en.wikipedia.org/wiki/Escape_sequences_in_C – redobot

1

Замена текстом для INIT_C_CC макроса является строкой символов, где каждый символ определен как восьмеричная последовательность.

Если используется для инициализации массива, он расширяется до

char c_cc[17] = "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0"; 

что эквивалентно

char c_cc[17] = {3, 28, 127, 21, 4, 0, 1, 0, 17, 19, 26, 0, 18, 15, 23, 22, 0 };