Beispiel #1
0
int
main(int argc,char *argv[],char *[])
{
    setlocale(LC_ALL,"");
    djvu_programname(argv[0]);
    G_TRY
    {
        int i;
        if (argc < 2)
            usage(argv[0]);
        for (i=1; i<argc; i++)
        {
            GURL djvufile;
            GURL *pdjvufile = 0;
            if (! strcmp(argv[i], "-o"))
            {
                if (++i >= argc)
                    usage(argv[0]);
                djvufile = GURL::Filename::Native(argv[i]);
                pdjvufile = &djvufile;
                if (! djvufile.is_file())
                    nofile(argv[i]);
                if (++i >= argc)
                    usage(argv[0]);
            }
            GURL xmlfile = GURL::Filename::Native(argv[i]);
            if (! xmlfile.is_file())
                nofile(argv[i]);
            GP<lt_XMLParser> parser(lt_XMLParser::create());
            GP<lt_XMLTags> tag(lt_XMLTags::create(xmlfile));
            parser->parse(*tag, pdjvufile);
            parser->save();
        }
    }
    G_CATCH(ex)
    {
        ex.perror();
        exit(1);
    }
    G_ENDCATCH;
    exit(0);
#ifdef WIN32
    return 0;
#endif
}
Beispiel #2
0
void senddata(const char *path, int sock) {
	char rpath[256];
	sprintf(rpath, ".%s", path);
	char *idx = index(rpath, '?');
	if (idx != NULL)
		*idx='\0';

	int fd = open(rpath, O_RDONLY);
	if (fd < 0) {
		nofile(sock, path);
	} else {
		char buf[1024*1024];	
		int bytes = read(fd, buf, sizeof(buf));
		if (bytes < 0) 
			nofile(sock, path);
		else {
			ok(sock, bytes);
			int ret = 0, send_bytes = 0;
			while (send_bytes < bytes && ret >= 0 )
				send_bytes += ret = send(sock, buf, bytes, MSG_NOSIGNAL);
		}
		close(fd);
	}
}