File nodejs-openssl-missing-api.patch of Package nodejs.1380

NodeJS 0.10 uses APIs introduced with OpenSSL 1.0.0.  To make it build against
OpenSSL 0.9.8 we must revert some API changes (298f6bf) and copy some missing
structs/functions from OpenSSL 1.0.0.

A better long-term solution might be to have the RPM depend on openssl>=1.0.0
and statically link with the bundled OpenSSL on platforms lacking it.
--- src/node_crypto.cc.orig	2013-04-18 14:27:08.000000000 -0500
+++ src/node_crypto.cc	2013-04-18 17:37:52.000000000 -0500
@@ -84,8 +84,13 @@
 static uv_rwlock_t* locks;
 
 
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
 static void crypto_threadid_cb(CRYPTO_THREADID* tid) {
   CRYPTO_THREADID_set_numeric(tid, uv_thread_self());
+#else
+static unsigned long crypto_id_cb(void) {
+  return (unsigned long) pthread_self();
+#endif
 }
 
 
@@ -3996,6 +4001,62 @@
   arr->Set(arr->Length(), String::New(from));
 }
 
+#if OPENSSL_VERSION_NUMBER < 0x10000000L
+/* Missing structs & functions copied from openssl-1.0.0 evp/names.c, with
+ * explicit casts added to make the C++ compiler happy.
+ */
+extern "C" {
+struct doall_cipher
+	{
+	void *arg;
+	void (*fn)(const EVP_CIPHER *ciph,
+			const char *from, const char *to, void *arg);
+	};
+
+static void do_all_cipher_fn(const OBJ_NAME *nm, void *arg)
+	{
+	struct doall_cipher *dc = (doall_cipher *)arg;
+	if (nm->alias)
+		dc->fn(NULL, nm->name, nm->data, dc->arg);
+	else
+		dc->fn((const EVP_CIPHER *)nm->data, nm->name, NULL, dc->arg);
+	}
+
+void EVP_CIPHER_do_all_sorted(void (*fn)(const EVP_CIPHER *ciph,
+		const char *from, const char *to, void *x), void *arg)
+	{
+	struct doall_cipher dc;
+	dc.fn = fn;
+	dc.arg = arg;
+	OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_CIPHER_METH, do_all_cipher_fn,&dc);
+	}
+
+struct doall_md
+	{
+	void *arg;
+	void (*fn)(const EVP_MD *ciph,
+			const char *from, const char *to, void *arg);
+	};
+
+static void do_all_md_fn(const OBJ_NAME *nm, void *arg)
+	{
+	struct doall_md *dc = (doall_md *)arg;
+	if (nm->alias)
+		dc->fn(NULL, nm->name, nm->data, dc->arg);
+	else
+		dc->fn((const EVP_MD *)nm->data, nm->name, NULL, dc->arg);
+	}
+
+void EVP_MD_do_all_sorted(void (*fn)(const EVP_MD *md,
+		const char *from, const char *to, void *x), void *arg)
+	{
+	struct doall_md dc;
+	dc.fn = fn;
+	dc.arg = arg;
+	OBJ_NAME_do_all_sorted(OBJ_NAME_TYPE_MD_METH, do_all_md_fn, &dc);
+	}
+}
+#endif
 
 Handle<Value> GetCiphers(const Arguments& args) {
   HandleScope scope;
@@ -4024,7 +4085,11 @@
 
   crypto_lock_init();
   CRYPTO_set_locking_callback(crypto_lock_cb);
+#if OPENSSL_VERSION_NUMBER >= 0x10000000L
   CRYPTO_THREADID_set_callback(crypto_threadid_cb);
+#else
+  CRYPTO_set_id_callback(crypto_id_cb);
+#endif
 
   // Turn off compression. Saves memory - do it in userland.
 #if !defined(OPENSSL_NO_COMP)
openSUSE Build Service is sponsored by