Ejemplo n.º 1
0
/*
 * Check for valid cpu_deep_idle option and communicate it to the kernel.
 */
int
cpuidle(void)
{
	struct btoc {
		char *behavior;
		int cmd;
		int Errno;
	};
	static struct btoc blist[] = {
		"disable",	PM_DISABLE_CPU_DEEP_IDLE, EINVAL,
		"enable",	PM_ENABLE_CPU_DEEP_IDLE, EBUSY,
		"default",	PM_DEFAULT_CPU_DEEP_IDLE, EBUSY,
		NULL,		0, 0
	};
	struct btoc *bp;
	char *behavior;

	for (behavior = LINEARG(1), bp = blist; bp->cmd; bp++) {
		if (strcmp(behavior, bp->behavior) == 0)
			break;
	}
	if (bp->cmd == 0) {
		mesg(MERR, "invalid cpu_deep_idle behavior \"%s\"\n", behavior);
		return (NOUP);
	}
	if (ioctl(pm_fd, bp->cmd, NULL) == -1 && errno != bp->Errno) {
		mesg(MERR, "cpu_deep_idle %s failed, %s\n",
		    behavior, strerror(errno));
		return (NOUP);
	}
	return (OKUP);
}
Ejemplo n.º 2
0
/*
 * Convert a numeric string (with a possible trailing scaling byte)
 * into an integer.  Returns a converted value and *nerrp unchanged,
 * or 0 with *nerrp set to 1 for a conversion error.
 */
static int
get_scaled_value(char *str, int *nerrp)
{
	longlong_t svalue = 0, factor = 1;
	char *sp;

	errno = 0;
	svalue = strtol(str, &sp, 0);
	if (errno || (*str != '-' && (*str < '0' || *str > '9')))
		*nerrp = 1;
	else if (sp && *sp != '\0') {
		if (*sp == 'h')
			factor = 3600;
		else if (*sp == 'm')
			factor = 60;
		else if (*sp != 's')
			*nerrp = 1;
	}
	/* any bytes following sp are ignored */

	if (*nerrp == 0) {
		svalue *= factor;
		if (svalue < INT_MIN || svalue > INT_MAX)
			*nerrp = 1;
	}
	if (*nerrp)
		mesg(MERR, nerr_fmt, str);
	mesg(MDEBUG, "got scaled value %d\n", (int)svalue);
	return ((int)svalue);
}
Ejemplo n.º 3
0
/*
 * Set device thresholds from (3) formats:
 * 	path	"always-on"
 * 	path	time-spec: [0-9]+[{h,m,s}]
 *	path	(ts1 ts2 ...)+
 */
int
devthr(void)
{
	int cmd, upval = OKUP, nthresh = 0, *vlist = NULL;
	pm_req_t pmreq;

	bzero(&pmreq, sizeof (pmreq));
	if (devpath(&pmreq.physpath, LINEARG(1), &upval))
		return (upval);

	if (strcmp(LINEARG(2), always_on) == 0) {
		cmd = PM_SET_DEVICE_THRESHOLD;
		pmreq.value = INT_MAX;
	} else if (get_thresh(&vlist, &nthresh)) {
		mesg(MERR, bad_thresh_fmt);
		upval = NOUP;
	} else if (nthresh == 1) {
		pmreq.value = *vlist;
		cmd = PM_SET_DEVICE_THRESHOLD;
	} else {
		pmreq.data = vlist;
		pmreq.datasize = (nthresh * sizeof (*vlist));
		cmd = PM_SET_COMPONENT_THRESHOLDS;
	}

	if (upval != NOUP && (upval = ioctl(pm_fd, cmd, &pmreq)) == -1)
		mesg(MERR, set_thresh_fmt, pmreq.physpath, strerror(errno));

	free(vlist);
	free(pmreq.physpath);
	return (upval);
}
Ejemplo n.º 4
0
/*
 * Convert autoshutdown idle and start/finish times;
 * check and record autoshutdown behavior.
 */
