Пример #1
0
CAMLprim value wrapper_bdd_save(value out, value bdd) {
    CAMLparam2(out, bdd);
    BDD x = BDD_val(bdd);
    FILE* f = stream_of_channel(out,"w");
    if (bdd_save(f, x) != 0) {
        caml_raise_constant(*caml_named_value("buddy_exn_IOError"));
    }
    fflush(f);
    CAMLreturn(Val_unit);
}
Пример #2
0
/*
NAME    {* bdd\_save *}
EXTRA   {* bdd\_fnsave *}
SECTION {* fileio *}
SHORT   {* saves a BDD to a file *}
PROTO   {* int bdd_fnsave(char *fname, BDD r)
int bdd_save(FILE *ofile, BDD r) *}
DESCR   {* Saves the nodes used by {\tt r} to either a file {\tt ofile}
           which must be opened for writing or to the file named {\tt fname}.
	   In the last case the file will be truncated and opened for
	   writing. *}
ALSO    {* bdd\_load *}
RETURN  {* Zero on succes, otherwise an error code from {\tt bdd.h}. *}
*/
int bdd_fnsave(char *fname, BDD r)
{
   FILE *ofile;
   int ok;

   if ((ofile=fopen(fname,"w")) == NULL)
      return bdd_error(BDD_FILE);

   ok = bdd_save(ofile, r);
   fclose(ofile);
   return ok;
}
Пример #3
0
/*
NAME    {* bdd\_save *}
EXTRA   {* bdd\_fnsave *}
SECTION {* fileio *}
SHORT   {* saves a BDD to a file *}
PROTO   {* int bdd_fnsave(char *fname, BDD r)
int bdd_save(FILE *ofile, BDD r) *}
DESCR   {* Saves the nodes used by {\tt r} to either a file {\tt ofile}
           which must be opened for writing or to the file named {\tt fname}.
	   In the last case the file will be truncated and opened for
	   writing. *}
ALSO    {* bdd\_load *}
RETURN  {* Zero on succes, otherwise an error code from {\tt bdd.h}. *}
*/
int bdd_fnsave(char *fname, BDD r)
{
   FILE *ofile;
   int ok;

   BUDDY_PROLOGUE;
   ADD_ARG1(T_CHAR_PTR,fname);
   ADD_ARG1(T_BDD,r);

   if ((ofile=fopen(fname,"w")) == NULL)
      RETURN(bdd_error(BDD_FILE));

   ok = bdd_save(ofile, r);
   fclose(ofile);
   RETURN(ok);
}