1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122:
| unit KeyIntf; { element 5 AG / ShareIt! key generator interface version 2.5
DO NOT MODIFY THIS FILE! }
interface
uses Windows, SysUtils, Classes;
const // error result codes supported by element 5 ERC_SUCCESS = 0; ERC_SUCCESS_BIN = 1; ERC_ERROR = 10; ERC_MEMORY = 11; ERC_FILE_IO = 12; ERC_BAD_ARGS = 13; ERC_BAD_INPUT = 14; ERC_EXPIRED = 15; ERC_INTERNAL = 16;
// use this function to get the value of input parameters function Value(key: string): string;
// main entry point procedure Main;
var gList: TStrings; // holds input parameters
implementation
uses KeyUser;
// use this function to get the value of input parameters function Value(key: string): string; begin try result := gList.Values[key]; except result := ''; end; end;
// write a string to the given filename procedure WriteFile(filename, value: string); var fout: TextFile; begin if (filename = '') or (value = '') then exit; // happens only when writing exception file
// write output data AssignFile(fout, filename); {$I-} Rewrite(fout); Write(fout, value); CloseFile(fout); {$I+} if IOResult <> 0 then raise Exception.Create('i/o error on write'); end;
// main function ** DO NOT CHANGE ** procedure Generate; var userkey, cckey: string; begin // check parameter count if (ParamCount <> 3) then begin ExitCode := ERC_BAD_INPUT; raise Exception.Create('bad args: ' + IntToStr(ParamCount)); end;
// see if input file supplied if not FileExists(ParamStr(1)) then begin ExitCode := ERC_FILE_IO; raise Exception.Create('file not found: ' + ParamStr(1)); end;
// load input values gList.LoadFromFile(ParamStr(1));
// call key generator userkey := ''; cckey := ''; ExitCode := GenerateKey(userkey, cckey);
// write output if successful WriteFile(ParamStr(2), userkey); WriteFile(ParamStr(3), cckey); end;
procedure Main; begin writeln(Title); gList := TStringList.Create; try Generate;
except on E: Exception do begin // update exit code only if it does not yet report an error if ExitCode < ERC_ERROR then ExitCode := ERC_INTERNAL; writeln(E.Message);
try // to write error to first output file WriteFile(ParamStr(2), 'ERROR: ' + E.Message); except // print to console on E: Exception do writeln(E.Message); end; end; end;
gList.Free; end;
end. |