int
autosd(void)
{
	char **bp, *behavior;
	char *unrec = gettext("unrecognized autoshutdown behavior");
	static char *blist[] = {
		"autowakeup", "default", "noshutdown",
		"shutdown", "unconfigured", NULL
	};

	new_cc.as_idle = atoi(LINEARG(1));
	if (gethm(LINEARG(2), &new_cc.as_sh, &new_cc.as_sm) ||
	    gethm(LINEARG(3), &new_cc.as_fh, &new_cc.as_fm))
		return (NOUP);
	mesg(MDEBUG, "idle %d, start %d:%02d, finish %d:%02d\n",
	    new_cc.as_idle, new_cc.as_sh, new_cc.as_sm,
	    new_cc.as_fh, new_cc.as_fm);

	for (behavior = LINEARG(4), bp = blist; *bp; bp++) {
		if (strcmp(behavior, *bp) == 0)
			break;
	}
	if (*bp == NULL) {
		mesg(MERR, "%s: \"%s\"\n", unrec, behavior);
		return (NOUP);
	}
	STRCPYLIM(new_cc.as_behavior, *bp, unrec);
	return (OKUP);
}
Ejemplo n.º 5
0
/*
 * given the path to a zvol, return the cXtYdZ name
 * returns < 0 on error, 0 if it isn't a zvol, > 1 on success
 */
