comparison src/channel.c @ 17789:0f7ae8010787 v8.1.1891

patch 8.1.1891: functions used in one file are global commit https://github.com/vim/vim/commit/5843f5f37b0632e2d706abc9014bfd7d98f7b02e Author: Bram Moolenaar <Bram@vim.org> Date: Tue Aug 20 20:13:45 2019 +0200 patch 8.1.1891: functions used in one file are global Problem: Functions used in one file are global. Solution: Add "static". (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/4840)
author Bram Moolenaar <Bram@vim.org>
date Tue, 20 Aug 2019 20:15:07 +0200
parents ff097edaae89
children 9fb236d0f386
comparison
equal deleted inserted replaced
17788:2cf6b7b53b1d 17789:0f7ae8010787
53 # define fd_write(sd, buf, len) write(sd, buf, len) 53 # define fd_write(sd, buf, len) write(sd, buf, len)
54 # define fd_close(sd) close(sd) 54 # define fd_close(sd) close(sd)
55 #endif 55 #endif
56 56
57 static void channel_read(channel_T *channel, ch_part_T part, char *func); 57 static void channel_read(channel_T *channel, ch_part_T part, char *func);
58 # if defined(MSWIN) || defined(FEAT_GUI_X11) || defined(FEAT_GUI_GTK)
59 static channel_T *channel_fd2channel(sock_T fd, ch_part_T *partp);
60 # endif
61 static ch_mode_T channel_get_mode(channel_T *channel, ch_part_T part);
62 static int channel_get_timeout(channel_T *channel, ch_part_T part);
63 static ch_part_T channel_part_send(channel_T *channel);
64 static ch_part_T channel_part_read(channel_T *channel);
65 static void free_job_options(jobopt_T *opt);
58 66
59 /* Whether a redraw is needed for appending a line to a buffer. */ 67 /* Whether a redraw is needed for appending a line to a buffer. */
60 static int channel_need_redraw = FALSE; 68 static int channel_need_redraw = FALSE;
61 69
62 /* Whether we are inside channel_parse_messages() or another situation where it 70 /* Whether we are inside channel_parse_messages() or another situation where it
1173 } 1181 }
1174 1182
1175 /* 1183 /*
1176 * Implements ch_open(). 1184 * Implements ch_open().
1177 */ 1185 */
1178 channel_T * 1186 static channel_T *
1179 channel_open_func(typval_T *argvars) 1187 channel_open_func(typval_T *argvars)
1180 { 1188 {
1181 char_u *address; 1189 char_u *address;
1182 char_u *p; 1190 char_u *p;
1183 char *rest; 1191 char *rest;
1346 } 1354 }
1347 1355
1348 /* 1356 /*
1349 * Set the callback for "channel"/"part" for the response with "id". 1357 * Set the callback for "channel"/"part" for the response with "id".
1350 */ 1358 */
1351 void 1359 static void
1352 channel_set_req_callback( 1360 channel_set_req_callback(
1353 channel_T *channel, 1361 channel_T *channel,
1354 ch_part_T part, 1362 ch_part_T part,
1355 callback_T *callback, 1363 callback_T *callback,
1356 int id) 1364 int id)
2846 } 2854 }
2847 2855
2848 /* 2856 /*
2849 * Return TRUE if "channel" has JSON or other typeahead. 2857 * Return TRUE if "channel" has JSON or other typeahead.
2850 */ 2858 */
2851 int 2859 static int
2852 channel_has_readahead(channel_T *channel, ch_part_T part) 2860 channel_has_readahead(channel_T *channel, ch_part_T part)
2853 { 2861 {
2854 ch_mode_T ch_mode = channel->ch_part[part].ch_mode; 2862 ch_mode_T ch_mode = channel->ch_part[part].ch_mode;
2855 2863
2856 if (ch_mode == MODE_JSON || ch_mode == MODE_JS) 2864 if (ch_mode == MODE_JSON || ch_mode == MODE_JS)
2957 2965
2958 STRCPY(namebuf + tail, "timeout"); 2966 STRCPY(namebuf + tail, "timeout");
2959 dict_add_number(dict, namebuf, chanpart->ch_timeout); 2967 dict_add_number(dict, namebuf, chanpart->ch_timeout);
2960 } 2968 }
2961 2969
2962 void 2970 static void
2963 channel_info(channel_T *channel, dict_T *dict) 2971 channel_info(channel_T *channel, dict_T *dict)
2964 { 2972 {
2965 dict_add_number(dict, "id", channel->ch_id); 2973 dict_add_number(dict, "id", channel->ch_id);
2966 dict_add_string(dict, "status", (char_u *)channel_status(channel, -1)); 2974 dict_add_string(dict, "status", (char_u *)channel_status(channel, -1));
2967 2975
3065 } 3073 }
3066 3074
3067 /* 3075 /*
3068 * Close the "in" part channel "channel". 3076 * Close the "in" part channel "channel".
3069 */ 3077 */
3070 void 3078 static void
3071 channel_close_in(channel_T *channel) 3079 channel_close_in(channel_T *channel)
3072 { 3080 {
3073 ch_close_part(channel, PART_IN); 3081 ch_close_part(channel, PART_IN);
3074 } 3082 }
3075 3083
3674 } 3682 }
3675 3683
3676 /* 3684 /*
3677 * Common for ch_read() and ch_readraw(). 3685 * Common for ch_read() and ch_readraw().
3678 */ 3686 */
3679 void 3687 static void
3680 common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob) 3688 common_channel_read(typval_T *argvars, typval_T *rettv, int raw, int blob)
3681 { 3689 {
3682 channel_T *channel; 3690 channel_T *channel;
3683 ch_part_T part = PART_COUNT; 3691 ch_part_T part = PART_COUNT;
3684 jobopt_T opt; 3692 jobopt_T opt;
3760 || defined(PROTO) 3768 || defined(PROTO)
3761 /* 3769 /*
3762 * Lookup the channel from the socket. Set "partp" to the fd index. 3770 * Lookup the channel from the socket. Set "partp" to the fd index.
3763 * Returns NULL when the socket isn't found. 3771 * Returns NULL when the socket isn't found.
3764 */ 3772 */
3765 channel_T * 3773 static channel_T *
3766 channel_fd2channel(sock_T fd, ch_part_T *partp) 3774 channel_fd2channel(sock_T fd, ch_part_T *partp)
3767 { 3775 {
3768 channel_T *channel; 3776 channel_T *channel;
3769 ch_part_T part; 3777 ch_part_T part;
3770 3778
4090 } 4098 }
4091 4099
4092 /* 4100 /*
4093 * common for "ch_evalexpr()" and "ch_sendexpr()" 4101 * common for "ch_evalexpr()" and "ch_sendexpr()"
4094 */ 4102 */
4095 void 4103 static void
4096 ch_expr_common(typval_T *argvars, typval_T *rettv, int eval) 4104 ch_expr_common(typval_T *argvars, typval_T *rettv, int eval)
4097 { 4105 {
4098 char_u *text; 4106 char_u *text;
4099 typval_T *listtv; 4107 typval_T *listtv;
4100 channel_T *channel; 4108 channel_T *channel;
4152 } 4160 }
4153 4161
4154 /* 4162 /*
4155 * common for "ch_evalraw()" and "ch_sendraw()" 4163 * common for "ch_evalraw()" and "ch_sendraw()"
4156 */ 4164 */
4157 void 4165 static void
4158 ch_raw_common(typval_T *argvars, typval_T *rettv, int eval) 4166 ch_raw_common(typval_T *argvars, typval_T *rettv, int eval)
4159 { 4167 {
4160 char_u buf[NUMBUFLEN]; 4168 char_u buf[NUMBUFLEN];
4161 char_u *text; 4169 char_u *text;
4162 int len; 4170 int len;
4538 } 4546 }
4539 4547
4540 /* 4548 /*
4541 * Return the "part" to write to for "channel". 4549 * Return the "part" to write to for "channel".
4542 */ 4550 */
4543 ch_part_T 4551 static ch_part_T
4544 channel_part_send(channel_T *channel) 4552 channel_part_send(channel_T *channel)
4545 { 4553 {
4546 if (channel->CH_SOCK_FD == INVALID_FD) 4554 if (channel->CH_SOCK_FD == INVALID_FD)
4547 return PART_IN; 4555 return PART_IN;
4548 return PART_SOCK; 4556 return PART_SOCK;
4549 } 4557 }
4550 4558
4551 /* 4559 /*
4552 * Return the default "part" to read from for "channel". 4560 * Return the default "part" to read from for "channel".
4553 */ 4561 */
4554 ch_part_T 4562 static ch_part_T
4555 channel_part_read(channel_T *channel) 4563 channel_part_read(channel_T *channel)
4556 { 4564 {
4557 if (channel->CH_SOCK_FD == INVALID_FD) 4565 if (channel->CH_SOCK_FD == INVALID_FD)
4558 return PART_OUT; 4566 return PART_OUT;
4559 return PART_SOCK; 4567 return PART_SOCK;
4561 4569
4562 /* 4570 /*
4563 * Return the mode of "channel"/"part" 4571 * Return the mode of "channel"/"part"
4564 * If "channel" is invalid returns MODE_JSON. 4572 * If "channel" is invalid returns MODE_JSON.
4565 */ 4573 */
4566 ch_mode_T 4574 static ch_mode_T
4567 channel_get_mode(channel_T *channel, ch_part_T part) 4575 channel_get_mode(channel_T *channel, ch_part_T part)
4568 { 4576 {
4569 if (channel == NULL) 4577 if (channel == NULL)
4570 return MODE_JSON; 4578 return MODE_JSON;
4571 return channel->ch_part[part].ch_mode; 4579 return channel->ch_part[part].ch_mode;
4572 } 4580 }
4573 4581
4574 /* 4582 /*
4575 * Return the timeout of "channel"/"part" 4583 * Return the timeout of "channel"/"part"
4576 */ 4584 */
4577 int 4585 static int
4578 channel_get_timeout(channel_T *channel, ch_part_T part) 4586 channel_get_timeout(channel_T *channel, ch_part_T part)
4579 { 4587 {
4580 return channel->ch_part[part].ch_timeout; 4588 return channel->ch_part[part].ch_timeout;
4581 } 4589 }
4582 4590
4636 } 4644 }
4637 4645
4638 /* 4646 /*
4639 * Free any members of a jobopt_T. 4647 * Free any members of a jobopt_T.
4640 */ 4648 */
4641 void 4649 static void
4642 free_job_options(jobopt_T *opt) 4650 free_job_options(jobopt_T *opt)
4643 { 4651 {
4644 if (opt->jo_callback.cb_partial != NULL) 4652 if (opt->jo_callback.cb_partial != NULL)
4645 partial_unref(opt->jo_callback.cb_partial); 4653 partial_unref(opt->jo_callback.cb_partial);
4646 else if (opt->jo_callback.cb_name != NULL) 4654 else if (opt->jo_callback.cb_name != NULL)
5307 job_free_contents(job); 5315 job_free_contents(job);
5308 job_free_job(job); 5316 job_free_job(job);
5309 } 5317 }
5310 } 5318 }
5311 5319
5312 job_T *jobs_to_free = NULL; 5320 static job_T *jobs_to_free = NULL;
5313 5321
5314 /* 5322 /*
5315 * Put "job" in a list to be freed later, when it's no longer referenced. 5323 * Put "job" in a list to be freed later, when it's no longer referenced.
5316 */ 5324 */
5317 static void 5325 static void