Exemple #1
0
int main(void) {
  char *mode, *name, *value;

  mode = qValue("mode");
  name = qValue("cname");
  value = qValue("cvalue");

  if(mode == NULL) { /* View Cookie */
    int amount;
    qContentType("text/html");
    amount = qPrint();
    printf("<p>Total %d entries\n", amount);
  }
  else if(!strcmp(mode, "set")) { /* Set Cookie */
    if(name == NULL || value == NULL) qError("Query not found");
    if(!strcmp(name, "")) qError("Empty cookie name can not be stored.");

    qCookieSet(name, value, 0, NULL, NULL, NULL);
    qContentType("text/html");
    printf("Cookie('%s'='%s') entry is stored.<br>Click <a href='%s'>here</a> to view your cookies\n", name, value, qCGIname());
  }
  else if(!strcmp(mode, "remove")) { /* Remove Cookie */
    if(name == NULL) qError("Query not found");
    if(!strcmp(name, "")) qError("Empty cookie name can not be removed.");

    qCookieRemove(name, NULL, NULL, NULL);
    qContentType("text/html");
    printf("Cookie('%s') entry is removed.<br>Click <a href='%s'>here</a> to view your cookies\n", name, qCGIname());
  }
  else qError("Unknown mode.");

  qFree();
  return 0;
}
Exemple #2
0
int main(void) {
  char *sessionid;
  char *mode, *name, *value;
  time_t expire;

  /* fetch queries */
  expire = (time_t)qiValue("expire");
  mode   = qValueNotEmpty("Mode not found", "mode");
  name   = qValue("name");
  value  = qValue("value");

  /* Set valid interval of this session */
  /* start session. this function should be called before qContentType(). */
  qSession(NULL);
  sessionid = qSessionGetID();

  /* Mose case, you don't need to set timeout but we use it here to give you a show case */
  if(expire > 0) qSessionSetTimeout(expire);

  switch(mode[0]) {
    case 's': {
      qSessionAdd(name, value);
      break;
    }
    case 'i': {
      qSessionAddInteger(name, atoi(value));
      break;
    }
    case 'r': {
      qSessionRemove(name);
      break;
    }
    case 'd': {
      qSessionDestroy();
      qContentType("text/html");
      printf("Session destroied.");
      return 0;
      break;
    }
  }

  /* screen out */
  qContentType("text/html");
  qSessionPrint();

  /* save session & free allocated memories */
  qSessionFree();
  return 0;
}
nv_math::quatf VkeAnimationChannel::currentQuatValue(){


	VkeAnimationKeyPair pair;
	double curTime = m_parent->getCurrentTime();
	m_keys.getKeys(curTime, &pair);

	//no keys found at all for this time.
	//Therefore there should not have been a channel
	//for this node in the first place.
    if (!pair.low && !pair.high) return nv_math::quatf();
	if (!pair.high){
		nv_math::vec4f vValue = pair.low->getValue();
		nv_math::quatf qValue(vValue.x, vValue.y, vValue.z, vValue.w);
		return qValue;

	}
	if (!pair.low){
		nv_math::vec4f vValue = pair.high->getValue();
		nv_math::quatf qValue(vValue.x, vValue.y, vValue.z, vValue.w);
		return qValue;

	}

	double timeDelta = pair.high->getTime() - pair.low->getTime();
    if (timeDelta == 0.0) return (nv_math::quatf)pair.low->getValue();

	double durationDelta = curTime - pair.low->getTime();

	double timeScale = durationDelta / timeDelta;

	nv_math::vec4f lowVal = pair.low->getValue();
	nv_math::vec4f highVal = pair.high->getValue();

	nv_math::quatf quatA(lowVal.x, lowVal.y, lowVal.z, lowVal.w);
	nv_math::quatf quatB(highVal.x, highVal.y, highVal.z, highVal.w);

	nv_math::quatf outQuat = cubicLerp(quatA, quatB, timeScale);

	return outQuat;
}
/**********************************************
** Usage : qValueAdd(name, value);
** Do    : Force to add given name and value to linked list.
**         If same name exists, it'll be replaced.
**
** ex) qValueAdd("NAME", "Seung-young Kim");
**********************************************/
char *qValueAdd(char *name, char *format, ...) {
    Q_Entry *new_entry;
    char    value[1024];
    int     status;
    va_list arglist;

    if (!strcmp(name, "")) qError("qValueAdd(): can not add empty name.");

    va_start(arglist, format);
    status = vsprintf(value, format, arglist);
    if ((strlen(value) + 1 > sizeof(value)) || (status == EOF)) qError("qValueAdd(): Message is too long or invalid.");
    va_end(arglist);

    if (_first_entry == NULL) qDecoder();

    if (qValue(name) == NULL) _new_cnt++; // if it's new entry, count up.
    new_entry = _EntryAdd(_first_entry, name, value);
    if (!_first_entry) _first_entry = new_entry;

    return qValue(name);
}
Exemple #5
0
void ServiceDB::ProcessIntChange(const char * key, uint32 oldValue, uint32 newValue, PyDict * notif, std::vector<std::string> & dbQ) {
    if (oldValue != newValue) {
        // add to notification
        PyTuple * val = new PyTuple(2);
        std::string qValue(key);

        val->items[0] = new PyInt(oldValue);
        val->items[1] = new PyInt(newValue);
        notif->SetItemString(key, val);

        char cc[10];
        snprintf(cc, 9, "%u", newValue);
        qValue += " = ";
        qValue += cc;
        dbQ.push_back(qValue);
    }
}
Exemple #6
0
void ServiceDB::ProcessRealChange(const char * key, double oldValue, double newValue, PyDict * notif, std::vector<std::string> & dbQ) {
    if (oldValue != newValue) {
        // add to notification
        std::string qValue(key);

        PyTuple * val = new PyTuple(2);
        val->items[0] = new PyFloat(oldValue);
        val->items[1] = new PyFloat(newValue);
        notif->SetItemString(key, val);

        char cc[10];
        snprintf(cc, 9, "'%5.3lf'", newValue);
        qValue += " = ";
        qValue += cc;
        dbQ.push_back(qValue);
    }
}
Exemple #7
0
void ServiceDB::ProcessStringChange(const char * key, const std::string & oldValue, const std::string & newValue, PyDict * notif, std::vector<std::string> & dbQ) {
    if (oldValue != newValue) {
        std::string newEscValue;
        std::string qValue(key);

        DBcore::DoEscapeString(newEscValue, newValue);

        // add to notification
        PyTuple * val = new PyTuple(2);
        val->items[0] = new PyString(oldValue);
        val->items[1] = new PyString(newValue);
        notif->SetItemString(key, val);

        qValue += " = '" + newEscValue + "'";
        dbQ.push_back(qValue);
    }
}