static int
ztop(char *arg, char *diskname)
{
	zpool_handle_t *zpool_handle;
	nvlist_t *config, *nvroot;
	nvlist_t **child;
	uint_t children;
	libzfs_handle_t *lzfs;
	char *vname;
	char *p;
	char pool_name[MAXPATHLEN];

	if (strncmp(arg, "/dev/zvol/dsk/", 14)) {
		return (0);
	}
	arg += 14;
	(void) strncpy(pool_name, arg, MAXPATHLEN);
	if ((p = strchr(pool_name, '/')) != NULL)
		*p = '\0';
	STRCPYLIM(new_cc.cf_fs, p + 1, "statefile path");

	if ((lzfs = libzfs_init()) == NULL) {
		mesg(MERR, "failed to initialize ZFS library\n");
		return (-1);
	}
	if ((zpool_handle = zpool_open(lzfs, pool_name)) == NULL) {
		mesg(MERR, "couldn't open pool '%s'\n", pool_name);
		libzfs_fini(lzfs);
		return (-1);
	}
	config = zpool_get_config(zpool_handle, NULL);
	if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_VDEV_TREE,
	    &nvroot) != 0) {
		zpool_close(zpool_handle);
		libzfs_fini(lzfs);
		return (-1);
	}
	verify(nvlist_lookup_nvlist_array(nvroot, ZPOOL_CONFIG_CHILDREN,
	    &child, &children) == 0);
	if (children != 1) {
		mesg(MERR, "expected one vdev, got %d\n", children);
		zpool_close(zpool_handle);
		libzfs_fini(lzfs);
		return (-1);
	}
	vname = zpool_vdev_name(lzfs, zpool_handle, child[0], B_FALSE);
	if (vname == NULL) {
		mesg(MERR, "couldn't determine vdev name\n");
		zpool_close(zpool_handle);
		libzfs_fini(lzfs);
		return (-1);
	}
	(void) strcpy(diskname, "/dev/dsk/");
	(void) strcat(diskname, vname);
	free(vname);
	zpool_close(zpool_handle);
	libzfs_fini(lzfs);
	return (1);
}
Ejemplo n.º 6
0
void
mousemoved(void)
{
	Icon *icon;

	for(icon = h.first; icon; icon = icon->next)
		if(ptinrect(mouse.xy, icon->sr)){
			mesg("%dx%d", icon->w, icon->h);
			return;
		}
	mesg("");
}
Ejemplo n.º 7
0
void pawsBuddyWindow::HandleMessage( MsgEntry* me )
{
    if ( me->GetType() == MSGTYPE_BUDDY_LIST )
    {
        psBuddyListMsg mesg(me);
    
        onlineBuddies.DeleteAll();
        offlineBuddies.DeleteAll();

        // Load aliases
        LoadAliases(psengine->GetMainPlayerName());

        for (size_t x = 0; x < mesg.buddies.GetSize(); x++ )
        {
            if (mesg.buddies[x].online)
                onlineBuddies.Push(GetAlias(mesg.buddies[x].name));
            else
                offlineBuddies.Push(GetAlias(mesg.buddies[x].name));
            chatWindow->AddAutoCompleteName(mesg.buddies[x].name);
        }

    }
    else if ( me->GetType() == MSGTYPE_BUDDY_STATUS )
    {
        psBuddyStatus mesg(me);
        
        // If player is online now remove from the offline list
        // else remove them from offline list and add to the online list.
        if ( mesg.onlineStatus )       
        {   
            size_t loc = offlineBuddies.Find(GetAlias(mesg.buddy.GetData()));
            if ( loc != csArrayItemNotFound )
            {
                offlineBuddies.DeleteIndex(loc);
            }                
            onlineBuddies.Push(GetAlias(mesg.buddy));
        }
        else
        {
            size_t loc = onlineBuddies.Find(GetAlias(mesg.buddy.GetData()));
            if ( loc != csArrayItemNotFound )
            {
                onlineBuddies.DeleteIndex(loc);
            }                

            offlineBuddies.Push(GetAlias(mesg.buddy));
        }

        chatWindow->AddAutoCompleteName(mesg.buddy);
    }

    FillBuddyList();
}
Ejemplo n.º 8
0
int
S3sup(void)	/* S3-support keyword handler */
{
	struct btoc {
		char *behavior;
		int cmd;
	};
	static struct btoc blist[] = {
		"default",	PM_DEFAULT_ALGORITHM,
		"enable",	PM_ENABLE_S3,
		"disable",	PM_DISABLE_S3,
		NULL,		0
	};
	struct btoc *bp;
	char *behavior;
	int dontcare;

	for (behavior = LINEARG(1), bp = blist; bp->cmd; bp++) {
		if (strcmp(behavior, bp->behavior) == 0)
			break;
	}
	if (bp->cmd == 0) {
		mesg(MERR, "invalid S3-support behavior \"%s\"\n", behavior);
		return (NOUP);
	}


	switch (bp->cmd) {

	case PM_ENABLE_S3:
	case PM_DISABLE_S3:
		return (do_ioctl(bp->cmd, "S3-support", behavior, EBUSY));

	case PM_DEFAULT_ALGORITHM:
		/*
		 * we suppress errors in the "default" case because we
		 * already did an invisible default call, so we know we'll
		 * get EBUSY
		 */
		return (S3_helper("S3-support-enable", "S3-support-disable",
		    PM_ENABLE_S3, PM_DISABLE_S3, "S3-support", behavior,
		    &dontcare, EBUSY));

	default:
		mesg(MERR, "S3-support %s failed, %s\n", behavior,
		    strerror(errno));
		return (NOUP);
	}
}
Ejemplo n.º 9
0
void
dcmd(char *arname, int count, char **files)
{
    Armember *bp;
    int fd, i;


    if (!count)
        return;
    fd = openar(arname, ORDWR, 0);
    Binit(&bar, fd, OREAD);
    Bseek(&bar,seek(fd,0,1), 1);
    astart = newtempfile(artemp);
    for (i = 0; bp = getdir(&bar); i++) {
        if(match(count, files)) {
            mesg('d', file);
            skip(&bar, bp->size);
            if (strcmp(file, symdef) == 0)
                allobj = 0;
        } else if (i == 0 && strcmp(file, symdef) == 0)
            skip(&bar, bp->size);
        else {
            scanobj(&bar, astart, bp->size);
            arcopy(&bar, astart, bp);
        }
    }
    close(fd);
    install(arname, astart, 0, 0, 0);
}
Ejemplo n.º 10
0
void SpellManager::SendSpellBook(MsgEntry* notused, Client* client)
{
    psSpellBookMessage mesg(client->GetClientNum());
    csArray<psSpell*> spells = client->GetCharacterData()->GetSpellList();

    for(size_t i = 0; i < spells.GetSize(); i++)
    {
        csArray<psItemStats*> glyphs = spells[i]->GetGlyphList();

        csString glyphImages[4];
        CS_ASSERT(glyphs.GetSize() <= 4);

        for(size_t j = 0; j < glyphs.GetSize(); j++)
        {
            glyphImages[j] = glyphs[j]->GetImageName();
        }

        mesg.AddSpell(spells[i]->GetName(), spells[i]->GetDescription(),
                      spells[i]->GetWay()->name, spells[i]->GetRealm(),
                      glyphImages[0], glyphImages[1],
                      glyphImages[2], glyphImages[3], spells[i]->GetImage());
    }

    mesg.Construct(cacheManager->GetMsgStrings());
    mesg.SendMessage();
}
//  This function constructs message names for external lookup.
//  The message names are constructed to avoid the problems of concatenating
//  phrases (which does not translate well into other languages). The
//  message names that can be generated are (listed here to appease the
//  auditing program which reads comments):
//    ERR_MSG("DjVuAnno.invalid2number"), ERR_MSG("DjVuAnno.string2number"),
//    ERR_MSG("DjVuAnno.symbol2number"), ERR_MSG("DjVuAnno.list2number")
//    ERR_MSG("DjVuAnno.invalid2string"), ERR_MSG("DjVuAnno.number2string"),
//    ERR_MSG("DjVuAnno.symbol2string"), ERR_MSG("DjVuAnno.list2string")
//    ERR_MSG("DjVuAnno.invalid2symbol"), ERR_MSG("DjVuAnno.number2symbol"),
//    ERR_MSG("DjVuAnno.string2symbol"), ERR_MSG("DjVuAnno.list2symbol")
//    ERR_MSG("DjVuAnno.invalid2list"), ERR_MSG("DjVuAnno.number2list"),
//    ERR_MSG("DjVuAnno.string2list"), ERR_MSG("DjVuAnno.symbol2list")
void
GLObject::throw_can_not_convert_to(const GLObjectType to) const
{
  static const GUTF8String two('2');
  static const GUTF8String tab('\t');
  GUTF8String mesg("DjVuAnno.");
  switch(type)
  {
    case NUMBER:
      mesg+=GLObjectString[NUMBER]+two+GLObjectString[to]+tab+GUTF8String(number);
      break;
    case STRING:
      mesg+=GLObjectString[STRING]+two+GLObjectString[to]+tab+string;
      break;
    case SYMBOL:
      mesg+=GLObjectString[SYMBOL]+two+GLObjectString[to]+tab+symbol;
      break;
    case LIST:
      mesg+=GLObjectString[LIST]+two+GLObjectString[to]+tab+name;
      break;
    default:
      mesg+=GLObjectString[INVALID]+two+GLObjectString[to];
      break;
  }
  G_THROW(mesg);
}
void pawsSpellBookWindow::HandleSpells( MsgEntry* me )
{
    spellList->Clear();
    descriptions_Hash.Empty();
    images_Hash.Empty();

    psSpellBookMessage mesg(me, psengine->GetNetManager()->GetConnection()->GetAccessPointers());
    for ( size_t x = 0; x < mesg.spells.GetSize(); x++ )
    {       
        pawsListBoxRow* row = spellList->NewRow();
        pawsTextBox* name = (pawsTextBox*)row->GetColumn(0);
        name->SetText( mesg.spells[x].name );
                       
        pawsTextBox* way = (pawsTextBox*)row->GetColumn(5);
        way->SetText( mesg.spells[x].way );
 
        pawsTextBox* realm = (pawsTextBox*)row->GetColumn(6);
        realm->FormatText( "%d", mesg.spells[x].realm );
        
        for (size_t i = 0; i < 4; i++)
        {
            if(!mesg.spells[x].glyphs[i])
                break;

            pawsWidget* glyph = (pawsWidget*)row->GetColumn(1+i);
            glyph->SetBackground(mesg.spells[x].glyphs[i]);
        }
        descriptions_Hash.Put(mesg.spells[x].name, mesg.spells[x].description);
        images_Hash.Put(mesg.spells[x].name, mesg.spells[x].image);
        if (selectedSpell == mesg.spells[x].name)
        {
            spellList->Select(row);
        }
    }            
}
void pawsContainerDescWindow::HandleUpdateItem( MsgEntry* me )
{
    psViewItemUpdate mesg( me, ((psNetManager*)psengine->GetNetManager())->GetConnection()->GetAccessPointers() );
    csString sigData, data;

    // We send ownerID to multiple clients, so each client must decide if the item is owned by
    // them or not.  This is double checked on the server if someone tries to move an item,
    // so hacking this to override just breaks the display, but does not enable a cheat.
    if (mesg.ownerID.IsValid() && mesg.ownerID != psengine->GetCelClient()->GetMainPlayer()->GetEID())
    {
        mesg.stackCount = -1; // hardcoded signal that item is not owned by this player
    }

    sigData.Format("invslot_%d", mesg.containerID.Unbox() * 100 + mesg.slotID + 16);
    if (!mesg.clearSlot)
    {
        data.Format("%s %d %d %s %s %s", mesg.icon.GetData(), mesg.stackCount, 0, mesg.meshName.GetData(), mesg.materialName.GetData(), mesg.name.GetData());
    }

    Debug3(LOG_CHARACTER, 0, "Got item update for %s: %s\n", sigData.GetDataSafe(), data.GetDataSafe() );

    // FIXME: psViewItemMessages should probably send out purification status

    PawsManager::GetSingleton().Publish(sigData, data);
}
Ejemplo n.º 14
0
LRESULT MainDialog::OnFinishConvert(UINT, WPARAM wp, LPARAM)
{
	EnableDlgItem(IDC_XML, true);
	EnableDlgItem(IDC_XML_BROWSE, true);
	EnableDlgItem(IDC_OUT_IMPORT, true);
	EnableDlgItem(IDC_OUT_MYSQL, true);
	EnableDlgItem(IDC_OUT_PSQL7, true);
	EnableDlgItem(IDC_OUT_PSQL8, true);
	EnableDlgItem(IDC_OPT_NOTEXT, true);
	EnableDlgItem(IDC_OUTDIR, true);
	EnableDlgItem(IDC_OUTDIR_BROWSE, true);
	EnableDlgItem(IDC_START, true);
	OnUpdateOption(0, 0, 0);
	m_converting = false;
	
	SetWindowText(RString(IDS_APP_TITLE));
	if(!m_abort) {
		m_csStderr.Lock();
		if(wp == 0) {
			if(m_errbuff.IsEmpty()) {
				MessageBox(RString(IDS_COMPLETE), MB_ICONINFORMATION);
			} else {
				RString mesg(IDS_COMPLETE_WARNING);
				MessageBox(mesg + m_errbuff, MB_ICONINFORMATION);
			}
		} else {
			MessageBox(m_errbuff, MB_ICONEXCLAMATION);
		}
		m_csStderr.Unlock();
	}
	m_abort = false;
	return 0;
}
Ejemplo n.º 15
0
void psMainWidget::HandleMessage( MsgEntry* message )
{
    if(message->GetType() != MSGTYPE_SYSTEM)
        return;

    psSystemMessage mesg(message);

    //Don't proceed if the message is disabled and it's not a server admin
    //or gm message
    if(!GetMesgOption(mesg.type) &&
        mesg.msgline.Find("server admin") == (size_t)-1 &&
         mesg.msgline.Find("gm warning") == (size_t)-1)
        return;

    int color = -1;

    if(mesg.type == MSG_ERROR)
        color = graphics2D->FindRGB(255,0,0);
    else if(mesg.type == MSG_INFO_SERVER)
        color = graphics2D->FindRGB(255,0,0);
    else if(mesg.type == MSG_RESULT)
        color = graphics2D->FindRGB(255,255,0);
    else if(mesg.type == MSG_OK)
        color = graphics2D->FindRGB(0,255,0);
    else if(mesg.type == MSG_ACK)
        color = graphics2D->FindRGB(0,0,255);

    if(color != -1)
        PrintOnScreen(mesg.msgline,color);
}
Ejemplo n.º 16
0
int
main(int argc, char *argv[])
{
	register int n;

	NoP(argc);
	error_info.id = "mesg";
	for (;;)
	{
		switch (optget(argv, usage))
		{
		case ':':
			error(2, "%s", opt_info.arg);
			break;
		case '?':
			error(ERROR_usage(2), "%s", opt_info.arg);
			break;
		}
		break;
	}
	argv += opt_info.index;
	n = 0;
	if(error_info.errors || (*argv && (n= **argv) !='y' && n!='n'))
		error(ERROR_usage(2), "%s", optusage(NiL));
	return mesg(n);
}
Ejemplo n.º 17
0
void psCreationManager::HandleVerify( MsgEntry* me )
{
    psCharVerificationMesg mesg(me);
    pawsSummaryWindow * window = (pawsSummaryWindow*)PawsManager::GetSingleton().FindWidget("Summary");
    if ( window )
        window->SetVerify( mesg.stats, mesg.skills );
}
Ejemplo n.º 18
0
/*
 * Call pm ioctl request(s) to set property/device dependencies.
 */
