1 #include <commands/GSSImportName.h>
2 #include <commands/GSSInitSecContext.h>
3 #include <commands/GSSAcquireCred.h>
4 #include <datamodel/GSSBuffer.h>
16 #include <util_json.h>
17 #include <GSSRequest.h>
26 int main(int argc, char **argv) {
42 if (_sopen_s(&fd, argv[1], _O_BINARY, _SH_DENYNO, _S_IREAD) != 0)
44 cout << "error :" << errno << " opening file: " << argv[1] << "\n";
48 if (_fstat(fd, &fs) != 0) {
49 cout << "error: " << errno << " from _fstat.\n";
53 FILE *f =_fdopen(fd, "rb");
55 cout << "error: " << errno << " from _fdopen.\n";
59 input = new char[len+1];
60 size_t count = fread(input, 1, len, f) ;
62 cout << "expected " << len << " bytes from fread; got " << count << ".\n";
67 ssize_t readTotal, readThisRound, readRemaining;
72 readThisRound = readTotal = 0;
75 readThisRound = read(0, ((&len) + readTotal), 4 - readTotal);
76 readTotal += readThisRound;
79 // Reads the number of bytes indicated by the above read
80 input = new char[len + 1];
81 readTotal = readThisRound = 0;
82 while (readTotal < len)
84 readRemaining = len - readTotal;
85 readThisRound = read( 0, &(input[readTotal]), readRemaining);
86 if (-1 == readThisRound)
89 readTotal += readThisRound;
91 // ... and null-terminate it
95 GSSRequest *req = new GSSRequest(string(input));
97 output = req->getResponse();
98 len = output.length();
100 cout.write((char *)&len, 4);