Added OSX for pthreads api, added curl example script
This commit is contained in:
@@ -20,11 +20,16 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#ifdef PLATFORM_OSX
|
||||
#include <pthread.h>
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
#include <sys/socket.h>
|
||||
@@ -92,7 +97,11 @@ send_response(struct MHD_Connection* conn, const char* body, int status_code)
|
||||
int connection_cb(void* cls, struct MHD_Connection* conn, const char* url, const char* method,
|
||||
const char* version, const char* data, size_t* size, void** con_cls)
|
||||
{
|
||||
#ifdef PLATFORM_OSX
|
||||
pthread_setname_np("http");
|
||||
#else
|
||||
prctl(PR_SET_NAME, "http");
|
||||
#endif
|
||||
|
||||
if (*con_cls == NULL) {
|
||||
ConnectionInfo *con_info = create_connection_info();
|
||||
|
||||
@@ -20,11 +20,15 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#ifndef PLATFORM_OSX
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
#include <pthread.h>
|
||||
|
||||
#include <glib.h>
|
||||
@@ -152,7 +156,14 @@ log_println(stbbr_log_t loglevel, const char * const msg, ...)
|
||||
GDateTime *dt = g_date_time_new_now(tz);
|
||||
gchar *date_fmt = g_date_time_format(dt, "%d/%m/%Y %H:%M:%S");
|
||||
char thr_name[16];
|
||||
|
||||
#ifdef PLATFORM_OSX
|
||||
pthread_t self = pthread_self();
|
||||
pthread_getname_np(self, thr_name, 16);
|
||||
#else
|
||||
prctl(PR_GET_NAME, thr_name);
|
||||
#endif
|
||||
|
||||
char *levelstr = _levelstr(loglevel);
|
||||
fprintf(logp, "%s: [%s] [%s] %s\n", date_fmt, thr_name, levelstr, fmt_msg->str);
|
||||
g_date_time_unref(dt);
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <glib.h>
|
||||
#include <errno.h>
|
||||
@@ -27,7 +29,11 @@
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#ifdef PLATFORM_OSX
|
||||
#include <pthread.h>
|
||||
#else
|
||||
#include <sys/prctl.h>
|
||||
#endif
|
||||
|
||||
#include "server/xmppclient.h"
|
||||
#include "server/stream_parser.h"
|
||||
@@ -255,7 +261,11 @@ server_wait_for(char *id)
|
||||
void*
|
||||
_start_server_cb(void* userdata)
|
||||
{
|
||||
#ifdef PLATFORM_OSX
|
||||
pthread_setname_np("stbr");
|
||||
#else
|
||||
prctl(PR_SET_NAME, "stbr");
|
||||
#endif
|
||||
|
||||
struct sockaddr_in client_addr;
|
||||
|
||||
@@ -299,7 +309,12 @@ _start_server_cb(void* userdata)
|
||||
int
|
||||
server_run(stbbr_log_t loglevel, int port, int httpport)
|
||||
{
|
||||
#ifdef PLATFORM_OSX
|
||||
pthread_setname_np("main");
|
||||
#else
|
||||
prctl(PR_SET_NAME, "main");
|
||||
#endif
|
||||
|
||||
pthread_mutex_lock(&send_queue_lock);
|
||||
send_queue = NULL;
|
||||
pthread_mutex_unlock(&send_queue_lock);
|
||||
|
||||
6
stabber-curl.sh
Executable file
6
stabber-curl.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
curl --data '<iq type="result" to="stabber@localhost/profanity"><query xmlns="jabber:iq:roster" ver="362"><item jid="buddy1@localhost" subscription="both" name="Buddy1"/><item jid="buddy2@localhost" subscription="both" name="Buddy2"/></query></iq>' http://localhost:5231/for?query=jabber:iq:roster
|
||||
|
||||
echo "Press enter to send message..."
|
||||
read
|
||||
|
||||
curl --data '<message id="mesg10" to="stabber@localhost/profanity" from="buddy1@localhost/laptop" type="chat"><body>Here is a message sent from stabber, using the Python bindings</body></message>' http://localhost:5231/send
|
||||
Reference in New Issue
Block a user