Example #1
0
static char *pick_symlink_target(const char *symlink_path)
{
	struct dir_info *dir;
	struct dir_entry_info *entry;
	size_t r;
	char *path, *rel_path;

	dir = pick_dir();

	if (tests_random_no(100) < 10)
		return dir_path(dir, make_name(dir));

	r = tests_random_no(dir->number_of_entries);
	entry = dir->first;
	while (entry && r) {
		entry = entry->next;
		--r;
	}
	if (!entry)
		entry = dir->first;
	if (!entry)
		return dir_path(dir, make_name(dir));
	path = dir_path(dir, entry->name);
	if (tests_random_no(20) < 10)
		return path;
	rel_path = relative_path(symlink_path, path);
	free(path);
	return rel_path;
}
Example #2
0
static char *pick_rename_name(struct dir_info **parent,
			      struct dir_entry_info **rename_entry, int isdir)
{
	struct dir_info *dir = pick_dir();
	struct dir_entry_info *entry;
	size_t r;

	*parent = dir;
	*rename_entry = NULL;

	if (grow || tests_random_no(20) < 10)
		return copy_string(make_name(dir));

	r = tests_random_no(dir->number_of_entries);
	entry = dir->first;
	while (entry && r) {
		entry = entry->next;
		--r;
	}
	if (!entry)
		entry = dir->first;
	if (!entry ||
	    (entry->type == 'd' && entry->entry.dir->number_of_entries != 0))
		return copy_string(make_name(dir));

	if ((isdir && entry->type != 'd') ||
	    (!isdir && entry->type == 'd'))
		return copy_string(make_name(dir));

	*rename_entry = entry;
	return copy_string(entry->name);
}
Example #3
0
/* Randomly select something to do with a directory */
static void operate_on_dir(struct dir_info *dir)
{
	size_t r;
	struct dir_entry_info *entry;
	struct file_info *file;

	r = tests_random_no(14);
	if (r == 0 && grow)
		/* When growing, 1 time in 14 create a file */
		file_new(dir, make_name(dir));
	else if (r == 1 && grow)
		/* When growing, 1 time in 14 create a directory */
		dir_new(dir, make_name(dir));
	else if (r == 2 && grow && (file = pick_file()) != NULL)
		/* When growing, 1 time in 14 create a hard link */
		link_new(dir, make_name(dir), file);
	else if (r == 3 && grow && tests_random_no(5) == 0)
		/* When growing, 1 time in 70 create a symbolic link */
		symlink_new(dir, make_name(dir));
	else {
		/* Otherwise randomly select an entry to operate on */
		r = tests_random_no(dir->number_of_entries);
		entry = dir->first;
		while (entry && r) {
			entry = entry->next;
			--r;
		}
		if (entry)
			operate_on_entry(entry);
	}
}
Example #4
0
void sync_const() {
	String s;
	Form2->Edit1->Text = get_nb();
	Form2->Edit2->Text = get_k();
	Form2->Edit3->Text = make_name(get_Pb());
	Form2->Edit4->Text = make_name(get_E());
	Form2->Edit5->Text = make_name(get_G());
}
Example #5
0
/* Outputs all addresses in the table through subwrite. subwrite must be
 * a function returning >=0 on success, -1 on error, and taking
 * arguments (char* string, unsigned int length). It will be called once
 * per address and should take care of newline or whatever needed for
 * the output form. */
