Ejemplo n.º 1
0
BOOL
spool_move_message(uschar *id, uschar *subdir, uschar *from, uschar *to)
{
/* Create any output directories that do not exist. */

sprintf(CS big_buffer, "%sinput/%s", to, subdir);
(void)directory_make(spool_directory, big_buffer, INPUT_DIRECTORY_MODE, TRUE);
sprintf(CS big_buffer, "%smsglog/%s", to, subdir);
(void)directory_make(spool_directory, big_buffer, INPUT_DIRECTORY_MODE, TRUE);

/* Move the message by first creating new hard links for all the files, and
then removing the old links. When moving messages onto the main spool, the -H
file should be set up last, because that's the one that tells Exim there is a
message to be delivered, so we create its new link last and remove its old link
first. Programs that look at the alternate directories should follow the same
rule of waiting for a -H file before doing anything. When moving messages off
the mail spool, the -D file should be open and locked at the time, thus keeping
Exim's hands off. */

if (!make_link(US"msglog", subdir, id, US"", from, to, TRUE) ||
    !make_link(US"input",  subdir, id, US"-D", from, to, FALSE) ||
    !make_link(US"input",  subdir, id, US"-H", from, to, FALSE))
  return FALSE;

if (!break_link(US"input",  subdir, id, US"-H", from, FALSE) ||
    !break_link(US"input",  subdir, id, US"-D", from, FALSE) ||
    !break_link(US"msglog", subdir, id, US"", from, TRUE))
  return FALSE;

log_write(0, LOG_MAIN, "moved from %sinput, %smsglog to %sinput, %smsglog",
   from, from, to, to);

return TRUE;
}
Ejemplo n.º 2
0
std::vector<topic> generate_time_of_day_topics(const bool /*sort_generated*/)
{
	std::vector<topic> topics;
	std::stringstream toplevel;

	if (! resources::tod_manager) {
		toplevel << N_("Only available during a scenario.");
		topics.push_back( topic("Time of Day Schedule", "..schedule", toplevel.str()) );
		return topics;
	}
	const std::vector<time_of_day>& times = resources::tod_manager->times();
	BOOST_FOREACH(const time_of_day& time, times)
	{
		const std::string id = "time_of_day_" + time.id;
		const std::string image = "<img>src='" + time.image + "'</img>";
		std::stringstream text;

		toplevel << make_link(time.name.str(), id) << jump_to(160) <<
				image << jump(30) << time.lawful_bonus << '\n';

		text << image << '\n' <<
				time.description.str() << '\n' <<
				"Lawful Bonus: " << time.lawful_bonus << '\n' <<
				'\n' << make_link(N_("Schedule"), "..schedule");

		topics.push_back( topic(time.name.str(), id, text.str()) );
	}

	topics.push_back( topic("Time of Day Schedule", "..schedule", toplevel.str()) );
	return topics;
}
Ejemplo n.º 3
0
int add_dccallow(aClient *sptr, aClient *optr)
{
Link *lp;
int cnt = 0;

	for (lp = sptr->user->dccallow; lp; lp = lp->next)
	{
		if (lp->flags != DCC_LINK_ME)
			continue;
		if (++cnt >= MAXDCCALLOW)
		{
			sendto_one(sptr, err_str(ERR_TOOMANYDCC), me.name, sptr->name,
				optr->name, MAXDCCALLOW);
			return 0;
		} else
		if (lp->value.cptr == optr)
			return 0;
	}
	
	lp = make_link();
	lp->value.cptr = optr;
	lp->flags = DCC_LINK_ME;
	lp->next = sptr->user->dccallow;
	sptr->user->dccallow = lp;
	
	lp = make_link();
	lp->value.cptr = sptr;
	lp->flags = DCC_LINK_REMOTE;
	lp->next = optr->user->dccallow;
	optr->user->dccallow = lp;
	
	sendto_one(sptr, rpl_str(RPL_DCCSTATUS), me.name, sptr->name, optr->name, "added to");
	return 0;
}
Ejemplo n.º 4
0
std::vector<topic> generate_era_topics(const bool sort_generated, const std::string & era_id)
{
	std::vector<topic> topics;

	const config & era = game_cfg->find_child("era","id", era_id);
	if(era) {
		topics = generate_faction_topics(era, sort_generated);

		std::vector<std::string> faction_links;
		BOOST_FOREACH(const topic & t, topics) {
			faction_links.push_back(make_link(t.title, t.id));
		}

		std::stringstream text;
		text << "<header>text='" << _("Era:") << " " << era["name"] << "'</header>" << "\n";
		text << "\n";
		const config::attribute_value& description = era["description"];
		if (!description.empty()) {
			text << description.t_str() << "\n";
			text << "\n";
		}

		text << "<header>text='" << _("Factions:") << "'</header>" << "\n";

		std::sort(faction_links.begin(), faction_links.end());
		BOOST_FOREACH(const std::string &link, faction_links) {
			text << link << "\n";
		}

		topic era_topic(era["name"], ".." + era_prefix + era["id"].str(), text.str());

		topics.push_back( era_topic );
	}
Ejemplo n.º 5
0
/* sort_tree_by_shares()
 */
static void
sort_tree_by_shares(struct tree_ *t)
{
    link_t *stack;
    struct tree_node_ *root;
    struct tree_node_ *n;

    stack = make_link();
    root = t->root;
    n = root->child;

znovu:
    while (n) {

        if (n->child)
            enqueue_link(stack, n);

        n = n->right;
    }

    sort_siblings(root, node_cmp);

    n = pop_link(stack);
    if (n) {
        root = n;
        n = root->child;
        goto znovu;
    }

    fin_link(stack);
    make_leafs(t);
}
Ejemplo n.º 6
0
/* zero_out_sent()
 */
static void
zero_out_sent(struct tree_ *t)
{
    link_t *stack;
    struct tree_node_ *root;
    struct tree_node_ *n;
    struct share_acct *s;

    stack = make_link();
    root = t->root;
    n = root->child;

znovu:
    while (n) {

        if (n->child)
            enqueue_link(stack, n);

        s = n->data;
        s->sent = 0;
        n = n->right;
    }

    n = pop_link(stack);
    if (n) {
        root = n;
        n = root->child;
        goto znovu;
    }

    fin_link(stack);
}
Ejemplo n.º 7
0
static int restore_link(struct asfd *asfd, struct sbuf *sb,
	const char *fname, enum action act, struct cntr *cntr,
	enum protocol protocol, const char *restore_prefix)
{
	int ret=0;

	if(act==ACTION_RESTORE)
	{
		char *rpath=NULL;
		if(build_path(fname, "", &rpath, NULL))
		{
			ret=warn_and_interrupt(asfd, sb, cntr, protocol,
				"build path failed: %s", fname);
			goto end;
		}
		else if(make_link(asfd,
			fname, sb->link.buf, sb->link.cmd,
			cntr, restore_prefix))
		{
			ret=warn_and_interrupt(asfd, sb, cntr, protocol,
				"could not create link", "");
			goto end;
		}
		else if(!ret)
		{
			attribs_set(asfd, fname,
				&(sb->statp), sb->winattr, cntr);
			cntr_add(cntr, sb->path.cmd, 1);
		}
		free_w(&rpath);
	}
	else cntr_add(cntr, sb->path.cmd, 1);
end:
	return ret;
}
Ejemplo n.º 8
0
/* get_rusage_entries()
 */
static link_t *
get_rusage_entries(const char *s)
{
    char *p;
    char *ss;
    char *ss0;
    char *z;
    link_t *l;

    l = make_link();

    /* Return an empty link
     */
    ss0 = ss = strdup(s);
    if (! strstr(ss, "||")) {
        enqueue_link(l, ss);
        return l;
    }

    while ((p = strstr(ss, "||"))) {
        *p = 0;
        z = strdup(ss);
        enqueue_link(l, z);
        ss = p + 2;
    }

    z = strdup(ss);
    enqueue_link(l, z);
    _free_(ss0);

    return l;
}
Ejemplo n.º 9
0
static int restore_link(struct asfd *asfd, struct sbuf *sb,
	const char *fname, enum action act, struct conf **confs)
{
	int ret=0;

	if(act==ACTION_RESTORE)
	{
		char *rpath=NULL;
		if(build_path(fname, "", &rpath, NULL))
		{
			ret=warn_and_interrupt(asfd, sb, confs,
				"build path failed: %s", fname);
			goto end;
		}
		else if(make_link(asfd,
			fname, sb->link.buf, sb->link.cmd, confs))
		{
			ret=warn_and_interrupt(asfd, sb, confs,
				"could not create link", "");
			goto end;
		}
		else if(!ret)
		{
			attribs_set(asfd, fname,
				&(sb->statp), sb->winattr, confs);
			cntr_add(get_cntr(confs[OPT_CNTR]), sb->path.cmd, 1);
		}
		if(rpath) free(rpath);
	}
	else cntr_add(get_cntr(confs[OPT_CNTR]), sb->path.cmd, 1);
end:
	return ret;
}
Ejemplo n.º 10
0
void http::server::list_directory(const http::server::request &req, http::server::reply &reply,
                                  const std::string &doc_root) {
    try {
        boost::filesystem::path root = doc_root + req.uri;
        std::ostringstream stream;
        stream << "<h1>Directory listing of " + req.uri + "</h1>";
        stream << parent_directory_anchor(req.uri, doc_root);
        std::vector<boost::filesystem::path> files_in_folder;
        std::copy(boost::filesystem::directory_iterator(root), boost::filesystem::directory_iterator(),
                  std::back_inserter(files_in_folder));

        std::sort(files_in_folder.begin(), files_in_folder.end(), [](const auto &p1, const auto &p2) {
            return boost::filesystem::last_write_time(p1) > boost::filesystem::last_write_time(p2);
        });
        std::stable_partition(files_in_folder.begin(), files_in_folder.end(),
                              [](const auto &p) { return boost::filesystem::is_regular_file(p); });

        for (const auto &p : files_in_folder) {
            try {
                stream << "<a href=\"";
                stream << make_link(req.uri, p) << "\">";
                stream << trim_quotes(make_file_name(p));
                stream << "</a><br/>";
            } catch (const std::logic_error &) {
                continue;
            }
        }
        reply.content = stream.str();
        reply.add_header("Cache-Control", "max-age=60");
        reply.add_header("Content-Type", "text/html");
    } catch (...) {
        reply.status = reply::status_type::internal_server_error;
        reply.add_header("Cache-Control", "no-cache");
    }
}
Ejemplo n.º 11
0
/* parse_user_shares()
 *
 * parse user_shares[[g, 1] [e,1]]
 */
static link_t *
parse_user_shares(const char *user_shares)
{
    link_t *l;
    char *p;
    char *u;
    int cc;
    int n;
    struct share_acct *sacct;
    uint32_t sum_shares;
    linkiter_t iter;

    u = strdup(user_shares);
    assert(u);

    p = strchr(u, '[');
    *p++ = 0;

    tokenize(p);

    l = make_link();
    sum_shares = 0;

    while (1 ) {
        char name[128];
        uint32_t shares;

        cc = sscanf(p, "%s%u%n", name, &shares, &n);
        if (cc == EOF)
            break;
        if (cc != 2)
            goto bail;
        p = p + n;

        sacct = make_sacct(name, shares);
        assert(sacct);

        sum_shares = sum_shares + sacct->shares;

        enqueue_link(l, sacct);
    }

    traverse_init(l, &iter);
    while ((sacct = traverse_link(&iter))) {
        sacct->dshares = (double)sacct->shares/(double)sum_shares;
    }

    _free_(u);
    return l;

bail:

    _free_(u);
    traverse_init(l, &iter);
    while ((sacct = traverse_link(&iter)))
        free_sacct(sacct);
    fin_link(l);

    return NULL;
}
Ejemplo n.º 12
0
/*
 * This is like addlink(), but it doesn't try to find a 5.x
 * link to point to.  It is used by the rule functions to add
 * additional links to links already created with addlink().
 */
static void
addlink_nolookup(char *compat_link, char *target, int unique)
{
	struct symlink *slp;
	char *oldtarg;

	slp = lookup_link_sym(compat_link);
	if (slp == NULL) {
		slp = xmalloc(sizeof (struct symlink));
		slp->linkname = xstrdup(compat_link);
		slp->target = NULL;
		slp->already = 0;
		insert_link_sym(slp);
	}
	oldtarg = slp->target;

	if (unique) {
		if (slp->already)
			return;
		else
			slp->already = 1;
	}

	make_link(compat_link, target, slp, DI_SECONDARY_LINK);

	/*
	 * If it didn't exist or pointed to the wrong
	 * thing we need to duplicate the target and
	 * note that the symlink now points to it.
	 */
	if (slp->target != oldtarg)
		slp->target = xstrdup(target);
}
Ejemplo n.º 13
0
static void countline(int dir, struct field *line)
{
    int i;
    int max;
    int counter = -1;
    struct count count;

    if (hori(dir))
	max = XMAX;
    else
	max = YMAX;
    count.zero = count.one = count.num = 0;
    count.empty = -1;
    
    for (i=0; i<max; i++) {
	init_link(&(line[i]));
	make_count(counter, &(line[i]), &count);
	if (line[i].value == -1)
	    count.empty = i;
    }
    fill_remain(max, line, count);
    make_link(max, line, count);
    check_link(max, line);
    counter = 0;
    count.zero = count.one = count.num = 0;
    count.empty = -1;

    for (i=0; i<max; i++) {
	counter = make_count(counter, &(line[i]), &count);
	if ((line[i].value == -1) && (line[i].link.x == -1))
	    count.empty = i;
    }
    fill_remain(max, line, count);
}
Ejemplo n.º 14
0
std::vector<topic> generate_weapon_special_topics(const bool sort_generated)
{
	std::vector<topic> topics;

	std::map<t_string, std::string> special_description;
	std::map<t_string, std::set<std::string, string_less> > special_units;

	BOOST_FOREACH(const unit_type_data::unit_type_map::value_type &i, unit_types.types())
	{
		const unit_type &type = i.second;
		// Only show the weapon special if we find it on a unit that
		// detailed description should be shown about.
		if (description_type(type) != FULL_DESCRIPTION)
		 	continue;

		std::vector<attack_type> attacks = type.attacks();
		for (std::vector<attack_type>::const_iterator it = attacks.begin();
					it != attacks.end(); ++it) {

			std::vector<std::pair<t_string, t_string> > specials = it->special_tooltips();
			for ( size_t i = 0; i != specials.size(); ++i )
			{
				special_description.insert(std::make_pair(specials[i].first, specials[i].second));

				if (!type.hide_help()) {
					//add a link in the list of units having this special
					std::string type_name = type.type_name();
					//check for variations (walking corpse/soulless etc)
					const std::string section_prefix = type.show_variations_in_help() ? ".." : "";
					std::string ref_id = section_prefix + unit_prefix + type.id();
					//we put the translated name at the beginning of the hyperlink,
					//so the automatic alphabetic sorting of std::set can use it
					std::string link = make_link(type_name, ref_id);
					special_units[specials[i].first].insert(link);
				}
			}
		}
	}

	for (std::map<t_string, std::string>::iterator s = special_description.begin();
			s != special_description.end(); ++s) {
		// use untranslated name to have universal topic id
		std::string id = "weaponspecial_" + s->first.base_str();
		std::stringstream text;
		text << s->second;
		text << "\n\n" << _("<header>text='Units having this special attack'</header>") << "\n";
		std::set<std::string, string_less> &units = special_units[s->first];
		for (std::set<std::string, string_less>::iterator u = units.begin(); u != units.end(); ++u) {
			text << (*u) << "\n";
		}

		topics.push_back( topic(s->first, id, text.str()) );
	}

	if (sort_generated)
		std::sort(topics.begin(), topics.end(), title_less());
	return topics;
}
Ejemplo n.º 15
0
void add_invite(aClient *cptr, aChannel *chptr)
{
	Link *inv, *tmp;

	del_invite(cptr, chptr);
	/*
	 * delete last link in chain if the list is max length
	 */
	if (list_length(cptr->user->invited) >= MAXCHANNELSPERUSER)
	{
/*		This forgets the channel side of invitation     -Vesa
		inv = cptr->user->invited;
		cptr->user->invited = inv->next;
		free_link(inv);
*/
		for (tmp = cptr->user->invited; tmp->next; tmp = tmp->next)
			;
		del_invite(cptr, tmp->value.chptr);

	}
	/* We get pissy over too many invites per channel as well now,
	 * since otherwise mass-inviters could take up some major
	 * resources -Donwulff
	 */
	if (list_length(chptr->invites) >= MAXCHANNELSPERUSER)
	{
		for (tmp = chptr->invites; tmp->next; tmp = tmp->next)
			;
		del_invite(tmp->value.cptr, chptr);
	}
	/*
	 * add client to the beginning of the channel invite list
	 */
	inv = make_link();
	inv->value.cptr = cptr;
	inv->next = chptr->invites;
	chptr->invites = inv;
	/*
	 * add channel to the beginning of the client invite list
	 */
	inv = make_link();
	inv->value.chptr = chptr;
	inv->next = cptr->user->invited;
	cptr->user->invited = inv;
}
Ejemplo n.º 16
0
void add_invite(aClient *from, aClient *to, aChannel *chptr)
{
	Link *inv, *tmp;

	del_invite(to, chptr);
	/*
	 * delete last link in chain if the list is max length
	 */
	if (list_length(to->user->invited) >= MAXCHANNELSPERUSER)
	{
		for (tmp = to->user->invited; tmp->next; tmp = tmp->next)
			;
		del_invite(to, tmp->value.chptr);

	}
	/* We get pissy over too many invites per channel as well now,
	 * since otherwise mass-inviters could take up some major
	 * resources -Donwulff
	 */
	if (list_length(chptr->invites) >= MAXCHANNELSPERUSER)
	{
		for (tmp = chptr->invites; tmp->next; tmp = tmp->next)
			;
		del_invite(tmp->value.cptr, chptr);
	}
	/*
	 * add client to the beginning of the channel invite list
	 */
	inv = make_link();
	inv->value.cptr = to;
	inv->next = chptr->invites;
	chptr->invites = inv;
	/*
	 * add channel to the beginning of the client invite list
	 */
	inv = make_link();
	inv->value.chptr = chptr;
	inv->next = to->user->invited;
	to->user->invited = inv;

	RunHook3(HOOKTYPE_INVITE, from, to, chptr);
}
Ejemplo n.º 17
0
/* sort_tree_by_deviate()
 *
 */
static void
sort_tree_by_deviate(struct tree_ *t)
{
    struct tree_node_ *n;
    struct tree_node_ *n2;
    struct tree_node_ *root;
    link_t *stack;
    struct share_acct *s;
    uint64_t sum;
    uint64_t avail;

    stack = make_link();
    root = t->root;
    n = root->child;

znovu:
    n2 = n;
    sum = 0;
    while (n) {

        if (n->child)
            enqueue_link(stack, n);

        s = n->data;
        s->dsrv2 = 0;
        /* sum up the historical.
         */
        sum = sum + s->numRAN;
        n = n->right;
    }

    avail = sum;
    n = n2;
    while (n) {

        avail = avail - compute_deviate(n, sum, avail);
        assert(avail >= 0);
        n = n->right;
    }

    sort_siblings(root, node_cmp2);

    n = pop_link(stack);
    if (n) {
        root = n;
        n = n->child;
        goto znovu;
    }

    fin_link(stack);
    make_leafs(t);
}
Ejemplo n.º 18
0
/*
 * addlink is called from the rule functions when they want a
 * compatibility link made.  At this point we only know the
 * link name, the /devices entry, and the prefix of a 5.x /dev
 * name (that points to the /devices entry) that the rule would
 * prefer the compatibility link point to.  If a symlink already
 * exists with the required prefix that points to the /devices
 * entry, make the compatibility link point to that link.
 * If a link with the required prefix doesn't exist, make the
 * link point directly to the /devices entry.  The idea is that
 * someone looking at a compatibility link will be reminded of
 * the "real" 5.x /dev name.  For example, ls -l will show sd0a ->
 * dsk/c0t3d0s0.
 *
 * If the symlink we're creating isn't already in the hash
 * table we add it for possible future use by make_link.
 * If multiple /devices entries exist with the same major
 * and minor numbers this prevents problems with trying to
 * make the link twice.  Generally, though, there shouldn't
 * be multiple /devices entries of the same type, major, and
 * minor, except for tape devices.  The tape rules pass 1 for
 * the unique argument (all others pass 0) so we keep track
 * and only create the first link for a particular compatibility
 * name.
 */
static void
addlink(char *compat_link, char *prefix, struct devices_ent *dep, int unique)
{
	int len, link_type = 0;
	struct symlink *devent_slp;
	struct symlink *compat_slp;
	char *target = NULL;
	char linkbuf[MAXPATHLEN + 1];

	compat_slp = lookup_link_sym(compat_link);
	if (compat_slp == NULL) {
		compat_slp = xmalloc(sizeof (struct symlink));
		compat_slp->linkname = xstrdup(compat_link);
		compat_slp->target = NULL;
		compat_slp->already = 0;
		insert_link_sym(compat_slp);
	}

	if (unique) {
		if (compat_slp->already)
			return;
		else
			compat_slp->already = 1;
	}

	/*
	 * Look for a name with the correct prefix.
	 */
	len = strlen(prefix);
	devent_slp = dep->linksto;
	while (devent_slp != NULL) {
		if (strncmp(prefix, devent_slp->linkname, len) == 0) {
			target = devent_slp->linkname;
			link_type = DI_SECONDARY_LINK;
			break;
		}
		devent_slp = devent_slp->deventnext;
	}

	/*
	 * If we didn't find one with the prefix, point directly
	 * to the /devices entry.
	 */
	if (target == NULL) {
		link_type = DI_PRIMARY_LINK;
		(void) sprintf(linkbuf, "../devices/%s", dep->devicename);
		target = xstrdup(linkbuf);
	}
	make_link(compat_link, target, compat_slp, link_type);
}
Ejemplo n.º 19
0
void patcher_dynamic::update ()
{
    if (!m_changed)
        return;

    for (map<int, pnode>::iterator i = m_nodes.begin();
            i != m_nodes.end();
            ++i)
        (*i).second.out_used = false;

    for (auto i = m_links.begin();
            i != m_links.end();
            ++i)
    {
        map<int, pnode>::iterator n = m_nodes.find((*i)->src->get_id());
        map<int, pnode>::iterator n2 = m_nodes.find((*i)->dest->get_id());
        if (n == m_nodes.end()) {
            logger::self () ("dynamic_patcher", log::warning, "Object not found.");
        }

        pnode& node_src = (*n).second;
        pnode& node_dest = (*n2).second;
        link& link = **i;

        //cout << "trying, src: " << link.src->getID() << " dest: " << link.dest->getID() << " out: " << node_src.out_used << endl;

        if (!node_src.out_used &&
                !(node_dest.out_used == true && node_dest.dest == link.src))
        {
            if (!is_linked (link)) {
                find_in_sock (link);
                if (link.actual_in_sock >= 0) {
                    make_link (link);
                    node_src.out_used = true;
                    node_src.dest = link.dest;
                }
            } else {
                node_src.out_used = true;
            }
        } else {
            undo_link (link);
            link.actual_in_sock = -1;
        }
    }

    //cout << "---" << endl;

    m_changed = false;
}
Ejemplo n.º 20
0
int add_mark(struct Client* sptr, const char* mark)
{
  struct SLink *lp;

  if (!find_mark(sptr, mark)) {
    lp = make_link();
    memset(lp, 0, sizeof(struct SLink));
    lp->next = cli_marks(sptr);
    lp->value.cp = (char*) MyMalloc(strlen(mark) + 1);
    assert(0 != lp->value.cp);
    strcpy(lp->value.cp, mark);
    cli_marks(sptr) = lp;
  }
  return 0;
}
Ejemplo n.º 21
0
 bool FileRecord::AddLock(const std::string& lock_id, const std::list<std::string>& ids, const std::string& owner) {
   if(!valid_) return false;
   Glib::Mutex::Lock lock(lock_);
   Dbt key;
   Dbt data;
   for(std::list<std::string>::const_iterator id = ids.begin(); id != ids.end(); ++id) {
     make_link(lock_id,*id,owner,data);
     void* pdata = data.get_data();
     if(!dberr("addlock:put",db_link_->put(NULL,&key,&data,DB_APPEND))) {
       ::free(pdata);
       return false;
     };
     ::free(pdata);
   };
   db_link_->sync(0);
   return true;
 }
void BtAboutDialog::init_sword_tab()
{
	selectTab(2);
	setTabText("Sword" );

	QString version( sword::SWVersion::currentVersion.getText());
	QString content = make_br() + make_br();
	content += make_center(make_bold("Sword Version " + version));
	content += make_br();

	content += "BibleTime makes use of the SWORD Project. The SWORD Project is the CrossWire Bible Society's free Bible software project. Its purpose is to create cross-platform open-source tools-- covered by the GNU General Public License-- that allow programmers and Bible societies to write new Bible software more quickly and easily.";
	content += make_br() + make_br();
	content += "The SWORD Project" + make_br();
	content += make_link("http://www.crosswire.org/sword/index.jsp","www.crosswire.org/sword/index.jsp");

	setHtml(content);

}
Ejemplo n.º 23
0
int main(int argc, char *argv[])
{
    struct GModule *module;
    struct _options options;
    struct _flags   flags;

    G_gisinit(argv[0]);

    module = G_define_module();
    G_add_keyword(_("vector"));
    G_add_keyword(_("export"));
    G_add_keyword(_("output"));
    G_add_keyword(_("external"));
    module->description =
	_("Defines vector output format utilizing OGR library.");

    OGRRegisterAll();

    parse_args(argc, argv, &options, &flags);

    if (flags.f->answer) {
	list_formats();
	exit(EXIT_SUCCESS);
    }

    if (flags.r->answer) {
	G_remove("", "OGR");
	exit(EXIT_SUCCESS);
    }

    if (options.format->answer)
	check_format(options.format->answer);

    if (options.dsn->answer)
	make_link(options.dsn->answer,
		  options.format->answer, options.opts->answers);
    
    if (flags.p->answer || flags.g->answer) {
	print_status(flags.g->answer ? 1 : 0);
    }

    exit(EXIT_SUCCESS);
}
Ejemplo n.º 24
0
/** Associate a specific configuration entry to a *local* client (this
 * is the one which used in accepting the connection). Note, that this
 * automatically changes the attachment if there was an old one...
 * @param cptr Client to attach \a aconf to
 * @param aconf ConfItem to attach
 * @return Authorization check result.
 */
enum AuthorizationCheckResult attach_conf(struct Client *cptr, struct ConfItem *aconf)
{
  struct SLink *lp;

  if (is_attached(aconf, cptr))
    return ACR_ALREADY_AUTHORIZED;
  if (IsIllegal(aconf))
    return ACR_NO_AUTHORIZATION;
  if ((aconf->status & (CONF_OPERATOR | CONF_CLIENT)) &&
      ConfLinks(aconf) >= ConfMaxLinks(aconf) && ConfMaxLinks(aconf) > 0)
    return ACR_TOO_MANY_IN_CLASS;  /* Use this for printing error message */
  lp = make_link();
  lp->next = cli_confs(cptr);
  lp->value.aconf = aconf;
  cli_confs(cptr) = lp;
  ++aconf->clients;
  if (aconf->status & CONF_CLIENT_MASK)
    ConfLinks(aconf)++;
  return ACR_OK;
}
void BtAboutDialog::init_bt_tab()
{
	selectTab(0);
	setTabText("BibleTime" );
	QString content;
	content = make_file_icon("bibletime");
	content += "&nbsp;&nbsp;";
	content += make_bold("BibleTime " + make_version());
	content = make_center(content) + make_br();
	content += tr("BibleTime is an easy to use but powerful Bible study tool.");
	content += make_br() + make_br();
	content += tr("We are looking for developers and translators.");
	content += tr("If you would like to join our team, please send an email to [email protected].");
	content += make_br() + make_br();
	content += tr("(c)1999-2009, The BibleTime Team");
	content += make_br();
	content += make_link("http://www.bibletime.info","http://www.bibletime.info");
	QString bibletime = make_html(make_head("") + make_body(content));
	setHtml(bibletime);
}
void BtAboutDialog::init_qt_tab()
{
	selectTab(3);
	setTabText("Qt");
	QString content;
	content += make_br() + make_br();
	content += make_center(make_bold("Qt"));
	content += make_br();
	content += tr("This program uses Qt Open Source Edition version ");
	content += qVersion();
	content += make_br() + make_br();
	content += tr("Qt Open Source Edition is intended for the development of Open Source applications.");
	content += tr("Qt is a C++ toolkit for cross-platform application development.");
	content += make_br() + make_br();
	content += tr("Please see ");
	content += make_link("http://qtsoftware.com/company/model/","qtsoftware.com/company/model");
	content += tr(" for an overview of Qt licensing.");
	QString qt = make_html(make_head("") + make_body(content));
	setHtml(qt);
}
Ejemplo n.º 27
0
static int restore_link(struct asfd *asfd, struct sbuf *sb, const char *fname,
                        const char *restoreprefix, enum action act, struct conf *conf)
{
    int ret=0;

    if(act==ACTION_RESTORE)
    {
        char *rpath=NULL;
        if(build_path(fname, "", &rpath, NULL))
        {
            char msg[256]="";
            // failed - do a warning
            snprintf(msg, sizeof(msg), "build path failed: %s",
                     fname);
            if(restore_interrupt(asfd, sb, msg, conf))
                ret=-1;
            goto end;
        }
        else if(make_link(asfd, fname, sb->link.buf, sb->link.cmd,
                          restoreprefix, conf))
        {
            // failed - do a warning
            if(restore_interrupt(asfd, sb,
                                 "could not create link", conf))
                ret=-1;
            goto end;
        }
        else if(!ret)
        {
            attribs_set(asfd, fname, &(sb->statp), sb->winattr, conf);
            cntr_add(conf->cntr, sb->path.cmd, 1);
        }
        if(rpath) free(rpath);
    }
    else cntr_add(conf->cntr, sb->path.cmd, 1);
end:
    return ret;
}
Ejemplo n.º 28
0
/* sort_tree_by_deviate()
 *
 */
static void
sort_tree_by_deviate(struct tree_ *t)
{
    struct tree_node_ *n;
    struct tree_node_ *n2;
    struct tree_node_ *root;
    link_t *stack;
    struct share_acct *s;
    uint64_t sum;
    uint64_t avail;

    stack = make_link();
    root = t->root;
    n = root->child;

znovu:
    n2 = n;
    sum = 0;
    while (n) {

        if (n->child)
            enqueue_link(stack, n);

        s = n->data;
        s->dsrv2 = 0;
        /* sum up the historical.
         */
        sum = sum + s->numRAN;

        if (logclass & LC_FAIR) {
            ls_syslog(LOG_INFO, "\
%s: updating %s pend %d run %d ran %d", __func__,
                      s->name, s->numPEND, s->numRAN, s->numRUN);
        }

        n = n->right;
    }
static u32 build_default_directory_structure()
{
	u32 inode;
	u32 root_inode;
	struct dentry dentries = {
			.filename = "lost+found",
			.file_type = EXT4_FT_DIR,
			.mode = S_IRWXU,
			.uid = 0,
			.gid = 0,
			.mtime = 0,
	};
	root_inode = make_directory(0, 1, &dentries, 1);
	inode = make_directory(root_inode, 0, NULL, 0);
	*dentries.inode = inode;
	inode_set_permissions(inode, dentries.mode,
		dentries.uid, dentries.gid, dentries.mtime);

	return root_inode;
}

#ifndef USE_MINGW
/* Read a local directory and create the same tree in the generated filesystem.
   Calls itself recursively with each directory in the given directory */
static u32 build_directory_structure(const char *full_path, const char *dir_path,
		u32 dir_inode, fs_config_func_t fs_config_func,
		struct selabel_handle *sehnd)
{
	int entries = 0;
	struct dentry *dentries;
	struct dirent **namelist = NULL;
	struct stat stat;
	int ret;
	int i;
	u32 inode;
	u32 entry_inode;
	u32 dirs = 0;
	bool needs_lost_and_found = false;

	if (full_path) {
		entries = scandir(full_path, &namelist, filter_dot, (void*)alphasort);
		if (entries < 0) {
			error_errno("scandir");
			return EXT4_ALLOCATE_FAILED;
		}
	}

	if (dir_inode == 0) {
		/* root directory, check if lost+found already exists */
		for (i = 0; i < entries; i++)
			if (strcmp(namelist[i]->d_name, "lost+found") == 0)
				break;
		if (i == entries)
			needs_lost_and_found = true;
	}

	dentries = calloc(entries, sizeof(struct dentry));
	if (dentries == NULL)
		critical_error_errno("malloc");

	for (i = 0; i < entries; i++) {
		dentries[i].filename = strdup(namelist[i]->d_name);
		if (dentries[i].filename == NULL)
			critical_error_errno("strdup");

		asprintf(&dentries[i].path, "%s/%s", dir_path, namelist[i]->d_name);
		asprintf(&dentries[i].full_path, "%s/%s", full_path, namelist[i]->d_name);

		free(namelist[i]);

		ret = lstat(dentries[i].full_path, &stat);
		if (ret < 0) {
			error_errno("lstat");
			i--;
			entries--;
			continue;
		}

		dentries[i].size = stat.st_size;
		dentries[i].mode = stat.st_mode & (S_ISUID|S_ISGID|S_ISVTX|S_IRWXU|S_IRWXG|S_IRWXO);
		dentries[i].mtime = stat.st_mtime;
		if (fs_config_func != NULL) {
#ifdef ANDROID
			unsigned int mode = 0;
			unsigned int uid = 0;
			unsigned int gid = 0;
			int dir = S_ISDIR(stat.st_mode);
			fs_config_func(dentries[i].path, dir, &uid, &gid, &mode);
			dentries[i].mode = mode;
			dentries[i].uid = uid;
			dentries[i].gid = gid;
#else
			error("can't set android permissions - built without android support");
#endif
		}
#ifdef HAVE_SELINUX
		if (sehnd) {
			char *sepath = NULL;
			asprintf(&sepath, "/%s", dentries[i].path);
			if (selabel_lookup(sehnd, &dentries[i].secon, sepath, stat.st_mode) < 0) {
				error("cannot lookup security context for %s", sepath);
			}
			if (dentries[i].secon)
				printf("Labeling %s as %s\n", sepath, dentries[i].secon);
			free(sepath);
		}
#endif

		if (S_ISREG(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_REG_FILE;
		} else if (S_ISDIR(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_DIR;
			dirs++;
		} else if (S_ISCHR(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_CHRDEV;
		} else if (S_ISBLK(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_BLKDEV;
		} else if (S_ISFIFO(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_FIFO;
		} else if (S_ISSOCK(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_SOCK;
		} else if (S_ISLNK(stat.st_mode)) {
			dentries[i].file_type = EXT4_FT_SYMLINK;
			dentries[i].link = calloc(info.block_size, 1);
			readlink(dentries[i].full_path, dentries[i].link, info.block_size - 1);
		} else {
			error("unknown file type on %s", dentries[i].path);
			i--;
			entries--;
		}
	}
	free(namelist);

	if (needs_lost_and_found) {
		/* insert a lost+found directory at the beginning of the dentries */
		struct dentry *tmp = calloc(entries + 1, sizeof(struct dentry));
		memset(tmp, 0, sizeof(struct dentry));
		memcpy(tmp + 1, dentries, entries * sizeof(struct dentry));
		dentries = tmp;

		dentries[0].filename = strdup("lost+found");
		asprintf(&dentries[0].path, "%s/lost+found", dir_path);
		dentries[0].full_path = NULL;
		dentries[0].size = 0;
		dentries[0].mode = S_IRWXU;
		dentries[0].file_type = EXT4_FT_DIR;
		dentries[0].uid = 0;
		dentries[0].gid = 0;
#ifdef HAVE_SELINUX
		if (sehnd) {
			char *sepath = NULL;
			asprintf(&sepath, "/%s", dentries[0].path);
			if (selabel_lookup(sehnd, &dentries[0].secon, sepath, dentries[0].mode) < 0)
				error("cannot lookup security context for %s", dentries[0].path);
			free(sepath);
		}
#endif
		entries++;
		dirs++;
	}

	inode = make_directory(dir_inode, entries, dentries, dirs);

	for (i = 0; i < entries; i++) {
		if (dentries[i].file_type == EXT4_FT_REG_FILE) {
			entry_inode = make_file(dentries[i].full_path, dentries[i].size);
		} else if (dentries[i].file_type == EXT4_FT_DIR) {
			entry_inode = build_directory_structure(dentries[i].full_path,
					dentries[i].path, inode, fs_config_func, sehnd);
		} else if (dentries[i].file_type == EXT4_FT_SYMLINK) {
			entry_inode = make_link(dentries[i].full_path, dentries[i].link);
		} else {
			error("unknown file type on %s", dentries[i].path);
			entry_inode = 0;
		}
		*dentries[i].inode = entry_inode;

		ret = inode_set_permissions(entry_inode, dentries[i].mode,
			dentries[i].uid, dentries[i].gid,
			dentries[i].mtime);
		if (ret)
			error("failed to set permissions on %s\n", dentries[i].path);
		ret = inode_set_selinux(entry_inode, dentries[i].secon);
		if (ret)
			error("failed to set SELinux context on %s\n", dentries[i].path);

		free(dentries[i].path);
		free(dentries[i].full_path);
		free(dentries[i].link);
		free((void *)dentries[i].filename);
		free(dentries[i].secon);
	}

	free(dentries);
	return inode;
}
Ejemplo n.º 30
0
static inline cmark_node* make_autolink(cmark_node* label, cmark_chunk url, int is_email)
{
	return make_link(label, cmark_clean_autolink(&url, is_email), NULL);
}