OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2008 The Native Client Authors. All rights reserved. | 2 * Copyright 2008 The Native Client Authors. All rights reserved. |
3 * Use of this source code is governed by a BSD-style license that can be | 3 * Use of this source code is governed by a BSD-style license that can be |
4 * found in the LICENSE file. | 4 * found in the LICENSE file. |
5 */ | 5 */ |
6 | 6 |
7 /* | 7 /* |
8 * Misc functions missing from windows. | 8 * Misc functions missing from windows. |
9 */ | 9 */ |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 | 62 |
63 | 63 |
64 /* | 64 /* |
65 * Based on code by Hans Dietrich | 65 * Based on code by Hans Dietrich |
66 * see http://www.codeproject.com/KB/cpp/xgetopt.aspx | 66 * see http://www.codeproject.com/KB/cpp/xgetopt.aspx |
67 */ | 67 */ |
68 | 68 |
69 char *optarg; /* global argument pointer */ | 69 char *optarg; /* global argument pointer */ |
70 int optind = 0; /* global argv index */ | 70 int optind = 0; /* global argv index */ |
71 | 71 |
72 int getopt(int argc, char *argv[], char *optstring) { | 72 int getopt(int argc, char *argv[], const char *optstring) { |
73 char c, *cp; | 73 char c, *cp; |
74 static char *next = NULL; | 74 static char *next = NULL; |
75 if (optind == 0) | 75 if (optind == 0) |
76 next = NULL; | 76 next = NULL; |
77 | 77 |
78 optarg = NULL; | 78 optarg = NULL; |
79 | 79 |
80 if (next == NULL || *next == ('\0')) { | 80 if (next == NULL || *next == ('\0')) { |
81 if (optind == 0) | 81 if (optind == 0) |
82 optind++; | 82 optind++; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 } else if (optind < argc) { | 117 } else if (optind < argc) { |
118 optarg = argv[optind]; | 118 optarg = argv[optind]; |
119 optind++; | 119 optind++; |
120 } else { | 120 } else { |
121 return ('?'); | 121 return ('?'); |
122 } | 122 } |
123 } | 123 } |
124 | 124 |
125 return c; | 125 return c; |
126 } | 126 } |
OLD | NEW |