static int
dev_dep_common(int isprop)
{
	int cmd, argn, upval = OKUP;
	char *src, *first, **destp;
	pm_req_t pmreq;

	bzero(&pmreq, sizeof (pmreq));
	src = LINEARG(1);
	if (isprop) {
		cmd = PM_ADD_DEPENDENT_PROPERTY;
		first = NULL;
		pmreq.pmreq_kept = src;
	} else {
		cmd = PM_ADD_DEPENDENT;
		if (devpath(&first, src, &upval))
			return (upval);
		pmreq.pmreq_kept = first;
	}
	destp = &pmreq.pmreq_keeper;

	/*
	 * Now loop through any dependents.
	 */
	for (argn = 2; (src = LINEARG(argn)) != NULL; argn++) {
		if (devpath(destp, src, &upval)) {
			if (upval != OKUP)
				return (upval);
			break;
		}
		if ((upval = ioctl(pm_fd, cmd, &pmreq)) == -1) {
			mesg(MDEBUG, "pm ioctl, cmd %d, errno %d\n"
			    "kept \"%s\", keeper \"%s\"\n",
			    cmd, errno, pmreq.pmreq_kept, pmreq.pmreq_keeper);
			mesg(MERR, "cannot set \"%s\" dependency "
			    "for \"%s\", %s\n", pmreq.pmreq_keeper,
			    pmreq.pmreq_kept, strerror(errno));
		}
		free(*destp);
		*destp = NULL;
		if (upval != OKUP)
			break;
	}

	free(first);
	return (upval);
}
Ejemplo n.º 19
0
/*
 * Check for valid cpupm behavior and communicate it to the kernel.
 */
