]> the.earth.li Git - onak.git/blobdiff - keyarray.h
Remove dead store in generic_fetch_key
[onak.git] / keyarray.h
index a3e288aae656da90d0416f1aa0efa2bd9ab07857..1ac13ba571c68d0190a5aa92bdf44d5e3ea9bbf8 100644 (file)
@@ -14,8 +14,7 @@
  * more details.
  *
  * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 51
- * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * this program.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef __KEYARRAY_H__
@@ -65,4 +64,32 @@ void array_free(struct keyarray *array);
  */
 bool array_add(struct keyarray *array, struct openpgp_fingerprint *fp);
 
+/**
+ * @brief Load a file into a keyarray
+ * @param array Pointer to the key array
+ * @param file The full path to the file to load
+ *
+ * Loads fingerprints from the supplied file into the provided keyarray. Does
+ * not re-initialise the array so can be called repeatedly to add multiple
+ * files. The file does not need to be sorted; array_add() is called for each
+ * key to ensure the array is suitable for binary searching with array_find()
+ */
+bool array_load(struct keyarray *array, const char *file);
+
+/**
+ * @brief Compare two OpenPGP fingerprints
+ * @param a Fingerprint 1
+ * @param b Fingerprint 2
+ *
+ * Compares 2 OpenPGP fingerprints, returning an integer less than, equal to,
+ * or greater than zero depending on whether a is less than, matches, or is
+ * greater than b.
+ *
+ * For the purposes of comparison shorter fingerprints sort earlier than
+ * longer fingerprints (i.e. v3 < v4 < v5) and comparison of same-length
+ * fingerprints treats them as a numberical value.
+ */
+int fingerprint_cmp(struct openpgp_fingerprint *a,
+               struct openpgp_fingerprint *b);
+
 #endif /* __KEYARRAY_H__ */