示例#1
0
文件: mode.c 项目: DonCN/haiku
void    
currentModeInfo(uiContext d)
{
  coreContext cc = (coreContext)d->modec;

  if (d->current_mode->flags & CANNA_KANJIMODE_EMPTY_MODE) {
    d->kanji_status_return->info |= KanjiEmptyInfo;
  }

  if (howToReturnModeInfo == ModeInfoStyleIsString) {
    WCHAR_T *modename, *gmodename;
    if (cc->minorMode != d->minorMode) {
      modename = modestr(cc->minorMode);
      gmodename = modestr(d->minorMode);
      d->majorMode = cc->majorMode;
      d->minorMode = cc->minorMode;
      if (modename && (gmodename == (WCHAR_T *)NULL ||
		       WStrcmp(modename, gmodename))) {
	d->kanji_status_return->mode = modename;
	d->kanji_status_return->info |= KanjiModeInfo;
      }
    }
  }
  else {
    if (cc->majorMode != d->majorMode) {
      d->majorMode = cc->majorMode;
      d->minorMode = cc->minorMode;
      numMode[0] = (WCHAR_T)('@' + cc->majorMode);
      numMode[1] = (WCHAR_T) 0;
      d->kanji_status_return->info |= KanjiModeInfo;
      d->kanji_status_return->mode = numMode;
    }
  }
}
示例#2
0
void
SetModes(char *source, int plus, char mode, struct Channel *chptr, char *args)

