db_output.c (37224cd3fcb911d440e40dd8e1f31652e2452537) | db_output.c (d39d4a6e6412f88225d1b78c8a797ab82daac250) |
---|---|
1/* 2 * Mach Operating System 3 * Copyright (c) 1991,1990 Carnegie Mellon University 4 * All Rights Reserved. 5 * 6 * Permission to use, copy, modify and distribute this software and its 7 * documentation is hereby granted, provided that both the copyright 8 * notice and this permission notice appear in all copies of the --- 51 unchanged lines hidden (view full) --- 60 * of the wraparounds. 61 */ 62static int db_output_position = 0; /* output column */ 63static int db_last_non_space = 0; /* last non-space character */ 64db_expr_t db_tab_stop_width = 8; /* how wide are tab stops? */ 65#define NEXT_TAB(i) \ 66 ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width) 67db_expr_t db_max_width = 79; /* output line width */ | 1/* 2 * Mach Operating System 3 * Copyright (c) 1991,1990 Carnegie Mellon University 4 * All Rights Reserved. 5 * 6 * Permission to use, copy, modify and distribute this software and its 7 * documentation is hereby granted, provided that both the copyright 8 * notice and this permission notice appear in all copies of the --- 51 unchanged lines hidden (view full) --- 60 * of the wraparounds. 61 */ 62static int db_output_position = 0; /* output column */ 63static int db_last_non_space = 0; /* last non-space character */ 64db_expr_t db_tab_stop_width = 8; /* how wide are tab stops? */ 65#define NEXT_TAB(i) \ 66 ((((i) + db_tab_stop_width) / db_tab_stop_width) * db_tab_stop_width) 67db_expr_t db_max_width = 79; /* output line width */ |
68db_expr_t db_lines_per_page = 20; /* lines per page */ |
|
68static int db_newlines; /* # lines this page */ | 69static int db_newlines; /* # lines this page */ |
69static int db_maxlines = -1; /* max lines per page */ | 70static int db_maxlines = -1; /* max lines/page when paging */ |
70static db_page_calloutfcn_t *db_page_callout = NULL; 71static void *db_page_callout_arg = NULL; 72static int ddb_use_printf = 0; 73SYSCTL_INT(_debug, OID_AUTO, ddb_use_printf, CTLFLAG_RW, &ddb_use_printf, 0, 74 "use printf for all ddb output"); 75 76static void db_putchar(int c, void *arg); 77 --- 60 unchanged lines hidden (view full) --- 138 */ 139 db_force_whitespace(); 140 cnputc(c); 141 db_output_position++; 142 db_last_non_space = db_output_position; 143 } 144 else if (c == '\n') { 145 /* Newline */ | 71static db_page_calloutfcn_t *db_page_callout = NULL; 72static void *db_page_callout_arg = NULL; 73static int ddb_use_printf = 0; 74SYSCTL_INT(_debug, OID_AUTO, ddb_use_printf, CTLFLAG_RW, &ddb_use_printf, 0, 75 "use printf for all ddb output"); 76 77static void db_putchar(int c, void *arg); 78 --- 60 unchanged lines hidden (view full) --- 139 */ 140 db_force_whitespace(); 141 cnputc(c); 142 db_output_position++; 143 db_last_non_space = db_output_position; 144 } 145 else if (c == '\n') { 146 /* Newline */ |
147 db_force_whitespace(); |
|
146 cnputc(c); 147 db_output_position = 0; 148 db_last_non_space = 0; 149 db_check_interrupt(); 150 if (db_maxlines > 0 && db_page_callout != NULL) { 151 db_newlines++; 152 if (db_newlines >= db_maxlines) { 153 db_maxlines = -1; 154 db_page_callout(db_page_callout_arg); 155 } 156 } 157 } 158 else if (c == '\r') { 159 /* Return */ | 148 cnputc(c); 149 db_output_position = 0; 150 db_last_non_space = 0; 151 db_check_interrupt(); 152 if (db_maxlines > 0 && db_page_callout != NULL) { 153 db_newlines++; 154 if (db_newlines >= db_maxlines) { 155 db_maxlines = -1; 156 db_page_callout(db_page_callout_arg); 157 } 158 } 159 } 160 else if (c == '\r') { 161 /* Return */ |
162 db_force_whitespace(); |
|
160 cnputc(c); 161 db_output_position = 0; 162 db_last_non_space = 0; 163 db_check_interrupt(); 164 } 165 else if (c == '\t') { 166 /* assume tabs every 8 positions */ 167 db_output_position = NEXT_TAB(db_output_position); --- 24 unchanged lines hidden (view full) --- 192 193/* 194 * A simple paging callout function. If the argument is not null, it 195 * points to an integer that will be set to 1 if the user asks to quit. 196 */ 197void 198db_simple_pager(void *arg) 199{ | 163 cnputc(c); 164 db_output_position = 0; 165 db_last_non_space = 0; 166 db_check_interrupt(); 167 } 168 else if (c == '\t') { 169 /* assume tabs every 8 positions */ 170 db_output_position = NEXT_TAB(db_output_position); --- 24 unchanged lines hidden (view full) --- 195 196/* 197 * A simple paging callout function. If the argument is not null, it 198 * points to an integer that will be set to 1 if the user asks to quit. 199 */ 200void 201db_simple_pager(void *arg) 202{ |
200 int c; | 203 int c, done; |
201 202 db_printf("--More--\r"); | 204 205 db_printf("--More--\r"); |
203 for (;;) { | 206 done = 0; 207 while (!done) { |
204 c = cngetc(); 205 switch (c) { | 208 c = cngetc(); 209 switch (c) { |
210 case 'e': 211 case 'j': |
|
206 case '\n': 207 /* Just one more line. */ 208 db_setup_paging(db_simple_pager, arg, 1); | 212 case '\n': 213 /* Just one more line. */ 214 db_setup_paging(db_simple_pager, arg, 1); |
209 return; | 215 done++; 216 break; 217 case 'd': 218 /* Half a page. */ 219 db_setup_paging(db_simple_pager, arg, 220 db_lines_per_page / 2); 221 done++; 222 break; 223 case 'f': |
210 case ' ': 211 /* Another page. */ 212 db_setup_paging(db_simple_pager, arg, | 224 case ' ': 225 /* Another page. */ 226 db_setup_paging(db_simple_pager, arg, |
213 DB_LINES_PER_PAGE); 214 return; | 227 db_lines_per_page); 228 done++; 229 break; |
215 case 'q': 216 case 'Q': 217 case 'x': 218 case 'X': 219 /* Quit */ 220 if (arg != NULL) { 221 *(int *)arg = 1; | 230 case 'q': 231 case 'Q': 232 case 'x': 233 case 'X': 234 /* Quit */ 235 if (arg != NULL) { 236 *(int *)arg = 1; |
222 db_printf("\n"); 223 return; | 237 done++; 238 break; |
224 } 225#if 0 226 /* FALLTHROUGH */ 227 default: 228 cnputc('\007'); 229#endif 230 } 231 } | 239 } 240#if 0 241 /* FALLTHROUGH */ 242 default: 243 cnputc('\007'); 244#endif 245 } 246 } |
247 db_printf(" \r"); |
|
232} 233 234/* 235 * Return output position 236 */ 237int 238db_print_position() 239{ --- 52 unchanged lines hidden --- | 248} 249 250/* 251 * Return output position 252 */ 253int 254db_print_position() 255{ --- 52 unchanged lines hidden --- |