1 /* 2 * Copyright (c) 2020 Proofpoint, Inc. and its suppliers. 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 */ 9 10 #include <sm/gen.h> 11 SM_IDSTR(id, "@(#)$Id: t-qic.c,v 1.10 2013-11-22 20:51:43 ca Exp $") 12 13 #include <stdio.h> 14 #include <stdlib.h> 15 #include <unistd.h> 16 #include <sm/sendmail.h> 17 #include <sm/ixlen.h> 18 #include <sm/test.h> 19 20 #if _FFR_8BITENVADDR 21 extern bool SmTestVerbose; 22 23 static void 24 chkilenx(str, len) 25 const char *str; 26 int len; 27 { 28 int xlen; 29 30 xlen = ilenx(str); 31 SM_TEST(len == xlen); 32 if (len != xlen) 33 fprintf(stderr, "str=\"%s\", len=%d, excpected=%d\n", 34 str, xlen, len); 35 } 36 37 static void 38 chkxleni(str, len) 39 const char *str; 40 int len; 41 { 42 int ilen; 43 44 ilen = xleni(str); 45 SM_TEST(len == ilen); 46 if (len != ilen) 47 fprintf(stderr, "str=\"%s\", len=%d, excpected=%d\n", 48 str, ilen, len); 49 } 50 51 52 static void 53 usage(prg) 54 const char *prg; 55 { 56 fprintf(stderr, "usage: %s [options]\n", prg); 57 fprintf(stderr, "options:\n"); 58 fprintf(stderr, "-x xleni\n"); 59 } 60 61 int 62 main(argc, argv) 63 int argc; 64 char *argv[]; 65 { 66 int o, len; 67 bool x; 68 char line[1024]; 69 70 x = false; 71 while ((o = getopt(argc, argv, "x")) != -1) 72 { 73 switch ((char) o) 74 { 75 case 'x': 76 x = true; 77 break; 78 79 default: 80 usage(argv[0]); 81 exit(1); 82 } 83 } 84 85 sm_test_begin(argc, argv, "test ilenx"); 86 87 while (fscanf(stdin, "%d:%s\n", &len, line) == 2) 88 { 89 if (x) 90 chkxleni(line, len); 91 else 92 chkilenx(line, len); 93 } 94 95 return sm_test_end(); 96 } 97 #else /* _FFR_8BITENVADDR */ 98 int 99 main(argc, argv) 100 int argc; 101 char *argv[]; 102 { 103 return 0; 104 } 105 #endif /* _FFR_8BITENVADDR */ 106