Exemple #1
0
static void add_depend(const char *source, set_t *incl, map_t *deps)
{
    set_t *mydeps;
    llnode_t *tmp;
    int i,num;

    if (source == NULL) return;

    mydeps = map_find(deps,source);
    if (mydeps != NULL) {
        num = mydeps->nbuckets;

        for (i = 0; i < num; ++i) {
            tmp = mydeps->buckets + i;
            while (tmp->next != NULL) {
                if (set_find(incl,tmp->key) == 0) {
                    set_add(incl,tmp->key);
                    add_depend(tmp->key,incl,deps);
                }
                tmp = tmp->next;
            }
        }
    }

}
Exemple #2
0
static void do_depend(llnode_t *head, map_t *deps)
{
    llnode_t *tmp, *lnk;
    set_t *incl;
    const char *source;
    char *target, *ptr;
    int i,num,ext;

    tmp = head;
    while (tmp->next != NULL) {
        source = tmp->key;
        target = strrchr(source,'/');
        if (target == NULL) {
            target = my_strdup(source);
        } else {
            target = my_strdup(target+1);
        }

        ext = 0;
        ptr = strrchr(target,'.');
        if (ptr != NULL) {
            for (i = 0; i < numextensions; ++i) {
                if (strcmp(ptr,extensions[i]) == 0) ++ext;
            }
            if (ext > 0) {
                ptr[1] = 'o';
                ptr[2] = '\0';
            }
        }

        if (ext > 0) {
            fputs(target,stdout);
            fputs(" : ",stdout);
            fputs(source,stdout);

            incl = set_init(50);
            add_depend(source,incl,deps);

            num = incl->nbuckets;
            for (i = 0; i < num; ++i) {
                lnk = incl->buckets + i;
                while (lnk->next != NULL) {
                    fputc(' ',stdout);
                    fputs(lnk->key,stdout);
                    lnk = lnk->next;
                }
            }
            fputc('\n',stdout);
            set_free(incl);
        }

        free((void *)target);
        tmp = tmp->next;
    }
}
Exemple #3
0
void dbmanager::png_finished(){
    qDebug()<<png_filename;
    if(png_network_reply->error() == QNetworkReply::NoError){


        png_file =  new QFile(imgpath+"/"+png_filename+".png");
        qDebug()<<imgpath+"/"+png_filename;
        if(!png_file->open(QIODevice::ReadWrite | QIODevice::Truncate)){
            qDebug() << png_file->errorString();
        }
        png_file->write(png_network_reply->readAll());

        QByteArray bytes = png_network_reply->readAll();
        QString str = QString::fromUtf8(bytes.data(), bytes.size());
        int statusCode = png_network_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
        qDebug() << QVariant(statusCode).toString();
    }
    png_file->flush();
    png_file->close();
    int total = png_down_links.count();
    if(png_curr<total-1){
        png_curr++;
        qDebug()<<"current = "<<png_curr<<"total = "<<total;
        png_download(png_down_links,png_hash);}
    else if(png_curr==total-1)
    {
        qDebug()<<"download complete";
        png_down_links.clear();
        png_hash.clear();
        image_png = false;
        clear_list();
    }

    bool success = false ;
    QString fname = png_filename;
    success = add_depend(fname,revision_number);
    if(success == true)
    {
        qDebug() <<"added in dependency table";
    }
    else
    {
        qDebug() << " error in adding to dependency table";
    }


}
Exemple #4
0
void dbmanager::downloadFinished(){
    qDebug()<<filename;
    if(m_network_reply->error() == QNetworkReply::NoError){

        // set filename and location to store the file  ( Generic location of application data )
        m_file =  new QFile(imgpath+"/"+filename+".svg");
        qDebug()<<imgpath+"/"+filename;
        if(!m_file->open(QIODevice::ReadWrite | QIODevice::Truncate)){
            qDebug() << m_file->errorString();
        }
        m_file->write(m_network_reply->readAll());

        QByteArray bytes = m_network_reply->readAll();
        QString str = QString::fromUtf8(bytes.data(), bytes.size());
        int statusCode = m_network_reply->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
        qDebug() << QVariant(statusCode).toString();
    }
    m_file->flush();
    m_file->close();
    // increment the counter on the basis of total number of files to download
    int total = down_links.count();
    if(current<total-1){
        current++;
        qDebug()<<"current = "<<current<<"total = "<<total;
        doDownload(down_links);}
    else if(current==total-1)
    {
        qDebug()<<"download complete";
        down_links.clear();
        math_svg = false;
        clear_list();
    }

    bool success = false ;
    QString fname = filename;
    success = add_depend(fname,revision_number); //  add the dependencies entry in database i.e. images
    if(success == true)
    {
        qDebug() <<"added in dependency table";
    }
    else
    {
        qDebug() << " error in adding to dependency table";
    }


}
/*
 * parse (pseudo) makefile
 *
 * it may have only the following form:
 *
 * TARGETS = xxx ...
 * INTERACTIVE = yyy ...
 * aaa:
 * bbb: xxx ddd ...
 *
 * other lines are ignored.
 */