int
cpupm(void)
{
	struct bmtoc {
		char *behavior;
		char *mode;
		int cmd;
		int Errno;
	};

	static struct bmtoc bmlist[] = {
		"disable",	"\0",		PM_STOP_CPUPM,		EINVAL,
		"enable",	"poll-mode",	PM_START_CPUPM_POLL,	EBUSY,
		"enable",	"event-mode",	PM_START_CPUPM_EV,	EBUSY,
		"enable",	"\0",		PM_START_CPUPM,		EBUSY,
		NULL,		0,		0,			0
	};
	struct bmtoc *bp;
	char *behavior;
	char *mode;

	behavior = LINEARG(1);
	if ((mode = LINEARG(2)) == NULL)
		mode = "\0";

	for (bp = bmlist; bp->cmd; bp++) {
		if (strcmp(behavior, bp->behavior) == 0 &&
		    strcmp(mode, bp->mode) == 0) {
			break;
		}
	}
	if (bp->cmd == 0) {
		if (LINEARG(2) == NULL) {
			mesg(MERR, "invalid cpupm behavior \"%s\"\n", behavior);
		} else {
			mesg(MERR, "invalid cpupm behavior \"%s %s\"\n",
			    behavior, mode);
		}
		return (NOUP);
	}
	if (ioctl(pm_fd, bp->cmd, NULL) == -1 && errno != bp->Errno) {
		mesg(MERR, "cpupm %s failed, %s\n",
		    behavior, strerror(errno));
		return (NOUP);
	}
	return (OKUP);
}
Ejemplo n.º 20
0
/*
 * Check for a real device and try to resolve to a full path.
 * The orig/resolved path may be modified into a prom pathname,
 * and an allocated copy of the result is stored at *destp;
 * the caller will need to free that space.  Returns 1 for any
 * error, otherwise 0; also sets *errp after an alloc error.
 */
