main.c
/*
 * Add the heap-allocated file to the queue for processing.
 */
Add the heap-allocated file to the queue for processing.
Add the heap - allocated file to the queue for processing .
static void
entityq_add(int fd, struct entityq *q, char *file, enum rtype type,
    const struct repo *rp, const unsigned char *dgst,
    const unsigned char *pkey, size_t pkeysz, char *descr, size_t *eid)
{
	struct entity	*p;
	if ((p = calloc(1, sizeof(struct entity))) == NULL)
		err(1, "calloc");
	p->id = (*eid)++;
	p->type = type;
	p->uri = file;
	p->repo = (rp != NULL) ? (ssize_t)rp->id : -1;
	p->has_dgst = dgst != NULL;
	p->has_pkey = pkey != NULL;
	p->has_descr = descr != NULL;
	if (p->has_dgst)
		memcpy(p->dgst, dgst, sizeof(p->dgst));
	if (p->has_pkey) {
		p->pkeysz = pkeysz;
		if ((p->pkey = malloc(pkeysz)) == NULL)
			err(1, "malloc");
		memcpy(p->pkey, pkey, pkeysz);
	}
	if (p->has_descr)
		if ((p->descr = strdup(descr)) == NULL)
			err(1, "strdup");
	TAILQ_INSERT_TAIL(q, p, entries);
	if (rp == NULL || rp->loaded)
		entity_write_req(fd, p);
}
static void entityq_add ( int fd , struct entityq * q , char * file , enum rtype type , const struct repo * rp , const unsigned char * dgst , const unsigned char * pkey , size_t pkeysz , char * descr , size_t * eid ) { struct entity * p ; if ( ( p = calloc ( 1 , sizeof ( struct entity ) ) ) == NULL ) err ( 1 , " " ) ; p -> id = ( * eid ) ++ ; p -> type = type ; p -> uri = file ; p -> repo = ( rp != NULL ) ? ( ssize_t ) rp -> id : -1 ; p -> has_dgst = dgst != NULL ; p -> has_pkey = pkey != NULL ; p -> has_descr = descr != NULL ; if ( p -> has_dgst ) memcpy ( p -> dgst , dgst , sizeof ( p -> dgst ) ) ; if ( p -> has_pkey ) { p -> pkeysz = pkeysz ; if ( ( p -> pkey = malloc ( pkeysz ) ) == NULL ) err ( 1 , " " ) ; memcpy ( p -> pkey , pkey , pkeysz ) ; } if ( p -> has_descr ) if ( ( p -> descr = strdup ( descr ) ) == NULL ) err ( 1 , " " ) ; TAILQ_INSERT_TAIL ( q , p , entries ) ; if ( rp == NULL || rp -> loaded ) entity_write_req ( fd , p ) ; }
Add the heap-allocated file to the queue for processing.
Add the heap - allocated file to the queue for processing .
/*
	 * Write to the queue if there's no repo or the repo has already
	 * been loaded.
	 */