ReactOS  0.4.14-dev-815-ge410a12
options.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>
#include "util.h"
#include "compat.h"
#include "config.h"
#include "help.h"
#include "log2lines.h"
#include "options.h"
Include dependency graph for options.c:

Go to the source code of this file.

Functions

int optionInit (int argc, const char **argv)
 
int optionParse (int argc, const char **argv)
 

Variables

charoptchars = "bcd:fFhl:L:mMP:rR:sS:tTuUvz:"
 
int opt_buffered = 0
 
int opt_help = 0
 
int opt_force = 0
 
int opt_exit = 0
 
int opt_verbose = 0
 
int opt_console = 0
 
int opt_mark = 0
 
int opt_Mark = 0
 
charopt_Pipe = NULL
 
int opt_quit = 0
 
int opt_cli = 0
 
int opt_raw = 0
 
int opt_stats = 0
 
int opt_Source = 0
 
int opt_SrcPlus = 0
 
int opt_twice = 0
 
int opt_Twice = 0
 
int opt_undo = 0
 
int opt_redo = 0
 
charopt_Revision = NULL
 
int opt_Revision_check = 0
 
char opt_dir [PATH_MAX]
 
char opt_logFile [PATH_MAX]
 
charopt_mod = NULL
 
char opt_7z [PATH_MAX]
 
char opt_scanned [LINESIZE]
 
char opt_SourcesPath [LINESIZE]
 

Function Documentation

◆ optionInit()

int optionInit ( int  argc,
const char **  argv 
)

Definition at line 52 of file options.c.

53 {
54  int i;
55  char *s;
56 
57  opt_mod = "a";
58  strcpy(opt_dir, "");
59  strcpy(opt_logFile, "");
62  if ((s = getenv(SOURCES_ENV)))
67  l2l_dbg(1, "Trunk build revision: %d\n", revinfo.buildrev);
68 
69  strcpy(opt_scanned, "");
70 
71  //The user introduced "log2lines.exe" or "log2lines.exe /?"
72  //Let's help the user
73  if ((argc == 1) ||
74  ((argc == 2) && (argv[1][0] == '/') && (argv[1][1] == '?')))
75  {
76  opt_help++;
77  usage(1);
78  return -1;
79  }
80 
81  for (i = 1; i < argc; i++)
82  {
83 
84  if ((argv[i][0] == '-') && (i+1 < argc))
85  {
86  //Because these arguments can contain spaces we cant use getopt(), a known bug:
87  switch (argv[i][1])
88  {
89  case 'd':
90  strcpy(opt_dir, argv[i+1]);
91  break;
92  case 'L':
93  opt_mod = "w";
94  //fall through
95  case 'l':
96  strcpy(opt_logFile, argv[i+1]);
97  break;
98  case 'P':
99  if (!opt_Pipe)
101  strcpy(opt_Pipe, argv[i+1]);
102  break;
103  case 'z':
104  strcpy(opt_7z, argv[i+1]);
105  break;
106  }
107  }
108 
110  strcat(opt_scanned, " ");
111  }
112 
113  l2l_dbg(4,"opt_scanned=[%s]\n",opt_scanned);
114 
115  return 0;
116 }
static int argc
Definition: ServiceArgs.c:12
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
#define SOURCES_ENV
Definition: config.h:13
#define CMD_7Z
Definition: config.h:22
int getRevision(char *fileName, int lastChanged)
Definition: revision.c:61
char opt_logFile[PATH_MAX]
Definition: options.c:43
#define argv
Definition: mplay32.c:18
char * opt_mod
Definition: options.c:44
char opt_scanned[LINESIZE]
Definition: options.c:46
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define l2l_dbg(level,...)
Definition: util.h:35
smooth NULL
Definition: ftsmooth.c:416
REVINFO revinfo
Definition: log2lines.c:37
char * opt_Pipe
Definition: options.c:29
char opt_7z[PATH_MAX]
Definition: options.c:45
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
GLdouble s
Definition: gl.h:2039
#define DEF_RANGE
Definition: config.h:10
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
#define LINESIZE
Definition: chargen.c:18
int getTBRevision(char *fileName)
Definition: revision.c:96
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
#define malloc
Definition: debug_ros.c:4
int opt_help
Definition: options.c:22
char opt_dir[PATH_MAX]
Definition: options.c:42
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by main().

