Ejemplo n.º 1
0
/**
* \brief Function to change VISHNU user password
* \fn int resetPassword(UMS_Data::User user, std::string sendmailScriptPath)
* \param user The user data structure
* \param sendmailScriptPath The path to the script for sending emails
* \return raises an exception on error
*/
int
UserServer::resetPassword(UMS_Data::User& user, std::string sendmailScriptPath) {
  std::string sqlResetPwd;
  std::string sqlUpdatePwdState;
  std::string passwordCrypted;
  std::string pwd;


  //If the user exists
  if (exist()) {
    //if the user is an admin
    if (isAdmin()) {
      //if the user whose password will be reset exists
      if (getAttribut("where userid='"+user.getUserId()+"'").size() != 0) {
        //generation of a new password
        pwd = generatePassword(user.getUserId(), user.getUserId());
        user.setPassword(pwd.substr(0,PASSWORD_MAX_SIZE));

        //to get the password encryptes
        passwordCrypted = vishnu::cryptPassword(user.getUserId(), user.getPassword());

        //The sql code to reset the password
        sqlResetPwd = "UPDATE users SET pwd='"+passwordCrypted+"' where "
        "userid='"+user.getUserId()+"';";
        //sql code to update the passwordstate
        sqlUpdatePwdState = "UPDATE users SET passwordstate=0 "
        "where userid='"+user.getUserId()+"' and pwd='"+passwordCrypted+"';";
        //To append the previous sql codes
        sqlResetPwd.append(sqlUpdatePwdState);
        //Execution of the sql code on the database
        mdatabaseVishnu->process( sqlResetPwd.c_str());
        //to get the email adress of the user
        std::string email = getAttribut("where userid='"+user.getUserId()+"'", "email");
        user.setEmail(email);
        //Send email
        std::string emailBody = getMailContent(user, false);
        sendMailToUser(user, emailBody, "Vishnu message: password reset", sendmailScriptPath);
      } // End if the user whose password will be reset exists
      else {
        UMSVishnuException e (ERRCODE_UNKNOWN_USERID, "You must use a global VISHNU identifier");
        throw e;
      }
    } //END if the user is an admin
    else {
      UMSVishnuException e (ERRCODE_NO_ADMIN);
      throw e;
    }
  } //END if the user exists
  else {
    UMSVishnuException e (ERRCODE_UNKNOWN_USER);
    throw e;
  }
  return 0;
}//END: resetPassword(UMS_Data::User user)
Ejemplo n.º 2
0
/**
* \brief Function to get a certain user account property
* \param machineId The machine identifier of machine on which the user have a account
* \param property The property name
* \return the user account login
*/
std::string
UserServer::getUserAccountProperty(const std::string& machineId, const std::string& property) {

  init();

  std::string userId = getData().getUserId();
  UMS_Data::LocalAccount_ptr account = new UMS_Data::LocalAccount();
  account->setMachineId(machineId);
  account->setUserId(userId);
  LocalAccountServer localAccount(account, *msessionServer);

  UMS_Data::Machine_ptr machine = new UMS_Data::Machine();
  machine->setMachineId(machineId);
  MachineServer machineServer(machine);

  //To get the database number id of the machine
  std::string numMachine = machineServer.getAttribut("where machineid='"+localAccount.getData()->getMachineId()+"'");
  //To get the database number id of the user
  std::string numUser = getAttribut("where userid='"+localAccount.getData()->getUserId()+"'");

  std::string value;
  if ((numMachine.size() > 0) && (numUser.size() > 0)) {
	  value = localAccount.getAttribut("where machine_nummachineid="+numMachine+" and users_numuserid="+numUser, property);
  }

  if(value.size()==0) {
    delete account;
    delete machine;
    throw UMSVishnuException(ERRCODE_UNKNOWN_LOCAL_ACCOUNT, "You have not a local account on this machine");
  }

  delete account;
  delete machine;
  return value;
}
Ejemplo n.º 3
0
/**
* \brief Function to delete VISHNU user
* \fn int deleteUser(UMS_Data::User user)
* \param user The user data structure
* \return raises an exception on error
*/
int
UserServer::deleteUser(UMS_Data::User user) {

  //If the user to delete is not the super VISHNU admin
  if (user.getUserId().compare(ROOTUSERNAME) != 0) {
    //If the user exists
    if (exist()) {
      if (isAdmin()) {
        //if the user who will be deleted exist
        if (getAttribut("where userid='"+user.getUserId()+"'").size() != 0) {
          //Execution of the sql code to delete the user
          mdatabaseVishnu->process("DELETE FROM users where userid='"+user.getUserId()+"'");
        } // End if the user who will be deleted exist
        else {
          UMSVishnuException e (ERRCODE_UNKNOWN_USERID);
          throw e;
        }
      } //END if the user is an admin
      else {
        UMSVishnuException e (ERRCODE_NO_ADMIN);
        throw e;
      }
    } //END if the user exists
    else {
      UMSVishnuException e (ERRCODE_UNKNOWN_USER);
      throw e;
    }
  }//END If the user to delete is not the super VISHNU admin
  else {
    UserException e (ERRCODE_INVALID_PARAM, "It is not possible to delete this user. It is the VISHNU root user");
    throw e;
  }
  return 0;
}//END: deleteUser(UMS_Data::User user)
Ejemplo n.º 4
0
int MSGinput(int len, char *buffer)
{
	extern MP_MSG msg;
	extern STATUS_WERTE sta;
	extern int sprache;

	char *to_buffers[MAX_MENU_ITEMS];
	int  status = MPOK;

	status = UtilSplitMenubuffer(buffer, to_buffers, (char)NULL);
	if (status != MPOK)
		{
		UtilMsg((int)MPE_CUTBUFFERIN, MSGTYP_ERROR, NULL);
		msg.msg_id=(int)_UNDEF;
		return((int)MPERROR);
		}

	if (ACTIONTYP == (unsigned char)INSERT)
		msg.msg_id=(int)_UNDEF;


	if (*to_buffers[MMSG_NR] != NULL)
		msg.msg_id = atoi(to_buffers[MMSG_NR]);
	else
		msg.msg_id = (int)_UNDEF;

	if (*to_buffers[MMSG_SPR] != NULL)
		msg.s_id = sprache;
	else
		msg.s_id = sprache;

	/* Meldungstyp setzen - default ist Typ MESSAGE */
	sta.typ = (int)_MSGTYP;
	if (getAttribut((int)_MSGTYP, to_buffers[MMSG_TYP]) != (int)MPERROR)
		msg.msg_typ = sta.sta_id;
	else
		msg.msg_typ = (int)MSGTYP_MSG; /* default */

	/* initialisiere Textsegment */
	msg.textnr = 0;
	*msg.text = NULL;

	/* insert/update a msg or delete a msg */
	if (msg.msg_id != (int)_UNDEF)
		{
		status = MPAPIdeleteEntry((int)_MSG, (char *)&msg);
		if ((ACTIONTYP == (unsigned char)INSERT ||
			 ACTIONTYP == (unsigned char)UPDATE) &&
			 status != (int)MPERROR)
			status = MsgTextWrite(&msg, to_buffers[MMSG_TXT]);

		if (status != (int)MPERROR)
			(void)WriteInfo((int)_MSG, (char *)&msg, buffer);
		else
			msg.msg_id = (int)_UNDEF;
		}

	UtilSplitFreeMenubuffer(to_buffers);
	return(status);
}
Ejemplo n.º 5
0
/**
* \brief Function to check a userId
* \fn bool existuserId(std::string userId)
* \param userId The userId to check
* \return true if the userId exists
*/
bool
UserServer::existuserId(std::string userId) {

  //If the userID exists on the database
  if (getAttribut("where userid='"+userId+"'").size() != 0)	{
    //If the user is not locked
    if ( convertToInt(getAttribut("where userid='"+userId+"'", "status")) == 1) {
      return true;
    } //END if the user is not locked
    else {
      UMSVishnuException e (ERRCODE_USER_LOCKED);
      throw e;
    }
  }//END If the userID exists on the database
  else {
    return false;
  }
}
Ejemplo n.º 6
0
/**
* \brief Function to check user on database
* \fn bool exist(bool flagForChangePwd)
* \param flagForChangePwd A flag to check the password state
* \return true if the password state has not to be checked else false
*/
bool
UserServer::exist(bool flagForChangePwd) {
  //if the user is on the database
  if (getAttribut("where userid='"+muser.getUserId()+"'and pwd='"+muser.getPassword()+"'").size() != 0) {
    CheckUserState(flagForChangePwd);
    return true;
  }//END if the user is on the database
  else {
    return false;
  }
} //END: exist(bool flagForChangePwd)
Ejemplo n.º 7
0
/**
* \brief Function to initialize user data for constructor with sessionServer
* \fn init()
*/
void
UserServer::init(){
  std::string numUser;
  std::string sessionState;

  //if userId and password have not been defined
  if ((muser.getUserId().size() == 0) && (muser.getPassword().size() == 0)) {
    //To get the users_numuserid by using the sessionServer
    numUser =
    msessionServer->getAttribut("where"
    " sessionkey='"+msessionServer->getData().getSessionKey()+"'", "users_numuserid");

    //if the session key is found
    if (numUser.size() != 0) {
      //To get the session state
      sessionState =
      msessionServer->getAttribut("where"
      " sessionkey='"+msessionServer->getData().getSessionKey()+"'", "state");

      //if the session is active
      if (convertToInt(sessionState) == 1) {
        muser.setUserId(getAttribut("where numuserid='"+numUser+"'", "userid"));
        muser.setPassword(getAttribut("where numuserid='"+numUser+"'", "pwd"));
      } //End if the session is active
      else {
        UMSVishnuException e (ERRCODE_SESSIONKEY_EXPIRED);
        throw e;
      }

    } //END If the session key is found
    else {
      UMSVishnuException e (ERRCODE_SESSIONKEY_NOT_FOUND);
      throw e;
    }
  }//END If the userId and password have not been defined
} //END: void init()
Ejemplo n.º 8
0
/**
* \brief Function to change VISHNU user password
* \fn int changePassword(std::string newPassword)
* \param newPassword The new password of the user
* \return raises an exception on error
*/
int
UserServer::changePassword(std::string newPassword) {
  std::string sqlChangePwd;
  std::string sqlUpdatePwdState;
  //the flagForChangePwd is set to true to avoid the password state checking

  //If the user exist
  if (isAuthenticate(true)) {
    //If the identifiers used for the connection are a global VISHNU identifiers registered on UMS database
    if (getAttribut("where userid='"+muser.getUserId()+"'").size() != 0) {
      //To encrypt password with the global userId as a salt
      newPassword = vishnu::cryptPassword(muser.getUserId(), newPassword);

      //sql code to change the user password
      sqlChangePwd = "UPDATE users SET pwd='"+newPassword+"'where "
      "userid='"+muser.getUserId()+"' and pwd='"+muser.getPassword()+"';";

      //sql code to update the passwordstate
      sqlUpdatePwdState = "UPDATE users SET passwordstate=1 "
      "where userid='"+muser.getUserId()+"' and pwd='"+newPassword+"';";

      sqlChangePwd.append(sqlUpdatePwdState);
      mdatabaseVishnu->process(sqlChangePwd.c_str());

      //Put the new user's password
      muser.setPassword(newPassword);
    }//End //If the identifiers used for the connection are a global VISHNU identifiers
    else {
      UMSVishnuException e (ERRCODE_READONLY_ACCOUNT);
      throw e;
    }
  } //End If the user exist with the flagForChangePwd to true ti avoid the passwordstate checking
  else {
    UMSVishnuException e (ERRCODE_UNKNOWN_USER);
    throw e;
  }
  return 0;
}//END: changePassword(std::string newPassword)
Ejemplo n.º 9
0
/*F***********************************************************
 * Function:  Choose
 *************************************************************/
