ts::uint32 active_protocol_c::gm_handler(gmsg<ISOGM_MESSAGE>&msg) // send message to other peer { if (msg.pass == 0 && msg.post.sender.is_self()) // handle only self-to-other messages { if (msg.post.receiver.protoid != id) return 0; contact_c *target = contacts().find( msg.post.receiver ); if (!target) return 0; for(;;) { if (CS_INVITE_RECEIVE == target->get_state() || CS_INVITE_SEND == target->get_state()) if (0 != (get_features() & PF_UNAUTHORIZED_CHAT)) break; if (0 == (get_features() & PF_OFFLINE_MESSAGING)) if (target->get_state() != CS_ONLINE) return 0; break; } if (typingsendcontact == target->getkey().contactid) typingsendcontact = 0; ipcp->send( ipcw(AQ_MESSAGE ) << target->getkey().contactid << (int)MTA_MESSAGE << msg.post.utag << msg.post.cr_time << msg.post.message_utf8 ); } return 0; }
void do_feature_selection(){ struct url_test *t; struct feature *f; struct feature *top=NULL; struct feature_selection *fs=NULL; struct feature_selection *fs_node; int i=0; double current_highest=0; double highest=0; double gain=0; struct test_score score; for(t=get_tests();t!=NULL;t=t->hh.next){ fs=NULL; score.score=(double) t->success/(double) t->count; score.test=t; current_highest=9000; /* if there are less than 100 successes for this test, * we probably don't know enough to make an informed decision. * Roll with the total probability */ if(t->success<100){ t->feature_selections=NULL; goto skip_feature_selection; } for(i=0;i<9;i++){ highest=0; for(f=get_features();f!=NULL;f=f->hh.next){ if(!f->ftr_loaded){ load_ftr_by_feature_id(f->id); f->ftr_loaded=1; } gain=expected_change(&score,f); if(gain>highest && gain<current_highest){ highest=gain; top=f; } } current_highest=highest; fs_node=malloc(sizeof(struct feature_selection)); fs_node->feature=top; fs_node->next=fs; fs=fs_node; } skip_feature_selection: printf("features for %s :",t->url); for(fs_node=fs;fs_node!=NULL;fs_node=fs_node->next){ if(fs_node->feature==NULL) continue; printf(" %s", fs_node->feature->label); } t->feature_selections=fs; update_feature_selection(t); printf("\n"); } }
struct cmd_results *cmd_permit(int argc, char **argv) { struct cmd_results *error = NULL; if ((error = checkarg(argc, "permit", EXPECTED_MORE_THAN, 1))) { return error; } struct feature_policy *policy = get_policy(argv[0]); policy->features |= get_features(argc, argv, &error); if (error) { return error; } sway_log(L_DEBUG, "Permissions granted to %s for features %d", policy->program, policy->features); return cmd_results_new(CMD_SUCCESS, NULL, NULL); }
struct feature *pick_feature(struct id3_node *root){ struct feature *f; struct feature *top=NULL; double highest=0; if(depth(root)>9){ return NULL; } for(f=get_features();f!=NULL;f=f->hh.next){ double gain=0; if(f->count<50) continue; if(in_chain(f,root)) continue; gain=expected_change(&root->score,f); if(gain>highest){ top=f; highest=gain; } } return top; }
int main(int argc, char *argv[]){ #ifdef FORCE char buffer[8192], *p, *q; int length; #endif if (argc == 1) return 0; switch (argv[1][0]) { case '0' : /* for Makefile */ #ifdef FORCE printf("CORE=%s\n", CORENAME); #else #if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__) printf("CORE=%s\n", get_corename()); #endif #endif #ifdef FORCE printf("LIBCORE=%s\n", LIBNAME); #else printf("LIBCORE="); get_libname(); printf("\n"); #endif printf("NUM_CORES=%d\n", get_num_cores()); #if defined(__arm__) && !defined(FORCE) get_features(); #endif #ifdef INTEL_AMD #ifndef FORCE get_sse(); #else sprintf(buffer, "%s", ARCHCONFIG); p = &buffer[0]; while (*p) { if ((*p == '-') && (*(p + 1) == 'D')) { p += 2; while ((*p != ' ') && (*p != '\0')) { if (*p == '=') { printf("="); p ++; while ((*p != ' ') && (*p != '\0')) { printf("%c", *p); p ++; } } else { printf("%c", *p); p ++; if ((*p == ' ') || (*p =='\0')) printf("=1"); } } printf("\n"); } else p ++; } #endif #endif #ifdef MAKE_NB_JOBS printf("MAKE += -j %d\n", MAKE_NB_JOBS); #elif NO_PARALLEL_MAKE==1 printf("MAKE += -j 1\n"); #else #ifndef OS_WINDOWS printf("MAKE += -j %d\n", get_num_cores()); #endif #endif break; case '1' : /* For config.h */ #ifdef FORCE sprintf(buffer, "%s -DCORE_%s\n", ARCHCONFIG, CORENAME); p = &buffer[0]; while (*p) { if ((*p == '-') && (*(p + 1) == 'D')) { p += 2; printf("#define "); while ((*p != ' ') && (*p != '\0')) { if (*p == '=') { printf(" "); p ++; while ((*p != ' ') && (*p != '\0')) { printf("%c", *p); p ++; } } else { printf("%c", *p); p ++; } } printf("\n"); } else p ++; } #else get_cpuconfig(); #endif #ifdef FORCE printf("#define CHAR_CORENAME \"%s\"\n", CORENAME); #else #if defined(INTEL_AMD) || defined(POWER) || defined(__mips__) || defined(__arm__) || defined(__aarch64__) printf("#define CHAR_CORENAME \"%s\"\n", get_corename()); #endif #endif break; case '2' : /* SMP */ if (get_num_cores() > 1) printf("SMP=1\n"); break; } fflush(stdout); return 0; }
/** * Calculates the feature values for all sequences in a file. * * The File has to have fasta format. * \param seq_file_name The name of the file (in fasta format). * \param max_dist The maximal distance to be considered. * \param k_tup Size of the k_tup. * \param alphabet_size The size of the alphabet. * * \return The feature values for every sequence in a Cluster_info object. */ Cluster_info * feature_extract(char *seq_file_name, int max_dist, int k_tup, int *char2value, int alphabet_size, int * elem_2_compare, int *num_seq_p, int num_features) { char line[500]; FILE *tree_f = fopen(seq_file_name,"r"); // fgets(line, 500, tree_f); int num_seq = -1; int size = 1000; int matrix_size = 1000; const int STEP = 1000; int seq_pos = -1; char *seq = (char*)vcalloc(size, sizeof(char)); Cluster_info *matrix =(Cluster_info*) vcalloc(matrix_size, sizeof(Cluster_info)); char *c_p; int max_coding = pow(alphabet_size,k_tup); while (fgets(line, 500, tree_f) != NULL) { if (line[0] == '>') { if (num_seq >= 0) { seq[++seq_pos] = '\0'; if (num_seq > matrix_size -2) { matrix_size += STEP; matrix = (Cluster_info*)vrealloc(matrix, matrix_size * sizeof(Cluster_info)); } int *recoded_seq = recode_sequence(seq, seq_pos, char2value, alphabet_size, k_tup); matrix[num_seq].seq_number = num_seq; matrix[num_seq].elem_2_compare = elem_2_compare; matrix[num_seq].features=get_features(recoded_seq, seq_pos- k_tup +1, k_tup, max_coding, max_dist, num_features); vfree(recoded_seq); seq_pos = -1; } ++num_seq; } else { if (size - seq_pos < 500) { size += STEP; seq = (char*)vrealloc(seq, size*sizeof(char)); } c_p = &line[0]; while ((*c_p != '\n') && (*c_p != '\0')) { seq[++seq_pos] = toupper(*(c_p)); ++c_p; } } } fclose(tree_f); seq[++seq_pos] = '\0'; int *recoded_seq = recode_sequence(seq, seq_pos, char2value, alphabet_size, k_tup); matrix[num_seq].seq_number = num_seq; matrix[num_seq].elem_2_compare = elem_2_compare; matrix[num_seq].features=get_features(recoded_seq, seq_pos- k_tup +1, k_tup, max_coding, max_dist, num_features); *num_seq_p = ++num_seq; vfree(seq); vfree(recoded_seq); return matrix; }