void vv2__do_cmd_cat(SG_context * pCtx, const SG_option_state * pOptSt, const SG_stringarray * psaArgs) { SG_pathname* pPathOutputFile = NULL; if (pOptSt->psz_output_file) { SG_ERR_CHECK( SG_pathname__alloc__sz(pCtx, &pPathOutputFile, pOptSt->psz_output_file) ); SG_ERR_CHECK( SG_vv2__cat__to_pathname(pCtx, pOptSt->psz_repo, pOptSt->pRevSpec, psaArgs, pPathOutputFile) ); } else { // TODO 2012/12/21 For now, just splat the contents of each file // TODO to the console without anything fancy. // TODO // TODO We support multiple files in one command, but // TODO only without bells or whistles. // TODO Do we need to print headers or breaks between // TODO them or should we just behave like '/bin/cat'? // TODO // TODO Do we want to have a '/bin/cat -v' like mode? SG_ERR_CHECK( SG_vv2__cat__to_console(pCtx, pOptSt->psz_repo, pOptSt->pRevSpec, psaArgs) ); } fail: SG_PATHNAME_NULLFREE(pCtx, pPathOutputFile); }
void _set_curl_options(SG_context* pCtx, CURL* pCurl) { char * szServerFiles = NULL; char * szVerifyCerts = NULL; SG_pathname *pServerFiles = NULL; CURLcode rc = CURLE_OK; #ifdef WINDOWS SG_bool bExists = SG_FALSE; SG_bool bVerifyCerts = SG_TRUE; #endif SG_ERR_CHECK( SG_localsettings__get__sz(pCtx, SG_LOCALSETTING__VERIFY_SSL_CERTS, NULL, &szVerifyCerts, NULL) ); if (szVerifyCerts != NULL && (SG_strcmp__null(szVerifyCerts, "false") == 0 || SG_strcmp__null(szVerifyCerts, "FALSE") == 0)) { #ifdef WINDOWS bVerifyCerts = SG_FALSE; #endif rc = curl_easy_setopt(pCurl, CURLOPT_SSL_VERIFYPEER, SG_FALSE); } if (rc) SG_ERR_THROW(SG_ERR_LIBCURL(rc)); #ifdef WINDOWS if (bVerifyCerts) { SG_ERR_CHECK( SG_localsettings__get__sz(pCtx, SG_LOCALSETTING__SERVER_FILES, NULL, &szServerFiles, NULL) ); if (szServerFiles) { SG_ERR_CHECK( SG_pathname__alloc__sz(pCtx, &pServerFiles, szServerFiles) ); SG_ERR_CHECK( SG_pathname__append__from_sz(pCtx, pServerFiles, "ssl") ); SG_ERR_CHECK( SG_pathname__append__from_sz(pCtx, pServerFiles, "curl-ca-bundle.crt") ); SG_ERR_CHECK( SG_fsobj__exists__pathname(pCtx, pServerFiles, &bExists, NULL, NULL) ); } if (bExists) { rc = curl_easy_setopt(pCurl, CURLOPT_CAINFO, SG_pathname__sz(pServerFiles)); if (rc) SG_ERR_THROW(SG_ERR_LIBCURL(rc)); } else { if (pServerFiles) SG_ERR_CHECK( SG_log__report_warning(pCtx, "Could not find root certificate file. Looked for it at: %s. SSL connections will not work.", SG_pathname__sz(pServerFiles)) ); else SG_ERR_CHECK( SG_log__report_warning(pCtx, "Could not find root certificate file: no server/files path is configured. SSL connections will not work.") ); } } #endif fail: SG_PATHNAME_NULLFREE(pCtx, pServerFiles); SG_NULLFREE(pCtx, szServerFiles); SG_NULLFREE(pCtx, szVerifyCerts); }
/** * Let the UI dispatch methods know where to find their template files. */ void _sgui_set_templatePath(SG_context * pCtx) { SG_pathname *collateralRoot = NULL; SG_pathname * templatePath = NULL; char* psz = NULL; SG_ERR_CHECK( SG_localsettings__get__sz(pCtx, SG_LOCALSETTING__SSI_DIR, NULL, &psz, NULL) ); SG_ERR_CHECK( SG_pathname__alloc__sz(pCtx, &collateralRoot, psz) ); SG_ERR_CHECK( SG_PATHNAME__ALLOC__PATHNAME_SZ(pCtx, &templatePath, collateralRoot, "templates") ); SG_NULLFREE(pCtx, psz); SG_PATHNAME_NULLFREE(pCtx, collateralRoot); _sg_uridispatch__templatePath = templatePath; return; fail: SG_NULLFREE(pCtx, psz); SG_PATHNAME_NULLFREE(pCtx, templatePath); SG_PATHNAME_NULLFREE(pCtx, collateralRoot); }