unsigned long sub_sql_putsubs(struct subdbinfo *info,
			      const char *table,
			      unsigned long hash_lo,
			      unsigned long hash_hi,
			      int subwrite()) /* write function. */
{
  void *result;
  unsigned long no = 0L;
  char strnum[FMT_ULONG];

  stralloc_copyb(&params[0],strnum,fmt_ulong(strnum,hash_lo));
  stralloc_copyb(&params[1],strnum,fmt_ulong(strnum,hash_hi));
  make_name(info,table?"_":0,table,0);

  /* main query */
  stralloc_copys(&query,"SELECT address FROM ");
  stralloc_cat(&query,&name);
  stralloc_cats(&query," WHERE ");
  stralloc_cats(&query,sql_putsubs_where_defn);

  result = sql_select(info,&query,2,params);

  no = 0;
  while (sql_fetch_row(info,result,1,&addr)) {
    if (subwrite(addr.s,addr.len) == -1) die_write();
    no++;					/* count for list-list fxn */
  }
  sql_free_result(info,result);
  return no;
}
Example #6
0
Pbase start_cl(TOK t, Pname c, Pname b)
{
	if (c == 0) c = new name(make_name('C'));
//error('d',"c: %d %s",c->base,c->string);
	Pname n = c->tname(t);			/* t ignored */
	n->where = curloc;
	Pbase bt = (Pbase)n->tp;		/* COBJ */
	if (bt->base != COBJ) {
		error("twoDs of%n:%t andC",n,bt);
		error('i', "can't recover from previous errors");
	}
	Pclass occl = ccl;
	ccl = (Pclass)bt->b_name->tp;		/* CLASS */
	if (ccl->defined) {
		error("C%n defined twice");
		ccl->defined |= IN_ERROR;
	}
	ccl->defined |= DEF_SEEN;
	if (ccl->in_class = occl) occl->tn_list = modified_tn;	// save  mod-list
	modified_tn = 0;
	ccl->string = n->string;
	ccl->csu = t;
	if (b) ccl->clbase = b->tname(t);
	return bt;	
}
Example #7
0
/*
 * seek_emty: walk database starting at an empty nonterminal node
 * (should fail)
 */
static void test_seek_nx(const atf_tc_t *tc) {
	isc_result_t result;
	dns_db_t *db = NULL;
	dns_dbiterator_t *iter = NULL;
	dns_name_t *seekname;
	dns_fixedname_t f1;

	UNUSED(tc);

	dns_fixedname_init(&f1);
	seekname = dns_fixedname_name(&f1);

	result = dns_test_begin(NULL, ISC_FALSE);
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = dns_test_loaddb(&db, dns_dbtype_cache, TEST_ORIGIN,
				 atf_tc_get_md_var(tc, "X-filename"));
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = dns_db_createiterator(db, 0, &iter);
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = make_name("nonexistent." TEST_ORIGIN, seekname);
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = dns_dbiterator_seek(iter, seekname);
	ATF_CHECK_EQ(result, ISC_R_NOTFOUND);

	dns_dbiterator_destroy(&iter);
	dns_db_detach(&db);
	dns_test_end();
}
Example #8
0
int ph_mkostemps(char *nametemplate, int suffixlen, int flags)
{
  int len = strlen(nametemplate);
  char *base = nametemplate + (len - suffixlen) - 1;
  int tlen = 0;
  int fd, retries = 100;

  while (*base == 'X' && base > nametemplate) {
    tlen++;
    base--;
  }

  if (tlen == 0) {
    errno = EINVAL;
    return -1;
  }
  base++;

  while (retries--) {
    make_name(base, tlen);
    fd = open(nametemplate, flags|O_RDWR|O_CREAT|O_EXCL, 0600);
    if (fd >= 0) {
      return fd;
    }
    if (errno != EEXIST) {
      return -1;
    }
  }
  return -1;
}
Example #9
0
static void SetInfo(void)
{
  nsf_t * nsf = app.nsf;
  unsigned int ms;
  gchar *name = 0;
  unsigned int track = app.cur_track;

  pdebug("nsf : set info #%02u\n", track);

  ms = 0;
  if (!track || track > app.n_tracks) {
    ms = app.tracks[0].ms;
  } else {
    unsigned int tms = app.tracks[track].ms;
    ms = app.tracks[0].ms;
    name =
      g_strdup_printf("%s by %s track:%02d %02u:%02u copyright:%s :-)",
		      nsf->song_name, nsf->artist_name,
		      track, tms/60000u, tms%60000u/1000u,
		      nsf->copyright);
    nosefart_ip.set_info_text(name);
    g_free(name);
  }
  name = make_name(nsf->song_name, nsf->artist_name, track, app.n_tracks);
  nosefart_ip.set_info(name, ms, 44100, 44100, 1);
  g_free(name); /* $$$ ? */
}
Example #10
0
static HANDLE create_event(int sig, BOOL initial, BOOL errmsg, BOOL * exists)
{
	char name[EVT_NAME_LEN];
	HANDLE h;
	if (sig >= 0)
		make_name(name, sig);
	else
		name[0] = 0;
	if (exists)
		*exists = FALSE;
	if (!(h = CreateEventA(NULL, FALSE, initial, (name[0] ? name : NULL)))) {
		if (errmsg)
			fprintf(stderr, "CreateEvent(.,\"%s\"): Error=%ld\n", name, GetLastError());
		return 0;
	}

	if (GetLastError() == ERROR_ALREADY_EXISTS) {
		if (!exists) {
			if (errmsg)
				fprintf(stderr, "CreateEvent(.,\"%s\"): Exists\n", name);
			CloseHandle(h);
			return 0;
		}
		*exists = TRUE;
	}
	return h;
}
Example #11
0
static int sig_event(int sig)
{
	char name[EVT_NAME_LEN];
	HANDLE h;
	make_name(name, sig);
	if (!(h = OpenEventA(EVENT_MODIFY_STATE, FALSE, name))) {
		make_name(name, EVT_RUNNING);
		if (!(h = OpenEvent(EVENT_MODIFY_STATE, FALSE, name)))
			return -1;
		CloseHandle(h);
		return 0;
	}
	SetEvent(h);
	CloseHandle(h);
	return 1;
}
Example #12
0
/**
 * initialize the in/out connections
 *
 * @param basename base name for abstract namespace
 *
 * @return unix status
 */
