You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fprintf(stderr, "the socket-udp action requires 3 number arguments\n");
1205
+
fprintf(stderr, "the socket-udp action requires 2 number arguments\n");
1206
1206
if(!sts_value_reference_decrement(script, first_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp action");
1207
1207
if(!sts_value_reference_decrement(script, second_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the second argument in the socket-udp action");
fprintf(stderr, "the socket-set-broadcast action requires a socket argument and state\n");
1252
+
if(!sts_value_reference_decrement(script, first_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-set-broadcast action");
1253
+
if(!sts_value_reference_decrement(script, second_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the second argument in the socket-set-broadcast action");
if(!sts_value_reference_decrement(script, first_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-set-broadcast action");
1264
+
if(!sts_value_reference_decrement(script, second_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the second argument in the socket-set-broadcast action");
fprintf(stderr, "the socket-udp-send action requires a socket, the destination, destination port, and the data to send\n");
1460
+
if(!sts_value_reference_decrement(script, first_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-send action");
1461
+
if(!sts_value_reference_decrement(script, second_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the second argument in the socket-udp-send action");
1462
+
if(!sts_value_reference_decrement(script, third_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the third argument in the socket-udp-send action");
1463
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the fourth argument in the socket-udp-send action");
if(!sts_value_reference_decrement(script, first_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-send action");
1476
+
if(!sts_value_reference_decrement(script, second_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the second argument in the socket-udp-send action");
1477
+
if(!sts_value_reference_decrement(script, third_arg_value)) STS_ERROR_SIMPLE("could not decrement references for the third argument in the socket-udp-send action");
1478
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the fourth argument in the socket-udp-send action");
1479
+
}
1480
+
else {STS_ERROR_SIMPLE("socket-udp-send action requires a socket and a data string"); returnNULL;}
1481
+
}
1482
+
ACTION(elseif, "socket-udp-recv") /* returns a string of data from the socket. ret of 1 means would block, -1 means error, string is data */
1483
+
{
1484
+
GOTO_SET(&cli_actions);
1485
+
if(args->next)
1486
+
{
1487
+
EVAL_ARG(args->next);
1488
+
1489
+
if(!IS_CLI_SOCKET(eval_value))
1490
+
{
1491
+
fprintf(stderr, "the socket-udp-recv action requires a socket and the data to send\n");
1492
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
1493
+
returnNULL;
1494
+
}
1495
+
1496
+
/* first check if it would block and return a 1 instead of a string */
STS_ERROR_SIMPLE("could not create number retval in socket-udp-recv");
1503
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
1504
+
returnNULL;
1505
+
}
1506
+
1507
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
STS_ERROR_SIMPLE("could not resize temporary buffer in socket-udp-recv");
1526
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
1527
+
returnNULL;
1528
+
}
1529
+
1530
+
memcpy(&temp_str[temp_ulong], buf, temp_int);
1531
+
1532
+
temp_ulong+=temp_int;
1533
+
temp_str[temp_ulong] =0x0;
1534
+
} while(temp_int==sizeof(buf));
1535
+
1536
+
1537
+
/* return a number instead of a string */
1538
+
if(temp_int==-1)
1539
+
{
1540
+
if(!(ret=sts_value_from_number(script, -1)))
1541
+
{
1542
+
STS_ERROR_SIMPLE("could not create number retval in socket-udp-recv");
1543
+
if(temp_str) free(temp_str);
1544
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
1545
+
returnNULL;
1546
+
}
1547
+
1548
+
if(temp_str) free(temp_str);
1549
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
STS_ERROR_SIMPLE("could not create string retval in socket-udp-recv");
1557
+
if(temp_str) free(temp_str);
1558
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
1559
+
returnNULL;
1560
+
}
1561
+
1562
+
if(temp_str)
1563
+
{
1564
+
ret->string.length=temp_ulong;
1565
+
ret->string.data=temp_str;
1566
+
}
1567
+
else
1568
+
{
1569
+
ret->string.length=0;
1570
+
ret->string.data=sts_memdup("", 0);
1571
+
}
1572
+
1573
+
1574
+
if(!sts_value_reference_decrement(script, eval_value)) STS_ERROR_SIMPLE("could not decrement references for the first argument in the socket-udp-recv action");
1575
+
}
1576
+
else {STS_ERROR_SIMPLE("socket-tcp-send action requires a socket"); returnNULL;}
1577
+
}
1414
1578
ACTION(elseif, "socket-tcp-would-block") /* tests if a socket will block */
0 commit comments