Esempio n. 1
0
void CLIF_print_options (const char *header,
				const CLIF_option *option_list) {
	const CLIF_option *optn;
	char *excl;
	int excl_cnt = 0;

	/*  Print a header string, if present...  */
	if (header)  fprintf (stderr, "%s\n", header);

	if (!option_list)  return;


	for (optn = option_list; optn->short_opt || optn->long_opt; optn++) {
	    int len;

	    /*  generate and print an option usage   */

	    if (optn->short_opt) {
		if (optn->long_opt)
		    len = fprintf (stderr, OPT_START_DLM "%s"
					   SHORT_LONG_DLM "%s",
					show_short (optn), show_long (optn));
		else
		    len = fprintf (stderr, OPT_START_DLM "%s",
						    show_short (optn));
	    } else
		len = fprintf (stderr, OPT_START_DLM "%s", show_long (optn));


	    /*  print a help string, if present   */
	    
	    if (optn->help_string)
		    box_output (len, OPT_FIELD_WIDTH,
				SCREEN_WIDTH - OPT_FIELD_WIDTH,
				optn->help_string, optn->arg_name);

	    fprintf (stderr, "\n");	/*  a last one   */
	}

	excl = show_excl (option_list, &excl_cnt);
	if (excl_cnt > 0) {

	    if (excl_cnt == 1) {
		if ((curr.parse_flags & CLIF_STRICT_EXCL) &&
		    curr.option_list == option_list
		)  fprintf (stderr, "Anyway `%s' must be specified.\n", excl);
		else  /*  simple ordinary option, because excl_cnt == 1 ... */;
	    } else
	        fprintf (stderr, "Only one of these may be specified:\n"
				 "    %s\n", excl);
	}

	return;
}
Esempio n. 2
0
static char *show_excl (const CLIF_option *option_list, int *cnt_p) {
	static char buf[256];
	const CLIF_option *optn;
	char *p = buf;
	char *endp = buf + sizeof (buf) - sizeof (EXCL_DLM);
	int excl_cnt = 0;

	*p = '\0';
	if (cnt_p)  *cnt_p = 0;
	if (!option_list)  return buf;

	for (optn = option_list; optn->short_opt || optn->long_opt; optn++) {
	    char *s;

	    if (!(optn->flags & CLIF_EXCL))  continue;

	    if (optn->short_opt)  s = show_short (optn);
	    else  s = show_long (optn);

	    if (excl_cnt > 0) {	    /*  i.e., second etc...  */
		    strcpy (p, EXCL_DLM);
		    p += sizeof (EXCL_DLM) - 1;
	    }

	    while (*s && p < endp)  *p++ = *s++;

	    excl_cnt++;
	}

	*p = '\0';

	if (cnt_p)  *cnt_p = excl_cnt;

	return buf;
}
Esempio n. 3
0
int main() {
	int intVariable = 10;
	float floatVariable = 2.5f;
	int* intPointer = &intVariable;
	int intValue = *intPointer;
	short shortVariable = 10;
	long longVariable = 65535;
	double doubleVariable = 0.000125f;

	printf("int:");
	show_int(intVariable);

	printf("float:");
	show_float(floatVariable);

	printf("pointer:");
	show_pointer(intPointer);

	printf("short:");
	show_short(shortVariable);

	printf("long:");
	show_long(longVariable);

	printf("double:");
	show_double(doubleVariable);
}
Esempio n. 4
0
void run_255() {
  printf("\nexersize 2.55: \n");
  show_int(1);
  show_short(12345);
  show_int(12345);
  show_long(12345);
  show_double(12345);
}
Esempio n. 5
0
static void test() {
  short s = 0x34AB;
  long l = 0x1122AABB;
  double d = 1.0;
  
  show_short(s);
  show_long(l);
  show_double(d);
}
Esempio n. 6
0
static void err_bad_arg (const CLIF_option *optn, char c, int n) {
	CLIF_option tmp = *optn;
	char ss[80];
	char *s;

	tmp.arg_name = NULL;

	if (c) {
	    s = show_short (&tmp);	/*  always without arg...  */
	    strncpy (ss, s, sizeof (ss));
	    s = show_short (optn);
	} else {
	    s = show_long (&tmp);	/*  always without arg...  */
	    strncpy (ss, s, sizeof (ss));
	    s = show_long (optn);
	}

	err_report ("%s `%s' (argc %d) requires an argument: `%s'",
		    (c || !is_keyword (optn)) ? "Option" : "Keyword", ss, n, s);
}
Esempio n. 7
0
void MethodTransform::remove_opcode(DexInstruction* insn) {
  for (auto const& mei : *m_fmethod) {
    if (mei.type == MFLOW_OPCODE && mei.insn == insn) {
      m_fmethod->erase(m_fmethod->iterator_to(mei));
      delete insn;
      return;
    }
  }
  always_assert_log(false,
                    "No match found while removing '%s' from method %s",
                    SHOW(insn),
                    show_short(m_method).c_str());
}
Esempio n. 8
0
File: 2-57.c Progetto: xiahei/TOTAL
int main (void)
{
    short short_x = 12345;
    long long_x = 12345;
    double double_x = 12345.0;

    printf ("show_short:\n");
    show_short (short_x);
    printf ("show_long:\n");
    show_long (long_x);
    printf ("show_double:\n");
    show_double (double_x);

}
Esempio n. 9
0
static void err_bad_excl (const CLIF_option *optn, char c, int n) {
	CLIF_option tmp = *optn;
	char *ss;
	char *excl = show_excl (curr.option_list, 0);
				/*  Note: show_(short|long)() nested!!! */

	tmp.arg_name = NULL;

	if (c)  ss = show_short (&tmp);
	else  ss = show_long (&tmp);

	err_report ("%s `%s' (argc %d): Only one of:\n    %s\n"
		    "may be specified.",
		    (c || !is_keyword (optn)) ? "Option" : "Keyword",
							    ss, n, excl);
}
Esempio n. 10
0
void MethodTransform::replace_opcode(DexInstruction* from, DexInstruction* to) {
  for (auto miter = m_fmethod->begin(); miter != m_fmethod->end(); miter++) {
    MethodItemEntry* mentry = &*miter;
    if (mentry->type == MFLOW_OPCODE && mentry->insn == from) {
      mentry->insn = to;
      delete from;
      return;
    }
  }
  always_assert_log(
      false,
      "No match found while replacing '%s' with '%s' in method %s",
      SHOW(from),
      SHOW(to),
      show_short(m_method).c_str());
}
Esempio n. 11
0
void test_show_bytes(int val)
{
    int ival    = val;
    float fval  = (float) ival;
    int *pval   = &ival;
    short sval  = (short) ival;
    long lval   = (long) ival;
    double dval = (double) ival;

    show_int(ival);
    show_float(fval);
    show_pointer(pval);
    show_short(sval);
    show_long(lval);
    show_double(dval);

    printf("\n");
}
Esempio n. 12
0
static void err_bad_res (const CLIF_option *optn, char c,
					const char *opt_arg, int n) {
	CLIF_option tmp = *optn;
	char *ss;
	const char *type;

	tmp.arg_name = NULL;

	if (c) {
	    ss = show_short (&tmp);
	    type = "option";
	} else {
	    ss = show_long (&tmp);
	    type = is_keyword (optn) ? "keyword" : "option";
	}

	if (optn->arg_name)
	    err_report ("Cannot handle `%s' %s with arg `%s' (argc %d)",
							ss, type, opt_arg, n);
	else
	    err_report ("Cannot handle `%s' %s (argc %d)", ss, type, n);
}
Esempio n. 13
0
void CLIF_print_usage (const char *header, const char *progname, 
				const CLIF_option *option_list,
				const CLIF_argument *argument_list) {

	if (!progname && curr.argv)
		progname = curr.argv[0];

	if (!header) {
	    if (progname)
		fprintf (stderr, "Usage: %s", progname);
	    else
		fprintf (stderr, "Command line options:");
	} else {
	    if (progname)
		fprintf (stderr, "%s\n" OPT_START_DLM "%s", header, progname);
	    else
		fprintf (stderr, "%s", header);
	}


	if (option_list) {
	    const CLIF_option *optn;
	    char m_buf[256], p_buf[256], mp_buf[256];
	    char *m = m_buf, *p = p_buf, *mp = mp_buf;
	    char *end_m = m_buf + sizeof (m_buf) - 1;
	    char *end_p = p_buf + sizeof (p_buf) - 1;
	    char *end_mp = mp_buf + sizeof (mp_buf) - 1;
	    char *excl;
	    int excl_cnt = 0;


	    /*  first, show exclusive option list, if any...  */

	    excl = show_excl (option_list, &excl_cnt);
	    if (excl_cnt > 0) {
		if ((curr.parse_flags & CLIF_STRICT_EXCL) &&
		    curr.option_list == option_list
		) {
		    if (excl_cnt == 1)
			    fprintf (stderr, " %s", excl);
		    else
			fprintf (stderr, " { %s }", excl);
		} else
		    fprintf (stderr, " [ %s ]", excl);
	    }


	    /*  second, find short options without arguments...  */

	    for (optn = option_list;
		    optn->short_opt || optn->long_opt;
			optn++
	    ) {
		/*  We don`t exclude CLIF_EXTRA hear:
		   simple one char don`t eat a lot of space...
		*/

		if (!optn->short_opt ||
		    optn->arg_name ||
		    (optn->flags & CLIF_EXCL)
		)  continue;

		if (optn->function_plus) {
		    if (optn->function) {
			if (mp < end_mp)  *mp++ = optn->short_opt[0];
		    } else {
			if (p < end_p)  *p++ = optn->short_opt[0];
		    }
		} else {
		    if (m < end_m)  *m++ = optn->short_opt[0];
		}
	    }

	    if (m > (char *) m_buf) {
		*m = '\0';
		fprintf (stderr, " [ -%s ]", m_buf);
	    }
	    if (p > (char *) p_buf) {
		*p = '\0';
		fprintf (stderr, " [ +%s ]", p_buf);
	    }
	    if (mp > (char *) mp_buf) {
		*mp = '\0';
		fprintf (stderr, " [ " SHORT_PLUS_MINUS "%s ]", mp_buf);
	    }


	    /*  third, print all another...  */

	    for (optn = option_list;
		    optn->short_opt || optn->long_opt;
			optn++
	    ) {
		if (optn->flags & CLIF_EXTRA)  continue;

		if (optn->flags & CLIF_EXCL)
			continue;	/*  already handled   */

		if (optn->short_opt) {
		    if (optn->arg_name) 
			fprintf (stderr, " [ %s ]", show_short (optn));
		    else
			/*  already handled   */;
		} else
		    fprintf (stderr, " [ %s ]", show_long (optn));
	    }
	}
		        

	if (argument_list) {
	    const CLIF_argument *argm;
	    int deep = 0;

	    for (argm = argument_list; argm->name; argm++) {

		if (argm->flags & CLIF_STRICT) {
		    if (deep > 0) {
			fputc (' ', stderr);
			while (deep--)  fputc (']', stderr);
			deep = 0;
		    }
			
		    fprintf (stderr, " %s", argm->name);
		} else {
		    if (argm->flags & CLIF_MORE)
			    fprintf (stderr, " [ %s ...", argm->name);
		    else if (argm->flags & CLIF_ACC_PREV) {
			    fprintf (stderr, " %s", argm->name);
			    --deep;	/*  ugly, but easy   */
		    } else
			fprintf (stderr, " [ %s", argm->name);

		    deep++;
		}
	    }

	    if (deep > 0) {
		fputc (' ', stderr);
		while (deep--)  fputc (']', stderr);
	    }
	}


	fprintf (stderr, "\n");
}