static int
devpath(char **destp, char *src, int *errp)
{
	struct stat stbuf;
	char buf[PATH_MAX];
	char *cp, *dstr;
	int devok, dcs = 0;
	size_t len;

	/*
	 * When there's a real device, try to resolve the path
	 * and trim the leading "/devices" component.
	 */
	if ((devok = (stat(src, &stbuf) == 0 && stbuf.st_rdev)) != 0) {
		if (realpath(src, buf) == NULL) {
			mesg(MERR, "realpath cannot resolve \"%s\"\n",
			    src, strerror(errno));
			return (1);
		}
		src = buf;
		dstr = "/devices";
		len = strlen(dstr);
		dcs = (strncmp(src, dstr, len) == 0);
		if (dcs)
			src += len;
	} else
		mesg(MDEBUG, stat_fmt, src, strerror(errno));

	/*
	 * When the path has ":anything", display an error for
	 * a non-device or truncate a resolved+modifed path.
	 */
	if ((cp = strchr(src, ':')) != NULL) {
		if (devok == 0) {
			mesg(MERR, "physical path may not contain "
			    "a minor string (%s)\n", src);
			return (1);
		} else if (dcs)
			*cp = '\0';
	}

	if ((*destp = strdup(src)) == NULL) {
		*errp = NOUP;
		mesg(MERR, alloc_fmt, src, strerror(errno));
	}
	return (*destp == NULL);
}
Ejemplo n.º 21
0
std::string mpiErrorMessage(const int err){
  char *msg = new char [MPI_MAX_ERROR_STRING];
  int len;
  MPI_Error_string(err, msg, &len);
  std::string mesg(msg);
  delete [] msg;
  return mesg;
}
Ejemplo n.º 22
0
void BYdpMainWindow::ConfigPath(void) {
//	printf("configure path\n");
	BMessenger mesg(this);
	myPanel = new BFilePanel(B_OPEN_PANEL,
			&mesg, NULL, B_DIRECTORY_NODE, false, NULL, NULL, true, true);
	myPanel->Show();
	myPanel->Window()->SetTitle("Choose directory with dictionary files");
}
Ejemplo n.º 23
0
static int
gethm(char *src, int *hour, int *min)
{
	if (sscanf(src, "%d:%d", hour, min) != 2) {
		mesg(MERR, "bad time format (%s)\n", src);
		return (-1);
	}
	return (0);
}
Ejemplo n.º 24
0
// Send something to the chat window.
void LuaSendChat(const char *msg,bool IsDebug)
{
	std::string mesg(msg);
	LLChat dongs(mesg);
	dongs.mSourceType=CHAT_SOURCE_LUA;
	if(IsDebug) dongs.mChatType=CHAT_TYPE_DEBUG_MSG;
	LLFloaterChat::addChat(dongs);
	LLFloaterLuaConsole::addOutput(mesg,false); //no debug exception yet.
}
Ejemplo n.º 25
0
/*
 * Check for valid autoS3 behavior and save after ioctl success.
 */
