コード例 #1
0
ファイル: database.cpp プロジェクト: wxsBSD/osquery
Status deleteDatabaseRange(const std::string& domain,
                           const std::string& low,
                           const std::string& high) {
  if (domain.empty()) {
    return Status(1, "Missing domain");
  }

  if (RegistryFactory::get().external()) {
    // External registries (extensions) do not have databases active.
    // It is not possible to use an extension-based database.
    PluginRequest request = {{"action", "remove_range"},
                             {"domain", domain},
                             {"key", low},
                             {"key_high", high}};
    return Registry::call("database", request);
  }

  ReadLock lock(kDatabaseReset);
  if (!DatabasePlugin::kDBInitialized) {
    throw std::runtime_error("Cannot delete database values: " + low + " - " +
                             high);
  } else {
    auto plugin = getDatabasePlugin();
    return plugin->removeRange(domain, low, high);
  }
}
コード例 #2
0
ファイル: Program.cpp プロジェクト: 453483289/smartdec
BasicBlock *Program::createBasicBlock(ByteAddr address) {
    if (BasicBlock *result = getBasicBlockStartingAt(address)) {
        return result;
    } else if (BasicBlock *basicBlock = getBasicBlockCovering(address)) {
        removeRange(basicBlock);

        std::size_t i = 0;
        for (std::size_t size = basicBlock->statements().size(); i < size; ++i) {
            if (basicBlock->statements()[i]->instruction()->addr() >= address) {
                break;
            }
        }

        BasicBlock *result = takeOwnership(basicBlock->split(i, address));

        addRange(basicBlock);
        addRange(result);

        return result;
    } else {
        BasicBlock *result = takeOwnership(std::make_unique<BasicBlock>(address));
        addRange(result);

        return result;
    }
}
コード例 #3
0
ファイル: Vector.cpp プロジェクト: preda/pepper
void Vector<T>::insertAt(int pos, T v) {
    if (pos < size()) {
        removeRange(pos + 1, pos);
        buf()[pos] = v;
    } else {
        setExtend(pos, v);
    }
}
コード例 #4
0
ファイル: sndcut.c プロジェクト: CamiWilliams/C-Languages
int main(int argc, char* argv[])
{
    FILE* f;
    struct file input;
    int k;
    int lows[argc];
    int highs[argc];
    int high, low, numRanges = 0;

    input = getFileInfo("(standard input)", stdin);
    fclose(f);
    for(k = 1; k < argc; k++)
    {
        if(strncmp(argv[k], "-h", 2) == 0)
        {
            fprintf(stderr, "This program reads a sound file from the standard input stream and writes it to the standard output stream. It removes all samples specified as arguments. The arguments are written as low..high \n");
        }
        else
        {
            /*Looks for range*/
            if(sscanf(argv[k], "%d..%d", &low, &high) > 0)
            {
                if( low >= 0 && high <= input.samples)
                {
                    lows[numRanges] = low;
                    highs[numRanges] = high;
                    numRanges++;
                }
                else {
                    fprintf(stderr, "\nYou specified ranges outside of the file sample ranges\n");
                }
            }
        }
    }

    if(input.error == 0)
    {
        input = removeRange(lows, highs, numRanges, input);
        if(input.error == 5)
        {
            fprintf(stderr, "Error: Boundaries written incorrectly");
            printf("\n");
            return 0;
        }
    }
    if(input.type == 1)	{
        convert(input, stdout, 2);
    }
    else if(input.type == 2) {
        convert(input, stdout, 1);
    }
}
コード例 #5
0
String DemoContentComponent::trimPIP (const String& fileContents)
{
    auto lines = StringArray::fromLines (fileContents);

    auto metadataEndIndex = lines.indexOf (" END_JUCE_PIP_METADATA");

    if (metadataEndIndex == -1)
        return fileContents;

    lines.removeRange (0, metadataEndIndex + 3); // account for newline and comment block end

    return lines.joinIntoString ("\n");
}
コード例 #6
0
void SeasideCache::finalizeUpdate(SeasideFilteredModel::FilterType filter)
{
    const QList<QContactLocalId> queryIds = m_contactIdRequest.ids();
    QVector<QContactLocalId> &cacheIds = m_contacts[filter];

    if (m_cacheIndex < cacheIds.count())
        removeRange(filter, m_cacheIndex, cacheIds.count() - m_cacheIndex);

    if (m_queryIndex < queryIds.count()) {
        const int count = queryIds.count() - m_queryIndex;
        insertRange(filter, cacheIds.count(), count, queryIds, m_queryIndex);
    }

    m_cacheIndex = 0;
    m_queryIndex = 0;
}
コード例 #7
0
ファイル: Program.cpp プロジェクト: 453483289/smartdec
BasicBlock *Program::getBasicBlockForInstruction(const arch::Instruction *instruction) {
    /* If there is a basic block that starts here, just take it. */
    BasicBlock *result = getBasicBlockStartingAt(instruction->addr());

    if (!result) {
        /* Maybe this instruction stands next to an existing basic block? */
        result = getBasicBlockCovering(instruction->addr() - 1);

        /* No way? Create new block. */
        if (!result) {
            result = createBasicBlock(instruction->addr());
        }
    }

    removeRange(result);
    result->setSuccessorAddress(instruction->endAddr());
    addRange(result);

    return result;
}
コード例 #8
0
ファイル: Program.cpp プロジェクト: 8l/snowman
BasicBlock *Program::createBasicBlock(ByteAddr address) {
    if (BasicBlock *result = getBasicBlockStartingAt(address)) {
        return result;
    } else if (BasicBlock *basicBlock = getBasicBlockCovering(address)) {
        removeRange(basicBlock);

        auto iterator = std::find_if(basicBlock->statements().begin(), basicBlock->statements().end(), [address](const Statement *statement) {
            return statement->instruction()->addr() >= address;
        });

        BasicBlock *result = takeOwnership(basicBlock->split(iterator, address));

        addRange(basicBlock);
        addRange(result);

        return result;
    } else {
        BasicBlock *result = takeOwnership(std::make_unique<BasicBlock>(address));
        addRange(result);
        return result;
    }
}
コード例 #9
0
void VoxelEditor::removeSelected() {
    if(_selectedFirstBlock && _selectedSecondBlock) {
        removeRange(_selectedX1, _selectedY1, _selectedZ1, _selectedX2, _selectedY2, _selectedZ2);
    }
}