Browse Source

Client name rewritting to remove path characters (used in fifo naming).

git-svn-id: http://subversion.jackaudio.org/jack/jack2/trunk/jackmp@1686 0c269be4-1314-0410-8aa9-9f06e86f4224
tags/0.68
sletz 18 years ago
parent
commit
188505126f
5 changed files with 55 additions and 2 deletions
  1. +1
    -0
      ChangeLog
  2. +5
    -1
      common/JackLibAPI.cpp
  3. +5
    -1
      common/JackServerAPI.cpp
  4. +42
    -0
      common/JackTools.cpp
  5. +2
    -0
      common/JackTools.h

+ 1
- 0
ChangeLog View File

@@ -16,6 +16,7 @@ Tom Szilagyi
2007-10-31 Stephane Letz <letz@grame.fr>

* Server and user directory related code moved in a JackTools file.
* Client name rewritting to remove path characters (used in fifo naming).

2007-10-30 Stephane Letz <letz@grame.fr>



+ 5
- 1
common/JackLibAPI.cpp View File

@@ -24,6 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "JackLibGlobals.h"
#include "JackGlobals.h"
#include "JackServerLaunch.h"
#include "JackTools.h"

using namespace Jack;

@@ -56,12 +57,15 @@ static inline bool CheckPort(jack_port_id_t port_index)
return (port_index < PORT_NUM);
}

EXPORT jack_client_t* jack_client_open(const char* client_name, jack_options_t options, jack_status_t* status, ...)
EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
{
va_list ap; /* variable argument pointer */
jack_varargs_t va; /* variable arguments */
jack_status_t my_status;
JackClient* client;
char client_name[JACK_CLIENT_NAME_SIZE];
JackTools::RewriteName(ext_client_name, client_name);

if (status == NULL) /* no status from caller? */
status = &my_status; /* use local status word */


+ 5
- 1
common/JackServerAPI.cpp View File

@@ -29,6 +29,7 @@ This program is free software; you can redistribute it and/or modify
#include "JackServerGlobals.h"
#include "JackError.h"
#include "JackServerLaunch.h"
#include "JackTools.h"

#ifdef WIN32
#define EXPORT __declspec(dllexport)
@@ -62,12 +63,15 @@ EXPORT jack_client_t* jack_client_new(const char* client_name)
return jack_client_open(client_name, (jack_options_t)options, NULL);
}

EXPORT jack_client_t* jack_client_open(const char* client_name, jack_options_t options, jack_status_t* status, ...)
EXPORT jack_client_t* jack_client_open(const char* ext_client_name, jack_options_t options, jack_status_t* status, ...)
{
va_list ap; /* variable argument pointer */
jack_varargs_t va; /* variable arguments */
jack_status_t my_status;
JackClient* client;
char client_name[JACK_CLIENT_NAME_SIZE];
JackTools::RewriteName(ext_client_name, client_name);

if (status == NULL) /* no status from caller? */
status = &my_status; /* use local status word */


+ 42
- 0
common/JackTools.cpp View File

@@ -140,5 +140,47 @@ void JackTools::CleanupFiles(const char* server_name)
}
}

int JackTools::GetTmpdir()
{
FILE* in;
size_t len;
char buf[PATH_MAX + 2]; /* allow tmpdir to live anywhere, plus newline, plus null */

if ((in = popen("jackd -l", "r")) == NULL) {
return -1;
}

if (fgets(buf, sizeof(buf), in) == NULL) {
fclose(in);
return -1;
}

len = strlen(buf);

if (buf[len - 1] != '\n') {
/* didn't get a whole line */
fclose(in);
return -1;
}

jack_tmpdir = (char *)malloc(len);
memcpy(jack_tmpdir, buf, len - 1);
jack_tmpdir[len - 1] = '\0';
fclose(in);
return 0;
}

void JackTools::RewriteName(const char* name, char* new_name)
{
int i;
for (i = 0; i < strlen(name); i++) {
if ((name[i] == '/') || (name[i] == '\\'))
new_name[i] = '_';
else
new_name[i] = name[i];
}
new_name[i] = '\0';
}

}

+ 2
- 0
common/JackTools.h View File

@@ -40,6 +40,8 @@ namespace Jack
static char* ServerDir(const char* server_name, char* server_dir);
static char* DefaultServerName();
static void CleanupFiles(const char* server_name);
static int GetTmpdir();
static void RewriteName(const char* name, char* new_name);

};
}


Loading…
Cancel
Save