1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
/**************************************************************/
/* ********************************************************** */
/* * * */
/* * PROBLEM DESCRIPTION * */
/* * * */
/* ********************************************************** */
/**************************************************************/
/**************************************************************/
/* * This program is free software; you can redistribute * */
/* * it and/or modify it under the terms of the FreeBSD * */
/* * Licence. * */
/* * * */
/* * This program is distributed in the hope that it will * */
/* * be useful, but WITHOUT ANY WARRANTY; without even * */
/* * the implied warranty of MERCHANTABILITY or FITNESS * */
/* * FOR A PARTICULAR PURPOSE. See the LICENCE file * */
/* * for more details. * */
/**************************************************************/
#include "description.h"
/**************************************************************/
/* Functions */
/**************************************************************/
DFGDESCRIPTION desc_Create(void)
/**************************************************************
INPUT: Nothing.
RETURNS: Newly allocated problem description instance.
***************************************************************/
{
DFGDESCRIPTION problem;
problem = (DFGDESCRIPTION)memory_Malloc(sizeof(DFGDESCRIPTION_NODE));
memset(problem,0,sizeof(DFGDESCRIPTION_NODE));
problem->status = DFG_UNKNOWNSTATE;
return problem;
}
void desc_Delete(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: Nothing.
EFFECT: Frees memory used by the problem description.
***************************************************************/
{
if (Description->name != NULL)
string_StringFree(Description->name);
if (Description->author != NULL)
string_StringFree(Description->author);
if (Description->version != NULL)
string_StringFree(Description->version);
if (Description->logic != NULL)
string_StringFree(Description->logic);
if (Description->description != NULL)
string_StringFree(Description->description);
if(Description->date != NULL)
string_StringFree(Description->date);
memory_Free(Description,sizeof(DFGDESCRIPTION_NODE));
}
const char* desc_Name(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's name from the description section.
***************************************************************/
{
return Description->name;
}
const char* desc_Author(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's author from the description section.
***************************************************************/
{
return Description->author;
}
const char* desc_Version(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's version from the description section.
***************************************************************/
{
return Description->version;
}
const char* desc_Logic(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's logic from the description section.
***************************************************************/
{
return Description->logic;
}
DFG_STATE desc_Status(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's status from the description section.
***************************************************************/
{
return Description->status;
}
const char* desc_StatusString(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The string representation of the problem's status.
***************************************************************/
{
const char* result = "";
switch (Description->status) {
case DFG_SATISFIABLE:
result = "satisfiable"; break;
case DFG_UNSATISFIABLE:
result = "unsatisfiable"; break;
case DFG_UNKNOWNSTATE:
result = "unknown"; break;
default:
misc_StartErrorReport();
misc_ErrorReport("\n In desc_StatusString: Invalid status.\n");
misc_FinishErrorReport();
}
return result;
}
const char* desc_Description(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's description from the description section.
***************************************************************/
{
return Description->description;
}
const char* desc_Date(DFGDESCRIPTION Description)
/**************************************************************
INPUT: Problem description instance.
RETURNS: The problem's date from the description section.
***************************************************************/
{
return Description->date;
}
void desc_FPrintDescription(DFGDESCRIPTION Description, FILE* File)
/**************************************************************
INPUT: Problem description instance and a file stream.
RETURNS: Nothing.
EFFECT: The description section from the input file
is printed to 'File'. You must call the parser first
before calling this function.
***************************************************************/
{
fputs("list_of_descriptions.\n name(", File);
if (Description->name != NULL)
fputs(Description->name, File);
else
fputs("{* *}", File);
fputs(").\n author(", File);
if (Description->author != NULL)
fputs(Description->author, File);
else
fputs("{* *}", File);
fputs(").\n", File);
if (Description->version != NULL) {
fputs(" version(", File);
fputs(Description->version, File);
fputs(").\n", File);
}
if (Description->logic != NULL) {
fputs(" logic(", File);
fputs(Description->logic, File);
fputs(").\n", File);
}
fputs(" status(", File);
fputs(desc_StatusString(Description), File);
fputs(").\n description(", File);
if (Description->description != NULL)
fputs(Description->description, File);
else
fputs("{* *}", File);
fputs(").\n", File);
if (Description->date != NULL) {
fputs(" date(", File);
fputs(Description->date, File);
fputs(").\n", File);
}
fputs("end_of_list.", File);
}
|