您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FileWriter函数代码示例

51自学网 2021-06-01 20:46:13
  C++
这篇教程C++ FileWriter函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中FileWriter函数的典型用法代码示例。如果您正苦于以下问题:C++ FileWriter函数的具体用法?C++ FileWriter怎么用?C++ FileWriter使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

在下文中一共展示了FileWriter函数的30个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: CallFunction

static FnCallResult CallFunction(EvalContext *ctx, const Policy *policy, const FnCall *fp, const Rlist *expargs){    const Rlist *rp = fp->args;    const FnCallType *fncall_type = FnCallTypeGet(fp->name);    int argnum = 0;    for (argnum = 0; rp != NULL && fncall_type->args[argnum].pattern != NULL; argnum++)    {        if (rp->val.type != RVAL_TYPE_FNCALL)        {            /* Nested functions will not match to lval so don't bother checking */            SyntaxTypeMatch err = CheckConstraintTypeMatch(fp->name, rp->val,                                                           fncall_type->args[argnum].dtype,                                                           fncall_type->args[argnum].pattern, 1);            if (err != SYNTAX_TYPE_MATCH_OK && err != SYNTAX_TYPE_MATCH_ERROR_UNEXPANDED)            {                FatalError(ctx, "In function '%s', error in variable '%s', '%s'", fp->name, (const char *)rp->val.item, SyntaxTypeMatchToString(err));            }        }        rp = rp->next;    }    char output[CF_BUFSIZE];    if (argnum != RlistLen(expargs) && !(fncall_type->options & FNCALL_OPTION_VARARG))    {        snprintf(output, CF_BUFSIZE, "Argument template mismatch handling function %s(", fp->name);        {            Writer *w = FileWriter(stderr);            RlistWrite(w, expargs);            FileWriterDetach(w);        }        fprintf(stderr, ")/n");        rp = expargs;        for (int i = 0; i < argnum; i++)        {            printf("  arg[%d] range %s/t", i, fncall_type->args[i].pattern);            if (rp != NULL)            {                Writer *w = FileWriter(stdout);                RvalWrite(w, rp->val);                FileWriterDetach(w);                rp = rp->next;            }            else            {                printf(" ? ");            }            printf("/n");        }        FatalError(ctx, "Bad arguments");    }    return (*fncall_type->impl) (ctx, policy, fp, expargs);}
开发者ID:bahamat,项目名称:cfengine-core,代码行数:59,


示例2: main

int main(int argc, char *argv[]){    EvalContext *ctx = EvalContextNew();    GenericAgentConfig *config = CheckOpts(ctx, argc, argv);    GenericAgentConfigApply(ctx, config);    GenericAgentDiscoverContext(ctx, config);    Policy *policy = GenericAgentLoadPolicy(ctx, config);    if (!policy)    {        Log(LOG_LEVEL_ERR, "Input files contain errors.");        exit(EXIT_FAILURE);    }    if (SHOWREPORTS)    {        ShowPromises(policy->bundles, policy->bodies);    }    switch (config->agent_specific.common.policy_output_format)    {    case GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_CF:        {            Policy *output_policy = ParserParseFile(config->input_file, config->agent_specific.common.parser_warnings,                                                    config->agent_specific.common.parser_warnings_error);            Writer *writer = FileWriter(stdout);            PolicyToString(policy, writer);            WriterClose(writer);            PolicyDestroy(output_policy);        }        break;    case GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_JSON:        {            Policy *output_policy = ParserParseFile(config->input_file, config->agent_specific.common.parser_warnings,                                                    config->agent_specific.common.parser_warnings_error);            JsonElement *json_policy = PolicyToJson(output_policy);            Writer *writer = FileWriter(stdout);            JsonWrite(writer, json_policy, 2);            WriterClose(writer);            JsonDestroy(json_policy);            PolicyDestroy(output_policy);        }        break;    case GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_NONE:        break;    }    GenericAgentConfigDestroy(config);    EvalContextDestroy(ctx);}
开发者ID:nperron,项目名称:core,代码行数:52,


示例3: QString

