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 readThisRound;
68 size_t readTotal, readRemaining;
73 readThisRound = readTotal = 0;
76 readThisRound = read(0, ((&len) + readTotal), 4 - readTotal);
77 readTotal += readThisRound;
80 // Reads the number of bytes indicated by the above read
81 input = new char[len + 1];
82 readTotal = readThisRound = 0;
83 while (readTotal < len)
85 readRemaining = len - readTotal;
86 readThisRound = read( 0, &(input[readTotal]), readRemaining);
87 if (-1 == readThisRound)
90 readTotal += readThisRound;
92 // ... and null-terminate it
96 GSSRequest *req = new GSSRequest(string(input));
98 output = req->getResponse();
99 len = output.length();
101 cout.write((char *)&len, 4);