1 /*
2     Copyright (C) 2008, 2009, 2010 William Hart
3     Copyright (C) 2010 Sebastian Pancratz
4     Copyright (C) 2013 Mike Hansen
5 
6     This file is part of FLINT.
7 
8     FLINT is free software: you can redistribute it and/or modify it under
9     the terms of the GNU Lesser General Public License (LGPL) as published
10     by the Free Software Foundation; either version 2.1 of the License, or
11     (at your option) any later version.  See <http://www.gnu.org/licenses/>.
12 */
13 
14 #ifdef T
15 
16 #include "templates.h"
17 
18 #include <stdlib.h>
19 #include <stdio.h>
20 
21 /*
22     Recall the return value conventions for fputc (of type int)
23 
24     ``If there are no errors, the same character that has been written is
25     returned.  If an error occurs, EOF is returned and the error indicator
26     is set''
27 
28     where the EOF macro expands to a negative int, and fprintf (of type int)
29 
30     ``On success, the total number of characters written is returned.
31     On failure, a negative number is returned.''
32  */
33 
_TEMPLATE(T,vec_fprint)34 int _TEMPLATE(T, vec_fprint) (FILE * file,
35                               const TEMPLATE(T, struct) * vec,
36                               slong len, const TEMPLATE(T, ctx_t) ctx)
37 {
38     int r;
39     slong i;
40 
41     r = fprintf(file, "%li", len);
42     if ((len > 0) && (r > 0))
43     {
44         r = fputc(' ', file);
45         for (i = 0; (i < len) && (r > 0); i++)
46         {
47             r = fputc(' ', file);
48             if (r > 0)
49                 r = TEMPLATE(T, fprint) (file, vec + i, ctx);
50         }
51     }
52 
53     return r;
54 }
55 
56 
57 #endif
58