예제 #1
0
/*********************************************************
*函数名:    Print()
*函数功能:  输入单个图书的全部信息
*
*函数参数:  void
*函数返回值:void
*********************************************************/
void Book::Print()
{
    cout <<  GetISBN()  << '\t'  << GetTitle() << '\t';
    cout << GetAuthor() << '\t'  << GetPublisher() << '\t';
    cout << GetDate() << '\t' << GetPrice();
    cout << setw(10) << GetCatalogNum() << setw(11) << GetNumber() << endl;
}
예제 #2
0
	Item* RSS091Parser::ParseItem (const QDomElement& item,
			const IDType_t& channelId) const
	{
		Item *result = new Item (channelId);
		result->Title_ = UnescapeHTML (item.firstChildElement ("title").text ());
		if (result->Title_.isEmpty ())
			result->Title_ = "<>";
		result->Link_ = item.firstChildElement ("link").text ();
		result->Description_ = item.firstChildElement ("description").text ();
		GetDescription (item, result->Description_);
		result->PubDate_ = RFC822TimeToQDateTime (item.firstChildElement ("pubDate").text ());
		if (!result->PubDate_.isValid () || result->PubDate_.isNull ())
		{
			qWarning () << "Aggregator RSS 0.91: Can't parse item pubDate: "
					<< item.firstChildElement ("pubDate").text ();
			result->PubDate_ = QDateTime::currentDateTime ();
		}
		result->Guid_ = item.firstChildElement ("guid").text ();
		if (result->Guid_.isEmpty ())
			result->Guid_ = "empty";
		result->Categories_ = GetAllCategories (item);
		result->Unread_ = true;
		result->Author_ = GetAuthor (item);
		result->NumComments_ = GetNumComments (item);
		result->CommentsLink_ = GetCommentsRSS (item);
		result->CommentsPageLink_ = GetCommentsLink (item);
		result->Enclosures_ = GetEnclosures (item, result->ItemID_);
		result->Enclosures_ += GetEncEnclosures (item, result->ItemID_);
		QPair<double, double> point = GetGeoPoint (item);
		result->Latitude_ = point.first;
		result->Longitude_ = point.second;
		return result;
	}
