/* GnuTLS glue for GNU Emacs.
- Copyright (C) 2010 Free Software Foundation, Inc.
+ Copyright (C) 2010-2011 Free Software Foundation, Inc.
This file is part of GNU Emacs.
register int rtnval, bytes_written;
gnutls_session_t state = proc->gnutls_state;
- if (proc->gnutls_initstage != GNUTLS_STAGE_READY)
+ if (proc->gnutls_initstage != GNUTLS_STAGE_READY) {
+#ifdef EWOULDBLOCK
+ errno = EWOULDBLOCK;
+#endif
+#ifdef EAGAIN
+ errno = EAGAIN;
+#endif
return -1;
+ }
bytes_written = 0;
{
rtnval = gnutls_write (state, buf, nbyte);
- if (rtnval == -1)
+ if (rtnval < 0)
{
- if (errno == EINTR)
+ if (rtnval == GNUTLS_E_AGAIN || rtnval == GNUTLS_E_INTERRUPTED)
continue;
else
return (bytes_written ? bytes_written : -1);
nbyte -= rtnval;
bytes_written += rtnval;
}
- fsync (STDOUT_FILENO);
return (bytes_written);
}
rtnval = gnutls_read (state, buf, nbyte);
if (rtnval >= 0)
return rtnval;
- else
- return 0;
+ else {
+ if (rtnval == GNUTLS_E_AGAIN ||
+ rtnval == GNUTLS_E_INTERRUPTED)
+ return -1;
+ else
+ return 0;
+ }
}
/* convert an integer error to a Lisp_Object; it will be either a
(x509_cred,
SDATA (trustfile),
file_format);
-
+
if (ret < GNUTLS_E_SUCCESS)
return gnutls_make_error (ret);
}
(x509_cred,
SDATA (keyfile),
file_format);
-
+
if (ret < GNUTLS_E_SUCCESS)
return gnutls_make_error (ret);
}
if (STRINGP (priority_string))
{
- priority_string_ptr = (char*) SDATA (priority_string);
+ priority_string_ptr = SSDATA (priority_string);
GNUTLS_LOG2 (1, max_log_level, "got non-default priority string:",
priority_string_ptr);
}
GNUTLS_LOG2 (1, max_log_level, "using default priority string:",
priority_string_ptr);
}
-
+
GNUTLS_LOG (1, max_log_level, "setting the priority string");
ret = gnutls_priority_set_direct (state,
Qgnutls_x509pki = intern_c_string ("gnutls-x509pki");
staticpro (&Qgnutls_x509pki);
- Qgnutls_bootprop_priority = intern_c_string ("priority");
+ Qgnutls_bootprop_priority = intern_c_string (":priority");
staticpro (&Qgnutls_bootprop_priority);
- Qgnutls_bootprop_trustfiles = intern_c_string ("trustfiles");
+ Qgnutls_bootprop_trustfiles = intern_c_string (":trustfiles");
staticpro (&Qgnutls_bootprop_trustfiles);
- Qgnutls_bootprop_keyfiles = intern_c_string ("keyfiles");
+ Qgnutls_bootprop_keyfiles = intern_c_string (":keyfiles");
staticpro (&Qgnutls_bootprop_keyfiles);
- Qgnutls_bootprop_callbacks = intern_c_string ("callbacks");
+ Qgnutls_bootprop_callbacks = intern_c_string (":callbacks");
staticpro (&Qgnutls_bootprop_callbacks);
- Qgnutls_bootprop_loglevel = intern_c_string ("loglevel");
+ Qgnutls_bootprop_loglevel = intern_c_string (":loglevel");
staticpro (&Qgnutls_bootprop_loglevel);
Qgnutls_e_interrupted = intern_c_string ("gnutls-e-interrupted");