0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #include <string.h>
0036 #include <stdio.h>
0037 #include <stdlib.h>
0038 #include <memory.h>
0039 #include <sys/param.h>
0040
0041 #include <ndrstandard.h>
0042 #include <ndebug.h>
0043
0044 #include <ndrx.h>
0045 #include <ndrxdcmn.h>
0046 #include <atmi_int.h>
0047 #include <gencall.h>
0048
0049 #include "nstopwatch.h"
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063 expublic int pe_rsp_process(command_reply_t *reply, size_t reply_len)
0064 {
0065 if (NDRXD_CALL_TYPE_PE==reply->msg_type)
0066 {
0067 command_reply_pe_t * pe_info = (command_reply_pe_t*)reply;
0068 fprintf(stdout, "%s\n", pe_info->env);
0069 }
0070
0071 return EXSUCCEED;
0072 }
0073
0074
0075
0076
0077
0078
0079
0080
0081 expublic int cmd_pe(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0082 {
0083 command_call_t call;
0084 memset(&call, 0, sizeof(call));
0085
0086
0087 return cmd_generic_listcall(p_cmd_map->ndrxd_cmd, NDRXD_SRC_ADMIN,
0088 NDRXD_CALL_TYPE_GENERIC,
0089 &call, sizeof(call),
0090 G_config.reply_queue_str,
0091 G_config.reply_queue,
0092 G_config.ndrxd_q,
0093 G_config.ndrxd_q_str,
0094 argc, argv,
0095 p_have_next,
0096 G_call_args,
0097 EXFALSE,
0098 G_config.listcall_flags);
0099 }
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109 expublic int cmd_set(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0110 {
0111 int ret=EXSUCCEED;
0112 command_setenv_t call;
0113 int i=1;
0114
0115 memset(&call, 0, sizeof(call));
0116
0117 if (argc>=2)
0118 {
0119 while (i<argc && strlen(call.env)+strlen(argv[i]) < EX_ENV_MAX-2)
0120 {
0121 if (i>1)
0122 {
0123 strcat(call.env, " ");
0124 }
0125 strcat(call.env, argv[i]);
0126 i++;
0127 }
0128 }
0129 else
0130 {
0131 fprintf(stderr, "Invalid value, format set 'ENV_VAR=VALUE'\n");
0132 EXFAIL_OUT(ret);
0133 }
0134
0135 ret=cmd_generic_listcall(p_cmd_map->ndrxd_cmd, NDRXD_SRC_ADMIN,
0136 NDRXD_CALL_TYPE_GENERIC,
0137 (command_call_t *)&call, sizeof(call),
0138 G_config.reply_queue_str,
0139 G_config.reply_queue,
0140 G_config.ndrxd_q,
0141 G_config.ndrxd_q_str,
0142 argc, argv,
0143 p_have_next,
0144 G_call_args,
0145 EXFALSE,
0146 G_config.listcall_flags);
0147 out:
0148 return ret;
0149 }
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160 expublic int cmd_unset(cmd_mapping_t *p_cmd_map, int argc, char **argv, int *p_have_next)
0161 {
0162 int ret=EXSUCCEED;
0163 command_setenv_t call;
0164
0165 memset(&call, 0, sizeof(call));
0166
0167 if (argc>=2)
0168 {
0169 NDRX_STRCPY_SAFE(call.env, argv[1]);
0170 if (NULL!=strchr(call.env, '='))
0171 {
0172 fprintf(stderr, "Invalid format\n");
0173 EXFAIL_OUT(ret);
0174 }
0175 strcat(call.env,"=");
0176 }
0177 else
0178 {
0179 fprintf(stderr, "Missing ENV name\n");
0180 EXFAIL_OUT(ret);
0181 }
0182
0183 ret=cmd_generic_listcall(p_cmd_map->ndrxd_cmd, NDRXD_SRC_ADMIN,
0184 NDRXD_CALL_TYPE_GENERIC,
0185 (command_call_t *)&call, sizeof(call),
0186 G_config.reply_queue_str,
0187 G_config.reply_queue,
0188 G_config.ndrxd_q,
0189 G_config.ndrxd_q_str,
0190 argc, argv,
0191 p_have_next,
0192 G_call_args,
0193 EXFALSE,
0194 G_config.listcall_flags);
0195 out:
0196 return ret;
0197 }
0198
0199