1 /******************************************************************************
2 *
3 * Copyright (C) 2006, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: mix 18.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov
13 *
14 * Summary: Different functions.
15 *
16 ******************************************************************************/
17
18 #include "mix.h"
19 #include "../genteeapi/gentee.h"
20
21 /*-----------------------------------------------------------------------------
22 * Id: argc F1
23 *
24 * Summary: Get the number of parameters. The function returns the count of
25 parameters in the command line.
26 *
27 * Return: The number of parameters passed in the command line.
28 *
29 * Define: func uint argc()
30 *
31 -----------------------------------------------------------------------------*/
32
33 uint STDCALL argc()
34 {
35 uint count = 0;
36 pubyte cur = _gentee.args;
37
38 if ( cur )
39 while ( *cur )
40 {
41 count++;
42 cur += mem_len( cur ) + 1;
43 }
44 return count;
45 }
46
47 /*-----------------------------------------------------------------------------
48 ** Id: argv F
49 *
50 * Summary: Get a parameter. The function returns the parameter of
51 the command line.
52 *
53 * Params: ret - A variable to write the return value to.
54 num - The number of the parameter to be obtained beginning from 1.
55 *
56 * Return: #lng/retpar( ret )
57 *
58 * Define: func str argv( str ret, uint num )
59 *
60 -----------------------------------------------------------------------------*/
61
62 pstr STDCALL argv( pstr ret, uint num )
63 {
64 pubyte cur = _gentee.args;
65
66 str_clear( ret );
67 if ( cur )
68 while ( *cur )
69 {
70 num--;
71 if ( !num )
72 {
73 str_copyzero( ret, cur );
74 break;
75 }
76 cur += mem_len( cur ) + 1;
77 }
78 return ret;
79 }
80
Редактировать