Commit e20d435c e20d435c8e310046c15acbdf47fa458fe7ead1ae by Sergey Poznyakoff

Minor improvements in logstream and related code.

* include/mailutils/stream.h (MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE)
(MU_IOCTL_LOGSTREAM_SET_LOCUS_COL): New subcodes.
* libmailutils/stream/logstream.c (_log_ctl): Handle two new subcodes.
* comsat/action.c (eval_biffrc): Use new ioctl subcode to update the
line number.
1 parent 06fb6b02
...@@ -522,12 +522,12 @@ eval_biffrc (struct biffrc_environ *env) ...@@ -522,12 +522,12 @@ eval_biffrc (struct biffrc_environ *env)
522 522
523 ws.ws_comment = "#"; 523 ws.ws_comment = "#";
524 wsflags = MU_WRDSF_DEFFLAGS | MU_WRDSF_COMMENT; 524 wsflags = MU_WRDSF_DEFFLAGS | MU_WRDSF_COMMENT;
525 while (mu_stream_getline (env->input, &stmt, &size, &n) == 0 && n > 0)
526 {
527 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, 525 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
528 MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus); 526 MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus);
529 mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM, 527 mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
530 MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus); 528 MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus);
529 while (mu_stream_getline (env->input, &stmt, &size, &n) == 0 && n > 0)
530 {
531 if (strncmp (stmt, "#line ", 6) == 0) 531 if (strncmp (stmt, "#line ", 6) == 0)
532 { 532 {
533 char *p; 533 char *p;
...@@ -540,9 +540,11 @@ eval_biffrc (struct biffrc_environ *env) ...@@ -540,9 +540,11 @@ eval_biffrc (struct biffrc_environ *env)
540 else 540 else
541 { 541 {
542 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM, 542 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
543 MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus); 543 MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE,
544 &env->locus.mu_line);
544 mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM, 545 mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
545 MU_IOCTL_LOGSTREAM_SET_LOCUS, &env->locus); 546 MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE,
547 &env->locus.mu_line);
546 } 548 }
547 continue; 549 continue;
548 } 550 }
...@@ -553,7 +555,10 @@ eval_biffrc (struct biffrc_environ *env) ...@@ -553,7 +555,10 @@ eval_biffrc (struct biffrc_environ *env)
553 555
554 if (ws.ws_wordc == 0) 556 if (ws.ws_wordc == 0)
555 { 557 {
556 env->locus.mu_line++; 558 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
559 MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
560 mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
561 MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
557 continue; 562 continue;
558 } 563 }
559 564
...@@ -591,7 +596,10 @@ eval_biffrc (struct biffrc_environ *env) ...@@ -591,7 +596,10 @@ eval_biffrc (struct biffrc_environ *env)
591 report_error (env, "%s", mu_wordsplit_strerror (&ws)); 596 report_error (env, "%s", mu_wordsplit_strerror (&ws));
592 597
593 wsflags |= MU_WRDSF_REUSE; 598 wsflags |= MU_WRDSF_REUSE;
594 env->locus.mu_line++; 599 mu_stream_ioctl (mu_strerr, MU_IOCTL_LOGSTREAM,
600 MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
601 mu_stream_ioctl (env->logstr, MU_IOCTL_LOGSTREAM,
602 MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE, NULL);
595 } 603 }
596 free (stmt); 604 free (stmt);
597 mu_wordsplit_free (&ws); 605 mu_wordsplit_free (&ws);
......
...@@ -108,26 +108,36 @@ enum mu_buffer_type ...@@ -108,26 +108,36 @@ enum mu_buffer_type
108 #define MU_IOCTL_LOGSTREAM_GET_MODE 4 108 #define MU_IOCTL_LOGSTREAM_GET_MODE 4
109 #define MU_IOCTL_LOGSTREAM_SET_MODE 5 109 #define MU_IOCTL_LOGSTREAM_SET_MODE 5
110 110
111 /* Set locus line.
112 Arg: unsigned *
113 */
114 #define MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE 6
115 /* Set locus column.
116 Arg: unsigned *
117 */
118 #define MU_IOCTL_LOGSTREAM_SET_LOCUS_COL 7
119
111 /* Advance locus line. 120 /* Advance locus line.
112 Arg: NULL (increment by 1) 121 Arg: NULL (increment by 1)
113 int * 122 int *
114 */ 123 */
115 #define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE 6 124 #define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE 8
116 /* Advance locus column. 125 /* Advance locus column.
117 Arg: NULL (increment by 1) 126 Arg: NULL (increment by 1)
118 int * 127 int *
119 */ 128 */
120 #define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_COL 7 129
130 #define MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_COL 9
121 131
122 /* Suppress output of messages having severity lower than the 132 /* Suppress output of messages having severity lower than the
123 given threshold. 133 given threshold.
124 Arg: int * 134 Arg: int *
125 */ 135 */
126 #define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY 8 136 #define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY 10
127 /* Same as above, but: 137 /* Same as above, but:
128 Arg: const char * 138 Arg: const char *
129 */ 139 */
130 #define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 9 140 #define MU_IOCTL_LOGSTREAM_SUPPRESS_SEVERITY_NAME 11
131 141
132 /* Opcodes for MU_IOCTL_XSCRIPTSTREAM */ 142 /* Opcodes for MU_IOCTL_XSCRIPTSTREAM */
133 /* Swap transcript levels. 143 /* Swap transcript levels.
......
...@@ -378,6 +378,18 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg) ...@@ -378,6 +378,18 @@ _log_ctl (struct _mu_stream *str, int code, int opcode, void *arg)
378 break; 378 break;
379 } 379 }
380 380
381 case MU_IOCTL_LOGSTREAM_SET_LOCUS_LINE:
382 if (!arg)
383 return EINVAL;
384 sp->locus.mu_line = *(unsigned*)arg;
385 break;
386
387 case MU_IOCTL_LOGSTREAM_SET_LOCUS_COL:
388 if (!arg)
389 return EINVAL;
390 sp->locus.mu_col = *(unsigned*)arg;
391 break;
392
381 case MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE: 393 case MU_IOCTL_LOGSTREAM_ADVANCE_LOCUS_LINE:
382 if (!arg) 394 if (!arg)
383 sp->locus.mu_line++; 395 sp->locus.mu_line++;
......