コード例 #1
0
void getTextEventBufferStatus(QQQQ) {
  unsigned used= theData[1], alloc= theData[2], max_= theData[3];
  const char *used_unit, *alloc_unit, *max_unit;
  convert_unit(used, used_unit);
  convert_unit(alloc, alloc_unit);
  convert_unit(max_, max_unit);
  BaseString::snprintf(m_text, m_text_len,
		       "Event buffer status: used=%d%s(%d%) alloc=%d%s(%d%) "
		       "max=%d%s apply_gci=%lld latest_gci=%lld",
		       used, used_unit,
		       theData[2] ? (Uint32)((((Uint64)theData[1])*100)/theData[2]) : 0,
		       alloc, alloc_unit,
		       theData[3] ? (Uint32)((((Uint64)theData[2])*100)/theData[3]) : 0,
		       max_, max_unit,
		       theData[4]+(((Uint64)theData[5])<<32),
		       theData[6]+(((Uint64)theData[7])<<32));
}
コード例 #2
0
ファイル: len.c プロジェクト: natediddy/random_tools
int
main (int argc, char **argv)
{
  set_p_name (*argv);

  if (argc != 4) {
    if (argc > 1 && (!strcmp (argv[1], "-u") || !strcmp (argv[1], "--units")))
    {
      fprintf (stdout, "%s: valid units are:\n"
          "      in  --  inches\n"
          "      ft  --  feet\n"
          "      mi  --  miles\n"
          "      mm  --  millimeter\n"
          "      cm  --  centimeter\n"
          "      m   --  meter\n"
          "      km  --  kilometer\n", p_name);
      return EXIT_SUCCESS;
    }
    fprintf (stderr, "usage: %s QUANTITY IN-UNIT OUT-UNIT\n"
        "      Ex: %s 10 ft in\n"
        "      Use `-u' or `--units' to see available units\n",
        p_name, p_name);
    return EXIT_FAILURE;
  }

  unit i_unit;
  unit o_unit;

  memset (&i_unit, 0, sizeof (unit));
  memset (&o_unit, 0, sizeof (unit));
  i_unit.val = atof (argv[1]);
  set_unit_type (argv[2], &i_unit);
  set_unit_type (argv[3], &o_unit);

  if (i_unit.type == UK) {
    fprintf (stderr, "%s: error: not a valid unit of length: `%s'\n",
        p_name, i_unit.str);
    return EXIT_FAILURE;
  }

  if (o_unit.type == UK) {
    fprintf (stderr, "%s: error: not a valid unit of length: `%s'\n",
        p_name, o_unit.str);
    return EXIT_FAILURE;
  }

  convert_unit (&i_unit, &o_unit);
  fprintf (stdout, "%s: %g%s = %g%s\n",
      p_name, i_unit.val, i_unit.str,
      o_unit.val, o_unit.str);
  return EXIT_SUCCESS;
}