{
  int acnt, mcnt, ii;
  char done[MAXLINE], sendstr[MAXLINE];
  char **av, *temp, *mtmp;

  if (!source || !chptr || !args)
    return;

  temp = MyStrdup(args);
  acnt = SplitBuf(temp, &av);
  memset(&done, 0, MAXLINE);
  mcnt = 1;
  for (ii = 0; ii < acnt; ii++)
  {
    strcat(done, av[ii]);
    /* Rewrote this to fix that nasty " " at the end of done[] -kre */
    if (mcnt != MaxModes)
      strcat(done, " ");
    else
    {
      mcnt = 0;
      mtmp = modestr(MaxModes, mode);
      ircsprintf(sendstr, "%s%s %s",
        plus ? "+" : "-", mtmp, done);
      toserv(":%s MODE %s %s\n",
        source,
        chptr->name,
        sendstr);
      UpdateChanModes(0, source, chptr, sendstr);
      MyFree(mtmp);
      memset(&done, 0, MAXLINE);
    }
    mcnt++;
  }

  if (done[0] != '\0')
  {
    mtmp = modestr(mcnt - 1, mode);
    ircsprintf(sendstr, "%s%s %s",
      plus ? "+" : "-",
      mtmp,
      done);
    toserv(":%s MODE %s %s\n",
      source,
      chptr->name,
      sendstr);
    UpdateChanModes(0, source, chptr, sendstr);
    MyFree(mtmp);
  }
  MyFree(temp);
  MyFree(av);
} /* SetModes() */
示例#3
0
static afs_uint32
file_cb(afs_vnode * v, XFILE * X, void *refcon)
{
    char *vnodepath, vnpx[30];
    dt_uint64 where;
    XFILE OX;
    int r, use = 0;

    if (!dirs_done) {
	dirs_done = 1;
	if (verbose)
	    printf("* Extracting files...\n");
    }

    /* Should we even use this? */
    if (!use_vnum) {
	if ((r = Path_Build(X, &phi, v->vnode, &vnodepath, !use_realpath)))
	    return r;
	if (!(use = usevnode(X, v->vnode, vnodepath))) {
	    free(vnodepath);
	    return 0;
	}
	if (use == 2) {
	    free(vnodepath);
	    sprintf(vnpx, "#%d:%d", v->vnode, v->vuniq);
	    vnodepath = vnpx;
	}
    } else {
	sprintf(vnpx, "#%d:%d", v->vnode, v->vuniq);
	vnodepath = vnpx;
    }

    /* Print it out */
    if (verbose) {
	printf("-%s %3d %-11d %11d %s %s\n", modestr(v->mode), v->nlinks,
	       v->owner, v->size, datestr(v->server_date), vnodepath);
    } else if (!quiet) {
	printf("%s\n", vnodepath);
    }

    if (!nomode) {
	if ((r = xftell(X, &where))
	    || (r = xfseek(X, &v->d_offset))
	    || (r =
		xfopen_path(&OX, O_RDWR | O_CREAT | O_TRUNC, vnodepath + 1,
			    0644))) {
	    if (vnodepath != vnpx)
		free(vnodepath);
	    return r;
	}
	r = copyfile(X, &OX, v->size);
	xfclose(&OX);
	xfseek(X, &where);
    } else
	r = 0;

    if (vnodepath != vnpx)
	free(vnodepath);
    return r;
}
示例#4
0
文件: server.cpp 项目: mailgyc/cube
bool vote(char *map, int reqmode, int sender) {
	strcpy_s(clients[sender].mapvote, map);
	clients[sender].modevote = reqmode;
	int yes = 0, no = 0;
	loopv(clients)
		if (clients[i].type != ST_EMPTY) {
			if (clients[i].mapvote[0]) {
				if (strcmp(clients[i].mapvote, map) == 0
						&& clients[i].modevote == reqmode)
					yes++;
				else
					no++;
			} else
				no++;
		};
	if (yes == 1 && no == 0)
		return true;  // single player

	IString msg;
	std::sprintf(msg, "%s suggests %s on map %s (set map to vote)",
			clients[sender].name, modestr(reqmode), map);
	sendservmsg(msg);
	if (yes / (float) (yes + no) <= 0.5f)
		return false;
	sendservmsg("vote passed");
	resetvotes();
	return true;
}
示例#5
0
static afs_uint32
directory_cb(afs_vnode * v, XFILE * X, void *refcon)
{
    char *vnodepath;
    int r, use = 0;

    /* Should we even use this? */
    if (!use_vnum) {
	if ((r = Path_Build(X, &phi, v->vnode, &vnodepath, !use_realpath)))
	    return r;
	if (!(use = usevnode(X, v->vnode, vnodepath))) {
	    free(vnodepath);
	    return 0;
	}
    }

    /* Print it out */
    if (verbose) {
	if (use_vnum)
	    printf("d%s %3d %-11d %11d %s #%d:%d\n", modestr(v->mode),
		   v->nlinks, v->owner, v->size, datestr(v->server_date),
		   v->vnode, v->vuniq);
	else
	    printf("d%s %3d %-11d %11d %s %s\n", modestr(v->mode), v->nlinks,
		   v->owner, v->size, datestr(v->server_date), vnodepath);
    } else if (!quiet && !use_vnum)
	printf("%s\n", vnodepath);

    /* Make the directory, if needed */
    if (!nomode && !use_vnum && use != 2) {
	if (strcmp(vnodepath, "/")
	    && (r = mkdirp(vnodepath + 1))) {
	    free(vnodepath);
	    return r;
	}
	if (do_acls) {
	    /* XXX do ACL's later */
	}
    }
    if (!use_vnum)
	free(vnodepath);
    return 0;
}
示例#6
0
文件: wmiir.c 项目: bartman/wmii
static void
print_stat(Stat *s, int lflag, char *file, int pflag) {
	char *slash;

	slash = "";
	if(pflag)
		slash = "/";
	else
		file = "";

	if(lflag)
		print("%s %s %s %5llud %s %s%s%s\n",
				modestr(s->mode), s->uid, s->gid, s->length,
				timestr(s->mtime), file, slash, s->name);
	else {
		if((s->mode&P9_DMDIR) && strcmp(s->name, "/"))
			print("%s%s%s/\n", file, slash, s->name);
		else
			print("%s%s%s\n", file, slash, s->name);
	}
}
示例#7
0
static afs_uint32
symlink_cb(afs_vnode * v, XFILE * X, void *refcon)
{
    char *vnodepath, *linktarget, vnpx[30];
    dt_uint64 where;
    int r, use = 0;

    if (!dirs_done) {
	dirs_done = 1;
	if (verbose)
	    printf("* Extracting files...\n");
    }

    /* Should we even use this? */
    if (!use_vnum) {
	if ((r = Path_Build(X, &phi, v->vnode, &vnodepath, !use_realpath)))
	    return r;
	if (!(use = usevnode(X, v->vnode, vnodepath))) {
	    free(vnodepath);
	    return 0;
	}
	if (use == 2) {
	    free(vnodepath);
	    sprintf(vnpx, "#%d:%d", v->vnode, v->vuniq);
	    vnodepath = vnpx;
	}
    } else {
	sprintf(vnpx, "#%d:%d", v->vnode, v->vuniq);
	vnodepath = vnpx;
    }

    if (!(linktarget = malloc(v->size + 1))) {
	if (vnodepath != vnpx)
	    free(vnodepath);
	return DSERR_MEM;
    }
    if ((r = xftell(X, &where))
	|| (r = xfseek(X, &v->d_offset))
	|| (r = xfread(X, linktarget, v->size))) {
	if (vnodepath != vnpx)
	    free(vnodepath);
	free(linktarget);
	return r;
    }
    xfseek(X, &where);
    linktarget[v->size] = 0;

    /* Print it out */
    if (verbose)
	printf("l%s %3d %-11d %11d %s %s -> %s\n", modestr(v->mode),
	       v->nlinks, v->owner, v->size, datestr(v->server_date),
	       vnodepath, linktarget);
    else if (!quiet)
	printf("%s\n", vnodepath);

    r = 0;
    if (!nomode) {
	if (symlink(linktarget, vnodepath + 1))
	    r = errno;
    }

    free(linktarget);
    if (vnodepath != vnpx)
	free(vnodepath);
    return r;
}