本文整理汇总了C++中GetWorkDir函数的典型用法代码示例。如果您正苦于以下问题:C++ GetWorkDir函数的具体用法?C++ GetWorkDir怎么用?C++ GetWorkDir使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetWorkDir函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
EvalContext *ctx = EvalContextNew();
GenericAgentConfig *config = CheckOpts(argc, argv);
GenericAgentConfigApply(ctx, config);
GenericAgentDiscoverContext(ctx, config);
if (SHOWHOSTS)
{
ShowLastSeenHosts();
return 0;
}
if (print_digest_arg)
{
return PrintDigest(print_digest_arg);
}
if (REMOVEKEYS)
{
return RemoveKeys(remove_keys_host, true);
}
if(LICENSE_INSTALL)
{
bool success = LicenseInstall(LICENSE_SOURCE);
return success ? 0 : 1;
}
if (trust_key_arg)
{
return TrustKey(trust_key_arg);
}
char *public_key_file, *private_key_file;
if (KEY_PATH)
{
xasprintf(&public_key_file, "%s.pub", KEY_PATH);
xasprintf(&private_key_file, "%s.priv", KEY_PATH);
}
else
{
public_key_file = xstrdup(PublicKeyFile(GetWorkDir()));
private_key_file = xstrdup(PrivateKeyFile(GetWorkDir()));
}
KeepKeyPromises(public_key_file, private_key_file);
free(public_key_file);
free(private_key_file);
GenericAgentConfigDestroy(config);
EvalContextDestroy(ctx);
return 0;
}
示例2: snprintf
static FILE *NewStream(char *name)
{
FILE *fp;
char filename[CF_BUFSIZE];
if (OUTPUT_DIRECTORY[0] != '\0')
{
snprintf(filename, CF_BUFSIZE, "%s/%s_runagent.out", OUTPUT_DIRECTORY, name);
}
else
{
snprintf(filename, CF_BUFSIZE, "%s%coutputs%c%s_runagent.out",
GetWorkDir(), FILE_SEPARATOR, FILE_SEPARATOR, name);
}
if (OUTPUT_TO_FILE)
{
printf("Opening file... %s\n", filename);
if ((fp = fopen(filename, "w")) == NULL)
{
Log(LOG_LEVEL_ERR, "Unable to open file '%s' (fopen: %s)", filename, GetErrorStr());
fp = stdout;
}
}
else
{
fp = stdout;
}
return fp;
}
示例3: GetWorkDir
BOOL CADHelper::WriteLaunchInfo()
{
CString CurrentPath = GetWorkDir();
if( !writeTestKeybyWinAPI( CurrentPath ) ) return FALSE;
if( !MotifiInfomationKey( 0 ) ) return FALSE;
return TRUE;
}
示例4: TestExpandVariables
void TestExpandVariables()
{
Promise pp = { 0 }, *pcopy;
Rlist *args, *listvars = NULL, *scalarvars = NULL;
Constraint *cp;
FnCall *fp;
strcpy(CFWORKDIR, GetWorkDir());
MapName(CFWORKDIR);
/* Still have diagnostic scope */
NewScope("control_common");
printf("%d. Testing variable expansion\n", ++NR);
pp.promiser = "the originator";
pp.promisee = (Rval) {"the recipient with $(two)", CF_SCALAR};
pp.classes = "proletariat";
pp.offset.line = 12;
pp.audit = NULL;
pp.conlist = NULL;
pp.agentsubtype = "none";
pp.bundletype = "bundle_type";
pp.bundle = "test_bundle";
pp.ref = "commentary";
pp.agentsubtype = xstrdup("files");
pp.done = false;
pp.next = NULL;
pp.cache = NULL;
pp.inode_cache = NULL;
pp.this_server = NULL;
pp.donep = &(pp.done);
pp.conn = NULL;
args = SplitStringAsRList("$(administrator)", ',');
fp = NewFnCall("getuid", args);
AppendConstraint(&(pp.conlist), "lval1", (Rval) {xstrdup("@(one)"), CF_SCALAR}, "lower classes1", false);
AppendConstraint(&(pp.conlist), "lval2", (Rval) {xstrdup("$(four)"), CF_SCALAR}, "upper classes1", false);
AppendConstraint(&(pp.conlist), "lval3", (Rval) {fp, CF_FNCALL}, "upper classes2", false);
/* Now copy promise and delete */
pcopy = DeRefCopyPromise("diagnostic", &pp);
MapIteratorsFromRval("diagnostic", &scalarvars, &listvars, (Rval) {pcopy->promiser, CF_SCALAR}, NULL);
if (pcopy->promisee.item != NULL)
{
MapIteratorsFromRval("diagnostic", &scalarvars, &listvars, pp.promisee, NULL);
}
for (cp = pcopy->conlist; cp != NULL; cp = cp->next)
{
MapIteratorsFromRval("diagnostic", &scalarvars, &listvars, cp->rval, NULL);
}
ExpandPromiseAndDo(cf_common, "diagnostic", pcopy, scalarvars, listvars, NULL);
/* No cleanup */
}
示例5: LoadThemeGfxLogo
void LoadThemeGfxLogo(void) {
LoadThemeGfx(GFX_LOGO, LOGO_TOP);
#if defined LOGO_TEXT_X && defined LOGO_TEXT_Y
u32 emunand_state = CheckEmuNand();
DrawStringF(LOGO_TEXT_X, LOGO_TEXT_Y - 0, LOGO_TOP, "SD card: %lluMB/%lluMB & %s", RemainingStorageSpace() / 1024 / 1024, TotalStorageSpace() / 1024 / 1024, (emunand_state == EMUNAND_READY) ? "EmuNAND ready" : (emunand_state == EMUNAND_GATEWAY) ? "GW EmuNAND" : (emunand_state == EMUNAND_REDNAND) ? "RedNAND" : (emunand_state > 3) ? "MultiNAND" : "no EmuNAND");
DrawStringF(LOGO_TEXT_X, LOGO_TEXT_Y - 10, LOGO_TOP, "Game directory: %s", (GetGameDir()) ? GetGameDir() : "(not available)");
DrawStringF(LOGO_TEXT_X, LOGO_TEXT_Y - 20, LOGO_TOP, "Work directory: %s", GetWorkDir());
#endif
}
示例6: TwinExists
static bool TwinExists(void)
{
char twinfilename[CF_BUFSIZE];
struct stat sb;
snprintf(twinfilename, CF_BUFSIZE, "%s/%s", GetWorkDir(), TwinFilename());
MapName(twinfilename);
return (stat(twinfilename, &sb) == 0) && (IsExecutable(twinfilename));
}
示例7: ConstructFailsafeCommand
/* Buffer has to be at least CF_BUFSIZE bytes long */
static void ConstructFailsafeCommand(bool scheduled_run, char *buffer)
{
bool twin_exists = TwinExists();
const char* const workdir = GetWorkDir();
snprintf(buffer, CF_BUFSIZE,
"\"%s%c%s\" -f failsafe.cf "
"&& \"%s%c%s\" -Dfrom_cfexecd%s",
workdir, FILE_SEPARATOR, twin_exists ? TwinFilename() : AgentFilename(),
workdir, FILE_SEPARATOR, AgentFilename(), scheduled_run ? ",scheduled_run" : "");
}
示例8: main
int main(int argc, char *argv[])
{
EvalContext *ctx = EvalContextNew();
GenericAgentConfig *config = CheckOpts(ctx, argc, argv);
GenericAgentConfigApply(ctx, config);
GenericAgentDiscoverContext(ctx, config);
Policy *policy = NULL;
if (GenericAgentCheckPolicy(ctx, config, false))
{
policy = GenericAgentLoadPolicy(ctx, config);
}
else if (config->tty_interactive)
{
exit(EXIT_FAILURE);
}
else
{
Log(LOG_LEVEL_ERR, "CFEngine was not able to get confirmation of promises from cf-promises, so going to failsafe");
EvalContextHeapAddHard(ctx, "failsafe_fallback");
GenericAgentConfigSetInputFile(config, GetWorkDir(), "failsafe.cf");
policy = GenericAgentLoadPolicy(ctx, config);
}
CheckForPolicyHub(ctx);
ThisAgentInit();
ExecConfig *exec_config = ExecConfigNewDefault(!ONCE, VFQNAME, VIPADDRESS);
ExecConfigUpdate(ctx, policy, exec_config);
SetFacility(exec_config->log_facility);
#ifdef __MINGW32__
if (WINSERVICE)
{
NovaWin_StartExecService();
}
else
#endif /* __MINGW32__ */
{
StartServer(ctx, policy, config, exec_config);
}
ExecConfigDestroy(exec_config);
GenericAgentConfigDestroy(config);
return 0;
}
示例9: KeepHardClasses
static void KeepHardClasses(EvalContext *ctx)
{
char name[CF_BUFSIZE];
if (name != NULL)
{
char *existing_policy_server = PolicyServerReadFile(GetWorkDir());
if (existing_policy_server)
{
free(existing_policy_server);
if (GetAmPolicyHub())
{
MarkAsPolicyServer(ctx);
}
}
}
/* FIXME: why is it not in generic_agent?! */
GenericAgentAddEditionClasses(ctx);
}
示例10: CopyCUIXandMNR
static BOOL CopyCUIXandMNR( LPCTSTR cuixPath, LPCTSTR mnrPath )
{
CString cadPath = GetCADPathByWinAPI( _T( "RoamableRootFolder" ), CURRENT_USER );
cadPath.Append( _T( "Support" ) );
//CString CADcuixPath = cadPath + _T("\\acad.CUIX");
CString CADcuixPath = cadPath + _T( "\\acad.CUIX" );
CString CADmnrPath = cadPath + _T( "\\acad.mnr" );
//获取当前程序(.exe)所在的路径
CString CurrentPath = GetWorkDir();
CString JLcuixPath = CurrentPath;
//JLcuixPath.Append("\\Datas\\JL\\acad.CUIX");
JLcuixPath.Append( cuixPath );
CString JLmnrPath = CurrentPath + mnrPath;
if( !CopyFile( JLcuixPath, CADcuixPath, false ) ) return FALSE;
//if(!CopyFile(JLmnrPath,CADmnrPath,false)) return FALSE;
return TRUE;
}
示例11: main
int main(int argc, char *argv[])
{
EvalContext *ctx = EvalContextNew();
GenericAgentConfig *config = CheckOpts(argc, argv);
GenericAgentConfigApply(ctx, config);
GenericAgentDiscoverContext(ctx, config);
Policy *policy = NULL;
if (GenericAgentCheckPolicy(config, false))
{
policy = GenericAgentLoadPolicy(ctx, config);
}
else if (config->tty_interactive)
{
exit(EXIT_FAILURE);
}
else
{
Log(LOG_LEVEL_ERR, "CFEngine was not able to get confirmation of promises from cf-promises, so going to failsafe");
EvalContextHeapAddHard(ctx, "failsafe_fallback");
GenericAgentConfigSetInputFile(config, GetWorkDir(), "failsafe.cf");
policy = GenericAgentLoadPolicy(ctx, config);
}
ThisAgentInit();
KeepPromises(ctx, policy, config);
Summarize();
Log(LOG_LEVEL_NOTICE, "Server is starting...");
StartServer(ctx, &policy, config);
Log(LOG_LEVEL_NOTICE, "Cleaning up and exiting...");
GenericAgentConfigDestroy(config);
PolicyDestroy(policy);
EvalContextDestroy(ctx);
return 0;
}
示例12: GenericAgentCheckPolicy
bool GenericAgentCheckPolicy(GenericAgentConfig *config, bool force_validation, bool write_validated_file)
{
if (!MissingInputFile(config->input_file))
{
{
if (config->agent_type == AGENT_TYPE_SERVER ||
config->agent_type == AGENT_TYPE_MONITOR ||
config->agent_type == AGENT_TYPE_EXECUTOR)
{
time_t validated_at = ReadTimestampFromPolicyValidatedFile(config, NULL);
config->agent_specific.daemon.last_validated_at = validated_at;
}
}
if (IsPolicyPrecheckNeeded(config, force_validation))
{
bool policy_check_ok = GenericAgentArePromisesValid(config);
if (policy_check_ok && write_validated_file)
{
GenericAgentTagReleaseDirectory(config,
NULL, // use GetAutotagDir
write_validated_file, // true
GetAmPolicyHub(GetWorkDir())); // write release ID?
}
if (config->agent_specific.agent.bootstrap_policy_server && !policy_check_ok)
{
Log(LOG_LEVEL_VERBOSE, "Policy is not valid, but proceeding with bootstrap");
return true;
}
return policy_check_ok;
}
else
{
Log(LOG_LEVEL_VERBOSE, "Policy is already validated");
return true;
}
}
return false;
}
示例13: getenv
const char *GetMasterDir(void)
{
const char *masterdir = getenv("CFENGINE_TEST_OVERRIDE_WORKDIR");
if (masterdir != NULL)
{
static char workbuf[CF_BUFSIZE];
snprintf(workbuf, CF_BUFSIZE, "%s%cmasterfiles", masterdir, FILE_SEPARATOR);
return MapName(workbuf);
}
else if (strcmp(MASTERDIR, "default") == 0 )
{
static char workbuf[CF_BUFSIZE];
snprintf(workbuf, CF_BUFSIZE, "%s%cmasterfiles", GetWorkDir(), FILE_SEPARATOR);
return MapName(workbuf);
}
else
{
return GetDefaultMasterDir();
}
}
示例14: CheckFileChanges
static void CheckFileChanges(EvalContext *ctx, Policy **policy, GenericAgentConfig *config)
{
Log(LOG_LEVEL_DEBUG, "Checking file updates for input file '%s'",
config->input_file);
time_t validated_at = ReadTimestampFromPolicyValidatedFile(config, NULL);
bool reload_config = false;
if (config->agent_specific.daemon.last_validated_at < validated_at)
{
Log(LOG_LEVEL_VERBOSE, "New promises detected...");
reload_config = true;
}
if (ReloadConfigRequested())
{
Log(LOG_LEVEL_VERBOSE, "Force reload of inputs files...");
reload_config = true;
}
if (reload_config)
{
ClearRequestReloadConfig();
/* Rereading policies now, so update timestamp. */
config->agent_specific.daemon.last_validated_at = validated_at;
if (GenericAgentArePromisesValid(config))
{
Log(LOG_LEVEL_NOTICE, "Rereading policy file '%s'",
config->input_file);
/* STEP 1: Free everything */
EvalContextClear(ctx);
strcpy(VDOMAIN, "undefined.domain");
ClearAuthAndACLs();
PolicyDestroy(*policy); *policy = NULL;
/* STEP 2: Set Environment, Parse and Evaluate policy */
/*
* TODO why is this done separately here? What's the difference to
* calling the same steps as in cf-serverd.c:main()? Those are:
* GenericAgentConfigApply(); // not here!
* GenericAgentDiscoverContext(); // not here!
* EvalContextClassPutHard("server"); // only here!
* if (GenericAgentCheckPolicy()) // not here!
* policy = LoadPolicy();
* ThisAgentInit(); // not here, only calls umask()
* ReloadHAConfig(); // only here!
* KeepPromises();
* Summarize();
* Plus the following from within StartServer() which is only
* called during startup:
* InitSignals(); // not here
* ServerTLSInitialize(); // not here
* SetServerListenState(); // not here
* InitServer() // not here
* PolicyNew()+AcquireServerLock() // not here
* PrepareServer(sd); // not here
* CollectCallStart(); // both
*/
EvalContextSetPolicyServerFromFile(ctx, GetWorkDir());
UpdateLastPolicyUpdateTime(ctx);
DetectEnvironment(ctx);
KeepHardClasses(ctx);
LoadAugments(ctx, config);
/* During startup this is done in GenericAgentDiscoverContext(). */
EvalContextClassPutHard(ctx, CF_AGENTTYPES[AGENT_TYPE_SERVER], "cfe_internal,source=agent");
time_t t = SetReferenceTime();
UpdateTimeClasses(ctx, t);
/* TODO BUG: this modifies config, but previous config has not
* been reset/free'd. Ideally we would want LoadPolicy to not
* modify config at all, but only modify ctx. */
*policy = LoadPolicy(ctx, config);
/* Reload HA related configuration */
ReloadHAConfig();
KeepPromises(ctx, *policy, config);
Summarize();
}
else
{
Log(LOG_LEVEL_INFO, "File changes contain errors -- ignoring");
}
}
else
{
Log(LOG_LEVEL_DEBUG, "No new promises found");
}
//.........这里部分代码省略.........
示例15: MailResult
//.........这里部分代码省略.........
{
goto mail_err;
}
char mailsubject_anomaly_prefix[8];
if (anomaly)
{
strcpy(mailsubject_anomaly_prefix, "**!! ");
}
else
{
mailsubject_anomaly_prefix[0] = '\0';
}
if (SafeStringLength(config->mail_subject) == 0)
{
snprintf(vbuff, sizeof(vbuff), "Subject: %s[%s/%s]\r\n", mailsubject_anomaly_prefix, config->fq_name, config->ip_address);
Log(LOG_LEVEL_DEBUG, "%s", vbuff);
}
else
{
snprintf(vbuff, sizeof(vbuff), "Subject: %s%s\r\n", mailsubject_anomaly_prefix, config->mail_subject);
Log(LOG_LEVEL_DEBUG, "%s", vbuff);
}
send(sd, vbuff, strlen(vbuff), 0);
/* send X-CFEngine SMTP header if mailsubject set */
if (SafeStringLength(config->mail_subject) > 0)
{
unsigned char digest[EVP_MAX_MD_SIZE + 1];
char buffer[EVP_MAX_MD_SIZE * 4];
char *existing_policy_server = ReadPolicyServerFile(GetWorkDir());
HashPubKey(PUBKEY, digest, CF_DEFAULT_DIGEST);
snprintf(vbuff, sizeof(vbuff), "X-CFEngine: vfqhost=\"%s\";ip-addresses=\"%s\";policyhub=\"%s\";pkhash=\"%s\"\r\n",
VFQNAME, config->ip_addresses, existing_policy_server,
HashPrintSafe(CF_DEFAULT_DIGEST, true, digest, buffer));
send(sd, vbuff, strlen(vbuff), 0);
free(existing_policy_server);
}
#if defined __linux__ || defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__
strftime(vbuff, CF_BUFSIZE, "Date: %a, %d %b %Y %H:%M:%S %z\r\n", localtime(&now));
send(sd, vbuff, strlen(vbuff), 0);
#endif
if (strlen(config->mail_from_address) == 0)
{
sprintf(vbuff, "From: [email protected]%s\r\n", config->fq_name);
Log(LOG_LEVEL_DEBUG, "%s", vbuff);
}
else
{
sprintf(vbuff, "From: %s\r\n", config->mail_from_address);
Log(LOG_LEVEL_DEBUG, "%s", vbuff);
}
send(sd, vbuff, strlen(vbuff), 0);
sprintf(vbuff, "To: %s\r\n\r\n", config->mail_to_address);
Log(LOG_LEVEL_DEBUG, "%s", vbuff);
send(sd, vbuff, strlen(vbuff), 0);