-#include <commands/GSSImportName.h>
-#include <commands/GSSInitSecContext.h>
-#include <commands/GSSAcquireCred.h>
-#include <datamodel/GSSBuffer.h>
-#include <exception>
+//
#include <iostream>
-#include <string>
#ifdef WIN32
-#include <sys/types.h>
-#include <sys/stat.h>
+#include <stdio.h>
#include <fcntl.h>
-#include <share.h>
+#include <io.h>
#else
#include <unistd.h>
#include <string.h>
#endif
-#include <util_json.h>
#include <GSSRequest.h>
using std::cout;
using std::endl;
using std::getline;
-using std::string;
int main(int argc, char **argv) {
/* Variables */
- string output;
char *input;
- size_t len;
+ char *output;
+ int32_t len;
/* Error checking */
/* Main processing */
#ifdef WIN32
- if (argc < 2) {
- return -1;
- }
- int fd;
- if (_sopen_s(&fd, argv[1], _O_BINARY, _SH_DENYNO, _S_IREAD) != 0)
- {
- cout << "error :" << errno << " opening file: " << argv[1] << "\n";
- return -1;
- }
- struct _stat fs;
- if (_fstat(fd, &fs) != 0) {
- cout << "error: " << errno << " from _fstat.\n";
- return -1;
- }
-
- FILE *f =_fdopen(fd, "rb");
- if (f == NULL) {
- cout << "error: " << errno << " from _fdopen.\n";
- return -1;
- }
- len = fs.st_size;
- input = new char[len+1];
- size_t count = fread(input, 1, len, f) ;
- if (count != len) {
- cout << "expected " << len << " bytes from fread; got " << count << ".\n";
- return -1;
- }
- fclose(f);
-#else
- ssize_t readThisRound;
- size_t readTotal, readRemaining;
+ _setmode(_fileno(stdin), _O_BINARY);
+#endif
+ int readThisRound, readTotal, readRemaining;
do
{
// Read 32 bit length
readThisRound = readTotal = 0;
while(4 != readTotal)
{
- readThisRound = read(0, ((&len) + readTotal), 4 - readTotal);
+ readThisRound = _read(0, ((&len) + readTotal), 4 - readTotal);
readTotal += readThisRound;
}
while (readTotal < len)
{
readRemaining = len - readTotal;
- readThisRound = read( 0, &(input[readTotal]), readRemaining);
+ readThisRound = _read( 0, &(input[readTotal]), readRemaining);
if (-1 == readThisRound)
break;
else
readTotal += readThisRound;
}
// ... and null-terminate it
-#endif
input[len] = '\0';
- char *out = gss_request(input);
- len = strlen(out);
+ output = gss_request(input);
+ len = (int32_t )strlen(output);
cout.write((char *)&len, 4);
- cout << out;
- deallocate_reply(out);
+ cout << output;
+ deallocate_reply(output);
cout.flush();
-#ifndef WIN32
} while(1);
-#endif
return 0;
}