◆ optionParse()

int optionParse ( int  argc,
const char **  argv 
)

Definition at line 118 of file options.c.

119 {
120  int i;
121  int optCount = 0;
122  int opt;
123 
124  while (-1 != (opt = getopt(argc, (char **const)argv, optchars)))
125  {
126  switch (opt)
127  {
128  case 'b':
129  opt_buffered++;
130  break;
131  case 'c':
132  opt_console++;
133  break;
134  case 'd':
135  optCount++;
136  //just count, see optionInit()
137  break;
138  case 'f':
139  opt_force++;
140  break;
141  case 'h':
142  opt_help++;
143  usage(1);
144  return -1;
145  break;
146  case 'F':
147  opt_exit++;
148  opt_force++;
149  break;
150  case 'l':
151  optCount++;
152  //just count, see optionInit()
153  break;
154  case 'm':
155  opt_mark++;
156  break;
157  case 'M':
158  opt_Mark++;
159  break;
160  case 'r':
161  opt_raw++;
162  break;
163  case 'P':
164  optCount++;
165  //just count, see optionInit()
166  break;
167  case 'R':
168  optCount++;
169  if (!opt_Revision)
171  sscanf(optarg, "%s", opt_Revision);
172  if (strcmp(opt_Revision, "check") == 0)
174  break;
175  case 's':
176  opt_stats++;
177  break;
178  case 'S':
179  optCount++;
180  i = sscanf(optarg, "%d+%d,%s", &opt_Source, &opt_SrcPlus, opt_SourcesPath);
181  if (i == 1)
182  sscanf(optarg, "%*d,%s", opt_SourcesPath);
183  l2l_dbg(3, "Sources option parse result: %d+%d,\"%s\"\n", opt_Source, opt_SrcPlus, opt_SourcesPath);
184  if (opt_Source)
185  {
186  /* need to retranslate for source info: */
187  opt_undo++;
188  opt_redo++;
190  }
191  break;
192  case 't':
193  opt_twice++;
194  break;
195  case 'T':
196  opt_twice++;
197  opt_Twice++;
198  break;
199  case 'u':
200  opt_undo++;
201  break;
202  case 'U':
203  opt_undo++;
204  opt_redo++;
205  break;
206  case 'v':
207  opt_verbose++;
208  break;
209  case 'z':
210  optCount++;
211  strcpy(opt_7z, optarg);
212  break;
213  default:
214  usage(0);
215  return -2;
216  break;
217  }
218  optCount++;
219  }
220  if(opt_console)
221  {
222  l2l_dbg(2, "Note: use 's' command in console mode. Statistics option disabled\n");
223  opt_stats = 0;
224  }
225  if (opt_SourcesPath[0])
226  {
228  }
229  if (!opt_dir[0])
230  {
233  }
234 
235  return optCount;
236 }
int opt_Twice
Definition: options.c:37
int opt_twice
Definition: options.c:36
static int argc
Definition: ServiceArgs.c:12
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
int opt_Mark
Definition: options.c:28
int opt_buffered
Definition: options.c:21
int opt_undo
Definition: options.c:38
int opt_raw
Definition: options.c:32
int opt_mark
Definition: options.c:27
#define argv
Definition: mplay32.c:18
int opt_Revision_check
Definition: options.c:41
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int opt_SrcPlus
Definition: options.c:35
#define l2l_dbg(level,...)
Definition: util.h:35
int opt_redo
Definition: options.c:39
int opt_force
Definition: options.c:23
_Check_return_ _CRTIMP int __cdecl sscanf(_In_z_ const char *_Src, _In_z_ _Scanf_format_string_ const char *_Format,...)
int opt_stats
Definition: options.c:33
char opt_7z[PATH_MAX]
Definition: options.c:45
int opt_exit
Definition: options.c:24
char * opt_Revision
Definition: options.c:40
int opt_Source
Definition: options.c:34
int getopt(int nargc, char *const *nargv, const char *ostr)
Definition: getopt.c:55
char * optchars
Definition: options.c:20
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
const char * optarg
Definition: getopt.c:49
int opt_verbose
Definition: options.c:25
#define LINESIZE
Definition: chargen.c:18
int opt_console
Definition: options.c:26
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
#define malloc
Definition: debug_ros.c:4
int opt_help
Definition: options.c:22
#define PATH_STR
Definition: compat.h:27
char opt_dir[PATH_MAX]
Definition: options.c:42
#define DEF_OPT_DIR
Definition: config.h:12
char opt_SourcesPath[LINESIZE]
Definition: options.c:47