void parse_makefile(const char *path)
{
	FILE *fp;
	char buf[LINE_MAX]; /* FIXME: is this enough big? */
	char *s, *strp, *p;
	struct makenode *node;

#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
	int fd;

	if (getuid() == (uid_t)0)
		o_flags |= O_NOATIME;
	if ((fd = open(path, o_flags)) < 0) {
		fprintf(stderr, "Can't open %s: %s\n", path, strerror(errno));
		exit(1);
	}
	(void)posix_fadvise(fd, 0, 0, POSIX_FADV_WILLNEED);
	(void)posix_fadvise(fd, 0, 0, POSIX_FADV_SEQUENTIAL);
	(void)posix_fadvise(fd, 0, 0, POSIX_FADV_NOREUSE);

	if ((fp = fdopen(fd, "r")) == NULL)
#else
	if ((fp = fopen(path, "r")) == NULL)
#endif
	{
		fprintf(stderr, "Can't open %s: %s\n", path, strerror(errno));
		exit(1);
	}

	while (fgets(buf, sizeof(buf), fp)) {
		for (s = buf; *s && isspace(*s); s++)
			;
		if (! *s || *s == '#')
			continue;
		if (! strncmp(s, "TARGETS =", 9)) {
			s += 9;
			strp = s;
			while ((s = strsep(&strp, DELIMITER))) {
				if (! *s)
					continue;
				add_target(s);
			}
		} else if (! strncmp(s, "INTERACTIVE =", 13)) {
			s += 13;
			strp = s;
			while ((s = strsep(&strp, DELIMITER))) {
				if (! *s)
					continue;
				mark_interactive(s);
			}
		} else {
			p = strchr(s, ':');
			if (! p)
				continue;
			*p = 0;
			node = add_target(s);
			strp = p + 1;
			while ((s = strsep(&strp, DELIMITER))) {
				if (! *s)
					continue;
				add_depend(node, s);
			}
		}
	}

#if defined _XOPEN_SOURCE && (_XOPEN_SOURCE - 0) >= 600
	(void)posix_fadvise(fd, 0, 0, POSIX_FADV_DONTNEED);
#endif

	fclose(fp);

	for (node = tree_list; node; node = node->next) {
		int importance = 0;

		if (! strcmp(node->name, "xdm")
		    || ! strncmp(node->name, "gdm", 3)
		    || ! strncmp(node->name, "kdm", 3)
		    || ! strcmp(node->name, "boot.udev")
		    || ! strcmp(node->name, "udev"))
			importance = 100;

		if (! strcmp(node->name, "sshd"))
			importance = 2000;

		if (! strncmp(node->name, "early", 5))
			importance = 8000;

		if (importance)
			add_importance(node, importance);
	}
}