array.c
//writes array at ap to buf upto a maximum of n characters
//printer is a function that takes 3 parameters respectively: buffer, length of buffer, and the value to write, returns bytes written
//start is prefixed to the array, delim is written between each element, and end is suffixed to the array 
writes array at ap to buf upto a maximum of n characters
printer is a function that takes 3 parameters respectively: buffer, length of buffer, and the value to write, returns bytes written
start is prefixed to the array, delim is written between each element, and end is suffixed to the array
writes array at ap to buf upto a maximum of n characters printer is a function that takes 3 parameters respectively : buffer length of buffer and the value to write returns bytes written start is prefixed to the array delim is written between each element and end is suffixed to the array
int snprintfc_array(char* buf, int n, array_t* ap, const char* start, int (*printer)(char*,int,int), const char* delim, const char* end) {
	int w = 0; 
	int i;
	strncpy(buf, start, n);
	w += strlen(start);
	WARN_IF(w >= n, "snprint_array exceeded buffer");
	if( w >= n ) { return w; }
	for(i=0; i+1<ap->length; i++) {
		w += printer(buf+w,n-w,ap->array[i]);
		WARN_IF(w >= n, "snprint_array exceeded buffer");
		if( w >= n ) { return w; }
		strncpy(buf+w, delim, n-w);
		w += strlen(delim);
		WARN_IF(w >= n, "snprint_array exceeded buffer");
		if( w >= n ) { return w; }
	}
	w += printer(buf+w,n-w,ap->array[i]);
	WARN_IF(w >= n, "snprint_array exceeded buffer");
	if( w >= n ) { return w; }
	strncpy(buf+w, end, n-w);
	w += strlen(end);
	WARN_IF(w >= n, "snprint_array exceeded buffer");
	if( w >= n ) { return w; }
	return(w);
}
int snprintfc_array ( char * buf , int n , array_t * ap , const char * start , int ( * printer ) ( char * , int , int ) , const char * delim , const char * end ) { int w = 0 ; int i ; strncpy ( buf , start , n ) ; w += strlen ( start ) ; WARN_IF ( w >= n , " " ) ; if ( w >= n ) { return w ; } for ( i = 0 ; i + 1 < ap -> length ; i ++ ) { w += printer ( buf + w , n - w , ap -> array [ i ] ) ; WARN_IF ( w >= n , " " ) ; if ( w >= n ) { return w ; } strncpy ( buf + w , delim , n - w ) ; w += strlen ( delim ) ; WARN_IF ( w >= n , " " ) ; if ( w >= n ) { return w ; } } w += printer ( buf + w , n - w , ap -> array [ i ] ) ; WARN_IF ( w >= n , " " ) ; if ( w >= n ) { return w ; } strncpy ( buf + w , end , n - w ) ; w += strlen ( end ) ; WARN_IF ( w >= n , " " ) ; if ( w >= n ) { return w ; } return ( w ) ; }
writes array at ap to buf upto a maximum of n characters
printer is a function that takes 3 parameters respectively: buffer, length of buffer, and the value to write, returns bytes written
start is prefixed to the array, delim is written between each element, and end is suffixed to the array
writes array at ap to buf upto a maximum of n characters printer is a function that takes 3 parameters respectively : buffer length of buffer and the value to write returns bytes written start is prefixed to the array delim is written between each element and end is suffixed to the array
//bytes written