⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 t-scanf.c

📁 a very popular packet of cryptography tools,it encloses the most common used algorithm and protocols
💻 C
📖 第 1 页 / 共 4 页
字号:
    { "%Zd", "\t\t0",    "0", 1, -1, -1 },    { "hello%Zd",      "hello0",       "0", 1, -1, -1 },    { "hello%Zd",      "hello 0",      "0", 1, -1, -1 },    { "hello%Zd",      "hello \t0",    "0", 1, -1, -1 },    { "hello%Zdworld", "hello 0world", "0", 1, -1, -1 },    { "hello%*Zd",      "hello0",       "-999", 0, -1, -1 },    { "hello%*Zd",      "hello 0",      "-999", 0, -1, -1 },    { "hello%*Zd",      "hello \t0",    "-999", 0, -1, -1 },    { "hello%*Zdworld", "hello 0world", "-999", 0, -1, -1 },    { "%Zd",    "",     "-999", -1, -1, -555 },    { "%Zd",    " ",    "-999", -1, -1, -555 },    { " %Zd",   "",     "-999", -1, -1, -555 },    { "xyz%Zd", "",     "-999", -1, -1, -555 },    { "%*Zd",    "",     "-999", -1, -1, -555 },    { " %*Zd",   "",     "-999", -1, -1, -555 },    { "xyz%*Zd", "",     "-999", -1, -1, -555 },    { "%Zd",    "xyz",  "0",     0, 0, -555 },    /* match something, but invalid */    { "%Zd",    "-",    "-999",  0, 1, -555 },    { "%Zd",    "+",    "-999",  0, 1, -555 },    { "xyz%Zd", "xyz-", "-999",  0, 4, -555 },    { "xyz%Zd", "xyz+", "-999",  0, 4, -555 },    { "%1Zi",  "1234", "1",    1, 1, 1 },    { "%2Zi",  "1234", "12",   1, 2, 2 },    { "%3Zi",  "1234", "123",  1, 3, 3 },    { "%4Zi",  "1234", "1234", 1, 4, 4 },    { "%5Zi",  "1234", "1234", 1, 4, 4 },    { "%6Zi",  "1234", "1234", 1, 4, 4 },    { "%1Zi",  "01234", "0",     1, 1, 1 },    { "%2Zi",  "01234", "01",    1, 2, 2 },    { "%3Zi",  "01234", "012",   1, 3, 3 },    { "%4Zi",  "01234", "0123",  1, 4, 4 },    { "%5Zi",  "01234", "01234", 1, 5, 5 },    { "%6Zi",  "01234", "01234", 1, 5, 5 },    { "%7Zi",  "01234", "01234", 1, 5, 5 },    { "%1Zi",  "0x1234", "0",      1, 1, 1 },    { "%2Zi",  "0x1234", "0",      1, 2, 2 },    { "%3Zi",  "0x1234", "0x1",    1, 3, 3 },    { "%4Zi",  "0x1234", "0x12",   1, 4, 4 },    { "%5Zi",  "0x1234", "0x123",  1, 5, 5 },    { "%6Zi",  "0x1234", "0x1234", 1, 6, 6 },    { "%7Zi",  "0x1234", "0x1234", 1, 6, 6 },    { "%8Zi",  "0x1234", "0x1234", 1, 6, 6 },    { "%%xyz%Zd",  "%xyz123",  "123", 1, -1, -1 },    { "12%%34%Zd", "12%34567", "567", 1, -1, -1 },    { "%%%%%Zd",   "%%123",    "123", 1, -1, -1 },    /* various subtle EOF cases */    { "x",       "",    "-999", EOF, 0, -555 },    { " x",      "",    "-999", EOF, 0, -555 },    { "xyz",     "",    "-999", EOF, 0, -555 },    { " ",       "",    "-999",   0, 0,    0 },    { " ",       " ",   "-999",   0, 1,    1 },    { "%*Zd%Zd", "",    "-999", EOF, 0, -555 },    { "%*Zd%Zd", "123", "-999", EOF, 3, -555 },    { "x",       "x",   "-999",   0, 1,    1 },    { "xyz",     "x",   "-999", EOF, 1, -555 },    { "xyz",     "xy",  "-999", EOF, 2, -555 },    { "xyz",     "xyz", "-999",   0, 3,    3 },    { "%Zn",     "",    "0",      0, 0,    0 },    { " %Zn",    "",    "0",      0, 0,    0 },    { " x%Zn",   "",    "-999", EOF, 0, -555 },    { "xyz%Zn",  "",    "-999", EOF, 0, -555 },    { " x%Zn",   "",    "-999", EOF, 0, -555 },    { " %Zn x",  " ",   "-999", EOF, 1, -555 },    /* these seem to tickle a bug in glibc 2.2.4 */    { " x",      " ",   "-999", EOF, 1, -555, 1 },    { " xyz",    " ",   "-999", EOF, 1, -555, 1 },    { " x%Zn",   " ",   "-999", EOF, 1, -555, 1 },  };  int         i, j, ignore;  int         got_ret, want_ret, got_upto, want_upto;  mpz_t       got, want;  long        got_l, want_ftell;  int         error = 0;  fun_t       fun;  const char  *name;  char        fmt[128];  mpz_init (got);  mpz_init (want);  for (i = 0; i < numberof (data); i++)    {      mpz_set_str_or_abort (want, data[i].want, 0);      ASSERT_ALWAYS (strlen (data[i].fmt) + 2 < sizeof (fmt));      strcpy (fmt, data[i].fmt);      strcat (fmt, "%n");      ignore = fmt_allignore (fmt);      for (j = 0; j <= 3; j++)        {          want_ret = data[i].want_ret;          want_ftell = data[i].want_ftell;          if (want_ftell == -1)            want_ftell = strlen (data[i].input);          want_upto = data[i].want_upto;          if (want_upto == -1)            want_upto = strlen (data[i].input);          switch (j) {          case 0:            name = "gmp_sscanf";            fun = fun_gmp_sscanf;            break;          case 1:            name = "gmp_fscanf";            fun = fun_gmp_fscanf;            break;          case 2:#ifdef __GLIBC__            if (data[i].not_glibc)              continue;#endif            if (! libc_scanf_convert (fmt))              continue;            name = "standard sscanf";            fun = fun_sscanf;            break;          case 3:#ifdef __GLIBC__            if (data[i].not_glibc)              continue;#endif            if (! libc_scanf_convert (fmt))              continue;            name = "standard fscanf";            fun = fun_fscanf;            break;          default:            ASSERT_ALWAYS (0);            break;          }          got_upto = -555;          got_ftell = -1L;          switch (j) {          case 0:          case 1:            mpz_set_si (got, -999L);            if (ignore)              got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL);            else              got_ret = (*fun) (data[i].input, fmt, got, &got_upto);            break;          case 2:          case 3:            got_l = -999L;            if (ignore)              got_ret = (*fun) (data[i].input, fmt, &got_upto, NULL);            else              got_ret = (*fun) (data[i].input, fmt, &got_l, &got_upto);            mpz_set_si (got, got_l);            break;          default:            ASSERT_ALWAYS (0);            break;          }          MPZ_CHECK_FORMAT (got);          if (got_ret != want_ret)            {              printf ("%s wrong return value\n", name);              error = 1;            }          if (want_ret == 1 && mpz_cmp (want, got) != 0)            {              printf ("%s wrong result\n", name);              error = 1;            }          if (got_upto != want_upto)            {              printf ("%s wrong upto\n", name);              error = 1;            }          if (got_ftell != -1 && want_ftell != -1 && got_ftell != want_ftell)            {              printf ("%s wrong ftell\n", name);              error = 1;            }          if (error)            {              printf    ("  fmt   \"%s\"\n", data[i].fmt);              printf    ("  input \"%s\"\n", data[i].input);              printf    ("  ignore %d\n", ignore);              printf    ("  ret   want=%d\n", want_ret);              printf    ("        got =%d\n", got_ret);              mpz_trace ("  value want", want);              mpz_trace ("        got ", got);              printf    ("  upto  want =%d\n", want_upto);              printf    ("        got  =%d\n", got_upto);              if (got_ftell != -1)                {                  printf    ("  ftell want =%ld\n", want_ftell);                  printf    ("        got  =%ld\n", got_ftell);                }              abort ();            }        }    }  mpz_clear (got);  mpz_clear (want);}voidcheck_q (void){  static const struct {    const char  *fmt;    const char  *input;    const char  *want;    int         ret;    long        ftell;  } data[] = {    { "%Qd",    "0",    "0", 1, -1 },    { "%Qd",    "1",    "1", 1, -1 },    { "%Qd",  "123",  "123", 1, -1 },    { "%Qd",   "+0",    "0", 1, -1 },    { "%Qd",   "+1",    "1", 1, -1 },    { "%Qd", "+123",  "123", 1, -1 },    { "%Qd",   "-0",    "0", 1, -1 },    { "%Qd",   "-1",   "-1", 1, -1 },    { "%Qd", "-123", "-123", 1, -1 },    { "%Qo",    "0",    "0", 1, -1 },    { "%Qo",  "173",  "123", 1, -1 },    { "%Qo",   "+0",    "0", 1, -1 },    { "%Qo", "+173",  "123", 1, -1 },    { "%Qo",   "-0",    "0", 1, -1 },    { "%Qo", "-173", "-123", 1, -1 },    { "%Qx",    "0",    "0", 1, -1 },    { "%Qx",   "7b",  "123", 1, -1 },    { "%Qx",   "7b",  "123", 1, -1 },    { "%Qx",   "+0",    "0", 1, -1 },    { "%Qx",  "+7b",  "123", 1, -1 },    { "%Qx",  "+7b",  "123", 1, -1 },    { "%Qx",   "-0",   "-0", 1, -1 },    { "%Qx",  "-7b", "-123", 1, -1 },    { "%Qx",  "-7b", "-123", 1, -1 },    { "%QX",    "0",    "0", 1, -1 },    { "%QX",   "7b",  "123", 1, -1 },    { "%QX",   "7b",  "123", 1, -1 },    { "%QX",   "+0",    "0", 1, -1 },    { "%QX",  "+7b",  "123", 1, -1 },    { "%QX",  "+7b",  "123", 1, -1 },    { "%QX",   "-0",   "-0", 1, -1 },    { "%QX",  "-7b", "-123", 1, -1 },    { "%QX",  "-7b", "-123", 1, -1 },    { "%Qx",    "0",    "0", 1, -1 },    { "%Qx",   "7B",  "123", 1, -1 },    { "%Qx",   "7B",  "123", 1, -1 },    { "%Qx",   "+0",    "0", 1, -1 },    { "%Qx",  "+7B",  "123", 1, -1 },    { "%Qx",  "+7B",  "123", 1, -1 },    { "%Qx",   "-0",   "-0", 1, -1 },    { "%Qx",  "-7B", "-123", 1, -1 },    { "%Qx",  "-7B", "-123", 1, -1 },    { "%QX",    "0",    "0", 1, -1 },    { "%QX",   "7B",  "123", 1, -1 },    { "%QX",   "7B",  "123", 1, -1 },    { "%QX",   "+0",    "0", 1, -1 },    { "%QX",  "+7B",  "123", 1, -1 },    { "%QX",  "+7B",  "123", 1, -1 },    { "%QX",   "-0",   "-0", 1, -1 },    { "%QX",  "-7B", "-123", 1, -1 },    { "%QX",  "-7B", "-123", 1, -1 },    { "%Qi",    "0",    "0", 1, -1 },    { "%Qi",    "1",    "1", 1, -1 },    { "%Qi",  "123",  "123", 1, -1 },    { "%Qi",   "+0",    "0", 1, -1 },    { "%Qi",   "+1",    "1", 1, -1 },    { "%Qi", "+123",  "123", 1, -1 },    { "%Qi",   "-0",    "0", 1, -1 },    { "%Qi",   "-1",   "-1", 1, -1 },    { "%Qi", "-123", "-123", 1, -1 },    { "%Qi",    "00",    "0", 1, -1 },    { "%Qi",  "0173",  "123", 1, -1 },    { "%Qi",   "+00",    "0", 1, -1 },    { "%Qi", "+0173",  "123", 1, -1 },    { "%Qi",   "-00",    "0", 1, -1 },    { "%Qi", "-0173", "-123", 1, -1 },    { "%Qi",    "0x0",    "0", 1, -1 },    { "%Qi",   "0x7b",  "123", 1, -1 },    { "%Qi",   "0x7b",  "123", 1, -1 },    { "%Qi",   "+0x0",    "0", 1, -1 },    { "%Qi",  "+0x7b",  "123", 1, -1 },    { "%Qi",  "+0x7b",  "123", 1, -1 },    { "%Qi",   "-0x0",   "-0", 1, -1 },    { "%Qi",  "-0x7b", "-123", 1, -1 },    { "%Qi",  "-0x7b", "-123", 1, -1 },    { "%Qi",    "0X0",    "0", 1, -1 },    { "%Qi",   "0X7b",  "123", 1, -1 },    { "%Qi",   "0X7b",  "123", 1, -1 },    { "%Qi",   "+0X0",    "0", 1, -1 },    { "%Qi",  "+0X7b",  "123", 1, -1 },    { "%Qi",  "+0X7b",  "123", 1, -1 },    { "%Qi",   "-0X0",   "-0", 1, -1 },    { "%Qi",  "-0X7b", "-123", 1, -1 },    { "%Qi",  "-0X7b", "-123", 1, -1 },    { "%Qi",    "0x0",    "0", 1, -1 },    { "%Qi",   "0x7B",  "123", 1, -1 },    { "%Qi",   "0x7B",  "123", 1, -1 },    { "%Qi",   "+0x0",    "0", 1, -1 },    { "%Qi",  "+0x7B",  "123", 1, -1 },    { "%Qi",  "+0x7B",  "123", 1, -1 },    { "%Qi",   "-0x0",   "-0", 1, -1 },    { "%Qi",  "-0x7B", "-123", 1, -1 },    { "%Qi",  "-0x7B", "-123", 1, -1 },    { "%Qi",    "0X0",    "0", 1, -1 },    { "%Qi",   "0X7B",  "123", 1, -1 },    { "%Qi",   "0X7B",  "123", 1, -1 },    { "%Qi",   "+0X0",    "0", 1, -1 },    { "%Qi",  "+0X7B",  "123", 1, -1 },    { "%Qi",  "+0X7B",  "123", 1, -1 },    { "%Qi",   "-0X0",   "-0", 1, -1 },    { "%Qi",  "-0X7B", "-123", 1, -1 },    { "%Qi",  "-0X7B", "-123", 1, -1 },    { "%Qd",    " 0",    "0", 1, -1 },    { "%Qd",   "  0",    "0", 1, -1 },    { "%Qd",  "   0",    "0", 1, -1 },    { "%Qd",   "\t0",    "0", 1, -1 },    { "%Qd", "\t\t0",    "0", 1, -1 },    { "%Qd",  "3/2",   "3/2", 1, -1 },    { "%Qd", "+3/2",   "3/2", 1, -1 },    { "%Qd", "-3/2",  "-3/2", 1, -1 },    { "%Qx",  "f/10", "15/16", 1, -1 },    { "%Qx",  "F/10", "15/16", 1, -1 },    { "%QX",  "f/10", "15/16", 1, -1 },    { "%QX",  "F/10", "15/16", 1, -1 },    { "%Qo",  "20/21",  "16/17", 1, -1 },    { "%Qo", "-20/21", "-16/17", 1, -1 },    { "%Qi",    "10/11",  "10/11", 1, -1 },    { "%Qi",   "+10/11",  "10/11", 1, -1 },    { "%Qi",   "-10/11", "-10/11", 1, -1 },    { "%Qi",   "010/11",   "8/11", 1, -1 },    { "%Qi",  "+010/11",   "8/11", 1, -1 },    { "%Qi",  "-010/11",  "-8/11", 1, -1 },    { "%Qi",  "0x10/11",  "16/11", 1, -1 },    { "%Qi", "+0x10/11",  "16/11", 1, -1 },    { "%Qi", "-0x10/11", "-16/11", 1, -1 },    { "%Qi",    "10/011",  "10/9", 1, -1 },    { "%Qi",   "+10/011",  "10/9", 1, -1 },    { "%Qi",   "-10/011", "-10/9", 1, -1 },    { "%Qi",   "010/011",   "8/9", 1, -1 },    { "%Qi",  "+010/011",   "8/9", 1, -1 },    { "%Qi",  "-010/011",  "-8/9", 1, -1 },    { "%Qi",  "0x10/011",  "16/9", 1, -1 },    { "%Qi", "+0x10/011",  "16/9", 1, -1 },    { "%Qi", "-0x10/011", "-16/9", 1, -1 },    { "%Qi",    "10/0x11",  "10/17", 1, -1 },    { "%Qi",   "+10/0x11",  "10/17", 1, -1 },    { "%Qi",   "-10/0x11", "-10/17", 1, -1 },    { "%Qi",   "010/0x11",   "8/17", 1, -1 },    { "%Qi",  "+010/0x11",   "8/17", 1, -1 },    { "%Qi",  "-010/0x11",  "-8/17", 1, -1 },    { "%Qi",  "0x10/0x11",  "16/17", 1, -1 },    { "%Qi", "+0x10/0x11",  "16/17", 1, -1 },    { "%Qi", "-0x10/0x11", "-16/17", 1, -1 },    { "hello%Qd",      "hello0",         "0", 1, -1 },    { "hello%Qd",      "hello 0",        "0", 1, -1 },

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -