Subversion Repositories SvarDOS

Rev

Rev 102 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 102 Rev 105
Line 80... Line 80...
80
    }
80
    }
81
    trim(line);
81
    trim(line);
82
    /* skip empty lines and comments */
82
    /* skip empty lines and comments */
83
    if ((line[0] == 0) || (line[0] == '#')) continue;
83
    if ((line[0] == 0) || (line[0] == '#')) continue;
84
    /* */
84
    /* */
85
    if (filetype == 0) {
85
    if (filetype == 0) { /* CATS-like */
86
      res++;
86
      res++;
87
    } else {
87
    } else if (filetype == 1) { /* lng (FreeCOM) */
88
      if ((line[0] == ':') && (stringongoing == 0)) stringongoing = 1;
88
      if ((line[0] == ':') && (stringongoing == 0)) stringongoing = 1;
89
      if ((line[0] == '.') && (stringongoing != 0)) {
89
      if ((line[0] == '.') && (stringongoing != 0)) {
90
        res++;
90
        res++;
91
        stringongoing = 0;
91
        stringongoing = 0;
92
      }
92
      }
-
 
93
    } else { /* err (FreeCOM) */
-
 
94
      res++;
93
    }
95
    }
94
  }
96
  }
95
  return(res);
97
  return(res);
96
}
98
}
97
 
99
 
Line 106... Line 108...
106
  int filetype;
108
  int filetype;
107
  int popenres;
109
  int popenres;
108
  #define FILEALLOC 1024*1024
110
  #define FILEALLOC 1024*1024
109
  FILE *fd;
111
  FILE *fd;
110
  /* read arg list */
112
  /* read arg list */
111
  if ((argc != 4) || (argv[1][0] == '-') || (atoi(argv[3]) > 1) || (atoi(argv[3]) < 0)) {
113
  if ((argc != 4) || (argv[1][0] == '-') || (argv[3][0] > '2') || (argv[3][0] < '0')) {
112
    printf("-1\n");
114
    printf("-1\n");
113
    fprintf(stderr, "svnlschk - Svarog's NLS checker\n"
115
    fprintf(stderr, "svnlschk - Svarog's NLS checker - Copyright (C) 2016 Mateusz Viste\n"
114
                    "usage: svnlschk pkg.zip lang filetype\n"
116
                    "usage: svnlschk pkg.zip lang nlstype\n"
115
                    "\n"
117
                    "\n"
116
                    "where filetype is:\n"
118
                    "where nlstype is:\n"
117
                    " 0 = standard CATS-like NLS file\n"
119
                    " 0 = standard CATS-like NLS file\n"
118
                    " 1 = FreeCOM-style LNG file\n");
120
                    " 1 = FreeCOM-style LNG file\n"
-
 
121
                    " 2 = FreeCOM-style ERR file\n");
119
    return(1);
122
    return(1);
120
  }
123
  }
121
  pkgfile = argv[1];
124
  pkgfile = argv[1];
122
  lang = argv[2];
125
  lang = argv[2];
123
  filetype = atoi(argv[3]);
126
  filetype = atoi(argv[3]);
Line 130... Line 133...
130
    printf("-1\n");
133
    printf("-1\n");
131
    fprintf(stderr, "ERROR: %s is not a valid ZIP archive!\n", pkgfile);
134
    fprintf(stderr, "ERROR: %s is not a valid ZIP archive!\n", pkgfile);
132
    return(1);
135
    return(1);
133
  }
136
  }
134
  /* extract wanted file through popen() and read it into memory */
137
  /* extract wanted file through popen() and read it into memory */
-
 
138
  if (filetype == 0) { /* CATS-like */
135
  snprintf(buff, sizeof(buff), "unzip -pC %s nls/%s.%s", pkgfile, pkgshortname, lang);
139
    snprintf(buff, sizeof(buff), "unzip -pC %s nls/%s.%s", pkgfile, pkgshortname, lang);
-
 
140
  } else if (filetype == 1) { /* lng (FreeCOM) */
-
 
141
    snprintf(buff, sizeof(buff), "unzip -pC %s source/%s/strings/%s.lng", pkgfile, pkgshortname, lang);
-
 
142
  } else { /* err (FreeCOM) */
-
 
143
    snprintf(buff, sizeof(buff), "unzip -pC %s source/%s/strings/%s.err", pkgfile, pkgshortname, lang);
-
 
144
  }
136
  /* */
145
  /* */
137
  fd = popen(buff, "r");
146
  fd = popen(buff, "r");
138
  if (fd == NULL) {
147
  if (fd == NULL) {
139
    printf("-1\n");
148
    printf("-1\n");
140
    fprintf(stderr, "ERROR: popen() failed\n");
149
    fprintf(stderr, "ERROR: popen() failed\n");