static int sim_init_conn(char *basename)
{
	union name_t name;
	size_t size;
	int fd, i;

	DEBUG("initializing network connections (basename \"%s\")", basename);

	// create ctl channel
	fd = simctl = socket(remote_mode ? PF_INET : PF_LOCAL, SOCK_DGRAM, 0);
	if (fd < 0)
		IBPANIC("can't create socket for ctl");
	if (maxfd < fd)
		maxfd = fd;

	size = make_name(&name, 0, listen_to_port, "%s:ctl", basename);

	if (bind(fd, (struct sockaddr *)&name, size) < 0)
		IBPANIC("can't bind socket %d to name %s",
			fd, get_name(&name));

	if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
		IBPANIC("can't set non blocking flags for ctl");

	for (i = 0; i < IBSIM_MAX_CLIENTS; i++) {
		fd = socket(remote_mode ? PF_INET : PF_LOCAL, SOCK_DGRAM, 0);
		if (fd < 0)
			IBPANIC("can't create socket for conn %d", i);
		if (maxfd < fd)
			maxfd = fd;

		size = make_name(&name, 0, listen_to_port + i + 1,
				 "%s:out%d", basename, i);
		if (bind(fd, (struct sockaddr *)&name, size) < 0)
			IBPANIC("can't bind socket %d to name %s",
				fd, get_name(&name));

		if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0)
			IBPANIC("can't set non blocking flags for "
			        "client conn %d", i);

		DEBUG("opening net connection fd %d %s", fd, get_name(&name));

		clients[i].fd = fd;
	}
	return 0;
}
Example #13
0
static const char *remove_table(struct subdbinfo *info,
				const char *suffix1,
				const char *suffix2)
{
  make_name(info,suffix1,suffix2,1);
  if (sql_table_exists(info,name.s) == 0)
    return 0;
  return sql_drop_table(info,name.s);
}
Example #14
0
static int event_exists(int sig)
{
	char name[EVT_NAME_LEN];
	HANDLE h;
	make_name(name, sig);
	if (!(h = OpenEventA(EVENT_MODIFY_STATE, FALSE, name)))
		return 0;
	CloseHandle(h);
	return 1;
}
Example #15
0
void
name_gather (void)
{
  /* Buffer able to hold a single name.  */
  static struct name *buffer = NULL;

  struct name_elt *ep;

  if (same_order_option)
    {
      static int change_dir;

      while ((ep = name_next_elt (0)) && ep->type == NELT_CHDIR)
	change_dir = chdir_arg (xstrdup (ep->v.name));

      if (ep)
	{
	  free_name (buffer);
	  buffer = make_name (ep->v.name);
	  buffer->change_dir = change_dir;
	  buffer->next = 0;
	  buffer->found_count = 0;
	  buffer->matching_flags = matching_flags;
	  buffer->directory = NULL;
	  buffer->parent = NULL;
	  buffer->cmdline = true;
	  
	  namelist = nametail = buffer;
	}
      else if (change_dir)
	addname (0, change_dir, false, NULL);
    }
  else
    {
      /* Non sorted names -- read them all in.  */
      int change_dir = 0;

      for (;;)
	{
	  int change_dir0 = change_dir;
	  while ((ep = name_next_elt (0)) && ep->type == NELT_CHDIR)
	    change_dir = chdir_arg (xstrdup (ep->v.name));

	  if (ep)
	    addname (ep->v.name, change_dir, true, NULL);
	  else
	    {
	      if (change_dir != change_dir0)
		addname (NULL, change_dir, false, NULL);
	      break;
	    }
	}
    }
}
Example #16
0
File: downboy2.c Project: anl/IT
void read_stat(char *proc_id,override_type *entry,int k,int uid)
{
   char *stat_filename=make_name(proc_id,1);
   int done=0;

   char *field;
   FILE *fp;
   int n; /* current field number */

   char *proc_name;
   unsigned utime;
   int priority;
   int nice;

   if ((fp=fopen(stat_filename,"r"))==NULL)
      fprintf(stderr,"Error: failed to open '%s'!\n",stat_filename);
   else
      {
      for (n=0; !done && (field=get_next_field(fp)); n++)
         switch (n)
            {
            case 1: /* proc name */
               proc_name=alloca(strlen(field)+1);
               strcpy(proc_name,strip_parens(field));
               break;

            case 13: /* utime */
               utime=atol(field)/(float)USER_HZ;
               break;

            case 17: /* priority */
               priority=atoi(field);
               break;

            case 18: /* nice */
               nice=atoi(field);
               done=1; /* end iteration after last interesting field */
               break;
            }

      fclose(fp);
      }

   if (done) /* reached last field OK */
      {
      /* if exceeded defined kill threshold and not an exception... */
      if (k>0 && (!entry || entry->elapsed!=-1) && utime>k)
         kill_proc(atoi(proc_id),uid,k);
      else
         adjust_sched(atoi(proc_id),proc_name,utime,priority,nice,entry);
      }
}
Example #17
0
static void nosefart_song_info(char *filename, char **title, int *length)
{
  nsf_t * nsf;

  *length = -1;
  *title = 0;
  nsf = load(filename);
  if (nsf) {
    *title = make_name(nsf->song_name, nsf->artist_name, -1, nsf->num_songs);
    *length = nsf->song_frames[0] * 1000u / (unsigned int)nsf->playback_rate;
    nsf_free(&nsf);
  }
}
Example #18
0
File: downboy2.c Project: anl/IT
int get_owner(char *proc_id)
{
   char *filename=make_name(proc_id,0);
   int uid=-1; /* error returned if stat not completed */

   struct stat file_stat;

   if (stat(filename,&file_stat)!=0)
      fprintf(stderr,"Error: failed to stat '%s'!\n",filename);
   else
      uid=file_stat.st_uid;

   return(uid);
}
Example #19
0
/* Searches the subscriber log and outputs via subwrite(s,len) any entry
 * that matches search. A '_' is search is a wildcard. Any other
 * non-alphanum/'.' char is replaced by a '_'. */
