Exemplo n.º 1
0
int iplink_ifla_xstats(int argc, char **argv)
{
	struct link_util *lu = NULL;
	__u32 filt_mask;

	if (!argc) {
		fprintf(stderr, "xstats: missing argument\n");
		return -1;
	}

	if (matches(*argv, "type") == 0) {
		NEXT_ARG();
		lu = get_link_kind(*argv);
		if (!lu)
			invarg("invalid type", *argv);
	} else if (matches(*argv, "help") == 0) {
		print_explain(stdout);
		return 0;
	} else {
		invarg("unknown argument", *argv);
	}

	if (!lu) {
		print_explain(stderr);
		return -1;
	}

	if (!lu->print_ifla_xstats) {
		fprintf(stderr, "xstats: link type %s doesn't support xstats\n",
			lu->id);
		return -1;
	}

	if (lu->parse_ifla_xstats &&
	    lu->parse_ifla_xstats(lu, argc-1, argv+1))
		return -1;

	if (strstr(lu->id, "_slave"))
		filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS_SLAVE);
	else
		filt_mask = IFLA_STATS_FILTER_BIT(IFLA_STATS_LINK_XSTATS);

	if (rtnl_wilddump_stats_req_filter(&rth, AF_UNSPEC,
					   RTM_GETSTATS,
					   filt_mask) < 0) {
		perror("Cannont send dump request");
		return -1;
	}

	if (rtnl_dump_filter(&rth, lu->print_ifla_xstats, stdout) < 0) {
		fprintf(stderr, "Dump terminated\n");
		return -1;
	}

	return 0;
}
Exemplo n.º 2
0
/* Prints the helptext for options in a generated form */
static tvalue print_flags(option_clone *opts,
  gen_cli_helpstr *opts_explain,
  unsigned int arglen,unsigned int cols)
{
  register unsigned int beta=0, gamma;
  unsigned int optcount = 0, curlen;
  unsigned int conslen = PRINTSPACELEN+2;

  if(opts)
    while(opts[optcount].longflag != NULL || opts[optcount].has_arg != 0
      || opts[optcount].shortflag != 0)
      optcount++;

  /* do the printing */
  for(beta = 0; beta < optcount; beta++)
  {
    curlen = conslen;

    print_out(PRINTSPACE);
    if(opts[beta].shortflag != 0)
      print_out("-%c", opts[beta].shortflag);

    if(opts[beta].longflag != NULL)
    {
      curlen += 4 + strlen(opts[beta].longflag);

      if(opts[beta].shortflag != 0)
        iolet_out_char(IL_IOStd,',');

      else
        print_out("   ");

      print_out(" --%s", opts[beta].longflag);

      if(opts_explain[beta].arg != NULL)
      {
        curlen += 1 + strlen(opts_explain[beta].arg);
        print_out(" %s", opts_explain[beta].arg);
      }
    }

    for(gamma = curlen; gamma < arglen; gamma++)
      iolet_out_char(IL_IOStd,' ');
  
    print_explain(arglen, opts_explain[beta].desc,cols);
  }

  iolet_out_char(IL_IOStd,'\n');

  return TRUE;
}
Exemplo n.º 3
0
Arquivo: dict.c Projeto: hhktony/dict
void get_explanation(pnode_t p)
{
	char buffer[EXPLAIN_LEN];
	FILE *fp;
    
    if (( fp = fopen(DICT_FILENAME, "r+")) == NULL)
		IERROR("Open '%s'failed!", DICT_FILENAME);

	fseek(fp, p->pos, SEEK_SET);
	fgets(buffer, WORD_LEN, fp);
	fgets(buffer, EXPLAIN_LEN, fp);
	print_explain(buffer);

	fclose(fp);
}
Exemplo n.º 4
0
static void explain(void)
{
	print_explain(stderr);
}
Exemplo n.º 5
0
static void bridge_print_help(struct link_util *lu, int argc, char **argv,
		FILE *f)
{
	print_explain(f);
}
Exemplo n.º 6
0
static void
format_pairs(FILE *f,
             const p3_global_settings *pa,
             const seq_args *sa,
             const p3retval *retval,
             const pair_array_t *best_pairs,
             const char *pr_release,
             const pr_append_str *combined_retval_err,
             int explain_flag)
{
  char *warning;
  int print_lib_sim = lib_sim_specified(pa);
  primer_rec *h = NULL;

  PR_ASSERT(NULL != f);
  PR_ASSERT(NULL != pa);
  PR_ASSERT(NULL != sa);
  
  /* If there are errors, print them and return */
  if (!pr_is_empty(combined_retval_err)) {
    format_error(f, sa->sequence_name, 
                 pr_append_str_chars(combined_retval_err));
    return;
    }
  
  /* Print the sequence name if it is provided */
  if (NULL != sa->sequence_name)
    fprintf(f, "PRIMER PICKING RESULTS FOR %s\n\n", sa->sequence_name);
  
  /* Print if a mispriming libraby was used and which one */
  if (pa->p_args.repeat_lib != NULL)
    fprintf(f, "Using mispriming library %s\n",
            pa->p_args.repeat_lib->repeat_file);
  else
    fprintf(f, "No mispriming library specified\n");

  /* Print if a mispriming libraby for the internal oligo 
   * was used and which one */
  if ( pa->pick_internal_oligo == 1 ) {
    if (pa->o_args.repeat_lib != NULL)
      fprintf(f, "Using internal oligo mishyb library %s\n",
              pa->o_args.repeat_lib->repeat_file);
    else
      fprintf(f, "No internal oligo mishyb library specified\n");
  }

  /* Does the sequence start at position 0 or 1 ? */
  fprintf(f, "Using %d-based sequence positions\n",
          pa->first_base_index);
  
  /* Complain if no primers are in the array */
  if (best_pairs->num_pairs == 0) fprintf(f, "NO PRIMERS FOUND\n\n");
  
  /* Print out the warings */
  if ((warning = p3_get_rv_and_gs_warnings(retval, pa)) != NULL) {
    fprintf(f, "WARNING: %s\n\n", warning);
    free(warning);
  }
  
  /* Print the results for the best pair */
  print_summary(f, pa, sa, best_pairs, 0);
  fprintf(f, "\n");

  /* Print nicely out the sequence with the best pair */
  if (print_seq(f, pa, sa, retval, h, best_pairs, 0)) exit(-2); /* ENOMEM */
  
  /* Print out the alternative pairs */
  if (best_pairs->num_pairs > 1 ) print_rest(f, pa, sa, best_pairs);
  
  /* Print the primer picking statistics */
  if (explain_flag)
    print_explain(f, pa, sa, retval, print_lib_sim, pr_release);
  
  /* Flush the buffers and return */
  fprintf(f, "\n\n");
  if (fflush(f) == EOF) {
    perror("fflush(f) failed");
    exit(-1);
  }

}
Exemplo n.º 7
0
static void
format_oligos(FILE *f,
              const p3_global_settings *pa,
              const seq_args    *sa,
              const p3retval *retval,
              const char* pr_release,
              const pr_append_str *combined_retval_err,
              int explain_flag)
{
    char *warning;
    int print_lib_sim = lib_sim_specified(pa);
    int i;
    int print_primers = 0;
    primer_rec  *h = NULL;
    pair_array_t *best_pairs;
    primer_rec *p;
    int rest_count = 0;

    PR_ASSERT(NULL != f);
    PR_ASSERT(NULL != pa);
    PR_ASSERT(NULL != sa);

    best_pairs = NULL;

    if (!pr_is_empty(combined_retval_err)) {
        format_error(f, sa->sequence_name, pr_append_str_chars(combined_retval_err));
        return;
    }

    if (NULL != sa->sequence_name)
        fprintf(f, "PRIMER PICKING RESULTS FOR %s\n\n", sa->sequence_name);
    if (pa->pick_left_primer || pa->pick_right_primer) {
        if (pa->p_args.repeat_lib != NULL)
            fprintf(f, "Using mispriming library %s\n",
                    pa->p_args.repeat_lib->repeat_file);
        else
            fprintf(f, "No mispriming library specified\n");
    }
    if (pa->pick_internal_oligo) {
        if (pa->o_args.repeat_lib != NULL)
            fprintf(f, "Using internal probe mishyb library %s\n", pa->o_args.repeat_lib->repeat_file);
        else
            fprintf(f, "No internal probe mishyb library specified\n");
    }
    fprintf(f, "Using %d-based sequence positions\n", pa->first_base_index);

    if (pa->pick_left_primer) {
        if (retval->fwd.num_elem == 0) {
            fprintf(f, "NO LEFT PRIMER FOUND\n\n");
        } else {
            print_primers = 1;
        }
    }
    if (pa->pick_internal_oligo) {
        if (retval->intl.num_elem == 0) {
            fprintf(f, "NO INTERNAL PROBE FOUND\n\n");
        } else {
            print_primers = 1;
        }
    }
    if (pa->pick_right_primer) {
        if (retval->rev.num_elem == 0) {
            fprintf(f, "NO RIGHT PRIMER FOUND\n\n");
        } else {
            print_primers = 1;
        }
    }
    if ((warning = p3_get_rv_and_gs_warnings(retval, pa)) != NULL) {
        fprintf(f, "\nWARNING: %s\n", warning);
        free(warning);
    }
    if ((pa->primer_task != pick_primer_list ) && (pa->primer_task != pick_sequencing_primers)) {
        if (print_primers == 1) {
            print_oligo_header(f, "OLIGO", print_lib_sim, pa->thermodynamic_alignment, sa->tar2.genotyping);
        }

        /* Print out the first line with the best primers */
        if ((pa->pick_left_primer) && (&retval->fwd != NULL ) && (retval->fwd.num_elem > 0)) {
            if(pa->modify_left_primer==1) {
                print_oligo_Z(f, TITLE_MOD_LEFT, sa, retval->fwd.oligo, OT_LEFT, pa, pa->p_args.repeat_lib, print_lib_sim);
            } else {
                print_oligo_Z(f, TITLE_LEFT, sa, retval->fwd.oligo, OT_LEFT, pa, pa->p_args.repeat_lib, print_lib_sim);
            }
            h = retval->fwd.oligo;
            rest_count = 1;
        }

        if ((pa->pick_internal_oligo) && (&retval->intl != NULL ) && (retval->intl.num_elem > 0)) {
            if(pa->modify_internal_oligo==1) {
                if((retval->intl.oligo)->oligo_dir==0) {
                    print_oligo_Z(f, TITLE_MOD_INTL_FW, sa, retval->intl.oligo, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                } else if((retval->intl.oligo)->oligo_dir==1) {
                    print_oligo_Z(f, TITLE_MOD_INTL_RV, sa, retval->intl.oligo, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                }
            } else {
                if((retval->intl.oligo)->oligo_dir==0) {
                    print_oligo_Z(f, TITLE_INTL_FW, sa, retval->intl.oligo, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                } else if((retval->intl.oligo)->oligo_dir==1) {
                    print_oligo_Z(f, TITLE_INTL_RV, sa, retval->intl.oligo, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                }
            }
            h = retval->intl.oligo;
            rest_count = 1;
        }

        if ((pa->pick_right_primer) && (&retval->rev != NULL ) && (retval->rev.num_elem > 0)) {
            if(pa->modify_right_primer==1) {
                print_oligo_Z(f, TITLE_MOD_RIGHT, sa, retval->rev.oligo, OT_RIGHT, pa, pa->p_args.repeat_lib, print_lib_sim);
            } else {
                print_oligo_Z(f, TITLE_RIGHT, sa, retval->rev.oligo, OT_RIGHT, pa, pa->p_args.repeat_lib, print_lib_sim);
            }
            h = retval->rev.oligo;
            rest_count = 1;
        }
    }

    if(print_primers == 1) {
        fprintf(f, "SEQUENCE SIZE: %ld\n", (long int) strlen(sa->sequence));
        fprintf(f, "INCLUDED REGION SIZE: %d\n\n", sa->incl_l);

        if(sa->tar2.genotyping==0) {
            print_pair_array(f, "TARGETS", sa->tar2.count, sa->tar2.pairs, pa, sa);
        } else if(sa->tar2.genotyping==1) {
            fprintf(f,"TARGET VARIANT * (position,size):");
            if(sa->tar2.char_count==sa->tar2.VAR_sequence_number) {
                fprintf(f," %d,%d",sa->tar2.VAR_start[0],sa->tar2.char_num[sa->tar2.VAR_sequence_number]-1);
            } else {
                fprintf(f," %d,%d",sa->tar2.VAR_start[0],sa->tar2.char_num[sa->tar2.VAR_sequence_number]);
            }
            fprintf(f,"\n\n");
        }

        print_pair_array(f, "EXCLUDED REGIONS", sa->excl2.count, sa->excl2.pairs, pa, sa);
        print_pair_array(f, "INTERNAL PROBE EXCLUDED REGIONS", sa->excl_internal2.count, sa->excl_internal2.pairs, pa, sa);
        print_2_pair_array(f, "PAIR_OK_REGIONS", sa->ok_regions.count, sa->ok_regions.left_pairs, sa->ok_regions.right_pairs, pa, sa);
    }

    if (pa->primer_task != pick_primer_list ) {
        if(pa->pick_internal_oligo==1) {
            if(print_seq(f,pa,sa,retval,retval->intl.oligo,best_pairs,0)) exit(-2);
        }
        else if(pa->pick_left_primer==1) {
            if(print_seq(f,pa,sa,retval,retval->fwd.oligo,best_pairs,0)) exit(-2);
        }
        else if(pa->pick_right_primer==1) {
            if(print_seq(f,pa,sa,retval,retval->rev.oligo,best_pairs,0)) exit(-2);
        }
        else if (print_seq(f, pa, sa, retval, h, best_pairs, 0)) exit(-2); /* ENOMEM */
    }
    fprintf(f, "\n");

    /* Print out the other primers */
    if ((pa->pick_left_primer) && (&retval->fwd != NULL ) && (retval->fwd.num_elem > rest_count)) {
        int n = retval->fwd.num_elem;
        h = retval->fwd.oligo;
        if (rest_count == 1) {
            fprintf(f, "ADDITIONAL OLIGOS\n");
        }
        fprintf(f, "   ");
        print_oligo_header(f, "", print_lib_sim, pa->thermodynamic_alignment, sa->tar2.genotyping);
        for (i = rest_count; i < pa->num_return; i++) {
            if(i > n-1) break;
            p = h + i;
            fprintf(f, "%2d ", i + 1 - rest_count);
            if(pa->modify_left_primer==1) {
                print_oligo_Z(f, TITLE_MOD_LEFT, sa, p, OT_LEFT, pa, pa->p_args.repeat_lib, print_lib_sim);
            } else {
                print_oligo_Z(f, TITLE_LEFT, sa, p, OT_LEFT, pa, pa->p_args.repeat_lib, print_lib_sim);
            }
        }
        if (rest_count == 0) {
            fprintf(f, "\n ");
        }
    }

    if ((pa->pick_internal_oligo) && (&retval->intl != NULL ) && (retval->intl.num_elem > rest_count)) {
        int n = retval->intl.num_elem;
        h = retval->intl.oligo;

        if (rest_count == 1) {
            fprintf(f, "ADDITIONAL OLIGOS\n");
        }
        fprintf(f, "   ");
        print_oligo_header(f, "", print_lib_sim, pa->thermodynamic_alignment, sa->tar2.genotyping);
        for (i = rest_count; i < pa->num_return; i++) {
            if(i > n-1) break;
            p = h + i;
            fprintf(f, "%2d ", i + 1 - rest_count);

            if(pa->modify_internal_oligo==1) {
                if(p->oligo_dir==0) {
                    print_oligo_Z(f, TITLE_MOD_INTL_FW, sa, p, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                } else if(p->oligo_dir==1) {
                    print_oligo_Z(f, TITLE_MOD_INTL_RV, sa, p, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                }
            } else {
                if(p->oligo_dir==0) {
                    print_oligo_Z(f, TITLE_INTL_FW, sa, p, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                } else if(p->oligo_dir==1) {
                    print_oligo_Z(f, TITLE_INTL_RV, sa, p, OT_INTL, pa, pa->p_args.repeat_lib, print_lib_sim);
                }
            }
        }
        if (rest_count == 0) {
            fprintf(f, "\n ");
        }
    }

    if ((pa->pick_right_primer) && (&retval->rev != NULL ) && (retval->rev.num_elem > rest_count)) {
        int n = retval->rev.num_elem;
        h = retval->rev.oligo;
        if (rest_count == 1) {
            fprintf(f, "ADDITIONAL OLIGOS\n");
        }
        fprintf(f, "   ");
        print_oligo_header(f, "", print_lib_sim, pa->thermodynamic_alignment, sa->tar2.genotyping);
        for (i = rest_count; i < pa->num_return; i++) {
            if(i > n-1) break;
            p = h + i;
            fprintf(f, "%2d ", i + 1 - rest_count);
            if(pa->modify_right_primer==1) {
                print_oligo_Z(f, TITLE_MOD_RIGHT, sa, p, OT_RIGHT, pa, pa->p_args.repeat_lib, print_lib_sim);
            } else {
                print_oligo_Z(f, TITLE_RIGHT, sa, p, OT_RIGHT, pa, pa->p_args.repeat_lib, print_lib_sim);
            }
        }
    }
    if (explain_flag)
        print_explain(f, pa, sa, retval, print_lib_sim, pr_release);
    fprintf(f, "\n\n");
    if (fflush(f) == EOF) {
        perror("fflush(f) failed");
        exit(-1);
    }
}
Exemplo n.º 8
0
static void explain(struct link_util *lu)
{
	print_explain(lu, stderr);
}
Exemplo n.º 9
0
static void macvlan_print_help(struct link_util *lu, int argc, char **argv,
	FILE *f)
{
	print_explain(lu, f);
}
Exemplo n.º 10
0
/* Recursive help */
tvalue gen_cli_print_help(char *prog_name,gen_cli_argument *arg)
{
  unsigned int arglen;
  unsigned int rows,cols;
  char *format_mand=" <%s>",*format_opt=" [%s]";
  char *cmd_fmt=format_mand,*flag_fmt=format_mand;

  ARG_ASSERT(!prog_name || !arg,FALSE);

  print_out("\nUsage: ");

  if(arg->cmd != NULL)
    print_command_path(prog_name,arg);
  else
    print_out("%s",prog_name);

  if(arg->helpcmdparameter != NULL)
    print_out(" %s",arg->helpcmdparameter);

  /* check if commands or flags are optional */
  if(arg->flags & GEN_CLI_CMDS_OPTIONAL)
    cmd_fmt=format_opt;
  if(arg->flags & GEN_CLI_FLAGS_OPTIONAL)
    flag_fmt=format_opt;

  if(arg->subcmds)
    print_out(cmd_fmt,"command");
  if(arg->opt.options != NULL)
    print_out(flag_fmt,"options");

  if(arg->helpcmdextra != NULL)
    print_out(" %s",arg->helpcmdextra);

  print_out("\n\n");
  get_win_size(&rows,&cols);
  print_explain(0,arg->cmdhelp,cols);
  print_out("\n\n");

  arglen = getprintpos(arg);

  /* print short descriptions of the subcommands */
  if(arg->subcmds)
  {
    register unsigned int beta,gamma;
    unsigned int curlen=0;

    /*
    if(arg->cmd != NULL)
      print_out("Subc");
    else
      print_out("C");
    */

    print_out("%sommands:\n", (arg->cmd) ? "Subc" : "C");

    for(beta=0;arg->subcmds[beta];beta++)
    {
      curlen=PRINTSPACELEN + strlen(arg->subcmds[beta]->cmd);

      print_out(PRINTSPACE "%s",arg->subcmds[beta]->cmd);

      if(arg->subcmds[beta]->shortcmd != 0)
        print_out(" (%c)",arg->subcmds[beta]->shortcmd);

      for(gamma = curlen; gamma < arglen; gamma++)
        print_out(" ");

      print_explain(arglen-1,arg->subcmds[beta]->cmdhelp,cols);

    }

    print_out("\n");
  }

  /* print out the flags */
  if(arg->opt.options)
  {
    print_out("Options:\n");
    print_flags(arg->opt.options,arg->opt.help_strs,arglen,cols);
  }

  return TRUE;
}