int
autoS3(void)
{
	struct btoc {
		char *behavior;
		int cmd;
	};
	static struct btoc blist[] = {
		"default",	PM_DEFAULT_ALGORITHM,
		"disable",	PM_STOP_AUTOS3,
		"enable",	PM_START_AUTOS3,
		NULL,		0
	};
	struct btoc *bp;
	char *behavior;
	int dontcare;

	for (behavior = LINEARG(1), bp = blist; bp->cmd; bp++) {
		if (strcmp(behavior, bp->behavior) == 0)
			break;
	}
	if (bp->cmd == 0) {
		mesg(MERR, "invalid autoS3 behavior \"%s\"\n", behavior);
		return (NOUP);
	}

	switch (bp->cmd) {
	default:
		mesg(MERR, "autoS3 %s failed, %s\n",
		    behavior, strerror(errno));
		mesg(MDEBUG, "unknown command\n", bp->cmd);
		return (OKUP);

	case PM_STOP_AUTOS3:
	case PM_START_AUTOS3:
		return (do_ioctl(bp->cmd, "autoS3", behavior, EBUSY));

	case PM_DEFAULT_ALGORITHM:
		return (S3_helper("S3-autoenable", "S3-autodisable",
		    PM_START_AUTOS3, PM_STOP_AUTOS3, "autoS3", behavior,
		    &dontcare, EBUSY));
	}
}
Ejemplo n.º 26
0
/*
 * Increment the count of threshold values,
 * reallocate *vlistp and append another element.
 * Returns 1 on error, otherwise 0.
 */
