1 module tomcrypt.argchk; 2 3 import tomcrypt.cfg; 4 import std..string; 5 6 extern(C) nothrow: 7 8 /* Defines the LTC_ARGCHK macro used within the library */ 9 /* ARGTYPE is defined in mycrypt_cfg.h */ 10 static if(ARGTYPE == 0) 11 { 12 import core.stdc.signal; 13 14 /* this is the default LibTomCrypt macro */ 15 void crypt_argchk(char* v, char* s, int d); 16 17 string LTC_ARGCHK(string x) 18 { 19 return "if (!"~x~") { crypt_argchk("~x~", __FILE__, __LINE__);"; 20 } 21 alias LTC_ARGCHKVD = LTC_ARGCHK; 22 } 23 else static if(ARGTYPE == 1) 24 { 25 /* fatal type of error */ 26 string LTC_ARGCHK(string x) 27 { 28 return "assert("~x~");"; 29 } 30 alias LTC_ARGCHKVD = LTC_ARGCHK; 31 } 32 else static if(ARGTYPE == 2) 33 { 34 string LTC_ARGCHK(string x) 35 { 36 return "if (!"~x~") { fprintf(stderr, \"\nwarning: ARGCHK failed at %s:%d\n\", file.toStringz, line);"; 37 } 38 alias LTC_ARGCHKVD = LTC_ARGCHK; 39 } 40 else static if(ARGTYPE == 3) 41 { 42 string LTC_ARGCHK(string x) 43 { 44 return ""; 45 } 46 alias LTC_ARGCHKVD = LTC_ARGCHK; 47 } 48 else static if(ARGTYPE == 4) 49 { 50 string LTC_ARGCHK(string x) 51 { 52 return "if (!("~x~")) return CRYPT_INVALID_ARG;"; 53 } 54 string LTC_ARGCHKVD(string x) 55 { 56 return "if (!("~x~")) return;"; 57 } 58 } 59 60 61 /* $Source: /cvs/libtom/libtomcrypt/src/headers/tomcrypt_argchk.h,v $ */ 62 /* $Revision: 1.5 $ */ 63 /* $Date: 2006/08/27 20:50:21 $ */