Welcome to mirror list, hosted at ThFree Co, Russian Federation.

crc.c « ext « aws-crt-php « aws - github.com/nextcloud/3rdparty.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8e520f8950d13de749b9fd6f37b473b13f86b730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/**
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#include "php_aws_crt.h"

PHP_FUNCTION(aws_crt_crc32) {
    zend_ulong prev = 0;
    const char *input = NULL;
    size_t len = 0;

    aws_php_parse_parameters("sl", &input, &len, &prev);

    if (prev > UINT32_MAX) {
        aws_php_throw_exception("previous crc cannot be larger than UINT32_MAX");
    }
    RETURN_LONG((zend_ulong)aws_crt_crc32((const uint8_t *)input, len, prev));
}

PHP_FUNCTION(aws_crt_crc32c) {
    zend_ulong prev = 0;
    const char *input = NULL;
    size_t len = 0;

    aws_php_parse_parameters("sl", &input, &len, &prev);

    if (prev > UINT32_MAX) {
        aws_php_throw_exception("previous crc cannot be larger than UINT32_MAX");
    }
    RETURN_LONG((zend_ulong)aws_crt_crc32c((const uint8_t *)input, len, prev));
}