Subversion Repositories svn1-original

Rev

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

Rev 95 Rev 162
Line 172... Line 172...
172
 *      Time entered
172
 *      Time entered
173
 *      Will return an illegal time if the entry is not complete
173
 *      Will return an illegal time if the entry is not complete
174
 *
174
 *
175
 *========================================================================*/
175
 *========================================================================*/
176
 
176
 
177
time_t get_time(time_t utim)
177
//time_t get_time(time_t utim)
178
{
178
//{
179
    char        c;                              /* One of those */
179
//    char        c;                              /* One of those */
180
    int         i = 0;                          /* Counts user input */
180
//    int         i = 0;                          /* Counts user input */
181
    int         maxi = 0;                       /* Max user input */
181
//    int         maxi = 0;                       /* Max user input */
182
    static char buf[] = "00:00:00";             /* Build up a string here */
182
//    static char buf[] = "00:00:00";             /* Build up a string here */
183
    static char max_digit[] = "29:59:59";       /* Maximum digit's allowed in entry */
183
//    static char max_digit[] = "29:59:59";       /* Maximum digit's allowed in entry */
184
    int         hh = 0, mm = 0, ss = 0;
184
//    int         hh = 0, mm = 0, ss = 0;
185
 
185
 
186
    /*
186
//    /*
187
    **  Insert the base time into the edit buffer
187
//    **  Insert the base time into the edit buffer
188
    **  Invalid times are treated as 00:00:00
188
//    **  Invalid times are treated as 00:00:00
189
    */
189
//    */
190
    if ( utim == -1L )
190
//    if ( utim == -1L )
191
    {
191
//    {
192
        utim = 0;
192
//        utim = 0;
193
    }
193
//    }
194
    
194
    
195
    {
195
//    {
196
        char * ctime;
196
//        char * ctime;
197
        ctime = time_a(utim);
197
//        ctime = time_a(utim);
198
        if ( ctime[0] != '*' )
198
//        if ( ctime[0] != '*' )
199
            memcpy( buf, ctime, sizeof(buf)-1);
199
//            memcpy( buf, ctime, sizeof(buf)-1);
200
        else
200
//        else
201
            memcpy( buf, "00:00:00", sizeof(buf)-1);
201
//            memcpy( buf, "00:00:00", sizeof(buf)-1);
202
    }
202
//    }
203
 
203
 
204
    /*
204
//    /*
205
    **  Edit the string
205
//    **  Edit the string
206
    */
206
//    */
207
    while( TRUE )
207
//    while( TRUE )
208
    {
208
//    {
209
        c = getinp();
209
//        c = getinp();
210
        if( c == ABORT_CHAR )
210
//        if( c == ABORT_CHAR )
211
        {
211
//        {
212
            i = 0;
212
//            i = 0;
213
            break;
213
//            break;
214
        }
214
//        }
215
        if( c == '\n' || c == '\t' )
215
//        if( c == '\n' || c == '\t' )
216
            break;
216
//            break;
217
 
217
 
218
        if( ( c == rubout ) && i > 0 )           /* rubout character */
218
//        if( ( c == rubout ) && i > 0 )           /* rubout character */
219
        {
219
//        {
220
            i--;
220
//            i--;
221
            if( max_digit[i] == ':' )
221
//            if( max_digit[i] == ':' )
222
            {
222
//            {
223
                printf( "\010:\010" );
223
//                printf( "\010:\010" );
224
                buf[i--] = ':';
224
//                buf[i--] = ':';
225
            }
225
//            }
226
            buf[i] = '0';
226
//            buf[i] = '0';
227
            printf( "\010" "0" "\010" );
227
//            printf( "\010" "0" "\010" );
228
        }
228
//        }
229
 
229
 
230
        else if ( (c == (char)LEFTARROW)  && i > 0 )
230
//        else if ( (c == (char)LEFTARROW)  && i > 0 )
231
        {
231
//        {
232
            i--;
232
//            i--;
233
            if( max_digit[i] == ':' )
233
//            if( max_digit[i] == ':' )
234
            {
234
//            {
235
                printf( "\010" );
235
//                printf( "\010" );
236
                buf[i--] = ':';
236
//                buf[i--] = ':';
237
            }
237
//            }
238
            printf( "\010" );
238
//            printf( "\010" );
239
        }
239
//        }
240
 
240
 
241
        else if ( (c == (char)DELETE_KEY)  && i < 8 )
241
//        else if ( (c == (char)DELETE_KEY)  && i < 8 )
242
        {
242
//        {
243
            buf[i]='0';
243
//            buf[i]='0';
244
            printf( "0" "\010");
244
//            printf( "0" "\010");
245
        }
245
//        }
246
 
246
 
247
        else if ( (c == (char)RIGHTARROW)  && i < 8 )
247
//        else if ( (c == (char)RIGHTARROW)  && i < 8 )
248
        {
248
//        {
249
            printf( "%c", buf[i++] );
249
//            printf( "%c", buf[i++] );
250
            if( max_digit[i] == ':' )
250
//            if( max_digit[i] == ':' )
251
            {
251
//            {
252
                printf( ":" );
252
//                printf( ":" );
253
                buf[i++] = ':';
253
//                buf[i++] = ':';
254
            }
254
//            }
255
        }
255
//        }
256
 
256
 
257
        else if( ( i < 9 ) && isascii( c ) && isdigit( c )
257
//        else if( ( i < 9 ) && isascii( c ) && isdigit( c )
258
                 && max_digit[i] >= c )
258
//                 && max_digit[i] >= c )
259
        {
259
//        {
260
            printf( "%c", c );
260
//            printf( "%c", c );
261
            buf[i++] = c;
261
//            buf[i++] = c;
262
            if( max_digit[i] == ':' )
262
//            if( max_digit[i] == ':' )
263
            {
263
//            {
264
                printf( ":" );
264
//                printf( ":" );
265
                buf[i++] = ':';
265
//                buf[i++] = ':';
266
            }
266
//            }
267
        }
267
//        }
268
        else
268
//        else
269
        {
269
//        {
270
            beep();
270
//            beep();
271
        }
271
//        }
272
 
272
 
273
        if ( i > maxi )
273
//        if ( i > maxi )
274
            maxi = i;
274
//            maxi = i;
275
    }
275
//    }
276
 
276
 
277
    if( maxi > 0 )
277
//    if( maxi > 0 )
278
    {
278
//    {
279
        /*
279
//        /*
280
         * Parse the buffer extracting the required fields
280
//         * Parse the buffer extracting the required fields
281
         */
281
//         */
282
        if( sscanf( buf, "%d:%d:%d", &hh, &mm, &ss ) == 3 )
282
//        if( sscanf( buf, "%d:%d:%d", &hh, &mm, &ss ) == 3 )
283
        {
283
//        {
284
            return ( conv_time( hh, mm, ss ) );
284
//            return ( conv_time( hh, mm, ss ) );
285
        }
285
//        }
286
    }
286
//    }
287
    return ( ( time_t ) -1L );
287
//    return ( ( time_t ) -1L );
288
}
288
//}
289
 
289
 
290
/********************************* EOF ***********************************/
290
/********************************* EOF ***********************************/