Example #1
0
static void setprefix(char *buf, node package){
     if (package == NULL) return;
     setprefix(buf,package->body.symbol.package);
     if (EQUAL!=strcmp("C",tostring(package))) {
          strcat(buf,tostring(package));
     	  strcat(buf,"_");
	  }
     }
Example #2
0
char *prefixify(node package, char *name){
     char buf[500];
     if (package==NULL) return name;
     assertpos(issym(package),package);
     assertpos(isstr(package->body.symbol.name),package);
     assertpos(tostring(package) != NULL, package->body.symbol.name);
     buf[0]=0;
     setprefix(buf,package);
     strcat(buf,name);
     return strperm(buf);
     }
Example #3
0
/* ARGSUSED */
int
prefixregion(int f, int n)
{
	struct line	*first, *last;
	struct region	 region;
	char	*prefix = prefix_string;
	int	 nline;
	int	 s;

	if ((s = checkdirty(curbp)) != TRUE)
		return (s);
	if (curbp->b_flag & BFREADONLY) {
		dobeep();
		ewprintf("Buffer is read-only");
		return (FALSE);
	}
	if ((f == TRUE) && ((s = setprefix(FFRAND, 1)) != TRUE))
		return (s);

	/* get # of lines to affect */
	if ((s = getregion(&region)) != TRUE)
		return (s);
	first = region.r_linep;
	last = (first == curwp->w_dotp) ? curwp->w_markp : curwp->w_dotp;
	for (nline = 1; first != last; nline++)
		first = lforw(first);

	/* move to beginning of region */
	curwp->w_dotp = region.r_linep;
	curwp->w_doto = region.r_offset;
	curwp->w_dotline = region.r_lineno;

	/* for each line, go to beginning and insert the prefix string */
	while (nline--) {
		(void)gotobol(FFRAND, 1);
		for (prefix = prefix_string; *prefix; prefix++)
			(void)linsert(1, *prefix);
		(void)forwline(FFRAND, 1);
	}
	(void)gotobol(FFRAND, 1);
	return (TRUE);
}
Example #4
0
/**
 * code_addr2key - convert the octant address to the locational key
 *
 * - check the level, which is the only source of error
 * - call code_coord2morton to convert from the coordinate
 * - set the last byte of the key properly according to the type of the oct
 *   for index oct, do nothing;
 *   for leaf oct, set the most significant bit of the least significant
 *   byte to 1
 * - return 0 if OK, -1 on error
 *
 */
int code_addr2key(etree_t *ep, etree_addr_t addr, void *key)
{
    /*
       etree_addr_t checkaddr;
    */


    if (addr.level >= theMaxLevelP1)
        return -1;

    /* Use the newer version */
    code_coord2morton(theMaxLevelP1, addr.x, addr.y, addr.z, (char *)key + 1);


    /* for debug */
    /*
    code_morton2coord(theMaxLevelP1, key + 1, &checkaddr.x, &checkaddr.y,
                      &checkaddr.z);
    if ((addr.x != checkaddr.x)  ||
        (addr.y != checkaddr.y) ||
        (addr.z != checkaddr.z)) {
        fprintf(stderr, "New conversion routine not correct.\n");
        exit(-1);
    }
    */


    *(unsigned char *)key = (unsigned char)addr.level;
    if (addr.type == ETREE_LEAF)
        *(unsigned char *)key |= 0x80;

    if (ep->dimensions == 4) {
        /* an ad-hoc solution, subject to future modification */
        setprefix(ep, addr.t, (char *)key + theTimeStepOffset);
    }
    return 0;
}
Example #5
0
int checkconfig(void)
{
   char *p;
   
   if (!(p = config_get("core", "nick")) || !strlen(p)) {
      fprintf(stderr, "Missing core/nick\n");
      return -1;
   }

   if (!(p = config_get("core", "user")) || !strlen(p)) {
      fprintf(stderr, "Missing core/user\n");
      return -1;
   }

   if (!(p = config_get("core", "realname")) || !strlen(p)) {
      fprintf(stderr, "Missing core/realname\n");
      return -1;
   }

   if (!(p = config_get("core", "port")) || !(atoi(p)>0)) {
      fprintf(stderr, "Missing core/port\n");
      return -1;
   }

   if (!config_getcnt("core", "server")) {
      fprintf(stderr, "No core/server given\n");
      return -1;   
   }

   if (!(p = config_get("core", "prefix"))) {
      fprintf(stderr, "No core/prefix given\n");
      return -1;
   } else {
      setprefix(p);
   }
   return 0;
}