Linux programming unleash phần 6

Khi bạn đã hoàn thành bằng cách sử dụng một tập tin bộ nhớ ánh xạ, gọi munmap () để unmap khu vực và trả lại bộ nhớ cho hệ điều hành. Chức năng này sử dụng các mẫu thử nghiệm sau đây:Một dòng mới nào không thực hiện một trở về vận chuyển, vì vậy đầu vào Sử dụng chức năng munmap () | Programming the User Interface 422 Part IV The two error handling functions declared and defined on lines 10-12 and 62-73 respectively are strictly for convenience. The program creates a signal-handling function to demonstrate that it catches some signals lines 13 57-60 . The program s real meat appears in lines 31-39. Line 33 turns off canonical mode local echo and ignores signals line 34 turns of the CR to NL translation and line 35 turns off all output processing. After updating the terminal attributes the loop on lines 43-46 reads input one character at a time and outputs it to the screen in octal notation. If you press the Delete key the program exits after restoring the original terminal settings. A sample run of the program looks like the following . rawmode In RAW mode. Press DELETE key to exit 154 Type 1 151 Type i 156 Type n 165 Type u 170 Type x 3 Type Ctr1-C 32 Type Ctr1-Z 4 Type Ctr1-D A newline does not perform a carriage return so input appears on a new line but at the location of the cursor from the last line. Because the program turned off signals signals entered at the keyboard such as C interrupt Z suspend and D EOF get ignored. Using terminfo Where termios gives you very low-level control over input processing terminfo gives you a similar level of control over output processing. terminfo provides a portable low-level interface to operations such as clearing a terminal screen positioning the cursor or deleting lines or characters. Due to the wide variety of terminals in existence UNIX s designers eventually learned to standardize descriptions of terminal capabilities in centrally located database files. The word terminfo refers both to this database and to the routines that access it. Note Strictly speaking the termcap database first used in BSD-derived systems preceded terminfo the name termcap is a contraction of the phrase TERMinal CAPability . As the termcap database grew in size however it became too slow for interactive use and was replaced

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
366    96    8    18-06-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.