void plus(SV* num1, ...) {
     Inline_Stack_Vars;
     int i;
     for(i = 0; i < Inline_Stack_Items; i++)
         printf("Hello %d!\n", SvPv(Inline_Stack_Item(i), PL_na));
         
         Inline_Stack_Void;
     
 }
 void greet(SV* name1, ...) {
         Inline_Stack_Vars;
         int i;
         int j;
         for (i = 0; i < Inline_Stack_Items; i++)
             j = 2 * SvPV(Inline_Stack_Item(i), PL_na);
             printf("Hello %s!\n", j);
             
         Inline_Stack_Void;
             }
示例#3
0
int BacnetReadPropertyMultiple(
    int deviceInstanceNumber,
    ...)
{
    /* Get the variable argument list from the stack */
    Inline_Stack_Vars;
    int rpmIndex = 1;
    BACNET_READ_ACCESS_DATA *rpm_object =
        calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
    BACNET_READ_ACCESS_DATA *Read_Access_Data = rpm_object;
    BACNET_PROPERTY_REFERENCE *rpm_property;
    uint8_t buffer[MAX_PDU] = { 0 };

    while (rpmIndex < Inline_Stack_Items) {
        SV *pSV = Inline_Stack_Item(rpmIndex++);

        /* Make sure the argument is an Array Reference */
        if (SvTYPE(SvRV(pSV)) != SVt_PVAV) {
            LogError("Argument is not an Array reference");
            break;
        }
        /* Make sure we can access the memory */
        if (rpm_object) {
            rpm_object->listOfProperties = NULL;
        } else {
            LogError("Memory Allocation Issue");
            break;
        }

        AV *pAV = (AV *) SvRV(pSV);
        SV **ppSV;

        /* The 0th argument is the object type */
        ppSV = av_fetch(pAV, 0, 0);
        if (ppSV) {
            rpm_object->object_type = SvIV(*ppSV);
        } else {
            LogError("Problem parsing the Array of arguments");
            break;
        }

        /* The 1st argument is the object instance */
        ppSV = av_fetch(pAV, 1, 0);
        if (ppSV) {
            rpm_object->object_instance = SvIV(*ppSV);
        } else {
            LogError("Problem parsing the Array of arguments");
            break;
        }

        /* The 2nd argument is the property type */
        ppSV = av_fetch(pAV, 2, 0);
        if (ppSV) {
            rpm_property = calloc(1, sizeof(BACNET_PROPERTY_REFERENCE));
            rpm_object->listOfProperties = rpm_property;
            if (rpm_property) {
                rpm_property->propertyIdentifier = SvIV(*ppSV);
            } else {
                LogError("Memory allocation error");
                break;
            }
        } else {
            LogError("Problem parsing the Array of arguments");
            break;
        }

        /* The 3rd argument is the property index */
        ppSV = av_fetch(pAV, 3, 0);
        if (ppSV) {
            rpm_property->propertyArrayIndex = SvIV(*ppSV);
        } else {
            LogError("Problem parsing the Array of arguments");
            break;
        }

        /* Advance to the next RPM index */
        if (rpmIndex < Inline_Stack_Items) {
            rpm_object->next = calloc(1, sizeof(BACNET_READ_ACCESS_DATA));
            rpm_object = rpm_object->next;
        } else {
            rpm_object->next = NULL;
        }
    }

    if (!isReadPropertyMultipleHandlerRegistered) {
        /* handle the data coming back from confirmed requests */
        apdu_set_confirmed_ack_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
            My_Read_Property_Multiple_Ack_Handler);

        /* handle any errors coming back */
        apdu_set_error_handler(SERVICE_CONFIRMED_READ_PROP_MULTIPLE,
            My_Error_Handler);

        /* indicate that handlers are now registered */
        isReadPropertyMultipleHandlerRegistered = true;
    }
    /* Send the message out */
    if (!Error_Detected) {
        Request_Invoke_ID =
            Send_Read_Property_Multiple_Request(&buffer[0], sizeof(buffer),
            deviceInstanceNumber, Read_Access_Data);
        Wait_For_Answer_Or_Timeout(100, waitAnswer);
    }
    /* Clean up allocated memory */
    BACNET_READ_ACCESS_DATA *old_rpm_object;
    BACNET_PROPERTY_REFERENCE *old_rpm_property;

    rpm_object = Read_Access_Data;
    old_rpm_object = rpm_object;
    while (rpm_object) {
        rpm_property = rpm_object->listOfProperties;
        while (rpm_property) {
            old_rpm_property = rpm_property;
            rpm_property = rpm_property->next;
            free(old_rpm_property);
        }
        old_rpm_object = rpm_object;
        rpm_object = rpm_object->next;
        free(old_rpm_object);
    }

    /* Process the return value */
    int isFailure = Error_Detected;
    Error_Detected = 0;
    return isFailure;
}