1 /* Copyright 2004,2007,2014 IPB, Universite de Bordeaux, INRIA & CNRS
2 **
3 ** This file is part of the Scotch software package for static mapping,
4 ** graph partitioning and sparse matrix ordering.
5 **
6 ** This software is governed by the CeCILL-C license under French law
7 ** and abiding by the rules of distribution of free software. You can
8 ** use, modify and/or redistribute the software under the terms of the
9 ** CeCILL-C license as circulated by CEA, CNRS and INRIA at the following
10 ** URL: "http://www.cecill.info".
11 **
12 ** As a counterpart to the access to the source code and rights to copy,
13 ** modify and redistribute granted by the license, users are provided
14 ** only with a limited warranty and the software's author, the holder of
15 ** the economic rights, and the successive licensors have only limited
16 ** liability.
17 **
18 ** In this respect, the user's attention is drawn to the risks associated
19 ** with loading, using, modifying and/or developing or reproducing the
20 ** software by the user in light of its specific status of free software,
21 ** that may mean that it is complicated to manipulate, and that also
22 ** therefore means that it is reserved for developers and experienced
23 ** professionals having in-depth computer knowledge. Users are therefore
24 ** encouraged to load and test the software's suitability as regards
25 ** their requirements in conditions enabling the security of their
26 ** systems and/or data to be ensured and, more generally, to use and
27 ** operate it in the same conditions as regards security.
28 **
29 ** The fact that you are presently reading this means that you have had
30 ** knowledge of the CeCILL-C license and that you accept its terms.
31 */
32 /************************************************************/
33 /** **/
34 /** NAME : library_parser.c **/
35 /** **/
36 /** AUTHOR : Francois PELLEGRINI **/
37 /** **/
38 /** FUNCTION : This module is the API for the generic **/
39 /** strategy handling routines of the **/
40 /** libSCOTCH library. **/
41 /** **/
42 /** DATES : # Version 3.2 : from : 19 aug 1998 **/
43 /** to 19 aug 1998 **/
44 /** DATES : # Version 3.3 : from : 01 oct 1998 **/
45 /** to 31 may 1999 **/
46 /** # Version 3.4 : from : 01 nov 2001 **/
47 /** to 01 nov 2001 **/
48 /** # Version 4.0 : from : 23 dec 2001 **/
49 /** to : 23 dec 2001 **/
50 /** # Version 6.0 : from : 07 jan 2014 **/
51 /** to 07 jan 2014 **/
52 /** **/
53 /************************************************************/
54
55 /*
56 ** The defines and includes.
57 */
58
59 #define LIBRARY
60
61 #include "module.h"
62 #include "common.h"
63 #include "parser.h"
64 #include "scotch.h"
65
66 /************************************/
67 /* */
68 /* These routines are the C API for */
69 /* the strategy handling routines. */
70 /* */
71 /************************************/
72
73 /* This routine initializes a strategy
74 ** structure.
75 ** It returns:
76 ** - 0 : in all cases.
77 */
78
79 int
SCOTCH_stratInit(SCOTCH_Strat * const stratptr)80 SCOTCH_stratInit (
81 SCOTCH_Strat * const stratptr)
82 {
83 if (sizeof (SCOTCH_Strat) < sizeof (Strat *)) {
84 errorPrint ("SCOTCH_stratInit: internal error (1)");
85 return (1);
86 }
87
88 *((Strat **) stratptr) = NULL; /* Initialize pointer to strategy */
89
90 return (0);
91 }
92
93 /* This routine frees a strategy structure.
94 ** It returns:
95 ** - VOID : in all cases.
96 */
97
98 void
SCOTCH_stratExit(SCOTCH_Strat * const stratptr)99 SCOTCH_stratExit (
100 SCOTCH_Strat * const stratptr)
101 {
102 if (*((Strat **) stratptr) != NULL) /* If strategy is not null */
103 stratExit (*((Strat **) stratptr)); /* Free strategy structure */
104 }
105
106 /* This routine frees the contents of a
107 ** strategy structure and cleans it for
108 ** future use.
109 ** It returns:
110 ** - VOID : in all cases.
111 */
112
113 void
SCOTCH_stratFree(SCOTCH_Strat * const stratptr)114 SCOTCH_stratFree (
115 SCOTCH_Strat * const stratptr)
116 {
117 if (*((Strat **) stratptr) != NULL) { /* If strategy is not null */
118 stratExit (*((Strat **) stratptr)); /* Free strategy structure */
119 *((Strat **) stratptr) = NULL; /* Initialize pointer to strategy */
120 }
121 }
122
123 /* This routine outputs the contents of the
124 ** given strategy to the given stream.
125 ** It returns:
126 ** - 0 : on success.
127 ** - !0 : on error.
128 */
129
130 int
SCOTCH_stratSave(const SCOTCH_Strat * const stratptr,FILE * const stream)131 SCOTCH_stratSave (
132 const SCOTCH_Strat * const stratptr,
133 FILE * const stream)
134 {
135 return (stratSave (*((Strat **) stratptr), stream));
136 }
137