Moved ngmx to C++, renamed it to view.
[alexxy/gromacs.git] / src / programs / view / fgrid.cpp
similarity index 93%
rename from src/ngmx/fgrid.c
rename to src/programs/view/fgrid.cpp
index 172e40cb7e1dd7348df313fdbadec120fc830cf0..a8ca08524671a2c7fd5a0526e2c30f9efdafe2e9 100644 (file)
@@ -9,7 +9,7 @@
  *                        VERSION 3.2.0
  * Written by David van der Spoel, Erik Lindahl, Berk Hess, and others.
  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
- * Copyright (c) 2001-2004, The GROMACS development team,
+ * Copyright (c) 2001-2013, The GROMACS development team,
  * check out http://www.gromacs.org for more information.
 
  * This program is free software; you can redistribute it and/or
@@ -91,24 +91,17 @@ void ReadDlgError(const char *infile, eDLGERR err, const char *s,
             break;
     }
     fprintf(stderr, " in file %s\n", infile);
-    fprintf(stderr, "C-File: %s, line: %d\n", file, line);
+    fprintf(stderr, "source file: %s, line: %d\n", file, line);
     exit(1);
 }
 
 #define ReadDlgErr(in, er, es) ReadDlgError(in, er, es, __FILE__, __LINE__)
 
-static void GetBuf(FILE *in, char *buf)
-{
-    int rc;
-
-    rc = fscanf(in, "%s", buf);
-}
-
 static void ReadAccOpen(const char *infile, FILE *in)
 {
     char buf[STRLEN];
 
-    GetBuf(in, buf);
+    fscanf(in, "%4s", buf);
     if (strcmp(buf, "{") != 0)
     {
         ReadDlgErr(infile, eACCOEXP, buf);
@@ -119,7 +112,7 @@ static void ReadAccClose(const char *infile, FILE *in)
 {
     char buf[STRLEN];
 
-    GetBuf(in, buf);
+    fscanf(in, "%4s", buf);
     if (strcmp(buf, "}") != 0)
     {
         ReadDlgErr(infile, eACCCEXP, buf);
@@ -174,7 +167,7 @@ static void ReadQuoteStringOrAccClose(FILE *in, char *buf)
     buf[i] = '\0';
 }
 
-static gmx_bool bNotAccClose(const char *buf)
+static bool bNotAccClose(const char *buf)
 {
     return (strcmp(buf, "}") != 0);
 }
@@ -324,7 +317,7 @@ static t_fitem *ScanFItem(const char *infile, FILE *in, char *buf)
     {
         /* Special case */
         edlg        = edlgBN;
-        fitem->bDef = TRUE;
+        fitem->bDef = true;
     }
     if (edlg == edlgNR+1)
     {
@@ -373,8 +366,6 @@ t_fgrid *FGridFromFile(const char *infile)
 {
     FILE      *in;
     char       buf[STRLEN];
-    char      *gmxlib;
-    char       newinfile[STRLEN];
 
     t_fgrid   *fgrid;
     t_fgroup  *fgroup;
@@ -382,20 +373,20 @@ t_fgrid *FGridFromFile(const char *infile)
     int        gridx, gridy;
 
     in = libopen(infile);
-    GetBuf(in, buf);
+    fscanf(in, "%6s", buf);
     if (strcmp(buf, "grid") != 0)
     {
         ReadDlgErr(infile, eGRIDEXP, buf);
     }
     fgrid = NewFGrid();
-    if ((fscanf(in, "%d%d", &gridx, &gridy)) != 2)
+    if ((fscanf(in, "%5d%5d", &gridx, &gridy)) != 2)
     {
         ReadDlgErr(infile, eNOVALS, "grid w,h");
     }
     fgrid->w = gridx;
     fgrid->h = gridy;
     ReadAccOpen(infile, in);
-    GetBuf(in, buf);
+    fscanf(in, "%15s", buf);
     while (bNotAccClose(buf))
     {
         if (strcmp(buf, "group") == 0)
@@ -403,7 +394,7 @@ t_fgrid *FGridFromFile(const char *infile)
             fgroup = AddFGridFGroup(fgrid);
             ReadQuoteString(infile, in, buf);
             fgroup->name = strdup(buf);
-            if ((fscanf(in, "%d%d%d%d", &fgroup->x, &fgroup->y, &fgroup->w, &fgroup->h)) != 4)
+            if ((fscanf(in, "%5d%5d%5d%5d", &fgroup->x, &fgroup->y, &fgroup->w, &fgroup->h)) != 4)
             {
                 ReadDlgErr(infile, eNOVALS, "group x,y,w,h");
             }
@@ -416,17 +407,17 @@ t_fgrid *FGridFromFile(const char *infile)
                 ReadDlgErr(infile, eTOOHIGH, buf);
             }
             ReadAccOpen(infile, in);
-            GetBuf(in, buf);
+            fscanf(in, "%15s", buf);
             while (bNotAccClose(buf))
             {
                 AddFGroupFItem(fgroup, ScanFItem(infile, in, buf));
-                GetBuf(in, buf);
+                fscanf(in, "%15s", buf);
             }
         }
         else if (strcmp(buf, "simple") == 0)
         {
             fsimple = AddFGridFSimple(fgrid);
-            if ((fscanf(in, "%d%d%d%d", &fsimple->x, &fsimple->y, &fsimple->w, &fsimple->h)) != 4)
+            if ((fscanf(in, "%5d%5d%5d%5d", &fsimple->x, &fsimple->y, &fsimple->w, &fsimple->h)) != 4)
             {
                 ReadDlgErr(infile, eNOVALS, "simple x,y,w,h");
             }
@@ -439,11 +430,11 @@ t_fgrid *FGridFromFile(const char *infile)
                 ReadDlgErr(infile, eTOOHIGH, "simple");
             }
             ReadAccOpen(infile, in);
-            GetBuf(in, buf);
+            fscanf(in, "%15s", buf);
             fsimple->fitem = ScanFItem(infile, in, buf);
             ReadAccClose(infile, in);
         }
-        GetBuf(in, buf);
+        fscanf(in, "%15s", buf);
     }
     ffclose(in);