char* cc_getRemoteResourcePath(pool* p, cc_globals* globals,char* resource,char**details){ char* ret=NULL, * bakFile=NULL,* filename=NULL; http_util_result* result=NULL; cc_service_descriptor* rs=NULL; char* reqUri=NULL; //file vars apr_file_t* file=NULL; apr_status_t status; apr_pool_t* tp=NULL; apr_size_t file_written; char* errorMsg=NULL; if(resource==NULL) return NULL; if(globals->resourceService!=NULL){ rs=globals->resourceService; //setup filepool if(apr_pool_create(&tp,p)!=APR_SUCCESS){ if(details!=NULL){ *details=apr_pstrdup(p,"Failure to create subpool"); } return NULL; } reqUri=apr_pstrcat(p,rs->uri,"/",resource,NULL); //try to load from remote result=http_request_get_verbose(p,reqUri,rs->timeoutSeconds,rs->userColonPass,NULL,&errorMsg); if(http_is200_OK(result)){ //write file to filesystem if(result->size>0){ bakFile=apr_pstrcat(tp,globals->homeDir,"/",resource,".part",NULL); status=apr_file_open(&file,bakFile,APR_WRITE|APR_CREATE|APR_TRUNCATE,APR_OS_DEFAULT,tp); if(apr_file_write_full(file,result->data,result->size,&file_written)==APR_SUCCESS){ filename=apr_pstrcat(p,globals->homeDir,"/",resource,NULL); apr_file_close(file); if(apr_file_rename(bakFile,filename,tp)==APR_SUCCESS){ ret=filename; } }else{ apr_file_close(file); if(details!=NULL){ *details=apr_pstrcat(p,"Failure to write file:",SAFESTR(bakFile),NULL); } } } }else{ if(details!=NULL){ *details=apr_pstrcat(p,"Failure to write file (Response Code!=200): ",SAFESTR(resource),",",SAFESTR(errorMsg),NULL); } } apr_pool_destroy(tp); } return ret; }
static void ifiDb_ShowRow(idrc_t *pIdrc) { if(pIdrc != NULL) { printf("%s|%s|%s|%s\n" , SAFESTR(pIdrc->pCols[TBL_COL_ALLOWDENY]) , SAFESTR(pIdrc->pCols[TBL_COL_ADDRESS]) , SAFESTR(pIdrc->pCols[TBL_COL_EXECEPTION]) , SAFESTR(pIdrc->pCols[TBL_COL_LOCALFOREIGN]) ); } }
/* RFC 2981 Section 2.2 * If a sort key is a multi-valued attribute, and an entry happens to * have multiple values for that attribute and no other controls are * present that affect the sorting order, then the server SHOULD use the * least value (according to the ORDERING rule for that attribute). */ static struct berval* select_value( Attribute *attr, sort_key *key ) { struct berval* ber1, *ber2; MatchingRule *mr = key->sk_ordering; unsigned i; int cmp; ber1 = &(attr->a_nvals[0]); ber2 = ber1+1; for ( i = 1; i < attr->a_numvals; i++,ber2++ ) { mr->smr_match( &cmp, 0, mr->smr_syntax, mr, ber1, ber2 ); if ( cmp > 0 ) { ber1 = ber2; } } Debug(LDAP_DEBUG_TRACE, "%s: value selected for compare: %s\n", debug_header, SAFESTR(ber1->bv_val, "<Empty>"), 0); return ber1; }
char* cb_writeRemoteResourceToDisk(pool* p, char* homeDir, char* reqUri, char* resource, long timeoutSeconds, char* userColonPass, apr_pool_t* tp, char**details, int* responseCode){ char* ret=NULL, * bakFile=NULL,* filename=NULL; http_util_result* result=NULL; //file vars apr_file_t* file=NULL; apr_status_t status; apr_size_t file_written; char* errorMsg=NULL; if(resource==NULL) return NULL; result=hc_get_verbose(p,reqUri,timeoutSeconds,userColonPass,NULL,&errorMsg); if(hc_is200_OK(result)){ //write file to filesystem if(result->size>0){ bakFile=apr_pstrcat(tp,homeDir,"/",resource,".part",NULL); status=apr_file_open(&file,bakFile,APR_WRITE|APR_CREATE|APR_TRUNCATE,APR_OS_DEFAULT,tp); if(apr_file_write_full(file,result->data,result->size,&file_written)==APR_SUCCESS){ filename=apr_pstrcat(p,homeDir,"/",resource,NULL); apr_file_close(file); if(apr_file_rename(bakFile,filename,tp)==APR_SUCCESS){ ret=filename; } }else{ apr_file_close(file); if(details!=NULL){ *details=apr_pstrcat(p,"Failure to write file:",SAFESTR(bakFile),NULL); } } } }else{ if(details!=NULL){ *details=apr_pstrcat(p,"Failure to write file (Response Code!=200): ",SAFESTR(resource),",",SAFESTR(errorMsg),NULL); } if(responseCode!=NULL&&result!=NULL){ *responseCode=result->responseCode; } } return ret; }
LPCTSTR CFileName::GetFullPath() { if (IsFavorite()) return SAFESTR(filename); if (!location) return NULL; if (fullpath) return fullpath; if (!IsFile()) return location; fullpath = (LPTSTR) malloc((_tcslen(location) + _tcslen(filename) + 2) * sizeof(TCHAR)); _stprintf(fullpath, _T("%s%s"), location, filename); return fullpath; }
static void send_entry( Operation *op, SlapReply *rs, sort_op *so) { Debug(LDAP_DEBUG_TRACE, "%s: response control: status=%d, text=%s\n", debug_header, rs->sr_err, SAFESTR(rs->sr_text, "<None>")); if ( !so->so_tree ) return; /* RFC 2891: If critical then send the entries iff they were * successfully sorted. If non-critical send all entries * whether they were sorted or not. */ if ( (op->o_ctrlflag[sss_cid] != SLAP_CONTROL_CRITICAL) || (rs->sr_err == LDAP_SUCCESS) ) { if ( so->so_vlv > SLAP_CONTROL_IGNORED ) { send_list( op, rs, so ); } else { /* Get the first node to send */ TAvlnode *start_node = tavl_end(so->so_tree, TAVL_DIR_LEFT); so->so_tree = start_node; if ( so->so_paged <= SLAP_CONTROL_IGNORED ) { /* Not paged result search. Send all entries. * Set the page size to the number of entries * so that send_page() will send all entries. */ so->so_page_size = so->so_nentries; } send_page( op, rs, so ); } } }
virtual bool RegisterTypes( int nFactoryType, bool bUnregister ) { bool bRet = CPluginBaseMinimal::RegisterTypes( nFactoryType, bUnregister ); if ( bRet ) { eFactoryType enFactoryType = eFactoryType( nFactoryType ); if ( enFactoryType == FT_All || enFactoryType == FT_Flownode ) { IFlowSystem* pFlow = NULL; if ( gEnv && gEnv->pSystem && !gEnv->pSystem->IsQuitting() && gEnv->pGameFramework && ( pFlow = gEnv->pGameFramework->GetIFlowSystem() ) ) { if ( !bUnregister ) { // Register all flownodes of this plugin in the crygame loading this plugin for ( CG2AutoRegFlowNodeBase* pFactory = CG2AutoRegFlowNodeBase::m_pFirst; pFactory; pFactory = pFactory->m_pNext ) { TFlowNodeTypeId nTypeId = pFlow->RegisterType( pFactory->m_sClassName, pFactory ); if ( nTypeId != InvalidFlowNodeTypeId ) { LogAlways( "Flownode Class(%s) Ptr(%p) TypeId(%d) registered.", SAFESTR( pFactory->m_sClassName ), pFactory, ( int )nTypeId ); } else { LogError( "Flownode Class(%s) Ptr(%p) couldn't register.", SAFESTR( pFactory->m_sClassName ), pFactory ); //bRet = false; } } } else { // Unregister all flownodes of this plugin for ( CG2AutoRegFlowNodeBase* pFactory = CG2AutoRegFlowNodeBase::m_pFirst; pFactory; pFactory = pFactory->m_pNext ) { // A shame unregistering flownodes types still will produce errors later on in sandbox (then when clicked on) // it would be much better if UnregisterTypes would automatically unload and set related flownodes to missing status. bool bUnregistered = pFlow->UnregisterType( pFactory->m_sClassName ); LogAlways( "Flownode Class(%s) Ptr(%p) Ret(%s) unregistered.", SAFESTR( pFactory->m_sClassName ), pFactory ); } } } else if ( CG2AutoRegFlowNodeBase::m_pFirst ) { LogWarning( "Flownodes couldn't be un/registered" ); //bRet = false; } // else there where no flownodes to register } } return bRet; };
/* * @internal * @brief Delay a function * @param sFilter custom filter for remove control * @param pFunc function pointer of delayed function * @param pFuncCleanup function pointer that cleans up the data when the delayed call is canceled or finished * @param pData Data for delayed function * @param fDelay delay amount * @param eType delay type * @param pFuncTrigger function pointer delay trigger function * @param pFuncTriggerCleanup function pointer that cleans up the data when the delayed call is canceled or finished * @param pDataTrigger Data for delay trigger function */ void DelayFunction( const char* sFilter = NULL, tDelayedCall pFunc = NULL, tDelayedCall pFuncCleanup = NULL, void* pData = NULL, float fDelay = 1.0f, eDelayType eType = eDT_Default, tDelayedCallTrigger pFuncTrigger = NULL, tDelayedCall pFuncTriggerCleanup = NULL, void* pDataTrigger = NULL ) { m_queue[ SAFESTR( sFilter ) ].push_back( std::shared_ptr<CallDelay>( new CallDelay( pFunc, pFuncCleanup, pData, fDelay, eType, pFuncTrigger, pFuncTriggerCleanup, pDataTrigger ) ) ); }
static void contacts_entry_changed (GtkWidget *widget, EContactChangeData *data) { GList *v, *values = contacts_entries_get_values (data->widget, NULL); e_vcard_attribute_remove_values (data->attr); /* Note: First element of a structured field is type, so remove it */ if (g_list_length (values) > 1) { GList *type = g_list_last (values); values = g_list_remove_link (values, type); g_free (type->data); g_list_free (type); } for (v = g_list_last (values); v; v = v->prev) { e_vcard_attribute_add_value (data->attr, (const gchar *)v->data); } if (!g_ascii_strcasecmp (e_vcard_attribute_get_name (data->attr), EVC_FN)) { /* add N and X-EVOLUTION-FILE-AS attributes */ ENameWestern *name; gchar *file_as; EVCardAttribute *attr; EVCard *evc = E_VCARD (data->contact); name = e_name_western_parse ((char*)values->data); /* Add "N" attribute */ attr = e_vcard_get_attribute (evc, EVC_N); if (attr) e_vcard_attribute_remove_values (attr); else { attr = e_vcard_attribute_new ("", EVC_N); e_vcard_add_attribute (evc, attr); } #define SAFESTR(x) (x) ? x : "" e_vcard_attribute_add_value (attr, SAFESTR (name->last)); e_vcard_attribute_add_value (attr, SAFESTR (name->first)); e_vcard_attribute_add_value (attr, SAFESTR (name->middle)); e_vcard_attribute_add_value (attr, SAFESTR (name->prefix)); e_vcard_attribute_add_value (attr, SAFESTR (name->suffix)); /* Add file-as attribute for evolution */ file_as = g_strdup_printf ("%s, %s", name->last, name->first); attr = e_vcard_get_attribute (evc, EVC_X_FILE_AS); if (attr) e_vcard_remove_attribute (evc, attr); attr = e_vcard_attribute_new ("", EVC_X_FILE_AS); e_vcard_add_attribute_with_value (evc, attr, file_as); g_free (file_as); g_free (name); } g_list_foreach (values, (GFunc)g_free, NULL); g_list_free (values); *data->changed = TRUE; }
static int build_key( BerElement *ber, SlapReply *rs, sort_key *key ) { struct berval attr; struct berval matchrule = BER_BVNULL; ber_int_t reverse = 0; ber_tag_t tag; ber_len_t len; MatchingRule *ordering = NULL; AttributeDescription *ad = NULL; const char *text; if (( tag = ber_scanf( ber, "{" )) == LBER_ERROR ) { rs->sr_text = "serverSort control: decoding error"; rs->sr_err = LDAP_PROTOCOL_ERROR; return rs->sr_err; } if (( tag = ber_scanf( ber, "m", &attr )) == LBER_ERROR ) { rs->sr_text = "serverSort control: attribute decoding error"; rs->sr_err = LDAP_PROTOCOL_ERROR; return rs->sr_err; } tag = ber_peek_tag( ber, &len ); if ( tag == LDAP_MATCHRULE_IDENTIFIER ) { if (( tag = ber_scanf( ber, "m", &matchrule )) == LBER_ERROR ) { rs->sr_text = "serverSort control: matchrule decoding error"; rs->sr_err = LDAP_PROTOCOL_ERROR; return rs->sr_err; } tag = ber_peek_tag( ber, &len ); } if ( tag == LDAP_REVERSEORDER_IDENTIFIER ) { if (( tag = ber_scanf( ber, "b", &reverse )) == LBER_ERROR ) { rs->sr_text = "serverSort control: reverse decoding error"; rs->sr_err = LDAP_PROTOCOL_ERROR; return rs->sr_err; } } if (( tag = ber_scanf( ber, "}" )) == LBER_ERROR ) { rs->sr_text = "serverSort control: decoding error"; rs->sr_err = LDAP_PROTOCOL_ERROR; return rs->sr_err; } if ( slap_bv2ad( &attr, &ad, &text ) != LDAP_SUCCESS ) { rs->sr_text = "serverSort control: Unrecognized attribute type in sort key"; Debug(LDAP_DEBUG_TRACE, "%s: Unrecognized attribute type in sort key: %s\n", debug_header, SAFESTR(attr.bv_val, "<None>")); rs->sr_err = LDAP_NO_SUCH_ATTRIBUTE; return rs->sr_err; } /* get_ordering_rule will set sr_err and sr_text */ get_ordering_rule( ad, &matchrule, rs, &ordering ); if ( rs->sr_err != LDAP_SUCCESS ) { return rs->sr_err; } key->sk_ad = ad; key->sk_ordering = ordering; key->sk_direction = reverse ? -1 : 1; return rs->sr_err; }