bool ValidatorGenerator::generate() const{    // Writes each files    QString output = QString(VALIDATOR_HEADER_TEMPLATE).arg(name.toUpper()).arg(name);    FileWriter(dstDir.filePath(name.toLower() + "validator.h")).write(output, false);    output = QString(VALIDATOR_IMPL_TEMPLATE).arg(name.toLower()).arg(name);    FileWriter(dstDir.filePath(name.toLower() + "validator.cpp")).write(output, false);    // Updates the project file    ProjectFileGenerator progen(dstDir.filePath("helpers.pro"));    QStringList files;    files << name.toLower() + "validator.h" << name.toLower() + "validator.cpp";    return progen.add(files);}
开发者ID:CasyWang,项目名称:treefrog-framework,代码行数:15,


示例4: WriteReleaseIdFile

/** * @brief Writes a file with a contained release ID based on git SHA, *        or file checksum if git SHA is not available. * @param filename the release_id file * @param dirname the directory to checksum or get the Git hash * @return True if successful */static bool WriteReleaseIdFile(const char *filename, const char *dirname){    char release_id[GENERIC_AGENT_CHECKSUM_SIZE];    bool have_release_id =        GeneratePolicyReleaseID(release_id, sizeof(release_id), dirname);    if (!have_release_id)    {        return false;    }    int fd = creat(filename, 0600);    if (fd == -1)    {        Log(LOG_LEVEL_ERR, "While writing policy release ID file '%s', could not create file (creat: %s)", filename, GetErrorStr());        return false;    }    JsonElement *info = JsonObjectCreate(3);    JsonObjectAppendString(info, "releaseId", release_id);    Writer *w = FileWriter(fdopen(fd, "w"));    JsonWrite(w, info, 0);    WriterClose(w);    JsonDestroy(info);    Log(LOG_LEVEL_VERBOSE, "Saved policy release ID file '%s'", filename);    return true;}
开发者ID:nishesj,项目名称:core,代码行数:38,


示例5: WritePolicyValidatedFile

/** * @brief Writes a file with a contained timestamp to mark a policy file as validated * @param filename the filename * @return True if successful. */static bool WritePolicyValidatedFile(ARG_UNUSED const GenericAgentConfig *config, const char *filename){    if (!MakeParentDirectory(filename, true))    {        Log(LOG_LEVEL_ERR, "While writing policy validated marker file '%s', could not create directory (MakeParentDirectory: %s)", filename, GetErrorStr());        return false;    }    int fd = creat(filename, 0600);    if (fd == -1)    {        Log(LOG_LEVEL_ERR, "While writing policy validated marker file '%s', could not create file (creat: %s)", filename, GetErrorStr());        return false;    }    JsonElement *info = JsonObjectCreate(3);    JsonObjectAppendInteger(info, "timestamp", time(NULL));    Writer *w = FileWriter(fdopen(fd, "w"));    JsonWrite(w, info, 0);    WriterClose(w);    JsonDestroy(info);    Log(LOG_LEVEL_VERBOSE, "Saved policy validated marker file '%s'", filename);    return true;}
开发者ID:nishesj,项目名称:core,代码行数:32,


示例6: GenerateAvahiConfig

static int GenerateAvahiConfig(const char *path){    FILE *fout;    Writer *writer = NULL;    fout = safe_fopen(path, "w+");    if (fout == NULL)    {        Log(LOG_LEVEL_ERR, "Unable to open '%s'", path);        return -1;    }    writer = FileWriter(fout);    fprintf(fout, "<?xml version=/"1.0/" standalone='no'?>/n");    fprintf(fout, "<!DOCTYPE service-group SYSTEM /"avahi-service.dtd/">/n");    XmlComment(writer, "This file has been automatically generated by cf-serverd.");    XmlStartTag(writer, "service-group", 0);    FprintAvahiCfengineTag(fout);    XmlStartTag(writer, "service", 0);    XmlTag(writer, "type", "_cfenginehub._tcp",0);    DetermineCfenginePort();    XmlStartTag(writer, "port", 0);    WriterWriteF(writer, "%d", CFENGINE_PORT);    XmlEndTag(writer, "port");    XmlEndTag(writer, "service");    XmlEndTag(writer, "service-group");    fclose(fout);    return 0;}
开发者ID:maciejmrowiec,项目名称:core,代码行数:28,


示例7: GenerateAvahiConfig

static int GenerateAvahiConfig(const char *path){    FILE *fout;    Writer *writer = NULL;    fout = fopen(path, "w+");    if (fout == NULL)    {        CfOut(cf_error, "", "Unable to open %s", path);        return -1;    }    writer = FileWriter(fout);    fprintf(fout, "<?xml version=/"1.0/" standalone='no'?>/n");    fprintf(fout, "<!DOCTYPE service-group SYSTEM /"avahi-service.dtd/">/n");    XmlComment(writer, "This file has been automatically generated by cf-serverd.");    XmlStartTag(writer, "service-group", 0);#ifdef HAVE_NOVA    fprintf(fout,"<name replace-wildcards=/"yes/" >CFEngine Enterprise %s Policy Hub on %s </name>/n", Version(), "%h");#else    fprintf(fout,"<name replace-wildcards=/"yes/" >CFEngine Community %s Policy Server on %s </name>/n", Version(), "%h");#endif    XmlStartTag(writer, "service", 0);    XmlTag(writer, "type", "_cfenginehub._tcp",0);    DetermineCfenginePort();    XmlTag(writer, "port", STR_CFENGINEPORT, 0);    XmlEndTag(writer, "service");    XmlEndTag(writer, "service-group");    fclose(fout);    return 0;}
开发者ID:cf-gary,项目名称:core,代码行数:30,


示例8: XmlManual

void XmlManual(const char *mandir, FILE *fout){    Writer *writer = NULL;    int i;    SubTypeSyntax *st = NULL;    MANUAL_DIRECTORY = (char *) mandir;    AddSlash(MANUAL_DIRECTORY);    writer = FileWriter(fout);/* XML HEADER */    XmlComment(writer, "AUTOGENERATED SYNTAX DOCUMENTATION BY CF-KNOW");    WriterWrite(writer, "/n");/* START XML ELEMENT -- SYNTAX-DOCUMENTATION */    XmlStartTag(writer, XMLTAG_DOC_ROOT, 0);/* SPECIAL VARIABLES */    XmlStartTag(writer, XMLTAG_VARSCOPES_ROOT, 0);    XmlExportVariables(writer, "const");    XmlExportVariables(writer, "edit");    XmlExportVariables(writer, "match");    XmlExportVariables(writer, "mon");    XmlExportVariables(writer, "sys");    XmlExportVariables(writer, "this");    XmlEndTag(writer, XMLTAG_VARSCOPES_ROOT);/* SPECIAL FUNCTIONS */    XmlStartTag(writer, XMLTAG_FUNCTIONS_ROOT, 0);    for (i = 0; CF_FNCALL_TYPES[i].name != NULL; i++)    {        XmlExportFunction(writer, CF_FNCALL_TYPES[i]);    }    XmlEndTag(writer, XMLTAG_FUNCTIONS_ROOT);/* CONTROL */    XmlStartTag(writer, XMLTAG_CONTROLS_ROOT, 0);    for (i = 0; CF_ALL_BODIES[i].btype != NULL; i++)    {        XmlExportControl(writer, CF_ALL_BODIES[i]);    }    XmlEndTag(writer, XMLTAG_CONTROLS_ROOT);/* PROMISE TYPES */    XmlStartTag(writer, XMLTAG_PROMISETYPES_ROOT, 0);    for (i = 0; i < CF3_MODULES; i++)    {        st = CF_ALL_SUBTYPES[i];        XmlExportPromiseType(writer, st);    }    XmlEndTag(writer, XMLTAG_PROMISETYPES_ROOT);/* END XML ELEMENT -- SYNTAX-DOCUMENTATION */    XmlEndTag(writer, XMLTAG_DOC_ROOT);    WriterClose(writer);}
开发者ID:joegen,项目名称:sipx-externals,代码行数:58,


示例9: time

Policy *GenericAgentLoadPolicy(EvalContext *ctx, GenericAgentConfig *config){    config->policy_last_read_attempt = time(NULL);    StringSet *parsed_files = StringSetNew();    StringSet *failed_files = StringSetNew();    Policy *policy = LoadPolicyFile(ctx, config, config->input_file, parsed_files, failed_files);    if (StringSetSize(failed_files) > 0)    {        Log(LOG_LEVEL_ERR, "There are syntax errors in policy files");        exit(EXIT_FAILURE);    }    StringSetDestroy(parsed_files);    StringSetDestroy(failed_files);    {        Seq *errors = SeqNew(100, PolicyErrorDestroy);        if (PolicyCheckPartial(policy, errors))        {            if (!config->bundlesequence && (PolicyIsRunnable(policy) || config->check_runnable))            {                Log(LOG_LEVEL_VERBOSE, "Running full policy integrity checks");                PolicyCheckRunnable(ctx, policy, errors, config->ignore_missing_bundles);            }        }        if (SeqLength(errors) > 0)        {            Writer *writer = FileWriter(stderr);            for (size_t i = 0; i < errors->length; i++)            {                PolicyErrorWrite(writer, errors->data[i]);            }            WriterClose(writer);            exit(EXIT_FAILURE); // TODO: do not exit        }        SeqDestroy(errors);    }    if (LogGetGlobalLevel() >= LOG_LEVEL_VERBOSE)    {        ShowContext(ctx);    }    if (policy)    {        VerifyPromises(ctx, policy, config);    }    return policy;}
开发者ID:nperron,项目名称:core,代码行数:56,


示例10: WaitForSingleObject

void ArrayStringCount::writeToDisk(std::string& file_name){    WaitForSingleObject(gHashWriteSemaphone, INFINITE);    {        FileWriter FW = FileWriter(file_name);        FW.write(this->start, this->start_offset - this->start);        this->total_write += (this->start_offset - this->start);        this->start_offset = this->start;    }    ReleaseSemaphore(gHashWriteSemaphone, 1, NULL);}
开发者ID:arunxls,项目名称:InvertedLinks,代码行数:11,


示例11: DumpErrors

static void DumpErrors(Seq *errs){    if (SeqLength(errs) > 0)    {        Writer *writer = FileWriter(stdout);        for (size_t i = 0; i < errs->length; i++)        {            PolicyErrorWrite(writer, errs->data[i]);        }        FileWriterDetach(writer);    }}
开发者ID:modulistic,项目名称:cfengine__core,代码行数:12,


示例12: test_empty_file_buffer

void test_empty_file_buffer(void **p){    global_w = StringWriter();    global_w_closed = false;    Writer *w = FileWriter(NULL);    assert_int_equal(StringWriterLength(global_w), 0);    assert_string_equal(StringWriterData(global_w), "");    WriterClose(w);    WriterClose(global_w);    assert_int_equal(global_w_closed, true);}
开发者ID:FancsalMelinda,项目名称:core,代码行数:13,


示例13: test_write_file_buffer

void test_write_file_buffer(void **p){    global_w = StringWriter();    Writer *w = FileWriter(NULL);    WriterWrite(w, "123");    assert_int_equal(StringWriterLength(global_w), 3);    assert_string_equal(StringWriterData(global_w), "123");    WriterClose(w);    WriterClose(global_w);    assert_int_equal(global_w_closed, true);}
开发者ID:FancsalMelinda,项目名称:core,代码行数:14,


示例14: FileWriter

void Simulation::writeFile(std::string path, int channels, double duration, bool mayApplyMixingMatrix) {	int blocks = (duration*getSr()/block_size)+1;	auto file = FileWriter();	file.open(path.c_str(), sr, channels);	//vectors are guaranteed to be contiguous. Using a vector here guarantees proper cleanup.	std::vector<float> block;	block.resize(channels*getBlockSize());	for(int i = 0; i < blocks; i++) {		getBlock(&block[0], channels, mayApplyMixingMatrix);		unsigned int written= 0;		while(written < getBlockSize()) written += file.write(getBlockSize(), &block[0]);	}	file.close();}
开发者ID:moshverhavikk,项目名称:libaudioverse,代码行数:14,


示例15: pro

bool ProjectFileGenerator::remove(const QStringList &files){    QString output;    QFile pro(filePath);    if (pro.exists()) {        if (pro.open(QIODevice::ReadOnly | QIODevice::Text)) {            output = pro.readAll();        } else {            qCritical("failed to open file: %s", qPrintable(pro.fileName()));            return false;        }    } else {        qCritical("Project file not found: %s", qPrintable(pro.fileName()));        return false;    }    pro.close();    if (files.isEmpty())        return true;    for (QStringListIterator i(files); i.hasNext(); ) {        QString f = QFileInfo(i.next()).fileName();        QString str;        QRegExp rx("*.h");        rx.setPatternSyntax(QRegExp::Wildcard);        if (rx.exactMatch(f)) {            str  = "HEADERS += ";            str += f;            str += '/n';        } else {            rx.setPattern("*.cpp");            if (rx.exactMatch(f)) {                str  = "SOURCES += ";                str += f;                str += '/n';            }        }                int idx = 0;        if (!str.isEmpty() && (idx = output.indexOf(str)) >= 0 ) {            output.remove(idx, str.length());        }    }    return FileWriter(filePath).write(output, true);}
开发者ID:Keloran,项目名称:treefrog-framework,代码行数:47,


示例16: pro

bool ProjectFileGenerator::add(const QStringList &files){    QString output;    QFile pro(filePath);    if (!pro.exists()) {        qCritical("Project file not found: %s", qPrintable(pro.fileName()));        return false;    } else {        if (pro.open(QIODevice::ReadOnly | QIODevice::Text)) {            output = pro.readAll();        } else {            qCritical("failed to open file: %s", qPrintable(pro.fileName()));            return false;        }    }    pro.close();    for (QStringListIterator i(files); i.hasNext(); ) {        const QString &f = i.next();        QString str;        QRegExp rx("*.h");        rx.setPatternSyntax(QRegExp::Wildcard);        if (rx.exactMatch(f)) {            str  = "HEADERS += ";            str += f;            str += '/n';        } else {            rx.setPattern("*.cpp");            if (rx.exactMatch(f)) {                str  = "SOURCES += ";                str += f;                str += '/n';            }        }                if (!str.isEmpty() && !output.contains(str)) {            if (!output.endsWith('/n')) {                output += '/n';            }            output += str;        }    }    return FileWriter(filePath).write(output, true);}
开发者ID:deniskin82,项目名称:treefrog-framework,代码行数:46,


示例17: tempnam

static Seq *LoadAndCheckString(const char *policy_code){    const char *tmp = tempnam(NULL, "cfengine_test");    {        FILE *out = fopen(tmp, "w");        Writer *w = FileWriter(out);        WriterWrite(w, policy_code);        WriterClose(w);    }    Policy *p = ParserParseFile(tmp, PARSER_WARNING_ALL, PARSER_WARNING_ALL);    assert_true(p);    Seq *errs = SeqNew(10, PolicyErrorDestroy);    PolicyCheckPartial(p, errs);    unlink(tmp);    return errs;}
开发者ID:modulistic,项目名称:cfengine__core,代码行数:21,


示例18: Mesh

bool MeshManager::convertMeshToNativeFormat(const String& name){    auto mesh = Mesh();    if (!MeshFormatRegistry::loadMeshFile(Mesh::MeshDirectory + name, mesh))    {        LOG_ERROR << "Failed converting mesh: " << name;        return false;    }    try    {        auto file = FileWriter();        fileSystem().open(Mesh::MeshDirectory + name + Mesh::MeshExtension, file);        file.write(mesh);    }    catch (const Exception& e)    {        LOG_ERROR << name << " - " << e;        return false;    }    return true;}
开发者ID:savant-nz,项目名称:carbon,代码行数:23,


示例19: GetPendingReportsJsonFilepath

void FPendingReports::Save() const{	auto PendingReportsPath = GetPendingReportsJsonFilepath();	// Ensure directory structure exists	FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree(*FPaths::GetPath(PendingReportsPath));		FJsonReportArray JsonReports;	for (auto Path : Reports)	{		JsonReports.Push(MakeShareable(new FJsonValueString(Path)));	}		TSharedRef<FJsonObject> JsonRootObject = MakeShareable(new FJsonObject);	JsonRootObject->SetArrayField(ReportsArrayFieldName, JsonReports);	TUniquePtr<FArchive> FileWriter(IFileManager::Get().CreateFileWriter(*PendingReportsPath));	if (!FileWriter)	{		UE_LOG(CrashReportClientLog, Warning, TEXT("Failed to save pending reports JSON file"));		return;	}	FJsonSerializer::Serialize(JsonRootObject, FPrettyJsonWriter::Create(FileWriter.Get()));}
开发者ID:RandomDeveloperM,项目名称:UE4_Hairworks,代码行数:24,


示例20: CFTestD_Help

void CFTestD_Help(){    Writer *w = FileWriter(stdout);    WriterWriteHelp(w, "cf-testd", OPTIONS, HINTS, true, NULL);    FileWriterDetach(w);}
开发者ID:kkaempf,项目名称:core,代码行数:6,


示例21: StringSetNew

Policy *LoadPolicy(EvalContext *ctx, GenericAgentConfig *config){    StringSet *parsed_files_and_checksums = StringSetNew();    StringSet *failed_files = StringSetNew();    Policy *policy = LoadPolicyFile(ctx, config, config->input_file, parsed_files_and_checksums, failed_files);    if (StringSetSize(failed_files) > 0)    {        Log(LOG_LEVEL_ERR, "There are syntax errors in policy files");        exit(EXIT_FAILURE);    }    StringSetDestroy(parsed_files_and_checksums);    StringSetDestroy(failed_files);    {        Seq *errors = SeqNew(100, PolicyErrorDestroy);        if (PolicyCheckPartial(policy, errors))        {            if (!config->bundlesequence && (PolicyIsRunnable(policy) || config->check_runnable))            {                Log(LOG_LEVEL_VERBOSE, "Running full policy integrity checks");                PolicyCheckRunnable(ctx, policy, errors, config->ignore_missing_bundles);            }        }        if (SeqLength(errors) > 0)        {            Writer *writer = FileWriter(stderr);            for (size_t i = 0; i < errors->length; i++)            {                PolicyErrorWrite(writer, errors->data[i]);            }            WriterClose(writer);            exit(EXIT_FAILURE); // TODO: do not exit        }        SeqDestroy(errors);    }    if (LogGetGlobalLevel() >= LOG_LEVEL_VERBOSE)    {        ShowContext(ctx);    }    if (policy)    {        for (size_t i = 0; i < SeqLength(policy->bundles); i++)        {            Bundle *bp = SeqAt(policy->bundles, i);            EvalContextStackPushBundleFrame(ctx, bp, NULL, false);            for (size_t j = 0; j < SeqLength(bp->promise_types); j++)            {                PromiseType *sp = SeqAt(bp->promise_types, j);                EvalContextStackPushPromiseTypeFrame(ctx, sp);                for (size_t ppi = 0; ppi < SeqLength(sp->promises); ppi++)                {                    Promise *pp = SeqAt(sp->promises, ppi);                    ExpandPromise(ctx, pp, CommonEvalPromise, NULL);                }                EvalContextStackPopFrame(ctx);            }            EvalContextStackPopFrame(ctx);        }        PolicyResolve(ctx, policy, config);        // TODO: need to move this inside PolicyCheckRunnable eventually.        if (!config->bundlesequence && config->check_runnable)        {            // only verify policy-defined bundlesequence for cf-agent, cf-promises            if ((config->agent_type == AGENT_TYPE_AGENT) ||                (config->agent_type == AGENT_TYPE_COMMON))            {                if (!VerifyBundleSequence(ctx, policy, config))                {                    FatalError(ctx, "Errors in promise bundles: could not verify bundlesequence");                }            }        }    }    JsonElement *validated_doc = ReadReleaseIdFileFromInputs();    if (validated_doc)    {        const char *release_id = JsonObjectGetAsString(validated_doc, "releaseId");        if (release_id)        {            policy->release_id = xstrdup(release_id);        }        JsonDestroy(validated_doc);    }    return policy;//.........这里部分代码省略.........
开发者ID:lra,项目名称:core,代码行数:101,


示例22: GenericAgentConfigNewDefault

static GenericAgentConfig *CheckOpts(int argc, char **argv){    extern char *optarg;    int optindex = 0;    int c;    char ld_library_path[CF_BUFSIZE];    GenericAgentConfig *config = GenericAgentConfigNewDefault(AGENT_TYPE_EXECUTOR);    while ((c = getopt_long(argc, argv, "dvnKIf:D:N:VxL:hFOV1gMWlC::", OPTIONS, &optindex)) != EOF)    {        switch ((char) c)        {        case 'l':            LEGACY_OUTPUT = true;            break;        case 'f':            GenericAgentConfigSetInputFile(config, GetInputDir(), optarg);            MINUSF = true;            break;        case 'd':            LogSetGlobalLevel(LOG_LEVEL_DEBUG);            break;        case 'K':            config->ignore_locks = true;            break;        case 'D':            config->heap_soft = StringSetFromString(optarg, ',');            break;        case 'N':            config->heap_negated = StringSetFromString(optarg, ',');            break;        case 'I':            LogSetGlobalLevel(LOG_LEVEL_INFO);            break;        case 'v':            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);            NO_FORK = true; // TODO: really?            break;        case 'n':            DONTDO = true;            config->ignore_locks = true;            break;        case 'L':            snprintf(ld_library_path, CF_BUFSIZE - 1, "LD_LIBRARY_PATH=%s", optarg);            putenv(xstrdup(ld_library_path));            break;        case 'W':            WINSERVICE = false;            break;        case 'F':            NO_FORK = true;            break;        case 'O':            ONCE = true;            NO_FORK = true;            break;        case 'V':            {                Writer *w = FileWriter(stdout);                GenericAgentWriteVersion(w);                FileWriterDetach(w);            }            exit(EXIT_SUCCESS);        case 'h':            {                Writer *w = FileWriter(stdout);                GenericAgentWriteHelp(w, "cf-execd", OPTIONS, HINTS, true);                FileWriterDetach(w);            }            exit(EXIT_SUCCESS);        case 'M':            {                Writer *out = FileWriter(stdout);                ManPageWrite(out, "cf-execd", time(NULL),                             CF_EXECD_SHORT_DESCRIPTION,                             CF_EXECD_MANPAGE_LONG_DESCRIPTION,                             OPTIONS, HINTS,                             true);                FileWriterDetach(out);                exit(EXIT_SUCCESS);            }        case 'x':            Log(LOG_LEVEL_ERR, "Self-diagnostic functionality is retired.");            exit(EXIT_SUCCESS);//.........这里部分代码省略.........
开发者ID:shreyu82,项目名称:core,代码行数:101,


示例23: GenericAgentConfigNewDefault

GenericAgentConfig *CheckOpts(int argc, char **argv){    extern char *optarg;    int c;    GenericAgentConfig *config = GenericAgentConfigNewDefault(AGENT_TYPE_SERVER, GetTTYInteractive());    while ((c = getopt_long(argc, argv, "dvIKf:D:N:VSxLFMhAC::l",                            OPTIONS, NULL))           != -1)    {        switch (c)        {        case 'f':            GenericAgentConfigSetInputFile(config, GetInputDir(), optarg);            MINUSF = true;            break;        case 'd':            LogSetGlobalLevel(LOG_LEVEL_DEBUG);            NO_FORK = true;            break;        case 'K':            config->ignore_locks = true;            break;        case 'D':            {                StringSet *defined_classes = StringSetFromString(optarg, ',');                if (! config->heap_soft)                {                    config->heap_soft = defined_classes;                }                else                {                    StringSetJoin(config->heap_soft, defined_classes);                    free(defined_classes);                }            }            break;        case 'N':            {                StringSet *negated_classes = StringSetFromString(optarg, ',');                if (! config->heap_negated)                {                    config->heap_negated = negated_classes;                }                else                {                    StringSetJoin(config->heap_negated, negated_classes);                    free(negated_classes);                }            }            break;        case 'I':            LogSetGlobalLevel(LOG_LEVEL_INFO);            break;        case 'v':            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);            NO_FORK = true;            break;        case 'F':            NO_FORK = true;            break;        case 'L':        {            static char ld_library_path[CF_BUFSIZE]; /* GLOBAL_A */            Log(LOG_LEVEL_VERBOSE, "Setting LD_LIBRARY_PATH to '%s'", optarg);            snprintf(ld_library_path, CF_BUFSIZE - 1, "LD_LIBRARY_PATH=%s", optarg);            putenv(ld_library_path);            break;        }        case 'V':            {                Writer *w = FileWriter(stdout);                GenericAgentWriteVersion(w);                FileWriterDetach(w);            }            exit(EXIT_SUCCESS);        case 'h':            {                Writer *w = FileWriter(stdout);                WriterWriteHelp(w, "cf-serverd", OPTIONS, HINTS, true, NULL);                FileWriterDetach(w);            }            exit(EXIT_SUCCESS);        case 'M':            {                Writer *out = FileWriter(stdout);                ManPageWrite(out, "cf-serverd", time(NULL),                             CF_SERVERD_SHORT_DESCRIPTION,                             CF_SERVERD_MANPAGE_LONG_DESCRIPTION,//.........这里部分代码省略.........
开发者ID:maciejmrowiec,项目名称:core,代码行数:101,


示例24: GenericAgentConfigNewDefault

static GenericAgentConfig *CheckOpts(int argc, char **argv){    extern char *optarg;    int optindex = 0;    int c;    GenericAgentConfig *config = GenericAgentConfigNewDefault(AGENT_TYPE_KEYGEN);    while ((c = getopt_long(argc, argv, "dvf:VMp:sr:t:hl:C::", OPTIONS, &optindex)) != EOF)    {        switch ((char) c)        {        case 'f':            KEY_PATH = optarg;            break;        case 'd':            LogSetGlobalLevel(LOG_LEVEL_DEBUG);            break;        case 'V':            PrintVersion();            exit(0);        case 'v':            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);            break;        case 'p': /* print digest */            print_digest_arg = optarg;            break;        case 's':            SHOWHOSTS = true;            break;        case 'r':            REMOVEKEYS = true;            remove_keys_host = optarg;            break;        case 'l':            LICENSE_INSTALL = true;            strlcpy(LICENSE_SOURCE, optarg, sizeof(LICENSE_SOURCE));            break;        case 't':            trust_key_arg = optarg;            break;        case 'h':            PrintHelp("cf-key", OPTIONS, HINTS, false);            exit(0);        case 'M':            {                Writer *out = FileWriter(stdout);                ManPageWrite(out, "cf-key", time(NULL),                             CF_KEY_SHORT_DESCRIPTION,                             CF_KEY_MANPAGE_LONG_DESCRIPTION,                             OPTIONS, HINTS,                             false);                FileWriterDetach(out);                exit(EXIT_SUCCESS);            }        case 'C':            if (!GenericAgentConfigParseColor(config, optarg))            {                exit(EXIT_FAILURE);            }            break;        default:            PrintHelp("cf-key", OPTIONS, HINTS, false);            exit(1);        }    }    return config;}
开发者ID:JarleB,项目名称:core,代码行数:81,


示例25: CFTestD_ConfigInit

CFTestD_Config *CFTestD_CheckOpts(int argc, char **argv, long *n_threads){    extern char *optarg;    int c;    CFTestD_Config *config = CFTestD_ConfigInit();    assert(config != NULL);    while ((c = getopt_long(argc, argv, "a:df:g:hIj:k:lp:vV", OPTIONS, NULL)) != -1)    {        switch (c)        {        case 'a':            config->address = xstrdup(optarg);            break;        case 'd':            LogSetGlobalLevel(LOG_LEVEL_DEBUG);            break;        case 'h':            CFTestD_Help();            exit(EXIT_SUCCESS);        case 'I':            LogSetGlobalLevel(LOG_LEVEL_INFO);            break;        case 'g':            LogSetGlobalLevelArgOrExit(optarg);            break;        case 'j':        {            int ret = StringToLong(optarg, n_threads);            if (ret != 0)            {                Log(LOG_LEVEL_ERR, "Failed to parse number of threads/jobs from '%s'/n", optarg);                *n_threads = 1;            }            break;        }        case 'k':            config->key_file = xstrdup(optarg);            break;        case 'l':            LoggingEnableTimestamps(true);            break;        case 'p':        {            bool ret = SetCfenginePort(optarg);            if (!ret)            {                /* the function call above logs an error for us (if any) */                exit(EXIT_FAILURE);            }            break;        }        case 'r':            config->report_file = xstrdup(optarg);            break;        case 'v':            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);            break;        case 'V':        {            Writer *w = FileWriter(stdout);            GenericAgentWriteVersion(w);            FileWriterDetach(w);        }            exit(EXIT_SUCCESS);        default:            CFTestD_Help();            exit(EXIT_FAILURE);        }    }    if (optind < argc) // More unparsed arguments left after getopt_long    {        // Enumerate and print all invalid arguments:        Log(LOG_LEVEL_ERR, "Invalid command line arguments:");        int start = optind;        int stop  = argc;        int total = stop - start;        for (int i = 0; i < total; ++i)        {            Log(LOG_LEVEL_ERR,                "[%d/%d]: %s/n",                i + 1,                total,                argv[start + i]);        }    }    return config;}
开发者ID:kkaempf,项目名称:core,代码行数:91,


示例26: RvalShow

void RvalShow(FILE *fp, Rval rval){    Writer *w = FileWriter(fp);    RvalWrite(w, rval);    FileWriterDetach(w);}
开发者ID:ouafae31,项目名称:core,代码行数:6,


示例27: ShowContext

static void ShowContext(EvalContext *ctx){    {        Writer *w = NULL;        if (LEGACY_OUTPUT)        {            w = FileWriter(stdout);            WriterWriteF(w, "%s>  -> Hard classes = {", VPREFIX);        }        else        {            w = StringWriter();            WriterWrite(w, "Discovered hard classes:");        }        Seq *hard_contexts = SeqNew(1000, NULL);        SetIterator it = EvalContextHeapIteratorHard(ctx);        char *context = NULL;        while ((context = SetIteratorNext(&it)))        {            if (!EvalContextHeapContainsNegated(ctx, context))            {                SeqAppend(hard_contexts, context);            }        }        SeqSort(hard_contexts, (SeqItemComparator)strcmp, NULL);        for (size_t i = 0; i < SeqLength(hard_contexts); i++)        {            const char *context = SeqAt(hard_contexts, i);            WriterWriteF(w, " %s", context);        }        if (LEGACY_OUTPUT)        {            WriterWrite(w, "}/n");            FileWriterDetach(w);        }        else        {            Log(LOG_LEVEL_VERBOSE, "%s", StringWriterData(w));            WriterClose(w);        }        SeqDestroy(hard_contexts);    }    {        Writer *w = NULL;        if (LEGACY_OUTPUT)        {            w = FileWriter(stdout);            WriterWriteF(w, "%s>  -> Additional classes = {", VPREFIX);        }        else        {            w = StringWriter();            WriterWrite(w, "Additional classes:");        }        Seq *soft_contexts = SeqNew(1000, NULL);        SetIterator it = EvalContextHeapIteratorSoft(ctx);        char *context = NULL;        while ((context = SetIteratorNext(&it)))        {            if (!EvalContextHeapContainsNegated(ctx, context))            {                SeqAppend(soft_contexts, context);            }        }        SeqSort(soft_contexts, (SeqItemComparator)strcmp, NULL);        for (size_t i = 0; i < SeqLength(soft_contexts); i++)        {            const char *context = SeqAt(soft_contexts, i);            WriterWriteF(w, " %s", context);        }        if (LEGACY_OUTPUT)        {            WriterWrite(w, "}/n");            FileWriterDetach(w);        }        else        {            if (SeqLength(soft_contexts) > 0)            {                Log(LOG_LEVEL_VERBOSE, "%s", StringWriterData(w));            }            WriterClose(w);        }        SeqDestroy(soft_contexts);    }    {        bool have_negated_classes = false;//.........这里部分代码省略.........
开发者ID:nperron,项目名称:core,代码行数:101,


示例28: GenericAgentConfigNewDefault

//.........这里部分代码省略.........                GenericAgentConfigSetBundleSequence(config, bundlesequence);                RlistDestroy(bundlesequence);            }            break;        case 'p':            if (strcmp("none", optarg) == 0)            {                config->agent_specific.common.policy_output_format = GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_NONE;            }            else if (strcmp("cf", optarg) == 0)            {                config->agent_specific.common.policy_output_format = GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_CF;            }            else if (strcmp("json", optarg) == 0)            {                config->agent_specific.common.policy_output_format = GENERIC_AGENT_CONFIG_COMMON_POLICY_OUTPUT_FORMAT_JSON;            }            else            {                Log(LOG_LEVEL_ERR, "Invalid policy output format: '%s'. Possible values are 'none', 'cf', 'json'", optarg);                exit(EXIT_FAILURE);            }            break;        case 's':            if (strcmp("none", optarg) == 0)            {                break;            }            else if (strcmp("json", optarg) == 0)            {                JsonElement *json_syntax = SyntaxToJson();                Writer *out = FileWriter(stdout);                JsonWrite(out, json_syntax, 0);                FileWriterDetach(out);                JsonDestroy(json_syntax);                exit(EXIT_SUCCESS);            }            else            {                Log(LOG_LEVEL_ERR, "Invalid syntax description output format: '%s'. Possible values are 'none', 'json'", optarg);                exit(EXIT_FAILURE);            }            break;        case 'K':            config->ignore_locks = true;            break;        case 'D':            config->heap_soft = StringSetFromString(optarg, ',');            break;        case 'N':            config->heap_negated = StringSetFromString(optarg, ',');            break;        case 'I':            LogSetGlobalLevel(LOG_LEVEL_INFO);            break;        case 'v':            LogSetGlobalLevel(LOG_LEVEL_VERBOSE);            break;
开发者ID:tzz,项目名称:core,代码行数:66,


示例29: ScheduleEditOperation

//.........这里部分代码省略.........        else        {            method_deref = edit_bundle_name;        }                Log(LOG_LEVEL_VERBOSE, "Handling file edits in edit_xml bundle '%s'", method_deref);        Bundle *bp = NULL;        if ((bp = PolicyGetBundle(policy, NULL, "edit_xml", method_deref)))        {            BannerSubBundle(bp, args);            EvalContextStackPushBundleFrame(ctx, bp, args, a.edits.inherit);            BundleResolve(ctx, bp);            ScheduleEditXmlOperations(ctx, bp, a, pp, edcontext);            EvalContextStackPopFrame(ctx);        }    }        if (a.edit_template)    {        if (!a.template_method || strcmp("cfengine", a.template_method) == 0)        {            Policy *tmp_policy = PolicyNew();            Bundle *bp = NULL;            if ((bp = MakeTemporaryBundleFromTemplate(ctx, tmp_policy, a, pp, &result)))            {                BannerSubBundle(bp, args);                a.haveeditline = true;                EvalContextStackPushBundleFrame(ctx, bp, args, a.edits.inherit);                BundleResolve(ctx, bp);                ScheduleEditLineOperations(ctx, bp, a, pp, edcontext);                EvalContextStackPopFrame(ctx);            }            PolicyDestroy(tmp_policy);        }        else if (strcmp("mustache", a.template_method) == 0)        {            if (!FileCanOpen(a.edit_template, "r"))            {                cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Template file '%s' could not be opened for reading", a.edit_template);                result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);                goto exit;            }            Writer *ouput_writer = NULL;            {                FILE *output_file = fopen(pp->promiser, "w");                if (!output_file)                {                    cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Output file '%s' could not be opened for writing", pp->promiser);                    result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);                    goto exit;                }                ouput_writer = FileWriter(output_file);            }            Writer *template_writer = FileRead(a.edit_template, SIZE_MAX, NULL);            if (!template_writer)            {                cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Could not read template file '%s'", a.edit_template);                result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);                WriterClose(ouput_writer);                goto exit;            }            JsonElement *default_template_data = NULL;            if (!a.template_data)            {                a.template_data = default_template_data = DefaultTemplateData(ctx);            }            if (!MustacheRender(ouput_writer, StringWriterData(template_writer), a.template_data))            {                cfPS(ctx, LOG_LEVEL_ERR, PROMISE_RESULT_FAIL, pp, a, "Error rendering mustache template '%s'", a.edit_template);                result = PromiseResultUpdate(result, PROMISE_RESULT_FAIL);                WriterClose(template_writer);                WriterClose(ouput_writer);                goto exit;            }            JsonDestroy(default_template_data);            WriterClose(template_writer);            WriterClose(ouput_writer);        }    }exit:    result = PromiseResultUpdate(result, FinishEditContext(ctx, edcontext, a, pp));    YieldCurrentLock(thislock);    return result;}
开发者ID:cduclos,项目名称:core,代码行数:101,


示例30: RlistShow

void RlistShow(FILE *fp, const Rlist *list){    Writer *w = FileWriter(fp);    RlistWrite(w, list);    FileWriterDetach(w);}
开发者ID:ouafae31,项目名称:core,代码行数:6,



注:本文中的FileWriter函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


C++ File_Close函数代码示例
C++ FileToString函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。