Exemplo n.º 1
0
UITableViewCell*	
	 UITableViewCell::init()
	{
		if(super::init())
		{
		if(style == UITableViewSylePlain)
			textLabel = CCLabelTTF::labelWithString("","Arial",38);
		else
			textLabel = CCLabelTTF::labelWithString("","Arial",38);
		setnode(textLabel);
		self->imageView =  UIImageView::alloc()->init();
		self->contentView =  UIView::alloc()->init();
		self->retain();
		self->accessoryType = UITableViewCellAccessoryDefault;
		self->indentationLevel = 0;
		self->indentationWidth = 10;
		self->indexPath = NSIndexPath::alloc()->init();
		}
		return self;
	}
Exemplo n.º 2
0
int processdir(int level, const char *base, const char *dirname, struct stat *sb,
               struct filenode *dir, struct filenode *root, int curroffset) {
    DIR *dirfd;
    struct dirent *dp;
    struct filenode *n, *link;
    struct excludes *pe;

    if(level <= 1) {
        /* Ok, to make sure . and .. are handled correctly
         * we add them first.  Note also that we alloc them
         * first to get to know the real name
         */
        link = newnode(base, ".", curroffset);

        if(!lstat(link->realname, sb)) {
            setnode(link, sb->st_dev, sb->st_ino, sb->st_mode);
            append(&dir->dirlist, link);

            /* special case for root node - '..'s in subdirs should link to
             *   '.' of root node, not root node itself.
             */
            dir->dirlist.owner = link;

            curroffset = alignnode(link, curroffset, 0) + spaceneeded(link);
            n = newnode(base, "..", curroffset);

            if(!lstat(n->realname, sb)) {
                setnode(n, sb->st_dev, sb->st_ino, sb->st_mode);
                append(&dir->dirlist, n);
                n->orig_link = link;
                curroffset = alignnode(n, curroffset, 0) + spaceneeded(n);
            }
        }
    }

    dirfd = opendir(dir->realname);

    while((dp = readdir(dirfd))) {
        /* don't process main . and .. twice */
        if(level <= 1 &&
                (strcmp(dp->d_name, ".") == 0
                 || strcmp(dp->d_name, "..") == 0))
            continue;

        n = newnode(base, dp->d_name, curroffset);

        /* Process exclude list. */
        for(pe = excludelist; pe; pe = pe->next) {
            if(!nodematch(pe->pattern, n)) {
                freenode(n);
                break;
            }
        }

        if(pe) continue;

        if(lstat(n->realname, sb)) {
            fprintf(stderr, "ignoring '%s' (lstat failed)\n", n->realname);
            freenode(n);
            continue;
        }

        /* Handle special names */
        if(n->name[0] == '@') {
            if(S_ISLNK(sb->st_mode)) {
                /* this is a link to follow at build time */
                n->name = n->name + 1; /* strip off the leading @ */
                memset(bigbuf, 0, sizeof(bigbuf));
                if(readlink(n->realname, bigbuf, sizeof(bigbuf))) {
                    return -1;
                }
                n->realname = strdup(bigbuf);

                if(lstat(n->realname, sb)) {
                    fprintf(stderr, "ignoring '%s' (lstat failed)\n",
                            n->realname);
                    freenode(n);
                    continue;
                }
            }
            else if(S_ISREG(sb->st_mode) && sb->st_size == 0) {
                /*
                 *        special file @name,[bcp..],major,minor
                 */
                char      devname[32];
                char      type;
                int       major;
                int       minor;

                if(sscanf(n->name, "@%[a-zA-Z0-9],%c,%d,%d",
                          devname, &type, &major, &minor) == 4) {
                    strcpy(n->name, devname);
                    sb->st_rdev = makedev(major, minor);
                    sb->st_mode &= ~S_IFMT;

                    switch(type) {
                        case 'c':
                        case 'u':
                            sb->st_mode |= S_IFCHR;
                            break;
                        case 'b':
                            sb->st_mode |= S_IFBLK;
                            break;
                        case 'p':
                            sb->st_mode |= S_IFIFO;
                            break;
                        default:
                            fprintf(stderr, "Invalid special device type '%c' "
                                    "for file %s\n", type, n->realname);
                            freenode(n);
                            continue;
                    }
                }
            }
        }

        setnode(n, sb->st_dev, sb->st_ino, sb->st_mode);

        /* Skip unreadable files/dirs */
        if(!S_ISLNK(n->modes) && access(n->realname, R_OK)) {
            fprintf(stderr, "ignoring '%s' (access failed)\n", n->realname);
            freenode(n);
            continue;
        }

        /* Look up old links */
        if(strcmp(n->name, ".") == 0) {
            append(&dir->dirlist, n);
            link = n->parent;
        }
        else if(strcmp(n->name, "..") == 0) {
            append(&dir->dirlist, n);
            link = n->parent->parent;
        }
        else {
            link = findnode(root, n->ondev, n->onino);
            append(&dir->dirlist, n);
        }

        if(link) {
            n->orig_link = link;
            curroffset = alignnode(n, curroffset, 0) + spaceneeded(n);
            continue;
        }

        if(S_ISREG(sb->st_mode)) {
            curroffset = alignnode(n, curroffset, spaceneeded(n));
            n->size = sb->st_size;
        }
        else
            curroffset = alignnode(n, curroffset, 0);

        if(S_ISLNK(sb->st_mode)) {
            n->size = sb->st_size;
        }

        curroffset += spaceneeded(n);

        if(S_ISCHR(sb->st_mode) || S_ISBLK(sb->st_mode)) {
            n->devnode = sb->st_rdev;
        }

        if(S_ISDIR(sb->st_mode)) {
            if(!strcmp(n->name, "..")) {
                curroffset = processdir(level + 1, dir->realname, dp->d_name,
                                        sb, dir, root, curroffset);
            }
            else {
                curroffset = processdir(level + 1, n->realname, dp->d_name,
                                        sb, n, root, curroffset);
            }

            if(curroffset < 0)
                return -1;
        }
    }

    closedir(dirfd);
    return curroffset;
}
Exemplo n.º 3
0
void get_info_by_linkname (const char * pid, const char * linkname) {
	if (strncmp(linkname, "socket:[", 8) == 0) {
		setnode(str2ulong(linkname + 8), str2int(pid));
	}
}