Subversion Repositories SvarDOS

Rev

Rev 538 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 538 Rev 989
Line 1... Line 1...
1
/* This file is part of the SvarCOM project and is published under the terms
1
/* This file is part of the SvarCOM project and is published under the terms
2
 * of the MIT license.
2
 * of the MIT license.
3
 *
3
 *
4
 * Copyright (C) 2021 Mateusz Viste
4
 * Copyright (C) 2021-2022 Mateusz Viste
5
 *
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
Line 139... Line 139...
139
  char *buff = p->BUFFER + sizeof(*nls);
139
  char *buff = p->BUFFER + sizeof(*nls);
140
  unsigned short i;
140
  unsigned short i;
141
  signed char ho = -1, mi = -1, se = -1;
141
  signed char ho = -1, mi = -1, se = -1;
142
 
142
 
143
  if (cmd_ishlp(p)) {
143
  if (cmd_ishlp(p)) {
144
    outputnl("Displays or sets the system time.");
144
    nls_outputnl(22,0); /* "Displays or sets the system time." */
145
    outputnl("");
145
    outputnl("");
146
    outputnl("TIME [time]");
146
    nls_outputnl(22,1); /* "TIME [time]" */
147
    outputnl("");
147
    outputnl("");
148
    outputnl("Type TIME with no parameters to display the current time and a prompt for a");
148
    nls_outputnl(22,2); /* "Type TIME with no parameters to display the current time and (...)" */
149
    outputnl("new one. Press ENTER to keep the same time.");
-
 
150
    return(CMD_OK);
149
    return(CMD_OK);
151
  }
150
  }
152
 
151
 
153
  i = nls_getpatterns(nls);
152
  i = nls_getpatterns(nls);
154
  if (i != 0) {
153
  if (i != 0) {
Line 176... Line 175...
176
      pop bx
175
      pop bx
177
      pop ax
176
      pop ax
178
    }
177
    }
179
    buff[0] = ' ';
178
    buff[0] = ' ';
180
    nls_format_time(buff + 1, ho, mi, se, nls);
179
    nls_format_time(buff + 1, ho, mi, se, nls);
181
    output("Current time is");
180
    nls_output(22,3); /* "Current time is" */
182
    outputnl(buff);
181
    outputnl(buff);
183
    ho = -1;
182
    ho = -1;
184
  } else { /* parse time if provided */
183
  } else { /* parse time if provided */
185
    if (cmd_time_parse(p->argv[0], &ho, &mi, &se, nls) != 0) {
184
    if (cmd_time_parse(p->argv[0], &ho, &mi, &se, nls) != 0) {
186
      outputnl("Invalid time");
185
      nls_outputnl(22,4); /* "Invalid time" */
187
      ho = -1;
186
      ho = -1;
188
    }
187
    }
189
  }
188
  }
190
 
189
 
191
  /* ask for time if not provided or if input was malformed */
190
  /* ask for time if not provided or if input was malformed */
192
  while (ho < 0) {
191
  while (ho < 0) {
193
    output("Enter new time:");
192
    nls_output(22,5); /* "Enter new time:" */
194
    output(" ");
193
    output(" ");
195
    /* collect user input into buff */
194
    /* collect user input into buff */
196
    _asm {
195
    _asm {
197
      push ax
196
      push ax
198
      push bx
197
      push bx
Line 222... Line 221...
222
      pop bx
221
      pop bx
223
      pop ax
222
      pop ax
224
    }
223
    }
225
    if (buff[1] == 0) break; /* empty string = do not change time */
224
    if (buff[1] == 0) break; /* empty string = do not change time */
226
    if (cmd_time_parse(buff + 2, &ho, &mi, &se, nls) == 0) break;
225
    if (cmd_time_parse(buff + 2, &ho, &mi, &se, nls) == 0) break;
227
    outputnl("Invalid time");
226
    nls_outputnl(22,4); /* "Invalid time" */
228
    return(CMD_FAIL);
227
    return(CMD_FAIL);
229
  }
228
  }
230
 
229
 
231
  if (ho >= 0) {
230
  if (ho >= 0) {
232
    /* set time */
231
    /* set time */