Exemplo n.º 1
0
PyObject *xmlsec_PtrListSet(PyObject *self, PyObject *args) {
  PyObject *list_obj, *item_obj;
  xmlSecPtrListPtr list;
  xmlSecSize pos;
  int ret;

  if (CheckArgs(args, "OOI:ptrListSet")) {
    if (!PyArg_ParseTuple(args, "OOi:ptrListSet", &list_obj, &item_obj, &pos))
      return NULL;
  }
  else return NULL;

  list = xmlSecPtrListPtr_get(list_obj);
  ret = xmlSecPtrListSet(list, xmlSecPtr_get(item_obj), pos);

  return (wrap_int(ret));
}
Exemplo n.º 2
0
/**
 * xmlSecKeysMngrAdoptDataStore:
 * @mngr:		the pointer to keys manager.
 * @store:		the pointer to data store.
 *
 * Adopts data store in the keys manager.
 *
 * Returns 0 on success or a negative value if an error occurs.
 */
int
xmlSecKeysMngrAdoptDataStore(xmlSecKeysMngrPtr mngr, xmlSecKeyDataStorePtr store) {
    xmlSecKeyDataStorePtr tmp;
    xmlSecSize pos, size;
    
    xmlSecAssert2(mngr != NULL, -1);
    xmlSecAssert2(xmlSecKeyDataStoreIsValid(store), -1);

    size = xmlSecPtrListGetSize(&(mngr->storesList));
    for(pos = 0; pos < size; ++pos) {
	tmp = (xmlSecKeyDataStorePtr)xmlSecPtrListGetItem(&(mngr->storesList), pos);
	if((tmp != NULL) && (tmp->id == store->id)) {	
	    return(xmlSecPtrListSet(&(mngr->storesList), store, pos));
	}
    }
    
    return(xmlSecPtrListAdd(&(mngr->storesList), store));
}
Exemplo n.º 3
0
/**
 * xmlSecKeyAdoptData:
 * @key:                the pointer to key.
 * @data:               the pointer to key data.
 *
 * Adds @data to the @key. The @data object will be destroyed
 * by @key.
 *
 * Returns: 0 on success or a negative value otherwise.
 */
int
xmlSecKeyAdoptData(xmlSecKeyPtr key, xmlSecKeyDataPtr data) {
    xmlSecKeyDataPtr tmp;
    xmlSecSize pos, size;

    xmlSecAssert2(key != NULL, -1);
    xmlSecAssert2(xmlSecKeyDataIsValid(data), -1);

    /* special cases */
    if(data->id == xmlSecKeyDataValueId) {
        if(key->value != NULL) {
            xmlSecKeyDataDestroy(key->value);
        }
        key->value = data;
        return(0);
    }

    if(key->dataList == NULL) {
        key->dataList = xmlSecPtrListCreate(xmlSecKeyDataListId);
        if(key->dataList == NULL) {
            xmlSecError(XMLSEC_ERRORS_HERE,
                        NULL,
                        "xmlSecPtrListCreate",
                        XMLSEC_ERRORS_R_XMLSEC_FAILED,
                        XMLSEC_ERRORS_NO_MESSAGE);
            return(-1);
        }
    }


    size = xmlSecPtrListGetSize(key->dataList);
    for(pos = 0; pos < size; ++pos) {
        tmp = (xmlSecKeyDataPtr)xmlSecPtrListGetItem(key->dataList, pos);
        if((tmp != NULL) && (tmp->id == data->id)) {
            return(xmlSecPtrListSet(key->dataList, data, pos));
        }
    }

    return(xmlSecPtrListAdd(key->dataList, data));
}