1 #include <commands/GSSImportName.h>
2 #include <commands/GSSInitSecContext.h>
3 #include <commands/GSSAcquireCred.h>
4 #include <datamodel/GSSBuffer.h>
17 #include <util_json.h>
18 #include <GSSRequest.h>
27 int main(int argc, char **argv) {
43 if (_sopen_s(&fd, argv[1], _O_BINARY, _SH_DENYNO, _S_IREAD) != 0)
45 cout << "error :" << errno << " opening file: " << argv[1] << "\n";
49 if (_fstat(fd, &fs) != 0) {
50 cout << "error: " << errno << " from _fstat.\n";
54 FILE *f =_fdopen(fd, "rb");
56 cout << "error: " << errno << " from _fdopen.\n";
60 input = new char[len+1];
61 size_t count = fread(input, 1, len, f) ;
63 cout << "expected " << len << " bytes from fread; got " << count << ".\n";
68 ssize_t readThisRound;
69 size_t readTotal, readRemaining;
74 readThisRound = readTotal = 0;
77 readThisRound = read(0, ((&len) + readTotal), 4 - readTotal);
78 readTotal += readThisRound;
81 // Reads the number of bytes indicated by the above read
82 input = new char[len + 1];
83 readTotal = readThisRound = 0;
84 while (readTotal < len)
86 readRemaining = len - readTotal;
87 readThisRound = read( 0, &(input[readTotal]), readRemaining);
88 if (-1 == readThisRound)
91 readTotal += readThisRound;
93 // ... and null-terminate it
97 char *out = gss_request(input);
100 cout.write((char *)&len, 4);
102 deallocate_reply(out);