Esempio n. 1
0
PyObject *
packagelist_to_pylist(HyPackageList plist, PyObject *sack)
{
    HyPackage cpkg;
    PyObject *list;
    PyObject *retval;

    list = PyList_New(0);
    if (list == NULL)
	return NULL;
    retval = list;

    int i;
    FOR_PACKAGELIST(cpkg, plist, i) {
	PyObject *package = new_package(sack, package_id(cpkg));
	if (package == NULL) {
	    retval = NULL;
	    break;
	}

	int rc = PyList_Append(list, package);
	Py_DECREF(package);
	if (rc == -1) {
	    retval = NULL;
	    break;
	}
    }
Esempio n. 2
0
int
pkgfs_init(const char *pkgname, struct fs_ops *proto)
{
	struct package *pkg;
	int error, fd;

	if (proto != &pkgfs_fsops)
		pkgfs_cleanup();

	exclusive_file_system = proto;

	fd = open(pkgname, O_RDONLY);

	exclusive_file_system = NULL;

	if (fd == -1)
		return (errno);

	error = new_package(fd, &pkg);
	if (error) {
		close(fd);
		return (error);
	}

	if (pkg == NULL)
		return (EDOOFUS);

	pkg->pkg_chain = package;
	package = pkg;
	exclusive_file_system = &pkgfs_fsops;
	return (0);
}
Esempio n. 3
0
PyObject *
packageset_to_pylist(DnfPackageSet *pset, PyObject *sack)
{
    PyObject *list = PyList_New(0);
    if (list == NULL)
        return NULL;

    const int count = dnf_packageset_count(pset);
    Id id = -1;
    for (int i = 0; i < count; ++i) {
        id = dnf_packageset_get_pkgid(pset, i, id);
        PyObject *package = new_package(sack, id);
        if (package == NULL)
            goto fail;

        int rc = PyList_Append(list, package);
        Py_DECREF(package);
        if (rc == -1)
            goto fail;
    }

    return list;
 fail:
    Py_DECREF(list);
    return NULL;
}
Esempio n. 4
0
PyObject *
packagelist_to_pylist(GPtrArray *plist, PyObject *sack)
{
    DnfPackage *cpkg;
    PyObject *list;
    PyObject *retval;

    list = PyList_New(0);
    if (list == NULL)
        return NULL;
    retval = list;

    for (unsigned int i = 0; i < plist->len; i++) {
        cpkg = g_ptr_array_index (plist, i);
        PyObject *package = new_package(sack, dnf_package_get_id(cpkg));
        if (package == NULL) {
            retval = NULL;
            break;
        }

        int rc = PyList_Append(list, package);
        Py_DECREF(package);
        if (rc == -1) {
            retval = NULL;
            break;
        }
    }
    if (retval)
        return retval;
    /* return error */
    Py_DECREF(list);
    return NULL;
}
Esempio n. 5
0
static PyObject *
create_package(_SackObject *self, PyObject *solvable_id)
{
    Id id  = PyLong_AsLong(solvable_id);
    if (id <= 0) {
        PyErr_SetString(PyExc_TypeError, "Expected a positive integer.");
        return NULL;
    }
    return new_package((PyObject*)self, id);
}
Esempio n. 6
0
static PyObject *
get_running_kernel(_SackObject *self, PyObject *unused)
{
    DnfSack *sack = self->sack;
    DnfPackage *cpkg = dnf_sack_get_running_kernel(sack);

    if (cpkg == NULL)
        Py_RETURN_NONE;
    PyObject *pkg = new_package((PyObject*)self, dnf_package_get_id(cpkg));
    g_object_unref(cpkg);
    return pkg;
}
Esempio n. 7
0
void t_write(void* sock)
{
    int* sockfd = (int*) &sock;
    size_t number_of_bytes;
    char buffer[BUFFER_SIZE];
    char *message = (char *)malloc(BUFFER_SIZE);
    int error = 0;
    char destiny[7];
    char data[80];
    
    while(1)
    {
        printf("%s>", user);
        scanf("%s", buffer);
        if (strncasecmp(buffer, "connect", 7) == 0)
        {
            package send_msn = new_package(user, "server", 'C', "CONEXION");
            message = prepare_to_send(send_msn);
        }
        else if (strncasecmp(buffer, "exit", 4) == 0)
        {
            package send_msn = new_package(user, "server", 'Q', "QUIT");
            message = prepare_to_send(send_msn);
        }
        else if (strncasecmp(buffer, "show", 10) == 0)
        {
            scanf("%s", destiny);
            package send_msn = new_package(user, "server", 'L', "PETICION LISTA USUARIOS");
            message = prepare_to_send(send_msn);
        }
        else if (strncasecmp(buffer, "send", 4) == 0)
        {
            scanf("%s", destiny);
            fgets(data, 80, stdin);
            package send_msn = new_package(user, destiny, 'S', data);
            message = prepare_to_send(send_msn);
        }
        else if (strncasecmp(buffer, "broadcast", 9) == 0)
        {
            fgets(data, 80, stdin);
            package send_msn = new_package(user, "server", 'B', data);
            message = prepare_to_send(send_msn);
        }else{
            package send_msn = new_package(user, "server", 'E', "Error. El comando no existe");
            message = prepare_to_send(send_msn);
            printf("Error.El comando no existe.\n");
            error =1;
        }
        number_of_bytes = write(*sockfd, message, BUFFER_SIZE);
        
        /*if (number_of_bytes < 0)
        {
        panic_with_system_message("Error al escribir datos en el servidor.");
        }*/
        
    }
    pthread_exit(0);
}
Esempio n. 8
0
static PyObject *
add_cmdline_package(_SackObject *self, PyObject *fn_obj)
{
    DnfPackage *cpkg;
    PyObject *pkg;
    PycompString fn(fn_obj);

    if (!fn.getCString())
        return NULL;
    cpkg = dnf_sack_add_cmdline_package_nochecksum(self->sack, fn.getCString());
    if (cpkg == NULL) {
        PyErr_Format(PyExc_IOError, "Can not load RPM file: %s.", fn.getCString());
        return NULL;
    }
    pkg = new_package((PyObject*)self, dnf_package_get_id(cpkg));
    g_object_unref(cpkg);
    return pkg;
}
Esempio n. 9
0
static PyObject *
add_cmdline_package(_SackObject *self, PyObject *fn_obj)
{
    HifPackage *cpkg;
    PyObject *pkg;
    PyObject *tmp_py_str = NULL;
    const char *fn = pycomp_get_string(fn_obj, &tmp_py_str);

    if (fn == NULL) {
        Py_XDECREF(tmp_py_str);
        return NULL;
    }
    cpkg = hif_sack_add_cmdline_package(self->sack, fn);
    Py_XDECREF(tmp_py_str);
    if (cpkg == NULL) {
        PyErr_Format(PyExc_IOError, "Can not load RPM file: %s.", fn);
        return NULL;
    }
    pkg = new_package((PyObject*)self, hif_package_get_id(cpkg));
    g_object_unref(cpkg);
    return pkg;
}
Esempio n. 10
0
static void handle_one_cpu(unsigned int number, char *vendor, int family, int model)
{
	char filename[1024];
	ifstream file;
	unsigned int package_number = 0;
	unsigned int core_number = 0;
	class abstract_cpu *package, *core, *cpu;

	sprintf(filename, "/sys/devices/system/cpu/cpu%i/topology/core_id", number);
	file.open(filename, ios::in);
	if (file) {
		file >> core_number;
		file.close();
	}

	sprintf(filename, "/sys/devices/system/cpu/cpu%i/topology/physical_package_id", number);
	file.open(filename, ios::in);
	if (file) {
		file >> package_number;
		if (package_number == (unsigned int) -1)
			package_number = 0;
		file.close();
	}


	if (system_level.children.size() <= package_number)
		system_level.children.resize(package_number + 1, NULL);

	if (!system_level.children[package_number]) {
		system_level.children[package_number] = new_package(package_number, number, vendor, family, model);
		system_level.childcount++;
	}

	package = system_level.children[package_number];
	package->parent = &system_level;

	if (package->children.size() <= core_number)
		package->children.resize(core_number + 1, NULL);

	if (!package->children[core_number]) {
		package->children[core_number] = new_core(core_number, number, vendor, family, model);
		package->childcount++;
	}

	core = package->children[core_number];
	core->parent = package;

	if (core->children.size() <= number)
		core->children.resize(number + 1, NULL);
	if (!core->children[number]) {
		core->children[number] = new_cpu(number, vendor, family, model);
		core->childcount++;
	}

	cpu = core->children[number];
	cpu->parent = core;

	if (number >= all_cpus.size())
		all_cpus.resize(number + 1, NULL);
	all_cpus[number] = cpu;
}