void sub_sql_searchlog(struct subdbinfo *info,
		       const char *table,
		       char *search,		/* search string */
		       int subwrite())		/* output fxn */
{
  void *result;
  datetime_sec when;
  struct datetime dt;
  char date[DATE822FMT];
  int nparams;
  char strnum[FMT_ULONG];

  make_name(info,table?"_":0,table,0);
/* SELECT (*) FROM list_slog WHERE fromline LIKE '%search%' OR address   */
/* LIKE '%search%' ORDER BY tai; */
/* The '*' is formatted to look like the output of the non-mysql version */
/* This requires reading the entire table, since search fields are not   */
/* indexed, but this is a rare query and time is not of the essence.     */

  stralloc_copys(&query,"SELECT ");
  stralloc_cats(&query,sql_searchlog_select_defn);
  stralloc_cats(&query," FROM ");
  stralloc_cat(&query,&name);
  stralloc_cats(&query,"_slog");
  if (*search) {	/* We can afford to wait for LIKE '%xx%' */
    stralloc_copys(&params[0],search);
    stralloc_copys(&params[1],search);
    nparams = 2;
    stralloc_cats(&query," WHERE ");
    stralloc_cats(&query,sql_searchlog_where_defn);
  }
  else
    nparams = 0;
  /* ordering by tai which is an index */
  stralloc_cats(&query," ORDER by tai");

  result = sql_select(info,&query,nparams,params);
  while (sql_fetch_row(info,result,2,params)) {
    stralloc_0(&params[0]);
    (void)scan_ulong(params[0].s,&when);
    datetime_tai(&dt,when);
    stralloc_copyb(&params[0],date,date822fmt(date,&dt)-1);
    stralloc_cats(&params[0],": ");
    stralloc_catb(&params[0],strnum,fmt_ulong(strnum,when));
    stralloc_cats(&params[0]," ");
    stralloc_cat(&params[0],&params[1]);
    if (subwrite(params[0].s,params[0].len) == -1) die_write();
  }
  sql_free_result(info,result);
}
Example #20
0
char *
get_name(ADDR mem, int idx, Elf64_Sym *symtab, int symcount, int symstart, char *strtab, char *count_strtab)
{
  char *name1;

  if (idx == 0) {
    if ((name1 = find_and_get_str(mem, symtab, symcount, symstart, strtab)) == 0) {
      /* manufacture a name */
      name1 = make_name(mem);
    }
  }
  else 
    name1 = count_strtab + idx;
  return name1;
}
Example #21
0
/* Randomly select something to do with a directory */
static void operate_on_dir(struct dir_info *dir)
{
	size_t r;
	struct dir_entry_info *entry;

	r = tests_random_no(12);
	if (r == 0 && grow)
		/* When growing, 1 time in 12 create a file */
		file_new(dir, make_name(dir));
	else if (r == 1 && grow)
		/* When growing, 1 time in 12 create a directory */
		dir_new(dir, make_name(dir));
	else {
		/* Otherwise randomly select an entry to operate on */
		r = tests_random_no(dir->number_of_entries);
		entry = dir->first;
		while (entry && r) {
			entry = entry->next;
			--r;
		}
		if (entry)
			operate_on_entry(entry);
	}
}
Example #22
0
/* seek: walk database starting at a particular node */
static void test_seek(const atf_tc_t *tc) {
	isc_result_t result;
	dns_db_t *db = NULL;
	dns_dbiterator_t *iter = NULL;
	dns_dbnode_t *node = NULL;
	dns_name_t *name, *seekname;
	dns_fixedname_t f1, f2;
	int i = 0;

	UNUSED(tc);

	dns_fixedname_init(&f1);
	name = dns_fixedname_name(&f1);
	dns_fixedname_init(&f2);
	seekname = dns_fixedname_name(&f2);

	result = dns_test_begin(NULL, ISC_FALSE);
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = dns_test_loaddb(&db, dns_dbtype_cache, TEST_ORIGIN,
				 atf_tc_get_md_var(tc, "X-filename"));
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = dns_db_createiterator(db, 0, &iter);
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = make_name("c." TEST_ORIGIN, seekname);
	ATF_REQUIRE_EQ(result, ISC_R_SUCCESS);

	result = dns_dbiterator_seek(iter, seekname);
	ATF_CHECK_EQ(result, ISC_R_SUCCESS);

	while (result == ISC_R_SUCCESS) {
		result = dns_dbiterator_current(iter, &node, name);
		if (result == DNS_R_NEWORIGIN)
			result = ISC_R_SUCCESS;
		ATF_CHECK_EQ(result, ISC_R_SUCCESS);
		dns_db_detachnode(db, &node);
		result = dns_dbiterator_next(iter);
		i++;
	}

	ATF_CHECK_EQ(i, atoi(atf_tc_get_md_var(tc, "X-nodes")));

	dns_dbiterator_destroy(&iter);
	dns_db_detach(&db);
	dns_test_end();
}
Example #23
0
static const char *create_table(struct subdbinfo *info,
				const char *suffix1,
				const char *suffix2,
				const char *definition)
{
  make_name(info,suffix1,suffix2,1);
  if (sql_table_exists(info,name.s) > 0)
    return 0;
  stralloc_copys(&query,"CREATE TABLE ");
  stralloc_cats(&query,name.s);
  stralloc_cats(&query," (");
  stralloc_cats(&query,definition);
  stralloc_cats(&query,")");
  stralloc_0(&query);
  return sql_create_table(info,query.s);
}
Example #24
0
 //functions
 FullConnection(Layer* f, Layer* t, const vector<int>& d = empty_list_of<int>(), FullConnection* s = 0):
     Connection(make_name(f, t, d), f, t),
     source(s),
     paramRange(source ? source->paramRange : WeightContainer::instance().new_parameters(this->from->output_size() * this->to->input_size(), this->from->name, this->to->name, name))    {
     if (source)
     {
         WeightContainer::instance().link_layers(this->from->name, this->to->name, this->name, 
                                                 paramRange.first, paramRange.second);
     }
     set_delay(d);
     assert(num_weights() == (this->from->output_size() * this->to->input_size()));
     if (this->from->name != "bias" && this->from != this->to && !this->to->source)
     {
         this->to->source = this->from;
     }
 }
