Ejemplo n.º 1
0
/* Called by:  zxbus_subscribe */
static int zxbus_write_ch_subs(struct hiios* shf, struct hi_ch* ch)
{
#ifndef PATH_MAX
#define PATH_MAX ZXID_MAX_BUF
#endif
    char err_buf[PATH_MAX];
    int ch_num = ch - shf->chs;
    struct hi_ent* ent;
    char buf[ZXID_MAX_BUF];
    FILE* out;

    D("writing .subs for ch(%s) ch_num=%d", ch->dest, ch_num);
    name_from_path(buf, sizeof(buf), "%s" ZXBUS_CH_DIR "%s/.subs", zxbus_path, ch->dest);
    if (!(out = fopen(buf, "wb"))) {
        perror("open");
        ERR("writing subscriptions: File(%s) not writable errno=%d err(%s). euid=%d egid=%d cwd(%s)", buf, errno, STRERROR(errno), geteuid(), getegid(), getcwd(err_buf, sizeof(err_buf)));
        return 0;
    }

    for (ent = shf->ents; ent; ent = ent->n)
        if (ent->chs[ch_num]) {
            D("eid(%s)", ent->eid);
            fprintf(out, "%s\n", ent->eid);
        }
    fclose(out);
    return 1;
}
Ejemplo n.º 2
0
/* Called by:  zxbusd_main */
int zxbus_load_subs(struct hiios* shf)
{
    char path[ZXID_MAX_BUF];
    struct dirent* de;
    DIR* dir;
    struct hi_ch* ch = shf->chs;
    int n = 0;

    name_from_path(path, sizeof(path), "%s" ZXBUS_CH_DIR, zxbus_path);
    dir = opendir(path);
    if (!dir) {
        perror("opendir for /var/zxid/bus/ch/ (or other if configured)");
        D("failed path(%s)", path);
        return 0;
    }

    while (de = readdir(dir))
        if (de->d_name[0] != '.' && de->d_name[strlen(de->d_name)-1] != '~') { /* ign hidden&backup */
            if (++n > shf->max_chs) {
                ERR("More channels in directory(%s) than fit in array. Consider increasing -nch", path);
                break;
            }
            ch->dest = strdup(de->d_name);
            zxbus_load_ch_subs(shf, ch++);
        }
    closedir(dir);
    return 1;
}
Ejemplo n.º 3
0
SLClip::SLClip
	(std::string fname, std::string name, int launch, int stop, int loop, int amc, int amk, float vol, float rate, int pitch) :
	Clip(name, launch, stop, loop, amc, amk), volume_(vol)
{
	data_type_ = AUDIO;
	uri_ = fname;
	filename_ = name_from_path( uri_ );
}
Ejemplo n.º 4
0
SLClip::SLClip( std::string fname ) : Clip(), volume_(0.5f)
{
	data_type_ = AUDIO;
	uri_ = fname;
	filename_ = name_from_path( uri_ );
	int p = filename_.rfind( "." );
	name_ = filename_.substr( 0, p );
	launchstyle_ = LAUNCH_BAR;
	stopstyle_ = STOP_FREE;
	loopstyle_ = ONESHOT;
}
Ejemplo n.º 5
0
int main()
{
	char old_chr;
	char new_chr;

	printf("Input old character: ");
	old_chr = _getch();
	printf("'%c'\n", old_chr);

	printf("Input new character: ");
	new_chr = _getch();
	printf("'%c'\n", new_chr);

	char self_path[256];

	GetModuleFileName(NULL, self_path, 256);

	char *self_name = name_from_path(self_path);

	WIN32_FIND_DATA data;

	HANDLE hFindFile = FindFirstFile("./*", &data);

	if (hFindFile != INVALID_HANDLE_VALUE)
	{
		do
		{
			if (strcmp(data.cFileName, self_name) != 0 && strcmp(data.cFileName, ".") != 0 && strcmp(data.cFileName, ".."))
			{
				char old_name[256];
				char new_name[256];
				
				strcpy(old_name, data.cFileName);
				strcpy(new_name, chr_replace(data.cFileName, old_chr, new_chr));

				if (strcmp(old_name, new_name) != 0)
				{
					printf("Renamed %s to %s\n", old_name, new_name);

					rename(old_name, new_name);
				}
			}
		}
		while (FindNextFile(hFindFile, &data));
	}

	_getch();

	return 0;
}
Ejemplo n.º 6
0
/* Called by:  zxbus_load_acks, zxbus_load_ch_subs, zxbus_login_ent, zxbus_login_subj_hash */
struct hi_ent* zxbus_load_ent(struct hiios* shf, int len, const char* eid)
{
  char eid_buf[256];
  char sha1_name[28];
  char u_path[ZXID_MAX_BUF];
  struct hi_ent* ent;
  struct stat st;

  if (len == -1)
    len = strlen(eid);
  
  /* Check if already loaded */
  
  for (ent = shf->ents; ent; ent = ent->n) {
    DD("Checking eid(%.*s) against ent_%p->eid(%s)", len, eid, ent, ent->eid);
    if (!memcmp(ent->eid, eid, len) && !ent->eid[len]) {
      DD("Found ent_%p->eid(%s) io(%x) ache_%p", ent, ent->eid, ent->io?ent->io->fd:0xdeadbeef, ent->acks);
      return ent;
    }
  }
  
  /* Seems not. Prepare path and check if user directory exists. */

  if (len > sizeof(eid_buf)-2) {
    ERR("Entity ID too long (%.*s) len=%d", len, eid, len);
    return 0;
  }
  memcpy(eid_buf, eid, len);
  eid_buf[len] = 0;
  
  sha1_safe_base64(sha1_name, len, eid_buf);
  sha1_name[27] = 0;

  name_from_path(u_path, sizeof(u_path), "%s" ZXID_UID_DIR "/%s/", zxbus_path, sha1_name);
  if (stat(u_path, &st)==-1) {
    D("Entity(%.*s) does not exit. path(%s)", len, eid, u_path);
    return 0;
  }

  /* Add newly allocated entity to the list. */
  
  ent = zxbus_new_ent(shf, len, eid);
  D("Loaded ent_%p->eid(%s) io(%x) ache_%p",ent,ent->eid,ent->io?ent->io->fd:0xdeadbeef,ent->acks);
  return ent;
}
Ejemplo n.º 7
0
RessourceFile::RessourceFile (DataType dt, std::string path) : data_type_(dt), path_(path)
{
	name_ = name_from_path (path_);
}
Ejemplo n.º 8
0
void RessourceFile::setPath (std::string path)
{
	path_ = path;
	name_ = name_from_path (path_);
}