Browse Source

Merge branch 'master' of https://src.libcode.org/pkun/klish

Serj Kalichev 1 year ago
parent
commit
8b955417e8
2 changed files with 7 additions and 2 deletions
  1. 1 0
      klish/ktp.h
  2. 6 2
      klish/ktp/ktpd_session.c

+ 1 - 0
klish/ktp.h

@@ -33,6 +33,7 @@ typedef enum {
 typedef enum {
 	KTP_PARAM_NULL = '\0',
 	KTP_PARAM_LINE = 'L',
+	KTP_PARAM_PREFIX = 'P', // Same as line but differ by meaning
 	KTP_PARAM_ERROR = 'E',
 	KTP_PARAM_RETCODE = 'R',
 } ktp_param_e;

+ 6 - 2
klish/ktp/ktpd_session.c

@@ -304,6 +304,7 @@ static bool_t ktpd_session_process_completion(ktpd_session_t *ktpd, faux_msg_t *
 	kpargv_t *pargv = NULL;
 	ktp_cmd_e cmd = KTP_COMPLETION_ACK;
 	uint32_t status = KTP_STATUS_NONE;
+	const char *prefix = NULL;
 
 	assert(ktpd);
 	assert(msg);
@@ -323,8 +324,6 @@ static bool_t ktpd_session_process_completion(ktpd_session_t *ktpd, faux_msg_t *
 	}
 	kpargv_debug(pargv);
 
-	kpargv_free(pargv);
-
 	if (ksession_done(ktpd->session)) {
 		ktpd->exit = BOOL_TRUE;
 		status |= KTP_STATUS_EXIT; // Notify client about exiting
@@ -332,9 +331,14 @@ static bool_t ktpd_session_process_completion(ktpd_session_t *ktpd, faux_msg_t *
 
 	// Send ACK message
 	ack = ktp_msg_preform(cmd, status);
+	prefix = kpargv_last_arg(pargv);
+	if (!faux_str_is_empty(prefix))
+		faux_msg_add_param(ack, KTP_PARAM_PREFIX, prefix, strlen(prefix));
 	faux_msg_send_async(ack, ktpd->async);
 	faux_msg_free(ack);
 
+	kpargv_free(pargv);
+
 	return BOOL_TRUE;
 }