PyObject* info( int type, const char *name) { PyObject* output = NULL; switch(type) { /* display requested info */ case TYPE: output = get_types(name, policy); break; case ATTRIBUTE: output = get_attribs(name, policy); break; case ROLE: output = get_roles(name, policy); break; case USER: output = get_users(name, policy); break; case CLASS: output = get_classes(name, policy); break; case BOOLEAN: output = get_booleans(name, policy); break; case PORT: output = get_ports(name, policy); break; default: errno = EINVAL; PyErr_SetString(PyExc_RuntimeError,strerror(errno)); break; } return output; }
int parse_conf(struct spkg_conf *pkg_conf) { pkg_conf->src_dir = NULL; pkg_conf->pkg_dir = NULL; pkg_conf->wrk_dir = NULL; pkg_conf->coll_curr = NULL; pkg_conf->coll_head = NULL; parse_pkgmk_conf(pkg_conf); parse_prtget_conf(pkg_conf); get_colls(pkg_conf); get_ports(pkg_conf); return 0; }
static int sw_serial_resume(struct platform_device *dev) { struct uart_port *port; int i; UART_MSG("sw_serial_resume SUPER_STANDBY resume\n"); UART_MSG("&dev->dev is 0x%x\n",&dev->dev); for (i = 0; i < MAX_PORTS; i++) { port=(struct uart_port *)get_ports(i); if (port->type != PORT_UNKNOWN){ UART_MSG("type is 0x%x PORT_UNKNOWN is 0x%x\n",port->type,PORT_UNKNOWN); UART_MSG("port.dev is 0x%x &dev->dev is 0x%x\n",port->dev,&dev->dev); } if ((port->type != PORT_UNKNOWN) && (port->dev == &dev->dev)) serial8250_resume_port(i); } return 0; }
static int sw_serial_suspend(struct platform_device *dev, pm_message_t state) { int i; struct uart_port *port; UART_MSG("sw_serial_suspend uart suspend\n"); UART_MSG("&dev->dev is 0x%x\n",&dev->dev); for (i = 0; i < MAX_PORTS; i++) { port=(struct uart_port *)get_ports(i); if (port->type != PORT_UNKNOWN){ UART_MSG("type is 0x%x PORT_UNKNOWN is 0x%x\n",port->type,PORT_UNKNOWN); UART_MSG("port.dev is 0x%x &dev->dev is 0x%x\n",port->dev,&dev->dev); } if ((port->type != PORT_UNKNOWN)&& (port->dev == &dev->dev)) serial8250_suspend_port(i); } return 0; }
int main(int argc, char **argv) { struct options_t opts; struct store_t *store; memset(&opts, 0, sizeof(opts)); set_portsdir(&opts); parse_opts(argc, argv, &opts); if (opts.update_db) mkdb(&opts); else if (opts.search_crit) { if (!s_exists()) errx(EX_USAGE, "Database does not exist, please create it first using the -u option"); if (!ISSET(SEARCH_BY_PFILE, opts.search_crit) && strstr(opts.outflds, "rawfiles") != NULL) errx(EX_USAGE, "-o rawfiles is specified without -f or -b"); parse_outflds(opts.outflds, opts.outflds_parsed); alloc_store(&store); s_search_start(store); filter_ports(store, &opts); display_ports(get_ports(store), &opts); s_search_end(store); free_store(store); } return 0; }
main() { unsigned long a, b, c, d; a = 0x80; b = 0x40; a |= b; c = a ^ b; printf("c: %lx, b: %lx\n", c, b); //a = 0xFFC0000000000000; a = 0x1; a <<= get_shift_bits(9); printf("%lx\n", a); get_ports(a); b = 0x1; b <<= get_shift_bits(8); a |= b; printf("%lx\n", a); get_ports(a); int i; //print_bits(a); /* print_bits(n); print_bits(0x1234567890ABCDEF); unsigned long i = 0xFEDCBA0987654321; printf("%lx\n", i); printf("%#010x\n", i); printf("0x%08x\n", i); // gives 0x00000007 printf("%#08x\n", i); // gives 0x000007 */ //print_bits(c); //long b = 0xFFFFFFFFFFFFFF; //a = a >> 1; //printf("size: %d\n", sizeof(unsigned long)); //printf("%x\n",a<<3); //printf("%u\n",a); /* char name[10]; char scan[10]; int port = 0; int ret = 0; ret = sscanf("br40", "swp%d", &port); printf("ret: %d, port: %d", ret, port); */ }
int nfs_mount(const char *pathname, const char *hostname, uint32_t server, const char *rem_path, const char *path, struct nfs_mount_data *data) { struct client *clnt = NULL; struct sockaddr_in addr; char mounted = 0; int sock = -1; int ret = 0; int mountflags; if (get_ports(server, data) != 0) goto bail; dump_params(server, rem_path, data); if (data->flags & NFS_MOUNT_TCP) clnt = tcp_client(server, mount_port, CLI_RESVPORT); else clnt = udp_client(server, mount_port, CLI_RESVPORT); if (clnt == NULL) goto bail; if (data->flags & NFS_MOUNT_VER3) ret = mount_v3(rem_path, data, clnt); else ret = mount_v2(rem_path, data, clnt); if (ret == -1) goto bail; mounted = 1; if (data->flags & NFS_MOUNT_TCP) sock = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); else sock = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP); if (sock == -1) { perror("socket"); goto bail; } if (bindresvport(sock, 0) == -1) { perror("bindresvport"); goto bail; } addr.sin_family = AF_INET; addr.sin_addr.s_addr = server; addr.sin_port = htons(nfs_port); memcpy(&data->addr, &addr, sizeof(data->addr)); strncpy(data->hostname, hostname, sizeof(data->hostname)); data->fd = sock; mountflags = (data->flags & NFS_MOUNT_KLIBC_RONLY) ? MS_RDONLY : 0; data->flags = data->flags & NFS_MOUNT_FLAGMASK; ret = mount(pathname, path, "nfs", mountflags, data); if (ret == -1) { if (errno == ENODEV) { fprintf(stderr, "mount: the kernel lacks NFS v%d " "support\n", (data->flags & NFS_MOUNT_VER3) ? 3 : 2); } else { perror("mount"); } goto bail; } dprintf("Mounted %s on %s\n", pathname, path); goto done; bail: if (mounted) { if (data->flags & NFS_MOUNT_VER3) umount_v3(path, clnt); else umount_v2(path, clnt); } ret = -1; done: if (clnt) client_free(clnt); if (sock != -1) close(sock); return ret; }