static int
vlist_append(int **vlistp, int *vcntp, int value)
{
	(*vcntp)++;
	if ((*vlistp = realloc(*vlistp, *vcntp * sizeof (**vlistp))) != NULL)
		*(*vlistp + *vcntp - 1) = value;
	else
		mesg(MERR, alloc_fmt, "threshold list", strerror(errno));
	return (*vlistp == NULL);
}
Ejemplo n.º 27
0
void
domask(Icon *icon)
{
	int rv;
	char file[64];
	int fd;

	rv = -1;
	snprint(file, sizeof(file), "%dx%d.mask", icon->w, icon->h);
	fd = create(file, OWRITE, 0664);
	if(fd >= 0){
		rv = writeimage(fd, icon->mask, 0);
		close(fd);
	}
	if(rv < 0)
		mesg("error writing %s: %r", file);
	else
		mesg("created %s", file);
}
Ejemplo n.º 28
0
static int
do_ioctl(int ioctl_cmd, char *keyword, char *behavior, int suppress)
{
	mesg(MDEBUG, "doing ioctl %s for %s ", pm_map(ioctl_cmd), keyword);
	if (ioctl(pm_fd, ioctl_cmd, NULL) == -1) {
		int suppressed = suppress == -1 || suppress == errno;
		if (!suppressed) {
			mesg(MERR, "%s %s failed, %s\n", keyword, behavior,
			    strerror(errno));
			return (NOUP);
		} else {
			mesg(MDEBUG, "%s %s failed, %s\n", keyword, behavior,
			    strerror(errno));
			return (OKUP);
		}
	}
	mesg(MDEBUG, "succeeded\n");
	return (OKUP);
}
Ejemplo n.º 29
0
void AuthenticationServer::HandleDisconnect(MsgEntry* me,Client *client)
{
    psDisconnectMessage mesg(me);

    // Check if this client is allowed to disconnect or if the
    // zombie state should be set
    if(!client->AllowDisconnect())
        return;

    psserver->RemovePlayer(me->clientnum, "Your client has disconnected. If you are seeing this message a connection error has likely occurred.");
}
Ejemplo n.º 30
0
void SpellManager::StartPurifying(MsgEntry* me, Client* client)
{
    psPurifyGlyphMessage mesg(me);
    int statID = mesg.glyph;

    psCharacter* character = client->GetCharacterData();

    psGlyph* glyph = FindUnpurifiedGlyph(character, statID);

    if(glyph == NULL)
    {
        return;
    }

    if(glyph->GetStackCount() > 1)
    {
        psGlyph* stackOfGlyphs = glyph;

        glyph = dynamic_cast <psGlyph*>(stackOfGlyphs->SplitStack(1));
        if(glyph == NULL)
        {
            return;
        }

        psItem* glyphItem = glyph; // Needed for reference in next function
        if(!character->Inventory().Add(glyphItem,false,false))
        {
            // Notify the player that and why purification failed
            psserver->SendSystemError(client->GetClientNum(), "You can't purify %s because your inventory is full!", glyph->GetName());

            cacheManager->RemoveInstance(glyphItem);

            // Reset the stack count to account for the one that was destroyed.
            stackOfGlyphs->SetStackCount(stackOfGlyphs->GetStackCount() + 1);
            SendGlyphs(NULL,client);
            return;
        }
        stackOfGlyphs->Save(false);
        glyph->Save(false);
    }

    glyph->PurifyingStarted();

    // If the glyph has no ID, we must save it now because we need to have an ID for the purification script
    glyph->ForceSaveIfNew();

    // Should probably just assume PURIFYING glyphs actually finished when we load them next.
    psserver->SendSystemInfo(client->GetClientNum(), "You start to purify %s", glyph->GetName());
    psPurifyEvent* evt = new psPurifyEvent(20000, client->GetActor(), glyph->GetUID());
    psserver->GetEventManager()->Push(evt);

    SendGlyphs(NULL,client);
    psserver->GetCharManager()->SendInventory(client->GetClientNum());
}