예제 #3
0
Item* Atom10Parser::ParseItem (const QDomElement& entry,
                               const IDType_t& channelId) const
{
    Item *item = new Item (channelId);

    item->Title_ = entry.firstChildElement ("title").text ();
    item->Link_ = GetLink (entry);
    item->Guid_ = entry.firstChildElement ("id").text ();
    item->PubDate_ = FromRFC3339 (entry.firstChildElement ("updated").text ());
    item->Unread_ = true;
    item->Categories_ = GetAllCategories (entry);
    item->Author_ = GetAuthor (entry);
    item->NumComments_ = GetNumComments (entry);
    item->CommentsLink_ = GetCommentsRSS (entry);
    item->CommentsPageLink_ = GetCommentsLink (entry);

    QDomElement summary = entry.firstChildElement ("content");
    if (summary.isNull ())
        summary = entry.firstChildElement ("summary");
    item->Description_ = ParseEscapeAware (summary);
    GetDescription (entry, item->Description_);

    item->Enclosures_ = GetEnclosures (entry, item->ItemID_);
    item->Enclosures_ += GetEncEnclosures (entry, item->ItemID_);

    QPair<double, double> point = GetGeoPoint (entry);
    item->Latitude_ = point.first;
    item->Longitude_ = point.second;
    item->MRSSEntries_ = GetMediaRSS (entry, item->ItemID_);

    return item;
}
예제 #4
0
channels_container_t Atom10Parser::Parse (const QDomDocument& doc,
        const IDType_t& feedId) const
{
    channels_container_t channels;
    Channel_ptr chan (new Channel (feedId));
    channels.push_back (chan);

    QDomElement root = doc.documentElement ();
    chan->Title_ = root.firstChildElement ("title").text ().trimmed ();
    if (chan->Title_.isEmpty ())
        chan->Title_ = QObject::tr ("(No title)");
    chan->LastBuild_ = FromRFC3339 (root.firstChildElement ("updated").text ());
    chan->Link_ = GetLink (root);
    chan->Description_ = root.firstChildElement ("subtitle").text ();
    chan->Author_ = GetAuthor (root);
    if (chan->Author_.isEmpty ())
    {
        QDomElement author = root.firstChildElement ("author");
        chan->Author_ = author.firstChildElement ("name").text () +
                        " (" +
                        author.firstChildElement ("email").text () +
                        ")";
    }
    chan->Language_ = "<>";

    QDomElement entry = root.firstChildElement ("entry");
    while (!entry.isNull ())
    {
        chan->Items_.push_back (Item_ptr (ParseItem (entry, chan->ChannelID_)));
        entry = entry.nextSiblingElement ("entry");
    }

    return channels;
}
예제 #5
0
파일: cvexport.c 프로젝트: behnam/fontforge
int _ExportEPS(FILE *eps,SplineChar *sc, int layer, int preview) {
    DBounds b;
    time_t now;
    struct tm *tm;
    int ret;
    char oldloc[24];
    const char *author = GetAuthor();

    strcpy( oldloc,setlocale(LC_NUMERIC,NULL) );
    setlocale(LC_NUMERIC,"C");

    fprintf( eps, "%%!PS-Adobe-3.0 EPSF-3.0\n" );
    SplineCharLayerFindBounds(sc,layer,&b);
    fprintf( eps, "%%%%BoundingBox: %g %g %g %g\n", (double) b.minx, (double) b.miny, (double) b.maxx, (double) b.maxy );
    fprintf( eps, "%%%%Pages: 0\n" );
    fprintf( eps, "%%%%Title: %s from %s\n", sc->name, sc->parent->fontname );
    fprintf( eps, "%%%%Creator: FontForge\n" );
    if ( author!=NULL )
	fprintf( eps, "%%%%Author: %s\n", author);
    time(&now);
    tm = localtime(&now);
    fprintf( eps, "%%%%CreationDate: %d:%02d %d-%d-%d\n", tm->tm_hour, tm->tm_min,
	    tm->tm_mday, tm->tm_mon+1, 1900+tm->tm_year );
    if ( sc->parent->multilayer ) {
	int ly, had_grad=0, had_pat=0;
	for ( ly=ly_fore; ly<sc->layer_cnt; ++ly ) {
	    if ( sc->layers[ly].fill_brush.gradient!=NULL || sc->layers[ly].stroke_pen.brush.gradient!=NULL ) {
		had_grad = true;
	break;
	    }
	    if ( sc->layers[ly].fill_brush.gradient!=NULL || sc->layers[ly].stroke_pen.brush.gradient!=NULL )
		had_pat = true;
	}
	if ( had_grad )
	    fprintf( eps, "%%%%LanguageLevel: 3\n" );
	else if ( had_pat )
	    fprintf( eps, "%%%%LanguageLevel: 2\n" );
    }
    fprintf( eps, "%%%%EndComments\n" );
    if ( preview )
	EpsGeneratePreview(eps,sc,layer,&b);
    fprintf( eps, "%%%%EndProlog\n" );
    fprintf( eps, "%%%%Page \"%s\" 1\n", sc->name );

    fprintf( eps, "gsave newpath\n" );
    SC_PSDump((void (*)(int,void *)) fputc,eps,sc,true,false,layer);
    if ( sc->parent->multilayer )
	fprintf( eps, "grestore\n" );
    else
    if ( sc->parent->strokedfont )
	fprintf( eps, "%g setlinewidth stroke grestore\n", (double) sc->parent->strokewidth );
    else
	fprintf( eps, "fill grestore\n" );
    fprintf( eps, "%%%%EOF\n" );
    ret = !ferror(eps);
    setlocale(LC_NUMERIC,oldloc);
return( ret );
}
예제 #6
0
			Item* RSS20Parser::ParseItem (const QDomElement& item,
					const IDType_t& channelId) const
			{
				Item *result = new Item (channelId);
				result->Title_ = UnescapeHTML (item.firstChildElement ("title").text ());
				if (result->Title_.isEmpty ())
					result->Title_ = "<>";
				result->Link_ = item.firstChildElement ("link").text ();

				result->Description_ = item.firstChildElement ("description").text ();
				GetDescription (item, result->Description_);

				QDomNodeList duration = item.elementsByTagNameNS (ITunes_, "duration");
				if (duration.size ())
				{
					if (!result->Description_.isEmpty ())
						result->Description_ += "<br /><br />";
					result->Description_ += QObject::tr ("Duration: %1")
						.arg (duration.at (0).toElement ().text ());
				}

				QString pubDateText = item.firstChildElement ("pubDate").text ();
				if (pubDateText.size ())
				{
					result->PubDate_ = RFC822TimeToQDateTime (pubDateText);
					if (!result->PubDate_.isValid () || result->PubDate_.isNull ())
						result->PubDate_ = QDateTime::currentDateTime ();
				}

				result->Guid_ = item.firstChildElement ("guid").text ();
				if (result->Guid_.isEmpty ())
					result->Guid_ = "empty";
				result->Categories_ = GetAllCategories (item);
				result->Unread_ = true;
				result->Author_ = GetAuthor (item);
				result->NumComments_ = GetNumComments (item);
				result->CommentsLink_ = GetCommentsRSS (item);
				result->CommentsPageLink_ = GetCommentsLink (item);
				result->Enclosures_ = GetEnclosures (item, result->ItemID_);
				result->Enclosures_ += GetEncEnclosures (item, result->ItemID_);
				QPair<double, double> point = GetGeoPoint (item);
				result->Latitude_ = point.first;
				result->Longitude_ = point.second;
				result->MRSSEntries_ = GetMediaRSS (item, result->ItemID_);
				return result;
			}
예제 #7
0
// OutputToStream()
//  Outputs an ImageData instance as ASCII text to the stream provided.
void ImageData::OutputToStream( ostream &out ) {
  out << " Filename:             \"" << GetFilename() << "\"" << endl;
  out << "  File Format:         " << GetFileFormat() << "; \"" << ImageFileFormatStrings[ GetFileFormat() ] << "\"" << endl;
  out << "  File Size:           " << GetFileSize() << " bytes " << endl;
  out << endl;
  out << " File Data:" << endl;
  out << "  Bits Per Pixel:      " << GetBitsPerPixel() << endl;
  out << "  Compression:         " << GetCompression() << "; \"" << ImageCompressionModeStrings[ GetCompression() ] << "\"" << endl;
  out << "  DPI X/Y:             " << GetDPIX() << "/" <<  GetDPIY() << endl;
  out << "  Pixel Aspect Ration: " << GetPixelAspectNum() << "/" <<  GetPixelAspectDenom() << endl;
  out << "  Gamma Correction:    " << GetGammaNum() << "/" <<  GetGammaDenom() << endl;
  out << "  Thumbnail:           ";
  if( GetThumbnail() == NULL )
    out << "No" << endl;
  else
    out << "Yes" << endl;

  out << endl;
  out << " Creator Data:" << endl;
  out << "  Author:              \"" << GetAuthor() << "\"" << endl;
  out << "  Creator Program:     \"" << GetCreator() << "\"" << endl;
  out << "  Creator Version:     "   << GetCreatorVersion() << "." << GetCreatorRevision() << GetCreatorSubRev() << endl;
  out << "  Comment:             \"" << GetComment() << "\"" << endl;
  out << "  Job Name:            \"" << GetJobName() << "\"" << endl;
  out << "  Job Time:            "   << GetJobTime()[0] << ":" << GetJobTime()[1] << ":" << GetJobTime()[2] << endl;
  out << "  Date Stamp:          "   << GetDateStamp()[0] << "/" << GetDateStamp()[1] << "/" << GetDateStamp()[2] << "  "
                                     << GetDateStamp()[3] << ":" << GetDateStamp()[4] << ":" << GetDateStamp()[5] << endl;
  out << endl;

  out << " Image Data:" << endl;
  out << "  Width:               " << GetImage()->GetWidth() << endl;
  out << "  Height:              " << GetImage()->GetHeight() << endl;
  out << "  Type:                " << GetImage()->GetType() << "; \"" << ImageTypeStrings[ GetImage()->GetType() ] << "\"" << endl;
  out << "  Num Registers:       ";
  if( GetImage()->GetType() == IMAGE_INDEXED )
    out << GetImage()->GetNumRegisters() << endl;
  else
    out << "N/A" << endl;

}
예제 #8
0
			channels_container_t RSS20Parser::Parse (const QDomDocument& doc,
					const IDType_t& feedId) const
			{
				channels_container_t channels;
				QDomElement root = doc.documentElement ();
				QDomElement channel = root.firstChildElement ("channel");
				while (!channel.isNull ())
				{
					Channel_ptr chan (new Channel (feedId));
					chan->Title_ = channel.firstChildElement ("title").text ().trimmed ();
					chan->Description_ = channel.firstChildElement ("description").text ();
					chan->Link_ = GetLink (channel);
					chan->LastBuild_ = RFC822TimeToQDateTime (channel.firstChildElement ("lastBuildDate").text ());
					chan->Language_ = channel.firstChildElement ("language").text ();
					chan->Author_ = GetAuthor (channel);
					if (chan->Author_.isEmpty ())
						chan->Author_ = channel.firstChildElement ("managingEditor").text ();
					if (chan->Author_.isEmpty ())
						chan->Author_ = channel.firstChildElement ("webMaster").text ();
					chan->PixmapURL_ = channel.firstChildElement ("image").attribute ("url");
			
					QDomElement item = channel.firstChildElement ("item");
					while (!item.isNull ())
					{
						chan->Items_.push_back (Item_ptr (ParseItem (item, chan->ChannelID_)));
						item = item.nextSiblingElement ("item");
					}
					if (!chan->LastBuild_.isValid () || chan->LastBuild_.isNull ())
					{
						if (chan->Items_.size ())
							chan->LastBuild_ = chan->Items_.at (0)->PubDate_;
						else
							chan->LastBuild_ = QDateTime::currentDateTime ();
					}
					channels.push_back (chan);
					channel = channel.nextSiblingElement ("channel");
				}
				return channels;
			}
예제 #9
0
char *AHTMODEL::GetAHTOption( char *name )
{
    if (tstrcmp(name,"flag")) {
        sprintf( s_flag, "%d", GetFlag() );
        return s_flag;
    }
    if (tstrcmp(name,"glid")) {
        sprintf( s_glid, "%d", GetGlobalId2() );
        return s_glid;
    }
    if (tstrcmp(name,"name")) {
        return GetName();
    }
    if (tstrcmp(name,"class")) {
        return GetClass();
    }
    if (tstrcmp(name,"author")) {
        return GetAuthor();
    }
    if (tstrcmp(name,"ver")) {
        return GetVersion();
    }
    if (tstrcmp(name,"icon")) {
        return GetIconFile();
    }
    if (tstrcmp(name,"exp")) {
        return exp->GetBuffer();
    }
    if (tstrcmp(name,"source")) {
        return fname;
    }
    if (tstrcmp(name,"helpkw")) {
        return GetHelpKeyword();
    }
    return (char *)&dummy;
}
예제 #10
0
int _ExportPDF(FILE *pdf,SplineChar *sc,int layer) {
/* TODO: Note, maybe this routine can be combined with print.c dump_pdfprologue() */
    DBounds b;
    time_t now;
    struct tm *tm;
    int ret;
    char oldloc[24];
    int _objlocs[8], xrefloc, streamstart, streamlength, resid = 0, nextobj;
    int *objlocs = _objlocs;
    const char *author = GetAuthor();
    int i;

    SFUntickAll(sc->parent);
    locale_t tmplocale; locale_t oldlocale; // Declare temporary locale storage.
    switch_to_c_locale(&tmplocale, &oldlocale); // Switch to the C locale temporarily and cache the old locale.

    fprintf( pdf, "%%PDF-1.4\n%%\201\342\202\203\n" );	/* Header comment + binary comment */
    /* Every document contains a catalog which points to a page tree, which */
    /*  in our case, points to a single page */
    objlocs[1] = ftell(pdf);
    fprintf( pdf, "1 0 obj\n << /Type /Catalog\n    /Pages 2 0 R\n    /PageMode /UseNone\n >>\nendobj\n" );
    objlocs[2] = ftell(pdf);
    fprintf( pdf, "2 0 obj\n << /Type /Pages\n    /Kids [ 3 0 R ]\n    /Count 1\n >>\nendobj\n" );
    /* And our single page points to its contents */
    objlocs[3] = ftell(pdf);
    fprintf( pdf, "3 0 obj\n" );
    fprintf( pdf, " << /Type /Page\n" );
    fprintf( pdf, "    /Parent 2 0 R\n" );
    fprintf( pdf, "    /Resources " );
    if ( sc->parent->multilayer ) {
	resid = ftell(pdf);
	fprintf( pdf, "000000 0 R\n" );
    } else
	fprintf( pdf, "<< >>\n" );
    SplineCharLayerFindBounds(sc,layer,&b);
    fprintf( pdf, "    /MediaBox [%g %g %g %g]\n", (double) b.minx, (double) b.miny, (double) b.maxx, (double) b.maxy );
    fprintf( pdf, "    /Contents 4 0 R\n" );
    fprintf( pdf, " >>\n" );
    fprintf( pdf, "endobj\n" );
    /* And the contents are the interesting stuff */
    objlocs[4] = ftell(pdf);
    fprintf( pdf, "4 0 obj\n" );
    fprintf( pdf, " << /Length 5 0 R >> \n" );
    fprintf( pdf, " stream \n" );
    streamstart = ftell(pdf);
    SC_PSDump((void (*)(int,void *)) fputc,pdf,sc,true,true,layer);
    if ( sc->parent->multilayer )
	/* Already filled or stroked */;
    else if ( sc->parent->strokedfont )
	fprintf( pdf, "%g w S\n", (double) sc->parent->strokewidth );
    else
	fprintf( pdf, "f\n" );
    streamlength = ftell(pdf)-streamstart;
    fprintf( pdf, " endstream\n" );
    fprintf( pdf, "endobj\n" );
    objlocs[5] = ftell(pdf);
    fprintf( pdf, "5 0 obj\n" );
    fprintf( pdf, " %d\n", (int) streamlength );
    fprintf( pdf, "endobj\n" );

    /* Optional Info dict */
    objlocs[6] = ftell(pdf);
    fprintf( pdf, "6 0 obj\n" );
    fprintf( pdf, " <<\n" );
    fprintf( pdf, "    /Creator (FontForge)\n" );
    time(&now);
    tm = localtime(&now);
    fprintf( pdf, "    /CreationDate (D:%04d%02d%02d%02d%02d%02d",
	    1900+tm->tm_year, tm->tm_mon+1, tm->tm_mday,
	    tm->tm_hour, tm->tm_min, tm->tm_sec );
#ifdef _NO_TZSET
    fprintf( pdf, "Z)\n" );
#else
    tzset();
    if ( timezone==0 )
	fprintf( pdf, "Z)\n" );
    else {
	if ( timezone<0 ) /* fprintf bug - this is a kludge to print +/- in front of a %02d-padded value */
	    fprintf( pdf, "-" );
	else
	    fprintf( pdf, "+" );
	fprintf( pdf, "%02d'%02d')\n", (int)(timezone/3600),(int)(timezone/60-(timezone/3600)*60) );
    }
#endif
    fprintf( pdf, "    /Title (%s from %s)\n", sc->name, sc->parent->fontname );
    if ( author!=NULL )
	fprintf( pdf, "    /Author (%s)\n", author );
    fprintf( pdf, " >>\n" );

    nextobj = 7;
    if ( sc->parent->multilayer ) {
	PI pi;
	int resobj;
	memset(&pi,0,sizeof(pi));
	pi.out = pdf;
	pi.max_object = 100;
	pi.object_offsets = malloc(pi.max_object*sizeof(int));
	memcpy(pi.object_offsets,objlocs,nextobj*sizeof(int));
	pi.next_object = nextobj;
	resobj = PdfDumpGlyphResources(&pi,sc);
	nextobj = pi.next_object;
	objlocs = pi.object_offsets;
	fseek(pdf,resid,SEEK_SET);
	fprintf(pdf,"%06d", resobj );
	fseek(pdf,0,SEEK_END);
    }

    xrefloc = ftell(pdf);
    fprintf( pdf, "xref\n" );
    fprintf( pdf, " 0 %d\n", nextobj );
    fprintf( pdf, "0000000000 65535 f \n" );
    for ( i=1; i<nextobj; ++i )
	fprintf( pdf, "%010d %05d n \n", (int) objlocs[i], 0 );
    fprintf( pdf, "trailer\n" );
    fprintf( pdf, " <<\n" );
    fprintf( pdf, "    /Size %d\n", nextobj );
    fprintf( pdf, "    /Root 1 0 R\n" );
    fprintf( pdf, "    /Info 6 0 R\n" );
    fprintf( pdf, " >>\n" );
    fprintf( pdf, "startxref\n" );
    fprintf( pdf, "%d\n", (int) xrefloc );
    fprintf( pdf, "%%%%EOF\n" );

    if ( objlocs!=_objlocs )
	free(objlocs);

    ret = !ferror(pdf);
    switch_to_old_locale(&tmplocale, &oldlocale); // Switch to the cached locale.
return( ret );
}
예제 #11
0
	channels_container_t RSS10Parser::Parse (const QDomDocument& doc,
			const IDType_t& feedId) const
	{
		channels_container_t result;
	
		QMap<QString, Channel_ptr> item2Channel;
		QDomElement root = doc.documentElement ();
		QDomElement channelDescr = root.firstChildElement ("channel");
		while (!channelDescr.isNull ())
		{
			Channel_ptr channel (new Channel (feedId));
			channel->Title_ = channelDescr.firstChildElement ("title").text ().trimmed ();
			channel->Link_ = channelDescr.firstChildElement ("link").text ();
			channel->Description_ =
				channelDescr.firstChildElement ("description").text ();
			channel->PixmapURL_ =
				channelDescr.firstChildElement ("image")
				.firstChildElement ("url").text ();
			channel->LastBuild_ = GetDCDateTime (channelDescr);
	
			QDomElement itemsRoot = channelDescr.firstChildElement ("items");
			QDomNodeList seqs = itemsRoot.elementsByTagNameNS (RDF_, "Seq");
	
			channelDescr = channelDescr.nextSiblingElement ("channel");
	
			if (!seqs.size ())
				continue;
	
			QDomElement seqElem = seqs.at (0).toElement ();
			QDomNodeList lis = seqElem.elementsByTagNameNS (RDF_, "li");
			for (int i = 0; i < lis.size (); ++i)
				item2Channel [lis.at (i).toElement ().attribute ("resource")] = channel;
	
			result.push_back (channel);
		}
	
		QDomElement itemDescr = root.firstChildElement ("item");
		while (!itemDescr.isNull ())
		{
			QString about = itemDescr.attributeNS (RDF_, "about");
			if (item2Channel.contains (about))
			{
				Item_ptr item (new Item (item2Channel [about]->ChannelID_));
				item->Title_ = itemDescr.firstChildElement ("title").text ();
				item->Link_ = itemDescr.firstChildElement ("link").text ();
				item->Description_ = itemDescr.firstChildElement ("description").text ();
				GetDescription (itemDescr, item->Description_);
	
				item->Categories_ = GetAllCategories (itemDescr);
				item->Author_ = GetAuthor (itemDescr);
				item->PubDate_ = GetDCDateTime (itemDescr);
				item->Unread_ = true;
				item->NumComments_ = GetNumComments (itemDescr);
				item->CommentsLink_ = GetCommentsRSS (itemDescr);
				item->CommentsPageLink_ = GetCommentsLink (itemDescr);
				item->Enclosures_ = GetEncEnclosures (itemDescr, item->ItemID_);
				QPair<double, double> point = GetGeoPoint (itemDescr);
				item->Latitude_ = point.first;
				item->Longitude_ = point.second;
				if (item->Guid_.isEmpty ())
					item->Guid_ = "empty";
	
				item2Channel [about]->Items_.push_back (item);
			}
			itemDescr = itemDescr.nextSiblingElement ("item");
		}
	
		return result;
	}
/**
 *  COllect Updates
 *  
 *  We store each update with a new sequence number, and if necessary, a
 *  time-to-live. We publish updates immediately on our publisher socket:
 */
static int
s_collector (zloop_t *loop, zmq_pollitem_t *poller, void *args)
{
    clonesrv_t *self = (clonesrv_t *) args;

    DEBUG("I: s_collector");
    
    kvmsg_t *kvmsg = kvmsg_recv (poller->socket);
    if (kvmsg) {
        kvmsg_set_sequence (kvmsg, ++self->sequence);
	kvmsg_fmt_key(kvmsg, "%s%d", SUBTREE, self->sequence-1 );

	if( !strcmp(MSG_TYPE_SFD, kvmsg_get_prop (kvmsg, "type")))
	{
	    // setup the beacon
	    //  Broadcast on the zyre port
	    beacon_announce_t ba;
	    memset( &ba, 0, sizeof(ba));
	    strcpy( ba.protocol, "fontforge-collab" );
	    ba.version = 2;
	    char* uuid = kvmsg_get_prop (kvmsg, "collab_uuid" );
	    if( uuid ) {
		strcpy( ba.uuid, uuid );
	    } else {
		ff_uuid_generate( ba.uuid );
	    }
	    strncpy( ba.username,    GetAuthor(), beacon_announce_username_sz );
	    ff_gethostname( ba.machinename, beacon_announce_machinename_sz );
	    ba.port = htons( self->port );
	    strcpy( ba.fontname, "" );

	    DEBUG("I: adding beacon, payloadsz:%zu user:%s machine:%s",
		  sizeof(beacon_announce_t), ba.username, ba.machinename );

	    
	    char* fontname = kvmsg_get_prop (kvmsg, "fontname" );
	    if( fontname )
	    {
		strcpy( ba.fontname, fontname );
	    }


	    service_beacon = zbeacon_new( self->ctx, 5670 );
	    zbeacon_set_interval (service_beacon, 300 );
	    zbeacon_publish (service_beacon, (byte*)&ba, sizeof(ba));
	}
	
	
        kvmsg_send (kvmsg, self->publisher);
//        int ttl = atoi (kvmsg_get_prop (kvmsg, "ttl"));
//        if (ttl)
//            kvmsg_set_prop (kvmsg, "ttl",
//                "%" PRId64, zclock_time () + ttl * 1000);
        DEBUG ("I: publishing update=%d type:%s", (int) self->sequence,kvmsg_get_prop (kvmsg, "type"));
	DEBUG("I:x hash size:%ld", zhash_size(self->kvmap));
	
        kvmsg_store( &kvmsg, self->kvmap );
	
    }
    return 0;
}
예제 #13
0
STRUCT__HEADER__SET	* GetFileSchema(int ifcModel, STRUCT__HEADER__SET * parent)
{
#ifdef	_UNICODE
	STRUCT__HEADER__SET	* headerFileSchema = CreateHeaderSet(parent, L"Set of FileSchemas", 0),
#else
	STRUCT__HEADER__SET	* headerFileSchema = CreateHeaderSet(parent, "Set of FileSchemas", 0),
#endif
						** ppHeader = &headerFileSchema->child;
#ifdef	_UNICODE
	wchar_t	* text = 0;
#else
	char	* text = 0;
#endif
	int		i = 0;

#ifdef	_UNICODE
	if	(!GetSPFFHeaderItem(ifcModel, 9, i, sdaiUNICODE, (char **) &text)) {
		while  (!GetSPFFHeaderItem(ifcModel, 9, i++, sdaiUNICODE, (char **) &text)) {
			(* ppHeader) = CreateHeaderSet(headerFileSchema, L"FileSchema", text);
#else
	if	(!GetSPFFHeaderItem(ifcModel, 9, i, sdaiSTRING, &text)) {
		while  (!GetSPFFHeaderItem(ifcModel, 9, i++, sdaiSTRING, &text)) {
			(* ppHeader) = CreateHeaderSet(headerFileSchema, "FileSchema", text);
#endif
			ppHeader = &(* ppHeader)->next;
			text = 0;
		}
	}

	return	headerFileSchema;
}

STRUCT__HEADER__SET	* GetHeaderInfo(int ifcModel)
{
#ifdef	_UNICODE
	STRUCT__HEADER__SET	* headerFileSchema = CreateHeaderSet(0, L"Header Info", 0),
#else
	STRUCT__HEADER__SET	* headerFileSchema = CreateHeaderSet(0, "Header Info", 0),
#endif
						** ppHeader = &headerFileSchema->child;

	(* ppHeader) = GetHeaderDescription(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetImplementationLevel(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetName(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetTimeStamp(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetAuthor(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetOrganization(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetPreprocessorVersion(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetOriginatingSystem(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetAuthorization(ifcModel, headerFileSchema);
	ppHeader = &(* ppHeader)->next;
	(* ppHeader) = GetFileSchema(ifcModel, headerFileSchema);

	return	headerFileSchema;
}