int STAchoose(int table, char *buffer)
{
	extern int sprache;
	extern STATUS_WERTE		sta;
	extern STATUS_WERTE		sta_old;
	extern BEZEICHNUNG		bez;
	extern char glob_typbez_sta[];
	extern int glob_typ_sta;

	BEZEICHNUNG					tmpbez;
	char	buffer1[RECLAENGE];
	char	buffer2[RECLAENGE];
	char	message[RECLAENGE];
	char dbbuffer[RECLAENGE];

	(void)memset((void *)buffer1, NULL, sizeof(buffer1));
	(void)memset((void *)buffer2, NULL, sizeof(buffer2));
	COMMTYP = CHOOSE;

	/* feldspezifischen Einschr�nkungen */
	switch(FELDNR)
		{
		case MSTA_BEZ:
			break;
		case MSTA_TYP:
			tmpbez.s_id=(int)sprache;
			tmpbez.typ = (int)_NAMEN;
			(void)strcpy(tmpbez.bez, buffer);
			(void)strcpy(glob_typbez_sta, buffer);
			if ( *buffer != NULL && MPAPIselectEntry((int)_BEZEICHNUNG, buffer, (char *)&tmpbez,
						sizeof(BEZEICHNUNG), sizeof(tmpbez.bez_id) ) != (int)_UNDEF )
				glob_typ_sta = tmpbez.typ;
			else
				glob_typ_sta = (int)_UNDEF;
			return(MPOK);
			break;
		default:
			return(MPOK);
			break;
		}

	/* Falls im INSERT Modus nicht mehr weiter suchen   Output: 1 Feld */
	if (ACTIONTYP == INSERT)
		return(MPOK);

	/* F�lle das Menu so viel wie m�glich               Output: 1 Menu */

	/* STATUS_WERTE  Bezeichnung */
	strcpy(dbbuffer, buffer);
	(void)ConvertSpecialChar(dbbuffer, NULL);
	sta.typ=glob_typ_sta;
	if (getAttribut((int)sta.typ, dbbuffer) != (int)MPOK)
		{
		UtilMsg((int)MPE_NOENTRYFOUND, MSGTYP_ERROR, NULL);
		return((int)MPERROR);
		}
	(void)strcat(buffer, "\t");

	/* UNDEF  Abk�rzung */
	(void)copyTextTo(buffer1, sta.abk, (int)_CHAR39);
	(void)strcat(buffer, buffer1);
	(void)strcat(buffer, "\t");

	/* UNDEF  Wert / Inhalt / Code */
	(void)copyTextTo(buffer1, sta.sta, (int)_CHAR39);
	(void)strcat(buffer, buffer1);
	(void)strcat(buffer, "\t");

	/* UNDEF  Konditionen */
	(void)sprintf(buffer2, "%f", sta.kond);
	(void)strcat(buffer, buffer2);
	(void)strcat(buffer, "\t");

	/* STATUS_WERTE  Typ */
	(void)strcat(buffer, glob_typbez_sta);
	(void)strcat(buffer, "\t");

	(void)memcpy((void *)&sta_old, (void *)&sta, sizeof(sta));	/* f�r Update */

	COMMTYP = SELECTITEM;
	return(MPOK);
}
Ejemplo n.º 10
0
/**
* \brief Function to add a new VISHNU user
* \fn int add(UMS_Data::User*& user, int vishnuId)
* \param user The user data structure
* \param vishnuId The identifier of the vishnu instance
* \param sendmailScriptPath The path to the script for sending emails
* \return raises an exception on error
*/
int
UserServer::add(UMS_Data::User*& user, int vishnuId, std::string sendmailScriptPath) {
  std::string pwd;
  std::string sqlUpdate = "update users set ";

  std::string idUserGenerated;
  std::string passwordCrypted;
  std::string formatiduser;

  if (exist()) {
    if (isAdmin()) {

      //Generation of password
      pwd = generatePassword(user->getLastname(), user->getFirstname());
      user->setPassword(pwd.substr(0,PASSWORD_MAX_SIZE));

      //Generation of userid
      idUserGenerated = vishnu::getObjectId(vishnuId,
                                            "formatiduser",
                                            USER,
                                            user->getLastname());
      user->setUserId(idUserGenerated);
      //To get the password encrypted
      passwordCrypted = vishnu::cryptPassword(user->getUserId(), user->getPassword());

      // If there only one field reserved by getObjectId
      if (getAttribut("where userid='"+user->getUserId()+"'","count(numuserid)") == "1") {

        //To active the user status
        user->setStatus(ACTIVE_STATUS);

        sqlUpdate+="vishnu_vishnuid="+convertToString(vishnuId)+", ";
        sqlUpdate+="pwd='"+passwordCrypted+"', ";
        sqlUpdate+="firstname='"+user->getFirstname()+"', ";
        sqlUpdate+="lastname='"+user->getLastname()+"', ";
        sqlUpdate+="privilege="+convertToString(user->getPrivilege())+", ";
        sqlUpdate+="email='"+user->getEmail()+"', ";
        sqlUpdate+="passwordstate=0, ";
        sqlUpdate+="status="+convertToString(user->getStatus())+" ";
        sqlUpdate+="where userid='"+user->getUserId()+"';";
        mdatabaseVishnu->process(sqlUpdate);


        //Send email
        std::string emailBody = getMailContent(*user, true);
        sendMailToUser(*user, emailBody, "Vishnu message: user created", sendmailScriptPath);

      }// END If the user to add exists
      else {
        UMSVishnuException e (ERRCODE_USERID_EXISTING);
        throw e;
      }
    } //END if the user is an admin
    else {
      UMSVishnuException e (ERRCODE_NO_ADMIN);
      throw e;
    }
  } //END if the user exists
  else {
    UMSVishnuException e (ERRCODE_UNKNOWN_USER);
    throw e;
  }
  return 0;
}//END: add(UMS_Data::User*& user)
Ejemplo n.º 11
0
/**
* \brief Function to check the user attribut value
* \fn bool isAttributOk(std::string attributName, int valueOk)
* \param attributName The name of the attribut to check
* \param valueOk the value which will be compare to attribut name value
* \return true if the attributName value is valueOk
*/
bool
UserServer::isAttributOk(std::string attributName, int valueOk) {
    return (convertToInt(getAttribut("where userid='"+muser.getUserId()+"'and "
    "pwd='"+muser.getPassword()+"'", attributName)) == valueOk);
}
Ejemplo n.º 12
0
/**
* \brief Function to check the VISHNU user privilege
* \fn bool isAdmin()
* \return true if the user is an admin else false
*/
bool
UserServer::isAdmin() {

    return (convertToInt (getAttribut("where userid='"+muser.getUserId()+"'and "
    "pwd='"+muser.getPassword()+"'", " privilege")) != 0);
}
Ejemplo n.º 13
0
/**
* \brief Function to update user information
* \fn int update(UMS_Data::User*& user)
* \param user The user data structure
* \return raises an exception on error
*/
int
UserServer::update(UMS_Data::User *user) {
  std::string sqlCommand = "";

  if (exist()) {
    if (isAdmin()) {
      //if the user whose information will be updated exists
      if (getAttribut("where userid='"+user->getUserId()+"'").size() != 0) {

        //if a new fisrtname has been defined
        if (user->getFirstname().size() != 0) {
          sqlCommand.append("UPDATE users SET firstname='"+user->getFirstname()+"'"
          " where userid='"+user->getUserId()+"';");
        }

        //if a new lastname has been defined
        if (user->getLastname().size() != 0) {
          sqlCommand.append("UPDATE users SET lastname='"+user->getLastname()+"'"
          " where userid='"+user->getUserId()+"';");
        }

        //if a new email has been defined
        if (user->getEmail().size() != 0) {
          sqlCommand.append("UPDATE users SET email='"+user->getEmail()+"'"
          " where userid='"+user->getUserId()+"';");
        }

        //If a new status has been defined
        if (user->getStatus() != UNDEFINED_VALUE) {
          //if the user will be locked
          if (user->getStatus() == 0) {
            //if the user is not already locked
            if (convertToInt(getAttribut("where userid='"+user->getUserId()+"'", "status")) != 0) {
              sqlCommand.append("UPDATE users SET status="+convertToString(user->getStatus())+""
              " where userid='"+user->getUserId()+"';");
            } //End if the user is not already locked
            else {
              UMSVishnuException e (ERRCODE_USER_ALREADY_LOCKED);
              throw e;
            }
          } //End if the user will be locked
          else {
            sqlCommand.append("UPDATE users SET status="+convertToString(user->getStatus())+""
            " where userid='"+user->getUserId()+"';");
          }
        }
        // if the user whose privilege will be updated is not an admin
        if (convertToInt(getAttribut("where userid='"+user->getUserId()+"'", "privilege")) != 1) {
          sqlCommand.append("UPDATE users SET privilege="+convertToString(user->getPrivilege())+""
          " where userid='"+user->getUserId()+"';");
        }

        //If there is a change
        if (!sqlCommand.empty()) {
          mdatabaseVishnu->process(sqlCommand.c_str());
        }
      } // End if the user whose information will be updated exists
      else {
        UMSVishnuException e (ERRCODE_UNKNOWN_USERID);
        throw e;
      }
    } //END if the user is an admin
    else {
      UMSVishnuException e (ERRCODE_NO_ADMIN);
      throw e;
    }
  } //END if the user exists
  else {
    UMSVishnuException e (ERRCODE_UNKNOWN_USER);
    throw e;
  }
  return 0;
} //END: update(UMS_Data::User *user)
Ejemplo n.º 14
0
int AKTinput(int len, char *buffer)
{
	extern AKTIONEN akt;
	extern AKTIONSGRP aktgrp;
	extern BEZEICHNUNG bez;
	extern TEXTE txt;
	extern AKTIONS_TYP aktt;
	extern STATUS_WERTE sta;
	extern int sprache;

	char *to_buffers[MAX_MENU_ITEMS];
	char tmp_buffer[RECLAENGE];
	char *buffer_ptr;
	int status=(int)MPOK;
	int buffersize;

	status = UtilSplitMenubuffer(buffer, to_buffers, (char)NULL);
	if (status != MPOK)
		{
		UtilMsg((int)MPE_CUTBUFFERIN, MSGTYP_ERROR, NULL);
		akt.akt_id=(int)_UNDEF;
		return((int)MPERROR);
		}

	if (ACTIONTYP == (unsigned char)INSERT)
		{
		akt.akt_id=(int)_UNDEF;
		akt.b_flag=(int)_UNDEF;
		akt.b2_flag=(int)_UNDEF;
		akt.textid=(int)_UNDEF;
		txt.textid=(int)_UNDEF;
		}

	/* AKTION */
	if (ACTIONTYP != INSERT && ACTIONTYP != UPDATE)
		{
		akt.akt_id=MPAPIselectEntry((int)_AKTIONEN, to_buffers[MAKT_BEZ],
		             (char *)&akt, sizeof(AKTIONEN), sizeof(akt.akt_id));
		if (akt.akt_id == (int)_UNDEF)
			{
			UtilMsg((int)MPE_NOENTRYFOUND, MSGTYP_ERROR, NULL);
			akt.akt_id=(int)_UNDEF;
			return((int)MPERROR);
			}
		}

	bez.s_id=(int)sprache;
	bez.typ=(int)_AKTIONEN;
	(void)copyTextTo(bez.bez, to_buffers[MAKT_BEZ], (int)_BEZLEN);
	if (*bez.bez != NULL)
		{
		if (*to_buffers[MAKT_AKTT] == NULL)
			akt.a_typ_id = (int)_UNDEF;
		else
			{
			akt.a_typ_id=(int)MPAPIselectEntry((int)_AKTIONS_TYP, to_buffers[MAKT_AKTT],
			          (char *)&aktt, sizeof(AKTIONS_TYP), sizeof(akt.a_typ_id));
			}

		if (*to_buffers[MAKT_STAAUS] == NULL)
			akt.a_flag = (int)_UNDEF;
		else
			{
			sta.typ = (int)_A_FLG;
			status = getAttribut((int)_A_FLG, to_buffers[MAKT_STAAUS]);
			if (status != (int)MPERROR)
				akt.a_flag=sta.sta_id;
			else
				{
				UtilMsg((int)MPE_NOSTA, MSGTYP_ERROR, NULL);
				akt.akt_id=(int)_UNDEF;
				UtilSplitFreeMenubuffer(to_buffers);
				return((int)MPERROR);
				}
			}

		if (*to_buffers[MAKT_STAINRES] == NULL)
			akt.b_flag = (int)_UNDEF;
		else
			{
			sta.typ = (int)_R_STA;
			status = getAttribut((int)_R_STA, to_buffers[MAKT_STAINRES]);
			if (status != (int)MPERROR)
				akt.b_flag=sta.sta_id;
			else
				{
				UtilMsg((int)MPE_NOSTA, MSGTYP_ERROR, NULL);
				akt.akt_id=(int)_UNDEF;
				UtilSplitFreeMenubuffer(to_buffers);
				return((int)MPERROR);
				}
			}

		if (*to_buffers[MAKT_STAOUTRES] == NULL)
			akt.b2_flag = (int)_UNDEF;
		else
			{
			sta.typ = (int)_R_STA;
			status = getAttribut((int)_R_STA, to_buffers[MAKT_STAOUTRES]);
			if (status != (int)MPERROR)
				akt.b2_flag=sta.sta_id;
			else
				{
				UtilMsg((int)MPE_NOSTA, MSGTYP_ERROR, NULL);
				akt.akt_id=(int)_UNDEF;
				UtilSplitFreeMenubuffer(to_buffers);
				return((int)MPERROR);
				}
			}

		if (*to_buffers[MAKT_STADEV] == NULL)
			akt.m_flag = (int)_UNDEF;
		else
			{
			sta.typ = (int)_DEVICE;
			status = getAttribut((int)_DEVICE, to_buffers[MAKT_STADEV]);
			if (status != (int)MPERROR)
				akt.m_flag=sta.sta_id;
			else
				{
				UtilMsg((int)MPE_NOSTA, MSGTYP_ERROR, NULL);
				akt.akt_id=(int)_UNDEF;
				UtilSplitFreeMenubuffer(to_buffers);
				return((int)MPERROR);
				}
			}

		txt.typ=(int)_AKTIONEN;
		txt.s_id=(int)sprache;
		txt.textid=akt.textid;
		akt.textid=xTxtWrite(to_buffers[MAKT_TXT]);

		status=WriteEntry((int)_AKTIONEN, (char *)&akt, &bez);
		if (status == (int)MPERROR)
			akt.akt_id=(int)_UNDEF;
		}
	else
		{
		UtilMsg((int)MPE_NOBEZ, MSGTYP_ERROR, NULL);
		akt.akt_id=(int)_UNDEF;
		status=(int)MPERROR;
		}

	UtilSplitFreeMenubuffer(to_buffers);
	return(status);
}
Ejemplo n.º 15
0
//fonction qui verifie le type de l'arbre
ClasseP evalType(TreeP t)
{
	TreeP tmp = NULL;

	if(t->type == INTEGER)
	{
		return getClasse("integer");
	}
	if(t->type == STRING)
	{
		return getClasse("string");
	}
	
	checkInstruction(t);
	
	switch(t->type) {
		case OP:
			if((!strcmp(evalType(getChild(t, 0))->nom, "integer")) && (!strcmp(evalType(getChild(t, 1))->nom, "integer")))
				return getClasse("integer");
			else
				return NULL;
			break;
		case CAT_STRUCT:
			if((!strcmp(evalType(getChild(t, 0))->nom, "string")) && (!strcmp(evalType(getChild(t, 1))->nom, "string")))
				return getClasse("string");
			else
				return NULL;
			break;
		case UNARY_STRUCT:
			if((!strcmp(evalType(getChild(t, 0))->nom, "integer")))
				return getClasse("integer");
			else
				return NULL;
			break;

		case DOT:
			if(getChild(t, 1)->nbChildren > 1) {
				tmp = getChild(getChild(t, 1), 0);
				if(tmp->type != VAR_STRUCT)
					return NULL;

				if(getAttribut(evalType(getChild(t, 0)), tmp->content.var->nom))
					return getClasse(tmp->content.var->type);
				else
					return NULL;
			}
			else {
				if(getChild(t, 1)->type != VAR_STRUCT)
					return NULL;
				if(getAttribut(evalType(getChild(t, 0)), getChild(t, 1)->content.var->nom))
					return getClasse(getChild(t, 1)->content.var->type);
				else
					return NULL;
			}
		case MTDCALL:
			if(getChild(t, 1)->nbChildren > 1) {
				tmp = getChild(getChild(t, 1), 0);
				if(tmp->type != MTD)
					return NULL;

				if(getMethode(evalType(getChild(t, 0)), tmp->content.meth->nom))
					return getClasse(tmp->content.meth->type);
				else
					return NULL;
			}
			else {
				if(getChild(t, 1)->type != MTD)
					return NULL;
				if(getMethode(evalType(getChild(t, 0)), getChild(t, 1)->content.meth->nom))
					return getClasse(getChild(t, 1)->content.meth->type);
				else
					return NULL;
			}
			break;
		default:
			return NULL;
	}
	
	return 0;
}