Example #1
0
static rc_t _KConfigGetAscp(const KConfig *self,
    const char **ascp_bin, const char **private_file)
{
    String *bin = NULL;
    String *key = NULL;
    assert(self && ascp_bin && private_file);
    *ascp_bin = *private_file = NULL;
    bin = _KConfigAscpString(self, "tools/ascp/path", "ascp");
    key = _KConfigAscpString(self, "tools/ascp/key", "Aspera key");
    if (bin != NULL && key != NULL) {
        *ascp_bin = string_dup_measure(bin->addr, NULL);
        *private_file = string_dup_measure(key->addr, NULL);
        free(bin);
        free(key);
        if (*ascp_bin == NULL || *private_file == NULL) {
            free((void*)*ascp_bin);
            free((void*)*private_file);
            *ascp_bin = *private_file = NULL;
            return RC(rcNS, rcStorage, rcAllocating, rcMemory, rcExhausted);
        }
        return 0;
    }
    free(bin);
    free(key);
    return 0;
}
Example #2
0
static rc_t _KConfigGetAscpRate(const KConfig *self,
    char *max_rate, size_t max_rate_sz)
{
    String *s = NULL;

    assert(self && max_rate && max_rate_sz);

    max_rate[0] = '\0';

    s = _KConfigAscpString(self, "tools/ascp/max_rate", "Aspera max rate");
    if (s != NULL) {
        if (s->size == 0) {
            free(s);
        }
        else {
            size_t sz = string_copy(max_rate, max_rate_sz, s->addr, s->size);

            free(s);

            if (sz >= max_rate_sz) {
                return RC(rcNS, rcNode, rcReading, rcBuffer, rcInsufficient);
            }
        }

        return 0;
    }

    return 0;
}
Example #3
0
static rc_t _KConfigGetAscpRate(const KConfig *self, const char **max_rate) {
    String *s = NULL;
    assert(self && max_rate);
    *max_rate = NULL;
    s = _KConfigAscpString(self, "tools/ascp/max_rate", "Aspera max rate");
    if (s != NULL) {
        if (s->size == 0) {
            free(s);
        }
        else {
            *max_rate = string_dup_measure(s->addr, NULL);
            free(s);
            if (*max_rate == NULL) {
                free((void*)*max_rate);
                return RC(rcNS, rcStorage, rcAllocating, rcMemory, rcExhausted);
            }
        }
        return 0;
    }
    return 0;
}