CONFIG LIB 1.5
Configuration Files Library (by TGG 2020)
Loading...
Searching...
No Matches
panukl_auto.cpp
1/*********************************************************************/
2/* */
3/* Config files library - (C) TGG 2018 */
4/* */
5/*********************************************************************/
6/* Warszawa, 2018 */
7/*********************************************************************/
8/* */
9/* File: panukl_auto.h */
10/* */
11/* Author: T.Grabowski */
12/* */
13/* Contents - auto file data (sequence computation) class */
14/* */
15/* */
16/*********************************************************************/
17/* */
18/* */
19
20#include "panukl_auto.h"
21
22PANUKL_AUTO::PANUKL_AUTO( void ){ Clean (); }
23
24PANUKL_AUTO::~PANUKL_AUTO( void ){}
25
27{
28 Ms2Flag = 0;
29 NghFlag = 0;
30 ParFlag = 0;
31 PrsFlag = 0;
32
33 memset( Ms2File, 0, 256 );
34 memset( NghFile, 0, 256 );
35 memset( ParFile, 0, 256 );
36 memset( PrsFile, 0, 256 );
37
38 memset( AUTO_file, 0, 256 );
39}
40
41int PANUKL_AUTO::Read( const char *AutoFile )
42{
43 FILE *File;
44 File = fopen( AutoFile, "r" );
45 if( File == NULL )
46 {
47 fprintf( stderr, "[.auto] file open error to reading (%s)\n", AutoFile );
48 return (-1);
49 }
50
51 ReadPar( File, "%d", &Ms2Flag );
52 ReadPar( File, "%d", &NghFlag );
53 ReadPar( File, "%d", &ParFlag );
54 ReadPar( File, "%d", &PrsFlag );
55 ReadStr( File, Ms2File );
56 ReadStr( File, NghFile );
57 ReadStr( File, ParFile );
58 ReadStr( File, PrsFile );
59
60 fclose( File );
61
66
67 strcpy( AUTO_file, AutoFile );
68
69 return (0);
70}
71
72int PANUKL_AUTO::Write( const char *AutoFile )
73{
74 FILE *File;
75 File = fopen( AutoFile, "w" );
76 if( File == NULL )
77 {
78 fprintf( stderr, "[.auto] file open error to writing (%s)\n", AutoFile );
79 return (-1);
80 }
81
82 fprintf( File, "%d\n", Ms2Flag );
83 fprintf( File, "%d\n", NghFlag );
84 fprintf( File, "%d\n", ParFlag );
85 fprintf( File, "%d\n", PrsFlag );
86 fprintf( File, "%s\n", Ms2File );
87 fprintf( File, "%s\n", NghFile );
88 fprintf( File, "%s\n", ParFile );
89 fprintf( File, "%s\n", PrsFile );
90
91 fclose( File );
92
93 strcpy( AUTO_file, AutoFile );
94
95 return (0);
96}
97
static FILE * fopen(const char *filename, const char *mode)
Cross-platform function to fopen function that supports UTF-8 encoded name.
Definition iofun.cpp:358
static void ClipFileName(char *string)
Clipping of the ending blanc characters of "string".
Definition iofun.cpp:250
static int ReadStr(FILE *stream, char *Par)
Function to read the new line from FILE "stream" and to store it in table of char "Par"....
Definition iofun.cpp:163
static int ReadPar(FILE *stream, const char *Format, void *Par)
Function to read one variable. The type of variable depends on Format, compatible with stdio library.
Definition iofun.cpp:67
int Write(const char *AutoFile)
writes AUTO file
bool PrsFlag
Press program flag (1-run Press with PrsFile, 0-don't run Press)
Definition panukl_auto.h:34
bool Ms2Flag
Mesh program flag (1-run Mesh3 with Ms2File, 0-don't run Mesh)
Definition panukl_auto.h:31
char NghFile[256]
NGH filename.
Definition panukl_auto.h:37
bool NghFlag
Neigh program flag (1-run Neigh with NghFile, 0-don't run Neigh)
Definition panukl_auto.h:32
int Read(const char *AutoFile)
reads AUTO file
char PrsFile[256]
PRS filename.
Definition panukl_auto.h:39
void Clean()
cleans local variables
char AUTO_file[256]
AUTO filename.
Definition panukl_auto.h:41
char ParFile[256]
PAR filename.
Definition panukl_auto.h:38
bool ParFlag
Panukl program flag (1-run Panukl with ParFile, 0-don't run Panukl)
Definition panukl_auto.h:33
char Ms2File[256]
MS2 filename.
Definition panukl_auto.h:36