├── .gitignore ├── AUTHORS ├── COPYING ├── ChangeLog ├── INSTALL ├── Makefile.am ├── Makefile.in ├── NEWS ├── README ├── aclocal.m4 ├── compile ├── config.h.in ├── configure ├── configure.ac ├── depcomp ├── install-sh ├── lib ├── Makefile.am ├── Makefile.in ├── k3screenctrl-test │ ├── basic.sh │ ├── host.sh │ ├── port.sh │ ├── wan.sh │ └── wifi.sh └── k3screenctrl │ ├── basic.sh │ ├── host.sh │ ├── port.sh │ ├── wan.sh │ └── wifi.sh ├── missing └── src ├── Makefile.am ├── Makefile.in ├── checksum.h ├── common.h ├── config.c ├── config.h ├── crcccitt.c ├── debug.c ├── debug.h ├── file_util.c ├── file_util.h ├── frame.c ├── frame.h ├── gpio.c ├── gpio.h ├── handlers.c ├── handlers.h ├── infocenter.c ├── infocenter.h ├── logging.c ├── logging.h ├── main.c ├── mcu_proto.h ├── mem_util.c ├── mem_util.h ├── pages.c ├── pages.h ├── requests.c ├── requests.h ├── scripts.c ├── scripts.h ├── serial_port.c ├── serial_port.h ├── signals.c └── signals.h /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | a.out 3 | *.o 4 | .deps/ 5 | src/k3screenctrl 6 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/updateing/k3screenctrl/dd05ce9a5cb0cb6cebfc6b3b5823c7f6d75796ff/AUTHORS -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | , 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/updateing/k3screenctrl/dd05ce9a5cb0cb6cebfc6b3b5823c7f6d75796ff/ChangeLog -------------------------------------------------------------------------------- /INSTALL: -------------------------------------------------------------------------------- 1 | Installation Instructions 2 | ************************* 3 | 4 | Copyright (C) 1994-1996, 1999-2002, 2004-2013 Free Software Foundation, 5 | Inc. 6 | 7 | Copying and distribution of this file, with or without modification, 8 | are permitted in any medium without royalty provided the copyright 9 | notice and this notice are preserved. This file is offered as-is, 10 | without warranty of any kind. 11 | 12 | Basic Installation 13 | ================== 14 | 15 | Briefly, the shell command `./configure && make && make install' 16 | should configure, build, and install this package. The following 17 | more-detailed instructions are generic; see the `README' file for 18 | instructions specific to this package. Some packages provide this 19 | `INSTALL' file but do not implement all of the features documented 20 | below. The lack of an optional feature in a given package is not 21 | necessarily a bug. More recommendations for GNU packages can be found 22 | in *note Makefile Conventions: (standards)Makefile Conventions. 23 | 24 | The `configure' shell script attempts to guess correct values for 25 | various system-dependent variables used during compilation. It uses 26 | those values to create a `Makefile' in each directory of the package. 27 | It may also create one or more `.h' files containing system-dependent 28 | definitions. Finally, it creates a shell script `config.status' that 29 | you can run in the future to recreate the current configuration, and a 30 | file `config.log' containing compiler output (useful mainly for 31 | debugging `configure'). 32 | 33 | It can also use an optional file (typically called `config.cache' 34 | and enabled with `--cache-file=config.cache' or simply `-C') that saves 35 | the results of its tests to speed up reconfiguring. Caching is 36 | disabled by default to prevent problems with accidental use of stale 37 | cache files. 38 | 39 | If you need to do unusual things to compile the package, please try 40 | to figure out how `configure' could check whether to do them, and mail 41 | diffs or instructions to the address given in the `README' so they can 42 | be considered for the next release. If you are using the cache, and at 43 | some point `config.cache' contains results you don't want to keep, you 44 | may remove or edit it. 45 | 46 | The file `configure.ac' (or `configure.in') is used to create 47 | `configure' by a program called `autoconf'. You need `configure.ac' if 48 | you want to change it or regenerate `configure' using a newer version 49 | of `autoconf'. 50 | 51 | The simplest way to compile this package is: 52 | 53 | 1. `cd' to the directory containing the package's source code and type 54 | `./configure' to configure the package for your system. 55 | 56 | Running `configure' might take a while. While running, it prints 57 | some messages telling which features it is checking for. 58 | 59 | 2. Type `make' to compile the package. 60 | 61 | 3. Optionally, type `make check' to run any self-tests that come with 62 | the package, generally using the just-built uninstalled binaries. 63 | 64 | 4. Type `make install' to install the programs and any data files and 65 | documentation. When installing into a prefix owned by root, it is 66 | recommended that the package be configured and built as a regular 67 | user, and only the `make install' phase executed with root 68 | privileges. 69 | 70 | 5. Optionally, type `make installcheck' to repeat any self-tests, but 71 | this time using the binaries in their final installed location. 72 | This target does not install anything. Running this target as a 73 | regular user, particularly if the prior `make install' required 74 | root privileges, verifies that the installation completed 75 | correctly. 76 | 77 | 6. You can remove the program binaries and object files from the 78 | source code directory by typing `make clean'. To also remove the 79 | files that `configure' created (so you can compile the package for 80 | a different kind of computer), type `make distclean'. There is 81 | also a `make maintainer-clean' target, but that is intended mainly 82 | for the package's developers. If you use it, you may have to get 83 | all sorts of other programs in order to regenerate files that came 84 | with the distribution. 85 | 86 | 7. Often, you can also type `make uninstall' to remove the installed 87 | files again. In practice, not all packages have tested that 88 | uninstallation works correctly, even though it is required by the 89 | GNU Coding Standards. 90 | 91 | 8. Some packages, particularly those that use Automake, provide `make 92 | distcheck', which can by used by developers to test that all other 93 | targets like `make install' and `make uninstall' work correctly. 94 | This target is generally not run by end users. 95 | 96 | Compilers and Options 97 | ===================== 98 | 99 | Some systems require unusual options for compilation or linking that 100 | the `configure' script does not know about. Run `./configure --help' 101 | for details on some of the pertinent environment variables. 102 | 103 | You can give `configure' initial values for configuration parameters 104 | by setting variables in the command line or in the environment. Here 105 | is an example: 106 | 107 | ./configure CC=c99 CFLAGS=-g LIBS=-lposix 108 | 109 | *Note Defining Variables::, for more details. 110 | 111 | Compiling For Multiple Architectures 112 | ==================================== 113 | 114 | You can compile the package for more than one kind of computer at the 115 | same time, by placing the object files for each architecture in their 116 | own directory. To do this, you can use GNU `make'. `cd' to the 117 | directory where you want the object files and executables to go and run 118 | the `configure' script. `configure' automatically checks for the 119 | source code in the directory that `configure' is in and in `..'. This 120 | is known as a "VPATH" build. 121 | 122 | With a non-GNU `make', it is safer to compile the package for one 123 | architecture at a time in the source code directory. After you have 124 | installed the package for one architecture, use `make distclean' before 125 | reconfiguring for another architecture. 126 | 127 | On MacOS X 10.5 and later systems, you can create libraries and 128 | executables that work on multiple system types--known as "fat" or 129 | "universal" binaries--by specifying multiple `-arch' options to the 130 | compiler but only a single `-arch' option to the preprocessor. Like 131 | this: 132 | 133 | ./configure CC="gcc -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 134 | CXX="g++ -arch i386 -arch x86_64 -arch ppc -arch ppc64" \ 135 | CPP="gcc -E" CXXCPP="g++ -E" 136 | 137 | This is not guaranteed to produce working output in all cases, you 138 | may have to build one architecture at a time and combine the results 139 | using the `lipo' tool if you have problems. 140 | 141 | Installation Names 142 | ================== 143 | 144 | By default, `make install' installs the package's commands under 145 | `/usr/local/bin', include files under `/usr/local/include', etc. You 146 | can specify an installation prefix other than `/usr/local' by giving 147 | `configure' the option `--prefix=PREFIX', where PREFIX must be an 148 | absolute file name. 149 | 150 | You can specify separate installation prefixes for 151 | architecture-specific files and architecture-independent files. If you 152 | pass the option `--exec-prefix=PREFIX' to `configure', the package uses 153 | PREFIX as the prefix for installing programs and libraries. 154 | Documentation and other data files still use the regular prefix. 155 | 156 | In addition, if you use an unusual directory layout you can give 157 | options like `--bindir=DIR' to specify different values for particular 158 | kinds of files. Run `configure --help' for a list of the directories 159 | you can set and what kinds of files go in them. In general, the 160 | default for these options is expressed in terms of `${prefix}', so that 161 | specifying just `--prefix' will affect all of the other directory 162 | specifications that were not explicitly provided. 163 | 164 | The most portable way to affect installation locations is to pass the 165 | correct locations to `configure'; however, many packages provide one or 166 | both of the following shortcuts of passing variable assignments to the 167 | `make install' command line to change installation locations without 168 | having to reconfigure or recompile. 169 | 170 | The first method involves providing an override variable for each 171 | affected directory. For example, `make install 172 | prefix=/alternate/directory' will choose an alternate location for all 173 | directory configuration variables that were expressed in terms of 174 | `${prefix}'. Any directories that were specified during `configure', 175 | but not in terms of `${prefix}', must each be overridden at install 176 | time for the entire installation to be relocated. The approach of 177 | makefile variable overrides for each directory variable is required by 178 | the GNU Coding Standards, and ideally causes no recompilation. 179 | However, some platforms have known limitations with the semantics of 180 | shared libraries that end up requiring recompilation when using this 181 | method, particularly noticeable in packages that use GNU Libtool. 182 | 183 | The second method involves providing the `DESTDIR' variable. For 184 | example, `make install DESTDIR=/alternate/directory' will prepend 185 | `/alternate/directory' before all installation names. The approach of 186 | `DESTDIR' overrides is not required by the GNU Coding Standards, and 187 | does not work on platforms that have drive letters. On the other hand, 188 | it does better at avoiding recompilation issues, and works well even 189 | when some directory options were not specified in terms of `${prefix}' 190 | at `configure' time. 191 | 192 | Optional Features 193 | ================= 194 | 195 | If the package supports it, you can cause programs to be installed 196 | with an extra prefix or suffix on their names by giving `configure' the 197 | option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. 198 | 199 | Some packages pay attention to `--enable-FEATURE' options to 200 | `configure', where FEATURE indicates an optional part of the package. 201 | They may also pay attention to `--with-PACKAGE' options, where PACKAGE 202 | is something like `gnu-as' or `x' (for the X Window System). The 203 | `README' should mention any `--enable-' and `--with-' options that the 204 | package recognizes. 205 | 206 | For packages that use the X Window System, `configure' can usually 207 | find the X include and library files automatically, but if it doesn't, 208 | you can use the `configure' options `--x-includes=DIR' and 209 | `--x-libraries=DIR' to specify their locations. 210 | 211 | Some packages offer the ability to configure how verbose the 212 | execution of `make' will be. For these packages, running `./configure 213 | --enable-silent-rules' sets the default to minimal output, which can be 214 | overridden with `make V=1'; while running `./configure 215 | --disable-silent-rules' sets the default to verbose, which can be 216 | overridden with `make V=0'. 217 | 218 | Particular systems 219 | ================== 220 | 221 | On HP-UX, the default C compiler is not ANSI C compatible. If GNU 222 | CC is not installed, it is recommended to use the following options in 223 | order to use an ANSI C compiler: 224 | 225 | ./configure CC="cc -Ae -D_XOPEN_SOURCE=500" 226 | 227 | and if that doesn't work, install pre-built binaries of GCC for HP-UX. 228 | 229 | HP-UX `make' updates targets which have the same time stamps as 230 | their prerequisites, which makes it generally unusable when shipped 231 | generated files such as `configure' are involved. Use GNU `make' 232 | instead. 233 | 234 | On OSF/1 a.k.a. Tru64, some versions of the default C compiler cannot 235 | parse its `' header file. The option `-nodtk' can be used as 236 | a workaround. If GNU CC is not installed, it is therefore recommended 237 | to try 238 | 239 | ./configure CC="cc" 240 | 241 | and if that doesn't work, try 242 | 243 | ./configure CC="cc -nodtk" 244 | 245 | On Solaris, don't put `/usr/ucb' early in your `PATH'. This 246 | directory contains several dysfunctional programs; working variants of 247 | these programs are available in `/usr/bin'. So, if you need `/usr/ucb' 248 | in your `PATH', put it _after_ `/usr/bin'. 249 | 250 | On Haiku, software installed for all users goes in `/boot/common', 251 | not `/usr/local'. It is recommended to use the following options: 252 | 253 | ./configure --prefix=/boot/common 254 | 255 | Specifying the System Type 256 | ========================== 257 | 258 | There may be some features `configure' cannot figure out 259 | automatically, but needs to determine by the type of machine the package 260 | will run on. Usually, assuming the package is built to be run on the 261 | _same_ architectures, `configure' can figure that out, but if it prints 262 | a message saying it cannot guess the machine type, give it the 263 | `--build=TYPE' option. TYPE can either be a short name for the system 264 | type, such as `sun4', or a canonical name which has the form: 265 | 266 | CPU-COMPANY-SYSTEM 267 | 268 | where SYSTEM can have one of these forms: 269 | 270 | OS 271 | KERNEL-OS 272 | 273 | See the file `config.sub' for the possible values of each field. If 274 | `config.sub' isn't included in this package, then this package doesn't 275 | need to know the machine type. 276 | 277 | If you are _building_ compiler tools for cross-compiling, you should 278 | use the option `--target=TYPE' to select the type of system they will 279 | produce code for. 280 | 281 | If you want to _use_ a cross compiler, that generates code for a 282 | platform different from the build platform, you should specify the 283 | "host" platform (i.e., that on which the generated programs will 284 | eventually be run) with `--host=TYPE'. 285 | 286 | Sharing Defaults 287 | ================ 288 | 289 | If you want to set default values for `configure' scripts to share, 290 | you can create a site shell script called `config.site' that gives 291 | default values for variables like `CC', `cache_file', and `prefix'. 292 | `configure' looks for `PREFIX/share/config.site' if it exists, then 293 | `PREFIX/etc/config.site' if it exists. Or, you can set the 294 | `CONFIG_SITE' environment variable to the location of the site script. 295 | A warning: not all `configure' scripts look for a site script. 296 | 297 | Defining Variables 298 | ================== 299 | 300 | Variables not defined in a site shell script can be set in the 301 | environment passed to `configure'. However, some packages may run 302 | configure again during the build, and the customized values of these 303 | variables may be lost. In order to avoid this problem, you should set 304 | them in the `configure' command line, using `VAR=value'. For example: 305 | 306 | ./configure CC=/usr/local2/bin/gcc 307 | 308 | causes the specified `gcc' to be used as the C compiler (unless it is 309 | overridden in the site shell script). 310 | 311 | Unfortunately, this technique does not work for `CONFIG_SHELL' due to 312 | an Autoconf limitation. Until the limitation is lifted, you can use 313 | this workaround: 314 | 315 | CONFIG_SHELL=/bin/bash ./configure CONFIG_SHELL=/bin/bash 316 | 317 | `configure' Invocation 318 | ====================== 319 | 320 | `configure' recognizes the following options to control how it 321 | operates. 322 | 323 | `--help' 324 | `-h' 325 | Print a summary of all of the options to `configure', and exit. 326 | 327 | `--help=short' 328 | `--help=recursive' 329 | Print a summary of the options unique to this package's 330 | `configure', and exit. The `short' variant lists options used 331 | only in the top level, while the `recursive' variant lists options 332 | also present in any nested packages. 333 | 334 | `--version' 335 | `-V' 336 | Print the version of Autoconf used to generate the `configure' 337 | script, and exit. 338 | 339 | `--cache-file=FILE' 340 | Enable the cache: use and save the results of the tests in FILE, 341 | traditionally `config.cache'. FILE defaults to `/dev/null' to 342 | disable caching. 343 | 344 | `--config-cache' 345 | `-C' 346 | Alias for `--cache-file=config.cache'. 347 | 348 | `--quiet' 349 | `--silent' 350 | `-q' 351 | Do not print messages saying which checks are being made. To 352 | suppress all normal output, redirect it to `/dev/null' (any error 353 | messages will still be shown). 354 | 355 | `--srcdir=DIR' 356 | Look for the package's source code in directory DIR. Usually 357 | `configure' can determine that directory automatically. 358 | 359 | `--prefix=DIR' 360 | Use DIR as the installation prefix. *note Installation Names:: 361 | for more details, including other options available for fine-tuning 362 | the installation locations. 363 | 364 | `--no-create' 365 | `-n' 366 | Run the configure checks, but stop before creating any output 367 | files. 368 | 369 | `configure' also accepts some other, not widely useful, options. Run 370 | `configure --help' for more details. 371 | -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src lib 2 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/updateing/k3screenctrl/dd05ce9a5cb0cb6cebfc6b3b5823c7f6d75796ff/NEWS -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/updateing/k3screenctrl/dd05ce9a5cb0cb6cebfc6b3b5823c7f6d75796ff/README -------------------------------------------------------------------------------- /compile: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Wrapper for compilers which do not understand '-c -o'. 3 | 4 | scriptversion=2012-10-14.11; # UTC 5 | 6 | # Copyright (C) 1999-2014 Free Software Foundation, Inc. 7 | # Written by Tom Tromey . 8 | # 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | # 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | # 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | # This file is maintained in Automake, please report 28 | # bugs to or send patches to 29 | # . 30 | 31 | nl=' 32 | ' 33 | 34 | # We need space, tab and new line, in precisely that order. Quoting is 35 | # there to prevent tools from complaining about whitespace usage. 36 | IFS=" "" $nl" 37 | 38 | file_conv= 39 | 40 | # func_file_conv build_file lazy 41 | # Convert a $build file to $host form and store it in $file 42 | # Currently only supports Windows hosts. If the determined conversion 43 | # type is listed in (the comma separated) LAZY, no conversion will 44 | # take place. 45 | func_file_conv () 46 | { 47 | file=$1 48 | case $file in 49 | / | /[!/]*) # absolute file, and not a UNC file 50 | if test -z "$file_conv"; then 51 | # lazily determine how to convert abs files 52 | case `uname -s` in 53 | MINGW*) 54 | file_conv=mingw 55 | ;; 56 | CYGWIN*) 57 | file_conv=cygwin 58 | ;; 59 | *) 60 | file_conv=wine 61 | ;; 62 | esac 63 | fi 64 | case $file_conv/,$2, in 65 | *,$file_conv,*) 66 | ;; 67 | mingw/*) 68 | file=`cmd //C echo "$file " | sed -e 's/"\(.*\) " *$/\1/'` 69 | ;; 70 | cygwin/*) 71 | file=`cygpath -m "$file" || echo "$file"` 72 | ;; 73 | wine/*) 74 | file=`winepath -w "$file" || echo "$file"` 75 | ;; 76 | esac 77 | ;; 78 | esac 79 | } 80 | 81 | # func_cl_dashL linkdir 82 | # Make cl look for libraries in LINKDIR 83 | func_cl_dashL () 84 | { 85 | func_file_conv "$1" 86 | if test -z "$lib_path"; then 87 | lib_path=$file 88 | else 89 | lib_path="$lib_path;$file" 90 | fi 91 | linker_opts="$linker_opts -LIBPATH:$file" 92 | } 93 | 94 | # func_cl_dashl library 95 | # Do a library search-path lookup for cl 96 | func_cl_dashl () 97 | { 98 | lib=$1 99 | found=no 100 | save_IFS=$IFS 101 | IFS=';' 102 | for dir in $lib_path $LIB 103 | do 104 | IFS=$save_IFS 105 | if $shared && test -f "$dir/$lib.dll.lib"; then 106 | found=yes 107 | lib=$dir/$lib.dll.lib 108 | break 109 | fi 110 | if test -f "$dir/$lib.lib"; then 111 | found=yes 112 | lib=$dir/$lib.lib 113 | break 114 | fi 115 | if test -f "$dir/lib$lib.a"; then 116 | found=yes 117 | lib=$dir/lib$lib.a 118 | break 119 | fi 120 | done 121 | IFS=$save_IFS 122 | 123 | if test "$found" != yes; then 124 | lib=$lib.lib 125 | fi 126 | } 127 | 128 | # func_cl_wrapper cl arg... 129 | # Adjust compile command to suit cl 130 | func_cl_wrapper () 131 | { 132 | # Assume a capable shell 133 | lib_path= 134 | shared=: 135 | linker_opts= 136 | for arg 137 | do 138 | if test -n "$eat"; then 139 | eat= 140 | else 141 | case $1 in 142 | -o) 143 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 144 | eat=1 145 | case $2 in 146 | *.o | *.[oO][bB][jJ]) 147 | func_file_conv "$2" 148 | set x "$@" -Fo"$file" 149 | shift 150 | ;; 151 | *) 152 | func_file_conv "$2" 153 | set x "$@" -Fe"$file" 154 | shift 155 | ;; 156 | esac 157 | ;; 158 | -I) 159 | eat=1 160 | func_file_conv "$2" mingw 161 | set x "$@" -I"$file" 162 | shift 163 | ;; 164 | -I*) 165 | func_file_conv "${1#-I}" mingw 166 | set x "$@" -I"$file" 167 | shift 168 | ;; 169 | -l) 170 | eat=1 171 | func_cl_dashl "$2" 172 | set x "$@" "$lib" 173 | shift 174 | ;; 175 | -l*) 176 | func_cl_dashl "${1#-l}" 177 | set x "$@" "$lib" 178 | shift 179 | ;; 180 | -L) 181 | eat=1 182 | func_cl_dashL "$2" 183 | ;; 184 | -L*) 185 | func_cl_dashL "${1#-L}" 186 | ;; 187 | -static) 188 | shared=false 189 | ;; 190 | -Wl,*) 191 | arg=${1#-Wl,} 192 | save_ifs="$IFS"; IFS=',' 193 | for flag in $arg; do 194 | IFS="$save_ifs" 195 | linker_opts="$linker_opts $flag" 196 | done 197 | IFS="$save_ifs" 198 | ;; 199 | -Xlinker) 200 | eat=1 201 | linker_opts="$linker_opts $2" 202 | ;; 203 | -*) 204 | set x "$@" "$1" 205 | shift 206 | ;; 207 | *.cc | *.CC | *.cxx | *.CXX | *.[cC]++) 208 | func_file_conv "$1" 209 | set x "$@" -Tp"$file" 210 | shift 211 | ;; 212 | *.c | *.cpp | *.CPP | *.lib | *.LIB | *.Lib | *.OBJ | *.obj | *.[oO]) 213 | func_file_conv "$1" mingw 214 | set x "$@" "$file" 215 | shift 216 | ;; 217 | *) 218 | set x "$@" "$1" 219 | shift 220 | ;; 221 | esac 222 | fi 223 | shift 224 | done 225 | if test -n "$linker_opts"; then 226 | linker_opts="-link$linker_opts" 227 | fi 228 | exec "$@" $linker_opts 229 | exit 1 230 | } 231 | 232 | eat= 233 | 234 | case $1 in 235 | '') 236 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 237 | exit 1; 238 | ;; 239 | -h | --h*) 240 | cat <<\EOF 241 | Usage: compile [--help] [--version] PROGRAM [ARGS] 242 | 243 | Wrapper for compilers which do not understand '-c -o'. 244 | Remove '-o dest.o' from ARGS, run PROGRAM with the remaining 245 | arguments, and rename the output as expected. 246 | 247 | If you are trying to build a whole package this is not the 248 | right script to run: please start by reading the file 'INSTALL'. 249 | 250 | Report bugs to . 251 | EOF 252 | exit $? 253 | ;; 254 | -v | --v*) 255 | echo "compile $scriptversion" 256 | exit $? 257 | ;; 258 | cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) 259 | func_cl_wrapper "$@" # Doesn't return... 260 | ;; 261 | esac 262 | 263 | ofile= 264 | cfile= 265 | 266 | for arg 267 | do 268 | if test -n "$eat"; then 269 | eat= 270 | else 271 | case $1 in 272 | -o) 273 | # configure might choose to run compile as 'compile cc -o foo foo.c'. 274 | # So we strip '-o arg' only if arg is an object. 275 | eat=1 276 | case $2 in 277 | *.o | *.obj) 278 | ofile=$2 279 | ;; 280 | *) 281 | set x "$@" -o "$2" 282 | shift 283 | ;; 284 | esac 285 | ;; 286 | *.c) 287 | cfile=$1 288 | set x "$@" "$1" 289 | shift 290 | ;; 291 | *) 292 | set x "$@" "$1" 293 | shift 294 | ;; 295 | esac 296 | fi 297 | shift 298 | done 299 | 300 | if test -z "$ofile" || test -z "$cfile"; then 301 | # If no '-o' option was seen then we might have been invoked from a 302 | # pattern rule where we don't need one. That is ok -- this is a 303 | # normal compilation that the losing compiler can handle. If no 304 | # '.c' file was seen then we are probably linking. That is also 305 | # ok. 306 | exec "$@" 307 | fi 308 | 309 | # Name of file we expect compiler to create. 310 | cofile=`echo "$cfile" | sed 's|^.*[\\/]||; s|^[a-zA-Z]:||; s/\.c$/.o/'` 311 | 312 | # Create the lock directory. 313 | # Note: use '[/\\:.-]' here to ensure that we don't use the same name 314 | # that we are using for the .o file. Also, base the name on the expected 315 | # object file name, since that is what matters with a parallel build. 316 | lockdir=`echo "$cofile" | sed -e 's|[/\\:.-]|_|g'`.d 317 | while true; do 318 | if mkdir "$lockdir" >/dev/null 2>&1; then 319 | break 320 | fi 321 | sleep 1 322 | done 323 | # FIXME: race condition here if user kills between mkdir and trap. 324 | trap "rmdir '$lockdir'; exit 1" 1 2 15 325 | 326 | # Run the compile. 327 | "$@" 328 | ret=$? 329 | 330 | if test -f "$cofile"; then 331 | test "$cofile" = "$ofile" || mv "$cofile" "$ofile" 332 | elif test -f "${cofile}bj"; then 333 | test "${cofile}bj" = "$ofile" || mv "${cofile}bj" "$ofile" 334 | fi 335 | 336 | rmdir "$lockdir" 337 | exit $ret 338 | 339 | # Local Variables: 340 | # mode: shell-script 341 | # sh-indentation: 2 342 | # eval: (add-hook 'write-file-hooks 'time-stamp) 343 | # time-stamp-start: "scriptversion=" 344 | # time-stamp-format: "%:y-%02m-%02d.%02H" 345 | # time-stamp-time-zone: "UTC" 346 | # time-stamp-end: "; # UTC" 347 | # End: 348 | -------------------------------------------------------------------------------- /config.h.in: -------------------------------------------------------------------------------- 1 | /* config.h.in. Generated from configure.ac by autoheader. */ 2 | 3 | /* Define to 1 if you have the `alarm' function. */ 4 | #undef HAVE_ALARM 5 | 6 | /* Define to 1 if you have the header file. */ 7 | #undef HAVE_ARPA_INET_H 8 | 9 | /* Define to 1 if you have the `atexit' function. */ 10 | #undef HAVE_ATEXIT 11 | 12 | /* Define to 1 if you have the `bzero' function. */ 13 | #undef HAVE_BZERO 14 | 15 | /* Define to 1 if you have the header file. */ 16 | #undef HAVE_FCNTL_H 17 | 18 | /* Define to 1 if you have the `getpagesize' function. */ 19 | #undef HAVE_GETPAGESIZE 20 | 21 | /* Define to 1 if you have the header file. */ 22 | #undef HAVE_INTTYPES_H 23 | 24 | /* Define to 1 if your system has a GNU libc compatible `malloc' function, and 25 | to 0 otherwise. */ 26 | #undef HAVE_MALLOC 27 | 28 | /* Define to 1 if you have the `memchr' function. */ 29 | #undef HAVE_MEMCHR 30 | 31 | /* Define to 1 if you have the `memmove' function. */ 32 | #undef HAVE_MEMMOVE 33 | 34 | /* Define to 1 if you have the header file. */ 35 | #undef HAVE_MEMORY_H 36 | 37 | /* Define to 1 if you have a working `mmap' system call. */ 38 | #undef HAVE_MMAP 39 | 40 | /* Define to 1 if you have the `munmap' function. */ 41 | #undef HAVE_MUNMAP 42 | 43 | /* Define to 1 if you have the header file. */ 44 | #undef HAVE_STDINT_H 45 | 46 | /* Define to 1 if you have the header file. */ 47 | #undef HAVE_STDLIB_H 48 | 49 | /* Define to 1 if you have the `strchr' function. */ 50 | #undef HAVE_STRCHR 51 | 52 | /* Define to 1 if you have the `strdup' function. */ 53 | #undef HAVE_STRDUP 54 | 55 | /* Define to 1 if you have the `strerror' function. */ 56 | #undef HAVE_STRERROR 57 | 58 | /* Define to 1 if you have the header file. */ 59 | #undef HAVE_STRINGS_H 60 | 61 | /* Define to 1 if you have the header file. */ 62 | #undef HAVE_STRING_H 63 | 64 | /* Define to 1 if you have the `strndup' function. */ 65 | #undef HAVE_STRNDUP 66 | 67 | /* Define to 1 if you have the header file. */ 68 | #undef HAVE_SYSLOG_H 69 | 70 | /* Define to 1 if you have the header file. */ 71 | #undef HAVE_SYS_IOCTL_H 72 | 73 | /* Define to 1 if you have the header file. */ 74 | #undef HAVE_SYS_PARAM_H 75 | 76 | /* Define to 1 if you have the header file. */ 77 | #undef HAVE_SYS_STAT_H 78 | 79 | /* Define to 1 if you have the header file. */ 80 | #undef HAVE_SYS_TYPES_H 81 | 82 | /* Define to 1 if you have the header file. */ 83 | #undef HAVE_TERMIOS_H 84 | 85 | /* Define to 1 if you have the header file. */ 86 | #undef HAVE_UNISTD_H 87 | 88 | /* Define to 1 if the system has the type `_Bool'. */ 89 | #undef HAVE__BOOL 90 | 91 | /* Name of package */ 92 | #undef PACKAGE 93 | 94 | /* Define to the address where bug reports for this package should be sent. */ 95 | #undef PACKAGE_BUGREPORT 96 | 97 | /* Define to the full name of this package. */ 98 | #undef PACKAGE_NAME 99 | 100 | /* Define to the full name and version of this package. */ 101 | #undef PACKAGE_STRING 102 | 103 | /* Define to the one symbol short name of this package. */ 104 | #undef PACKAGE_TARNAME 105 | 106 | /* Define to the home page for this package. */ 107 | #undef PACKAGE_URL 108 | 109 | /* Define to the version of this package. */ 110 | #undef PACKAGE_VERSION 111 | 112 | /* Define to 1 if you have the ANSI C header files. */ 113 | #undef STDC_HEADERS 114 | 115 | /* Version number of package */ 116 | #undef VERSION 117 | 118 | /* Define to rpl_malloc if the replacement function should be used. */ 119 | #undef malloc 120 | 121 | /* Define to `long int' if does not define. */ 122 | #undef off_t 123 | 124 | /* Define to `unsigned int' if does not define. */ 125 | #undef size_t 126 | 127 | /* Define to the type of an unsigned integer type of width exactly 16 bits if 128 | such a type exists and the standard includes do not define it. */ 129 | #undef uint16_t 130 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | # -*- Autoconf -*- 2 | # Process this file with autoconf to produce a configure script. 3 | 4 | AC_PREREQ([2.69]) 5 | AC_INIT(k3screenctrl, 0.10, haotia@gmail.com) 6 | AM_INIT_AUTOMAKE 7 | AC_CONFIG_SRCDIR([src/signals.c]) 8 | AC_CONFIG_HEADERS([config.h]) 9 | 10 | # Checks for programs. 11 | AC_PROG_CC 12 | 13 | # Checks for libraries. 14 | 15 | # Checks for header files. 16 | AC_CHECK_HEADERS([arpa/inet.h fcntl.h stdint.h stdlib.h string.h sys/ioctl.h syslog.h termios.h unistd.h]) 17 | 18 | # Checks for typedefs, structures, and compiler characteristics. 19 | AC_CHECK_HEADER_STDBOOL 20 | AC_TYPE_OFF_T 21 | AC_TYPE_SIZE_T 22 | AC_TYPE_UINT16_T 23 | 24 | # Checks for library functions. 25 | AC_FUNC_MALLOC 26 | AC_FUNC_MMAP 27 | AC_CHECK_FUNCS([alarm atexit bzero memchr memmove munmap strchr strdup strerror strndup]) 28 | 29 | AC_CONFIG_FILES([Makefile src/Makefile lib/Makefile]) 30 | AC_OUTPUT 31 | -------------------------------------------------------------------------------- /depcomp: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # depcomp - compile a program generating dependencies as side-effects 3 | 4 | scriptversion=2013-05-30.07; # UTC 5 | 6 | # Copyright (C) 1999-2014 Free Software Foundation, Inc. 7 | 8 | # This program is free software; you can redistribute it and/or modify 9 | # it under the terms of the GNU General Public License as published by 10 | # the Free Software Foundation; either version 2, or (at your option) 11 | # any later version. 12 | 13 | # This program is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU General Public License for more details. 17 | 18 | # You should have received a copy of the GNU General Public License 19 | # along with this program. If not, see . 20 | 21 | # As a special exception to the GNU General Public License, if you 22 | # distribute this file as part of a program that contains a 23 | # configuration script generated by Autoconf, you may include it under 24 | # the same distribution terms that you use for the rest of that program. 25 | 26 | # Originally written by Alexandre Oliva . 27 | 28 | case $1 in 29 | '') 30 | echo "$0: No command. Try '$0 --help' for more information." 1>&2 31 | exit 1; 32 | ;; 33 | -h | --h*) 34 | cat <<\EOF 35 | Usage: depcomp [--help] [--version] PROGRAM [ARGS] 36 | 37 | Run PROGRAMS ARGS to compile a file, generating dependencies 38 | as side-effects. 39 | 40 | Environment variables: 41 | depmode Dependency tracking mode. 42 | source Source file read by 'PROGRAMS ARGS'. 43 | object Object file output by 'PROGRAMS ARGS'. 44 | DEPDIR directory where to store dependencies. 45 | depfile Dependency file to output. 46 | tmpdepfile Temporary file to use when outputting dependencies. 47 | libtool Whether libtool is used (yes/no). 48 | 49 | Report bugs to . 50 | EOF 51 | exit $? 52 | ;; 53 | -v | --v*) 54 | echo "depcomp $scriptversion" 55 | exit $? 56 | ;; 57 | esac 58 | 59 | # Get the directory component of the given path, and save it in the 60 | # global variables '$dir'. Note that this directory component will 61 | # be either empty or ending with a '/' character. This is deliberate. 62 | set_dir_from () 63 | { 64 | case $1 in 65 | */*) dir=`echo "$1" | sed -e 's|/[^/]*$|/|'`;; 66 | *) dir=;; 67 | esac 68 | } 69 | 70 | # Get the suffix-stripped basename of the given path, and save it the 71 | # global variable '$base'. 72 | set_base_from () 73 | { 74 | base=`echo "$1" | sed -e 's|^.*/||' -e 's/\.[^.]*$//'` 75 | } 76 | 77 | # If no dependency file was actually created by the compiler invocation, 78 | # we still have to create a dummy depfile, to avoid errors with the 79 | # Makefile "include basename.Plo" scheme. 80 | make_dummy_depfile () 81 | { 82 | echo "#dummy" > "$depfile" 83 | } 84 | 85 | # Factor out some common post-processing of the generated depfile. 86 | # Requires the auxiliary global variable '$tmpdepfile' to be set. 87 | aix_post_process_depfile () 88 | { 89 | # If the compiler actually managed to produce a dependency file, 90 | # post-process it. 91 | if test -f "$tmpdepfile"; then 92 | # Each line is of the form 'foo.o: dependency.h'. 93 | # Do two passes, one to just change these to 94 | # $object: dependency.h 95 | # and one to simply output 96 | # dependency.h: 97 | # which is needed to avoid the deleted-header problem. 98 | { sed -e "s,^.*\.[$lower]*:,$object:," < "$tmpdepfile" 99 | sed -e "s,^.*\.[$lower]*:[$tab ]*,," -e 's,$,:,' < "$tmpdepfile" 100 | } > "$depfile" 101 | rm -f "$tmpdepfile" 102 | else 103 | make_dummy_depfile 104 | fi 105 | } 106 | 107 | # A tabulation character. 108 | tab=' ' 109 | # A newline character. 110 | nl=' 111 | ' 112 | # Character ranges might be problematic outside the C locale. 113 | # These definitions help. 114 | upper=ABCDEFGHIJKLMNOPQRSTUVWXYZ 115 | lower=abcdefghijklmnopqrstuvwxyz 116 | digits=0123456789 117 | alpha=${upper}${lower} 118 | 119 | if test -z "$depmode" || test -z "$source" || test -z "$object"; then 120 | echo "depcomp: Variables source, object and depmode must be set" 1>&2 121 | exit 1 122 | fi 123 | 124 | # Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po. 125 | depfile=${depfile-`echo "$object" | 126 | sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`} 127 | tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`} 128 | 129 | rm -f "$tmpdepfile" 130 | 131 | # Avoid interferences from the environment. 132 | gccflag= dashmflag= 133 | 134 | # Some modes work just like other modes, but use different flags. We 135 | # parameterize here, but still list the modes in the big case below, 136 | # to make depend.m4 easier to write. Note that we *cannot* use a case 137 | # here, because this file can only contain one case statement. 138 | if test "$depmode" = hp; then 139 | # HP compiler uses -M and no extra arg. 140 | gccflag=-M 141 | depmode=gcc 142 | fi 143 | 144 | if test "$depmode" = dashXmstdout; then 145 | # This is just like dashmstdout with a different argument. 146 | dashmflag=-xM 147 | depmode=dashmstdout 148 | fi 149 | 150 | cygpath_u="cygpath -u -f -" 151 | if test "$depmode" = msvcmsys; then 152 | # This is just like msvisualcpp but w/o cygpath translation. 153 | # Just convert the backslash-escaped backslashes to single forward 154 | # slashes to satisfy depend.m4 155 | cygpath_u='sed s,\\\\,/,g' 156 | depmode=msvisualcpp 157 | fi 158 | 159 | if test "$depmode" = msvc7msys; then 160 | # This is just like msvc7 but w/o cygpath translation. 161 | # Just convert the backslash-escaped backslashes to single forward 162 | # slashes to satisfy depend.m4 163 | cygpath_u='sed s,\\\\,/,g' 164 | depmode=msvc7 165 | fi 166 | 167 | if test "$depmode" = xlc; then 168 | # IBM C/C++ Compilers xlc/xlC can output gcc-like dependency information. 169 | gccflag=-qmakedep=gcc,-MF 170 | depmode=gcc 171 | fi 172 | 173 | case "$depmode" in 174 | gcc3) 175 | ## gcc 3 implements dependency tracking that does exactly what 176 | ## we want. Yay! Note: for some reason libtool 1.4 doesn't like 177 | ## it if -MD -MP comes after the -MF stuff. Hmm. 178 | ## Unfortunately, FreeBSD c89 acceptance of flags depends upon 179 | ## the command line argument order; so add the flags where they 180 | ## appear in depend2.am. Note that the slowdown incurred here 181 | ## affects only configure: in makefiles, %FASTDEP% shortcuts this. 182 | for arg 183 | do 184 | case $arg in 185 | -c) set fnord "$@" -MT "$object" -MD -MP -MF "$tmpdepfile" "$arg" ;; 186 | *) set fnord "$@" "$arg" ;; 187 | esac 188 | shift # fnord 189 | shift # $arg 190 | done 191 | "$@" 192 | stat=$? 193 | if test $stat -ne 0; then 194 | rm -f "$tmpdepfile" 195 | exit $stat 196 | fi 197 | mv "$tmpdepfile" "$depfile" 198 | ;; 199 | 200 | gcc) 201 | ## Note that this doesn't just cater to obsosete pre-3.x GCC compilers. 202 | ## but also to in-use compilers like IMB xlc/xlC and the HP C compiler. 203 | ## (see the conditional assignment to $gccflag above). 204 | ## There are various ways to get dependency output from gcc. Here's 205 | ## why we pick this rather obscure method: 206 | ## - Don't want to use -MD because we'd like the dependencies to end 207 | ## up in a subdir. Having to rename by hand is ugly. 208 | ## (We might end up doing this anyway to support other compilers.) 209 | ## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like 210 | ## -MM, not -M (despite what the docs say). Also, it might not be 211 | ## supported by the other compilers which use the 'gcc' depmode. 212 | ## - Using -M directly means running the compiler twice (even worse 213 | ## than renaming). 214 | if test -z "$gccflag"; then 215 | gccflag=-MD, 216 | fi 217 | "$@" -Wp,"$gccflag$tmpdepfile" 218 | stat=$? 219 | if test $stat -ne 0; then 220 | rm -f "$tmpdepfile" 221 | exit $stat 222 | fi 223 | rm -f "$depfile" 224 | echo "$object : \\" > "$depfile" 225 | # The second -e expression handles DOS-style file names with drive 226 | # letters. 227 | sed -e 's/^[^:]*: / /' \ 228 | -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile" 229 | ## This next piece of magic avoids the "deleted header file" problem. 230 | ## The problem is that when a header file which appears in a .P file 231 | ## is deleted, the dependency causes make to die (because there is 232 | ## typically no way to rebuild the header). We avoid this by adding 233 | ## dummy dependencies for each header file. Too bad gcc doesn't do 234 | ## this for us directly. 235 | ## Some versions of gcc put a space before the ':'. On the theory 236 | ## that the space means something, we add a space to the output as 237 | ## well. hp depmode also adds that space, but also prefixes the VPATH 238 | ## to the object. Take care to not repeat it in the output. 239 | ## Some versions of the HPUX 10.20 sed can't process this invocation 240 | ## correctly. Breaking it into two sed invocations is a workaround. 241 | tr ' ' "$nl" < "$tmpdepfile" \ 242 | | sed -e 's/^\\$//' -e '/^$/d' -e "s|.*$object$||" -e '/:$/d' \ 243 | | sed -e 's/$/ :/' >> "$depfile" 244 | rm -f "$tmpdepfile" 245 | ;; 246 | 247 | hp) 248 | # This case exists only to let depend.m4 do its work. It works by 249 | # looking at the text of this script. This case will never be run, 250 | # since it is checked for above. 251 | exit 1 252 | ;; 253 | 254 | sgi) 255 | if test "$libtool" = yes; then 256 | "$@" "-Wp,-MDupdate,$tmpdepfile" 257 | else 258 | "$@" -MDupdate "$tmpdepfile" 259 | fi 260 | stat=$? 261 | if test $stat -ne 0; then 262 | rm -f "$tmpdepfile" 263 | exit $stat 264 | fi 265 | rm -f "$depfile" 266 | 267 | if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files 268 | echo "$object : \\" > "$depfile" 269 | # Clip off the initial element (the dependent). Don't try to be 270 | # clever and replace this with sed code, as IRIX sed won't handle 271 | # lines with more than a fixed number of characters (4096 in 272 | # IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines; 273 | # the IRIX cc adds comments like '#:fec' to the end of the 274 | # dependency line. 275 | tr ' ' "$nl" < "$tmpdepfile" \ 276 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' \ 277 | | tr "$nl" ' ' >> "$depfile" 278 | echo >> "$depfile" 279 | # The second pass generates a dummy entry for each header file. 280 | tr ' ' "$nl" < "$tmpdepfile" \ 281 | | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \ 282 | >> "$depfile" 283 | else 284 | make_dummy_depfile 285 | fi 286 | rm -f "$tmpdepfile" 287 | ;; 288 | 289 | xlc) 290 | # This case exists only to let depend.m4 do its work. It works by 291 | # looking at the text of this script. This case will never be run, 292 | # since it is checked for above. 293 | exit 1 294 | ;; 295 | 296 | aix) 297 | # The C for AIX Compiler uses -M and outputs the dependencies 298 | # in a .u file. In older versions, this file always lives in the 299 | # current directory. Also, the AIX compiler puts '$object:' at the 300 | # start of each line; $object doesn't have directory information. 301 | # Version 6 uses the directory in both cases. 302 | set_dir_from "$object" 303 | set_base_from "$object" 304 | if test "$libtool" = yes; then 305 | tmpdepfile1=$dir$base.u 306 | tmpdepfile2=$base.u 307 | tmpdepfile3=$dir.libs/$base.u 308 | "$@" -Wc,-M 309 | else 310 | tmpdepfile1=$dir$base.u 311 | tmpdepfile2=$dir$base.u 312 | tmpdepfile3=$dir$base.u 313 | "$@" -M 314 | fi 315 | stat=$? 316 | if test $stat -ne 0; then 317 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 318 | exit $stat 319 | fi 320 | 321 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 322 | do 323 | test -f "$tmpdepfile" && break 324 | done 325 | aix_post_process_depfile 326 | ;; 327 | 328 | tcc) 329 | # tcc (Tiny C Compiler) understand '-MD -MF file' since version 0.9.26 330 | # FIXME: That version still under development at the moment of writing. 331 | # Make that this statement remains true also for stable, released 332 | # versions. 333 | # It will wrap lines (doesn't matter whether long or short) with a 334 | # trailing '\', as in: 335 | # 336 | # foo.o : \ 337 | # foo.c \ 338 | # foo.h \ 339 | # 340 | # It will put a trailing '\' even on the last line, and will use leading 341 | # spaces rather than leading tabs (at least since its commit 0394caf7 342 | # "Emit spaces for -MD"). 343 | "$@" -MD -MF "$tmpdepfile" 344 | stat=$? 345 | if test $stat -ne 0; then 346 | rm -f "$tmpdepfile" 347 | exit $stat 348 | fi 349 | rm -f "$depfile" 350 | # Each non-empty line is of the form 'foo.o : \' or ' dep.h \'. 351 | # We have to change lines of the first kind to '$object: \'. 352 | sed -e "s|.*:|$object :|" < "$tmpdepfile" > "$depfile" 353 | # And for each line of the second kind, we have to emit a 'dep.h:' 354 | # dummy dependency, to avoid the deleted-header problem. 355 | sed -n -e 's|^ *\(.*\) *\\$|\1:|p' < "$tmpdepfile" >> "$depfile" 356 | rm -f "$tmpdepfile" 357 | ;; 358 | 359 | ## The order of this option in the case statement is important, since the 360 | ## shell code in configure will try each of these formats in the order 361 | ## listed in this file. A plain '-MD' option would be understood by many 362 | ## compilers, so we must ensure this comes after the gcc and icc options. 363 | pgcc) 364 | # Portland's C compiler understands '-MD'. 365 | # Will always output deps to 'file.d' where file is the root name of the 366 | # source file under compilation, even if file resides in a subdirectory. 367 | # The object file name does not affect the name of the '.d' file. 368 | # pgcc 10.2 will output 369 | # foo.o: sub/foo.c sub/foo.h 370 | # and will wrap long lines using '\' : 371 | # foo.o: sub/foo.c ... \ 372 | # sub/foo.h ... \ 373 | # ... 374 | set_dir_from "$object" 375 | # Use the source, not the object, to determine the base name, since 376 | # that's sadly what pgcc will do too. 377 | set_base_from "$source" 378 | tmpdepfile=$base.d 379 | 380 | # For projects that build the same source file twice into different object 381 | # files, the pgcc approach of using the *source* file root name can cause 382 | # problems in parallel builds. Use a locking strategy to avoid stomping on 383 | # the same $tmpdepfile. 384 | lockdir=$base.d-lock 385 | trap " 386 | echo '$0: caught signal, cleaning up...' >&2 387 | rmdir '$lockdir' 388 | exit 1 389 | " 1 2 13 15 390 | numtries=100 391 | i=$numtries 392 | while test $i -gt 0; do 393 | # mkdir is a portable test-and-set. 394 | if mkdir "$lockdir" 2>/dev/null; then 395 | # This process acquired the lock. 396 | "$@" -MD 397 | stat=$? 398 | # Release the lock. 399 | rmdir "$lockdir" 400 | break 401 | else 402 | # If the lock is being held by a different process, wait 403 | # until the winning process is done or we timeout. 404 | while test -d "$lockdir" && test $i -gt 0; do 405 | sleep 1 406 | i=`expr $i - 1` 407 | done 408 | fi 409 | i=`expr $i - 1` 410 | done 411 | trap - 1 2 13 15 412 | if test $i -le 0; then 413 | echo "$0: failed to acquire lock after $numtries attempts" >&2 414 | echo "$0: check lockdir '$lockdir'" >&2 415 | exit 1 416 | fi 417 | 418 | if test $stat -ne 0; then 419 | rm -f "$tmpdepfile" 420 | exit $stat 421 | fi 422 | rm -f "$depfile" 423 | # Each line is of the form `foo.o: dependent.h', 424 | # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'. 425 | # Do two passes, one to just change these to 426 | # `$object: dependent.h' and one to simply `dependent.h:'. 427 | sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile" 428 | # Some versions of the HPUX 10.20 sed can't process this invocation 429 | # correctly. Breaking it into two sed invocations is a workaround. 430 | sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" \ 431 | | sed -e 's/$/ :/' >> "$depfile" 432 | rm -f "$tmpdepfile" 433 | ;; 434 | 435 | hp2) 436 | # The "hp" stanza above does not work with aCC (C++) and HP's ia64 437 | # compilers, which have integrated preprocessors. The correct option 438 | # to use with these is +Maked; it writes dependencies to a file named 439 | # 'foo.d', which lands next to the object file, wherever that 440 | # happens to be. 441 | # Much of this is similar to the tru64 case; see comments there. 442 | set_dir_from "$object" 443 | set_base_from "$object" 444 | if test "$libtool" = yes; then 445 | tmpdepfile1=$dir$base.d 446 | tmpdepfile2=$dir.libs/$base.d 447 | "$@" -Wc,+Maked 448 | else 449 | tmpdepfile1=$dir$base.d 450 | tmpdepfile2=$dir$base.d 451 | "$@" +Maked 452 | fi 453 | stat=$? 454 | if test $stat -ne 0; then 455 | rm -f "$tmpdepfile1" "$tmpdepfile2" 456 | exit $stat 457 | fi 458 | 459 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" 460 | do 461 | test -f "$tmpdepfile" && break 462 | done 463 | if test -f "$tmpdepfile"; then 464 | sed -e "s,^.*\.[$lower]*:,$object:," "$tmpdepfile" > "$depfile" 465 | # Add 'dependent.h:' lines. 466 | sed -ne '2,${ 467 | s/^ *// 468 | s/ \\*$// 469 | s/$/:/ 470 | p 471 | }' "$tmpdepfile" >> "$depfile" 472 | else 473 | make_dummy_depfile 474 | fi 475 | rm -f "$tmpdepfile" "$tmpdepfile2" 476 | ;; 477 | 478 | tru64) 479 | # The Tru64 compiler uses -MD to generate dependencies as a side 480 | # effect. 'cc -MD -o foo.o ...' puts the dependencies into 'foo.o.d'. 481 | # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put 482 | # dependencies in 'foo.d' instead, so we check for that too. 483 | # Subdirectories are respected. 484 | set_dir_from "$object" 485 | set_base_from "$object" 486 | 487 | if test "$libtool" = yes; then 488 | # Libtool generates 2 separate objects for the 2 libraries. These 489 | # two compilations output dependencies in $dir.libs/$base.o.d and 490 | # in $dir$base.o.d. We have to check for both files, because 491 | # one of the two compilations can be disabled. We should prefer 492 | # $dir$base.o.d over $dir.libs/$base.o.d because the latter is 493 | # automatically cleaned when .libs/ is deleted, while ignoring 494 | # the former would cause a distcleancheck panic. 495 | tmpdepfile1=$dir$base.o.d # libtool 1.5 496 | tmpdepfile2=$dir.libs/$base.o.d # Likewise. 497 | tmpdepfile3=$dir.libs/$base.d # Compaq CCC V6.2-504 498 | "$@" -Wc,-MD 499 | else 500 | tmpdepfile1=$dir$base.d 501 | tmpdepfile2=$dir$base.d 502 | tmpdepfile3=$dir$base.d 503 | "$@" -MD 504 | fi 505 | 506 | stat=$? 507 | if test $stat -ne 0; then 508 | rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 509 | exit $stat 510 | fi 511 | 512 | for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" 513 | do 514 | test -f "$tmpdepfile" && break 515 | done 516 | # Same post-processing that is required for AIX mode. 517 | aix_post_process_depfile 518 | ;; 519 | 520 | msvc7) 521 | if test "$libtool" = yes; then 522 | showIncludes=-Wc,-showIncludes 523 | else 524 | showIncludes=-showIncludes 525 | fi 526 | "$@" $showIncludes > "$tmpdepfile" 527 | stat=$? 528 | grep -v '^Note: including file: ' "$tmpdepfile" 529 | if test $stat -ne 0; then 530 | rm -f "$tmpdepfile" 531 | exit $stat 532 | fi 533 | rm -f "$depfile" 534 | echo "$object : \\" > "$depfile" 535 | # The first sed program below extracts the file names and escapes 536 | # backslashes for cygpath. The second sed program outputs the file 537 | # name when reading, but also accumulates all include files in the 538 | # hold buffer in order to output them again at the end. This only 539 | # works with sed implementations that can handle large buffers. 540 | sed < "$tmpdepfile" -n ' 541 | /^Note: including file: *\(.*\)/ { 542 | s//\1/ 543 | s/\\/\\\\/g 544 | p 545 | }' | $cygpath_u | sort -u | sed -n ' 546 | s/ /\\ /g 547 | s/\(.*\)/'"$tab"'\1 \\/p 548 | s/.\(.*\) \\/\1:/ 549 | H 550 | $ { 551 | s/.*/'"$tab"'/ 552 | G 553 | p 554 | }' >> "$depfile" 555 | echo >> "$depfile" # make sure the fragment doesn't end with a backslash 556 | rm -f "$tmpdepfile" 557 | ;; 558 | 559 | msvc7msys) 560 | # This case exists only to let depend.m4 do its work. It works by 561 | # looking at the text of this script. This case will never be run, 562 | # since it is checked for above. 563 | exit 1 564 | ;; 565 | 566 | #nosideeffect) 567 | # This comment above is used by automake to tell side-effect 568 | # dependency tracking mechanisms from slower ones. 569 | 570 | dashmstdout) 571 | # Important note: in order to support this mode, a compiler *must* 572 | # always write the preprocessed file to stdout, regardless of -o. 573 | "$@" || exit $? 574 | 575 | # Remove the call to Libtool. 576 | if test "$libtool" = yes; then 577 | while test "X$1" != 'X--mode=compile'; do 578 | shift 579 | done 580 | shift 581 | fi 582 | 583 | # Remove '-o $object'. 584 | IFS=" " 585 | for arg 586 | do 587 | case $arg in 588 | -o) 589 | shift 590 | ;; 591 | $object) 592 | shift 593 | ;; 594 | *) 595 | set fnord "$@" "$arg" 596 | shift # fnord 597 | shift # $arg 598 | ;; 599 | esac 600 | done 601 | 602 | test -z "$dashmflag" && dashmflag=-M 603 | # Require at least two characters before searching for ':' 604 | # in the target name. This is to cope with DOS-style filenames: 605 | # a dependency such as 'c:/foo/bar' could be seen as target 'c' otherwise. 606 | "$@" $dashmflag | 607 | sed "s|^[$tab ]*[^:$tab ][^:][^:]*:[$tab ]*|$object: |" > "$tmpdepfile" 608 | rm -f "$depfile" 609 | cat < "$tmpdepfile" > "$depfile" 610 | # Some versions of the HPUX 10.20 sed can't process this sed invocation 611 | # correctly. Breaking it into two sed invocations is a workaround. 612 | tr ' ' "$nl" < "$tmpdepfile" \ 613 | | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 614 | | sed -e 's/$/ :/' >> "$depfile" 615 | rm -f "$tmpdepfile" 616 | ;; 617 | 618 | dashXmstdout) 619 | # This case only exists to satisfy depend.m4. It is never actually 620 | # run, as this mode is specially recognized in the preamble. 621 | exit 1 622 | ;; 623 | 624 | makedepend) 625 | "$@" || exit $? 626 | # Remove any Libtool call 627 | if test "$libtool" = yes; then 628 | while test "X$1" != 'X--mode=compile'; do 629 | shift 630 | done 631 | shift 632 | fi 633 | # X makedepend 634 | shift 635 | cleared=no eat=no 636 | for arg 637 | do 638 | case $cleared in 639 | no) 640 | set ""; shift 641 | cleared=yes ;; 642 | esac 643 | if test $eat = yes; then 644 | eat=no 645 | continue 646 | fi 647 | case "$arg" in 648 | -D*|-I*) 649 | set fnord "$@" "$arg"; shift ;; 650 | # Strip any option that makedepend may not understand. Remove 651 | # the object too, otherwise makedepend will parse it as a source file. 652 | -arch) 653 | eat=yes ;; 654 | -*|$object) 655 | ;; 656 | *) 657 | set fnord "$@" "$arg"; shift ;; 658 | esac 659 | done 660 | obj_suffix=`echo "$object" | sed 's/^.*\././'` 661 | touch "$tmpdepfile" 662 | ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@" 663 | rm -f "$depfile" 664 | # makedepend may prepend the VPATH from the source file name to the object. 665 | # No need to regex-escape $object, excess matching of '.' is harmless. 666 | sed "s|^.*\($object *:\)|\1|" "$tmpdepfile" > "$depfile" 667 | # Some versions of the HPUX 10.20 sed can't process the last invocation 668 | # correctly. Breaking it into two sed invocations is a workaround. 669 | sed '1,2d' "$tmpdepfile" \ 670 | | tr ' ' "$nl" \ 671 | | sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' \ 672 | | sed -e 's/$/ :/' >> "$depfile" 673 | rm -f "$tmpdepfile" "$tmpdepfile".bak 674 | ;; 675 | 676 | cpp) 677 | # Important note: in order to support this mode, a compiler *must* 678 | # always write the preprocessed file to stdout. 679 | "$@" || exit $? 680 | 681 | # Remove the call to Libtool. 682 | if test "$libtool" = yes; then 683 | while test "X$1" != 'X--mode=compile'; do 684 | shift 685 | done 686 | shift 687 | fi 688 | 689 | # Remove '-o $object'. 690 | IFS=" " 691 | for arg 692 | do 693 | case $arg in 694 | -o) 695 | shift 696 | ;; 697 | $object) 698 | shift 699 | ;; 700 | *) 701 | set fnord "$@" "$arg" 702 | shift # fnord 703 | shift # $arg 704 | ;; 705 | esac 706 | done 707 | 708 | "$@" -E \ 709 | | sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 710 | -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \ 711 | | sed '$ s: \\$::' > "$tmpdepfile" 712 | rm -f "$depfile" 713 | echo "$object : \\" > "$depfile" 714 | cat < "$tmpdepfile" >> "$depfile" 715 | sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile" 716 | rm -f "$tmpdepfile" 717 | ;; 718 | 719 | msvisualcpp) 720 | # Important note: in order to support this mode, a compiler *must* 721 | # always write the preprocessed file to stdout. 722 | "$@" || exit $? 723 | 724 | # Remove the call to Libtool. 725 | if test "$libtool" = yes; then 726 | while test "X$1" != 'X--mode=compile'; do 727 | shift 728 | done 729 | shift 730 | fi 731 | 732 | IFS=" " 733 | for arg 734 | do 735 | case "$arg" in 736 | -o) 737 | shift 738 | ;; 739 | $object) 740 | shift 741 | ;; 742 | "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI") 743 | set fnord "$@" 744 | shift 745 | shift 746 | ;; 747 | *) 748 | set fnord "$@" "$arg" 749 | shift 750 | shift 751 | ;; 752 | esac 753 | done 754 | "$@" -E 2>/dev/null | 755 | sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::\1:p' | $cygpath_u | sort -u > "$tmpdepfile" 756 | rm -f "$depfile" 757 | echo "$object : \\" > "$depfile" 758 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::'"$tab"'\1 \\:p' >> "$depfile" 759 | echo "$tab" >> "$depfile" 760 | sed < "$tmpdepfile" -n -e 's% %\\ %g' -e '/^\(.*\)$/ s::\1\::p' >> "$depfile" 761 | rm -f "$tmpdepfile" 762 | ;; 763 | 764 | msvcmsys) 765 | # This case exists only to let depend.m4 do its work. It works by 766 | # looking at the text of this script. This case will never be run, 767 | # since it is checked for above. 768 | exit 1 769 | ;; 770 | 771 | none) 772 | exec "$@" 773 | ;; 774 | 775 | *) 776 | echo "Unknown depmode $depmode" 1>&2 777 | exit 1 778 | ;; 779 | esac 780 | 781 | exit 0 782 | 783 | # Local Variables: 784 | # mode: shell-script 785 | # sh-indentation: 2 786 | # eval: (add-hook 'write-file-hooks 'time-stamp) 787 | # time-stamp-start: "scriptversion=" 788 | # time-stamp-format: "%:y-%02m-%02d.%02H" 789 | # time-stamp-time-zone: "UTC" 790 | # time-stamp-end: "; # UTC" 791 | # End: 792 | -------------------------------------------------------------------------------- /install-sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # install - install a program, script, or datafile 3 | 4 | scriptversion=2014-09-12.12; # UTC 5 | 6 | # This originates from X11R5 (mit/util/scripts/install.sh), which was 7 | # later released in X11R6 (xc/config/util/install.sh) with the 8 | # following copyright and license. 9 | # 10 | # Copyright (C) 1994 X Consortium 11 | # 12 | # Permission is hereby granted, free of charge, to any person obtaining a copy 13 | # of this software and associated documentation files (the "Software"), to 14 | # deal in the Software without restriction, including without limitation the 15 | # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 16 | # sell copies of the Software, and to permit persons to whom the Software is 17 | # furnished to do so, subject to the following conditions: 18 | # 19 | # The above copyright notice and this permission notice shall be included in 20 | # all copies or substantial portions of the Software. 21 | # 22 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 23 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 24 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 25 | # X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 26 | # AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC- 27 | # TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # Except as contained in this notice, the name of the X Consortium shall not 30 | # be used in advertising or otherwise to promote the sale, use or other deal- 31 | # ings in this Software without prior written authorization from the X Consor- 32 | # tium. 33 | # 34 | # 35 | # FSF changes to this file are in the public domain. 36 | # 37 | # Calling this script install-sh is preferred over install.sh, to prevent 38 | # 'make' implicit rules from creating a file called install from it 39 | # when there is no Makefile. 40 | # 41 | # This script is compatible with the BSD install script, but was written 42 | # from scratch. 43 | 44 | tab=' ' 45 | nl=' 46 | ' 47 | IFS=" $tab$nl" 48 | 49 | # Set DOITPROG to "echo" to test this script. 50 | 51 | doit=${DOITPROG-} 52 | doit_exec=${doit:-exec} 53 | 54 | # Put in absolute file names if you don't have them in your path; 55 | # or use environment vars. 56 | 57 | chgrpprog=${CHGRPPROG-chgrp} 58 | chmodprog=${CHMODPROG-chmod} 59 | chownprog=${CHOWNPROG-chown} 60 | cmpprog=${CMPPROG-cmp} 61 | cpprog=${CPPROG-cp} 62 | mkdirprog=${MKDIRPROG-mkdir} 63 | mvprog=${MVPROG-mv} 64 | rmprog=${RMPROG-rm} 65 | stripprog=${STRIPPROG-strip} 66 | 67 | posix_mkdir= 68 | 69 | # Desired mode of installed file. 70 | mode=0755 71 | 72 | chgrpcmd= 73 | chmodcmd=$chmodprog 74 | chowncmd= 75 | mvcmd=$mvprog 76 | rmcmd="$rmprog -f" 77 | stripcmd= 78 | 79 | src= 80 | dst= 81 | dir_arg= 82 | dst_arg= 83 | 84 | copy_on_change=false 85 | is_target_a_directory=possibly 86 | 87 | usage="\ 88 | Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE 89 | or: $0 [OPTION]... SRCFILES... DIRECTORY 90 | or: $0 [OPTION]... -t DIRECTORY SRCFILES... 91 | or: $0 [OPTION]... -d DIRECTORIES... 92 | 93 | In the 1st form, copy SRCFILE to DSTFILE. 94 | In the 2nd and 3rd, copy all SRCFILES to DIRECTORY. 95 | In the 4th, create DIRECTORIES. 96 | 97 | Options: 98 | --help display this help and exit. 99 | --version display version info and exit. 100 | 101 | -c (ignored) 102 | -C install only if different (preserve the last data modification time) 103 | -d create directories instead of installing files. 104 | -g GROUP $chgrpprog installed files to GROUP. 105 | -m MODE $chmodprog installed files to MODE. 106 | -o USER $chownprog installed files to USER. 107 | -s $stripprog installed files. 108 | -t DIRECTORY install into DIRECTORY. 109 | -T report an error if DSTFILE is a directory. 110 | 111 | Environment variables override the default commands: 112 | CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG 113 | RMPROG STRIPPROG 114 | " 115 | 116 | while test $# -ne 0; do 117 | case $1 in 118 | -c) ;; 119 | 120 | -C) copy_on_change=true;; 121 | 122 | -d) dir_arg=true;; 123 | 124 | -g) chgrpcmd="$chgrpprog $2" 125 | shift;; 126 | 127 | --help) echo "$usage"; exit $?;; 128 | 129 | -m) mode=$2 130 | case $mode in 131 | *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*) 132 | echo "$0: invalid mode: $mode" >&2 133 | exit 1;; 134 | esac 135 | shift;; 136 | 137 | -o) chowncmd="$chownprog $2" 138 | shift;; 139 | 140 | -s) stripcmd=$stripprog;; 141 | 142 | -t) 143 | is_target_a_directory=always 144 | dst_arg=$2 145 | # Protect names problematic for 'test' and other utilities. 146 | case $dst_arg in 147 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 148 | esac 149 | shift;; 150 | 151 | -T) is_target_a_directory=never;; 152 | 153 | --version) echo "$0 $scriptversion"; exit $?;; 154 | 155 | --) shift 156 | break;; 157 | 158 | -*) echo "$0: invalid option: $1" >&2 159 | exit 1;; 160 | 161 | *) break;; 162 | esac 163 | shift 164 | done 165 | 166 | # We allow the use of options -d and -T together, by making -d 167 | # take the precedence; this is for compatibility with GNU install. 168 | 169 | if test -n "$dir_arg"; then 170 | if test -n "$dst_arg"; then 171 | echo "$0: target directory not allowed when installing a directory." >&2 172 | exit 1 173 | fi 174 | fi 175 | 176 | if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then 177 | # When -d is used, all remaining arguments are directories to create. 178 | # When -t is used, the destination is already specified. 179 | # Otherwise, the last argument is the destination. Remove it from $@. 180 | for arg 181 | do 182 | if test -n "$dst_arg"; then 183 | # $@ is not empty: it contains at least $arg. 184 | set fnord "$@" "$dst_arg" 185 | shift # fnord 186 | fi 187 | shift # arg 188 | dst_arg=$arg 189 | # Protect names problematic for 'test' and other utilities. 190 | case $dst_arg in 191 | -* | [=\(\)!]) dst_arg=./$dst_arg;; 192 | esac 193 | done 194 | fi 195 | 196 | if test $# -eq 0; then 197 | if test -z "$dir_arg"; then 198 | echo "$0: no input file specified." >&2 199 | exit 1 200 | fi 201 | # It's OK to call 'install-sh -d' without argument. 202 | # This can happen when creating conditional directories. 203 | exit 0 204 | fi 205 | 206 | if test -z "$dir_arg"; then 207 | if test $# -gt 1 || test "$is_target_a_directory" = always; then 208 | if test ! -d "$dst_arg"; then 209 | echo "$0: $dst_arg: Is not a directory." >&2 210 | exit 1 211 | fi 212 | fi 213 | fi 214 | 215 | if test -z "$dir_arg"; then 216 | do_exit='(exit $ret); exit $ret' 217 | trap "ret=129; $do_exit" 1 218 | trap "ret=130; $do_exit" 2 219 | trap "ret=141; $do_exit" 13 220 | trap "ret=143; $do_exit" 15 221 | 222 | # Set umask so as not to create temps with too-generous modes. 223 | # However, 'strip' requires both read and write access to temps. 224 | case $mode in 225 | # Optimize common cases. 226 | *644) cp_umask=133;; 227 | *755) cp_umask=22;; 228 | 229 | *[0-7]) 230 | if test -z "$stripcmd"; then 231 | u_plus_rw= 232 | else 233 | u_plus_rw='% 200' 234 | fi 235 | cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;; 236 | *) 237 | if test -z "$stripcmd"; then 238 | u_plus_rw= 239 | else 240 | u_plus_rw=,u+rw 241 | fi 242 | cp_umask=$mode$u_plus_rw;; 243 | esac 244 | fi 245 | 246 | for src 247 | do 248 | # Protect names problematic for 'test' and other utilities. 249 | case $src in 250 | -* | [=\(\)!]) src=./$src;; 251 | esac 252 | 253 | if test -n "$dir_arg"; then 254 | dst=$src 255 | dstdir=$dst 256 | test -d "$dstdir" 257 | dstdir_status=$? 258 | else 259 | 260 | # Waiting for this to be detected by the "$cpprog $src $dsttmp" command 261 | # might cause directories to be created, which would be especially bad 262 | # if $src (and thus $dsttmp) contains '*'. 263 | if test ! -f "$src" && test ! -d "$src"; then 264 | echo "$0: $src does not exist." >&2 265 | exit 1 266 | fi 267 | 268 | if test -z "$dst_arg"; then 269 | echo "$0: no destination specified." >&2 270 | exit 1 271 | fi 272 | dst=$dst_arg 273 | 274 | # If destination is a directory, append the input filename; won't work 275 | # if double slashes aren't ignored. 276 | if test -d "$dst"; then 277 | if test "$is_target_a_directory" = never; then 278 | echo "$0: $dst_arg: Is a directory" >&2 279 | exit 1 280 | fi 281 | dstdir=$dst 282 | dst=$dstdir/`basename "$src"` 283 | dstdir_status=0 284 | else 285 | dstdir=`dirname "$dst"` 286 | test -d "$dstdir" 287 | dstdir_status=$? 288 | fi 289 | fi 290 | 291 | obsolete_mkdir_used=false 292 | 293 | if test $dstdir_status != 0; then 294 | case $posix_mkdir in 295 | '') 296 | # Create intermediate dirs using mode 755 as modified by the umask. 297 | # This is like FreeBSD 'install' as of 1997-10-28. 298 | umask=`umask` 299 | case $stripcmd.$umask in 300 | # Optimize common cases. 301 | *[2367][2367]) mkdir_umask=$umask;; 302 | .*0[02][02] | .[02][02] | .[02]) mkdir_umask=22;; 303 | 304 | *[0-7]) 305 | mkdir_umask=`expr $umask + 22 \ 306 | - $umask % 100 % 40 + $umask % 20 \ 307 | - $umask % 10 % 4 + $umask % 2 308 | `;; 309 | *) mkdir_umask=$umask,go-w;; 310 | esac 311 | 312 | # With -d, create the new directory with the user-specified mode. 313 | # Otherwise, rely on $mkdir_umask. 314 | if test -n "$dir_arg"; then 315 | mkdir_mode=-m$mode 316 | else 317 | mkdir_mode= 318 | fi 319 | 320 | posix_mkdir=false 321 | case $umask in 322 | *[123567][0-7][0-7]) 323 | # POSIX mkdir -p sets u+wx bits regardless of umask, which 324 | # is incompatible with FreeBSD 'install' when (umask & 300) != 0. 325 | ;; 326 | *) 327 | # $RANDOM is not portable (e.g. dash); use it when possible to 328 | # lower collision chance 329 | tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$ 330 | trap 'ret=$?; rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null; exit $ret' 0 331 | 332 | # As "mkdir -p" follows symlinks and we work in /tmp possibly; so 333 | # create the $tmpdir first (and fail if unsuccessful) to make sure 334 | # that nobody tries to guess the $tmpdir name. 335 | if (umask $mkdir_umask && 336 | $mkdirprog $mkdir_mode "$tmpdir" && 337 | exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1 338 | then 339 | if test -z "$dir_arg" || { 340 | # Check for POSIX incompatibilities with -m. 341 | # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or 342 | # other-writable bit of parent directory when it shouldn't. 343 | # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. 344 | test_tmpdir="$tmpdir/a" 345 | ls_ld_tmpdir=`ls -ld "$test_tmpdir"` 346 | case $ls_ld_tmpdir in 347 | d????-?r-*) different_mode=700;; 348 | d????-?--*) different_mode=755;; 349 | *) false;; 350 | esac && 351 | $mkdirprog -m$different_mode -p -- "$test_tmpdir" && { 352 | ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"` 353 | test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1" 354 | } 355 | } 356 | then posix_mkdir=: 357 | fi 358 | rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 359 | else 360 | # Remove any dirs left behind by ancient mkdir implementations. 361 | rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null 362 | fi 363 | trap '' 0;; 364 | esac;; 365 | esac 366 | 367 | if 368 | $posix_mkdir && ( 369 | umask $mkdir_umask && 370 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir" 371 | ) 372 | then : 373 | else 374 | 375 | # The umask is ridiculous, or mkdir does not conform to POSIX, 376 | # or it failed possibly due to a race condition. Create the 377 | # directory the slow way, step by step, checking for races as we go. 378 | 379 | case $dstdir in 380 | /*) prefix='/';; 381 | [-=\(\)!]*) prefix='./';; 382 | *) prefix='';; 383 | esac 384 | 385 | oIFS=$IFS 386 | IFS=/ 387 | set -f 388 | set fnord $dstdir 389 | shift 390 | set +f 391 | IFS=$oIFS 392 | 393 | prefixes= 394 | 395 | for d 396 | do 397 | test X"$d" = X && continue 398 | 399 | prefix=$prefix$d 400 | if test -d "$prefix"; then 401 | prefixes= 402 | else 403 | if $posix_mkdir; then 404 | (umask=$mkdir_umask && 405 | $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break 406 | # Don't fail if two instances are running concurrently. 407 | test -d "$prefix" || exit 1 408 | else 409 | case $prefix in 410 | *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;; 411 | *) qprefix=$prefix;; 412 | esac 413 | prefixes="$prefixes '$qprefix'" 414 | fi 415 | fi 416 | prefix=$prefix/ 417 | done 418 | 419 | if test -n "$prefixes"; then 420 | # Don't fail if two instances are running concurrently. 421 | (umask $mkdir_umask && 422 | eval "\$doit_exec \$mkdirprog $prefixes") || 423 | test -d "$dstdir" || exit 1 424 | obsolete_mkdir_used=true 425 | fi 426 | fi 427 | fi 428 | 429 | if test -n "$dir_arg"; then 430 | { test -z "$chowncmd" || $doit $chowncmd "$dst"; } && 431 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } && 432 | { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false || 433 | test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1 434 | else 435 | 436 | # Make a couple of temp file names in the proper directory. 437 | dsttmp=$dstdir/_inst.$$_ 438 | rmtmp=$dstdir/_rm.$$_ 439 | 440 | # Trap to clean up those temp files at exit. 441 | trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0 442 | 443 | # Copy the file name to the temp name. 444 | (umask $cp_umask && $doit_exec $cpprog "$src" "$dsttmp") && 445 | 446 | # and set any options; do chmod last to preserve setuid bits. 447 | # 448 | # If any of these fail, we abort the whole thing. If we want to 449 | # ignore errors from any of these, just make sure not to ignore 450 | # errors from the above "$doit $cpprog $src $dsttmp" command. 451 | # 452 | { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } && 453 | { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } && 454 | { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } && 455 | { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } && 456 | 457 | # If -C, don't bother to copy if it wouldn't change the file. 458 | if $copy_on_change && 459 | old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` && 460 | new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` && 461 | set -f && 462 | set X $old && old=:$2:$4:$5:$6 && 463 | set X $new && new=:$2:$4:$5:$6 && 464 | set +f && 465 | test "$old" = "$new" && 466 | $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1 467 | then 468 | rm -f "$dsttmp" 469 | else 470 | # Rename the file to the real destination. 471 | $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null || 472 | 473 | # The rename failed, perhaps because mv can't rename something else 474 | # to itself, or perhaps because mv is so ancient that it does not 475 | # support -f. 476 | { 477 | # Now remove or move aside any old file at destination location. 478 | # We try this two ways since rm can't unlink itself on some 479 | # systems and the destination file might be busy for other 480 | # reasons. In this case, the final cleanup might fail but the new 481 | # file should still install successfully. 482 | { 483 | test ! -f "$dst" || 484 | $doit $rmcmd -f "$dst" 2>/dev/null || 485 | { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null && 486 | { $doit $rmcmd -f "$rmtmp" 2>/dev/null; :; } 487 | } || 488 | { echo "$0: cannot unlink or rename $dst" >&2 489 | (exit 1); exit 1 490 | } 491 | } && 492 | 493 | # Now rename the file to the real destination. 494 | $doit $mvcmd "$dsttmp" "$dst" 495 | } 496 | fi || exit 1 497 | 498 | trap '' 0 499 | fi 500 | done 501 | 502 | # Local variables: 503 | # eval: (add-hook 'write-file-hooks 'time-stamp) 504 | # time-stamp-start: "scriptversion=" 505 | # time-stamp-format: "%:y-%02m-%02d.%02H" 506 | # time-stamp-time-zone: "UTC" 507 | # time-stamp-end: "; # UTC" 508 | # End: 509 | -------------------------------------------------------------------------------- /lib/Makefile.am: -------------------------------------------------------------------------------- 1 | scriptsdir = $(prefix)/lib/k3screenctrl 2 | dist_scripts_DATA = k3screenctrl/wan.sh k3screenctrl/basic.sh k3screenctrl/wifi.sh k3screenctrl/port.sh 3 | -------------------------------------------------------------------------------- /lib/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.15 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2014 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = { \ 19 | if test -z '$(MAKELEVEL)'; then \ 20 | false; \ 21 | elif test -n '$(MAKE_HOST)'; then \ 22 | true; \ 23 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ 24 | true; \ 25 | else \ 26 | false; \ 27 | fi; \ 28 | } 29 | am__make_running_with_option = \ 30 | case $${target_option-} in \ 31 | ?) ;; \ 32 | *) echo "am__make_running_with_option: internal error: invalid" \ 33 | "target option '$${target_option-}' specified" >&2; \ 34 | exit 1;; \ 35 | esac; \ 36 | has_opt=no; \ 37 | sane_makeflags=$$MAKEFLAGS; \ 38 | if $(am__is_gnu_make); then \ 39 | sane_makeflags=$$MFLAGS; \ 40 | else \ 41 | case $$MAKEFLAGS in \ 42 | *\\[\ \ ]*) \ 43 | bs=\\; \ 44 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 45 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 46 | esac; \ 47 | fi; \ 48 | skip_next=no; \ 49 | strip_trailopt () \ 50 | { \ 51 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 52 | }; \ 53 | for flg in $$sane_makeflags; do \ 54 | test $$skip_next = yes && { skip_next=no; continue; }; \ 55 | case $$flg in \ 56 | *=*|--*) continue;; \ 57 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 58 | -*I?*) strip_trailopt 'I';; \ 59 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 60 | -*O?*) strip_trailopt 'O';; \ 61 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 62 | -*l?*) strip_trailopt 'l';; \ 63 | -[dEDm]) skip_next=yes;; \ 64 | -[JT]) skip_next=yes;; \ 65 | esac; \ 66 | case $$flg in \ 67 | *$$target_option*) has_opt=yes; break;; \ 68 | esac; \ 69 | done; \ 70 | test $$has_opt = yes 71 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 72 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 73 | pkgdatadir = $(datadir)/@PACKAGE@ 74 | pkgincludedir = $(includedir)/@PACKAGE@ 75 | pkglibdir = $(libdir)/@PACKAGE@ 76 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 77 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 78 | install_sh_DATA = $(install_sh) -c -m 644 79 | install_sh_PROGRAM = $(install_sh) -c 80 | install_sh_SCRIPT = $(install_sh) -c 81 | INSTALL_HEADER = $(INSTALL_DATA) 82 | transform = $(program_transform_name) 83 | NORMAL_INSTALL = : 84 | PRE_INSTALL = : 85 | POST_INSTALL = : 86 | NORMAL_UNINSTALL = : 87 | PRE_UNINSTALL = : 88 | POST_UNINSTALL = : 89 | subdir = lib 90 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 91 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 92 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 93 | $(ACLOCAL_M4) 94 | DIST_COMMON = $(srcdir)/Makefile.am $(dist_scripts_DATA) \ 95 | $(am__DIST_COMMON) 96 | mkinstalldirs = $(install_sh) -d 97 | CONFIG_HEADER = $(top_builddir)/config.h 98 | CONFIG_CLEAN_FILES = 99 | CONFIG_CLEAN_VPATH_FILES = 100 | AM_V_P = $(am__v_P_@AM_V@) 101 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 102 | am__v_P_0 = false 103 | am__v_P_1 = : 104 | AM_V_GEN = $(am__v_GEN_@AM_V@) 105 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 106 | am__v_GEN_0 = @echo " GEN " $@; 107 | am__v_GEN_1 = 108 | AM_V_at = $(am__v_at_@AM_V@) 109 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 110 | am__v_at_0 = @ 111 | am__v_at_1 = 112 | SOURCES = 113 | DIST_SOURCES = 114 | am__can_run_installinfo = \ 115 | case $$AM_UPDATE_INFO_DIR in \ 116 | n|no|NO) false;; \ 117 | *) (install-info --version) >/dev/null 2>&1;; \ 118 | esac 119 | am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; 120 | am__vpath_adj = case $$p in \ 121 | $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ 122 | *) f=$$p;; \ 123 | esac; 124 | am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`; 125 | am__install_max = 40 126 | am__nobase_strip_setup = \ 127 | srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'` 128 | am__nobase_strip = \ 129 | for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||" 130 | am__nobase_list = $(am__nobase_strip_setup); \ 131 | for p in $$list; do echo "$$p $$p"; done | \ 132 | sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \ 133 | $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \ 134 | if (++n[$$2] == $(am__install_max)) \ 135 | { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \ 136 | END { for (dir in files) print dir, files[dir] }' 137 | am__base_list = \ 138 | sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ 139 | sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' 140 | am__uninstall_files_from_dir = { \ 141 | test -z "$$files" \ 142 | || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \ 143 | || { echo " ( cd '$$dir' && rm -f" $$files ")"; \ 144 | $(am__cd) "$$dir" && rm -f $$files; }; \ 145 | } 146 | am__installdirs = "$(DESTDIR)$(scriptsdir)" 147 | DATA = $(dist_scripts_DATA) 148 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 149 | am__DIST_COMMON = $(srcdir)/Makefile.in 150 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 151 | ACLOCAL = @ACLOCAL@ 152 | AMTAR = @AMTAR@ 153 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 154 | AUTOCONF = @AUTOCONF@ 155 | AUTOHEADER = @AUTOHEADER@ 156 | AUTOMAKE = @AUTOMAKE@ 157 | AWK = @AWK@ 158 | CC = @CC@ 159 | CCDEPMODE = @CCDEPMODE@ 160 | CFLAGS = @CFLAGS@ 161 | CPP = @CPP@ 162 | CPPFLAGS = @CPPFLAGS@ 163 | CYGPATH_W = @CYGPATH_W@ 164 | DEFS = @DEFS@ 165 | DEPDIR = @DEPDIR@ 166 | ECHO_C = @ECHO_C@ 167 | ECHO_N = @ECHO_N@ 168 | ECHO_T = @ECHO_T@ 169 | EGREP = @EGREP@ 170 | EXEEXT = @EXEEXT@ 171 | GREP = @GREP@ 172 | INSTALL = @INSTALL@ 173 | INSTALL_DATA = @INSTALL_DATA@ 174 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 175 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 176 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 177 | LDFLAGS = @LDFLAGS@ 178 | LIBOBJS = @LIBOBJS@ 179 | LIBS = @LIBS@ 180 | LTLIBOBJS = @LTLIBOBJS@ 181 | MAKEINFO = @MAKEINFO@ 182 | MKDIR_P = @MKDIR_P@ 183 | OBJEXT = @OBJEXT@ 184 | PACKAGE = @PACKAGE@ 185 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 186 | PACKAGE_NAME = @PACKAGE_NAME@ 187 | PACKAGE_STRING = @PACKAGE_STRING@ 188 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 189 | PACKAGE_URL = @PACKAGE_URL@ 190 | PACKAGE_VERSION = @PACKAGE_VERSION@ 191 | PATH_SEPARATOR = @PATH_SEPARATOR@ 192 | SET_MAKE = @SET_MAKE@ 193 | SHELL = @SHELL@ 194 | STRIP = @STRIP@ 195 | VERSION = @VERSION@ 196 | abs_builddir = @abs_builddir@ 197 | abs_srcdir = @abs_srcdir@ 198 | abs_top_builddir = @abs_top_builddir@ 199 | abs_top_srcdir = @abs_top_srcdir@ 200 | ac_ct_CC = @ac_ct_CC@ 201 | am__include = @am__include@ 202 | am__leading_dot = @am__leading_dot@ 203 | am__quote = @am__quote@ 204 | am__tar = @am__tar@ 205 | am__untar = @am__untar@ 206 | bindir = @bindir@ 207 | build_alias = @build_alias@ 208 | builddir = @builddir@ 209 | datadir = @datadir@ 210 | datarootdir = @datarootdir@ 211 | docdir = @docdir@ 212 | dvidir = @dvidir@ 213 | exec_prefix = @exec_prefix@ 214 | host_alias = @host_alias@ 215 | htmldir = @htmldir@ 216 | includedir = @includedir@ 217 | infodir = @infodir@ 218 | install_sh = @install_sh@ 219 | libdir = @libdir@ 220 | libexecdir = @libexecdir@ 221 | localedir = @localedir@ 222 | localstatedir = @localstatedir@ 223 | mandir = @mandir@ 224 | mkdir_p = @mkdir_p@ 225 | oldincludedir = @oldincludedir@ 226 | pdfdir = @pdfdir@ 227 | prefix = @prefix@ 228 | program_transform_name = @program_transform_name@ 229 | psdir = @psdir@ 230 | runstatedir = @runstatedir@ 231 | sbindir = @sbindir@ 232 | sharedstatedir = @sharedstatedir@ 233 | srcdir = @srcdir@ 234 | sysconfdir = @sysconfdir@ 235 | target_alias = @target_alias@ 236 | top_build_prefix = @top_build_prefix@ 237 | top_builddir = @top_builddir@ 238 | top_srcdir = @top_srcdir@ 239 | scriptsdir = $(prefix)/lib/k3screenctrl 240 | dist_scripts_DATA = k3screenctrl/wan.sh k3screenctrl/basic.sh k3screenctrl/wifi.sh k3screenctrl/port.sh 241 | all: all-am 242 | 243 | .SUFFIXES: 244 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 245 | @for dep in $?; do \ 246 | case '$(am__configure_deps)' in \ 247 | *$$dep*) \ 248 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 249 | && { if test -f $@; then exit 0; else break; fi; }; \ 250 | exit 1;; \ 251 | esac; \ 252 | done; \ 253 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu lib/Makefile'; \ 254 | $(am__cd) $(top_srcdir) && \ 255 | $(AUTOMAKE) --gnu lib/Makefile 256 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 257 | @case '$?' in \ 258 | *config.status*) \ 259 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 260 | *) \ 261 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 262 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 263 | esac; 264 | 265 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 266 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 267 | 268 | $(top_srcdir)/configure: $(am__configure_deps) 269 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 270 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 271 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 272 | $(am__aclocal_m4_deps): 273 | install-dist_scriptsDATA: $(dist_scripts_DATA) 274 | @$(NORMAL_INSTALL) 275 | @list='$(dist_scripts_DATA)'; test -n "$(scriptsdir)" || list=; \ 276 | if test -n "$$list"; then \ 277 | echo " $(MKDIR_P) '$(DESTDIR)$(scriptsdir)'"; \ 278 | $(MKDIR_P) "$(DESTDIR)$(scriptsdir)" || exit 1; \ 279 | fi; \ 280 | for p in $$list; do \ 281 | if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \ 282 | echo "$$d$$p"; \ 283 | done | $(am__base_list) | \ 284 | while read files; do \ 285 | echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(scriptsdir)'"; \ 286 | $(INSTALL_DATA) $$files "$(DESTDIR)$(scriptsdir)" || exit $$?; \ 287 | done 288 | 289 | uninstall-dist_scriptsDATA: 290 | @$(NORMAL_UNINSTALL) 291 | @list='$(dist_scripts_DATA)'; test -n "$(scriptsdir)" || list=; \ 292 | files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \ 293 | dir='$(DESTDIR)$(scriptsdir)'; $(am__uninstall_files_from_dir) 294 | tags TAGS: 295 | 296 | ctags CTAGS: 297 | 298 | cscope cscopelist: 299 | 300 | 301 | distdir: $(DISTFILES) 302 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 303 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 304 | list='$(DISTFILES)'; \ 305 | dist_files=`for file in $$list; do echo $$file; done | \ 306 | sed -e "s|^$$srcdirstrip/||;t" \ 307 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 308 | case $$dist_files in \ 309 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 310 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 311 | sort -u` ;; \ 312 | esac; \ 313 | for file in $$dist_files; do \ 314 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 315 | if test -d $$d/$$file; then \ 316 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 317 | if test -d "$(distdir)/$$file"; then \ 318 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 319 | fi; \ 320 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 321 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 322 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 323 | fi; \ 324 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 325 | else \ 326 | test -f "$(distdir)/$$file" \ 327 | || cp -p $$d/$$file "$(distdir)/$$file" \ 328 | || exit 1; \ 329 | fi; \ 330 | done 331 | check-am: all-am 332 | check: check-am 333 | all-am: Makefile $(DATA) 334 | installdirs: 335 | for dir in "$(DESTDIR)$(scriptsdir)"; do \ 336 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 337 | done 338 | install: install-am 339 | install-exec: install-exec-am 340 | install-data: install-data-am 341 | uninstall: uninstall-am 342 | 343 | install-am: all-am 344 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 345 | 346 | installcheck: installcheck-am 347 | install-strip: 348 | if test -z '$(STRIP)'; then \ 349 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 350 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 351 | install; \ 352 | else \ 353 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 354 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 355 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 356 | fi 357 | mostlyclean-generic: 358 | 359 | clean-generic: 360 | 361 | distclean-generic: 362 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 363 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 364 | 365 | maintainer-clean-generic: 366 | @echo "This command is intended for maintainers to use" 367 | @echo "it deletes files that may require special tools to rebuild." 368 | clean: clean-am 369 | 370 | clean-am: clean-generic mostlyclean-am 371 | 372 | distclean: distclean-am 373 | -rm -f Makefile 374 | distclean-am: clean-am distclean-generic 375 | 376 | dvi: dvi-am 377 | 378 | dvi-am: 379 | 380 | html: html-am 381 | 382 | html-am: 383 | 384 | info: info-am 385 | 386 | info-am: 387 | 388 | install-data-am: install-dist_scriptsDATA 389 | 390 | install-dvi: install-dvi-am 391 | 392 | install-dvi-am: 393 | 394 | install-exec-am: 395 | 396 | install-html: install-html-am 397 | 398 | install-html-am: 399 | 400 | install-info: install-info-am 401 | 402 | install-info-am: 403 | 404 | install-man: 405 | 406 | install-pdf: install-pdf-am 407 | 408 | install-pdf-am: 409 | 410 | install-ps: install-ps-am 411 | 412 | install-ps-am: 413 | 414 | installcheck-am: 415 | 416 | maintainer-clean: maintainer-clean-am 417 | -rm -f Makefile 418 | maintainer-clean-am: distclean-am maintainer-clean-generic 419 | 420 | mostlyclean: mostlyclean-am 421 | 422 | mostlyclean-am: mostlyclean-generic 423 | 424 | pdf: pdf-am 425 | 426 | pdf-am: 427 | 428 | ps: ps-am 429 | 430 | ps-am: 431 | 432 | uninstall-am: uninstall-dist_scriptsDATA 433 | 434 | .MAKE: install-am install-strip 435 | 436 | .PHONY: all all-am check check-am clean clean-generic cscopelist-am \ 437 | ctags-am distclean distclean-generic distdir dvi dvi-am html \ 438 | html-am info info-am install install-am install-data \ 439 | install-data-am install-dist_scriptsDATA install-dvi \ 440 | install-dvi-am install-exec install-exec-am install-html \ 441 | install-html-am install-info install-info-am install-man \ 442 | install-pdf install-pdf-am install-ps install-ps-am \ 443 | install-strip installcheck installcheck-am installdirs \ 444 | maintainer-clean maintainer-clean-generic mostlyclean \ 445 | mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \ 446 | uninstall-am uninstall-dist_scriptsDATA 447 | 448 | .PRECIOUS: Makefile 449 | 450 | 451 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 452 | # Otherwise a system limit (for SysV at least) may be exceeded. 453 | .NOEXPORT: 454 | -------------------------------------------------------------------------------- /lib/k3screenctrl-test/basic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo K4 3 | echo A3 4 | echo 02:00:00:00:00:00 5 | echo r6666 -------------------------------------------------------------------------------- /lib/k3screenctrl-test/host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 2 3 | echo MyHost1 4 | echo 231321 5 | echo 6781231 6 | echo 25 7 | echo MyHost2 8 | echo 237812 9 | echo 2934821 10 | echo 0 -------------------------------------------------------------------------------- /lib/k3screenctrl-test/port.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 1 3 | echo 1 4 | echo 0 5 | echo 1 6 | echo 1 -------------------------------------------------------------------------------- /lib/k3screenctrl-test/wan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 1 3 | echo 10240000 4 | echo 2048000 -------------------------------------------------------------------------------- /lib/k3screenctrl-test/wifi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | echo 0 3 | echo LEDE-24G 4 | echo password24 5 | echo 1 6 | echo 0 7 | echo LEDE-5G 8 | echo password5 9 | echo 1 10 | echo 4 11 | echo 12 | echo 13 | echo 0 14 | echo 0 -------------------------------------------------------------------------------- /lib/k3screenctrl/basic.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | . /etc/os-release 3 | 4 | PRODUCT_NAME_FULL=$(cat /etc/board.json | jsonfilter -e "@.model.name") 5 | PRODUCT_NAME=${PRODUCT_NAME_FULL#* } # Remove first word to save space 6 | 7 | WAN_IFNAME=$(uci get network.wan.ifname) 8 | MAC_ADDR=$(ifconfig $WAN_IFNAME | grep -oE "([0-9A-Z]{2}:){5}[0-9A-Z]{2}") 9 | 10 | HW_VERSION_CACHE_FILE=/tmp/hw_version 11 | if [ -e "$HW_VERSION_CACHE_FILE" ]; then 12 | HW_VERSION=$(cat $HW_VERSION_CACHE_FILE) 13 | else 14 | HW_VERSION=$(nvram get hd_version) 15 | echo $HW_VERSION > $HW_VERSION_CACHE_FILE 16 | fi 17 | 18 | FW_VERSION=${BUILD_ID:0:17} 19 | 20 | echo $PRODUCT_NAME 21 | echo $HW_VERSION 22 | echo $FW_VERSION 23 | echo $MAC_ADDR -------------------------------------------------------------------------------- /lib/k3screenctrl/host.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Stub 3 | echo 0 4 | -------------------------------------------------------------------------------- /lib/k3screenctrl/port.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | print_eth_port_status() { 4 | local port=$1 5 | 6 | # One `swconfig dev switch0 show` wastes more time than 4 `port show` 7 | if [ -n "`swconfig dev switch0 port $port show | grep \"link:up\"`" ]; then 8 | echo 1 9 | else 10 | echo 0 11 | fi 12 | } 13 | 14 | print_usb_port_status() { 15 | if [ "`ls -1 /sys/bus/usb/devices | wc -l`" -gt 8 ]; then 16 | echo 1 17 | else 18 | echo 0 19 | fi 20 | } 21 | 22 | print_eth_port_status 1 # Port 1 is LAN1 on label 23 | print_eth_port_status 0 # Port 0 is LAN2 on label 24 | print_eth_port_status 2 # LAN3 25 | print_eth_port_status 3 # WAN 26 | print_usb_port_status -------------------------------------------------------------------------------- /lib/k3screenctrl/wan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Basic vars 4 | TEMP_FILE="/tmp/wan_speed_temp" 5 | WAN_STAT=`ifstatus wan` 6 | WAN6_STAT=`ifstatus wan6` 7 | 8 | # Internet connectivity 9 | IPV4_ADDR=`echo $WAN_STAT | jsonfilter -e "@['ipv4-address']"` 10 | IPV6_ADDR=`echo $WAN6_STAT | jsonfilter -e "@['ipv6-address']"` 11 | 12 | if [ -n "$IPV4_ADDR" -o -n "$IPV6_ADDR" ]; then 13 | CONNECTED=1 14 | else 15 | CONNECTED=0 16 | fi 17 | 18 | WAN_IFNAME=`echo $WAN_STAT | jsonfilter -e "@.l3_device"` # pppoe-wan 19 | if [ -z "$WAN_IFNAME" ]; then 20 | WAN_IFNAME=`echo $WAN_STAT | jsonfilter -e "@.device"` # eth0.2 21 | if [ -z "$WAN_IFNAME" ]; then 22 | WAN_IFNAME=`uci get network.wan.ifname` # eth0.2 23 | fi 24 | fi 25 | # If there is still no WAN iface found, the script will fail - but that's rare 26 | 27 | # Calculate speed by traffic delta / time delta 28 | # NOTE: /proc/net/dev updates every ~1s. 29 | # You must call this script with longer interval! 30 | CURR_TIME=$(date +%s) 31 | CURR_STAT=$(cat /proc/net/dev | grep $WAN_IFNAME | sed -e 's/^ *//' -e 's/ */ /g') 32 | CURR_DOWNLOAD_BYTES=$(echo $CURR_STAT | cut -d " " -f 2) 33 | CURR_UPLOAD_BYTES=$(echo $CURR_STAT | cut -d " " -f 10) 34 | 35 | if [ -e "$TEMP_FILE" ]; then 36 | LINENO=0 37 | while read line; do 38 | case "$LINENO" in 39 | 0) 40 | LAST_TIME=$line 41 | ;; 42 | 1) 43 | LAST_UPLOAD_BYTES=$line 44 | ;; 45 | 2) 46 | LAST_DOWNLOAD_BYTES=$line 47 | ;; 48 | *) 49 | ;; 50 | esac 51 | LINENO=$(($LINENO+1)) 52 | done < $TEMP_FILE 53 | fi 54 | 55 | echo $CURR_TIME > $TEMP_FILE 56 | echo $CURR_UPLOAD_BYTES >> $TEMP_FILE 57 | echo $CURR_DOWNLOAD_BYTES >> $TEMP_FILE 58 | 59 | if [ -z "$LAST_TIME" -o -z "$LAST_UPLOAD_BYTES" -o -z "$LAST_DOWNLOAD_BYTES" ]; then 60 | # First time of launch 61 | UPLOAD_BPS=0 62 | DOWNLOAD_BPS=0 63 | else 64 | TIME_DELTA_S=$(($CURR_TIME-$LAST_TIME)) 65 | if [ $TIME_DELTA_S -eq 0 ]; then 66 | TIME_DELTA_S=1 67 | fi 68 | UPLOAD_BPS=$((($CURR_UPLOAD_BYTES-$LAST_UPLOAD_BYTES)/$TIME_DELTA_S)) 69 | DOWNLOAD_BPS=$((($CURR_DOWNLOAD_BYTES-$LAST_DOWNLOAD_BYTES)/$TIME_DELTA_S)) 70 | fi 71 | 72 | echo $CONNECTED 73 | echo $UPLOAD_BPS 74 | echo $DOWNLOAD_BPS 75 | -------------------------------------------------------------------------------- /lib/k3screenctrl/wifi.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | COMPLETE_STAT=`wifi status` 4 | 5 | print_wifi_info() { 6 | local ucidev=$1 ifname=$2 7 | local status device_json ssid psk client_count=0 enabled=0 8 | 9 | device_json=`echo $COMPLETE_STAT | jsonfilter -e "@.$ucidev"` 10 | if [ -n "$device_json" ]; then 11 | status=`echo $device_json | jsonfilter -e "@.disabled"` 12 | if [ "x$status" == "xfalse" -a -n "` echo $device_json | jsonfilter -e \"@.interfaces[0]\"`" ]; then 13 | ssid=`echo $COMPLETE_STAT | jsonfilter -e "@.$ucidev.interfaces[0].config.ssid"` 14 | psk=`echo $COMPLETE_STAT | jsonfilter -e "@.$ucidev.interfaces[0].config.key"` 15 | client_count=`iw dev $ifname station dump | grep Station | wc -l` 16 | enabled=1 17 | fi 18 | fi 19 | 20 | echo $ssid 21 | echo $psk 22 | echo $enabled 23 | echo $client_count 24 | } 25 | 26 | echo 0 # Band mix 27 | print_wifi_info radio0 wlan0 # 2.4GHz 28 | print_wifi_info radio1 wlan1 # 5GHZ 29 | print_wifi_info radiox wlanx # Visitor - not implemented -------------------------------------------------------------------------------- /missing: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | # Common wrapper for a few potentially missing GNU programs. 3 | 4 | scriptversion=2013-10-28.13; # UTC 5 | 6 | # Copyright (C) 1996-2014 Free Software Foundation, Inc. 7 | # Originally written by Fran,cois Pinard , 1996. 8 | 9 | # This program is free software; you can redistribute it and/or modify 10 | # it under the terms of the GNU General Public License as published by 11 | # the Free Software Foundation; either version 2, or (at your option) 12 | # any later version. 13 | 14 | # This program is distributed in the hope that it will be useful, 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | # GNU General Public License for more details. 18 | 19 | # You should have received a copy of the GNU General Public License 20 | # along with this program. If not, see . 21 | 22 | # As a special exception to the GNU General Public License, if you 23 | # distribute this file as part of a program that contains a 24 | # configuration script generated by Autoconf, you may include it under 25 | # the same distribution terms that you use for the rest of that program. 26 | 27 | if test $# -eq 0; then 28 | echo 1>&2 "Try '$0 --help' for more information" 29 | exit 1 30 | fi 31 | 32 | case $1 in 33 | 34 | --is-lightweight) 35 | # Used by our autoconf macros to check whether the available missing 36 | # script is modern enough. 37 | exit 0 38 | ;; 39 | 40 | --run) 41 | # Back-compat with the calling convention used by older automake. 42 | shift 43 | ;; 44 | 45 | -h|--h|--he|--hel|--help) 46 | echo "\ 47 | $0 [OPTION]... PROGRAM [ARGUMENT]... 48 | 49 | Run 'PROGRAM [ARGUMENT]...', returning a proper advice when this fails due 50 | to PROGRAM being missing or too old. 51 | 52 | Options: 53 | -h, --help display this help and exit 54 | -v, --version output version information and exit 55 | 56 | Supported PROGRAM values: 57 | aclocal autoconf autoheader autom4te automake makeinfo 58 | bison yacc flex lex help2man 59 | 60 | Version suffixes to PROGRAM as well as the prefixes 'gnu-', 'gnu', and 61 | 'g' are ignored when checking the name. 62 | 63 | Send bug reports to ." 64 | exit $? 65 | ;; 66 | 67 | -v|--v|--ve|--ver|--vers|--versi|--versio|--version) 68 | echo "missing $scriptversion (GNU Automake)" 69 | exit $? 70 | ;; 71 | 72 | -*) 73 | echo 1>&2 "$0: unknown '$1' option" 74 | echo 1>&2 "Try '$0 --help' for more information" 75 | exit 1 76 | ;; 77 | 78 | esac 79 | 80 | # Run the given program, remember its exit status. 81 | "$@"; st=$? 82 | 83 | # If it succeeded, we are done. 84 | test $st -eq 0 && exit 0 85 | 86 | # Also exit now if we it failed (or wasn't found), and '--version' was 87 | # passed; such an option is passed most likely to detect whether the 88 | # program is present and works. 89 | case $2 in --version|--help) exit $st;; esac 90 | 91 | # Exit code 63 means version mismatch. This often happens when the user 92 | # tries to use an ancient version of a tool on a file that requires a 93 | # minimum version. 94 | if test $st -eq 63; then 95 | msg="probably too old" 96 | elif test $st -eq 127; then 97 | # Program was missing. 98 | msg="missing on your system" 99 | else 100 | # Program was found and executed, but failed. Give up. 101 | exit $st 102 | fi 103 | 104 | perl_URL=http://www.perl.org/ 105 | flex_URL=http://flex.sourceforge.net/ 106 | gnu_software_URL=http://www.gnu.org/software 107 | 108 | program_details () 109 | { 110 | case $1 in 111 | aclocal|automake) 112 | echo "The '$1' program is part of the GNU Automake package:" 113 | echo "<$gnu_software_URL/automake>" 114 | echo "It also requires GNU Autoconf, GNU m4 and Perl in order to run:" 115 | echo "<$gnu_software_URL/autoconf>" 116 | echo "<$gnu_software_URL/m4/>" 117 | echo "<$perl_URL>" 118 | ;; 119 | autoconf|autom4te|autoheader) 120 | echo "The '$1' program is part of the GNU Autoconf package:" 121 | echo "<$gnu_software_URL/autoconf/>" 122 | echo "It also requires GNU m4 and Perl in order to run:" 123 | echo "<$gnu_software_URL/m4/>" 124 | echo "<$perl_URL>" 125 | ;; 126 | esac 127 | } 128 | 129 | give_advice () 130 | { 131 | # Normalize program name to check for. 132 | normalized_program=`echo "$1" | sed ' 133 | s/^gnu-//; t 134 | s/^gnu//; t 135 | s/^g//; t'` 136 | 137 | printf '%s\n' "'$1' is $msg." 138 | 139 | configure_deps="'configure.ac' or m4 files included by 'configure.ac'" 140 | case $normalized_program in 141 | autoconf*) 142 | echo "You should only need it if you modified 'configure.ac'," 143 | echo "or m4 files included by it." 144 | program_details 'autoconf' 145 | ;; 146 | autoheader*) 147 | echo "You should only need it if you modified 'acconfig.h' or" 148 | echo "$configure_deps." 149 | program_details 'autoheader' 150 | ;; 151 | automake*) 152 | echo "You should only need it if you modified 'Makefile.am' or" 153 | echo "$configure_deps." 154 | program_details 'automake' 155 | ;; 156 | aclocal*) 157 | echo "You should only need it if you modified 'acinclude.m4' or" 158 | echo "$configure_deps." 159 | program_details 'aclocal' 160 | ;; 161 | autom4te*) 162 | echo "You might have modified some maintainer files that require" 163 | echo "the 'autom4te' program to be rebuilt." 164 | program_details 'autom4te' 165 | ;; 166 | bison*|yacc*) 167 | echo "You should only need it if you modified a '.y' file." 168 | echo "You may want to install the GNU Bison package:" 169 | echo "<$gnu_software_URL/bison/>" 170 | ;; 171 | lex*|flex*) 172 | echo "You should only need it if you modified a '.l' file." 173 | echo "You may want to install the Fast Lexical Analyzer package:" 174 | echo "<$flex_URL>" 175 | ;; 176 | help2man*) 177 | echo "You should only need it if you modified a dependency" \ 178 | "of a man page." 179 | echo "You may want to install the GNU Help2man package:" 180 | echo "<$gnu_software_URL/help2man/>" 181 | ;; 182 | makeinfo*) 183 | echo "You should only need it if you modified a '.texi' file, or" 184 | echo "any other file indirectly affecting the aspect of the manual." 185 | echo "You might want to install the Texinfo package:" 186 | echo "<$gnu_software_URL/texinfo/>" 187 | echo "The spurious makeinfo call might also be the consequence of" 188 | echo "using a buggy 'make' (AIX, DU, IRIX), in which case you might" 189 | echo "want to install GNU make:" 190 | echo "<$gnu_software_URL/make/>" 191 | ;; 192 | *) 193 | echo "You might have modified some files without having the proper" 194 | echo "tools for further handling them. Check the 'README' file, it" 195 | echo "often tells you about the needed prerequisites for installing" 196 | echo "this package. You may also peek at any GNU archive site, in" 197 | echo "case some other package contains this missing '$1' program." 198 | ;; 199 | esac 200 | } 201 | 202 | give_advice "$1" | sed -e '1s/^/WARNING: /' \ 203 | -e '2,$s/^/ /' >&2 204 | 205 | # Propagate the correct exit status (expected to be 127 for a program 206 | # not found, 63 for a program that failed due to version mismatch). 207 | exit $st 208 | 209 | # Local variables: 210 | # eval: (add-hook 'write-file-hooks 'time-stamp) 211 | # time-stamp-start: "scriptversion=" 212 | # time-stamp-format: "%:y-%02m-%02d.%02H" 213 | # time-stamp-time-zone: "UTC" 214 | # time-stamp-end: "; # UTC" 215 | # End: 216 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | bin_PROGRAMS = k3screenctrl 2 | k3screenctrl_SOURCES = checksum.h common.h config.c config.h crcccitt.c debug.c debug.h file_util.c file_util.h frame.c frame.h gpio.c gpio.h handlers.c handlers.h infocenter.c infocenter.h logging.c logging.h main.c mcu_proto.h mem_util.c mem_util.h pages.c pages.h requests.c requests.h scripts.c scripts.h serial_port.c serial_port.h signals.c signals.h 3 | -------------------------------------------------------------------------------- /src/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile.in generated by automake 1.15 from Makefile.am. 2 | # @configure_input@ 3 | 4 | # Copyright (C) 1994-2014 Free Software Foundation, Inc. 5 | 6 | # This Makefile.in is free software; the Free Software Foundation 7 | # gives unlimited permission to copy and/or distribute it, 8 | # with or without modifications, as long as this notice is preserved. 9 | 10 | # This program is distributed in the hope that it will be useful, 11 | # but WITHOUT ANY WARRANTY, to the extent permitted by law; without 12 | # even the implied warranty of MERCHANTABILITY or FITNESS FOR A 13 | # PARTICULAR PURPOSE. 14 | 15 | @SET_MAKE@ 16 | 17 | VPATH = @srcdir@ 18 | am__is_gnu_make = { \ 19 | if test -z '$(MAKELEVEL)'; then \ 20 | false; \ 21 | elif test -n '$(MAKE_HOST)'; then \ 22 | true; \ 23 | elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \ 24 | true; \ 25 | else \ 26 | false; \ 27 | fi; \ 28 | } 29 | am__make_running_with_option = \ 30 | case $${target_option-} in \ 31 | ?) ;; \ 32 | *) echo "am__make_running_with_option: internal error: invalid" \ 33 | "target option '$${target_option-}' specified" >&2; \ 34 | exit 1;; \ 35 | esac; \ 36 | has_opt=no; \ 37 | sane_makeflags=$$MAKEFLAGS; \ 38 | if $(am__is_gnu_make); then \ 39 | sane_makeflags=$$MFLAGS; \ 40 | else \ 41 | case $$MAKEFLAGS in \ 42 | *\\[\ \ ]*) \ 43 | bs=\\; \ 44 | sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \ 45 | | sed "s/$$bs$$bs[$$bs $$bs ]*//g"`;; \ 46 | esac; \ 47 | fi; \ 48 | skip_next=no; \ 49 | strip_trailopt () \ 50 | { \ 51 | flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \ 52 | }; \ 53 | for flg in $$sane_makeflags; do \ 54 | test $$skip_next = yes && { skip_next=no; continue; }; \ 55 | case $$flg in \ 56 | *=*|--*) continue;; \ 57 | -*I) strip_trailopt 'I'; skip_next=yes;; \ 58 | -*I?*) strip_trailopt 'I';; \ 59 | -*O) strip_trailopt 'O'; skip_next=yes;; \ 60 | -*O?*) strip_trailopt 'O';; \ 61 | -*l) strip_trailopt 'l'; skip_next=yes;; \ 62 | -*l?*) strip_trailopt 'l';; \ 63 | -[dEDm]) skip_next=yes;; \ 64 | -[JT]) skip_next=yes;; \ 65 | esac; \ 66 | case $$flg in \ 67 | *$$target_option*) has_opt=yes; break;; \ 68 | esac; \ 69 | done; \ 70 | test $$has_opt = yes 71 | am__make_dryrun = (target_option=n; $(am__make_running_with_option)) 72 | am__make_keepgoing = (target_option=k; $(am__make_running_with_option)) 73 | pkgdatadir = $(datadir)/@PACKAGE@ 74 | pkgincludedir = $(includedir)/@PACKAGE@ 75 | pkglibdir = $(libdir)/@PACKAGE@ 76 | pkglibexecdir = $(libexecdir)/@PACKAGE@ 77 | am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd 78 | install_sh_DATA = $(install_sh) -c -m 644 79 | install_sh_PROGRAM = $(install_sh) -c 80 | install_sh_SCRIPT = $(install_sh) -c 81 | INSTALL_HEADER = $(INSTALL_DATA) 82 | transform = $(program_transform_name) 83 | NORMAL_INSTALL = : 84 | PRE_INSTALL = : 85 | POST_INSTALL = : 86 | NORMAL_UNINSTALL = : 87 | PRE_UNINSTALL = : 88 | POST_UNINSTALL = : 89 | bin_PROGRAMS = k3screenctrl$(EXEEXT) 90 | subdir = src 91 | ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 92 | am__aclocal_m4_deps = $(top_srcdir)/configure.ac 93 | am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ 94 | $(ACLOCAL_M4) 95 | DIST_COMMON = $(srcdir)/Makefile.am $(am__DIST_COMMON) 96 | mkinstalldirs = $(install_sh) -d 97 | CONFIG_HEADER = $(top_builddir)/config.h 98 | CONFIG_CLEAN_FILES = 99 | CONFIG_CLEAN_VPATH_FILES = 100 | am__installdirs = "$(DESTDIR)$(bindir)" 101 | PROGRAMS = $(bin_PROGRAMS) 102 | am_k3screenctrl_OBJECTS = config.$(OBJEXT) crcccitt.$(OBJEXT) \ 103 | debug.$(OBJEXT) file_util.$(OBJEXT) frame.$(OBJEXT) \ 104 | gpio.$(OBJEXT) handlers.$(OBJEXT) infocenter.$(OBJEXT) \ 105 | logging.$(OBJEXT) main.$(OBJEXT) mem_util.$(OBJEXT) \ 106 | pages.$(OBJEXT) requests.$(OBJEXT) scripts.$(OBJEXT) \ 107 | serial_port.$(OBJEXT) signals.$(OBJEXT) 108 | k3screenctrl_OBJECTS = $(am_k3screenctrl_OBJECTS) 109 | k3screenctrl_LDADD = $(LDADD) 110 | AM_V_P = $(am__v_P_@AM_V@) 111 | am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) 112 | am__v_P_0 = false 113 | am__v_P_1 = : 114 | AM_V_GEN = $(am__v_GEN_@AM_V@) 115 | am__v_GEN_ = $(am__v_GEN_@AM_DEFAULT_V@) 116 | am__v_GEN_0 = @echo " GEN " $@; 117 | am__v_GEN_1 = 118 | AM_V_at = $(am__v_at_@AM_V@) 119 | am__v_at_ = $(am__v_at_@AM_DEFAULT_V@) 120 | am__v_at_0 = @ 121 | am__v_at_1 = 122 | DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir) 123 | depcomp = $(SHELL) $(top_srcdir)/depcomp 124 | am__depfiles_maybe = depfiles 125 | am__mv = mv -f 126 | COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ 127 | $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) 128 | AM_V_CC = $(am__v_CC_@AM_V@) 129 | am__v_CC_ = $(am__v_CC_@AM_DEFAULT_V@) 130 | am__v_CC_0 = @echo " CC " $@; 131 | am__v_CC_1 = 132 | CCLD = $(CC) 133 | LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@ 134 | AM_V_CCLD = $(am__v_CCLD_@AM_V@) 135 | am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) 136 | am__v_CCLD_0 = @echo " CCLD " $@; 137 | am__v_CCLD_1 = 138 | SOURCES = $(k3screenctrl_SOURCES) 139 | DIST_SOURCES = $(k3screenctrl_SOURCES) 140 | am__can_run_installinfo = \ 141 | case $$AM_UPDATE_INFO_DIR in \ 142 | n|no|NO) false;; \ 143 | *) (install-info --version) >/dev/null 2>&1;; \ 144 | esac 145 | am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP) 146 | # Read a list of newline-separated strings from the standard input, 147 | # and print each of them once, without duplicates. Input order is 148 | # *not* preserved. 149 | am__uniquify_input = $(AWK) '\ 150 | BEGIN { nonempty = 0; } \ 151 | { items[$$0] = 1; nonempty = 1; } \ 152 | END { if (nonempty) { for (i in items) print i; }; } \ 153 | ' 154 | # Make sure the list of sources is unique. This is necessary because, 155 | # e.g., the same source file might be shared among _SOURCES variables 156 | # for different programs/libraries. 157 | am__define_uniq_tagged_files = \ 158 | list='$(am__tagged_files)'; \ 159 | unique=`for i in $$list; do \ 160 | if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \ 161 | done | $(am__uniquify_input)` 162 | ETAGS = etags 163 | CTAGS = ctags 164 | am__DIST_COMMON = $(srcdir)/Makefile.in $(top_srcdir)/depcomp 165 | DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST) 166 | ACLOCAL = @ACLOCAL@ 167 | AMTAR = @AMTAR@ 168 | AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ 169 | AUTOCONF = @AUTOCONF@ 170 | AUTOHEADER = @AUTOHEADER@ 171 | AUTOMAKE = @AUTOMAKE@ 172 | AWK = @AWK@ 173 | CC = @CC@ 174 | CCDEPMODE = @CCDEPMODE@ 175 | CFLAGS = @CFLAGS@ 176 | CPP = @CPP@ 177 | CPPFLAGS = @CPPFLAGS@ 178 | CYGPATH_W = @CYGPATH_W@ 179 | DEFS = @DEFS@ 180 | DEPDIR = @DEPDIR@ 181 | ECHO_C = @ECHO_C@ 182 | ECHO_N = @ECHO_N@ 183 | ECHO_T = @ECHO_T@ 184 | EGREP = @EGREP@ 185 | EXEEXT = @EXEEXT@ 186 | GREP = @GREP@ 187 | INSTALL = @INSTALL@ 188 | INSTALL_DATA = @INSTALL_DATA@ 189 | INSTALL_PROGRAM = @INSTALL_PROGRAM@ 190 | INSTALL_SCRIPT = @INSTALL_SCRIPT@ 191 | INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ 192 | LDFLAGS = @LDFLAGS@ 193 | LIBOBJS = @LIBOBJS@ 194 | LIBS = @LIBS@ 195 | LTLIBOBJS = @LTLIBOBJS@ 196 | MAKEINFO = @MAKEINFO@ 197 | MKDIR_P = @MKDIR_P@ 198 | OBJEXT = @OBJEXT@ 199 | PACKAGE = @PACKAGE@ 200 | PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ 201 | PACKAGE_NAME = @PACKAGE_NAME@ 202 | PACKAGE_STRING = @PACKAGE_STRING@ 203 | PACKAGE_TARNAME = @PACKAGE_TARNAME@ 204 | PACKAGE_URL = @PACKAGE_URL@ 205 | PACKAGE_VERSION = @PACKAGE_VERSION@ 206 | PATH_SEPARATOR = @PATH_SEPARATOR@ 207 | SET_MAKE = @SET_MAKE@ 208 | SHELL = @SHELL@ 209 | STRIP = @STRIP@ 210 | VERSION = @VERSION@ 211 | abs_builddir = @abs_builddir@ 212 | abs_srcdir = @abs_srcdir@ 213 | abs_top_builddir = @abs_top_builddir@ 214 | abs_top_srcdir = @abs_top_srcdir@ 215 | ac_ct_CC = @ac_ct_CC@ 216 | am__include = @am__include@ 217 | am__leading_dot = @am__leading_dot@ 218 | am__quote = @am__quote@ 219 | am__tar = @am__tar@ 220 | am__untar = @am__untar@ 221 | bindir = @bindir@ 222 | build_alias = @build_alias@ 223 | builddir = @builddir@ 224 | datadir = @datadir@ 225 | datarootdir = @datarootdir@ 226 | docdir = @docdir@ 227 | dvidir = @dvidir@ 228 | exec_prefix = @exec_prefix@ 229 | host_alias = @host_alias@ 230 | htmldir = @htmldir@ 231 | includedir = @includedir@ 232 | infodir = @infodir@ 233 | install_sh = @install_sh@ 234 | libdir = @libdir@ 235 | libexecdir = @libexecdir@ 236 | localedir = @localedir@ 237 | localstatedir = @localstatedir@ 238 | mandir = @mandir@ 239 | mkdir_p = @mkdir_p@ 240 | oldincludedir = @oldincludedir@ 241 | pdfdir = @pdfdir@ 242 | prefix = @prefix@ 243 | program_transform_name = @program_transform_name@ 244 | psdir = @psdir@ 245 | runstatedir = @runstatedir@ 246 | sbindir = @sbindir@ 247 | sharedstatedir = @sharedstatedir@ 248 | srcdir = @srcdir@ 249 | sysconfdir = @sysconfdir@ 250 | target_alias = @target_alias@ 251 | top_build_prefix = @top_build_prefix@ 252 | top_builddir = @top_builddir@ 253 | top_srcdir = @top_srcdir@ 254 | k3screenctrl_SOURCES = checksum.h common.h config.c config.h crcccitt.c debug.c debug.h file_util.c file_util.h frame.c frame.h gpio.c gpio.h handlers.c handlers.h infocenter.c infocenter.h logging.c logging.h main.c mcu_proto.h mem_util.c mem_util.h pages.c pages.h requests.c requests.h scripts.c scripts.h serial_port.c serial_port.h signals.c signals.h 255 | all: all-am 256 | 257 | .SUFFIXES: 258 | .SUFFIXES: .c .o .obj 259 | $(srcdir)/Makefile.in: $(srcdir)/Makefile.am $(am__configure_deps) 260 | @for dep in $?; do \ 261 | case '$(am__configure_deps)' in \ 262 | *$$dep*) \ 263 | ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \ 264 | && { if test -f $@; then exit 0; else break; fi; }; \ 265 | exit 1;; \ 266 | esac; \ 267 | done; \ 268 | echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu src/Makefile'; \ 269 | $(am__cd) $(top_srcdir) && \ 270 | $(AUTOMAKE) --gnu src/Makefile 271 | Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status 272 | @case '$?' in \ 273 | *config.status*) \ 274 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \ 275 | *) \ 276 | echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \ 277 | cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \ 278 | esac; 279 | 280 | $(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES) 281 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 282 | 283 | $(top_srcdir)/configure: $(am__configure_deps) 284 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 285 | $(ACLOCAL_M4): $(am__aclocal_m4_deps) 286 | cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh 287 | $(am__aclocal_m4_deps): 288 | install-binPROGRAMS: $(bin_PROGRAMS) 289 | @$(NORMAL_INSTALL) 290 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 291 | if test -n "$$list"; then \ 292 | echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \ 293 | $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \ 294 | fi; \ 295 | for p in $$list; do echo "$$p $$p"; done | \ 296 | sed 's/$(EXEEXT)$$//' | \ 297 | while read p p1; do if test -f $$p \ 298 | ; then echo "$$p"; echo "$$p"; else :; fi; \ 299 | done | \ 300 | sed -e 'p;s,.*/,,;n;h' \ 301 | -e 's|.*|.|' \ 302 | -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \ 303 | sed 'N;N;N;s,\n, ,g' | \ 304 | $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \ 305 | { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \ 306 | if ($$2 == $$4) files[d] = files[d] " " $$1; \ 307 | else { print "f", $$3 "/" $$4, $$1; } } \ 308 | END { for (d in files) print "f", d, files[d] }' | \ 309 | while read type dir files; do \ 310 | if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \ 311 | test -z "$$files" || { \ 312 | echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \ 313 | $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \ 314 | } \ 315 | ; done 316 | 317 | uninstall-binPROGRAMS: 318 | @$(NORMAL_UNINSTALL) 319 | @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \ 320 | files=`for p in $$list; do echo "$$p"; done | \ 321 | sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \ 322 | -e 's/$$/$(EXEEXT)/' \ 323 | `; \ 324 | test -n "$$list" || exit 0; \ 325 | echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \ 326 | cd "$(DESTDIR)$(bindir)" && rm -f $$files 327 | 328 | clean-binPROGRAMS: 329 | -test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS) 330 | 331 | k3screenctrl$(EXEEXT): $(k3screenctrl_OBJECTS) $(k3screenctrl_DEPENDENCIES) $(EXTRA_k3screenctrl_DEPENDENCIES) 332 | @rm -f k3screenctrl$(EXEEXT) 333 | $(AM_V_CCLD)$(LINK) $(k3screenctrl_OBJECTS) $(k3screenctrl_LDADD) $(LIBS) 334 | 335 | mostlyclean-compile: 336 | -rm -f *.$(OBJEXT) 337 | 338 | distclean-compile: 339 | -rm -f *.tab.c 340 | 341 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/config.Po@am__quote@ 342 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/crcccitt.Po@am__quote@ 343 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@ 344 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/file_util.Po@am__quote@ 345 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/frame.Po@am__quote@ 346 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpio.Po@am__quote@ 347 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/handlers.Po@am__quote@ 348 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/infocenter.Po@am__quote@ 349 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/logging.Po@am__quote@ 350 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@ 351 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mem_util.Po@am__quote@ 352 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pages.Po@am__quote@ 353 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/requests.Po@am__quote@ 354 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/scripts.Po@am__quote@ 355 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/serial_port.Po@am__quote@ 356 | @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/signals.Po@am__quote@ 357 | 358 | .c.o: 359 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< 360 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 361 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 362 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 363 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ $< 364 | 365 | .c.obj: 366 | @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'` 367 | @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po 368 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='$<' object='$@' libtool=no @AMDEPBACKSLASH@ 369 | @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 370 | @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'` 371 | 372 | ID: $(am__tagged_files) 373 | $(am__define_uniq_tagged_files); mkid -fID $$unique 374 | tags: tags-am 375 | TAGS: tags 376 | 377 | tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 378 | set x; \ 379 | here=`pwd`; \ 380 | $(am__define_uniq_tagged_files); \ 381 | shift; \ 382 | if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \ 383 | test -n "$$unique" || unique=$$empty_fix; \ 384 | if test $$# -gt 0; then \ 385 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 386 | "$$@" $$unique; \ 387 | else \ 388 | $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \ 389 | $$unique; \ 390 | fi; \ 391 | fi 392 | ctags: ctags-am 393 | 394 | CTAGS: ctags 395 | ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files) 396 | $(am__define_uniq_tagged_files); \ 397 | test -z "$(CTAGS_ARGS)$$unique" \ 398 | || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \ 399 | $$unique 400 | 401 | GTAGS: 402 | here=`$(am__cd) $(top_builddir) && pwd` \ 403 | && $(am__cd) $(top_srcdir) \ 404 | && gtags -i $(GTAGS_ARGS) "$$here" 405 | cscopelist: cscopelist-am 406 | 407 | cscopelist-am: $(am__tagged_files) 408 | list='$(am__tagged_files)'; \ 409 | case "$(srcdir)" in \ 410 | [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \ 411 | *) sdir=$(subdir)/$(srcdir) ;; \ 412 | esac; \ 413 | for i in $$list; do \ 414 | if test -f "$$i"; then \ 415 | echo "$(subdir)/$$i"; \ 416 | else \ 417 | echo "$$sdir/$$i"; \ 418 | fi; \ 419 | done >> $(top_builddir)/cscope.files 420 | 421 | distclean-tags: 422 | -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags 423 | 424 | distdir: $(DISTFILES) 425 | @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 426 | topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ 427 | list='$(DISTFILES)'; \ 428 | dist_files=`for file in $$list; do echo $$file; done | \ 429 | sed -e "s|^$$srcdirstrip/||;t" \ 430 | -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \ 431 | case $$dist_files in \ 432 | */*) $(MKDIR_P) `echo "$$dist_files" | \ 433 | sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \ 434 | sort -u` ;; \ 435 | esac; \ 436 | for file in $$dist_files; do \ 437 | if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \ 438 | if test -d $$d/$$file; then \ 439 | dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \ 440 | if test -d "$(distdir)/$$file"; then \ 441 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 442 | fi; \ 443 | if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \ 444 | cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \ 445 | find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \ 446 | fi; \ 447 | cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \ 448 | else \ 449 | test -f "$(distdir)/$$file" \ 450 | || cp -p $$d/$$file "$(distdir)/$$file" \ 451 | || exit 1; \ 452 | fi; \ 453 | done 454 | check-am: all-am 455 | check: check-am 456 | all-am: Makefile $(PROGRAMS) 457 | installdirs: 458 | for dir in "$(DESTDIR)$(bindir)"; do \ 459 | test -z "$$dir" || $(MKDIR_P) "$$dir"; \ 460 | done 461 | install: install-am 462 | install-exec: install-exec-am 463 | install-data: install-data-am 464 | uninstall: uninstall-am 465 | 466 | install-am: all-am 467 | @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am 468 | 469 | installcheck: installcheck-am 470 | install-strip: 471 | if test -z '$(STRIP)'; then \ 472 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 473 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 474 | install; \ 475 | else \ 476 | $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \ 477 | install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \ 478 | "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \ 479 | fi 480 | mostlyclean-generic: 481 | 482 | clean-generic: 483 | 484 | distclean-generic: 485 | -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES) 486 | -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES) 487 | 488 | maintainer-clean-generic: 489 | @echo "This command is intended for maintainers to use" 490 | @echo "it deletes files that may require special tools to rebuild." 491 | clean: clean-am 492 | 493 | clean-am: clean-binPROGRAMS clean-generic mostlyclean-am 494 | 495 | distclean: distclean-am 496 | -rm -rf ./$(DEPDIR) 497 | -rm -f Makefile 498 | distclean-am: clean-am distclean-compile distclean-generic \ 499 | distclean-tags 500 | 501 | dvi: dvi-am 502 | 503 | dvi-am: 504 | 505 | html: html-am 506 | 507 | html-am: 508 | 509 | info: info-am 510 | 511 | info-am: 512 | 513 | install-data-am: 514 | 515 | install-dvi: install-dvi-am 516 | 517 | install-dvi-am: 518 | 519 | install-exec-am: install-binPROGRAMS 520 | 521 | install-html: install-html-am 522 | 523 | install-html-am: 524 | 525 | install-info: install-info-am 526 | 527 | install-info-am: 528 | 529 | install-man: 530 | 531 | install-pdf: install-pdf-am 532 | 533 | install-pdf-am: 534 | 535 | install-ps: install-ps-am 536 | 537 | install-ps-am: 538 | 539 | installcheck-am: 540 | 541 | maintainer-clean: maintainer-clean-am 542 | -rm -rf ./$(DEPDIR) 543 | -rm -f Makefile 544 | maintainer-clean-am: distclean-am maintainer-clean-generic 545 | 546 | mostlyclean: mostlyclean-am 547 | 548 | mostlyclean-am: mostlyclean-compile mostlyclean-generic 549 | 550 | pdf: pdf-am 551 | 552 | pdf-am: 553 | 554 | ps: ps-am 555 | 556 | ps-am: 557 | 558 | uninstall-am: uninstall-binPROGRAMS 559 | 560 | .MAKE: install-am install-strip 561 | 562 | .PHONY: CTAGS GTAGS TAGS all all-am check check-am clean \ 563 | clean-binPROGRAMS clean-generic cscopelist-am ctags ctags-am \ 564 | distclean distclean-compile distclean-generic distclean-tags \ 565 | distdir dvi dvi-am html html-am info info-am install \ 566 | install-am install-binPROGRAMS install-data install-data-am \ 567 | install-dvi install-dvi-am install-exec install-exec-am \ 568 | install-html install-html-am install-info install-info-am \ 569 | install-man install-pdf install-pdf-am install-ps \ 570 | install-ps-am install-strip installcheck installcheck-am \ 571 | installdirs maintainer-clean maintainer-clean-generic \ 572 | mostlyclean mostlyclean-compile mostlyclean-generic pdf pdf-am \ 573 | ps ps-am tags tags-am uninstall uninstall-am \ 574 | uninstall-binPROGRAMS 575 | 576 | .PRECIOUS: Makefile 577 | 578 | 579 | # Tell versions [3.59,3.63) of GNU make to not export all variables. 580 | # Otherwise a system limit (for SysV at least) may be exceeded. 581 | .NOEXPORT: 582 | -------------------------------------------------------------------------------- /src/checksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libcrc 3 | * File: include/checksum.h 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 1999-2016 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The headerfile include/checksum.h contains the definitions and prototypes 31 | * for routines that can be used to calculate several kinds of checksums. 32 | */ 33 | 34 | #ifndef DEF_LIBCRC_CHECKSUM_H 35 | #define DEF_LIBCRC_CHECKSUM_H 36 | 37 | #include 38 | 39 | /* 40 | * #define CRC_POLY_xxxx 41 | * 42 | * The constants of the form CRC_POLY_xxxx define the polynomials for some well 43 | * known CRC calculations. 44 | */ 45 | 46 | #define CRC_POLY_CCITT 0x1021 47 | 48 | /* 49 | * #define CRC_START_xxxx 50 | * 51 | * The constants of the form CRC_START_xxxx define the values that are used for 52 | * initialization of a CRC value for common used calculation methods. 53 | */ 54 | 55 | #define CRC_START_XMODEM 0x0000 56 | 57 | /* 58 | * Prototype list of global functions 59 | */ 60 | 61 | uint16_t crc_xmodem( const unsigned char *input_str, size_t num_bytes ); 62 | uint16_t update_crc_ccitt( uint16_t crc, unsigned char c ); 63 | 64 | #endif // DEF_LIBCRC_CHECKSUM_H 65 | -------------------------------------------------------------------------------- /src/common.h: -------------------------------------------------------------------------------- 1 | #ifndef _COMMON_H 2 | #define _COMMON_H 3 | 4 | #define FAILURE -1 5 | #define SUCCESS 0 6 | 7 | #endif 8 | -------------------------------------------------------------------------------- /src/config.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "config.h" 7 | 8 | static CONFIG g_config; 9 | 10 | static void config_show_help() { 11 | fprintf( 12 | stderr, 13 | "USAGE: k3screenctrl [OPTIONS]\n\n" 14 | "\t-h, --help\t\t\tShow this help\n" 15 | "\t-r, --skip-reset\t\tDo not reset screen on startup (will reset " 16 | "by default)\n" 17 | "\t-f, --foreground\t\tRun in foreground and print logs to stderr " 18 | "as well\n" 19 | "\t-t, --test\t\t\tTest the scripts: collect info and print them, then " 20 | "exit\n" 21 | "\t-d, --update-interval \tCall data collection scripts " 22 | "corresponding to current page and update content every SECS seconds\n" 23 | "\t-m, --screen-timeout \tTurn off screen after this period of " 24 | "time if there isn't any user interaction\n" 25 | "\t-s, --host-script \tUse this script to gather hosts " 26 | "info\n" 27 | "\t-w, --wifi-script \tUse this script to gather WiFi " 28 | "info\n" 29 | "\t-p, --port-script \tUse this script to gather port " 30 | "info\n" 31 | "\t-n, --wan-script \t\tUse this script to gather WAN speed " 32 | "and internet connection info\n" 33 | "\t-i, --basic-info-script \tUse this script to gather " 34 | "basic info\n" 35 | "\nThe defaults are /lib/k3screenctrl/{host,wifi,port,wan,basic}.sh " 36 | "with an interval of 2 seconds\n"); 37 | exit(1); 38 | } 39 | 40 | void config_parse_cmdline(int argc, char *argv[]) { 41 | static const struct option long_options[] = { 42 | {"help", no_argument, NULL, 'h'}, 43 | {"foreground", no_argument, NULL, 'f'}, 44 | {"skip-reset", no_argument, NULL, 'r'}, 45 | {"test", no_argument, NULL, 't'}, 46 | {"update-interval", required_argument, NULL, 'd'}, 47 | {"screen-timeout", required_argument, NULL, 'm'}, 48 | {"host-script", required_argument, NULL, 's'}, 49 | {"wifi-script", required_argument, NULL, 'w'}, 50 | {"port-script", required_argument, NULL, 'p'}, 51 | {"wan-script", required_argument, NULL, 'n'}, 52 | {"basic-info-script", required_argument, NULL, 'i'}, 53 | {0, 0, 0, 0}}; 54 | static const char *short_opts = "hfrtd:m:s:w:p:n:i:"; 55 | 56 | int opt_index; 57 | signed char result; 58 | while ((result = getopt_long(argc, argv, short_opts, long_options, 59 | &opt_index)) != -1) { 60 | switch (result) { 61 | case 'h': 62 | config_show_help(); 63 | break; 64 | case 'f': 65 | g_config.foreground = 1; 66 | break; 67 | case 'r': 68 | g_config.skip_reset = 1; 69 | break; 70 | case 't': 71 | g_config.test_mode = 1; 72 | break; 73 | case 'd': 74 | g_config.update_interval = atoi(optarg); 75 | break; 76 | case 'm': 77 | g_config.screen_timeout = atoi(optarg); 78 | break; 79 | case 's': 80 | free(g_config.host_script); 81 | g_config.host_script = strdup(optarg); 82 | break; 83 | case 'w': 84 | free(g_config.wifi_script); 85 | g_config.wifi_script = strdup(optarg); 86 | break; 87 | case 'p': 88 | free(g_config.port_script); 89 | g_config.port_script = strdup(optarg); 90 | break; 91 | case 'n': 92 | free(g_config.wan_script); 93 | g_config.wan_script = strdup(optarg); 94 | break; 95 | case 'i': 96 | free(g_config.basic_info_script); 97 | g_config.basic_info_script = strdup(optarg); 98 | break; 99 | } 100 | } 101 | } 102 | 103 | void config_load_defaults() { 104 | g_config.skip_reset = DEFAULT_SKIP_RESET; 105 | g_config.foreground = DEFAULT_FOREGROUND; 106 | g_config.test_mode = DEFAULT_TEST_MODE; 107 | g_config.update_interval = DEFAULT_UPDATE_INTERVAL; 108 | g_config.screen_timeout = DEFAULT_SCREEN_TIMEOUT; 109 | g_config.host_script = strdup(DEFAULT_HOST_SCRIPT); 110 | g_config.wifi_script = strdup(DEFAULT_WIFI_SCRIPT); 111 | g_config.port_script = strdup(DEFAULT_PORT_SCRIPT); 112 | g_config.wan_script = strdup(DEFAULT_WAN_SCRIPT); 113 | g_config.basic_info_script = strdup(DEFAULT_BASIC_INFO_SCRIPT); 114 | } 115 | 116 | void config_free() { 117 | free(g_config.host_script); 118 | free(g_config.wifi_script); 119 | free(g_config.port_script); 120 | free(g_config.wan_script); 121 | free(g_config.basic_info_script); 122 | } 123 | 124 | CONFIG *config_get() { return &g_config; } -------------------------------------------------------------------------------- /src/config.h: -------------------------------------------------------------------------------- 1 | #ifndef _CONFIG_H 2 | #define _CONFIG_H 3 | 4 | typedef struct _config { 5 | /** 6 | * This script will be called in order to get basic info 7 | * such as HW/SW version, MAC address, model etc. 8 | * 9 | * Expected output format (one line for each field): 10 | * MODEL 11 | * HW version 12 | * FW version 13 | * MAC address 14 | * 15 | * Example: 16 | * K3 17 | * A1 18 | * r3921 19 | * 02:00:00:00:00:00 20 | */ 21 | char *basic_info_script; 22 | #define DEFAULT_BASIC_INFO_SCRIPT "/lib/k3screenctrl/basic.sh" 23 | 24 | /** 25 | * This script will be called in order to get ports info. 26 | * 27 | * Expected output format (one line for each field): 28 | * LAN1 connected? (0 or 1, applies to other fields as well) 29 | * LAN2 connected? 30 | * LAN3 connected? 31 | * WAN connected? 32 | * USB connected / mounted? (up to you) 33 | * 34 | * Example: 35 | * 1 36 | * 1 37 | * 0 38 | * 1 39 | * 1 40 | */ 41 | char *port_script; 42 | #define DEFAULT_PORT_SCRIPT "/lib/k3screenctrl/port.sh" 43 | 44 | /** 45 | * This script will be called in order to get WAN speed info. 46 | * 47 | * Expected output format (one line for each field): 48 | * Internet connected? (0 or 1) 49 | * Upload speed (integer, in Bytes per sec) 50 | * Download speed (integer, in Bytes per sec) 51 | * 52 | * Example: 53 | * 1 54 | * 10240000 55 | * 2048000 56 | */ 57 | char *wan_script; 58 | #define DEFAULT_WAN_SCRIPT "/lib/k3screenctrl/wan.sh" 59 | 60 | /** 61 | * This script will be called in order to get WiFi info. 62 | * 63 | * Expected output format (one line for each field): 64 | * Does 2.4GHz and 5GHz have same SSID? (Band steering?) (0 or 1) 65 | * 2.4GHz SSID 66 | * 2.4GHz password (or ******* if you like, applies to other fields) 67 | * 2.4GHz enabled (0 or 1) 68 | * Number of clients connected to 2.4GHz 69 | * 5GHz SSID 70 | * 5GHz password 71 | * 5GHz enabled 72 | * Number of clients connected to 5GHz 73 | * Visitor network SSID 74 | * Visitor network password 75 | * Visitor network enabled 76 | * Number of clients connected to visitor network 77 | * 78 | * Example: 79 | * 0 80 | * LEDE-24G 81 | * password24 82 | * 1 83 | * 0 84 | * LEDE-5G 85 | * password5 86 | * 1 87 | * 4 88 | * 89 | * 90 | * 0 91 | * 0 92 | */ 93 | char *wifi_script; 94 | #define DEFAULT_WIFI_SCRIPT "/lib/k3screenctrl/wifi.sh" 95 | 96 | /** 97 | * This script will be called in order to get host info. 98 | * 99 | * Expected output format (one line for each field): 100 | * Number of hosts 101 | * Host1 name 102 | * Host1 upload speed 103 | * Host1 download speed 104 | * Host1 brand (0~29) 105 | * 106 | * 107 | * Example: 108 | * 2 109 | * MyHost1 110 | * 248193 111 | * 1024000 112 | * 25 113 | * MyHost2 114 | * 902831 115 | * 10485760 116 | * 0 117 | */ 118 | char *host_script; 119 | #define DEFAULT_HOST_SCRIPT "/lib/k3screenctrl/host.sh" 120 | 121 | /** 122 | * Shall we skip GPIO setup (do not reset the microcontroller)? 123 | * Useful when debugging. 124 | */ 125 | int skip_reset; 126 | #define DEFAULT_SKIP_RESET 0 127 | 128 | /** 129 | * Keep in foreground. And log to stderr as well. 130 | */ 131 | int foreground; 132 | #define DEFAULT_FOREGROUND 0 133 | 134 | /** 135 | * Script test mode. Collect data from scripts and print them, then exit 136 | */ 137 | int test_mode; 138 | #define DEFAULT_TEST_MODE 0 139 | 140 | /** 141 | * Update interval. Scripts corresponding to current page will be called 142 | * with this interval (seconds). Should not be shorter than the time 143 | * scripts take. 144 | * Note: PAGE_WAN requires 2 scripts to gather enough data, while other 145 | * pages require only 1 each. 146 | */ 147 | int update_interval; 148 | #define DEFAULT_UPDATE_INTERVAL 2 149 | 150 | /** 151 | * Turn off screen after this time (seconds). 0 to disable. 152 | */ 153 | int screen_timeout; 154 | #define DEFAULT_SCREEN_TIMEOUT 10 155 | } CONFIG; 156 | 157 | void config_parse_cmdline(int argc, char *argv[]); 158 | void config_load_defaults(); 159 | CONFIG *config_get(); 160 | void config_free(); 161 | 162 | #define CFG (config_get()) 163 | #endif 164 | -------------------------------------------------------------------------------- /src/crcccitt.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Library: libcrc 3 | * File: src/crcccitt.c 4 | * Author: Lammert Bies 5 | * 6 | * This file is licensed under the MIT License as stated below 7 | * 8 | * Copyright (c) 1999-2016 Lammert Bies 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining a copy 11 | * of this software and associated documentation files (the "Software"), to deal 12 | * in the Software without restriction, including without limitation the rights 13 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the Software is 15 | * furnished to do so, subject to the following conditions: 16 | * 17 | * The above copyright notice and this permission notice shall be included in all 18 | * copies or substantial portions of the Software. 19 | * 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 26 | * SOFTWARE. 27 | * 28 | * Description 29 | * ----------- 30 | * The module src/crcccitt.c contains routines which are used to calculate the 31 | * CCITT CRC values of a string of bytes. 32 | */ 33 | 34 | #include 35 | #include 36 | #include "checksum.h" 37 | 38 | static uint16_t crc_ccitt_generic( const unsigned char *input_str, size_t num_bytes, uint16_t start_value ); 39 | static void init_crcccitt_tab( void ); 40 | 41 | static bool crc_tabccitt_init = false; 42 | static uint16_t crc_tabccitt[256]; 43 | 44 | /* 45 | * uint16_t crc_xmodem( const unsigned char *input_str, size_t num_bytes ); 46 | * 47 | * The function crc_xmodem() performs a one-pass calculation of an X-Modem CRC 48 | * for a byte string that has been passed as a parameter. 49 | */ 50 | 51 | uint16_t crc_xmodem( const unsigned char *input_str, size_t num_bytes ) { 52 | 53 | return crc_ccitt_generic( input_str, num_bytes, CRC_START_XMODEM ); 54 | 55 | } /* crc_xmodem */ 56 | 57 | /* 58 | * static uint16_t crc_ccitt_generic( const unsigned char *input_str, size_t num_bytes, uint16_t start_value ); 59 | * 60 | * The function crc_ccitt_generic() is a generic implementation of the CCITT 61 | * algorithm for a one-pass calculation of the CRC for a byte string. The 62 | * function accepts an initial start value for the crc. 63 | */ 64 | 65 | static uint16_t crc_ccitt_generic( const unsigned char *input_str, size_t num_bytes, uint16_t start_value ) { 66 | 67 | uint16_t crc; 68 | const unsigned char *ptr; 69 | size_t a; 70 | 71 | if ( ! crc_tabccitt_init ) init_crcccitt_tab(); 72 | 73 | crc = start_value; 74 | ptr = input_str; 75 | 76 | if ( ptr != NULL ) for (a=0; a> 8) ^ (uint16_t) *ptr++) & 0x00FF ]; 79 | } 80 | 81 | return crc; 82 | 83 | } /* crc_ccitt_generic */ 84 | 85 | /* 86 | * uint16_t update_crc_ccitt( uint16_t crc, unsigned char c ); 87 | * 88 | * The function update_crc_ccitt() calculates a new CRC-CCITT value based on 89 | * the previous value of the CRC and the next byte of the data to be checked. 90 | */ 91 | 92 | uint16_t update_crc_ccitt( uint16_t crc, unsigned char c ) { 93 | 94 | if ( ! crc_tabccitt_init ) init_crcccitt_tab(); 95 | 96 | return (crc << 8) ^ crc_tabccitt[ ((crc >> 8) ^ (uint16_t) c) & 0x00FF ]; 97 | 98 | } /* update_crc_ccitt */ 99 | 100 | /* 101 | * static void init_crcccitt_tab( void ); 102 | * 103 | * For optimal performance, the routine to calculate the CRC-CCITT uses a 104 | * lookup table with pre-compiled values that can be directly applied in the 105 | * XOR action. This table is created at the first call of the function by the 106 | * init_crcccitt_tab() routine. 107 | */ 108 | 109 | static void init_crcccitt_tab( void ) { 110 | 111 | uint16_t i; 112 | uint16_t j; 113 | uint16_t crc; 114 | uint16_t c; 115 | 116 | for (i=0; i<256; i++) { 117 | 118 | crc = 0; 119 | c = i << 8; 120 | 121 | for (j=0; j<8; j++) { 122 | 123 | if ( (crc ^ c) & 0x8000 ) crc = ( crc << 1 ) ^ CRC_POLY_CCITT; 124 | else crc = crc << 1; 125 | 126 | c = c << 1; 127 | } 128 | 129 | crc_tabccitt[i] = crc; 130 | } 131 | 132 | crc_tabccitt_init = true; 133 | 134 | } /* init_crcccitt_tab */ 135 | -------------------------------------------------------------------------------- /src/debug.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "mcu_proto.h" 4 | 5 | void print_port_info(PORT_INFO *info) { 6 | printf("PORT_INFO at %p:\n" 7 | " LAN1 = %hhu\n" 8 | " LAN2 = %hhu\n" 9 | " LAN3 = %hhu\n" 10 | " WAN = %hhu\n" 11 | " USB = %hhu\n", 12 | info, info->eth_port1_conn, info->eth_port2_conn, 13 | info->eth_port3_conn, info->eth_wan_conn, info->usb_conn); 14 | } 15 | 16 | void print_wan_info(WAN_INFO *info) { 17 | printf("WAN_INFO at %p:\n" 18 | " Connnected = %u\n" 19 | " Upload = %u B/s\n" 20 | " Download = %u B/s\n", 21 | info, info->is_connected, info->tx_bytes_per_sec, 22 | info->rx_bytes_per_sec); 23 | } 24 | 25 | static void print_wifi_info_single(struct _wifi_radio_info *info) { 26 | printf(" Single WiFi Radio info at %p:\n" 27 | " SSID = %s\n" 28 | " PSK = %s\n" 29 | " Enabled = %hhu\n" 30 | " STA Count = %hhu\n", 31 | info, info->ssid, info->psk, info->enabled, info->sta_count); 32 | } 33 | 34 | void print_wifi_info(WIFI_INFO *info) { 35 | printf("WIFI_INFO at %p:\n" 36 | " Band mix = %d\n", 37 | info, info->band_mix); 38 | print_wifi_info_single(&info->wl_24g_info); 39 | print_wifi_info_single(&info->wl_5g_info); 40 | print_wifi_info_single(&info->wl_visitor_info); 41 | } 42 | 43 | void print_basic_info(BASIC_INFO *info) { 44 | printf("BASIC_INFO at %p:\n" 45 | " Product Name = %s\n" 46 | " HW Version = %s\n" 47 | " FW Version = %s\n" 48 | " MAC Address = %s\n", 49 | info, info->product_name, info->hw_version, info->fw_version, 50 | info->mac_addr_base); 51 | } 52 | 53 | void print_host_info(struct _host_info_single *info, int len) { 54 | for (int i = 0; i < len; i++) { 55 | printf("Single host info at %p:\n" 56 | " Upload = %d B/s\n" 57 | " Download = %d B/s\n" 58 | " Name = %s\n" 59 | " Logo Index = %d\n", 60 | &info[i], info[i].upload_Bps, info[i].download_Bps, 61 | info[i].hostname, info[i].logo); 62 | } 63 | } 64 | 65 | static void print_buf(const unsigned char *buf, int len) { 66 | printf("RCVD %d bytes\n", len); 67 | 68 | for (int i = 0; i < len; i++) { 69 | printf("0x%hhx ", buf[i]); 70 | } 71 | printf("\n"); 72 | } -------------------------------------------------------------------------------- /src/debug.h: -------------------------------------------------------------------------------- 1 | #ifndef _DEBUG_H 2 | #define _DEBUG_H 3 | 4 | #include "mcu_proto.h" 5 | 6 | void print_port_info(PORT_INFO *info); 7 | void print_wan_info(WAN_INFO *info); 8 | void print_wifi_info(WIFI_INFO *info); 9 | void print_basic_info(BASIC_INFO *info); 10 | void print_host_info(struct _host_info_single *info, int len); 11 | 12 | #endif -------------------------------------------------------------------------------- /src/file_util.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include "common.h" 9 | 10 | int write_file_int(const char *file, int number) { 11 | int fd = open(file, O_WRONLY); 12 | if (fd == -1) { 13 | syslog(LOG_ERR, "Could not open %s: %s\n", file, strerror(errno)); 14 | return FAILURE; 15 | } 16 | 17 | if (dprintf(fd, "%d\n", number) < 0) { 18 | syslog(LOG_ERR, "Could not write to %d to %s: %s\n", number, file, 19 | strerror(errno)); 20 | return FAILURE; 21 | } 22 | return SUCCESS; 23 | } 24 | 25 | int write_file_str(const char *file, const char *str) { 26 | int fd = open(file, O_WRONLY); 27 | if (fd == -1) { 28 | syslog(LOG_ERR, "Could not open %s: %s\n", file, strerror(errno)); 29 | return FAILURE; 30 | } 31 | 32 | if (dprintf(fd, "%s\n", str) < 0) { 33 | syslog(LOG_ERR, "Could not write to %s to %s: %s\n", str, file, 34 | strerror(errno)); 35 | return FAILURE; 36 | } 37 | return SUCCESS; 38 | } 39 | 40 | int path_exists(const char *path) { 41 | struct stat statbuf; 42 | 43 | if (stat(path, &statbuf) < 0) { 44 | return FAILURE; 45 | } 46 | 47 | return SUCCESS; 48 | } 49 | -------------------------------------------------------------------------------- /src/file_util.h: -------------------------------------------------------------------------------- 1 | #ifndef _FILE_UTIL_H 2 | #define _FILE_UTIL_H 3 | 4 | /* 5 | * Write an integer to a file 6 | */ 7 | int write_file_int(const char *file, int number); 8 | 9 | /* 10 | * Write a string to a file 11 | */ 12 | int write_file_str(const char *file, const char *str); 13 | 14 | /* 15 | * Return if the path exists (file / dir) 16 | */ 17 | int path_exists(const char *path); 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /src/frame.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "checksum.h" 10 | #include "common.h" 11 | #include "mcu_proto.h" 12 | #include "serial_port.h" 13 | 14 | void (*g_frame_received_callback)(const unsigned char *frame, int len); 15 | 16 | int frame_send(const unsigned char *data, int len) { 17 | /* Allocate max possible space (escape every byte, with header/trailer) */ 18 | unsigned char *buf = (unsigned char *)malloc(len * 2 + 4); 19 | if (buf <= 0) { 20 | syslog(LOG_ERR, "unable to allocate memory for TX buffer: %s", 21 | strerror(errno)); 22 | return FAILURE; 23 | } 24 | bzero(buf, len * 2 + 4); 25 | 26 | /* Stage 1. Add header */ 27 | int buf_pos = 0; 28 | buf[buf_pos++] = FRAME_HEADER; /* Header */ 29 | 30 | /* Stage 2. Copy data, escaping FRAME_HEADER/TRAILER/ESCAPE */ 31 | #define ESCAPE_AND_APPEND_BYTE(byte) \ 32 | do { \ 33 | if ((byte) == FRAME_HEADER || (byte) == FRAME_TRAILER || \ 34 | (byte) == FRAME_ESCAPE) { \ 35 | buf[buf_pos++] = FRAME_ESCAPE; \ 36 | } \ 37 | buf[buf_pos++] = (byte); \ 38 | } while (0); 39 | 40 | for (int data_pos = 0; data_pos < len; data_pos++) { 41 | ESCAPE_AND_APPEND_BYTE(data[data_pos]); 42 | } 43 | 44 | /* Stage 3. Checksum with the same escaping procedure */ 45 | unsigned short checksum = crc_xmodem(data, len); 46 | ESCAPE_AND_APPEND_BYTE(checksum & 0xff); 47 | ESCAPE_AND_APPEND_BYTE((checksum & 0xff00) >> 8); 48 | 49 | /* Stage 4. Add trailer */ 50 | buf[buf_pos++] = FRAME_TRAILER; 51 | 52 | int ret = serial_write(buf, buf_pos); 53 | free(buf); 54 | return ret; 55 | } 56 | 57 | void frame_set_received_callback(void (*func)(const unsigned char *, int)) { 58 | g_frame_received_callback = func; 59 | } 60 | 61 | static void frame_notify_received(const unsigned char *frame_buf, int len) { 62 | unsigned char frame[2048]; 63 | unsigned char frame_pos = 0; 64 | 65 | /* Unescape */ 66 | int is_escaped = 0; 67 | int is_in_frame = 0; 68 | for (int input_pos = 0; input_pos < len; input_pos++) { 69 | if (is_escaped) { 70 | if (is_in_frame) { 71 | frame[frame_pos++] = frame_buf[input_pos]; 72 | } 73 | is_escaped = 0; 74 | continue; 75 | } 76 | 77 | switch (frame_buf[input_pos]) { 78 | case FRAME_ESCAPE: 79 | is_escaped = 1; 80 | break; 81 | case FRAME_HEADER: 82 | is_in_frame = 1; 83 | break; 84 | case FRAME_TRAILER: 85 | is_in_frame = 0; /* Loop should end after this */ 86 | break; 87 | default: 88 | if (is_in_frame) { 89 | frame[frame_pos++] = frame_buf[input_pos]; 90 | } 91 | } 92 | } 93 | 94 | /* frame[] should contain clean data with checksum but without header and 95 | * trailer */ 96 | unsigned short my_cksum = crc_xmodem(frame, frame_pos - 2); 97 | unsigned short msg_cksum = 98 | *(unsigned short *)(frame + frame_pos - 2); // Same, little endian 99 | if (my_cksum == msg_cksum) { 100 | if (g_frame_received_callback) { 101 | g_frame_received_callback(frame, frame_pos - 2); 102 | } 103 | } else { 104 | syslog(LOG_WARNING, "Checksum error! Got %04hx but expected %04hx\n", 105 | msg_cksum, my_cksum); 106 | } 107 | } 108 | 109 | void frame_notify_serial_recv() { 110 | static unsigned char g_serial_recv_buf[2048]; 111 | static int g_recv_buf_pos = 0; 112 | 113 | /* Read into this buffer */ 114 | int recv_len = serial_read(g_serial_recv_buf + g_recv_buf_pos, 115 | sizeof(g_serial_recv_buf) - g_recv_buf_pos); 116 | g_recv_buf_pos += recv_len; 117 | 118 | /* Search for end mark and notify if the frame has ended */ 119 | unsigned char *search_pos = g_serial_recv_buf; 120 | unsigned char *last_trailer; 121 | int remaining_search_range = g_recv_buf_pos; 122 | 123 | /* Search for FRAME_TRAILER within received data */ 124 | while (remaining_search_range > 0 && 125 | (last_trailer = memchr(search_pos, FRAME_TRAILER, 126 | remaining_search_range)) != NULL) { 127 | if (*(last_trailer - 1) != FRAME_ESCAPE) { 128 | /* Not escaped. This is the end of the frame */ 129 | frame_notify_received(g_serial_recv_buf, 130 | last_trailer - g_serial_recv_buf + 1); 131 | g_recv_buf_pos = 0; 132 | break; /* Do not support continous frames */ 133 | } else { 134 | /* Escaped. Continue search from this place */ 135 | search_pos = last_trailer + 1; 136 | remaining_search_range = 137 | g_recv_buf_pos - (search_pos - g_serial_recv_buf); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /src/frame.h: -------------------------------------------------------------------------------- 1 | #ifndef _FRAME_TX_H 2 | #define _FRAME_TX_H 3 | 4 | /* 5 | * Send payload to serial port. 6 | * Only raw data (PAYLOAD_*) needs to be given, header & 7 | * trailer & escaping will be added automatically. 8 | */ 9 | int frame_send(const unsigned char* data, int len); 10 | 11 | /* 12 | * Callback when a complete frame is received. 13 | * 14 | * The prototype is: 15 | * void callback(const unsigned char* frame, int len); 16 | * 17 | * The `frame` does not contain FRAME_* (unescaped & stripped). 18 | */ 19 | void frame_set_received_callback(void (*func)(const unsigned char*, int)); 20 | 21 | /* 22 | * Should be set in serial_set_pollin_callback() 23 | */ 24 | void frame_notify_serial_recv(); 25 | #endif 26 | -------------------------------------------------------------------------------- /src/gpio.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "common.h" 5 | #include "file_util.h" 6 | #include "gpio.h" 7 | 8 | int gpio_export(int gpio) { 9 | char path_buf[50]; 10 | 11 | sprintf(path_buf, "/sys/class/gpio/gpio%d", gpio); 12 | 13 | return path_exists(path_buf) == SUCCESS || 14 | write_file_int("/sys/class/gpio/export", gpio); 15 | } 16 | 17 | int gpio_unexport(int gpio) { 18 | char path_buf[50]; 19 | 20 | sprintf(path_buf, "/sys/class/gpio/gpio%d", gpio); 21 | 22 | return path_exists(path_buf) == FAILURE || 23 | write_file_int("/sys/class/gpio/unexport", gpio); 24 | } 25 | 26 | int gpio_set_direction(int gpio, GPIO_DIRECTION dir) { 27 | char path_buf[50]; 28 | char *dir_str; 29 | 30 | sprintf(path_buf, "/sys/class/gpio/gpio%d/direction", gpio); 31 | 32 | switch (dir) { 33 | case GPIO_IN: 34 | dir_str = "in"; 35 | break; 36 | case GPIO_OUT: 37 | dir_str = "out"; 38 | break; 39 | } 40 | 41 | return write_file_str(path_buf, dir_str); 42 | } 43 | 44 | int gpio_set_value(int gpio, int value) { 45 | char path_buf[50]; 46 | 47 | sprintf(path_buf, "/sys/class/gpio/gpio%d/value", gpio); 48 | 49 | return write_file_int(path_buf, value); 50 | } 51 | -------------------------------------------------------------------------------- /src/gpio.h: -------------------------------------------------------------------------------- 1 | #ifndef _GPIO_H 2 | #define _GPIO_H 3 | 4 | typedef enum _gpio_dir { GPIO_IN, GPIO_OUT } GPIO_DIRECTION; 5 | 6 | int gpio_export(int gpio); 7 | int gpio_unexport(int gpio); 8 | int gpio_set_direction(int gpio, GPIO_DIRECTION dir); 9 | int gpio_set_value(int gpio, int value); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/handlers.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "handlers.h" 6 | #include "mcu_proto.h" 7 | #include "pages.h" 8 | #include "requests.h" 9 | #include "signals.h" 10 | 11 | static MCU_VERSION g_mcu_version; 12 | void handle_mcu_version(const unsigned char *payload, int len) { 13 | if (len < 4) { 14 | syslog(LOG_WARNING, 15 | "Got malformed MCU version response. Length is %d\n", len); 16 | return; 17 | } 18 | g_mcu_version.patch_ver = 19 | payload[0] | 20 | payload[1] << 8; /* Do we need this endian compatabitity? */ 21 | g_mcu_version.minor_ver = payload[2]; 22 | g_mcu_version.major_ver = payload[3]; 23 | 24 | syslog(LOG_INFO, "MCU reported version as %hhd.%hhd.%hd\n", 25 | g_mcu_version.major_ver, g_mcu_version.minor_ver, 26 | g_mcu_version.patch_ver); 27 | } 28 | 29 | int g_is_screen_on = 1; 30 | void handle_key_press(const unsigned char *payload, int len) { 31 | if (len < 1) { 32 | syslog(LOG_WARNING, "Got malformed key press response. Length is %d\n", 33 | len); 34 | return; 35 | } 36 | refresh_screen_timeout(); 37 | if (!g_is_screen_on) { 38 | /* Do not process key messages when waking up */ 39 | request_notify_event(EVENT_WAKEUP); 40 | g_is_screen_on = 1; 41 | return; 42 | } 43 | switch (payload[0]) { 44 | case KEY_LEFT_SHORT: 45 | page_switch_prev(); 46 | printf("KEY_LEFT_SHORT\n"); 47 | break; 48 | case KEY_RIGHT_SHORT: 49 | page_switch_next(); 50 | printf("KEY_RIGHT_SHORT\n"); 51 | break; 52 | case KEY_MIDDLE_SHORT: 53 | page_switch_to(PAGE_WAN); 54 | printf("KEY_MIDDLE_SHORT\n"); 55 | break; 56 | case KEY_MIDDLE_LONG: 57 | request_notify_event(EVENT_SLEEP); 58 | g_is_screen_on = 0; 59 | return; 60 | case KEY_LEFT_LONG: 61 | case KEY_RIGHT_LONG: 62 | printf("KEY_x_LONG\n"); 63 | return; 64 | default: 65 | syslog(LOG_WARNING, "unknown key code: %hhx\n", payload[0]); 66 | return; 67 | } 68 | } 69 | 70 | RESPONSE_HANDLER g_response_handlers[] = { 71 | {RESPONSE_MCU_VERSION, handle_mcu_version}, 72 | {RESPONSE_KEY_PRESS, handle_key_press}, 73 | }; 74 | -------------------------------------------------------------------------------- /src/handlers.h: -------------------------------------------------------------------------------- 1 | #ifndef _HANDLERS_H 2 | #define _HANDLERS_H 3 | 4 | #include "mcu_proto.h" 5 | 6 | typedef struct _response_handler { 7 | RESPONSE_TYPE type; 8 | void (*handler)(const unsigned char *payload, int len); 9 | } RESPONSE_HANDLER; 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /src/infocenter.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "common.h" 7 | #include "config.h" 8 | #include "debug.h" 9 | #include "mcu_proto.h" 10 | #include "scripts.h" 11 | 12 | enum _token_type { 13 | TOKEN_STRING_NEW, /* Duplicate a new string and write its pointer to 14 | *storage */ 15 | TOKEN_STRING_OVERWRITE, /* Write the result directly to *storage, taking 16 | storage_len into consideration */ 17 | TOKEN_UINT, /* Write the result to *storage */ 18 | TOKEN_BYTE, /* Write the result to *storage */ 19 | }; 20 | 21 | struct _token_store { 22 | union { 23 | char **str_new_storage; 24 | char *str_overwrite_storage; 25 | unsigned int *uint_storage; 26 | unsigned char *byte_storage; 27 | }; 28 | enum _token_type type; 29 | int storage_len; 30 | }; 31 | 32 | /* Use the value rather than its address for x */ 33 | #define TOKEN_STRING_OVERWRITE_STORE(x) \ 34 | { \ 35 | .str_overwrite_storage = (x), .type = TOKEN_STRING_OVERWRITE, \ 36 | .storage_len = sizeof((x)), \ 37 | } 38 | #define TOKEN_STRING_NEW_STORE(x) \ 39 | { \ 40 | .str_new_storage = &(x), .type = TOKEN_STRING_NEW, \ 41 | .storage_len = sizeof((x)), \ 42 | } 43 | #define TOKEN_UINT_STORE(x) \ 44 | { .uint_storage = &(x), .type = TOKEN_UINT, .storage_len = sizeof((x)), } 45 | #define TOKEN_BYTE_STORE(x) \ 46 | { .byte_storage = &(x), .type = TOKEN_BYTE, .storage_len = sizeof((x)), } 47 | 48 | /* Will free(token) if needed */ 49 | static void token_store(const struct _token_store *store_info, char *token) { 50 | switch (store_info->type) { 51 | case TOKEN_STRING_NEW: 52 | *store_info->str_new_storage = token; 53 | break; 54 | case TOKEN_STRING_OVERWRITE: 55 | strncpy(store_info->str_overwrite_storage, token, 56 | store_info->storage_len - 1); 57 | store_info->str_overwrite_storage[store_info->storage_len - 1] = 0; 58 | free(token); 59 | break; 60 | case TOKEN_UINT: 61 | *store_info->uint_storage = atoi(token); 62 | free(token); 63 | break; 64 | case TOKEN_BYTE: 65 | *store_info->byte_storage = atoi(token); 66 | free(token); 67 | break; 68 | } 69 | } 70 | 71 | /* Returns pointer to where it left */ 72 | static const char *tokenize_and_store(const char *str, const char delim, 73 | const struct _token_store *stores, 74 | int store_len) { 75 | const char *last_start = str; 76 | const char *next_token; 77 | int token_pos = 0; 78 | 79 | while (token_pos < store_len && (next_token = strchr(last_start, delim))) { 80 | char *curr_token = strndup(last_start, next_token - last_start); 81 | token_store(&stores[token_pos], curr_token); 82 | last_start = next_token + 1; 83 | token_pos++; 84 | } 85 | 86 | if (token_pos < store_len && *last_start != 0) { 87 | /* We want more tokens, and there is the case where we might 88 | * miss a token: 89 | * The input is not delimiter-terminated, the last token was not 90 | * processed. */ 91 | char *curr_token = strdup(last_start); 92 | last_start += strlen(curr_token); 93 | token_store(&stores[token_pos], curr_token); 94 | token_pos++; 95 | } 96 | 97 | if (token_pos < store_len) { 98 | /* Still want more tokens */ 99 | syslog(LOG_WARNING, "tokenizer: found %d tokens but expected %d (%s)\n", 100 | token_pos, store_len, str); 101 | } 102 | return last_start; 103 | } 104 | 105 | static int update_storage_from_script(const char *script, 106 | const struct _token_store stores[], 107 | int store_len) { 108 | const char *out = script_get_output(script); 109 | if (out == NULL) { 110 | return FAILURE; 111 | } 112 | 113 | /* If the tokenizer stopped at \0, the entire output should have been 114 | * procesed successfully. 115 | * If it did not (there is something left in the output), the output may 116 | * be malformatted and the results are not reliable. 117 | */ 118 | const char *stopped_at = tokenize_and_store(out, '\n', stores, store_len); 119 | free((void *)out); 120 | 121 | return *stopped_at == 0 ? SUCCESS : FAILURE; 122 | } 123 | 124 | BASIC_INFO g_basic_info; 125 | static int update_basic_info() { 126 | static const struct _token_store stores[] = { 127 | TOKEN_STRING_OVERWRITE_STORE(g_basic_info.product_name), 128 | TOKEN_STRING_OVERWRITE_STORE(g_basic_info.hw_version), 129 | TOKEN_STRING_OVERWRITE_STORE(g_basic_info.fw_version), 130 | TOKEN_STRING_OVERWRITE_STORE(g_basic_info.mac_addr_base), 131 | }; 132 | return update_storage_from_script(CFG->basic_info_script, stores, 133 | sizeof(stores) / sizeof(stores[0])); 134 | } 135 | 136 | PORT_INFO g_port_info; 137 | static int update_port_info() { 138 | static const struct _token_store stores[] = { 139 | TOKEN_BYTE_STORE(g_port_info.eth_port1_conn), 140 | TOKEN_BYTE_STORE(g_port_info.eth_port2_conn), 141 | TOKEN_BYTE_STORE(g_port_info.eth_port3_conn), 142 | TOKEN_BYTE_STORE(g_port_info.eth_wan_conn), 143 | TOKEN_BYTE_STORE(g_port_info.usb_conn), 144 | }; 145 | return update_storage_from_script(CFG->port_script, stores, 146 | sizeof(stores) / sizeof(stores[0])); 147 | } 148 | 149 | WAN_INFO g_wan_info; 150 | static int update_wan_info() { 151 | static const struct _token_store stores[] = { 152 | TOKEN_UINT_STORE(g_wan_info.is_connected), 153 | TOKEN_UINT_STORE(g_wan_info.tx_bytes_per_sec), 154 | TOKEN_UINT_STORE(g_wan_info.rx_bytes_per_sec), 155 | }; 156 | return update_storage_from_script(CFG->wan_script, stores, 157 | sizeof(stores) / sizeof(stores[0])); 158 | } 159 | 160 | WIFI_INFO g_wifi_info; 161 | static int update_wifi_info() { 162 | static const struct _token_store stores[] = { 163 | TOKEN_UINT_STORE(g_wifi_info.band_mix), 164 | 165 | TOKEN_STRING_OVERWRITE_STORE(g_wifi_info.wl_24g_info.ssid), 166 | TOKEN_STRING_OVERWRITE_STORE(g_wifi_info.wl_24g_info.psk), 167 | TOKEN_BYTE_STORE(g_wifi_info.wl_24g_info.enabled), 168 | TOKEN_BYTE_STORE(g_wifi_info.wl_24g_info.sta_count), 169 | 170 | TOKEN_STRING_OVERWRITE_STORE(g_wifi_info.wl_5g_info.ssid), 171 | TOKEN_STRING_OVERWRITE_STORE(g_wifi_info.wl_5g_info.psk), 172 | TOKEN_BYTE_STORE(g_wifi_info.wl_5g_info.enabled), 173 | TOKEN_BYTE_STORE(g_wifi_info.wl_5g_info.sta_count), 174 | 175 | TOKEN_STRING_OVERWRITE_STORE(g_wifi_info.wl_visitor_info.ssid), 176 | TOKEN_STRING_OVERWRITE_STORE(g_wifi_info.wl_visitor_info.psk), 177 | TOKEN_BYTE_STORE(g_wifi_info.wl_visitor_info.enabled), 178 | TOKEN_BYTE_STORE(g_wifi_info.wl_visitor_info.sta_count), 179 | }; 180 | return update_storage_from_script(CFG->wifi_script, stores, 181 | sizeof(stores) / sizeof(stores[0])); 182 | } 183 | 184 | struct _host_info_single *g_host_info_array; 185 | unsigned int g_host_info_elements; 186 | static int update_host_info() { 187 | int ret = FAILURE; 188 | char *out = script_get_output(CFG->host_script); 189 | const char *curr_pos = out; 190 | if (out == NULL) { 191 | goto final_exit; 192 | } 193 | 194 | static const struct _token_store number_token[] = { 195 | TOKEN_UINT_STORE(g_host_info_elements), 196 | }; 197 | curr_pos = tokenize_and_store(out, '\n', number_token, 1); 198 | 199 | /* If there is no hosts, we won't bother to consider what's next */ 200 | if (g_host_info_elements == 0) { 201 | ret = SUCCESS; 202 | goto free_exit; 203 | } 204 | 205 | if (g_host_info_array != NULL) { 206 | free(g_host_info_array); 207 | } 208 | 209 | g_host_info_array = (struct _host_info_single *)malloc( 210 | g_host_info_elements * sizeof(struct _host_info_single)); 211 | if (g_host_info_array == NULL) { 212 | syslog(LOG_ERR, "could not allocate memory for host info: %s\n", 213 | strerror(errno)); 214 | goto free_exit; 215 | } 216 | 217 | /* The storage pointer is just placeholders. We will change later */ 218 | struct _token_store host_info_tokens[] = { 219 | TOKEN_STRING_OVERWRITE_STORE(g_host_info_array[0].hostname), 220 | TOKEN_UINT_STORE(g_host_info_array[0].download_Bps), 221 | TOKEN_UINT_STORE(g_host_info_array[0].upload_Bps), 222 | TOKEN_UINT_STORE(g_host_info_array[0].logo), 223 | }; 224 | for (unsigned int i = 0; i < g_host_info_elements; i++) { 225 | host_info_tokens[0].str_overwrite_storage = 226 | g_host_info_array[i].hostname; 227 | host_info_tokens[1].uint_storage = &g_host_info_array[i].download_Bps; 228 | host_info_tokens[2].uint_storage = &g_host_info_array[i].upload_Bps; 229 | host_info_tokens[3].uint_storage = &g_host_info_array[i].logo; 230 | 231 | curr_pos = tokenize_and_store(curr_pos, '\n', host_info_tokens, 232 | sizeof(host_info_tokens) / 233 | sizeof(host_info_tokens[0])); 234 | 235 | if (*curr_pos == 0) { 236 | syslog(LOG_ERR, "output from host info script was incomplete. " 237 | "Informed with %d hosts but only read %d hosts." 238 | "Showing read hosts only\n", 239 | g_host_info_elements, i); 240 | g_host_info_elements = i; 241 | goto free_exit; 242 | } 243 | } 244 | 245 | ret = SUCCESS; 246 | free_exit: 247 | free(out); 248 | final_exit: 249 | return ret; 250 | } 251 | 252 | int update_page_info(PAGE page) { 253 | int (*updater)() = NULL; 254 | 255 | switch (page) { 256 | case PAGE_BASIC_INFO: 257 | updater = update_basic_info; 258 | break; 259 | case PAGE_PORTS: 260 | updater = update_port_info; 261 | break; 262 | case PAGE_WAN: 263 | updater = update_wan_info; 264 | break; 265 | case PAGE_WIFI: 266 | updater = update_wifi_info; 267 | break; 268 | case PAGE_HOSTS: 269 | updater = update_host_info; 270 | break; 271 | } 272 | 273 | if (updater != NULL) { 274 | return updater(); 275 | } else { 276 | return FAILURE; 277 | } 278 | } 279 | 280 | int update_all_info() { 281 | int ret = 0; 282 | ret |= update_basic_info(); 283 | ret |= update_port_info(); 284 | ret |= update_wan_info(); 285 | ret |= update_wifi_info(); 286 | ret |= update_host_info(); 287 | return ret; 288 | } 289 | 290 | void print_all_info() { 291 | print_basic_info(&g_basic_info); 292 | print_wifi_info(&g_wifi_info); 293 | print_wan_info(&g_wan_info); 294 | print_port_info(&g_port_info); 295 | print_host_info(g_host_info_array, g_host_info_elements); 296 | } -------------------------------------------------------------------------------- /src/infocenter.h: -------------------------------------------------------------------------------- 1 | #ifndef _INFOCENTER_H 2 | #define _INFOCENTER_H 3 | 4 | #include "mcu_proto.h" 5 | 6 | int update_page_info(PAGE page); 7 | int update_all_info(); 8 | int print_all_info(); 9 | 10 | extern BASIC_INFO g_basic_info; 11 | extern PORT_INFO g_port_info; 12 | extern WAN_INFO g_wan_info; 13 | extern WIFI_INFO g_wifi_info; 14 | extern struct _host_info_single *g_host_info_array; 15 | extern unsigned int g_host_info_elements; 16 | 17 | #endif -------------------------------------------------------------------------------- /src/logging.c: -------------------------------------------------------------------------------- 1 | #include "logging.h" 2 | 3 | void syslog_setup(int print_stderr) { 4 | int log_options = LOG_CONS | LOG_PID; 5 | if (print_stderr) 6 | log_options |= LOG_PERROR; 7 | 8 | openlog(LOG_IDENT, log_options, LOG_USER); 9 | } 10 | 11 | void syslog_stop() { closelog(); } -------------------------------------------------------------------------------- /src/logging.h: -------------------------------------------------------------------------------- 1 | #ifndef _LOGGING_H 2 | #define _LOGGING_H 3 | 4 | #include 5 | 6 | #define LOG_IDENT "K3Screen" 7 | 8 | void syslog_setup(); 9 | void syslog_stop(); 10 | #endif 11 | -------------------------------------------------------------------------------- /src/main.c: -------------------------------------------------------------------------------- 1 | #include "common.h" 2 | #include "config.h" 3 | #include "frame.h" 4 | #include "gpio.h" 5 | #include "handlers.h" 6 | #include "infocenter.h" 7 | #include "logging.h" 8 | #include "mcu_proto.h" 9 | #include "mem_util.h" 10 | #include "pages.h" 11 | #include "requests.h" 12 | #include "serial_port.h" 13 | #include "signals.h" 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | #include 20 | #include 21 | 22 | /* 23 | * Detected on rising edge of RESET GPIO. 24 | * Low = Run app from ROM 25 | * High = Enter download mode and wait for a new app 26 | */ 27 | #define SCREEN_BOOT_MODE_GPIO 7 28 | 29 | /* 30 | * Resets the screen on rising edge 31 | */ 32 | #define SCREEN_RESET_GPIO 8 33 | 34 | #define SERIAL_PORT_PATH "/dev/ttyS1" 35 | 36 | static void frame_handler(const unsigned char *frame, int len) { 37 | if (frame[0] != PAYLOAD_HEADER) { 38 | syslog(LOG_WARNING, "frame with unknown type received: %hhx\n", 39 | frame[0]); 40 | return; 41 | } 42 | 43 | extern RESPONSE_HANDLER g_response_handlers[]; 44 | for (RESPONSE_HANDLER *handler = &g_response_handlers[0]; handler != NULL; 45 | handler++) { 46 | if (handler->type == frame[1]) { 47 | handler->handler(frame + 2, 48 | len - 2); /* Start from payload content */ 49 | return; 50 | } 51 | } 52 | 53 | syslog(LOG_WARNING, "frame with unknown response type received: %hhx\n", 54 | frame[1]); 55 | } 56 | 57 | static int screen_initialize(int skip_reset) { 58 | mask_memory_byte(0x1800c1c1, 0xf0, 0); /* Enable UART2 in DMU */ 59 | 60 | if (!skip_reset) { 61 | if (gpio_export(SCREEN_BOOT_MODE_GPIO) == FAILURE || 62 | gpio_export(SCREEN_RESET_GPIO) == FAILURE) { 63 | syslog(LOG_ERR, "Could not export GPIOs\n"); 64 | return FAILURE; 65 | } 66 | 67 | if (gpio_set_direction(SCREEN_BOOT_MODE_GPIO, GPIO_OUT) == FAILURE || 68 | gpio_set_direction(SCREEN_RESET_GPIO, GPIO_OUT) == FAILURE) { 69 | syslog(LOG_ERR, "Could not set GPIO direction\n"); 70 | return FAILURE; 71 | } 72 | 73 | if (gpio_set_value(SCREEN_BOOT_MODE_GPIO, 0) == FAILURE || 74 | gpio_set_value(SCREEN_RESET_GPIO, 0) == FAILURE || 75 | gpio_set_value(SCREEN_RESET_GPIO, 1) == FAILURE) { 76 | syslog(LOG_ERR, "Could not reset screen\n"); 77 | return FAILURE; 78 | } 79 | } 80 | 81 | return SUCCESS; 82 | } 83 | 84 | /* Parameters here are too ugly */ 85 | void pollin_loop(int serial_fd, int signal_fd) { 86 | struct pollfd fds[2]; 87 | fds[0].fd = serial_fd; 88 | fds[0].events = POLLIN; 89 | fds[1].fd = signal_fd; 90 | fds[1].events = POLLIN; 91 | 92 | while (1) { 93 | int readyfds = poll(fds, sizeof(fds) / sizeof(struct pollfd), 94 | SERIAL_POLL_INTERVAL_MS); 95 | if (readyfds < 0) { 96 | syslog(LOG_ERR, "poll() failed: %s", strerror(errno)); 97 | return; 98 | } else if (readyfds > 0) { 99 | if (fds[0].revents & POLLIN) { 100 | frame_notify_serial_recv(); 101 | } else if (fds[1].revents & POLLIN) { 102 | signal_notify(); 103 | } 104 | } 105 | } 106 | } 107 | 108 | void cleanup() { 109 | serial_close(); 110 | config_free(); 111 | syslog_stop(); 112 | } 113 | 114 | int main(int argc, char *argv[]) { 115 | int signal_fd; 116 | int serial_fd; 117 | 118 | atexit(cleanup); 119 | 120 | config_load_defaults(); 121 | config_parse_cmdline(argc, argv); 122 | 123 | syslog_setup(CFG->foreground); 124 | 125 | update_all_info(); 126 | 127 | if (CFG->test_mode) { 128 | print_all_info(); 129 | return 0; 130 | } 131 | 132 | if (screen_initialize(CFG->skip_reset) == FAILURE) { 133 | return -EIO; 134 | } 135 | 136 | if ((serial_fd = serial_setup("/dev/ttyS1")) < 0) { 137 | return -EIO; 138 | } 139 | 140 | if ((signal_fd = signal_setup()) < 0) { 141 | return -EIO; 142 | } 143 | 144 | frame_set_received_callback(frame_handler); 145 | request_mcu_version(); 146 | page_send_initial_data(); 147 | refresh_screen_timeout(); 148 | alarm(CFG->update_interval); 149 | pollin_loop(serial_fd, signal_fd); 150 | } 151 | -------------------------------------------------------------------------------- /src/mcu_proto.h: -------------------------------------------------------------------------------- 1 | #ifndef _MCU_PROTO_H 2 | #define _MCU_PROTO_H 3 | 4 | /* 5 | * Frame structure: 6 | * 7 | * FRAME_HEADER | PAYLOAD_HEADER | PAYLOAD_TYPE | PAYLOAD | FRAME_TRAILER 8 | * 9 | * PAYLOAD_TYPE can be one of the item in REQUEST_TYPE (Tx) or RESPONSE_TYPE 10 | (Rx) 11 | * 0x01, 0x04 and 0x10 in PAYLOAD_* needs to be escaped by FRAME_ESCAPE. 12 | * 13 | * Actually there are frames with 0x01 and 0x02 as PAYLOAD_HEADER. Maybe this 14 | kind of 15 | * frames is only used when communicating with bootloader. We do not need them 16 | here 17 | * since we are not upgrading the bootloader. 18 | */ 19 | 20 | #define FRAME_HEADER 0x01 21 | #define FRAME_TRAILER 0x04 22 | #define FRAME_ESCAPE 0x10 23 | #define PAYLOAD_HEADER 0x30 24 | 25 | typedef enum _request_type { 26 | REQUEST_GET_MCU_VERSION = 1, 27 | REQUEST_SWITCH_PAGE = 4, 28 | REQUEST_UPDATE_PORTS, 29 | REQUEST_UPDATE_WAN, 30 | REQUEST_UPDATE_WIFI, 31 | REQUEST_UPDATE_HOSTS_PAGED, 32 | REQUEST_UPDATE_BASIC_INFO, 33 | REQUEST_NOTIFY_EVENT 34 | } REQUEST_TYPE; 35 | 36 | /* REQUEST_NOTIFY_EVENT */ 37 | typedef enum _event { 38 | EVENT_WIFI_ON = 0, 39 | EVENT_WIFI_OFF, 40 | EVENT_24G_ON, 41 | EVENT_24G_OFF, 42 | EVENT_5G_ON, 43 | EVENT_5G_OFF, 44 | EVENT_WISP_ON, 45 | EVENT_WISP_OFF, 46 | EVENT_WAKEUP = 9, 47 | EVENT_SLEEP, 48 | EVENT_RESTORE_BACKUP, 49 | EVENT_UPGRADE, 50 | EVENT_REBOOT, 51 | EVENT_RESET, 52 | EVENT_WIFI_ON_2, /* Not known */ 53 | } EVENT; 54 | 55 | typedef enum _response_type { 56 | RESPONSE_MCU_VERSION = 1, 57 | RESPONSE_KEY_PRESS = 3 58 | } RESPONSE_TYPE; 59 | 60 | /* RESPONSE_MCU_VERSION */ 61 | typedef struct _mcu_version { 62 | unsigned short patch_ver; 63 | unsigned char minor_ver; 64 | unsigned char major_ver; 65 | } MCU_VERSION; 66 | 67 | /* RESPONSE_KEY_PRESS */ 68 | typedef enum _key_code { 69 | KEY_LEFT_SHORT = 1, 70 | KEY_LEFT_LONG = 3, 71 | KEY_RIGHT_SHORT = 4, 72 | KEY_RIGHT_LONG = 6, 73 | KEY_MIDDLE_SHORT = 7, 74 | KEY_MIDDLE_LONG = 9 75 | } KEY_CODE; 76 | 77 | /* REQUEST_SWITCH_PAGE */ 78 | typedef enum _page { 79 | PAGE_BASIC_INFO = 1, 80 | PAGE_PORTS, 81 | PAGE_WAN, 82 | PAGE_WIFI, 83 | PAGE_HOSTS 84 | } PAGE; 85 | 86 | #define PAGE_MIN PAGE_BASIC_INFO 87 | #define PAGE_MAX PAGE_HOSTS 88 | 89 | /* REQUEST_UPDATE_PORTS */ 90 | typedef struct _port_info { 91 | unsigned char eth_port1_conn; // Switch port 1 92 | unsigned char eth_port2_conn; // Switch port 0 93 | unsigned char eth_port3_conn; // Switch port 2 94 | unsigned char PAD1; 95 | unsigned char eth_wan_conn; // Switch port 3 96 | unsigned char usb_conn; 97 | unsigned char PAD2[2]; 98 | } PORT_INFO; 99 | 100 | /* REQUEST_UPDATE_WAN */ 101 | typedef struct _wan_info { 102 | unsigned int is_connected; 103 | unsigned int tx_bytes_per_sec; 104 | unsigned int rx_bytes_per_sec; 105 | } WAN_INFO; 106 | 107 | struct _wifi_radio_info { 108 | char ssid[64]; /* GBK */ 109 | char psk[64]; 110 | unsigned char enabled; 111 | unsigned char sta_count; 112 | unsigned char PAD[2]; 113 | }; 114 | 115 | /* REQUEST_UPDATE_WIFI */ 116 | typedef struct _wifi_info { 117 | unsigned int band_mix; /* This affects page 3 and page 4 */ 118 | struct _wifi_radio_info wl_24g_info; 119 | struct _wifi_radio_info wl_5g_info; 120 | struct _wifi_radio_info wl_visitor_info; 121 | } WIFI_INFO; 122 | 123 | /* REQUEST_UPDATE_HOSTS_PAGED */ 124 | struct _host_info_single { 125 | unsigned int upload_Bps; 126 | unsigned int download_Bps; 127 | char hostname[36]; 128 | unsigned int logo; 129 | }; 130 | 131 | #define HOSTS_PER_PAGE 5 132 | 133 | typedef struct _host_info { 134 | unsigned char total_hosts; 135 | unsigned char current_page_index; 136 | unsigned char PAD[2]; 137 | struct _host_info_single host_info[HOSTS_PER_PAGE]; 138 | } HOST_INFO; 139 | 140 | /* REQUEST_UPDATE_BASIC_INFO */ 141 | typedef struct _basic_info { 142 | char product_name[8]; 143 | char hw_version[8]; 144 | char fw_version[24]; 145 | char mac_addr_base[18]; 146 | } BASIC_INFO; 147 | 148 | #endif 149 | -------------------------------------------------------------------------------- /src/mem_util.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | #include "common.h" 10 | 11 | static int mask_begin_bit(int mask) { 12 | for (int i = 0; i < 8; i++) { 13 | if ((mask & (1 << i)) != 0) { 14 | return i; 15 | } 16 | } 17 | return 0; 18 | } 19 | 20 | int mask_memory_byte(off_t addr, int mask, int field_value) { 21 | int memfd = open("/dev/mem", O_RDWR); 22 | if (memfd < 0) { 23 | syslog(LOG_ERR, "Unable to access memory: %s", strerror(errno)); 24 | return FAILURE; 25 | } 26 | 27 | off_t page_size = sysconf(_SC_PAGESIZE); 28 | off_t map_start = addr & ~(page_size - 1); 29 | off_t data_offset = addr - map_start; 30 | 31 | void *map_addr = mmap(NULL, page_size, PROT_READ | PROT_WRITE, MAP_SHARED, 32 | memfd, map_start); 33 | if (map_addr == (void *)-1) { 34 | syslog(LOG_ERR, "Unable to mmap: %s", strerror(errno)); 35 | close(memfd); 36 | return FAILURE; 37 | } 38 | 39 | void *virt_addr = map_addr + data_offset; 40 | unsigned char current_byte = *((unsigned char *)virt_addr); 41 | unsigned char data = 42 | (current_byte & ~mask) | (field_value << mask_begin_bit(mask)); 43 | if (current_byte == data) { 44 | goto exit; 45 | } 46 | 47 | *((unsigned char *)virt_addr) = data; 48 | unsigned char read_result = *((unsigned char *)virt_addr); 49 | 50 | if (read_result != data) { 51 | syslog(LOG_INFO, "Written %zx with %hhx but read %hhx back\n", addr, 52 | data, read_result); 53 | } 54 | 55 | exit: 56 | munmap(map_addr, page_size); 57 | close(memfd); 58 | return SUCCESS; 59 | } 60 | -------------------------------------------------------------------------------- /src/mem_util.h: -------------------------------------------------------------------------------- 1 | #ifndef _MEMWRITE_H 2 | #define _MEMWRITE_H 3 | 4 | #include 5 | 6 | /* 7 | * Set the field specified by mask in the byte to given value. 8 | * E.g. mask_memory_byte(&mybyte, 0xf0, 0xf) will make mybyte[4:7] = 0xf. 9 | */ 10 | int mask_memory_byte(off_t addr, int mask, int field_value); 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /src/pages.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "common.h" 6 | #include "infocenter.h" 7 | #include "mcu_proto.h" 8 | #include "requests.h" 9 | 10 | static int g_host_page = 0; 11 | static PAGE g_current_page = PAGE_WAN; 12 | 13 | struct _host_info_single *get_hosts() { 14 | return g_host_info_array; 15 | } 16 | 17 | static int get_hosts_count() { return g_host_info_elements; } 18 | 19 | static void send_page_data(PAGE page) { 20 | switch (page) { 21 | case PAGE_BASIC_INFO: 22 | request_update_basic_info( 23 | g_basic_info.product_name, g_basic_info.hw_version, 24 | g_basic_info.fw_version, g_basic_info.mac_addr_base); 25 | break; 26 | case PAGE_PORTS: 27 | request_update_ports(&g_port_info); 28 | break; 29 | case PAGE_WAN: 30 | request_update_wan(g_wan_info.is_connected, g_wan_info.tx_bytes_per_sec, 31 | g_wan_info.rx_bytes_per_sec); 32 | break; 33 | case PAGE_WIFI: 34 | request_update_wifi(&g_wifi_info); 35 | break; 36 | case PAGE_HOSTS: 37 | request_update_hosts_paged(get_hosts(), get_hosts_count(), 38 | g_host_page * HOSTS_PER_PAGE); 39 | break; 40 | default: 41 | syslog(LOG_WARNING, "unknown page requested: %d\n", page); 42 | break; 43 | } 44 | } 45 | 46 | void page_send_initial_data() { 47 | send_page_data(PAGE_BASIC_INFO); 48 | send_page_data(PAGE_PORTS); 49 | send_page_data(PAGE_WAN); 50 | send_page_data(PAGE_WIFI); 51 | send_page_data(PAGE_HOSTS); 52 | request_switch_page(PAGE_WAN); 53 | } 54 | 55 | /* Collect info by running scripts */ 56 | void page_update() { 57 | switch (g_current_page) { 58 | case PAGE_WAN: 59 | update_page_info(PAGE_WAN); 60 | update_page_info(PAGE_WIFI); // Shows STA count on WAN page 61 | break; 62 | default: 63 | update_page_info(g_current_page); 64 | break; 65 | } 66 | } 67 | 68 | /* Sends collected info to screen but do not switch to the page */ 69 | void page_refresh() { 70 | switch (g_current_page) { 71 | case PAGE_WAN: 72 | send_page_data(PAGE_WAN); 73 | send_page_data(PAGE_WIFI); // Shows STA count on WAN page 74 | break; 75 | default: 76 | send_page_data(g_current_page); 77 | break; 78 | } 79 | } 80 | 81 | void page_switch_to(PAGE page) { 82 | if (page >= PAGE_MIN && page <= PAGE_MAX) { 83 | g_current_page = page; 84 | g_host_page = 0; 85 | page_refresh(); 86 | request_switch_page(g_current_page); 87 | } 88 | } 89 | 90 | void page_switch_next() { 91 | if (g_current_page != PAGE_HOSTS) { 92 | if (g_current_page < PAGE_MAX) { 93 | g_current_page++; 94 | page_refresh(); 95 | request_switch_page(g_current_page); 96 | } 97 | } else { 98 | /* In PAGE_HOSTS */ 99 | if (get_hosts_count() - (g_host_page + 1) * HOSTS_PER_PAGE > 0) { 100 | g_host_page++; 101 | page_refresh(); 102 | request_switch_page(g_current_page); 103 | } 104 | } 105 | } 106 | 107 | void page_switch_prev() { 108 | if (g_current_page != PAGE_HOSTS) { 109 | if (g_current_page > PAGE_MIN) { 110 | g_current_page--; 111 | page_refresh(); 112 | request_switch_page(g_current_page); 113 | } 114 | } else { 115 | /* In PAGE_HOSTS */ 116 | if (g_host_page > 0) { 117 | g_host_page--; 118 | } else { 119 | g_current_page--; 120 | } 121 | page_refresh(); 122 | request_switch_page(g_current_page); 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/pages.h: -------------------------------------------------------------------------------- 1 | #ifndef _ACTIONS_H 2 | #define _ACTIONS_H 3 | 4 | #include "mcu_proto.h" 5 | 6 | void page_send_initial_data(); 7 | void page_update(); 8 | void page_switch_next(); 9 | void page_switch_prev(); 10 | void page_switch_to(PAGE page); 11 | void page_refresh(); 12 | 13 | #endif 14 | -------------------------------------------------------------------------------- /src/requests.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | #include "common.h" 7 | #include "frame.h" 8 | #include "mcu_proto.h" 9 | #include "serial_port.h" 10 | 11 | static int request_send_raw(REQUEST_TYPE type, const void *data, int len) { 12 | unsigned char *cmdbuf = (unsigned char *)malloc(len + 2); 13 | if (cmdbuf < 0) { 14 | syslog(LOG_WARNING, 15 | "Could not allocate buffer for new request, drop it: %s\n", 16 | strerror(errno)); 17 | return FAILURE; 18 | } 19 | 20 | bzero(cmdbuf, len + 2); 21 | cmdbuf[0] = PAYLOAD_HEADER; 22 | cmdbuf[1] = type; 23 | memmove(cmdbuf + 2, data, len); 24 | 25 | int ret = frame_send(cmdbuf, len + 2); 26 | free(cmdbuf); 27 | return ret; 28 | } 29 | 30 | int request_mcu_version() { 31 | return request_send_raw(REQUEST_GET_MCU_VERSION, NULL, 0); 32 | } 33 | 34 | int request_switch_page(PAGE page) { 35 | return request_send_raw(REQUEST_SWITCH_PAGE, &page, 4); 36 | } 37 | 38 | int request_notify_event(EVENT event) { 39 | return request_send_raw(REQUEST_NOTIFY_EVENT, &event, 4); 40 | } 41 | 42 | int request_update_wan(int is_connected, int tx_Bps, int rx_Bps) { 43 | WAN_INFO waninfo; 44 | 45 | waninfo.is_connected = is_connected; 46 | waninfo.tx_bytes_per_sec = tx_Bps; 47 | waninfo.rx_bytes_per_sec = rx_Bps; 48 | 49 | return request_send_raw(REQUEST_UPDATE_WAN, &waninfo, sizeof(waninfo)); 50 | } 51 | 52 | int request_update_basic_info(const char *prod_name, const char *hw_ver, 53 | const char *fw_ver, const char *mac_addr) { 54 | BASIC_INFO basic_info; 55 | bzero(&basic_info, sizeof(basic_info)); 56 | 57 | #define ARRAY_SIZED_STRCPY(dst, src) strncpy((dst), (src), sizeof((dst))); 58 | ARRAY_SIZED_STRCPY(basic_info.product_name, prod_name); 59 | ARRAY_SIZED_STRCPY(basic_info.hw_version, hw_ver); 60 | ARRAY_SIZED_STRCPY(basic_info.fw_version, fw_ver); 61 | ARRAY_SIZED_STRCPY(basic_info.mac_addr_base, mac_addr); 62 | 63 | return request_send_raw(REQUEST_UPDATE_BASIC_INFO, &basic_info, 64 | sizeof(basic_info)); 65 | } 66 | 67 | /* Too many parameters. Fill the struct yourself */ 68 | int request_update_wifi(WIFI_INFO *wifi_info) { 69 | return request_send_raw(REQUEST_UPDATE_WIFI, wifi_info, sizeof(WIFI_INFO)); 70 | } 71 | 72 | int request_update_ports(PORT_INFO *port_info) { 73 | return request_send_raw(REQUEST_UPDATE_PORTS, port_info, sizeof(PORT_INFO)); 74 | } 75 | 76 | int request_update_hosts_paged(struct _host_info_single hosts[], int len, 77 | int start) { 78 | int ret = 0, copylen; 79 | HOST_INFO info; 80 | bzero(&info, sizeof(HOST_INFO)); 81 | 82 | copylen = len - start; 83 | copylen = copylen > HOSTS_PER_PAGE ? HOSTS_PER_PAGE : copylen; 84 | 85 | info.total_hosts = len; 86 | info.current_page_index = start / HOSTS_PER_PAGE; 87 | for (int i = 0; i < copylen; i++) { 88 | memmove(&info.host_info[i], &hosts[start + i], 89 | sizeof(struct _host_info_single)); 90 | } 91 | 92 | ret |= 93 | request_send_raw(REQUEST_UPDATE_HOSTS_PAGED, &info, sizeof(HOST_INFO)); 94 | return ret; 95 | } 96 | -------------------------------------------------------------------------------- /src/requests.h: -------------------------------------------------------------------------------- 1 | #ifndef _REQUESTS_H 2 | #define _REQUESTS_H 3 | 4 | #include "mcu_proto.h" 5 | 6 | int request_mcu_version(); 7 | int request_switch_page(PAGE page); 8 | int request_notify_event(EVENT event); 9 | int request_update_wan(int is_connected, int tx_bps, int rx_bps); 10 | int request_update_basic_info(const char *prod_name, const char *hw_ver, 11 | const char *fw_ver, const char *mac_addr); 12 | 13 | /** 14 | * Fill in the structures yourself. 15 | */ 16 | int request_update_wifi(WIFI_INFO *wifi_info); 17 | int request_update_ports(PORT_INFO *port_info); 18 | 19 | /** 20 | * This function sends `min(maxlen, HOSTS_PER_PAGE)` items in hosts[]. 21 | * You need to call this multiple times if you have more than 22 | * HOSTS_PER_PAGE hosts. 23 | * 24 | * len: number of elements in hosts[] 25 | * start: send elements beginning from this position in hosts[] 26 | * 27 | * The page number will be calculated on the basis of `start`. 28 | * 29 | * E.g. if you have 13 hosts, you need to call functions in this sequence: 30 | * 31 | * request_update_hosts_paged(hosts, 13, 0); 32 | * request_switch_page(5); 33 | * request_update_hosts_paged(hosts, 13, 5); 34 | * request_switch_page(5); 35 | * request_update_hosts_paged(hosts, 13, 10); 36 | * request_switch_page(5); 37 | */ 38 | int request_update_hosts_paged(struct _host_info_single hosts[], int len, 39 | int start); 40 | #endif 41 | -------------------------------------------------------------------------------- /src/scripts.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | 7 | #include "scripts.h" 8 | 9 | char *script_get_output(const char *script) { 10 | char *ret = NULL; 11 | FILE *fp = popen(script, "r"); 12 | if (fp == NULL) { 13 | syslog(LOG_ERR, "could not get output stream from \"%s\": %s\n", script, 14 | strerror(errno)); 15 | goto null_exit; 16 | } 17 | 18 | ret = (char *)malloc(SCRIPT_OUTPUT_BUFFER_SIZE); 19 | if (ret < 0) { 20 | syslog(LOG_ERR, "could not allocate memory for command output: %s\n", 21 | strerror(errno)); 22 | goto close_exit; 23 | } 24 | 25 | if (fread(ret, 1, SCRIPT_OUTPUT_BUFFER_SIZE, fp) == 0) { 26 | syslog(LOG_ERR, "could not read from stream: %s\n", strerror(errno)); 27 | free(ret); 28 | ret = NULL; 29 | } 30 | 31 | close_exit: 32 | pclose(fp); 33 | null_exit: 34 | return ret; 35 | } -------------------------------------------------------------------------------- /src/scripts.h: -------------------------------------------------------------------------------- 1 | #ifndef _SCRIPTS_H 2 | #define _SCRIPTS_H 3 | 4 | #define SCRIPT_OUTPUT_BUFFER_SIZE 65536 5 | 6 | char *script_get_output(const char *script); 7 | 8 | #endif -------------------------------------------------------------------------------- /src/serial_port.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "common.h" 11 | #include "logging.h" 12 | #include "serial_port.h" 13 | 14 | static int g_serial_fd = -1; 15 | 16 | int serial_setup(const char *dev_path) { 17 | struct termios serial_termios; 18 | 19 | g_serial_fd = open(dev_path, O_RDWR | O_NOCTTY | O_NONBLOCK); 20 | if (g_serial_fd == -1) { 21 | syslog(LOG_CRIT, "could not open %s\n", dev_path); 22 | return -1; 23 | } 24 | 25 | if (tcgetattr(g_serial_fd, &serial_termios)) { 26 | syslog(LOG_ERR, "could not get attrs from serial fd: %s\n", 27 | strerror(errno)); 28 | serial_close(); 29 | return -1; 30 | } 31 | 32 | /* 115200 */ 33 | cfsetspeed(&serial_termios, B115200); 34 | 35 | /* Noncanonical mode, no echo */ 36 | serial_termios.c_lflag &= ~(ISIG | ICANON | ECHO | ECHOE); 37 | 38 | /* No XON/XOFF flow control */ 39 | serial_termios.c_iflag &= ~(INPCK | INLCR | ICRNL | IXON | IXANY | IXOFF); 40 | 41 | /* 8-N-1 */ 42 | serial_termios.c_cflag &= ~(CSIZE | CSTOPB | PARENB); 43 | serial_termios.c_cflag |= CS8 | CREAD | CLOCAL; 44 | 45 | /* No output processing */ 46 | serial_termios.c_oflag &= ~(OPOST | ONLCR | OCRNL); 47 | 48 | /* Use select() to determine if there is data */ 49 | serial_termios.c_cc[VTIME] = 0; 50 | serial_termios.c_cc[VMIN] = 0; 51 | 52 | tcflush(g_serial_fd, TCIFLUSH); 53 | if (tcsetattr(g_serial_fd, TCSANOW, &serial_termios)) { 54 | syslog(LOG_ERR, "could not set attrs for serial fd: %s\n", 55 | strerror(errno)); 56 | serial_close(); 57 | return -1; 58 | } 59 | 60 | return g_serial_fd; 61 | } 62 | 63 | void serial_close() { close(g_serial_fd); } 64 | 65 | int serial_write(const unsigned char *data, int len) { 66 | return write(g_serial_fd, data, len); 67 | } 68 | 69 | int serial_read(unsigned char *buf, int maxlen) { 70 | return read(g_serial_fd, buf, maxlen); 71 | } 72 | -------------------------------------------------------------------------------- /src/serial_port.h: -------------------------------------------------------------------------------- 1 | #ifndef _SERIAL_PORT_H 2 | #define _SERIAL_PORT_H 3 | 4 | #define SERIAL_POLL_INTERVAL_MS 500 5 | 6 | /* 7 | * Setup serial port at given path 8 | * 9 | * Returns: serial fd, or -1 for failure 10 | */ 11 | int serial_setup(const char *dev_path); 12 | 13 | /* 14 | * Close the port 15 | */ 16 | void serial_close(); 17 | 18 | /* 19 | * Self-explanatory 20 | * 21 | * Returns: how many bytes are actually written / read 22 | */ 23 | int serial_write(const unsigned char *data, int len); 24 | int serial_read(unsigned char *buf, int maxlen); 25 | 26 | #endif 27 | -------------------------------------------------------------------------------- /src/signals.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "config.h" 11 | #include "mcu_proto.h" 12 | #include "pages.h" 13 | #include "requests.h" 14 | 15 | static int g_signal_fd; 16 | 17 | int signal_setup() { 18 | sigset_t mask; 19 | 20 | sigemptyset(&mask); 21 | sigaddset(&mask, SIGALRM); // Timed update 22 | sigaddset(&mask, SIGTERM); // Router reboot 23 | sigaddset(&mask, SIGUSR1); // Factory reset 24 | sigaddset(&mask, SIGUSR2); // Firmware update 25 | 26 | /* Block in order to prevent default disposition */ 27 | if (sigprocmask(SIG_BLOCK, &mask, NULL) == -1) { 28 | syslog(LOG_WARNING, "could not block signals: %s\n", strerror(errno)); 29 | } 30 | 31 | g_signal_fd = signalfd(-1, &mask, 0); 32 | if (g_signal_fd < 0) { 33 | syslog(LOG_WARNING, "could not set up signal fd: %s\n", 34 | strerror(errno)); 35 | } 36 | 37 | return g_signal_fd; 38 | } 39 | 40 | static time_t g_last_check_time; 41 | void refresh_screen_timeout() { g_last_check_time = time(NULL); } 42 | 43 | static void check_screen_timeout() { 44 | if (CFG->screen_timeout != 0 && 45 | time(NULL) - g_last_check_time >= CFG->screen_timeout) { 46 | extern int g_is_screen_on; 47 | g_is_screen_on = 0; /* Do not process key messages - just wake up if there are any */ 48 | request_notify_event(EVENT_SLEEP); 49 | } 50 | } 51 | 52 | void signal_notify() { 53 | struct signalfd_siginfo siginfo; 54 | if (read(g_signal_fd, &siginfo, sizeof(siginfo)) <= 0) { 55 | syslog(LOG_WARNING, 56 | "could not read from signalfd, signal ignored: %s\n", 57 | strerror(errno)); 58 | return; 59 | } 60 | 61 | switch (siginfo.ssi_signo) { 62 | case SIGALRM: 63 | page_update(); 64 | page_refresh(); 65 | check_screen_timeout(); 66 | alarm(CFG->update_interval); 67 | break; 68 | case SIGTERM: 69 | request_notify_event(EVENT_REBOOT); 70 | exit(0); 71 | break; 72 | case SIGUSR1: 73 | request_notify_event(EVENT_RESET); 74 | break; 75 | case SIGUSR2: 76 | request_notify_event(EVENT_UPGRADE); 77 | break; 78 | default: 79 | syslog(LOG_INFO, "someone forgot to add his signal (%d) handler here\n", 80 | siginfo.ssi_signo); 81 | break; 82 | } 83 | } -------------------------------------------------------------------------------- /src/signals.h: -------------------------------------------------------------------------------- 1 | #ifndef _SIGNALS_H 2 | #define _SIGNALS_H 3 | 4 | /** 5 | * Set up signalfd containing SIGTERM/USR1/USR2. 6 | * 7 | * Return the signalfd, or -1 for failure. 8 | */ 9 | int signal_setup(); 10 | 11 | /** 12 | * Notify there is a signal. 13 | */ 14 | void signal_notify(); 15 | 16 | /** 17 | * Notify there is user interaction (and turn off screen after timeout) 18 | * (like keypad backlight on phones) 19 | */ 20 | void refresh_screen_timeout(); 21 | #endif --------------------------------------------------------------------------------