bool equals(const formula_callable* other) const { return do_compare(other) == 0; }
bool less(const formula_callable* other) const { return do_compare(other) < 0; }
/// /// Compare two strings in rage [b1,e1), [b2,e2) according using a collation level \a level. Calls do_compare /// /// Returns -1 if the first of the two strings sorts before the seconds, returns 1 if sorts after and 0 if /// they considered equal. /// int compare(level_type level, char_type const *b1,char_type const *e1, char_type const *b2,char_type const *e2) const { return do_compare(level,b1,e1,b2,e2); }
int param_main(int argc, char *argv[]) { if (argc >= 2) { if (!strcmp(argv[1], "save")) { if (argc >= 3) { do_save(argv[2]); } else { if (param_save_default()) { warnx("Param export failed."); exit(1); } else { exit(0); } } } if (!strcmp(argv[1], "load")) { if (argc >= 3) { do_load(argv[2]); } else { do_load(param_get_default_file()); } } if (!strcmp(argv[1], "import")) { if (argc >= 3) { do_import(argv[2]); } else { do_import(param_get_default_file()); } } if (!strcmp(argv[1], "select")) { if (argc >= 3) { param_set_default_file(argv[2]); } else { param_set_default_file(NULL); } warnx("selected parameter default file %s", param_get_default_file()); exit(0); } if (!strcmp(argv[1], "show")) { if (argc >= 3) { do_show(argv[2]); } else { do_show(NULL); } } if (!strcmp(argv[1], "set")) { if (argc >= 4) { do_set(argv[2], argv[3]); } else { errx(1, "not enough arguments.\nTry 'param set PARAM_NAME 3'"); } } if (!strcmp(argv[1], "compare")) { if (argc >= 4) { do_compare(argv[2], &argv[3], argc - 3); } else { errx(1, "not enough arguments.\nTry 'param compare PARAM_NAME 3'"); } } } errx(1, "expected a command, try 'load', 'import', 'show', 'set', 'compare', 'select' or 'save'"); }
/// /// Compare two strings \a l and \a r using collation level \a level /// /// Returns -1 if the first of the two strings sorts before the seconds, returns 1 if sorts after and 0 if /// they considered equal. /// /// int compare(level_type level,string_type const &l,string_type const &r) const { return do_compare(level,l.data(),l.data()+l.size(),r.data(),r.data()+r.size()); }
/// /// This function is used to override default collation function that does not take in account collation level. /// Uses primary level /// virtual int do_compare( char_type const *b1,char_type const *e1, char_type const *b2,char_type const *e2) const { return do_compare(identical,b1,e1,b2,e2); }
int STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2, locale_t l) { struct __locale_data *current = l->__locales[LC_COLLATE]; uint_fast32_t nrules = current->values[_NL_ITEM_INDEX (_NL_COLLATE_NRULES)].word; /* We don't assign the following values right away since it might be unnecessary in case there are no rules. */ const unsigned char *rulesets; const int32_t *table; const USTRING_TYPE *weights; const USTRING_TYPE *extra; const int32_t *indirect; if (nrules == 0) return STRCMP (s1, s2); /* Catch empty strings. */ if (__glibc_unlikely (*s1 == '\0') || __glibc_unlikely (*s2 == '\0')) return (*s1 != '\0') - (*s2 != '\0'); rulesets = (const unsigned char *) current->values[_NL_ITEM_INDEX (_NL_COLLATE_RULESETS)].string; table = (const int32_t *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_TABLE,SUFFIX))].string; weights = (const USTRING_TYPE *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_WEIGHT,SUFFIX))].string; extra = (const USTRING_TYPE *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_EXTRA,SUFFIX))].string; indirect = (const int32_t *) current->values[_NL_ITEM_INDEX (CONCAT(_NL_COLLATE_INDIRECT,SUFFIX))].string; assert (((uintptr_t) table) % __alignof__ (table[0]) == 0); assert (((uintptr_t) weights) % __alignof__ (weights[0]) == 0); assert (((uintptr_t) extra) % __alignof__ (extra[0]) == 0); assert (((uintptr_t) indirect) % __alignof__ (indirect[0]) == 0); int result = 0, rule = 0; coll_seq seq1, seq2; seq1.len = 0; seq1.idxmax = 0; seq1.rule = 0; seq2.len = 0; seq2.idxmax = 0; for (int pass = 0; pass < nrules; ++pass) { seq1.idxcnt = 0; seq1.idx = 0; seq2.idx = 0; seq1.backw_stop = ~0ul; seq1.backw = ~0ul; seq2.idxcnt = 0; seq2.backw_stop = ~0ul; seq2.backw = ~0ul; /* We need the elements of the strings as unsigned values since they are used as indices. */ seq1.us = (const USTRING_TYPE *) s1; seq2.us = (const USTRING_TYPE *) s2; /* We assume that if a rule has defined `position' in one section this is true for all of them. Please note that the localedef programs makes sure that `position' is not used at the first level. */ int position = rulesets[rule * nrules + pass] & sort_position; while (1) { get_next_seq (&seq1, nrules, rulesets, weights, table, extra, indirect, pass); get_next_seq (&seq2, nrules, rulesets, weights, table, extra, indirect, pass); /* See whether any or both strings are empty. */ if (seq1.len == 0 || seq2.len == 0) { if (seq1.len == seq2.len) { /* Both strings ended and are equal at this level. Do a byte-level comparison to ensure that we don't waste time going through multiple passes for totally equal strings before proceeding to subsequent passes. */ if (pass == 0 && STRCMP (s1, s2) == 0) return result; else break; } /* This means one string is shorter than the other. Find out which one and return an appropriate value. */ return seq1.len == 0 ? -1 : 1; } result = do_compare (&seq1, &seq2, position, weights); if (result != 0) return result; } rule = seq1.rule; } return result; }
int main(int argc, char *argv[]) { struct tms usage; FILE *finp; int i,j, ticks; int numinfirst; char chkfile[255]; i=0; dump_file=NULL; do_cluster=do_pairwise_cluster; srandom(563573); bzero(&prog_opts,sizeof(ProgOptionsType)); outf=stdout; // set default distance function dist = d2; distpair= d2pair; #ifdef MPI MPI_Init(&argc, &argv); MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); MPI_Comm_size(MPI_COMM_WORLD, &numprocs); MPI_Comm_rank(MPI_COMM_WORLD, &myid); #endif if(myid==0) { // Master process_options(argc, argv); } else { process_slave_options(argc, argv); } if (prog_opts.show_version || (argc==1)) { if (myid==0) printf("Version \n%s\n",version); #ifdef MPI MPI_Finalize(); #endif exit(0); } // Allocate space for the RC table for big words rc_big = calloc(BIG_WORD_TSIZE, sizeof(SeqElt)); // work is an array of work blocks. If non-parallel, there'll only // be one. work[0] acts a template work = (WorkPtr) calloc(num_threads,sizeof(WorkBlock)); work->filename = argv[optind]; work->index = NULL; if(prog_opts.do_dump) dump_file = fopen(prog_opts.dname,"w"); #ifdef MPI if (numprocs > 1) if (myid>0) { // slaves if (prog_opts.split) { MPI_Finalize(); return 0; } handleMPISlaveSetup(&num_seqs); initialise(work, prog_opts.edfile); internalTest(); perform_clustering(work); transmitMPISlaveResponse(work); if (prog_opts.show_perf) show_performance(outf); MPI_Finalize(); exit(0); } #else if (numprocs > 1) { printf("This version of wcd is not compiled with MPI\n"); printf("You cannot run it with a multiple processes\n"); printf("Either only run it with one process or do a \n"); printf(" ./configure --enable-mpi\n"); printf(" make clean\n"); printf(" make \n"); exit(5); } #endif // work out number of sequences // if the user has specified a value for num_seqs then // use that, else use the number of sequences in the file num_seqs = count_seqs(argv[optind], &data_size)+reindex_value; seq = (SeqPtr *) calloc(num_seqs,sizeof(SeqPtr)); seqInfo = (SeqInfoPtr) calloc(num_seqs,sizeof(SeqInfoStruct)); tree= (UnionFindPtr) calloc(num_seqs,sizeof(UnionFindStruct)); data= (SeqPtr) calloc(data_size,sizeof(SeqElt)); init_dummy_sequences(); #ifndef AUXINFO seqID = (SeqIDPtr) calloc(num_seqs,sizeof(SeqIDStruct)); #endif if (seq == NULL) { perror("SeqStruct allocation"); exit(50); } numinfirst = global_i_end = num_seqs; global_j_beg = 0; // if merging, need to check the other file too if (prog_opts.domerge || prog_opts.doadd ) { global_j_beg = global_i_end; num_seqs = handleMerge(argv[optind+2], num_seqs); if (prog_opts.doadd) global_i_end = num_seqs; } initialise(work, prog_opts.edfile); if (data == NULL) { sprintf(chkfile,"Main data store (%d bytes)",data_size); perror(chkfile); exit(51); } for(i=0; i<num_seqs; i++) seqInfo[i].flag=0; // reopen sequence file for reading finp = fopen(argv[optind],"r"); if (finp == NULL) { perror(argv[optind]); exit(51); } // Some messy stuff to hande auxiliary options // Skip to next comment on first reading if (prog_opts.pairwise==1) { sscanf(argv[optind+1], "%d", &i); sscanf(argv[optind+2], "%d", &j); show_pairwise(finp,i,j); return 0; } if (prog_opts.statgen) { compared2nummatches(finp,prog_opts.statgen); return 0; } if (prog_opts.range) { sscanf(argv[optind+1], "%d", &global_i_beg); sscanf(argv[optind+2], "%d", &global_i_end); } if (prog_opts.show_comp==41) { char * fname; fname = malloc(255); sscanf(argv[optind+1], "%s", fname); read_sequences(finp,reindex_value,num_seqs); checkfile = fopen(fname,"r"); sscanf(argv[optind+2], "%d", &j); while (fscanf(checkfile,"%d", &i) != -1) { do_compare(finp,i,j,1); } return 0; } if (prog_opts.show_comp) { sscanf(argv[optind+1], "%d", &i); sscanf(argv[optind+2], "%d", &j); //printf("Comparing %d and %d of %d flag %d\n",i,j,num_seqs,prog_opts.flag); read_sequences(finp,reindex_value,num_seqs); do_compare(finp,i,j,prog_opts.flag); return 0; } if (prog_opts.show_index) { show_sequence(finp, prog_opts.index,prog_opts.flag); return 0; } // Now read in the sequences if (do_cluster == do_pairwise_cluster||do_cluster==do_MPImaster_cluster||do_cluster == do_suffix_cluster) read_sequences(finp,reindex_value,numinfirst); else init_sequences(finp,reindex_value,numinfirst); fclose(finp); //printf("%d Allocated %d, start=%d, last=%d\n",num_seqs,data_size,data,seq[num_seqs-1].seq); if (prog_opts.split) { process_split(prog_opts.clfname1, prog_opts.split); #ifdef MPI MPI_Finalize(); #endif return 0; } if (prog_opts.consfname1) process_constraints(prog_opts.consfname1,0); if (prog_opts.clustercomp) { cluster_compare(argv[optind+1]); return 0; } // If merging or adding need to open the second sequence file if (prog_opts.domerge || prog_opts.doadd) { finp = fopen(argv[optind+2], "r"); if (finp == NULL) { perror(argv[optind]); exit(1); } if (do_cluster == do_pairwise_cluster) read_sequences(finp,numinfirst+reindex_value,num_seqs); else init_sequences(finp,numinfirst+reindex_value,num_seqs); get_clustering(argv[optind+1],0); if (prog_opts.domerge) get_clustering(argv[optind+3],numinfirst); } if (prog_opts.init_cluster) get_clustering(prog_opts.clfname1, 0); if (prog_opts.recluster) reclustering(work,prog_opts.clfname2); else { // This really assumes there is only one thread for suffix if (prog_opts.pairwise==2) { matrix_compare(finp); return 0; } work->workflag = prog_opts.noninterleavednlc;//kludge for suffixarray global_j_end = num_seqs; perform_clustering(work); #ifdef MPI if (myid>0) transmitMPISlaveResponse(work); #endif } if (prog_opts.show_ext) show_EXT(outf); if (prog_opts.show_histo) show_histogram(work); if (prog_opts.show_clust&1) show_clusters(outf); if (prog_opts.show_clust&8) produce_clusters(prog_opts.clthresh,prog_opts.dirname); if (prog_opts.show_perf) show_performance(outf); if (prog_opts.do_dump) { strcpy(chkfile,prog_opts.dname); strcat(chkfile,"-FIN"); fclose(dump_file); dump_file = fopen(chkfile,"w"); times(&usage); ticks = sysconf(_SC_CLK_TCK); fprintf(dump_file,"Completed %ld %ld", usage.tms_utime/ticks, usage.tms_stime*1000/ticks); fclose(dump_file); } if (prog_opts.show_version) fprintf(outf,"\n%s\n",version); fclose(outf); #ifdef MPI MPI_Finalize(); #endif exit(0); }
static void compare_txs( QofBook* book_1, QofBook* book_2 ) { do_compare( book_1, book_2, GNC_ID_TRANS, compare_single_tx, "Transaction lists match" ); }
int param_main(int argc, char *argv[]) { if (argc >= 2) { if (!strcmp(argv[1], "save")) { if (argc >= 3) { return do_save(argv[2]); } else { if (param_save_default()) { warnx("Param export failed."); return 1; } else { return 0; } } } if (!strcmp(argv[1], "load")) { if (argc >= 3) { return do_load(argv[2]); } else { return do_load(param_get_default_file()); } } if (!strcmp(argv[1], "import")) { if (argc >= 3) { return do_import(argv[2]); } else { return do_import(param_get_default_file()); } } if (!strcmp(argv[1], "select")) { if (argc >= 3) { param_set_default_file(argv[2]); } else { param_set_default_file(NULL); } warnx("selected parameter default file %s", param_get_default_file()); return 0; } if (!strcmp(argv[1], "show")) { if (argc >= 3) { do_show(argv[2]); return 0; } else { do_show(NULL); return 0; } } if (!strcmp(argv[1], "set")) { if (argc >= 5) { /* if the fail switch is provided, fails the command if not found */ bool fail = !strcmp(argv[4], "fail"); return do_set(argv[2], argv[3], fail); } else if (argc >= 4) { return do_set(argv[2], argv[3], false); } else { warnx("not enough arguments.\nTry 'param set PARAM_NAME 3 [fail]'"); return 1; } } if (!strcmp(argv[1], "compare")) { if (argc >= 4) { return do_compare(argv[2], &argv[3], argc - 3); } else { warnx("not enough arguments.\nTry 'param compare PARAM_NAME 3'"); return 1; } } if (!strcmp(argv[1], "reset")) { if (argc >= 3) { return do_reset((const char **) &argv[2], argc - 2); } else { return do_reset(NULL, 0); } } if (!strcmp(argv[1], "reset_nostart")) { if (argc >= 3) { return do_reset_nostart((const char **) &argv[2], argc - 2); } else { return do_reset_nostart(NULL, 0); } } if (!strcmp(argv[1], "index_used")) { if (argc >= 3) { do_show_index(argv[2], true); } else { warnx("no index provided"); return 1; } } if (!strcmp(argv[1], "index")) { if (argc >= 3) { do_show_index(argv[2], false); } else { warnx("no index provided"); return 1; } } } warnx("expected a command, try 'load', 'import', 'show', 'set', 'compare', 'select' or 'save'"); return 1; }
static void compare_lots( QofBook* book_1, QofBook* book_2 ) { do_compare( book_1, book_2, GNC_ID_LOT, compare_single_lot, "Lot lists match" ); }
static void compare_sxs( QofBook* book_1, QofBook* book_2 ) { do_compare( book_1, book_2, GNC_ID_SCHEDXACTION, compare_single_sx, "Scheduled transaction lists match" ); }
main (int np, char **p) { int help = 0,/* request command line help */ layout_only = 0; /* print disk layout only */ int status,/* disk open or I/O status return */ i; /* loop index */ /* variables to handle fill characters */ unsigned char src_fill = 'S', dst_fill = 'D'; int is_fill, id_fill; /* source disk parameters */ static disk_control_ptr src_dcb; /* drive information */ char src_drive[NAME_LENGTH] = "/dev/hda"; /* source drive, default is Master on Primary IDE */ pte_rec src_pt[4]; /* partition table for source disk */ int src_n_regions = 0; /* number of chunks on the source */ layout_ptr src_layout = (layout_ptr) malloc(MAX_PARTITIONS*sizeof(layout_rec)); /* chunks */ /* destination disk parameters */ static disk_control_ptr dst_dcb; char dst_drive[NAME_LENGTH] = "/dev/hdb"; pte_rec dst_pt[4]; int dst_n_regions = 0; layout_ptr dst_layout = (layout_ptr) malloc(MAX_PARTITIONS*sizeof(layout_rec)); FILE *log; /* log file */ char comment [NAME_LENGTH] = "", log_name[NAME_LENGTH] = "cmpalog.txt", access[2] = "a"; /* tester (user) comment for log file */ static time_t from; /* time program started running */ int assign_regions = 0; /* flag: user wants to assign corresponding chunks */ /* _stklen = 2*_stklen; */ printf ("\n%s Version 3.1 compiled at %s on %s\n", p[0], __TIME__,__DATE__); /****************************************************************************** Get command line ******************************************************************************/ if (np < 8) { printf ("%s: Missing parameters\n",p[0]); help = 1; } else { sscanf (p[5],"%2x",&is_fill); src_fill = is_fill; sscanf (p[7],"%2x",&id_fill); dst_fill = id_fill; strncpy(src_drive, p[4], NAME_LENGTH - 1); strncpy(dst_drive, p[6], NAME_LENGTH - 1); printf ("Src drive %s dst drive %s\n",src_drive,dst_drive); printf ("Src fill 0x%02X dst fill 0x%02X\n",src_fill,dst_fill); } for (i = 8; i < np; i++) { if (strcmp(p[i], "-assign") == 0) assign_regions = 1; else if (strcmp (p[i], "-h") == 0) help = 1; else if (strcmp (p[i], "-layout") == 0) layout_only = 1; else if (strcmp (p[i], "-new_log")== 0) access[0] = 'w'; else if (strcmp (p[i], "-log_name") == 0) { if(++i >= np) { printf("%s: -log_name option requires a logfile name\n", p[0]); help = 1; } else strncpy(log_name, p[i], NAME_LENGTH - 1); } else if (strcmp (p[i],"-comment")== 0) { i++; if (i >= np) { printf ("%s: comment required with -comment\n", p[0]); print_help(p[0]); return 1; } strncpy (comment,p[i], NAME_LENGTH - 1); } else { printf("Invalid parameter: %s\n", p[i]); help = 1; } } if (help) { print_help(p[0]); return 0; } /****************************************************************************** Start log file, open source disk and get partition table ******************************************************************************/ log = log_open (log_name, access, comment, SCCS_ID, np, p); fprintf (log, "Src drive %s dst drive %s\n",src_drive,dst_drive); fprintf (log, "Src fill 0x%02X dst fill 0x%02X\n",src_fill,dst_fill); src_dcb = open_disk (src_drive,&status); if (status) { printf ("Could not access source drive %s status code %d\n",src_drive,status); return 1; } log_disk (log,"Source Disk",src_dcb); status = get_partition_table(src_dcb,src_pt); if (status == 0) { fprintf (log,"Source disk partition table\n"); print_partition_table(log,src_pt,0,1); print_partition_table(stdout,src_pt,1,1); } else { fprintf (log,"Error reading src partition table code %d\n", status); printf ("No partition table signature or error reading partition table (code %d)\n",status); return 1; } time(&from); src_n_regions = layout_disk (src_pt,src_layout,src_dcb); printf ("%d regions\n",src_n_regions); fprintf (log,"Source disk layout: "); fprintf (log," %05llu/%03llu/%02llu ", src_dcb->disk_max.cylinder, src_dcb->disk_max.head, src_dcb->disk_max.sector); fprintf (log,"%llu total sectors on disk\n",src_dcb->n_sectors); fprintf (log,"%4s%10s%10s%10s%23s\n","","Start LBA","End LBA","Length", "Size: MB (binary)"); for (i = 0; i < src_n_regions; i++){ printf ("%2d %c %9llu %9llu %9llu %8.2fMB %8.2fBMB\n", i, src_layout[i].chunk_class, src_layout[i].lba_start, src_layout[i].lba_start + src_layout[i].n_sectors - 1, src_layout[i].n_sectors, BYTES_PER_SECTOR*(float)src_layout[i].n_sectors/1000000.0, BYTES_PER_SECTOR*(float)src_layout[i].n_sectors/1048576.0); fprintf (log,"%2d %c %9llu %9llu %9llu %8.2fMB %8.2fBMB\n", i, src_layout[i].chunk_class, src_layout[i].lba_start, src_layout[i].lba_start + src_layout[i].n_sectors - 1, src_layout[i].n_sectors, BYTES_PER_SECTOR*(float)src_layout[i].n_sectors/1000000.0, BYTES_PER_SECTOR*(float)src_layout[i].n_sectors/1048576.0); } /****************************************************************************** Open destination disk, get partition table ******************************************************************************/ dst_dcb = open_disk (dst_drive,&status); if (status) { printf ("Could not access destination drive %s status code %d\n",dst_drive,status); return 1; } log_disk (log,"Destination Disk",dst_dcb); status = get_partition_table(dst_dcb,dst_pt); if (status == 0){ fprintf (log,"Destination disk partition table\n"); print_partition_table(log,dst_pt,0,1); print_partition_table(stdout,dst_pt,1,1); } else { fprintf (log,"Error reading src partition table code %d\n", status); printf ("No partition table signature or error reading partition table (code %d)\n",status); return 1; } dst_n_regions = layout_disk (dst_pt,dst_layout,dst_dcb); printf ("%d regions on %s\n",dst_n_regions,dst_drive); fprintf (log,"Destination disk layout: "); fprintf (log," %05llu/%03llu/%02llu ", dst_dcb->disk_max.cylinder, dst_dcb->disk_max.head, dst_dcb->disk_max.sector); fprintf (log,"%llu total sectors on disk\n",dst_dcb->n_sectors); fprintf (log,"%4s%10s%10s%10s%23s\n","","Start LBA","End LBA","Length", "Size: MB (binary)"); for (i = 0; i < dst_n_regions; i++){ printf ("%2d %c %9llu %9llu %9llu %8.2fMB %8.2fBMB\n", i, dst_layout[i].chunk_class, dst_layout[i].lba_start, dst_layout[i].lba_start + dst_layout[i].n_sectors - 1, dst_layout[i].n_sectors, BYTES_PER_SECTOR * (double)dst_layout[i].n_sectors/1000000.0, BYTES_PER_SECTOR * (double)dst_layout[i].n_sectors/1048576.0); fprintf (log,"%2d %c %9llu %9llu %9llu %8.2fMB %8.2fBMB\n", i, dst_layout[i].chunk_class, dst_layout[i].lba_start, dst_layout[i].lba_start + dst_layout[i].n_sectors - 1, dst_layout[i].n_sectors, BYTES_PER_SECTOR * (double)dst_layout[i].n_sectors/1000000.0, BYTES_PER_SECTOR * (double)dst_layout[i].n_sectors/1048576.0); } /****************************************************************************** Do the compare ******************************************************************************/ if (layout_only == 0) status = do_compare(src_dcb,src_n_regions,src_layout,dst_dcb,dst_n_regions, dst_layout,src_fill,dst_fill,log,assign_regions,from); /****************************************************************************** Close the log file ******************************************************************************/ log_close(log,from); return 0; }
static void compare_jobs( QofBook* book_1, QofBook* book_2 ) { do_compare( book_1, book_2, GNC_ID_JOB, compare_single_job, "Job lists match" ); }
int param_main(int argc, char *argv[]) { if (argc >= 2) { if (!strcmp(argv[1], "save")) { if (argc >= 3) { return do_save(argv[2]); } else { int ret = do_save_default(); if (ret) { PX4_ERR("Param save failed (%i)", ret); return 1; } else { return 0; } } } if (!strcmp(argv[1], "load")) { if (argc >= 3) { return do_load(argv[2]); } else { return do_load(param_get_default_file()); } } if (!strcmp(argv[1], "import")) { if (argc >= 3) { return do_import(argv[2]); } else { return do_import(param_get_default_file()); } } if (!strcmp(argv[1], "select")) { if (argc >= 3) { param_set_default_file(argv[2]); } else { param_set_default_file(NULL); } PX4_INFO("selected parameter default file %s", param_get_default_file()); return 0; } if (!strcmp(argv[1], "show")) { if (argc >= 3) { // optional argument -c to show only non-default params if (!strcmp(argv[2], "-c")) { if (argc >= 4) { return do_show(argv[3], true); } else { return do_show(NULL, true); } } else { return do_show(argv[2], false); } } else { return do_show(NULL, false); } } if (!strcmp(argv[1], "set")) { if (argc >= 5) { /* if the fail switch is provided, fails the command if not found */ bool fail = !strcmp(argv[4], "fail"); return do_set(argv[2], argv[3], fail); } else if (argc >= 4) { return do_set(argv[2], argv[3], false); } else { PX4_ERR("not enough arguments.\nTry 'param set PARAM_NAME 3 [fail]'"); return 1; } } if (!strcmp(argv[1], "compare")) { if (argc >= 4) { return do_compare(argv[2], &argv[3], argc - 3, COMPARE_OPERATOR_EQUAL); } else { PX4_ERR("not enough arguments.\nTry 'param compare PARAM_NAME 3'"); return 1; } } if (!strcmp(argv[1], "greater")) { if (argc >= 4) { return do_compare(argv[2], &argv[3], argc - 3, COMPARE_OPERATOR_GREATER); } else { PX4_ERR("not enough arguments.\nTry 'param greater PARAM_NAME 3'"); return 1; } } if (!strcmp(argv[1], "reset")) { if (argc >= 3) { return do_reset((const char **) &argv[2], argc - 2); } else { return do_reset(NULL, 0); } } if (!strcmp(argv[1], "reset_nostart")) { if (argc >= 3) { return do_reset_nostart((const char **) &argv[2], argc - 2); } else { return do_reset_nostart(NULL, 0); } } if (!strcmp(argv[1], "index_used")) { if (argc >= 3) { return do_show_index(argv[2], true); } else { PX4_ERR("no index provided"); return 1; } } if (!strcmp(argv[1], "index")) { if (argc >= 3) { return do_show_index(argv[2], false); } else { PX4_ERR("no index provided"); return 1; } } if (!strcmp(argv[1], "find")) { if (argc >= 3) { return do_find(argv[2]); } else { PX4_ERR("not enough arguments.\nTry 'param find PARAM_NAME'"); return 1; } } } PX4_INFO("expected a command, try 'load', 'import', 'show [-c] [<filter>]', 'set <param> <value>', 'compare',\n'index', 'index_used', 'find', 'greater', 'select', 'save', or 'reset' "); return 1; }
static void compare_vendors( QofBook* book_1, QofBook* book_2 ) { do_compare( book_1, book_2, GNC_ID_VENDOR, compare_single_vendor, "Vendor lists match" ); }
int __seqof1::operator != (const __seqof1 & that) const { return !do_compare(that, &__seqof1_compare); }