Example #25
0
/*ARGSUSED*/
static int
look_xmap(void *data,
          const prxmap_t *pmp,
          const char *object_name,
          int last, int doswap)
{
    struct totals *t = data;
    const pstatus_t *Psp = Pstatus(Pr);
    char mname[PATH_MAX];
    char *lname = NULL;
    char *ln;

    /*
     * If the mapping is not anon or not part of the heap, make a name
     * for it.  We don't want to report the heap as a.out's data.
     */
    if (!(pmp->pr_mflags & MA_ANON) ||
            pmp->pr_vaddr + pmp->pr_size <= Psp->pr_brkbase ||
            pmp->pr_vaddr >= Psp->pr_brkbase + Psp->pr_brksize) {
        lname = make_name(Pr, lflag, pmp->pr_vaddr, pmp->pr_mapname,
                          mname, sizeof (mname));
    }

    if (lname != NULL) {
        if ((ln = strrchr(lname, '/')) != NULL)
            lname = ln + 1;
    } else if ((pmp->pr_mflags & MA_ANON) || Pstate(Pr) == PS_DEAD) {
        lname = anon_name(mname, Psp, stacks, nstacks, pmp->pr_vaddr,
                          pmp->pr_size, pmp->pr_mflags, pmp->pr_shmid, NULL);
    }

    (void) printf("%.*lX", addr_width, (ulong_t)pmp->pr_vaddr);

    printK(ROUNDUP_KB(pmp->pr_size), size_width);
    printK(pmp->pr_rss * (pmp->pr_pagesize / KILOBYTE), size_width);
    printK(ANON(pmp) * (pmp->pr_pagesize / KILOBYTE), size_width);
    printK(pmp->pr_locked * (pmp->pr_pagesize / KILOBYTE), size_width);
    (void) printf(lname ? " %4s %-6s %s\n" : " %4s %s\n",
                  pagesize(pmp), mflags(pmp->pr_mflags), lname);

    t->total_size += ROUNDUP_KB(pmp->pr_size);
    t->total_rss += pmp->pr_rss * (pmp->pr_pagesize / KILOBYTE);
    t->total_anon += ANON(pmp) * (pmp->pr_pagesize / KILOBYTE);
    t->total_locked += (pmp->pr_locked * (pmp->pr_pagesize / KILOBYTE));

    return (0);
}
Example #26
0
int sub_sql_issub(struct subdbinfo *info,
		  const char *table,
		  const char *userhost,
		  stralloc *recorded)
{
  unsigned int j;
  void *result;
  int ret;

  /* SELECT address FROM list WHERE address = 'userhost' AND hash */
  /* BETWEEN 0 AND 52. Without the hash restriction, we'd make it */
  /* even easier to defeat. Just faking sender to the list name would*/
  /* work. Since sender checks for posts are bogus anyway, I don't */
  /* know if it's worth the cost of the "WHERE ...". */

  make_name(info,table?"_":0,table,0);

  /* Lower-case the domain portion */
  stralloc_copys(&addr,userhost);
  j = byte_rchr(addr.s,addr.len,'@');
  if (j == addr.len)
    return 0;
  case_lowerb(addr.s + j + 1,addr.len - j - 1);

  stralloc_copys(&query,"SELECT address FROM ");
  stralloc_cat(&query,&name);
  stralloc_cats(&query," WHERE ");
  stralloc_cats(&query,sql_issub_where_defn);

  result = sql_select(info,&query,1,&addr);

  if (!sql_fetch_row(info,result,1,&addr))
    ret = 0;
  else {
    /* we need to return the actual address as other dbs may accept
     * user-*@host, but we still want to make sure to send to e.g the
     * correct moderator address. */
    if (recorded != 0) {
      stralloc_copy(recorded,&addr);
      stralloc_0(recorded);
    }
    ret = 1;
  }
  sql_free_result(info,result);
  return ret;
}
Example #27
0
Pbase end_enum(Pname n, Pname b)
{
	if (n == 0) n = new name(make_name('E'));
	n = n->tname(ENUM);
	Pbase bt = (Pbase)n->tp;
	if (bt->base != EOBJ) {
		error("twoDs of%n:%t and enum",n,bt);
		error('i', "can't recover from previous errors");
	}
	Penum en = (Penum)bt->b_name->tp;
	en->e_body = 2;
	en->mem = name_unlist((class nlist *)b);
	if (en->defined) {
		error("enum%n defined twice",n);
		en->defined |= IN_ERROR;
	}
	en->defined |= DEF_SEEN;
	return bt;
}
Example #28
0
/*  Add a name to the namelist.  */
struct name *
addname (char const *string, int change_dir, bool cmdline, struct name *parent)
{
  struct name *name = make_name (string);

  name->prev = nametail;
  name->next = NULL;
  name->found_count = 0;
  name->matching_flags = matching_flags;
  name->change_dir = change_dir;
  name->directory = NULL;
  name->parent = parent;
  name->cmdline = cmdline;

  if (nametail)
    nametail->next = name;
  else
    namelist = name;
  nametail = name;
  return name;
}
Example #29
0
bool_t linphone_gtk_init_instance(const char *app_name, const char *addr_to_call){
	pipe_name=make_name(app_name);
	ortp_pipe_t p=ortp_client_pipe_connect(pipe_name);
	if (p!=(ortp_pipe_t)-1){
		uint8_t buf[256]={0};
		g_message("There is already a running instance.");
		if (addr_to_call!=NULL){
			//strncpy((char*)buf,addr_to_call,sizeof(buf)-1);
			sprintf((char*)buf, "%s %s %s", addr_to_call, aupkg_file, (g_enable_video==FALSE)?"audio":"video");
		}
		if (ortp_pipe_write(p,buf,sizeof(buf))==-1){
			g_error("Fail to send wakeup command to running instance: %s",strerror(errno));
		}else{
			g_message("Message to running instance sent.");
		}
		ortp_client_pipe_close(p);
		return FALSE;
	}else{
		linphone_gtk_init_pipe(pipe_name);
	}
	return TRUE;
}
Example #30
0
bool_t linphone_gtk_init_instance(const char *app_name, int option, const char *addr_to_call){
	ortp_pipe_t p;
	pipe_name=make_name(app_name);
	p=ortp_client_pipe_connect(pipe_name);
	if (p!=(ortp_pipe_t)-1){
		uint8_t buf[256]={0};
		g_message("There is already a running instance.");
		if (addr_to_call!=NULL){
			sprintf((char *)buf,"%i%s",option,addr_to_call);
		} else {
			sprintf((char *)buf,"%i",option);
		}
		if (ortp_pipe_write(p,buf,sizeof(buf))==-1){
			g_error("Fail to send wakeup command to running instance: %s",strerror(errno));
		}else{
			g_message("Message to running instance sent.");
		}
		ortp_client_pipe_close(p);
		return FALSE;
	}else{
		linphone_gtk_init_pipe(pipe_name);
	}
	return TRUE;
}