void MI_CALL MSFT_nxServiceResource_Invoke_SetTargetResource(
    _In_opt_ MSFT_nxServiceResource_Self* self,
    _In_ MI_Context* context,
    _In_opt_z_ const MI_Char* nameSpace,
    _In_opt_z_ const MI_Char* className,
    _In_opt_z_ const MI_Char* methodName,
    _In_ const MSFT_nxServiceResource* instanceName,
    _In_opt_ const MSFT_nxServiceResource_SetTargetResource* in)
{
    std::cerr << "Set" << std::endl;

    if (!self)
    {
        MI_Context_PostResult(context, MI_RESULT_OK);
        return;
    }

    MI_Result r = MI_RESULT_OK;
    MSFT_nxServiceResource_SetTargetResource out;
    const MSFT_nxServiceResource * service = in->InputResource.value;
    MI_Result res = MI_RESULT_OK;

    std::vector<std::string> ret_strings;
    long exit_code = callPythonFunction(
        ret_strings,
        self->pSetFn,
        4,
        PassString(service->Name),
        PassString(service->Controller),
        PassBoolean(service->Enabled),
        PassString(service->State));

    if (ret_strings.size() == 0 && exit_code == 0)
    {
        res = MI_RESULT_OK;
    }
    else
    {
        res = MI_RESULT_FAILED;
    }

    r = MSFT_nxServiceResource_SetTargetResource_Construct(&out, context);
    r = MSFT_nxServiceResource_SetTargetResource_Set_MIReturn(&out, res);
    r = MSFT_nxServiceResource_SetTargetResource_Post(&out, context);
    r = MSFT_nxServiceResource_SetTargetResource_Destruct(&out);
    MI_Context_PostResult(context, res);

}
示例#2
0
void get_printSetup_with_PRINTDLG(PRINTDLG *pd, char **o_devmode,
						char **o_device, char **o_driver, char **o_output)
{
	char		*newDriver, *newDevice, *newOutput;
	DEVMODE		*pDevmode;
	DEVNAMES	*pDevnames;

	pDevmode	= LocalLock(pd->hDevMode);
	*o_devmode	= PassString(pDevmode->dmDeviceName);
	LocalUnlock(pd->hDevMode);
	pDevnames	= LocalLock(pd->hDevNames);
	newDriver	= ((char*)pDevnames)+(pDevnames->wDriverOffset);
	newDevice	= ((char*)pDevnames)+(pDevnames->wDeviceOffset);
	newOutput	= ((char*)pDevnames)+(pDevnames->wOutputOffset);
	*o_driver	= PassString(newDriver);
	*o_device	= PassString(newDevice);
	*o_output	= PassString(newOutput);
	LocalUnlock(pd->hDevNames);
}
示例#3
0
void getDevmodeSizeC(int *size, HANDLE *phPrinter,
					 char **device, char **driver,  char **output)
{
	char	szPrinter[80];
	char	*szDevice, *szDriver, *szOutput;

	GetProfileString("windows", "device", ",,,", szPrinter, 80);
	szDevice = strtok(szPrinter,",");
	szDriver = strtok(NULL,", ");
	szOutput = strtok(NULL,", ");
	*device	= PassString(szDevice);
	*driver	= PassString(szDriver);
	*output	= PassString(szOutput);
	if (*szDevice=='\0' || *szDriver=='\0' || *szOutput=='\0')
	{
		*size	= 0;
		return;
	};
	OpenPrinter(szDevice,phPrinter,NULL);
	*size = DocumentProperties(NULL,*phPrinter,szDevice,NULL,NULL,0);
}
示例#4
0
void Screen::ControlPlayer(const int ch) {
	if ( 'Q'==ch ) {
		emit ExitReceived();
		return;
	}
	if ( ch>='a' && ch<='z' ) { //actions with inventory
		const int num=ch-'a';
		switch ( actionMode ) {
			case USE:      player->Use(num); break;
			case THROW:    player->Throw(num); break;
			case OBTAIN:   player->Obtain(num); break;
			case WIELD:    player->Wield(num); break;
			case INSCRIBE: player->Inscribe(num); break;
			case EAT:      player->Eat(num); break;
			case CRAFT:    player->Craft(num); break;
			case TAKEOFF:  player->TakeOff(num); break;
			case BUILD: {
				ushort x, y, z;
				ActionXyz(x, y, z);
				player->Build(x, y, z, num);
			} break;
			default:
				fprintf(stderr,
					"Screen::ControlPlayer: \
					unlisted action mode: %d\n",
					actionMode);
		}
		return;
	}
	switch ( ch ) { //interactions with world
		case KEY_UP:    player->Move(NORTH); break;
		case KEY_DOWN:  player->Move(SOUTH); break;
		case KEY_RIGHT: player->Move(EAST); break;
		case KEY_LEFT:  player->Move(WEST); break;
		case ' ': player->Jump(); break;

		case '>': player->Turn(World::TurnRight(player->Dir())); break;
		case '<': player->Turn(World::TurnLeft(player->Dir())); break;
		case KEY_NPAGE: player->Turn(DOWN); break;
		case KEY_PPAGE: player->Turn(UP); break;

		case KEY_HOME: player->Backpack(); break;
		case 8:
		case KEY_BACKSPACE: { //damage
			ushort x, y, z;
			ActionXyz(x, y, z);
			player->Damage(x, y, z);
		} break;
		case 13:
		case '\n': { //use
			ushort x, y, z;
			player->Focus(x, y, z);
			player->Use(x, y, z);
		} break;
		case  '?': { //examine
			ushort x, y, z;
			ActionXyz(x, y, z);
			player->Examine(x, y, z);
		} break;
		case  '~': { //inscribe
			ushort x, y, z;
			ActionXyz(x, y, z);
			player->Inscribe(x, y, z);
		} break;

		case 'U': actionMode=USE; break;
		case 'T': actionMode=THROW; break;
		case 'O': actionMode=OBTAIN; break;
		case 'W': actionMode=WIELD; break;
		case 'I': actionMode=INSCRIBE; break;
		case 'E': actionMode=EAT; break;
		case 'B': actionMode=BUILD; break;
		case 'C': actionMode=CRAFT; break;
		case 'F': actionMode=TAKEOFF; break;

		case ';': {
			Inventory * const inv=player->GetP() ?
				player->GetP()->HasInventory() : 0;
			if ( inv ) {
				player->MoveInsideInventory(
					inv->Start(), inv->Size()-1);
			}
		} break;
		case '{': shiftFocus -= ( -1==shiftFocus ) ? 0 : 1; break;
		case '}': shiftFocus += (  1==shiftFocus ) ? 0 : 1; break;

		case '+': w->SetNumActiveShreds(w->NumActiveShreds()+2); break;
		case '-':
			if ( w->NumActiveShreds() > 3 ) {
				w->SetNumActiveShreds(w->NumActiveShreds()-2);
			} else {
				Notify(QString(
					"Active zone is too small: %1x%2.").
						arg(w->NumActiveShreds()).
						arg(w->NumActiveShreds()));
			}
		break;
		case '#':
			Notify("Don't make shreds number too big.");
			player->SetNumShreds(w->NumShreds()+2);
		break;
		case '_':
			player->SetNumShreds(w->NumShreds()-2);
		break;

		case '!':
			player->SetCreativeMode( player->GetCreativeMode() ?
				false : true);
		break;
		case ':': //command mode
			PassString(command);
		//no break
		case '.':
			player->ProcessCommand(command);
		break;

		case 'L': RePrint(); break;
		default:
			Notify(QString("Don't know what such key means: %1").
				arg(ch));
	}
	updated=false;
}
void MI_CALL MSFT_nxServiceResource_Invoke_GetTargetResource(
    _In_opt_ MSFT_nxServiceResource_Self* self,
    _In_ MI_Context* context,
    _In_opt_z_ const MI_Char* nameSpace,
    _In_opt_z_ const MI_Char* className,
    _In_opt_z_ const MI_Char* methodName,
    _In_ const MSFT_nxServiceResource* instanceName,
    _In_opt_ const MSFT_nxServiceResource_GetTargetResource* in)
{
    std::cerr << "Get" << std::endl;

    MI_Result r = MI_RESULT_OK;
    MI_Boolean res = MI_TRUE;
    MSFT_nxServiceResource_GetTargetResource out;
    MI_Instance *newInstance;
    MI_Value value;

    r = MSFT_nxServiceResource_GetTargetResource_Construct(&out, context);
    r = MSFT_nxServiceResource_GetTargetResource_Set_MIReturn(&out, 0);

    const MSFT_nxServiceResource * service = in->InputResource.value;
    r = MI_Instance_Clone(&service->__instance, &newInstance);


    std::vector<std::string> ret_strings;
    long exit_code = callPythonFunction(
        ret_strings,
        self->pGetFn,
        4,
        PassString(service->Name),
        PassString(service->Controller),
        PassBoolean(service->Enabled),
        PassString(service->State));
    
    // Expecting 4+1 parameters in return
    if (ret_strings.size() == (4+1) && exit_code == 0)
    {
        res = MI_TRUE;
    }
    else
    {
        MI_Context_PostResult(context, MI_RESULT_FAILED);
        return;
    }

    if (SetElement(newInstance, "Name", ret_strings[0], MI_STRING)  != 0 ||
        SetElement(newInstance, "Controller", ret_strings[1], MI_STRING)  != 0 ||
        SetElement(newInstance, "Enabled", ret_strings[2], MI_BOOLEAN)  != 0 ||
        SetElement(newInstance, "State", ret_strings[3], MI_STRING)  != 0 ||
        SetElement(newInstance, "Path", ret_strings[4], MI_STRING))
    {
        MI_Context_PostResult(context, MI_RESULT_FAILED);
        return;
    }

    value.instance = newInstance;
    r = MI_Instance_SetElement(&out.__instance, "OutputResource", &value, MI_INSTANCE, 0);
    if ( r != MI_RESULT_OK )
    {
        MI_Context_PostResult(context, r);
        return;
    }

    MI_Instance_Delete(newInstance);
    r = MSFT_nxServiceResource_GetTargetResource_Post(&out, context);
    if ( r != MI_RESULT_OK )
    {
        MI_Context_PostResult(context, r);
        return;
    }

    r = MSFT_nxServiceResource_GetTargetResource_Destruct(&out);
    if ( r != MI_RESULT_OK )
    {
        MI_Context_PostResult(context, r);
        return;
    }

    MI_Context_PostResult(context, MI_RESULT_OK);
}