Remove dead code
This commit is contained in:
parent
06334ddd79
commit
41e0dea99f
1 changed files with 0 additions and 143 deletions
143
cwc.c
143
cwc.c
|
@ -785,149 +785,6 @@ cwc_transport_start(th_transport_t *t)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static void
|
||||
cwc_save(void)
|
||||
{
|
||||
cwc_t *cwc;
|
||||
|
||||
FILE *fp;
|
||||
char buf[400];
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/cwc.cfg", settings_dir);
|
||||
if((fp = settings_open_for_write(buf)) == NULL)
|
||||
return;
|
||||
|
||||
TAILQ_FOREACH(cwc, &cwcs, cwc_link) {
|
||||
|
||||
fprintf(fp, "cwc {\n");
|
||||
fprintf(fp, "\thostname = %s\n", cwc->cwc_tcp_session.tcp_hostname);
|
||||
fprintf(fp, "\tport = %d\n", cwc->cwc_tcp_session.tcp_port);
|
||||
|
||||
fprintf(fp, "\tusername = %s\n", cwc->cwc_username);
|
||||
fprintf(fp, "\tpassword = %s\n", cwc->cwc_password);
|
||||
fprintf(fp, "\tdeskey = "
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x:"
|
||||
"%02x:%02x:%02x:%02x:%02x:%02x:%02x\n",
|
||||
cwc->cwc_confedkey[0x0],
|
||||
cwc->cwc_confedkey[0x1],
|
||||
cwc->cwc_confedkey[0x2],
|
||||
cwc->cwc_confedkey[0x3],
|
||||
cwc->cwc_confedkey[0x4],
|
||||
cwc->cwc_confedkey[0x5],
|
||||
cwc->cwc_confedkey[0x6],
|
||||
cwc->cwc_confedkey[0x7],
|
||||
cwc->cwc_confedkey[0x8],
|
||||
cwc->cwc_confedkey[0x9],
|
||||
cwc->cwc_confedkey[0xa],
|
||||
cwc->cwc_confedkey[0xb],
|
||||
cwc->cwc_confedkey[0xc],
|
||||
cwc->cwc_confedkey[0xd]);
|
||||
fprintf(fp, "\tenabled = %d\n", cwc->cwc_tcp_session.tcp_enabled);
|
||||
|
||||
|
||||
fprintf(fp, "}\n");
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
}
|
||||
/**
|
||||
*
|
||||
*/
|
||||
static int
|
||||
nibble(char c)
|
||||
{
|
||||
switch(c) {
|
||||
case '0' ... '9':
|
||||
return c - '0';
|
||||
case 'a' ... 'f':
|
||||
return c - 'a' + 10;
|
||||
case 'A' ... 'F':
|
||||
return c - 'A' + 10;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
const char *
|
||||
cwc_add(const char *hostname, const char *porttxt, const char *username,
|
||||
const char *password, const char *deskey, const char *enabled,
|
||||
int save, int salt)
|
||||
{
|
||||
const char *k;
|
||||
cwc_t *cwc;
|
||||
uint8_t key[14];
|
||||
|
||||
int i, u, l, port;
|
||||
|
||||
if(hostname == NULL || strlen(hostname) < 1)
|
||||
return "Invalid hostname";
|
||||
|
||||
if(porttxt == NULL)
|
||||
return "Invalid port";
|
||||
|
||||
port = atoi(porttxt);
|
||||
if(port < 1 || port > 65535)
|
||||
return "Invalid port";
|
||||
|
||||
if(username == NULL || strlen(username) < 1)
|
||||
return "Invalid username";
|
||||
if(password == NULL || strlen(password) < 1)
|
||||
return "Invalid password";
|
||||
|
||||
if(deskey == NULL)
|
||||
return "Invalid DES-key";
|
||||
|
||||
k = deskey;
|
||||
for(i = 0; i < 14; i++) {
|
||||
while(*k != 0 && !isxdigit(*k)) k++;
|
||||
if(*k == 0)
|
||||
break;
|
||||
u = nibble(*k++);
|
||||
while(*k != 0 && !isxdigit(*k)) k++;
|
||||
if(*k == 0)
|
||||
break;
|
||||
l = nibble(*k++);
|
||||
key[i] = (u << 4) | l;
|
||||
}
|
||||
|
||||
if(i != 14)
|
||||
return "DES-key does not contain 14 valid hexadecimal bytes";
|
||||
|
||||
if(enabled == NULL)
|
||||
return "Enabled not set";
|
||||
|
||||
cwc = tcp_create_client(hostname, port, sizeof(cwc_t),
|
||||
"cwc", cwc_tcp_callback, atoi(enabled));
|
||||
cwc->cwc_username = strdup(username);
|
||||
|
||||
if(salt) {
|
||||
cwc->cwc_password = strdup(cwc_krypt(password, "$1$abcdefgh$"));
|
||||
} else {
|
||||
cwc->cwc_password = strdup(password);
|
||||
}
|
||||
|
||||
cwc->cwc_id = ++cwc_tally;
|
||||
|
||||
memcpy(cwc->cwc_confedkey, key, 14);
|
||||
TAILQ_INSERT_TAIL(&cwcs, cwc, cwc_link);
|
||||
|
||||
if(save)
|
||||
cwc_save();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue