Getting UNID from C API

Hello,

I cannot get from the C API the same values I get from the Lotus Notes Client of any of the IDs. (UNID, OID, DBID, etc.) I’m assuming I’m parsing (representing) them in a wrong way.

I’m basing my code in the allflds.c example in samples/basic/allfdls/. This code uses NSFSearch, so, in SearchMatch I supposedly have access to the OID:

printf (“\nNote ID is: %lX.\n”, SearchMatch.ID.NoteID);

printf (“Note is: %lX.\n”, SearchMatch.ID.Note);

printf (“Note File is: %lX.\n”, SearchMatch.ID.File);

printf (“\nOriginator File is: %lX.\n”, SearchMatch.OriginatorID.File);

printf (“\nOriginator Note is: %lX.\n”, SearchMatch.OriginatorID.Note);

printf (“\nOriginator Seq is: %lX.\n”, SearchMatch.OriginatorID.Sequence);

/* After NSFNoteOpen … */

NSFNoteGetInfo(note_handle,_NOTE_OID,&unid);

NSFNoteGetInfo(note_handle,_NOTE_DB,&dbid);

printf (“Got UNIVERSAL File is: %lX.\n”, unid.File);

printf (“Got UNIVERSAL Note is: %lX.\n”, unid.Note);

printf (“Got DB Unique ID is: %lX.\n”, dbid);

But the output doesn’t match the format a UNID (OID, DBID, etc.), is supposed to have, not even when 0-padded.

Note ID is: 2E76.

Note is: 2429C6.

Note File is: 241FD0.

Originator File is: C7844FB.

Originator Note is: 21C544.

Originator Seq is: 1D.

Got UNIVERSAL File is: C7844FB.

Got UNIVERSAL Note is: 21C544.

Got DB Unique ID is: A9.

So, the question is… what’s the proper way to parse these IDs to get the same ID Notes client produces?

The ID is a proper ID, as NSFNoteOpen succeeds with that value. I think %lX is not the proper representation for the value. But, I don’t know what is the proper representation.

Thanks a lot,

V.

Subject: Getting UNID from C API

This is what we use in our Midas Rich Text LSX:

      sprintf (str, "%.8lx%.8lx%.8lx%.8lx",

               notelink_->Note.File.Innards[1],

               notelink_->Note.File.Innards[0],

               notelink_->Note.Note.Innards[1],

               notelink_->Note.Note.Innards[0]);

      strupr(str);

While it doesn’t really need to be upper cased, we do it for consistency and comparisons. For NOTEID, we use the following:

#if (defined(UNIX))

    sprintf(str, "%0X", (unsigned long) this->NoteID);

#else

    _ltoa((long) this->NoteID, str, 16);

#endif

although I am not sure why we don’t have a single version for both operating systems. Probably an ancient historical reason.

Subject: RE: Getting UNID from C API

Thank you very much, that was exactly the information I needed.

BTW, you can use %.8lX to avoid the strupr if your libc’s [s]printf supports the X format specifier.

V.

Subject: RE: Getting UNID from C API

Thanks. Some do support the X and some don’t, so I remember deciding long ago to assume they didn’t. My guess is that it was an early OS/2 issue or something and I could safely use the X now.