int
main ()
{
  long i;

  for (i = 100; i < 200000; i++)
    if (checkp (i))
      goto found;

  printf ("No Solution found\n");
  exit (0);
found:
  printf ("Solution is %ld\n", i);
  exit (0);
}
Exemple #2
0
bool nid_parse(const xptr nid, xptr * prefix, shft * size) {
    CHECKP(nid);

    const t_nid * tnid = (t_nid *) XADDR(nid);
    const unsigned char sz = tnid->size;

    if (sz == 0) {
        *size = *(shft*) ((tnid->prefix) + sizeof(xptr));
        *prefix = pstrderef(checkp(*(xptr*) (tnid->prefix)));
        return true;
    } else {
        *prefix = nid;
        *size = sz;
        return false;
    }
}
Exemple #3
0
xptr copy_node_content(xptr new_node_i, xptr node, xptr left_node_i, upd_ns_map** nsupdmap, bool save_types, unsigned short depth) {
    xptr left_node = XNULL;
    xptr childi = getIndirectionSafeCP(getFirstChild(checkp(node)));

    while (childi != XNULL) {
        left_node = deep_copy_node_i(left_node_i, XNULL, new_node_i, indirectionDereferenceCP(childi), nsupdmap, save_types, depth + 1);

        /* due to : MG: deep_temp_copy can return XNULL if a trigger canceled
        * the insertion and there were now any left sibling */
        if (left_node != XNULL) {
            left_node_i = getIndirectionSafeCP(left_node);
        }

        childi = nodeiGetRightSiblingIndirection(childi);
    }

    return left_node_i;
}
Exemple #4
0
static void _pascal parsemail(char *keyword, char *value)

{
	char *s = value;
	char *e = NULL;
	AREA *t;
	AREA a;

	check(username);
	memset(&a,0,sizeof a);

	switch (tolower(*keyword)) { /* one letter is enough for now */
		default  :
		case 'f' : a.msgtype = FIDO; break;
		case 'q' : a.msgtype = QUICK; break;
	}

	while (*s && isspace(*s)) s++;
	if (!*s) return;

	switch (tolower(*s)) { /* one letter is enough */
		case 'n' : a.news = 1; break;
		case 'u' : a.uucp = 1; break;
		case 'm' : a.netmail = 1; break;
		case 'e' : a.echomail = 1; break;
		case 'l' :
		default  : a.local = 1; break;
	}

	while (*s && !isspace(*s)) s++;  /* skip the rest */
	while (*s && isspace(*s)) s++;
	if (!*s) return;

	if (*s != '\"') {
		while (*s && !isspace(*s)) {
			switch (tolower(*s)) {
				case 'p' : a.priv = 1; break;
				case 'h' : a.hold = 1; break;
				case 'd' : a.direct = 1; break;
				case 'c' : a.crash = 1; break;
				case 'k' : a.killsent = 1; break;
				case  0  : return;
			}
			s++;
		}
		while (*s && isspace(*s)) s++;
		if (!*s) return;
	}

	if ((e = strchr(++s,'\"')) == NULL) return;
	*e++ = '\0';
	a.description = strdup(s);
	s = e;

	while (*s && isspace(*s)) s++;
	if (!*s) {
		free(a.description);
		return;
	}

	if ((e = strchr(s,' ')) == NULL)
		e = strchr(s,'\t');

	if (e == NULL)
		e = s;
	else
		*e++ = '\0';

	while (*s && isspace(*s)) s++;
	if (!*s) {
		free(a.description);
		return;
	}

	switch (a.msgtype) {
		default :
		case FIDO  : a.path = strdup(strlwr(s)); break;
		case QUICK : a.board = atoi(s); break;
	}

	if (a.msgtype == FIDO) {
		if (chdir(a.path) != 0) {
			free(a.path);
			free(a.description);
			return;
		}
		else
			setcwd(home);
	}

	if (a.echomail) {
		s = e;
		while (*s && isspace(*s)) s++;
		if (s && *s)
			a.tag = strdup(s);
		else
			a.tag = NULL;
	}

	for (area = 0; area < areas; area++) {
		/* this is a sneaky use of the ternary operator */

		if (((a.msgtype == QUICK) && (arealist[area].msgtype == QUICK))?
			(a.board == arealist[area].board):
			(strcmp(a.path,arealist[area].path)==0)) {
				arealist[area].priv |= a.priv;
				arealist[area].hold |= a.hold;
				arealist[area].direct |= a.direct;
				arealist[area].crash |= a.crash;
				arealist[area].killsent |= a.killsent;
				arealist[area].news |= a.news;
				arealist[area].echomail |= a.echomail;
				arealist[area].uucp |= a.uucp;
				arealist[area].netmail |= a.netmail;
				arealist[area].local |= a.local;

				if (arealist[area].description == NULL)
					arealist[area].description = a.description;
				else if (a.description)
					free(a.description);

				if (arealist[area].tag == NULL)
					arealist[area].tag = a.tag;
				else if (a.tag)
					free(a.tag);

				if ((a.msgtype == FIDO) && (a.path))
					free(a.path);

				return;
		}
	}

	areas++;
	area = areas - 1;

	check(username);

	if (arealist == NULL)
		arealist = handle_malloc(areas * sizeof(struct _area));
	else {
		check(username);
		arealist = handle_realloc(arealist, areas * sizeof(struct _area));
		check(username);
	}

	check(username);

	if (arealist == NULL)
		outamemory();

	check(username);
	checkp(arealist);
	t = arealist + area;
	checkp(t);
	checkp(arealist);
	check(username);
	*t = a;
	checkp(t);
	check(username);
}