Referenced by main().

Variable Documentation

◆ opt_7z

char opt_7z[PATH_MAX]

Definition at line 45 of file options.c.

Referenced by check_directory(), handle_escape_cmd(), optionInit(), optionParse(), and unpack_iso().

◆ opt_buffered

int opt_buffered = 0

Definition at line 21 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and set_LogFile().

◆ opt_cli

int opt_cli = 0

Definition at line 31 of file options.c.

Referenced by handle_escape_cmd().

◆ opt_console

int opt_console = 0

Definition at line 26 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and translate_files().

◆ opt_dir

◆ opt_exit

int opt_exit = 0

Definition at line 24 of file options.c.

Referenced by main(), and optionParse().

◆ opt_force

int opt_force = 0

Definition at line 23 of file options.c.

Referenced by main(), and optionParse().

◆ opt_help

int opt_help = 0

Definition at line 22 of file options.c.

Referenced by optionInit(), and optionParse().

◆ opt_logFile

char opt_logFile[PATH_MAX]

Definition at line 43 of file options.c.

Referenced by handle_escape_cmd(), optionInit(), and set_LogFile().

◆ opt_mark

int opt_mark = 0

Definition at line 27 of file options.c.

Referenced by optionParse(), and translate_line().

◆ opt_Mark

int opt_Mark = 0

Definition at line 28 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and translate_line().

◆ opt_mod

char* opt_mod = NULL

Definition at line 44 of file options.c.

Referenced by handle_escape_cmd(), optionInit(), and set_LogFile().

◆ opt_Pipe

char* opt_Pipe = NULL

Definition at line 29 of file options.c.

Referenced by handle_escape_cmd(), main(), and optionInit().

◆ opt_quit

int opt_quit = 0

Definition at line 30 of file options.c.

Referenced by handle_escape_cmd(), and translate_files().

◆ opt_raw

int opt_raw = 0

Definition at line 32 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and translate_files().

◆ opt_redo

int opt_redo = 0

Definition at line 39 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and translate_line().

◆ opt_Revision

char* opt_Revision = NULL

Definition at line 40 of file options.c.

Referenced by handle_escape_cmd(), main(), optionParse(), and translate_files().

◆ opt_Revision_check

int opt_Revision_check = 0

Definition at line 41 of file options.c.

Referenced by handle_escape_cmd(), log_rev_check(), optionParse(), and reportRevision().

◆ opt_scanned

char opt_scanned[LINESIZE]

Definition at line 46 of file options.c.

Referenced by optionInit(), and stat_print().

◆ opt_Source

int opt_Source = 0

Definition at line 34 of file options.c.

Referenced by handle_escape_cmd(), log_file(), optionParse(), and reportSource().

◆ opt_SourcesPath

◆ opt_SrcPlus

int opt_SrcPlus = 0

Definition at line 35 of file options.c.

Referenced by handle_escape_cmd(), log_file(), and optionParse().

◆ opt_stats

int opt_stats = 0

Definition at line 33 of file options.c.

Referenced by optionParse(), and translate_files().

◆ opt_twice

int opt_twice = 0

Definition at line 36 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and print_offset().

◆ opt_Twice

int opt_Twice = 0

Definition at line 37 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and print_offset().

◆ opt_undo

int opt_undo = 0

Definition at line 38 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and translate_line().

◆ opt_verbose

int opt_verbose = 0

Definition at line 25 of file options.c.

Referenced by handle_escape_cmd(), and optionParse().

◆ optchars

char* optchars = "bcd:fFhl:L:mMP:rR:sS:tTuUvz:"

Definition at line 20 of file options.c.

Referenced by handle_escape_cmd(), optionParse(), and usage().