├── .gitignore ├── COPYING ├── Makefile ├── README.md ├── README_it.md ├── debian ├── changelog ├── compat ├── control ├── copyright ├── docs ├── rules ├── source │ └── format └── watch ├── m_env.mnu ├── m_main.mnu ├── m_submenu.mnu ├── qmenu.1 ├── qmenu.c ├── qmenu.cfg ├── qmenu.frm ├── qmenu.gif └── qmenu.hlp /.gitignore: -------------------------------------------------------------------------------- 1 | qmenu.log 2 | qmenu 3 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This Makefile is part of qmenu, and is Copyright © 2014 Andrea Colangelo. 3 | # 4 | # This file is free software, and is released under the terms of the WTFPL, as 5 | # described here: http://www.wtfpl.net/txt/copying/ 6 | 7 | SHELL = /bin/bash 8 | 9 | RELEASE = 5.0.2 10 | 11 | CC = gcc 12 | CFLAGS = -g -Wall 13 | LIBS = -lncurses 14 | 15 | TARGET = qmenu 16 | 17 | PREFIX = /usr/local 18 | BINDIR= $(PREFIX)/bin 19 | DATAROOTDIR = $(PREFIX)/share 20 | EXAMPLESDIR = $(DATAROOTDIR)/doc/$(TARGET)/examples 21 | MANDIR = $(DATAROOTDIR)/man/man1 22 | 23 | build: 24 | $(CC) $(CFLAGS) -o $(TARGET) $(TARGET).c $(LIBS) 25 | 26 | install: 27 | install -d -m 0755 $(BINDIR) 28 | install -d -m 0755 $(DATADIR) 29 | install -d -m 0755 $(MANDIR) 30 | install -m 0755 $(TARGET) $(BINDIR)/ 31 | install -m 0644 *.mnu $(EXAMPLESDIR) 32 | install -m 0644 $(TARGET).1 $(MANDIR) 33 | 34 | clean: 35 | $(RM) $(TARGET) 36 | $(RM) -rf .release-tmp 37 | 38 | release: clean 39 | mkdir -p .release-tmp/$(TARGET)-$(RELEASE)/ 40 | cp -rv * .release-tmp/$(TARGET)-$(RELEASE) 41 | rm -rf .release-tmp/$(TARGET)-$(RELEASE)/debian 42 | rm -f .release-tmp/$(TARGET)-$(RELEASE)/qmenu.{cfg,frm,gif,hlp} 43 | rm -f .release-tmp/$(TARGET)-$(RELEASE)/README_it.md 44 | tar czf $(TARGET)-$(RELEASE).tar.gz -C .release-tmp $(TARGET)-$(RELEASE) 45 | rm -rf .release-tmp 46 | 47 | .PHONY: build install clean release 48 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Quick Menu - The terminal menu creator 2 | 3 | ![Demo](https://raw.githubusercontent.com/teopost/qmenu/master/qmenu.gif) 4 | 5 | # How install on Ubuntu and Debian 6 | Execute this command 7 | 8 | sudo apt-get install qmenu 9 | 10 | 11 | # How to compile on Ubuntu 12 | You shoud compile qmenu with gcc. 13 | On ubuntu you should install ncurses library 14 | 15 | sudo apt-get install libncurses5-dev libncursesw5-dev 16 | make 17 | sudo make install 18 | qmenu m_main.mnu 19 | 20 | # How to compile on Centos/Oracle 21 | 22 | yum install ncurses-devel 23 | make 24 | cp ./qmenu /usr/local/bin/ 25 | chmod 777 /usr/local/bin/qmenu 26 | 27 | # How it works 28 | qmenu allows to create menus for interfaces and characters in an easy and intuitive way. 29 | Each menu is defined in a file (with extenision .mnu) that contains the visual appearance and the definition of the items. 30 | The file is divided on three sections 31 | 32 | 1. Screen Area 33 | 2. Item Area 34 | 3. Option Area 35 | 36 | Each area is delimited by the characters $$ and %% 37 | 38 | Screen area 39 | $$ 40 | Item area 41 | %% 42 | Option area 43 | 44 | ## Screen area 45 | This area starts from the beginning of the file to the symbol $$, and contains the "drawing" of the menu in text format. 46 | Each menu option, to be recognized as selectable, must be enclosed between the symbol ^ 47 | 48 | Example: 49 | 50 | ^1. Option 1^ 51 | ^2. Option 2^ 52 | 53 | The options can be selected by using the arrow keys or by pressing the first character of the string. 54 | In this area you can also add some variables with the following syntax: 55 | 56 | x[NAME_VARIABILE] 57 | 58 | The name of the variable is composed by a prefix (x) and the name between square brackets. These are the available values: 59 | 60 | * c - Centered 61 | * l - Left-justified 62 | * r - Right-justified 63 | 64 | Note: If the symbol is put capitalize the value is shown in reverse 65 | 66 | Variables can take the following value: 67 | 68 | * TIME - Current time 69 | * MENUNAME - Name of the menu 70 | * INFOTERM - Nome of the terminal 71 | * MNUTRACE - Path menu 72 | 73 | Special variables: 74 | 75 | & - Cursor position 76 | ${PATH} - Displays the contents of the environment variable PATH 77 | 78 | Example: 79 | 80 | C[TITLE] - Menu title centered and in reverse 81 | 82 | ## Item area 83 | In this section, for each menu item, you define: 84 | 85 | * The action to perform 86 | * An help message 87 | * An empty row 88 | 89 | The format to use for each item is composed by 4 lines: 90 | 91 | 1. Menu option 92 | 2. Command to perform 93 | 3. Help message 94 | 95 | 96 | 1. In the first line, insert the first character of the string which contains the menu option 97 | 2. In the second line, is possible to specify: 98 | 99 | * A shell command 100 | * A submenu to open ($menuname without extension) 101 | * Reserved command (return to go to the previous menu, end to quit menu) 102 | 103 | 3. In the third line you specify the message. 104 | This message will be shown at the variable TITLE present in the "Screen area" 105 | 106 | Example: 107 | 108 | %1 109 | ls -lisa; read x 110 | This item show shell file list 111 | 112 | 113 | ## Option area 114 | This section contains a series of generic settings: 115 | 116 | TITOLO - Menu title 117 | RVS_ROW=0,22 - Lines displayed in reverse. In this case the line 0 and line 22 118 | NOKEYDISP - Disables the automatic visualization of the labels of the function keys (ET[1-10]) 119 | ET[1-10] - Text shown to function key n if NOKEYDISP commented 120 | FZ[1-10] - Command (shell) for the function key n 121 | PW[1-10] - Password to set for the function key n 122 | SHELL=sh - Pressing shift-f1 starts a shell session 123 | EDITOR=vi - Pressing shift-f2 starts vi with the current menu 124 | 125 | Each of these options can be commented out with # 126 | 127 | # Note 128 | Documentation in italian language is available here 129 | 130 | * [README_it](README_it.md) 131 | 132 | Thanks 133 | --- 134 | * First version named appsel created by [Giovanni Juan Oteri](https://twitter.com/giovannioteri) 135 | -------------------------------------------------------------------------------- /README_it.md: -------------------------------------------------------------------------------- 1 | # Installazione 2 | Semplicemente, da terminale: 3 | 4 | sudo apt-get install qmenu 5 | 6 | 7 | # Compilazione 8 | Per compilare qmenu occorre gcc 9 | Su ubuntu installare la libreria ncurses 10 | 11 | sudo apt-get install libncurses5-dev libncursesw5-dev 12 | make 13 | sudo make install 14 | qmenu m_main.mnu 15 | 16 | ![Demo](https://raw.githubusercontent.com/teopost/qmenu/master/qmenu.gif) 17 | 18 | # Come funziona 19 | qmenu permette di creare in maniera semplice e intuitiva menu per interfacce a caratteri. 20 | Ogni menu è definito in un file (con estensione .mnu) che contiene sia l'aspetto visuale che la definizione delle varie voci. 21 | 22 | Il file è suddiviso in 3 sezioni: 23 | 24 | 1. Screen Area 25 | 2. Item Area 26 | 3. Option Area 27 | 28 | Ogni area è delimitata dai caratteri $$ e %% 29 | 30 | Screen area 31 | $$ 32 | Item area 33 | %% 34 | Option area 35 | 36 | ## Screen area 37 | Questa area va da inizio file fino al simbolo $$, e contiene il "disegno" vero e proprio del menu in formato testuale. 38 | Ogni opzione di menu, per essere riconosciuta come selezionabile deve essere racchiuso fra il simbolo ^ 39 | 40 | Esempio: 41 | 42 | ^1. Option 1^ 43 | ^2. Option 2^ 44 | 45 | Le opzioni si possono selezionare con la freccia della tastiera ma anche premendo la prima lettera della stringa 46 | 47 | All'interno di questa area si possono anche aggiungere alcune variabili con la sintassi: 48 | 49 | x[NOME_VARIABILE] 50 | 51 | In pratica il nome della variabile è composto da un prefisso (x) e, fra parentesi quadre il nome della variabile. Questi sono i valori disponibili: 52 | 53 | * c - Centrato 54 | * l - Giustificato a sinistra 55 | * r - Giustificato a destra 56 | 57 | Nota: Se il simbolo viene messo maiuscolo il valore viene mostrato in reverse 58 | 59 | Le variabili possono assumere il seguente valore: 60 | 61 | * TIME - Orario attuale 62 | * MENUNAME - Nome del menu 63 | * INFOTERM - Nome rel terminale 64 | * MNUTRACE - Percorso dei menu 65 | 66 | Variabili speciali: 67 | 68 | & - Posizione del cursore 69 | ${PATH} - Visualizza il contenuto della variabile d'ambiente PATH 70 | 71 | Esempio: 72 | 73 | C[TITLE] - Titolo del menu centrato ed in reverse 74 | 75 | ## Item area 76 | In questa sezione, per ogni item di menu, si definisce: 77 | 78 | * l'azione da effettuare 79 | * Un eventuale messaggio di Help 80 | * ??? 81 | 82 | Il formato da utilizzare per ogni item è composta da 4 righe: 83 | 84 | 1. Opzione di menu 85 | 2. Comando da eseguire 86 | 3. Messaggio di help da visualizzare 87 | 4. ??? 88 | 89 | 90 | 1. Nella prima riga inserire il primo carattere della stringa che contiene l'ozione di menu) 91 | 2. Nella seconda riga, è possibile specificare: 92 | 93 | * Un comando di shell 94 | * Un sottomenu da aprire ($menuname without extension) 95 | * Comando riservato (return per tornare al menu precedente, fine per uscire dal menu) 96 | 97 | 3. Nella terza riga specificare il messaggio di testo. 98 | Tale messaggio verrà mostrato in corrispondenza della variabile TITLE presente nella "Screen area" 99 | 100 | Esempio: 101 | 102 | %1 103 | ls -lisa; read x 104 | This item show shell file list 105 | ????? 106 | 107 | 108 | ## Option area 109 | Questa sezione contiene una sezie di impostazioni generiche: 110 | 111 | TITOLO - Titolo del menu 112 | RVS_ROW=0,22 - Righe da mostrare in reverse. In questo caso la riga 0 e la riga 22 113 | NOKEYDISP - Disabilita la visualizzazione automatica delle label dei tasti funzione (ET[1-10]) 114 | ET[1-10] - Testo mostrato per tasto funzione n se NOKEYDISP commentato 115 | FZ[1-10] - Comando (shell) eseguito per il tastofunzione n 116 | PW[1-10] - Password da impostare per tasto funzione n 117 | SHELL=sh - Premendo shift-f1 viene avviata una sessione di shell con questa 118 | EDITOR=vi - Premente shift-f2 viene avviato il vi con l'editing del menu attualmente in uso 119 | 120 | Ognuna di queste opzioni può essere commentata con il # 121 | -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | qmenu (5.0.2-1) unstable; urgency=low 2 | 3 | * Initial release (Closes: #761351) 4 | 5 | -- Andrea Colangelo Wed, 24 Sep 2014 21:41:07 +0200 6 | -------------------------------------------------------------------------------- /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: qmenu 2 | Section: utils 3 | Priority: optional 4 | Maintainer: Andrea Colangelo 5 | Uploaders: Stefano Teodorani 6 | Build-Depends: debhelper (>= 9), 7 | libncurses5-dev 8 | Standards-Version: 3.9.6 9 | Homepage: https://github.com/teopost/qmenu/ 10 | Vcs-Git: https://github.com/teopost/qmenu.git 11 | Vcs-Browser: https://github.com/teopost/qmenu 12 | 13 | Package: qmenu 14 | Architecture: any 15 | Depends: ${shlibs:Depends}, ${misc:Depends} 16 | Description: Tool to create simple menus for terminal interfaces 17 | qmenu allows one to create menus for textual interfaces in an easy and 18 | intuitive way. Each menu is defined in a file describing the 19 | visual appearance and the menu items using a simple syntax. 20 | . 21 | Features include options to format the menu, bindings to function keys, 22 | possibility to include submenus, show help messages and launch shell 23 | sessions. 24 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: qmenu 3 | Source: https://github.com/teopost/qmenu 4 | 5 | Files: * 6 | Copyright: 1992-2014 Stefano Teodorani 7 | License: GPL-3.0 8 | 9 | Files: Makefile 10 | Copyright: 2014 Andrea Colangelo 11 | License: WTFPL 12 | 13 | Files: debian/* 14 | Copyright: 2014 Andrea Colangelo 15 | License: GPL-3.0 16 | 17 | License: GPL-3.0 18 | This program is free software: you can redistribute it and/or modify 19 | it under the terms of the GNU General Public License as published by 20 | the Free Software Foundation; version 3 of the License. 21 | . 22 | This package is distributed in the hope that it will be useful, 23 | but WITHOUT ANY WARRANTY; without even the implied warranty of 24 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 25 | GNU General Public License for more details. 26 | . 27 | You should have received a copy of the GNU General Public License 28 | along with this program. If not, write to the Free Software 29 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110 - 1301, USA. 30 | . 31 | On Debian systems, the complete text of the GNU General 32 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 33 | 34 | License: WTFPL 35 | Everyone is permitted to copy and distribute verbatim or modified 36 | copies of this license document, and changing it is allowed as long 37 | as the name is changed. 38 | . 39 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 40 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 41 | . 42 | 0. You just DO WHAT THE FUCK YOU WANT TO. 43 | -------------------------------------------------------------------------------- /debian/docs: -------------------------------------------------------------------------------- 1 | README.md 2 | -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | %: 4 | dh $@ 5 | 6 | override_dh_auto_build: 7 | $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -lncurses -o qmenu qmenu.c 8 | 9 | override_dh_auto_install: 10 | $(MAKE) install PREFIX=$(CURDIR)/debian/qmenu/usr 11 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | opts=filenamemangle=s/.+\/v?(\d\S*)\.tar\.gz/qmenu-$1\.tar\.gz/ \ 3 | https://github.com/teopost/qmenu/tags .*/v?(\d\S*)\.tar\.gz 4 | -------------------------------------------------------------------------------- /m_env.mnu: -------------------------------------------------------------------------------- 1 | This is a template sample of SUBMENU E[TIME] 2 | -------------------------------------------------------------------------------- 3 | 4 | C[TITLE] 5 | 6 | Path: ${PATH} 7 | 8 | 9 | Bash: ${BASH} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | ^x. Back to main menu ^ 18 | 19 | Selection: [ &] 20 | 21 | c[MSG] 22 | -------------------------------------------------------------------------------- 23 | L[INFOTERM] E[MENUNAME] 24 | 239 | .br 240 | General help using software: 241 | .br 242 | Report qmenu translation bugs to 243 | .SH COPYRIGHT 244 | Copyright \(co 1992-2014 Stefano Teodorani 245 | .PP 246 | qmenu is free software: you are free to modify and/or redistribute it under the terms of the GNU General Public License version 3, or any later version. You should have received a copy of the GNU General Public License along with the source for qmenu, see the file COPYING. If now, you can find it at . 247 | .PP 248 | qmenu is distributeded in the hope that it will be useful, but WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE 249 | -------------------------------------------------------------------------------- /qmenu.c: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | '****************************************************************************** 4 | ' This file is part of qmenu.c 5 | ' 6 | ' Copyright © 1992 - 2014 Stefano Teodorani 7 | ' Authors: Stefano "teopost" Teodorani 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; version 3 OF the License. 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 | ' 20 | ' along WITH this program; IF NOT, WRITE TO the Free Software 21 | ' Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110 - 1301, USA. 22 | ' 23 | '****************************************************************************** 24 | 25 | 26 | ================================================================================ 27 | qmenu.c - quick menu 28 | -------------------------------------------------------------------------------- 29 | Compilazione su sistema 3000 -> cc -o qmenu qmenu.c -lcurses 30 | Compilazione su SCO -> cc -xenix -lcurses -ltermcap -o qmenu qmenu.c 31 | Compilazione su Linux -> gcc x -lncurses -o qmenu qmenu.c 32 | ================================================================================ 33 | */ 34 | 35 | // For Unix System V NCR -> #include 36 | 37 | #include 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include "dirent.h" 47 | #include 48 | 49 | // Varius constants 50 | 51 | #define VERSION "Rel. 5.0.3" 52 | #define SUPER 1 // Pop-up Stampanti Superutente 53 | #define USER 2 // Pop-up Stampanti Utente 54 | #define ON 1 // Costante stato ON 55 | #define OFF 0 // Costante stato OFF 56 | #define MENU -1 // Check Password da voce Menu 57 | #define EDIT -2 // Check Password da 58 | #define SHELL -3 // Check Password da 59 | #define SUPER_MENU -4 // Check Password da 60 | #define PASSWD_MODE -5 // Check Password in password mode 61 | #define TL 1 // Flag simbolo grafico Top-Left 62 | #define BL 2 // Flag simbolo grafico Bottom-Left 63 | #define TR 3 // Flag simbolo grafico Top-Right 64 | #define BR 4 // Flag simbolo grafico Bottom-Right 65 | #define ROW 5 // Flag simbolo grafico Row 66 | #define COL 6 // Flag simbolo grafico Col 67 | #define SHADOW 7 // Flag simbolo grafico Shadow 68 | #define LEFT_SYMBOL '>' // Simbolo Sx della barra di selezione 69 | #define RIGHT_SYMBOL ' ' // Simbolo Dx della barra di selezione 70 | #define LOGFILE_DIM 50000 // Dimensione max del file di LOG 71 | #define CONFIG_FILE qmenu.cfg // Nome File di configurazione 72 | #define MAXR 24 // Numero massimo righe Display 73 | #define MAXC 90 // Numero massimo colonne Display 74 | #define MAXITEMS 40 // Massimo Numero Voci di menu 75 | #define MAXFRMITEMS 20 // Massimo Numero Voci di menu 76 | #define PREV_FIELD "-2" // Massimo Numero Voci di menu 77 | #define ABORT "-1" // Massimo Numero Voci di menu 78 | #define C_U 256 // Cursore Su 79 | #define C_D 257 // Cursore Giu' 80 | #define C_L 258 // Cursore Sinistra 81 | #define C_R 259 // Cursore Destra 82 | #define FZ1 261 // Tasto Funzione F1 83 | #define FZ2 262 // Tasto Funzione F2 84 | #define FZ3 263 // Tasto Funzione F3 85 | #define FZ4 264 // Tasto Funzione F4 86 | #define FZ5 265 // Tasto Funzione F5 87 | #define FZ6 266 // Tasto Funzione F6 88 | #define FZ7 267 // Tasto Funzione F7 89 | #define FZ8 268 // Tasto Funzione F8 90 | #define FZ9 269 // Tasto Funzione F9 91 | #define FZ0 270 // Tasto Funzione F10 92 | #define FZA 271 // Tasto Funzione F11 93 | #define FZB 272 // Tasto Funzione F12 94 | #define DEL 18 // Tasto DELETE 95 | #define BKSP 8 // Tasto BACK-SPACE 96 | #define INS 5 // Tasto INSERT 97 | #define RET 13 // Tasto RETURN 98 | #define NL 10 // Tasto NEW-LINE 99 | #define PGUP 300 // Tasto Pagina Su' 100 | #define PGDN 301 // Tasto Pagina Giu' 101 | #define HOME 302 // Tasto Pagina Giu' 102 | #define END 303 // Tasto Pagina Giu' 103 | #define ESC 27 // Tasto ESCAPE 104 | #define X_COORD 3 // Coord. X Display Help 105 | #define Y_COORD 5 // Coord. Y Display Help 106 | #define MAX_ROW 16 // Righe Max Display Help 107 | #define MAX_COL 70 // Colonne Max Display Help 108 | 109 | // Messages 110 | 111 | #define msg_DONT_OPEN "Can't open" 112 | #define msg_DONT_WRITE "Can't write" 113 | #define msg_USER_DONT_HAVE_PERM "The user has not permissions" 114 | #define msg_MENU_FILE_ERROR "Menu file error" 115 | #define msg_THIS_IS_MAIN_MENU "This is the main menu" 116 | #define msg_INVALID_SELECTION "Invalid selection" 117 | #define msg_PARENT_MENU_CHANGED "Parent menu changed" 118 | 119 | // File pointer 120 | 121 | FILE *infile, *fopen (); // File Generici di Input/Output 122 | FILE *ofile, *helpfile; // File Generici di Input/Output 123 | 124 | // Global variables 125 | 126 | signed char attrb[MAXR + 1][MAXC];// Campi di selezione Dati 127 | char vscreen[MAXR + 1][MAXC]; // Schermo di Lavoro 128 | char linea[200]; // Buffer Globale Generico 129 | char finestra[23][200]; 130 | int max_elem_fin = 0; 131 | int max_lun_fin = 0; 132 | int j = 0; 133 | char help_line[800][255]; 134 | char nometemp[64]; // File temporaneo 135 | char lpdestenv[32]; // Spazio environment x LPDEST 136 | char lpdestval[32]; // Spazio environment x LPDEST 137 | char sistema[12]; // Nome sistema 138 | char imenu[80][40]; // Catasta di Menu 139 | char NULSTRING[] = { 0, 0 }; // Stringa nulla statica per funzioni 140 | char titolo[40]; // Titolo del menu 141 | char editor[40]; // Editor utilizzato (vi) 142 | char rvs_row[40]; // Stringa di righe da evidenziare 143 | char rvs_tmp[40][10]; // Stringa temp. di righe da evidenz. 144 | char shell[40]; // Shell lanciata 145 | char porta[20]; // Nome tty di input 146 | char utente[20]; // Nome login di input 147 | char spoolernm[16]; // Nome dello spooler assegnato 148 | char ability_user[80]; 149 | char prsuper[80]; 150 | char pruser[80]; 151 | char super_passwd[80]; 152 | char menu_dir[64]; // Nome directory dei menu 153 | char sh_passwd[64]; // Nome parola chiave per shell 154 | char sh_passwd_ok = 0; // Flag parola chiave per shell 155 | char edit_passwd[64]; // Nome parola chiave per edit menu 156 | char edit_passwd_ok = 0; // Flag parola chiave per edit menu 157 | char intflg = 0; // Flag Interrupt da subroutine 158 | char tfu[10][300]; // Tasti Funzione Utente 159 | char lfu[10][20]; // Label Tasti Funzione Utente 160 | char pfu[10][26]; // Password Tasti Funzione Utente 161 | int selmenu[40]; // Catasta di Menu 162 | int help_item = 0; 163 | int rvs_r; // Riga da evidenziare 164 | int ipmenu = 0; // Puntatore a Catasta di Menu 165 | int nitems; // Numero di Voci 166 | int curitem; // Voce corrente 167 | int iy = 21, ix = 1; // Posizione di default per input 168 | int keydisp = 1; // Flag Diplay Tasti Funzione 169 | int prdisp = 1; // Flag display Stampante 170 | int itime_out = 900; // Time Out di Procedura 171 | int mnu_tim = 1; // Inattivita tastiera attivata 172 | int bks_exit = 0; // Se 1 esce dal menu principale 173 | int neterr = 0; // Flag Errore di non trovato login 174 | int en, o = 0, junk, d; // Variabili generiche, contatori ecc. 175 | int user = OFF; 176 | int super = OFF; 177 | int superpasswd = OFF; 178 | int passwd_mode = OFF; 179 | int inc = 0, memoinc = 0; // Variabile pointer file memorizzato 180 | int graf = 1; // Flag Grafica Abilitata (se=1) 181 | double procid; // Numero processo in corso 182 | long logfile_dim = LOGFILE_DIM; // Dimensione max file di log 183 | char env_var[80]; // Stringa variabile d' ambiente 184 | char simb_var[80]; // Stringa variabile simbolo 185 | char env_value[80]; // Valore variabile d' environment 186 | char memofile[15000]; // File memorizzato in un array 187 | char hlp_filename[60]; // Nome file di Help 188 | char to_found[60]; // Stringa da ricercare nel file Help 189 | int mnuname_y; // Riga simbolo MNUNAME (Nome menu) 190 | int mnuname_x; // Colonna simbolo MNUNAME 191 | int mnuname_g; // Giustificazione simbolo MNUNAME 192 | int mnuname_flag = OFF; // Flag ON/OFF simbolo MNUNAME 193 | int mnuname_rvs = OFF; // Flag reverse on simbolo MNUNAME 194 | int msg_y; // Riga simbolo MSG (Messaggio Help) 195 | int msg_x; // Colonna simbolo MSG 196 | int msg_g; // Giustificazione simbolo MSG 197 | int msg_flag = OFF; // Flag ON/OFF simbolo MSG 198 | int msg_rvs = OFF; // Flag reverse on simbolo MSG 199 | int time_y; // Riga simbolo TIME (Orario) 200 | int time_x; // Colonna simbolo TIME 201 | int time_g; // Giustificazione simbolo TIME 202 | int time_flag = 0; // Flag ON/OFF simbolo TIME 203 | int time_rvs = OFF; // Flag reverse on simbolo TIME 204 | int title_y; // Riga simbolo TITLE (Titolo) 205 | int title_x; // Colonna simbolo TITLE 206 | int title_g; // Giustificazione simbolo TITLE 207 | int title_flag = 0; // Flag ON/OFF simbolo TITLE 208 | int title_rvs = OFF; // Flag reverse on simbolo TITLE 209 | int infoterm_y; // Riga simbolo INFOTERM (Info term.) 210 | int infoterm_x; // Colonna simbolo INFOTERM 211 | int infoterm_g; // Giustificazione simbolo INFOTER 212 | int infoterm_flag = 0; // Flag ON/OFF simbolo INFOTERM 213 | int infoterm_rvs = OFF; // Flag reverse on simbolo INFOTERM 214 | int mnutrace_y; // Riga simbolo MNUTRACE (Elenc.menu) 215 | int mnutrace_x; // Colonna simbolo MNUTRACE 216 | int mnutrace_g; // Giustificazione simbolo MNUTRACE 217 | int mnutrace_flag = 0; // Flag ON/OFF simbolo MNUTRACE 218 | int mnutrace_rvs = OFF; // Flag reverse on simbolo MNUTRACE 219 | int a = 0; 220 | 221 | // Menu struct 222 | 223 | struct menuitem 224 | { 225 | char desc[80]; // Descrizione a Video 226 | char execute[300]; // Comando Corrispondente Eseguito 227 | char msg[80]; // Messaggio descrittore del comando 228 | char passw[26]; // Eventuale Password 229 | int x; // Posizione x 230 | int y; // Posizione y 231 | int len; // Lunghezza Descizione 232 | int inplen; // Lunghezza indice Selezione 233 | } scelta[MAXITEMS]; // Massimo numero scelte (01-99,A-Z) 234 | 235 | struct form 236 | { 237 | char desc[80]; 238 | int x; 239 | int y; 240 | int lun; 241 | } frm[MAXFRMITEMS]; 242 | 243 | // Functions headers 244 | 245 | char *getlogin (); 246 | char *ttyname (); 247 | char *cercadop (); 248 | char *getenv (); 249 | int senum (); 250 | void fine1 (); 251 | void fine2 (); 252 | void fine3 (); 253 | void fine4 (); 254 | void fine5 (); 255 | void templim (); 256 | void helper (); 257 | void cre_cfg (); 258 | void cre_model (); 259 | int form (char *forma); 260 | void disegna_form (); 261 | void readcfg (); 262 | int getlineext (char *tamp); 263 | int loadmenu (); 264 | void alert (char *titolo, char *testo); 265 | void dispmenu (); 266 | void history_string (char *message); 267 | void mnutrace (); 268 | void disegna_form (); 269 | void display_config (); 270 | void pausa (); 271 | void dataoggi (char *datastr); 272 | int confirm (); 273 | int chkinit (); 274 | void orolog (); 275 | void menu_name_disp (); 276 | void getentry (int xpos, int ypos, int tot_entry, char *entry); 277 | void getpasswd (char *entry); 278 | void alert (char *titolo, char *testo); 279 | void grafic (int etichetta); 280 | void infoterm (); 281 | void simb_pos (char *simb_name, int y_pos, int x_pos, int gst); 282 | void hlpmsg (); 283 | void win (char *titolo, int x, int y, int z, int k); 284 | void disphelp (int row, int col, int first_row, int first_col); 285 | int ext (char *label); 286 | void inpsel (int op); 287 | void smove (int y, int x); 288 | void selspool (int type_sel); 289 | int esegui (char *comando); 290 | void scarica (); 291 | void menu_name_disp (); 292 | void selez (int op); 293 | int chkinit (); 294 | int ricerca_passwd (char *etichetta); 295 | int selectnext (int c); 296 | int win_option (char *winlist); 297 | int chkpass (int tipo); 298 | int getkey (); 299 | void microhelp(char *message); 300 | 301 | time_t t1; 302 | struct tm *tptr; 303 | 304 | 305 | // Main 306 | 307 | int main (int argc, char **argv) 308 | { 309 | int errorlvl = 0; /* Variabile controllo ritorno funz. */ 310 | int ii = 0, c, c1, t, idx; /* Variabili di utilizzo generale */ 311 | int k = 0; 312 | int primavolta; /* Primo utilizzo frecce e tastiera */ 313 | int tmpcnt, flg1, flg2; 314 | char command[60]; /* Command Variab.usato dalla system() */ 315 | char prgname[80]; 316 | char menu_name[128]; 317 | char compare[80]; 318 | char buf0[4]; 319 | char buf1[4]; 320 | char formid[30]; 321 | char shellid[30]; 322 | char frm_argument[255]; 323 | int dentro_parentesi = FALSE; 324 | int p, n, r; 325 | 326 | if (argc == 1) /* Se non esistono argomenti, errore */ 327 | { 328 | microhelp(""); 329 | exit (0); 330 | } 331 | 332 | if (strcmp (argv[1], "-init") == 0) 333 | { 334 | cre_cfg (); 335 | exit (0); 336 | } 337 | 338 | if (strcmp (argv[1], "-model") == 0) 339 | { 340 | cre_model (); 341 | exit (0); 342 | } 343 | 344 | readcfg (); // Lettura Variabili d' ambiente 345 | strcat (imenu[ipmenu], argv[1]); // Rilevo il nome del Menu passato 346 | //strcat(imenu[ipmenu],".mnu"); // Aggiungo estensione al nome menu 347 | strcpy (menu_name, menu_dir); 348 | strcat (menu_name, imenu[ipmenu]); 349 | 350 | if ((infile = fopen (menu_name, "r")) == NULL) 351 | { 352 | microhelp("File not found"); 353 | exit (0); 354 | } 355 | else 356 | fclose (infile); 357 | 358 | signal (SIGINT, fine1); // Interruzione utente (^C, Del, Trap) 359 | signal (SIGFPE, fine2); // Errore Aritmetico 360 | signal (SIGBUS, fine3); // Bus Error 361 | signal (SIGSEGV, fine4); // Segmentation fault 362 | signal (SIGTERM, fine5); // Segnale interruzione esterno 363 | signal (SIGALRM, templim); // Tempo di Inattiviva utente 364 | 365 | /* Lettura Variabili d' ambiente */ 366 | strcpy (porta, ttyname (fileno (stdin))); /* Identificazione porta */ 367 | initscr (); /* Inizializzazione schermo curses */ 368 | noecho (); 369 | cbreak (); 370 | clear (); 371 | refresh (); 372 | noecho (); 373 | crmode (); 374 | strcpy (compare, argv[0]); /* Ottiene nome programma di lancio */ 375 | 376 | while (compare[0] != 0) 377 | { 378 | strcpy (prgname, compare); 379 | strcpy (compare, cercadop (prgname, "/")); 380 | } 381 | 382 | if (argc < 3) /* Se non esistono 3 argomenti, uso */ 383 | strcpy (editor, "vi"); /* il vi come editor di modifica menu */ 384 | else /* altrimenti */ 385 | strcpy (editor, argv[2]); /* uso il terzo argomento come Editor */ 386 | 387 | strcpy (shell, "sh"); /* Uso sh come shell di sistema */ 388 | 389 | if (getlogin ()) /* Letto il nome login */ 390 | strcpy (utente, getlogin ()); /* e ne copio il contenuto in utente */ 391 | 392 | strcpy (nometemp, "\0"); /* Copio su sistema il sistema in uso */ 393 | strcpy (nometemp, tmpnam (nometemp)); 394 | strcpy (linea, "uuname -l > "); 395 | strcat (linea, nometemp); 396 | system (linea); 397 | infile = fopen (nometemp, "r"); 398 | getlineext (sistema); 399 | fclose (infile); 400 | unlink (nometemp); 401 | 402 | errorlvl = loadmenu (); 403 | if (errorlvl) 404 | { 405 | if (errorlvl != 10) 406 | { 407 | alert (" Warning ", msg_MENU_FILE_ERROR); 408 | errorlvl = 3; 409 | } 410 | beep (); 411 | goto the_end; 412 | } 413 | clear (); 414 | dispmenu (); 415 | history_string ("[START]"); 416 | curitem = 1; 417 | tmpcnt = 0; 418 | c = 0; 419 | primavolta = 0; 420 | tmpcnt = 0; 421 | 422 | if (passwd_mode) 423 | { 424 | if (chkinit ()) 425 | dispmenu (); 426 | else 427 | goto the_end; 428 | } 429 | 430 | while (1) /* inizio ciclo controllo menu' */ 431 | { 432 | c1 = c; 433 | if ((tmpcnt == 1) && (c1 > 1000)) 434 | { 435 | smove (iy, ix - 1); 436 | sprintf (buf0, "%.2d", c1 - 1000); 437 | addch ('?'); 438 | } 439 | smove (iy, ix); 440 | if (time_flag) 441 | orolog (); 442 | if (mnu_tim) 443 | alarm (itime_out); /* Delay di inattivita' */ 444 | if ((msg_flag) && (primavolta)) 445 | hlpmsg (); 446 | if (infoterm_flag) 447 | infoterm (); 448 | inpsel (primavolta); 449 | refresh (); 450 | c = getkey (); 451 | if (mnu_tim) 452 | alarm (0); 453 | if ((senum (c)) && (tmpcnt == 0)) /* Input numerico allora verifico */ 454 | { 455 | /* se puo essere una decina */ 456 | tmpcnt = 1; /* Flag controllo primo input */ 457 | buf0[0] = c; /* numerico */ 458 | buf0[1] = 0; 459 | c = atoi (buf0) + 1000; /* Sommo 1000 all'input c per */ 460 | flg1 = -1; /* distinguerlo come primo input */ 461 | flg2 = -1; 462 | for (t = 1; t <= nitems; t++) 463 | { 464 | buf1[0] = scelta[t].desc[0]; 465 | buf1[1] = scelta[t].desc[1]; 466 | buf1[2] = 0; 467 | if ((senum (buf1[0]) == 0) && (senum (buf1[1]) == 0)) 468 | continue; 469 | if (c == (atoi (buf1) + 1000)) 470 | flg1 = 0; 471 | } 472 | for (t = 1; t <= nitems; t++) 473 | if (scelta[t].desc[0] == buf0[0]) 474 | if (senum (scelta[t].desc[1]) == 1) 475 | flg2 = 0; 476 | if (flg1 == -1) 477 | { 478 | if ((flg2 == -1) && (buf0[0] != '0')) 479 | { 480 | beep (); 481 | tmpcnt = 0; 482 | } 483 | continue; 484 | } 485 | if ((flg1 == 0) && (flg2 == -1)) 486 | { 487 | tmpcnt = 0; 488 | inpsel (primavolta); 489 | } 490 | } 491 | if ((tmpcnt == 1) && (senum (c))) /* Se sono nel secondo ciclo */ 492 | { 493 | /* dell'input numerico */ 494 | tmpcnt = 0; 495 | buf0[0] = (c1 - 1000) + '0'; 496 | buf0[1] = c; 497 | buf0[2] = 0; 498 | c = atoi (buf0) + 1000; 499 | flg1 = -1; 500 | for (t = 1; t <= nitems; t++) 501 | { 502 | buf1[0] = scelta[t].desc[0]; 503 | buf1[1] = scelta[t].desc[1]; 504 | buf1[2] = 0; 505 | if ((senum (buf1[0]) == 0) && (senum (buf1[1]) == 0)) 506 | continue; 507 | if (c == (atoi (buf1) + 1000)) 508 | flg1 = 0; 509 | } 510 | if (flg1 != 0) 511 | { 512 | smove (iy, ix - 1); 513 | printw ("%.2d", c - 1000); 514 | scarica (); 515 | alert (" Warning ", msg_INVALID_SELECTION); 516 | dispmenu (); 517 | selez (1); 518 | c = 0; 519 | continue; 520 | } 521 | } 522 | if ((senum (c) != 1) && (c < 1000)) /* Non si ammettono cifre */ 523 | tmpcnt = 0; /* mischiate a lettere */ 524 | if (c == 0) /* Tasto nullo */ 525 | continue; 526 | if (c == BKSP) /* Ritorno a menu' Precedente */ 527 | { 528 | history_string ("[Previuous menu]"); 529 | ipmenu--; 530 | if (ipmenu < 0) 531 | { 532 | if (bks_exit) 533 | goto the_end; 534 | else 535 | { 536 | ipmenu = 0; 537 | alert (" Warning ", msg_THIS_IS_MAIN_MENU); 538 | dispmenu (); 539 | refresh (); 540 | primavolta = 0; 541 | selez (0); 542 | curitem = 1; 543 | c = 0; 544 | continue; 545 | } 546 | } 547 | if ((errorlvl = loadmenu (imenu[ipmenu]))) 548 | { 549 | alert (" Warning ", msg_PARENT_MENU_CHANGED); 550 | goto the_end; 551 | } 552 | clear (); 553 | dispmenu (); 554 | primavolta = 1; 555 | curitem = selmenu[ipmenu]; 556 | selez (1); 557 | continue; 558 | } 559 | 560 | if (c == '#') /*--- Richiesta Shell Assegnata -----*/ 561 | { 562 | if (superpasswd) 563 | { 564 | if (chkpass (SUPER_MENU)) 565 | { 566 | dispmenu (); 567 | selez (1); 568 | continue; 569 | } 570 | switch (win_option 571 | ("ACCESSO A SHELL,MODIFICA MENU,MODIFICA STAMPANTE DI DEFAULT,VISUAL. FILE DI CONFIGURAZIONE,VISUAL. FILE DI LOG,MODIFICA FILE DI CONFIGURAZIONE,MODIFICA FILE DI FORM,MODIFICA FILE DI HELP,INFORMAZIONI")) 572 | { 573 | case 0: 574 | strcpy (command, shell); 575 | esegui (command); 576 | errorlvl = loadmenu (imenu[ipmenu]); 577 | if (errorlvl) 578 | { 579 | if (errorlvl != 10) 580 | { 581 | alert (" Warning ", msg_MENU_FILE_ERROR); 582 | errorlvl = 3; 583 | } 584 | goto the_end; 585 | } 586 | break; 587 | case 1: 588 | strcpy (command, editor); 589 | strcat (command, " "); 590 | strcat (command, menu_dir); 591 | strcat (command, imenu[ipmenu]); 592 | esegui (command); 593 | errorlvl = loadmenu (imenu[ipmenu]); 594 | if (errorlvl) 595 | { 596 | if (errorlvl != 10) 597 | { 598 | alert (" Warning ", msg_MENU_FILE_ERROR); 599 | errorlvl = 3; 600 | } 601 | goto the_end; 602 | } 603 | break; 604 | case 2: 605 | selspool (SUPER); 606 | break; 607 | case 3: 608 | display_config (); 609 | break; 610 | case 4: 611 | if ((infile = fopen ("qmenu.log", "r")) == NULL) 612 | { 613 | printw ("%s qmenu.log\n", msg_DONT_OPEN); 614 | break; 615 | } 616 | help_item = 0; 617 | while ((a = getlineext (help_line[help_item])) != EOF) 618 | help_item++; 619 | help_item--; 620 | fclose (infile); 621 | helper (); 622 | for (a = 0; a != help_item; a++) 623 | help_line[a][0] = '\0'; 624 | break; 625 | case 5: 626 | esegui ("vi qmenu.cfg"); 627 | errorlvl = loadmenu (imenu[ipmenu]); 628 | break; 629 | case 6: 630 | esegui ("vi qmenu.frm"); 631 | errorlvl = loadmenu (imenu[ipmenu]); 632 | break; 633 | case 7: 634 | strcpy (command, editor); 635 | strcat (command, " "); 636 | strcat (command, hlp_filename); 637 | esegui (command); 638 | errorlvl = loadmenu (imenu[ipmenu]); 639 | break; 640 | case 8: 641 | win (" INFORMATION ", 2, 2, 18, 78); 642 | move (4, 3); 643 | printw (" %s ", VERSION); 644 | move (6, 3); 645 | printw (" quick menu"); 646 | move (8, 3); 647 | printw (" Created by S.Teodorani & G.Juan Oteri"); 648 | move (10, 3); 649 | printw (" File list : qmenu - main executable"); 650 | move (11, 3); 651 | printw(" qmenu.cfg - configuration file"); 652 | move (12, 3); 653 | printw(" qmenu.hlp - help file (mandatory)"); 654 | move (13, 3); 655 | printw(" qmenu.log - log file (generated by qmenu)"); 656 | move (14, 3); 657 | printw(" qmenu.log.bak - backup log file"); 658 | move (15, 3); 659 | printw(" qmenu.frm - form file"); 660 | move (18, 4); 661 | printw (" F4 - Exit "); 662 | while ((a = getkey ()) != FZ4); 663 | break; 664 | default: 665 | break; 666 | } 667 | } 668 | dispmenu (); 669 | selez (1); 670 | continue; 671 | } 672 | if (c == '\t') /*--- Richiesta Help su argomento ----*/ 673 | { 674 | strcpy (to_found, imenu[ipmenu]); 675 | strcat (to_found, ":"); 676 | if (primavolta != 0) 677 | strncat (to_found, scelta[curitem].desc, 2); 678 | strcat (to_found, "\0"); 679 | if ((junk = ext (to_found)) == 1) 680 | alert (" Warning ", " MENU FILE NOT FOUND \0"); 681 | dispmenu (); 682 | if (primavolta != 0) 683 | selez (1); 684 | inpsel (primavolta); 685 | continue; 686 | } 687 | if ((c >= FZ1) && (c <= FZ0)) /*--- Tasti funzione ----*/ 688 | { 689 | idx = c - FZ1; 690 | if (keydisp == 1) /* Flash del Tasto funzione */ 691 | { 692 | if (tfu[idx][0] > 0) 693 | { 694 | for (t = 0; t < 9; t++) 695 | { 696 | for (ii = 0; ii < 50000; ii++); 697 | { 698 | if (t % 2) 699 | standout (); 700 | else 701 | standend (); 702 | } 703 | move (23, idx * 8); 704 | if (idx < 9) 705 | printw ("F%.1d", idx + 1); 706 | else 707 | printw ("F0"); 708 | refresh (); 709 | } 710 | standend (); 711 | refresh (); 712 | } 713 | } 714 | if (tfu[idx][0] == 0) 715 | continue; 716 | if (strncmp (tfu[idx], "exit", 4) == 0) 717 | goto the_exit; 718 | if (strncmp (tfu[idx], "fine", 4) == 0) 719 | { 720 | if (confirm ()) 721 | { 722 | clear (); 723 | refresh (); 724 | history_string ("[END]"); 725 | goto the_end; 726 | } 727 | dispmenu (); 728 | selez (1); 729 | continue; 730 | } 731 | if (tfu[idx][0] == '$') 732 | { 733 | if ((pfu[idx][0]) > 0) 734 | if (chkpass (idx)) 735 | { 736 | dispmenu (); 737 | selez (1); 738 | continue; 739 | } 740 | selmenu[ipmenu] = curitem; 741 | ipmenu++; 742 | strcpy (imenu[ipmenu], &tfu[idx][1]); 743 | strcat (imenu[ipmenu], ".mnu"); 744 | errorlvl = loadmenu (imenu[ipmenu]); 745 | if (errorlvl) 746 | { 747 | ipmenu--; 748 | if (ipmenu == -1) 749 | ipmenu = 0; 750 | errorlvl = loadmenu (imenu[ipmenu]); 751 | if (errorlvl) 752 | { 753 | alert (" Warning ", msg_PARENT_MENU_CHANGED); 754 | goto the_end; 755 | } 756 | } 757 | clear (); 758 | dispmenu (); 759 | curitem = 1; 760 | selez (0); 761 | primavolta = 0; 762 | continue; 763 | } 764 | if (strncmp (tfu[idx], "return", 6) == 0) 765 | { 766 | if (strncmp (tfu[idx], "returnmain", 10) == 0) 767 | ipmenu = 0; 768 | else 769 | ipmenu--; 770 | if (ipmenu < 0) 771 | { 772 | clear (); 773 | refresh (); 774 | goto the_end; 775 | } 776 | if ((errorlvl = loadmenu (imenu[ipmenu]))) 777 | { 778 | alert (" Warning ", msg_PARENT_MENU_CHANGED); 779 | goto the_end; 780 | } 781 | clear (); 782 | curitem = 1; 783 | continue; 784 | } 785 | if ((pfu[idx][0]) > 0) 786 | if (chkpass (idx)) 787 | { 788 | dispmenu (); 789 | selez (1); 790 | continue; 791 | } 792 | strcpy (command, tfu[idx]); 793 | esegui (command); 794 | crmode (); 795 | noecho (); 796 | clear (); 797 | dispmenu (); 798 | selez (1); 799 | inpsel (primavolta); 800 | continue; 801 | } 802 | if (c == NL) /*--- Esecuzione ----*/ 803 | { 804 | if (primavolta == 0) 805 | { 806 | beep (); 807 | continue; 808 | } 809 | if (curitem == 0) 810 | continue; 811 | if (scelta[curitem].execute[0] == 0) 812 | continue; 813 | if (strncmp (scelta[curitem].execute, "exit", 4) == 0) 814 | goto the_exit; 815 | if (strncmp (scelta[curitem].execute, "fine", 4) == 0) 816 | { 817 | if (confirm ()) 818 | { 819 | clear (); 820 | refresh (); 821 | history_string ("[END]"); 822 | goto the_end; 823 | } 824 | dispmenu (); 825 | selez (1); 826 | continue; 827 | } 828 | if (scelta[curitem].execute[0] == '$') 829 | { 830 | if (strlen (scelta[curitem].passw) > 0) 831 | if (chkpass (MENU)) 832 | { 833 | dispmenu (); 834 | selez (1); 835 | continue; 836 | } 837 | 838 | history_string (scelta[curitem].desc); 839 | selmenu[ipmenu] = curitem; 840 | ipmenu++; 841 | strcpy (imenu[ipmenu], &scelta[curitem].execute[1]); 842 | strcat (imenu[ipmenu], ".mnu"); 843 | errorlvl = loadmenu (imenu[ipmenu]); 844 | if (errorlvl) 845 | { 846 | ipmenu--; 847 | if (ipmenu == -1) 848 | ipmenu = 0; 849 | errorlvl = loadmenu (imenu[ipmenu]); 850 | if (errorlvl) 851 | { 852 | alert (" Warning ", msg_PARENT_MENU_CHANGED); 853 | 854 | goto the_end; 855 | } 856 | } 857 | clear (); 858 | dispmenu (); 859 | curitem = 1; 860 | selez (0); 861 | primavolta = 0; 862 | c = 0; 863 | refresh (); 864 | continue; 865 | } 866 | /* FORM */ 867 | if (scelta[curitem].execute[0] == '*') 868 | { 869 | p = 1; 870 | n = 0; 871 | r = 0; 872 | while (scelta[curitem].execute[p] != '\0') 873 | { 874 | if (scelta[curitem].execute[p] == '(') 875 | { 876 | p++; 877 | dentro_parentesi = TRUE; 878 | } 879 | 880 | if (scelta[curitem].execute[p] == ')') 881 | { 882 | p++; 883 | dentro_parentesi = FALSE; 884 | } 885 | 886 | if (dentro_parentesi) 887 | shellid[n++] = scelta[curitem].execute[p]; 888 | else 889 | formid[r++] = scelta[curitem].execute[p]; 890 | 891 | p++; 892 | } 893 | shellid[n] = '\0'; 894 | formid[r] = '\0'; 895 | 896 | if (!form (formid)) 897 | { 898 | sprintf (frm_argument, "%s ", shellid); 899 | for (k = 0; k < j; k++) 900 | { 901 | strcat (frm_argument, " \""); 902 | strcat (frm_argument, frm[k].desc); 903 | strcat (frm_argument, "\""); 904 | } 905 | strcat (frm_argument, "\0"); 906 | resetty (); 907 | esegui (frm_argument); 908 | crmode (); 909 | noecho (); 910 | } 911 | dispmenu (); 912 | selez (1); 913 | continue; 914 | } 915 | if (strncmp (scelta[curitem].execute, "return", 6) == 0) 916 | { 917 | if (strncmp (scelta[curitem].execute, "returnmain", 10) == 0) 918 | ipmenu = 0; 919 | else 920 | ipmenu--; 921 | if (ipmenu < 0) 922 | { 923 | clear (); 924 | refresh (); 925 | goto the_end; 926 | } 927 | if ((errorlvl = loadmenu (imenu[ipmenu]))) 928 | { 929 | alert (" Warning ", msg_PARENT_MENU_CHANGED); 930 | goto the_end; 931 | } 932 | dispmenu (); 933 | curitem = 1; 934 | primavolta = 0; 935 | continue; 936 | } 937 | if (strlen (scelta[curitem].passw) > 0) 938 | if (chkpass (MENU)) 939 | { 940 | dispmenu (); 941 | selez (1); 942 | continue; 943 | } 944 | resetty (); 945 | strcpy (command, scelta[curitem].execute); 946 | history_string (scelta[curitem].execute); 947 | esegui (command); 948 | crmode (); 949 | noecho (); 950 | clear (); 951 | dispmenu (); 952 | selez (1); 953 | inpsel (primavolta); 954 | primavolta = 1; 955 | continue; 956 | } 957 | if ((c > 255) && (c < 1000)) /* Frecce */ 958 | { 959 | if (primavolta == 0) 960 | { 961 | selez (0); 962 | curitem = 1; 963 | selez (1); 964 | buf0[0] = scelta[curitem].desc[0]; 965 | buf0[1] = scelta[curitem].desc[1]; 966 | buf0[2] = 0; 967 | if ((senum (buf0[0])) || (senum (buf0[1]))) 968 | c = 1000 + atoi (buf0); 969 | primavolta = 1; 970 | } 971 | else 972 | { 973 | selez (0); 974 | curitem = selectnext (c); 975 | selez (1); 976 | buf0[0] = scelta[curitem].desc[0]; 977 | buf0[1] = scelta[curitem].desc[1]; 978 | buf0[2] = 0; 979 | if ((senum (buf0[0])) || (senum (buf0[1]))) 980 | c = 1000 + atoi (buf0); 981 | } 982 | } 983 | else /* Lettere o decine numeriche */ 984 | { 985 | if (c < 1000) /*--- Lettere ---*/ 986 | { 987 | c = toupper (c); 988 | primavolta = 1; 989 | selez (0); 990 | for (t = 1; t <= nitems; t++) 991 | { 992 | if (c == scelta[t].desc[0]) 993 | curitem = t; 994 | } 995 | selez (1); 996 | refresh (); 997 | } 998 | else 999 | { 1000 | primavolta = 1; 1001 | selez (0); 1002 | for (t = 1; t <= nitems; t++) 1003 | { 1004 | buf1[0] = scelta[t].desc[0]; 1005 | buf1[1] = scelta[t].desc[1]; 1006 | buf1[2] = 0; 1007 | if ((senum (buf1[0]) == 0) && (senum (buf1[1]) == 0)) 1008 | continue; 1009 | if (c == (atoi (buf1) + 1000)) 1010 | curitem = t; 1011 | } 1012 | selez (1); 1013 | } 1014 | } 1015 | if (tmpcnt == 0) 1016 | inpsel (primavolta); 1017 | } 1018 | the_end:; /* Label di fine procedura */ 1019 | resetty (); 1020 | if (errorlvl) 1021 | putchar ('\n'); 1022 | standend (); 1023 | /* 1024 | sleep(1); 1025 | */ 1026 | endwin (); 1027 | /* 1028 | sleep(1); 1029 | */ 1030 | exit (errorlvl); 1031 | 1032 | the_exit:; /* Label di fine procedura */ 1033 | resetty (); 1034 | if (errorlvl) 1035 | putchar ('\n'); 1036 | standend (); 1037 | /* 1038 | sleep(1); 1039 | */ 1040 | endwin (); 1041 | /* 1042 | sleep(1); 1043 | */ 1044 | exit (curitem); 1045 | } 1046 | 1047 | // Microhelp 1048 | 1049 | void microhelp(char *message) 1050 | { 1051 | printf ("\n"); 1052 | printf ("qmenu - %s - by S.Teodorani & G.Juan Oteri\n", VERSION); 1053 | printf ("source: https://github.com/teopost/qmenu\n"); 1054 | printf ("\n"); 1055 | printf ("usage : qmenu [-init] [-model] [menu_file]\n\n"); 1056 | printf (" -init : Creating configuration file \"qmenu.cfg\"\n"); 1057 | printf (" -model: Creating menu file model named \"model.mnu\"\n\n"); 1058 | printf ("%s", message); 1059 | } 1060 | 1061 | // Menu loader 1062 | 1063 | int loadmenu () 1064 | { 1065 | char menu_file[128]; 1066 | char buf0[3]; 1067 | char buf1[3]; 1068 | int sn; 1069 | int ii, t, c0, c1, c, y, x, invoce, r; 1070 | int kk, fine, getmemo (); 1071 | int startpos; 1072 | 1073 | mnuname_flag = OFF; 1074 | msg_flag = OFF; 1075 | time_flag = OFF; 1076 | title_flag = OFF; 1077 | infoterm_flag = OFF; 1078 | mnutrace_flag = OFF; 1079 | 1080 | strcpy (menu_file, menu_dir); 1081 | strcat (menu_file, imenu[ipmenu]); 1082 | 1083 | for (y = 0; y < MAXR; y++) /* Azzeramento Descrizioni */ 1084 | { 1085 | for (x = 0; x < MAXC; x++) 1086 | { 1087 | attrb[y][x] = 0; 1088 | vscreen[y][x] = 0; 1089 | } 1090 | } 1091 | attrb[0][0] = 0; 1092 | for (t = 0; t < MAXITEMS; t++) 1093 | { 1094 | scelta[t].desc[0] = 0; 1095 | scelta[t].desc[1] = 0; 1096 | scelta[t].passw[0] = 0; 1097 | scelta[t].execute[0] = 0; 1098 | scelta[t].msg[0] = 0; 1099 | scelta[t].len = 0; 1100 | scelta[t].y = 0; 1101 | scelta[t].x = 0; 1102 | } 1103 | 1104 | if ((infile = fopen (menu_file, "r")) == NULL) /* Memorizzazione File */ 1105 | return 10; 1106 | memoinc = 0; /* Azzeramento Pointer array */ 1107 | while ((c = getc (infile)) != EOF) 1108 | { 1109 | if ((c == '{') && (c0 == '$')) 1110 | { 1111 | o = 0; 1112 | while ((en = getc (infile)) != '}') 1113 | env_var[o++] = en; 1114 | 1115 | env_var[o] = '\0'; 1116 | if (getenv (env_var)) 1117 | strcpy (env_value, getenv (env_var)); 1118 | else 1119 | strcpy (env_value, ""); 1120 | 1121 | d = 0; 1122 | memoinc = memoinc - 1; 1123 | while (d < strlen (env_value)) 1124 | memofile[memoinc++] = env_value[d++]; 1125 | continue; 1126 | } 1127 | memofile[memoinc++] = c; 1128 | c0 = c; 1129 | } 1130 | memofile[memoinc] = '\0'; 1131 | fclose (infile); 1132 | 1133 | ii = 0; 1134 | c0 = 0; 1135 | y = 0; 1136 | x = 0; 1137 | r = -1; 1138 | invoce = 0; 1139 | nitems = 1; 1140 | 1141 | inc = 0; 1142 | fine = 0; 1143 | while ((c = memofile[inc++]) != EOF) 1144 | { 1145 | if (y > MAXR) 1146 | return (3); 1147 | if ((c == '[') && ((c0 == 'L') || (c0 == 'l') || (c0 == 'C') 1148 | || (c0 == 'c') || (c0 == 'R') || (c0 == 'r') 1149 | || (c0 == 'E') || (c0 == 'e') || (c0 == 'B') 1150 | || (c0 == 'b'))) 1151 | { 1152 | o = 0; 1153 | startpos = x - 1; 1154 | while ((en = memofile[inc++]) != ']') 1155 | simb_var[o++] = en; 1156 | simb_var[o] = '\0'; 1157 | move (0, 0); 1158 | x--; 1159 | for (ii = 0; ii <= strlen (simb_var) + 2; ii++) 1160 | vscreen[y][x++] = 32; 1161 | simb_pos (simb_var, y, startpos, c0); 1162 | continue; 1163 | } 1164 | if ((c0 == '$') && (c == '$')) /* Termine Parte Descrittiva */ 1165 | { 1166 | fine = 1; 1167 | vscreen[y][x - 1] = 32; 1168 | break; 1169 | } 1170 | if ((c == '^') || (invoce == 1)) 1171 | { 1172 | if ((c == '^') && (invoce == 0)) 1173 | { 1174 | invoce = 1; 1175 | ii = 0; 1176 | attrb[y][x + 1] = nitems; 1177 | vscreen[y][x++] = 32; 1178 | scelta[nitems].y = y; 1179 | scelta[nitems].x = x; 1180 | c = c0; 1181 | continue; 1182 | } 1183 | if ((c == '^') && (invoce == 1)) 1184 | { 1185 | scelta[nitems].desc[ii] = 0; 1186 | invoce = 0; 1187 | vscreen[y][x++] = 32; 1188 | c = c0; 1189 | nitems++; 1190 | continue; 1191 | } 1192 | if ((c < 32) || (c > 126)) 1193 | return (3); 1194 | if (ii > 0) 1195 | vscreen[y][x++] = c; 1196 | else 1197 | vscreen[y][x++] = toupper (c); 1198 | attrb[y][x] = nitems; 1199 | if (ii > 0) 1200 | scelta[nitems].desc[ii++] = c; 1201 | else 1202 | scelta[nitems].desc[ii++] = toupper (c); 1203 | scelta[nitems].len++; 1204 | c0 = c; 1205 | continue; 1206 | } 1207 | if (c == '-') 1208 | { 1209 | attrb[y][x] = -3; 1210 | vscreen[y][x++] = 32; 1211 | c0 = c; 1212 | continue; 1213 | } 1214 | if (c == '|') 1215 | { 1216 | attrb[y][x] = -4; 1217 | vscreen[y][x++] = 32; 1218 | c0 = c; 1219 | continue; 1220 | } 1221 | if (c == '\\') 1222 | { 1223 | attrb[y][x] = -2; 1224 | vscreen[y][x++] = 32; 1225 | c0 = c; 1226 | continue; 1227 | } 1228 | if (c == '@') 1229 | { 1230 | attrb[y][x] = -1; 1231 | vscreen[y][x++] = 32; 1232 | if (r == -1) 1233 | r = 1; 1234 | else 1235 | r = -1; 1236 | c0 = c; 1237 | continue; 1238 | } 1239 | if (c == '\n') 1240 | { 1241 | for (ii = x; ii <= 79; ii++) 1242 | vscreen[y][ii] = 32; 1243 | vscreen[y][ii] = 0; 1244 | y++; 1245 | x = 0; 1246 | continue; 1247 | } 1248 | if ((c < 32) || (c > 127)) 1249 | continue; 1250 | vscreen[y][x++] = c; 1251 | if ((c == '&') && (c0 != '$')) 1252 | { 1253 | ix = x - 1; 1254 | iy = y; 1255 | vscreen[y][x - 1] = ' '; 1256 | } 1257 | if ((c == '&') && (c0 == '$')) 1258 | { 1259 | vscreen[y][x - 1] = ' '; 1260 | vscreen[y][x - 2] = ' '; 1261 | } 1262 | if ((c == '%') && (c0 == '$')) 1263 | { 1264 | vscreen[y][x - 1] = ' '; 1265 | vscreen[y][x - 2] = ' '; 1266 | } 1267 | c0 = c; 1268 | } 1269 | 1270 | if (fine == 0) /* Caricamento dei parametri Menu */ 1271 | { 1272 | move (0, 0); 1273 | printw ("File without $$"); 1274 | refresh (); 1275 | sleep (2); 1276 | return (3); 1277 | } 1278 | while (1) 1279 | { 1280 | c = memofile[inc++]; 1281 | if (c == '\n') 1282 | break; 1283 | if (inc == memoinc) 1284 | { 1285 | alert (" Warning ", " END FILE 1 MISSING "); 1286 | return (3); 1287 | } 1288 | } 1289 | while (1) 1290 | { 1291 | if ((kk = getmemo (linea)) == -1) 1292 | { 1293 | alert (" Warning ", "END FILE 2 MISSING, CHECK MENU ITEMS "); 1294 | return (3); 1295 | } 1296 | if ((linea[0] == '%') && (linea[1] == '%')) 1297 | break; 1298 | if (linea[0] != '%') 1299 | { 1300 | alert (" Warning ", " MISSING SIMBOL %% "); 1301 | } 1302 | buf0[0] = 0; /* Azzero Indice Voci numeriche */ 1303 | buf0[1] = 0; 1304 | buf0[2] = 0; 1305 | sn = -1; 1306 | c1 = 0; 1307 | c0 = toupper (linea[1]); 1308 | if (strlen (linea) > 2) 1309 | c1 = linea[2]; 1310 | if (senum (c0) || senum (c1)) 1311 | { 1312 | buf0[0] = c0; 1313 | if (c1) 1314 | buf0[1] = c1; 1315 | sn = atoi (buf0) + 1000; 1316 | } 1317 | ii = 0; 1318 | buf1[0] = 0; 1319 | buf1[2] = 0; 1320 | for (t = 1; t <= nitems; t++) 1321 | { 1322 | if (sn == -1) 1323 | { 1324 | if (c0 == scelta[t].desc[0]) 1325 | { 1326 | ii = t; 1327 | break; 1328 | } 1329 | } 1330 | else 1331 | { 1332 | buf1[0] = scelta[t].desc[0]; 1333 | buf1[1] = scelta[t].desc[1]; 1334 | if (sn == (atoi (buf1) + 1000)) 1335 | { 1336 | ii = t; 1337 | break; 1338 | } 1339 | } 1340 | } 1341 | 1342 | /* if (ii == 0) Segnala errore se le Voci Menu non 1343 | { corrispondono ai punti %% inseriti 1344 | move(22,0); 1345 | standout(); 1346 | printw("Cross-Reference Error ..."); 1347 | standend(); 1348 | refresh(); 1349 | } 1350 | */ 1351 | kk = getmemo (linea); 1352 | if (kk == -1) 1353 | return (3); 1354 | strcpy (scelta[ii].execute, linea); 1355 | kk = getmemo (linea); 1356 | if (kk == -1) 1357 | return (3); 1358 | strcpy (scelta[ii].msg, linea); 1359 | 1360 | kk = getmemo (linea); 1361 | if (kk == -1) 1362 | return (3); 1363 | strncpy (scelta[ii].passw, linea, 11); 1364 | } 1365 | 1366 | 1367 | keydisp = 1; 1368 | for (t = 0; t <= 9; t++) 1369 | { 1370 | tfu[t][0] = 0; 1371 | pfu[t][0] = 0; 1372 | strcpy (lfu[t], " "); 1373 | } 1374 | 1375 | strcpy (titolo, ""); /* Interprete comandi Menu */ 1376 | strcpy (rvs_row, ""); 1377 | while ((kk = getmemo (linea)) != -1) 1378 | { 1379 | if (strncmp ("TITOLO=", linea, 7) == 0) 1380 | strncpy (titolo, &linea[7], 38); 1381 | if (strncmp ("RVS_ROW=", linea, 8) == 0) 1382 | strcpy (rvs_row, &linea[8]); 1383 | if (strncmp ("EDITOR=", linea, 7) == 0) 1384 | strcpy (editor, &linea[7]); 1385 | if (strncmp ("SHELL=", linea, 6) == 0) 1386 | strcpy (shell, &linea[6]); 1387 | if (strncmp ("FZ1=", linea, 4) == 0) 1388 | strcpy (tfu[0], &linea[4]); 1389 | if (strncmp ("FZ2=", linea, 4) == 0) 1390 | strcpy (tfu[1], &linea[4]); 1391 | if (strncmp ("FZ3=", linea, 4) == 0) 1392 | strcpy (tfu[2], &linea[4]); 1393 | if (strncmp ("FZ4=", linea, 4) == 0) 1394 | strcpy (tfu[3], &linea[4]); 1395 | if (strncmp ("FZ5=", linea, 4) == 0) 1396 | strcpy (tfu[4], &linea[4]); 1397 | if (strncmp ("FZ6=", linea, 4) == 0) 1398 | strcpy (tfu[5], &linea[4]); 1399 | if (strncmp ("FZ7=", linea, 4) == 0) 1400 | strcpy (tfu[6], &linea[4]); 1401 | if (strncmp ("FZ8=", linea, 4) == 0) 1402 | strcpy (tfu[7], &linea[4]); 1403 | if (strncmp ("FZ9=", linea, 4) == 0) 1404 | strcpy (tfu[8], &linea[4]); 1405 | if (strncmp ("FZ10=", linea, 5) == 0) 1406 | strcpy (tfu[9], &linea[5]); 1407 | if (strncmp ("ET1=", linea, 4) == 0) 1408 | strncpy (lfu[0], &linea[4], 18); 1409 | if (strncmp ("ET2=", linea, 4) == 0) 1410 | strncpy (lfu[1], &linea[4], 18); 1411 | if (strncmp ("ET3=", linea, 4) == 0) 1412 | strncpy (lfu[2], &linea[4], 18); 1413 | if (strncmp ("ET4=", linea, 4) == 0) 1414 | strncpy (lfu[3], &linea[4], 18); 1415 | if (strncmp ("ET5=", linea, 4) == 0) 1416 | strncpy (lfu[4], &linea[4], 18); 1417 | if (strncmp ("ET6=", linea, 4) == 0) 1418 | strncpy (lfu[5], &linea[4], 18); 1419 | if (strncmp ("ET7=", linea, 4) == 0) 1420 | strncpy (lfu[6], &linea[4], 18); 1421 | if (strncmp ("ET8=", linea, 4) == 0) 1422 | strncpy (lfu[7], &linea[4], 18); 1423 | if (strncmp ("ET9=", linea, 4) == 0) 1424 | strncpy (lfu[8], &linea[4], 12); 1425 | if (strncmp ("ET10=", linea, 5) == 0) 1426 | strncpy (lfu[9], &linea[5], 6); 1427 | if (strncmp ("PW1=", linea, 4) == 0) 1428 | strcpy (pfu[0], &linea[4]); 1429 | if (strncmp ("PW2=", linea, 4) == 0) 1430 | strcpy (pfu[1], &linea[4]); 1431 | if (strncmp ("PW3=", linea, 4) == 0) 1432 | strcpy (pfu[2], &linea[4]); 1433 | if (strncmp ("PW4=", linea, 4) == 0) 1434 | strcpy (pfu[3], &linea[4]); 1435 | if (strncmp ("PW5=", linea, 4) == 0) 1436 | strcpy (pfu[4], &linea[4]); 1437 | if (strncmp ("PW6=", linea, 4) == 0) 1438 | strcpy (pfu[5], &linea[4]); 1439 | if (strncmp ("PW7=", linea, 4) == 0) 1440 | strcpy (pfu[6], &linea[4]); 1441 | if (strncmp ("PW8=", linea, 4) == 0) 1442 | strcpy (pfu[7], &linea[4]); 1443 | if (strncmp ("PW9=", linea, 4) == 0) 1444 | strcpy (pfu[8], &linea[4]); 1445 | if (strncmp ("PW10=", linea, 5) == 0) 1446 | strcpy (pfu[9], &linea[5]); 1447 | if (strncmp ("KEYDISP", linea, 7) == 0) 1448 | keydisp = 1; 1449 | if (strncmp ("NOKEYDISP", linea, 9) == 0) 1450 | keydisp = 0; 1451 | } 1452 | if (time_flag) 1453 | orolog (); 1454 | return 0; 1455 | } 1456 | 1457 | void 1458 | dispmenu () /* MOSTRA LA VIDEATA MENU */ 1459 | { 1460 | /* ====================== */ 1461 | int i, t, r, ia; 1462 | int scan_pointer = 0; 1463 | int item = 0, a = 0; 1464 | r = -1; 1465 | if (strlen (rvs_row) > 1) 1466 | { 1467 | while (scan_pointer < strlen (rvs_row)) 1468 | { 1469 | if (rvs_row[scan_pointer] == ',') 1470 | { 1471 | rvs_tmp[item][a] = '\0'; 1472 | scan_pointer++; 1473 | item++; 1474 | a = 0; 1475 | } 1476 | else 1477 | { 1478 | rvs_tmp[item][a] = rvs_row[scan_pointer++]; 1479 | a++; 1480 | } 1481 | } 1482 | rvs_tmp[item][a] = '\0'; 1483 | for (ia = 0; ia <= item; ia++) 1484 | { 1485 | rvs_r = atoi (rvs_tmp[ia]); 1486 | attrb[rvs_r][0] = -1; 1487 | attrb[rvs_r][79] = -1; 1488 | } 1489 | } 1490 | 1491 | for (t = 0; t < MAXR; t++) /* Display della Pagina */ 1492 | { 1493 | move (t, 0); 1494 | for (i = 0; vscreen[t][i]; i++) 1495 | { 1496 | if (attrb[t][i] == -1) 1497 | { 1498 | if (r == -1) 1499 | { 1500 | standout (); 1501 | r = 1; 1502 | } 1503 | else 1504 | { 1505 | addch (vscreen[t][i]); 1506 | standend (); 1507 | r = -1; 1508 | } 1509 | addch (vscreen[t][i]); 1510 | } 1511 | else 1512 | { 1513 | if (attrb[t][i] == -3) 1514 | { 1515 | grafic (ROW); 1516 | continue; 1517 | } 1518 | if (attrb[t][i] == -4) 1519 | { 1520 | grafic (COL); 1521 | continue; 1522 | } 1523 | if (attrb[t][i] == -2) 1524 | { 1525 | if (r == -1) 1526 | { 1527 | standout (); 1528 | addch (vscreen[t][i]); 1529 | standend (); 1530 | } 1531 | else 1532 | { 1533 | standend (); 1534 | addch (vscreen[t][i]); 1535 | standout (); 1536 | } 1537 | } 1538 | else 1539 | addch (vscreen[t][i]); 1540 | } 1541 | } 1542 | } 1543 | 1544 | if (keydisp == 1) /* Display Label Tasto Funz. */ 1545 | { 1546 | for (t = 0; t <= 9; t++) 1547 | { 1548 | if (tfu[t][0]) 1549 | { 1550 | standout (); 1551 | move (23, (t * 8)); 1552 | if (t < 9) 1553 | printw ("F%.1d", t + 1); 1554 | else 1555 | printw ("F0"); 1556 | standend (); 1557 | if (lfu[t][0]) 1558 | addstr (lfu[t]); 1559 | refresh (); 1560 | } 1561 | } 1562 | } 1563 | refresh (); 1564 | smove (iy, ix); 1565 | if (time_flag) 1566 | orolog (); 1567 | if (mnuname_flag) 1568 | menu_name_disp (); 1569 | if (title_flag) 1570 | { 1571 | if (title_g == 'L') 1572 | move (title_y, title_x); 1573 | if (title_g == 'R') 1574 | move (title_y, title_x - strlen (titolo)); 1575 | if (title_g == 'C') 1576 | move (title_y, 38 - (strlen (titolo) / 2) + 1); 1577 | if (title_g == 'E') 1578 | move (title_y, 79 - (strlen (titolo) + 2)); 1579 | if (title_g == 'B') 1580 | move (title_y, 0); 1581 | if (title_rvs == ON) 1582 | standout (); 1583 | printw (" %s ", titolo); 1584 | standend (); 1585 | refresh (); 1586 | } 1587 | if (mnutrace_flag) 1588 | mnutrace (); 1589 | refresh (); 1590 | } 1591 | 1592 | int selectnext (int c) /* Cerca Argomento successivo da Frecce */ 1593 | { 1594 | int y, x; 1595 | y = scelta[curitem].y; 1596 | x = scelta[curitem].x; 1597 | if (c == C_U) 1598 | { 1599 | y--; 1600 | do 1601 | { 1602 | if (attrb[y][x] > 0) 1603 | { 1604 | curitem = attrb[y][x]; 1605 | break; 1606 | } 1607 | } 1608 | while (--y); 1609 | return (curitem); 1610 | } 1611 | if (c == C_D) 1612 | { 1613 | y++; 1614 | do 1615 | { 1616 | if (attrb[y][x] > 0) 1617 | { 1618 | curitem = attrb[y][x]; 1619 | break; 1620 | } 1621 | } 1622 | while ((++y) < MAXR); 1623 | return (curitem); 1624 | } 1625 | if (c == C_R) 1626 | { 1627 | while (attrb[y][x++] > 0); 1628 | do 1629 | { 1630 | if (attrb[y][x] > 0) 1631 | { 1632 | curitem = attrb[y][x]; 1633 | break; 1634 | } 1635 | } 1636 | while ((++x) < MAXC); 1637 | return (curitem); 1638 | } 1639 | if (c == C_L) 1640 | { 1641 | x--; 1642 | do 1643 | { 1644 | if (attrb[y][x] > 0) 1645 | { 1646 | curitem = attrb[y][x]; 1647 | break; 1648 | } 1649 | } 1650 | while ((--x) >= 0); 1651 | return (curitem); 1652 | } 1653 | return (curitem); 1654 | } 1655 | 1656 | int getlineext (char *tamp) /* Memorizza una riga fino al new-line */ 1657 | { 1658 | int ii, c; 1659 | ii = 0; 1660 | while ((c = getc (infile)) != EOF) 1661 | { 1662 | if (c == '\n') 1663 | { 1664 | tamp[ii] = 0; 1665 | return (ii); 1666 | } 1667 | tamp[ii++] = c; 1668 | tamp[ii] = 0; 1669 | } 1670 | return (EOF); 1671 | } 1672 | 1673 | int 1674 | getmemo (char *tamp) /* Memorizza una riga dall'array file */ 1675 | { 1676 | int ii, c; 1677 | ii = 0; 1678 | while (inc != memoinc) 1679 | { 1680 | c = memofile[inc++]; 1681 | if (c == '\n') 1682 | { 1683 | tamp[ii] = 0; 1684 | return (ii); 1685 | } 1686 | tamp[ii++] = c; 1687 | tamp[ii] = 0; 1688 | } 1689 | return (-1); 1690 | } 1691 | 1692 | /* 1693 | chkentry() 1694 | { 1695 | char cmpred[40]; 1696 | char tmp[40]; 1697 | 1698 | win(" INSERIMENTO ", 8,15,12,65); 1699 | standout(); 1700 | move(10,17); 1701 | printw(" Valore variabile : "); 1702 | standend(); 1703 | printw(" "); 1704 | move(10,38); 1705 | refresh(); 1706 | getentry(cmpred); 1707 | standend(); 1708 | return; 1709 | } 1710 | */ 1711 | int chkpass (int tipo) /* Controllo parola Chiave */ 1712 | { 1713 | char cmpred[40]; /* Variabile utilizzata per paragone */ 1714 | char tmp_passwd[26]; 1715 | int ii = 0; 1716 | 1717 | switch (tipo) 1718 | { 1719 | case MENU: 1720 | strcpy (tmp_passwd, scelta[curitem].passw); 1721 | break; 1722 | case SHELL: 1723 | strcpy (tmp_passwd, sh_passwd); 1724 | break; 1725 | case EDIT: 1726 | strcpy (tmp_passwd, edit_passwd); 1727 | break; 1728 | case SUPER_MENU: 1729 | strcpy (tmp_passwd, super_passwd); 1730 | break; 1731 | case PASSWD_MODE: 1732 | strcpy (tmp_passwd, super_passwd); 1733 | break; 1734 | default: 1735 | strcpy (tmp_passwd, pfu[tipo]); 1736 | break; 1737 | } 1738 | 1739 | while (ii <= strlen (tmp_passwd)) 1740 | { 1741 | tmp_passwd[ii] = toupper (tmp_passwd[ii]); 1742 | ii++; 1743 | } 1744 | 1745 | tmp_passwd[ii] = '\0'; 1746 | 1747 | win (" RESERVED AREA ", 8, 15, 12, 65); 1748 | move (12, 17); 1749 | printw (" F4 - Esce "); 1750 | standend (); 1751 | move (10, 17); 1752 | printw (" Enter password : "); 1753 | standout (); 1754 | printw (" "); 1755 | move (10, 38); 1756 | refresh (); 1757 | getpasswd (cmpred); 1758 | if (strcmp (cmpred, "ABORT") == 0) 1759 | return 1; 1760 | standout (); 1761 | if (strcmp (cmpred, tmp_passwd) != 0) 1762 | { 1763 | alert (" Warning ", " WRONG PASSWORD "); 1764 | clear (); 1765 | dispmenu (); 1766 | selez (1); 1767 | return 1; 1768 | } 1769 | else 1770 | { 1771 | return 0; 1772 | } 1773 | } 1774 | 1775 | int chkinit () /* Controllo parola Chiave */ 1776 | { 1777 | char cmpred[40]; /* Variabile utilizzata per paragone */ 1778 | 1779 | win (" RESERVED AREA ", 8, 15, 12, 65); 1780 | move (12, 17); 1781 | printw (" F4 - Esce "); 1782 | standend (); 1783 | move (10, 17); 1784 | printw (" Enter password : "); 1785 | standout (); 1786 | printw (" "); 1787 | move (10, 38); 1788 | refresh (); 1789 | getpasswd (cmpred); 1790 | if (ricerca_passwd(cmpred)) 1791 | { 1792 | alert (ability_user, " ACCESS GRANTED "); 1793 | return 1; 1794 | } 1795 | else 1796 | { 1797 | alert (" Access Denied ", 1798 | msg_USER_DONT_HAVE_PERM); 1799 | return 0; 1800 | } 1801 | } 1802 | 1803 | int ricerca_passwd (char *etichetta) 1804 | { 1805 | int opi; 1806 | int a = 0; 1807 | char tmp_linea[256]; 1808 | char linea[256]; 1809 | 1810 | if ((infile = fopen ("qmenu.cfg", "r")) == NULL) 1811 | { 1812 | history_string ("ERROR, Don't open qmenu.cfg"); 1813 | return 10; 1814 | } 1815 | else 1816 | { 1817 | while ((opi = getlineext (linea)) != EOF) 1818 | { 1819 | a = 0; 1820 | while (linea[a] != 0) 1821 | { 1822 | if (linea[a] != '=') 1823 | { 1824 | tmp_linea[a] = linea[a]; 1825 | ++a; 1826 | } 1827 | else 1828 | { 1829 | break; 1830 | } 1831 | } 1832 | tmp_linea[a] = '\0'; 1833 | 1834 | if (strcmp (etichetta, tmp_linea) == 0) 1835 | { 1836 | strcpy (ability_user, &linea[a + 1]); 1837 | fclose (infile); 1838 | return 1; 1839 | } 1840 | 1841 | } 1842 | fclose (infile); 1843 | return 0; 1844 | } 1845 | } 1846 | 1847 | // Mostra selezioni tastiera a video 1848 | void inpsel (int op) 1849 | { 1850 | char buf1[3]; 1851 | buf1[2] = 0; 1852 | if (op != 1) 1853 | { 1854 | smove (iy, ix - 1); 1855 | printw ("??"); 1856 | refresh (); 1857 | return; 1858 | } 1859 | 1860 | if (senum (scelta[curitem].desc[0]) || senum (scelta[curitem].desc[1])) 1861 | { 1862 | buf1[0] = scelta[curitem].desc[0]; 1863 | buf1[1] = scelta[curitem].desc[1]; 1864 | smove (iy, ix - 1); 1865 | printw ("%.2d", atoi (buf1)); 1866 | } 1867 | else 1868 | { 1869 | smove (iy, ix - 1); 1870 | addch (' '); 1871 | addch (scelta[curitem].desc[0]); 1872 | } 1873 | } 1874 | 1875 | void selez (int op) /* Attiva e Disattiva Evidenziatore scelte */ 1876 | { 1877 | if (curitem == 0) 1878 | return; 1879 | move (scelta[curitem].y, scelta[curitem].x); 1880 | if (op) 1881 | standout (); 1882 | else 1883 | standend (); 1884 | printw ("%s", scelta[curitem].desc); 1885 | standend (); 1886 | move (scelta[curitem].y, scelta[curitem].x - 1); 1887 | if (op) 1888 | addch (LEFT_SYMBOL); 1889 | else 1890 | addch (' '); 1891 | move (scelta[curitem].y, scelta[curitem].x + strlen (scelta[curitem].desc)); 1892 | if (op) 1893 | addch (RIGHT_SYMBOL); 1894 | else 1895 | addch (' '); 1896 | standend (); 1897 | refresh (); 1898 | } 1899 | 1900 | void history_string (char *message) /* Memorizza message in un LOGFILE */ 1901 | { 1902 | 1903 | struct stat stbuf; 1904 | 1905 | char datario[10]; 1906 | /* 1907 | int c; 1908 | 1909 | c=setuid(0); 1910 | */ 1911 | 1912 | dataoggi (datario); 1913 | if (stat ("qmenu.log", &stbuf) == -1) /* Se file non c'e' lo crea a 0 bytes */ 1914 | { 1915 | system ("echo \"\" > qmenu.log"); 1916 | return; 1917 | } 1918 | if (stbuf.st_size > logfile_dim) /* Se dim. max superata copio in bak */ 1919 | system ("mv qmenu.log qmenu.log.bak"); 1920 | 1921 | if ((ofile = fopen ("qmenu.log", "a+")) != NULL) 1922 | { 1923 | fprintf (ofile, "%-10s, ", utente); 1924 | if (passwd_mode) 1925 | fprintf (ofile, "%s, ", ability_user); 1926 | fprintf (ofile, "%-10s, ", porta); 1927 | fprintf (ofile, "%s, ", datario); 1928 | 1929 | fprintf (ofile, "%d.%d.%d\n", tptr->tm_hour, tptr->tm_min, 1930 | tptr->tm_sec); 1931 | fprintf (ofile, "%-13s, ", imenu[ipmenu]); 1932 | fprintf (ofile, "%s", message); 1933 | fprintf (ofile, "\n"); 1934 | } 1935 | else 1936 | { 1937 | alert (" Warning ", "Don't write log"); 1938 | clear (); 1939 | dispmenu (); 1940 | selez (1); 1941 | refresh (); 1942 | } 1943 | fclose (ofile); 1944 | } 1945 | 1946 | void orolog () /* Stampa Orario a Video */ 1947 | { 1948 | 1949 | int ly, lx; 1950 | 1951 | t1 = time ((time_t *) 0); 1952 | 1953 | tptr = localtime (&t1); 1954 | 1955 | getyx (stdscr, ly, lx); 1956 | if (time_g == 'L') 1957 | move (time_y, time_x); 1958 | if (time_g == 'R') 1959 | move (time_y, time_x - 5); 1960 | if (time_g == 'C') 1961 | move (time_y, 38 - 5); 1962 | if (time_g == 'E') 1963 | move (time_y, 79 - 5); 1964 | if (time_g == 'B') 1965 | move (time_y, 0); 1966 | if (time_rvs == ON) 1967 | standout (); 1968 | else 1969 | standend (); 1970 | 1971 | printw ("%.2d:%.2d\n", tptr->tm_hour, tptr->tm_min); 1972 | 1973 | standend (); 1974 | move (ly, lx); 1975 | refresh (); 1976 | intflg = 1; 1977 | } 1978 | 1979 | // Stampa il nome del menu a Video 1980 | void menu_name_disp () 1981 | { 1982 | if (mnuname_g == 'L') 1983 | move (mnuname_y, mnuname_x); 1984 | if (mnuname_g == 'R') 1985 | move (mnuname_y, mnuname_x - strlen (imenu[ipmenu])); 1986 | if (mnuname_g == 'C') 1987 | move (mnuname_y, 38 - (strlen (imenu[ipmenu]) / 2) + 1); 1988 | if (mnuname_g == 'E') 1989 | move (mnuname_y, 79 - (strlen (imenu[ipmenu]) + 2)); 1990 | if (mnuname_g == 'B') 1991 | move (mnuname_y, 0); 1992 | if (mnuname_rvs) 1993 | standout (); 1994 | printw (" %s ", imenu[ipmenu]); 1995 | 1996 | standend (); 1997 | refresh (); 1998 | } 1999 | 2000 | /* Scarica residuo tastiera dopo esecuzione comando solo SCO */ 2001 | void scarica () 2002 | { 2003 | #ifdef SCO 2004 | while (rdchk (fileno (stdin))) 2005 | getc (stdin); 2006 | #endif 2007 | return; 2008 | } 2009 | 2010 | void 2011 | templim () /* Uscita da programma se l'utente non preme tasti */ 2012 | { 2013 | alert (" Warning ", 2014 | " TEMPO MASSIMO DI INATTIVITA' RAGGIUNTO, ESECUZIONE TERMINATA "); 2015 | sleep (9); 2016 | endwin (); 2017 | sleep (1); 2018 | exit (0); 2019 | } 2020 | 2021 | /* Trap Interruzione Utente (^C o DEL , BREAK , etc ) */ 2022 | /* 2023 | void fine() 2024 | { 2025 | switch(ON) 2026 | { 2027 | case 1: 2028 | alert(" Warning "," ESECUZIONE TERMINATA, SEGNALE UTENTE RICEVUTO "); 2029 | resetty(); 2030 | sleep(1); 2031 | endwin(); 2032 | sleep(1); 2033 | exit(9); 2034 | break; 2035 | case 2: 2036 | resetty(); 2037 | sleep(1); 2038 | endwin(); 2039 | perror("FPE ERROR !!!!"); 2040 | sleep(1); 2041 | exit(SIGFPE); 2042 | break; 2043 | case 3: 2044 | resetty(); 2045 | sleep(1); 2046 | endwin(); 2047 | sleep(1); 2048 | exit(SIGBUS); 2049 | break; 2050 | case 4: 2051 | endwin(); 2052 | alert(" Warning ", " ERRORE DI MEMORIA, ESECUZIONE SOSPESA "); 2053 | abort(SIGSEGV); 2054 | break; 2055 | case 5: 2056 | alert(" Warning ", " SEGNALE INTERRUZIONE ESTERNO RICEVUTO "); 2057 | resetty(); 2058 | sleep(1); 2059 | endwin(); 2060 | sleep(1); 2061 | exit(SIGTERM); 2062 | break; 2063 | } 2064 | } 2065 | */ 2066 | 2067 | void 2068 | fine1 () /* Trap Interruzione Utente (^C o DEL , BREAK , etc ) */ 2069 | { 2070 | alert (" Warning ", " SEGNALE UTENTE RICEVUTO, ESECUZIONE TERMINATA "); 2071 | resetty (); 2072 | sleep (1); 2073 | endwin (); 2074 | sleep (1); 2075 | exit (9); 2076 | } 2077 | 2078 | void 2079 | fine2 () 2080 | { 2081 | resetty (); 2082 | sleep (1); 2083 | endwin (); 2084 | perror ("FPE ERROR !!!!"); 2085 | sleep (1); 2086 | exit (SIGFPE); 2087 | } 2088 | 2089 | void 2090 | fine3 () 2091 | { 2092 | resetty (); 2093 | sleep (1); 2094 | endwin (); 2095 | sleep (1); 2096 | exit (SIGBUS); 2097 | } 2098 | 2099 | void fine4 () 2100 | { 2101 | alert (" Warning ", " ERRORE DI MEMORIA, ESECUZIONE SOSPESA "); 2102 | endwin (); 2103 | abort (); 2104 | } 2105 | 2106 | void fine5 () 2107 | { 2108 | alert (" Warning ", " SEGNALE ESTERNO RICEVUTO, ESECUZIONE TERMINATA "); 2109 | refresh (); 2110 | resetty (); 2111 | sleep (1); 2112 | endwin (); 2113 | sleep (1); 2114 | exit (SIGTERM); 2115 | } 2116 | 2117 | /* Slow move , move ritardata per problemi di refresh */ 2118 | void smove (int y, int x) 2119 | { 2120 | if (y < 0) 2121 | y = 0; 2122 | if (y > 79) 2123 | y = 23; 2124 | if (x < 0) 2125 | x = 0; 2126 | if (x > 79) 2127 | x = 0; 2128 | move (0, 0); 2129 | refresh (); 2130 | move (y, x); 2131 | } 2132 | 2133 | char * cercadop (char *string0, char *string1) 2134 | { 2135 | int t; 2136 | for (t = 0; t <= (strlen (string0) - strlen (string1)); t++) 2137 | if (strncmp (&string0[t], string1, strlen (string1)) == 0) 2138 | return (&string0[t + strlen (string1)]); 2139 | return (NULSTRING); 2140 | } 2141 | 2142 | int 2143 | senum (numero) /* Verifica se l'argomento e' un numero */ 2144 | { 2145 | if ((numero >= '0') && (numero <= '9')) 2146 | return (1); 2147 | else 2148 | return (0); 2149 | } 2150 | 2151 | int esegui (char *comando) /* Esecutore comandi in ambiente shell prescelto */ 2152 | { 2153 | if (strncmp (comando, "prsuper", 7) == 0) 2154 | { 2155 | selspool (SUPER); 2156 | return (0); 2157 | } 2158 | if (strncmp (comando, "config", 7) == 0) 2159 | { 2160 | display_config (); 2161 | return (0); 2162 | } 2163 | if (strncmp (comando, "pruser", 6) == 0) 2164 | { 2165 | selspool (USER); 2166 | return (0); 2167 | } 2168 | /* 2169 | if (strncmp(comando,"getentry",8) == 0) 2170 | { 2171 | chkentry(); 2172 | return(0); 2173 | } 2174 | */ 2175 | signal (SIGINT, SIG_DFL); 2176 | endwin (); 2177 | if (comando[0] == '~') 2178 | { 2179 | printw ("%s", comando); 2180 | refresh (); 2181 | junk = getch (); 2182 | exit (system (&comando[1])); 2183 | } 2184 | system (comando); 2185 | initscr (); 2186 | noecho (); 2187 | cbreak (); 2188 | scarica (); 2189 | crmode (); 2190 | noecho (); 2191 | refresh (); 2192 | standend (); 2193 | signal (SIGINT, fine1); 2194 | return 0; 2195 | } 2196 | 2197 | void selspool (int type_sel) /* Selezione le stampanti */ 2198 | { 2199 | int nprts; 2200 | int row_pos, col_pos; 2201 | char prts[16][32]; 2202 | char prlist[256]; 2203 | int ia = 0, iu, max_len = 0, c, t, scan_pointer = 0, a = 0, item = 0; 2204 | nprts = 0; 2205 | 2206 | if (type_sel == SUPER) 2207 | { 2208 | if (super) 2209 | strcpy (prlist, prsuper); 2210 | else 2211 | { 2212 | alert (" Warning ", 2213 | " STAMPANTI SUPERUTENTE NON DEFINITE NELLA VARIABILE PRSUPER "); 2214 | return; 2215 | } 2216 | } 2217 | if (type_sel == USER) 2218 | { 2219 | if (user) 2220 | strcpy (prlist, pruser); 2221 | else 2222 | { 2223 | alert (" Warning ", 2224 | " STAMPANTI UTENTE NON DEFINITE NELLA VARIABILE PRUSER "); 2225 | return; 2226 | } 2227 | } 2228 | 2229 | while (scan_pointer < strlen (prlist)) 2230 | { 2231 | if (prlist[scan_pointer] == ',') 2232 | { 2233 | prts[item][a] = '\0'; 2234 | scan_pointer++; 2235 | item++; 2236 | a = 0; 2237 | } 2238 | else 2239 | { 2240 | prts[item][a] = prlist[scan_pointer++]; 2241 | a++; 2242 | } 2243 | } 2244 | 2245 | for (ia = 0, max_len = 0; ia < item; ia++) 2246 | { 2247 | if (strlen (prts[ia]) > max_len) 2248 | max_len = strlen (prts[ia]); 2249 | } 2250 | 2251 | nprts = item + 1; 2252 | prts[item][a] = '\0'; 2253 | if (max_len < 10) 2254 | max_len = 11; 2255 | row_pos = 12 - (nprts / 2) - 2; 2256 | col_pos = 38 - (max_len / 2); 2257 | win (" Printer ", row_pos - 1, col_pos - 2, row_pos + nprts, 2258 | col_pos + max_len); 2259 | standend (); 2260 | for (iu = 0; iu < nprts; iu++) 2261 | { 2262 | move (row_pos + iu, col_pos - 1); 2263 | printw (" %s", prts[iu]); 2264 | } 2265 | standout (); 2266 | 2267 | for (t = 0; t < nprts; t++) 2268 | if (strcmp (spoolernm, prts[t]) == 0) 2269 | break; 2270 | if (t >= nprts) 2271 | t = 0; 2272 | standend (); 2273 | move (row_pos + t, col_pos - 1); 2274 | printw ("%c", LEFT_SYMBOL); 2275 | standout (); 2276 | move (row_pos + t, col_pos); 2277 | printw (prts[t]); 2278 | while (1) 2279 | { 2280 | refresh (); 2281 | c = getkey (); 2282 | if ((c == C_U) || (c == '8')) 2283 | { 2284 | standend (); 2285 | move (row_pos + t, col_pos - 1); 2286 | addstr (" "); 2287 | move (row_pos + t, col_pos); 2288 | printw (prts[t]); 2289 | t--; 2290 | if (t < 0) 2291 | t = nprts - 1; 2292 | move (row_pos + t, col_pos - 1); 2293 | printw ("%c", LEFT_SYMBOL); 2294 | standout (); 2295 | move (row_pos + t, col_pos); 2296 | printw (prts[t]); 2297 | standend (); 2298 | } 2299 | if ((c == C_D) || (c == '2')) 2300 | { 2301 | standend (); 2302 | move (row_pos + t, col_pos - 1); 2303 | addstr (" "); 2304 | move (row_pos + t, col_pos); 2305 | printw (prts[t]); 2306 | t++; 2307 | if (t >= nprts) 2308 | t = 0; 2309 | move (row_pos + t, col_pos - 1); 2310 | printw ("%c", LEFT_SYMBOL); 2311 | standout (); 2312 | move (row_pos + t, col_pos); 2313 | printw (prts[t]); 2314 | standend (); 2315 | } 2316 | if (c == NL) 2317 | { 2318 | standend (); 2319 | break; 2320 | } 2321 | } 2322 | strcpy (lpdestval, "LPDEST="); 2323 | strcat (lpdestval, prts[t]); 2324 | strcpy (lpdestenv, prts[t]); 2325 | putenv (lpdestval); 2326 | ia = loadmenu (imenu[ipmenu]); 2327 | return; 2328 | } 2329 | 2330 | // Estrazione per Help della label 2331 | // ================================ 2332 | int ext (char *label) 2333 | { 2334 | char head[500]; 2335 | signed char c; 2336 | int h; 2337 | int a = 0, kk = 0; 2338 | int found = 0; 2339 | 2340 | if ((helpfile = fopen (hlp_filename, "r")) == NULL) 2341 | { 2342 | return 1; 2343 | } 2344 | 2345 | // Scansione file 2346 | while ((c = getc (helpfile)) != EOF) 2347 | { 2348 | if (c == '[') 2349 | { 2350 | while ((c = getc (helpfile)) != ']') 2351 | head[a++] = c; 2352 | head[a] = '\0'; 2353 | a = 0; 2354 | if (strcmp (head, label) == 0) 2355 | { 2356 | while (h != '[') 2357 | { 2358 | found = 1; 2359 | a = getlineext (help_line[kk]); 2360 | h = help_line[kk][0]; 2361 | kk++; 2362 | } 2363 | help_item = --kk; 2364 | help_line[kk][0] = '\0'; 2365 | } 2366 | } 2367 | 2368 | } 2369 | fclose (helpfile); 2370 | if (found) 2371 | { 2372 | helper (); 2373 | for (a = 0; a != help_item; a++) 2374 | help_line[a][0] = '\0'; 2375 | } 2376 | return 0; 2377 | 2378 | } 2379 | 2380 | void helper () 2381 | { 2382 | int a, j = 0; 2383 | int x = 0, ch; 2384 | int c = 0, r = 0; 2385 | 2386 | for (a = 0; a != help_item; a++) 2387 | { 2388 | if (strlen (help_line[x]) > j) 2389 | j = strlen (help_line[x]); 2390 | x++; 2391 | } 2392 | x--; 2393 | 2394 | win (" HELP ", 2395 | X_COORD - 1, 2396 | Y_COORD - 2, 2397 | X_COORD + MAX_ROW, 2398 | Y_COORD + MAX_COL); 2399 | 2400 | move (X_COORD + MAX_ROW, Y_COORD + 3); 2401 | printw (" F4 - Esce "); 2402 | move (X_COORD + MAX_ROW, Y_COORD + 41); 2403 | printw (" <=Sx, >=Dx, ^=Su, v=Giu' "); 2404 | 2405 | disphelp (1, 0, 0, 0); 2406 | 2407 | while (1) 2408 | { 2409 | move (X_COORD - 1, Y_COORD + 55); 2410 | printw ("[%3i,%3i]", r, c); 2411 | ch = getkey (); 2412 | 2413 | if (ch == HOME) 2414 | { 2415 | c = 0; 2416 | r = 0; 2417 | disphelp (1, 0, 0, 0); 2418 | } 2419 | 2420 | if (ch == END) 2421 | { 2422 | c = 0; 2423 | if (help_item < MAX_ROW) 2424 | beep (); 2425 | else 2426 | { 2427 | beep (); 2428 | r = x - MAX_ROW + 1; 2429 | disphelp (1, 0, r, c); 2430 | } 2431 | } 2432 | 2433 | if (ch == C_R) 2434 | { 2435 | if (c + MAX_COL < j) 2436 | disphelp (1, 0, r, ++c); 2437 | else 2438 | beep (); 2439 | } 2440 | 2441 | if (ch == C_L) 2442 | { 2443 | if (c != 0) 2444 | disphelp (1, 0, r, --c); 2445 | else 2446 | beep (); 2447 | } 2448 | 2449 | if (ch == C_D) 2450 | { 2451 | if (r + (MAX_ROW - 1) < x) 2452 | disphelp (1, 0, ++r, c); 2453 | else 2454 | beep (); 2455 | } 2456 | if (ch == C_U) 2457 | { 2458 | if (r > 0) 2459 | disphelp (1, 0, --r, c); 2460 | else 2461 | beep (); 2462 | } 2463 | if (ch == PGDN) 2464 | { 2465 | if (help_item < MAX_ROW) 2466 | beep (); 2467 | else 2468 | { 2469 | if (x - (r + MAX_ROW) < MAX_ROW) 2470 | { 2471 | r = x - MAX_ROW + 1; 2472 | beep (); 2473 | } 2474 | else 2475 | r = r + MAX_ROW; 2476 | disphelp (1, 0, r, c); 2477 | } 2478 | } 2479 | if (ch == PGUP) 2480 | { 2481 | if (r < MAX_ROW) 2482 | { 2483 | beep (); 2484 | r = 0; 2485 | } 2486 | else 2487 | r = r - MAX_ROW; 2488 | disphelp (1, 0, r, c); 2489 | } 2490 | if (ch == FZ4) 2491 | return; 2492 | 2493 | } 2494 | } 2495 | 2496 | void disphelp (int row, int col, int first_row, int first_col) 2497 | { 2498 | int g, k; 2499 | int tot_righe; 2500 | char buffer[255]; 2501 | int lun; 2502 | 2503 | for (g = first_row, tot_righe = 0; tot_righe != MAX_ROW; g++, tot_righe++) 2504 | { 2505 | if (strlen (&help_line[g][0]) < MAX_COL) 2506 | lun = strlen (&help_line[g][0]); 2507 | else 2508 | lun = MAX_COL; 2509 | 2510 | strncpy (buffer, &help_line[g][first_col], lun); 2511 | buffer[lun] = '\0'; 2512 | if (strlen (buffer) < MAX_COL) 2513 | { 2514 | for (k = strlen (buffer); k != MAX_COL; k++) 2515 | buffer[k] = 32; 2516 | buffer[k] = '\0'; 2517 | 2518 | } 2519 | move (X_COORD + tot_righe, Y_COORD); 2520 | addstr (buffer); 2521 | } 2522 | refresh (); 2523 | } 2524 | 2525 | /* ========================================================================== */ 2526 | 2527 | void alert (char *titolo, char *testo) /* Giustifica al centro una finestra di */ 2528 | { 2529 | /* allarme */ 2530 | int len_text; 2531 | int start_col, ii; 2532 | 2533 | len_text = strlen (testo); 2534 | start_col = 40 - (len_text / 2); 2535 | /* standout(); */ 2536 | move (8, start_col); 2537 | grafic (TL); 2538 | for (ii = 1; ii <= len_text; ii++) 2539 | grafic (ROW); 2540 | grafic (TR); 2541 | move (9, start_col - 1); 2542 | grafic (SHADOW); 2543 | move (9, start_col); 2544 | grafic (COL); 2545 | for (ii = 1; ii <= len_text; ii++) 2546 | printw (" "); 2547 | grafic (COL); 2548 | 2549 | move (10, start_col - 1); 2550 | grafic (SHADOW); 2551 | grafic (COL); 2552 | printw ("%s", testo); 2553 | grafic (COL); 2554 | 2555 | move (11, start_col - 1); 2556 | grafic (SHADOW); 2557 | grafic (COL); 2558 | for (ii = 1; ii <= len_text; ii++) 2559 | printw (" "); 2560 | grafic (COL); 2561 | 2562 | move (12, start_col - 1); 2563 | grafic (SHADOW); 2564 | grafic (BL); 2565 | for (ii = 1; ii <= len_text; ii++) 2566 | grafic (ROW); 2567 | grafic (BR); 2568 | move (13, start_col - 1); 2569 | grafic (SHADOW); 2570 | for (ii = 1; ii <= len_text + 1; ii++) 2571 | grafic (SHADOW); 2572 | /* standend(); */ 2573 | standout (); 2574 | move (8, 40 - strlen (titolo) / 2); 2575 | printw ("%s", titolo); 2576 | standend (); 2577 | refresh (); 2578 | beep (); 2579 | sleep (2); 2580 | } 2581 | 2582 | void win (char *titolo, int x, int y, int z, int k) /* Finestra con titolo */ 2583 | { 2584 | int largh = 0, altez = 0; 2585 | int ii = 0, ia = 0; 2586 | 2587 | largh = k - y; 2588 | altez = z - x; 2589 | 2590 | move (x, y); 2591 | grafic (TL); 2592 | for (ii = 1; ii <= largh; ii++) 2593 | grafic (ROW); 2594 | grafic (TR); 2595 | 2596 | for (ii = 1; ii < altez; ii++) 2597 | { 2598 | move (x + ii, y - 1); 2599 | grafic (SHADOW); 2600 | grafic (COL); 2601 | for (ia = 1; ia <= largh; ia++) 2602 | printw (" "); 2603 | grafic (COL); 2604 | } 2605 | 2606 | move (x + ii, y - 1); 2607 | grafic (SHADOW); 2608 | grafic (BL); 2609 | for (ia = 1; ia <= largh; ia++) 2610 | grafic (ROW); 2611 | grafic (BR); 2612 | 2613 | move (x + ii + 1, y - 1); 2614 | for (ii = 0; ii <= largh + 1; ii++) 2615 | grafic (SHADOW); 2616 | if (titolo) 2617 | { 2618 | move (x, 1 + (y + (k - y) / 2) - strlen (titolo) / 2); 2619 | standout (); 2620 | printw ("%s", titolo); 2621 | standend (); 2622 | } 2623 | } 2624 | 2625 | // Print help message 2626 | void hlpmsg () 2627 | { 2628 | int op = 0; 2629 | int x_coord; 2630 | 2631 | if (msg_g == 'L') 2632 | x_coord = msg_x; 2633 | if (msg_g == 'R') 2634 | x_coord = msg_x - strlen (scelta[curitem].msg); 2635 | if (msg_g == 'C') 2636 | x_coord = 38 - strlen (scelta[curitem].msg) / 2; 2637 | if (msg_g == 'E') 2638 | x_coord = 79 - strlen (scelta[curitem].msg); 2639 | if (msg_g == 'B') 2640 | x_coord = 0; 2641 | 2642 | move (msg_y, 0); 2643 | for (op = 0; op < 80; op++) 2644 | printw (" "); 2645 | 2646 | if (msg_rvs == ON) 2647 | standout (); 2648 | 2649 | move (msg_y, x_coord); 2650 | printw ("%s", scelta[curitem].msg); 2651 | standend (); 2652 | refresh (); 2653 | } 2654 | 2655 | void mnutrace () /* Stampa traccia menu */ 2656 | { 2657 | char riga[120]; 2658 | int io; 2659 | 2660 | strcpy (riga, ""); 2661 | for (io = 0; io <= ipmenu; io++) 2662 | { 2663 | strcat (riga, imenu[io]); 2664 | strcat (riga, " "); 2665 | } 2666 | strcat (riga, "\0"); 2667 | 2668 | if (mnutrace_g == 'L') 2669 | move (mnutrace_y, mnutrace_x); 2670 | if (mnutrace_g == 'R') 2671 | move (mnutrace_y, mnutrace_x - strlen (riga)); 2672 | if (mnutrace_g == 'C') 2673 | move (mnutrace_y, 38 - (strlen (riga) / 2)); 2674 | if (mnutrace_g == 'E') 2675 | move (mnutrace_y, 79 - (strlen (riga))); 2676 | if (mnutrace_g == 'B') 2677 | move (mnutrace_y, 0); 2678 | if (mnutrace_rvs == ON) 2679 | standout (); 2680 | 2681 | printw ("%s", riga); 2682 | standend (); 2683 | refresh (); 2684 | } 2685 | 2686 | /* Sintattica simboli */ 2687 | void simb_pos (char *simb_name, int y_pos, int x_pos, int gst) 2688 | { 2689 | int reverse; 2690 | if (gst == 'R') 2691 | x_pos = x_pos + strlen (simb_name) + 2; 2692 | if ((gst == 'L') || (gst == 'C') || (gst == 'R') || (gst == 'E') 2693 | || (gst == 'B')) 2694 | reverse = ON; 2695 | if ((gst == 'l') || (gst == 'c') || (gst == 'r') || (gst == 'e') 2696 | || (gst == 'b')) 2697 | reverse = OFF; 2698 | gst = toupper (gst); 2699 | if (strcmp (simb_name, "MENUNAME") == 0) 2700 | { 2701 | mnuname_rvs = reverse; 2702 | mnuname_flag = ON; 2703 | mnuname_g = gst; 2704 | mnuname_y = y_pos; 2705 | mnuname_x = x_pos; 2706 | } 2707 | if (strcmp (simb_name, "TIME") == 0) 2708 | { 2709 | time_rvs = reverse; 2710 | time_flag = ON; 2711 | time_g = gst; 2712 | time_y = y_pos; 2713 | time_x = x_pos; 2714 | } 2715 | if (strcmp (simb_name, "MSG") == 0) 2716 | { 2717 | msg_rvs = reverse; 2718 | msg_flag = ON; 2719 | msg_g = gst; 2720 | msg_y = y_pos; 2721 | msg_x = x_pos; 2722 | } 2723 | if (strcmp (simb_name, "TITLE") == 0) 2724 | { 2725 | title_rvs = reverse; 2726 | title_flag = ON; 2727 | title_g = gst; 2728 | title_y = y_pos; 2729 | title_x = x_pos; 2730 | } 2731 | if (strcmp (simb_name, "INFOTERM") == 0) 2732 | { 2733 | infoterm_rvs = reverse; 2734 | infoterm_flag = ON; 2735 | infoterm_g = gst; 2736 | infoterm_y = y_pos; 2737 | infoterm_x = x_pos; 2738 | } 2739 | if (strcmp (simb_name, "MNUTRACE") == 0) 2740 | { 2741 | mnutrace_rvs = reverse; 2742 | mnutrace_flag = ON; 2743 | mnutrace_g = gst; 2744 | mnutrace_y = y_pos; 2745 | mnutrace_x = x_pos; 2746 | } 2747 | } 2748 | 2749 | void infoterm () /* Stampa Info Terminale a Video */ 2750 | { 2751 | char riga[80]; 2752 | 2753 | sprintf (riga, "%s %s:%s,[%s] %s", sistema, utente, porta, termname (), 2754 | lpdestenv); 2755 | if (infoterm_g == 'L') 2756 | move (infoterm_y, infoterm_x); 2757 | if (infoterm_g == 'R') 2758 | move (infoterm_y, infoterm_x - strlen (riga)); 2759 | if (infoterm_g == 'C') 2760 | move (infoterm_y, 38 - (strlen (riga) / 2)); 2761 | if (infoterm_g == 'E') 2762 | move (infoterm_y, 79 - (strlen (riga))); 2763 | if (infoterm_g == 'B') 2764 | move (infoterm_y, 0); 2765 | if (infoterm_rvs == ON) 2766 | standout (); 2767 | 2768 | printw ("%s", riga); 2769 | standend (); 2770 | refresh (); 2771 | } 2772 | 2773 | int confirm () 2774 | { 2775 | int nprts; 2776 | int row_pos, col_pos; 2777 | char tag_item[16][32]; 2778 | int iu, max_len = 12, c, t; 2779 | 2780 | nprts = 2; 2781 | strcpy (tag_item[0], " No "); 2782 | strcpy (tag_item[1], " Si "); 2783 | 2784 | row_pos = 12 - (nprts / 2) - 2; 2785 | col_pos = 38 - (max_len / 2); 2786 | win (" Confermi ? ", row_pos - 1, col_pos - 2, row_pos + nprts, 2787 | col_pos + max_len); 2788 | move (row_pos - 1, col_pos); 2789 | for (iu = 0; iu < nprts; iu++) 2790 | { 2791 | move (row_pos + iu, col_pos - 1); 2792 | printw (" %s", tag_item[iu]); 2793 | } 2794 | t = 0; 2795 | 2796 | standend (); 2797 | move (row_pos + t, col_pos - 1); 2798 | printw ("%c", LEFT_SYMBOL); 2799 | standout (); 2800 | move (row_pos + t, col_pos); 2801 | printw (tag_item[t]); 2802 | while (1) 2803 | { 2804 | refresh (); 2805 | c = getkey (); 2806 | if ((c == C_U) || (c == '8')) 2807 | { 2808 | standend (); 2809 | move (row_pos + t, col_pos - 1); 2810 | addstr (" "); 2811 | move (row_pos + t, col_pos); 2812 | printw (tag_item[t]); 2813 | t--; 2814 | if (t < 0) 2815 | t = nprts - 1; 2816 | move (row_pos + t, col_pos - 1); 2817 | printw ("%c", LEFT_SYMBOL); 2818 | standout (); 2819 | move (row_pos + t, col_pos); 2820 | printw (tag_item[t]); 2821 | standend (); 2822 | } 2823 | if ((c == C_D) || (c == '2')) 2824 | { 2825 | standend (); 2826 | move (row_pos + t, col_pos - 1); 2827 | addstr (" "); 2828 | move (row_pos + t, col_pos); 2829 | printw (tag_item[t]); 2830 | t++; 2831 | if (t >= nprts) 2832 | t = 0; 2833 | move (row_pos + t, col_pos - 1); 2834 | printw ("%c", LEFT_SYMBOL); 2835 | standout (); 2836 | move (row_pos + t, col_pos); 2837 | printw (tag_item[t]); 2838 | standend (); 2839 | } 2840 | if (c == NL) 2841 | { 2842 | standend (); 2843 | break; 2844 | } 2845 | } 2846 | return (t); 2847 | } 2848 | 2849 | void grafic (int etichetta) 2850 | { 2851 | switch (etichetta) 2852 | { 2853 | /* Top Left */ 2854 | case TL: 2855 | if (graf == 0) 2856 | printw ("+"); 2857 | if (graf == 1) 2858 | { 2859 | attrset (A_ALTCHARSET); 2860 | printw ("%s", lab_f0); 2861 | attroff (A_ALTCHARSET); 2862 | } 2863 | if (graf == 2) 2864 | addch (ACS_ULCORNER); 2865 | break; 2866 | 2867 | /* Botton Left */ 2868 | case BL: 2869 | if (graf == 0) 2870 | printw ("+"); 2871 | if (graf == 1) 2872 | { 2873 | attrset (A_ALTCHARSET); 2874 | printw ("%s", lab_f3); 2875 | attroff (A_ALTCHARSET); 2876 | } 2877 | if (graf == 2) 2878 | addch (ACS_LLCORNER); 2879 | break; 2880 | /* Top Right */ 2881 | case TR: 2882 | if (graf == 0) 2883 | printw ("+"); 2884 | if (graf == 1) 2885 | { 2886 | attrset (A_ALTCHARSET); 2887 | printw ("%s", lab_f1); 2888 | attroff (A_ALTCHARSET); 2889 | } 2890 | if (graf == 2) 2891 | addch (ACS_URCORNER); 2892 | break; 2893 | /* Botton Right */ 2894 | case BR: 2895 | if (graf == 0) 2896 | printw ("+"); 2897 | if (graf == 1) 2898 | { 2899 | attrset (A_ALTCHARSET); 2900 | printw ("%s", lab_f2); 2901 | attroff (A_ALTCHARSET); 2902 | } 2903 | if (graf == 2) 2904 | addch (ACS_LRCORNER); 2905 | break; 2906 | /* Row */ 2907 | case ROW: 2908 | if (graf == 0) 2909 | printw ("-"); 2910 | if (graf == 1) 2911 | { 2912 | attrset (A_ALTCHARSET); 2913 | printw ("%s", lab_f4); 2914 | attroff (A_ALTCHARSET); 2915 | } 2916 | if (graf == 2) 2917 | addch (ACS_HLINE); 2918 | break; 2919 | /* Col */ 2920 | case COL: 2921 | if (graf == 0) 2922 | printw ("|"); 2923 | if (graf == 1) 2924 | { 2925 | attrset (A_ALTCHARSET); 2926 | printw ("%s", lab_f5); 2927 | attroff (A_ALTCHARSET); 2928 | } 2929 | if (graf == 2) 2930 | addch (ACS_VLINE); 2931 | break; 2932 | /* Shadow */ 2933 | case SHADOW: 2934 | if (graf == 0) 2935 | printw ("#"); 2936 | if (graf == 1) 2937 | { 2938 | attrset (A_ALTCHARSET); 2939 | // TEO 2940 | printw ("%s", lab_f7); 2941 | //addch ("%s", ACS_CKBOARD); 2942 | attroff (A_ALTCHARSET); 2943 | } 2944 | if (graf == 2) 2945 | addch (ACS_CKBOARD); 2946 | break; 2947 | } 2948 | } 2949 | 2950 | int getkey () /* Legge un tasto premuto */ 2951 | { 2952 | int c; 2953 | 2954 | nonl (); 2955 | keypad (stdscr, TRUE); 2956 | c = getch (); 2957 | if (c == ' ') 2958 | return (' '); 2959 | if (c == RET) 2960 | return ('\n'); 2961 | if (c == NL) 2962 | return (C_D); 2963 | if (c == KEY_BACKSPACE) 2964 | return (BKSP); 2965 | if (c == DEL) 2966 | return (DEL); 2967 | if (c == INS) 2968 | return (INS); 2969 | if (c == KEY_UP) 2970 | return (C_U); 2971 | if (c == KEY_DOWN) 2972 | return (C_D); 2973 | if (c == KEY_LEFT) 2974 | return (C_L); 2975 | if (c == KEY_RIGHT) 2976 | return (C_R); 2977 | if (c == KEY_HOME) 2978 | return (HOME); 2979 | if (c == KEY_END) 2980 | return (END); 2981 | if (c == KEY_F0) 2982 | return (FZ0); 2983 | if (c == KEY_F0 + 1) 2984 | return (FZ1); 2985 | if (c == KEY_F0 + 2) 2986 | return (FZ2); 2987 | if (c == KEY_F0 + 3) 2988 | return (FZ3); 2989 | if (c == KEY_F0 + 4) 2990 | return (FZ4); 2991 | if (c == KEY_F0 + 5) 2992 | return (FZ5); 2993 | if (c == KEY_F0 + 6) 2994 | return (FZ6); 2995 | if (c == KEY_F0 + 7) 2996 | return (FZ7); 2997 | if (c == KEY_F0 + 8) 2998 | return (FZ8); 2999 | if (c == KEY_F0 + 9) 3000 | return (FZ9); 3001 | if (c == KEY_F0 + 10) 3002 | return (FZ0); 3003 | if (c == KEY_F0 + 11) 3004 | return (FZA); 3005 | if (c == KEY_F0 + 12) 3006 | return (FZB); 3007 | if (c == KEY_PPAGE) 3008 | return (PGUP); 3009 | if (c == KEY_NPAGE) 3010 | return (PGDN); 3011 | if (c == ESC) 3012 | return (ESC); 3013 | return (c); 3014 | } 3015 | 3016 | void getpasswd (char *entry) 3017 | { 3018 | int i, c; 3019 | int xpos, ypos; 3020 | i = 0; 3021 | c = 0; 3022 | standout (); 3023 | while ((c != '\n') && (c != '\r')) 3024 | { 3025 | c = getkey (); 3026 | if (c == FZ4) 3027 | { 3028 | strcpy (entry, "ABORT"); 3029 | break; 3030 | } 3031 | if (((c >= 32) && (c < 127)) && (i < 24)) 3032 | { 3033 | printw ("*"); 3034 | refresh (); 3035 | entry[i++] = toupper (c); 3036 | entry[i] = 0; 3037 | } 3038 | if ((c == '\b') && (i != 0)) 3039 | { 3040 | getyx (stdscr, ypos, xpos); 3041 | move (ypos, xpos - 1); 3042 | printw (" "); 3043 | move (ypos, xpos - 1); 3044 | refresh (); 3045 | entry[--i] = 0; 3046 | } 3047 | } 3048 | standend (); 3049 | 3050 | if (i == 0) 3051 | strcpy (entry, "ABORT"); 3052 | } 3053 | 3054 | void getentry (int xpos, int ypos, int tot_entry, char *entry) 3055 | { 3056 | int i = 0, c = 0, k = 0; 3057 | standout (); 3058 | if (strlen (entry) != 0) 3059 | { 3060 | move (xpos, ypos); 3061 | i = strlen (entry); 3062 | printw ("%s", entry); 3063 | } 3064 | else 3065 | { 3066 | move (xpos, ypos); 3067 | for (k = 0; k < tot_entry; k++) 3068 | printw (" "); 3069 | move (xpos, ypos); 3070 | } 3071 | while ((c != '\n') && (c != '\r')) 3072 | { 3073 | c = getkey (); 3074 | if (c == C_U) 3075 | { 3076 | strcpy (entry, PREV_FIELD); 3077 | break; 3078 | } 3079 | if (c == C_D) 3080 | { 3081 | c = '\n'; 3082 | } 3083 | if (c == FZ4) 3084 | { 3085 | strcpy (entry, ABORT); 3086 | break; 3087 | } 3088 | if (((c >= 32) && (c < 127)) && (i < tot_entry)) 3089 | { 3090 | printw ("%c", c); 3091 | refresh (); 3092 | entry[i++] = c; 3093 | entry[i] = 0; 3094 | } 3095 | if ((c == '\b') && (i == 0)) 3096 | { 3097 | strcpy (entry, PREV_FIELD); 3098 | break; 3099 | } 3100 | if ((c == '\b') && (i != 0)) 3101 | { 3102 | getyx (stdscr, ypos, xpos); 3103 | move (ypos, xpos - 1); 3104 | printw (" "); 3105 | move (ypos, xpos - 1); 3106 | refresh (); 3107 | entry[--i] = 0; 3108 | } 3109 | } 3110 | standend (); 3111 | } 3112 | 3113 | void dataoggi (char *datastr) /* Estrae la data di oggi */ 3114 | { 3115 | 3116 | //long tempo; 3117 | 3118 | //tempo=time(0L); 3119 | 3120 | t1 = time ((time_t *) 0); 3121 | tptr = localtime (&t1); 3122 | 3123 | sprintf (datastr, "%d/%d/%d", 3124 | tptr->tm_mday, 1 + tptr->tm_mon, 1900 + tptr->tm_year); 3125 | } 3126 | 3127 | void readcfg () 3128 | { 3129 | int opi; 3130 | int c, c0; 3131 | 3132 | if (getenv ("LPDEST")) 3133 | strcpy (lpdestenv, getenv ("LPDEST")); 3134 | 3135 | if ((infile = fopen ("qmenu.cfg", "r")) == NULL) /* Apertura file di config. */ 3136 | { 3137 | history_string ("ERROR, Cant' open configuration file"); 3138 | return; 3139 | } 3140 | else 3141 | { 3142 | /* Sostituisco le variabili d' ambiente */ 3143 | memoinc = 0; 3144 | while ((c = getc (infile)) != EOF) 3145 | { 3146 | if ((c == '{') && (c0 == '$')) 3147 | { 3148 | o = 0; 3149 | while ((en = getc (infile)) != '}') 3150 | env_var[o++] = en; 3151 | 3152 | env_var[o] = '\0'; 3153 | if (getenv (env_var)) 3154 | strcpy (env_value, getenv (env_var)); 3155 | else 3156 | strcpy (env_value, ""); 3157 | 3158 | d = 0; 3159 | memoinc = memoinc - 1; 3160 | while (d < strlen (env_value)) 3161 | memofile[memoinc++] = env_value[d++]; 3162 | continue; 3163 | } 3164 | memofile[memoinc++] = c; 3165 | c0 = c; 3166 | } 3167 | memofile[memoinc] = '\0'; 3168 | fclose (infile); 3169 | inc = 0; 3170 | while ((opi = getmemo (linea)) != -1) /* Leggo i parametri config. */ 3171 | { 3172 | if (strncmp ("MNU_TIM=", linea, 8) == 0) 3173 | { 3174 | itime_out = atoi (&linea[8]); 3175 | if (itime_out == 0) 3176 | mnu_tim = 0; 3177 | } 3178 | 3179 | if (strncmp ("LOGFILE_DIM=", linea, 12) == 0) 3180 | logfile_dim = atol (&linea[12]); 3181 | 3182 | if (strncmp ("BKS_EXIT=", linea, 9) == 0) 3183 | bks_exit = atoi (&linea[9]); 3184 | 3185 | if (strncmp ("PASSWD_MODE=ON", linea, 14) == 0) 3186 | passwd_mode = ON; 3187 | 3188 | if (strncmp ("MNU_PATH=", linea, 9) == 0) 3189 | strcpy (menu_dir, &linea[9]); 3190 | 3191 | if (strncmp ("GRAPH=", linea, 6) == 0) 3192 | graf = atoi (&linea[6]); 3193 | 3194 | if (strncmp ("SH_PASSWD=", linea, 10) == 0) 3195 | { 3196 | strcpy (sh_passwd, &linea[10]); 3197 | sh_passwd_ok = 1; 3198 | } 3199 | 3200 | if (strncmp ("EDIT_PASSWD=", linea, 12) == 0) 3201 | { 3202 | strcpy (edit_passwd, &linea[12]); 3203 | edit_passwd_ok = 1; 3204 | } 3205 | 3206 | if (strncmp ("HLP_FILENAME=", linea, 13) == 0) 3207 | strcpy (hlp_filename, &linea[13]); 3208 | 3209 | if (strncmp ("PRSUPER=", linea, 8) == 0) 3210 | { 3211 | strcpy (prsuper, &linea[8]); 3212 | super = ON; 3213 | } 3214 | 3215 | if (strncmp ("PRUSER=", linea, 7) == 0) 3216 | { 3217 | strcpy (pruser, &linea[7]); 3218 | user = ON; 3219 | } 3220 | 3221 | if (strncmp ("MENU_SUPER_PASSWD=", linea, 18) == 0) 3222 | { 3223 | strcpy (super_passwd, &linea[18]); 3224 | superpasswd = ON; 3225 | } 3226 | 3227 | } 3228 | } 3229 | } 3230 | 3231 | void display_config () 3232 | { 3233 | int u; 3234 | 3235 | win (" FILE DI CONFIGURAZIONE (qmenu.cfg) ", 2, 2, 18, 78); 3236 | move (18, 4); 3237 | printw (" F4 - Esce "); 3238 | move (4, 4); 3239 | printw (" MNU_TIM = %i ", itime_out); 3240 | move (5, 4); 3241 | printw (" LOGFILE_DIM = %i ", logfile_dim); 3242 | move (6, 4); 3243 | printw (" GRAPH = %i ", graf); 3244 | move (7, 4); 3245 | printw (" MNU_PATH = %s ", menu_dir); 3246 | move (8, 4); 3247 | printw (" PASSWD_MODE = %i ", passwd_mode); 3248 | move (9, 4); 3249 | printw (" MENU_SUPER_PASSWD= %s ", super_passwd); 3250 | move (10, 4); 3251 | printw (" HLP_FILENAME= %s ", hlp_filename); 3252 | move (11, 4); 3253 | printw (" LPDEST = %s ", lpdestenv); 3254 | move (12, 4); 3255 | printw (" PRSUPER = %s ", prsuper); 3256 | move (13, 4); 3257 | printw (" PRUSER = %s ", pruser); 3258 | refresh (); 3259 | while ((u = getkey ()) != FZ4); 3260 | } 3261 | 3262 | int win_option (char *winlist) /* Selezione le stampanti */ 3263 | { 3264 | int nprts; 3265 | int row_pos, col_pos; 3266 | char prts[16][32]; 3267 | int ia = 0, iu, max_len = 0, c, t, scan_pointer = 0, a = 0, item = 0; 3268 | nprts = 0; 3269 | 3270 | while (scan_pointer < strlen (winlist)) 3271 | { 3272 | if (winlist[scan_pointer] == ',') 3273 | { 3274 | prts[item][a] = '\0'; 3275 | scan_pointer++; 3276 | item++; 3277 | a = 0; 3278 | } 3279 | else 3280 | { 3281 | prts[item][a] = winlist[scan_pointer++]; 3282 | a++; 3283 | } 3284 | } 3285 | 3286 | for (ia = 0, max_len = 0; ia <= item; ia++) 3287 | { 3288 | if (strlen (prts[ia]) > max_len) 3289 | max_len = strlen (prts[ia]); 3290 | } 3291 | 3292 | nprts = item + 1; 3293 | prts[item][a] = '\0'; 3294 | if (max_len < 10) 3295 | max_len = 11; 3296 | row_pos = 12 - (nprts / 2) - 2; 3297 | col_pos = 38 - (max_len / 2); 3298 | standend (); 3299 | win (" OPZIONI SUPERUTENTE ", row_pos - 1, col_pos - 2, row_pos + nprts, 3300 | col_pos + max_len); 3301 | move (row_pos + nprts, col_pos); 3302 | printw (" F4 - Esce "); 3303 | 3304 | standend (); 3305 | for (iu = 0; iu < nprts; iu++) 3306 | { 3307 | move (row_pos + iu, col_pos - 1); 3308 | printw (" %s", prts[iu]); 3309 | } 3310 | standout (); 3311 | 3312 | for (t = 0; t < nprts; t++) 3313 | if (strcmp (spoolernm, prts[t]) == 0) 3314 | break; 3315 | if (t >= nprts) 3316 | t = 0; 3317 | standend (); 3318 | move (row_pos + t, col_pos - 1); 3319 | printw ("%c", LEFT_SYMBOL); 3320 | standout (); 3321 | move (row_pos + t, col_pos); 3322 | printw (prts[t]); 3323 | while (1) 3324 | { 3325 | refresh (); 3326 | c = getkey (); 3327 | if ((c == C_U) || (c == '8')) 3328 | { 3329 | standend (); 3330 | move (row_pos + t, col_pos - 1); 3331 | addstr (" "); 3332 | move (row_pos + t, col_pos); 3333 | printw (prts[t]); 3334 | t--; 3335 | if (t < 0) 3336 | t = nprts - 1; 3337 | move (row_pos + t, col_pos - 1); 3338 | printw ("%c", LEFT_SYMBOL); 3339 | standout (); 3340 | move (row_pos + t, col_pos); 3341 | printw (prts[t]); 3342 | standend (); 3343 | } 3344 | if ((c == C_D) || (c == '2')) 3345 | { 3346 | standend (); 3347 | move (row_pos + t, col_pos - 1); 3348 | addstr (" "); 3349 | move (row_pos + t, col_pos); 3350 | printw (prts[t]); 3351 | t++; 3352 | if (t >= nprts) 3353 | t = 0; 3354 | move (row_pos + t, col_pos - 1); 3355 | printw ("%c", LEFT_SYMBOL); 3356 | standout (); 3357 | move (row_pos + t, col_pos); 3358 | printw (prts[t]); 3359 | standend (); 3360 | } 3361 | if ((c == ESC) || (c == FZ4)) 3362 | { 3363 | t = -1; 3364 | standend (); 3365 | break; 3366 | } 3367 | if (c == NL) 3368 | { 3369 | standend (); 3370 | break; 3371 | } 3372 | } 3373 | return (t); 3374 | } 3375 | 3376 | void 3377 | cre_cfg () 3378 | { 3379 | if ((ofile = fopen ("qmenu.cfg", "w")) == NULL) 3380 | { 3381 | printf ("%s qmenu.cfg\n", msg_DONT_WRITE); 3382 | exit (0); 3383 | } 3384 | printf ("Rebuilding \"qmenu.cfg\"\n"); 3385 | fprintf (ofile, "\ 3386 | [Option]\n\ 3387 | MNU_TIM=1000\n\ 3388 | LOGFILE_DIM=50000\n\ 3389 | GRAPH=2\n\ 3390 | PASSWD_MODE=OFF\n\ 3391 | MENU_SUPER_PASSWD=MENU\n\ 3392 | BKS_EXIT=0\n\ 3393 | \n\ 3394 | [FileName]\n\ 3395 | HLP_FILENAME=qmenu.hlp\n\ 3396 | \n\ 3397 | [Printers]\n\ 3398 | PRSUPER=printer0,printer1\n\ 3399 | PRUSER=printer0,printer1\n\ 3400 | \n\ 3401 | [Path]\n\ 3402 | #MNU_PATH=${HOME}/\n\ 3403 | \n\ 3404 | [PassWord]\n\ 3405 | #PAROLA_CHIAVE=NOMINATIVO\n\ 3406 | \n"); 3407 | fclose (ofile); 3408 | 3409 | } 3410 | 3411 | void 3412 | cre_model () 3413 | { 3414 | if ((ofile = fopen ("model.mnu", "w")) == NULL) 3415 | { 3416 | printf ("%s model.mnu\n", msg_DONT_WRITE); 3417 | exit (0); 3418 | } 3419 | printf ("Creating \"model.mnu\"\n"); 3420 | 3421 | fprintf (ofile, "\ 3422 | Template header E[TIME] \n\ 3423 | --------------------------------------------------------------------------------\n\ 3424 | \n\ 3425 | C[TITLE]\n\ 3426 | \n\ 3427 | ^1. ................................................ ^\n\ 3428 | ^2. ................................................ ^\n\ 3429 | ^3. ................................................ ^\n\ 3430 | ^4. ................................................ ^\n\ 3431 | ^5. ................................................ ^\n\ 3432 | ^6. ................................................ ^\n\ 3433 | ^7. ................................................ ^\n\ 3434 | ^8. ................................................ ^\n\ 3435 | ^9. ................................................ ^\n\ 3436 | ^0. ................................................ ^\n\ 3437 | \n\ 3438 | ^F. Exit ^\n\ 3439 | \n\ 3440 | Selection..: [ &]\n\ 3441 | \n\ 3442 | c[MSG]\n\ 3443 | --------------------------------------------------------------------------------\n\ 3444 | L[INFOTERM] E[MENUNAME]\n\ 3445 | F1=Stampanti max_lun_fin) 3582 | max_lun_fin = strlen (linea); 3583 | strcpy (finestra[a++], linea); 3584 | } 3585 | } 3586 | fclose (infile); 3587 | max_elem_fin = a; 3588 | disegna_form (); 3589 | if (j != 0) 3590 | { 3591 | while (loop_OK) 3592 | { 3593 | getentry (frm[s].x, frm[s].y, frm[s].lun, frm[s].desc); 3594 | switch (atoi (frm[s].desc)) 3595 | { 3596 | case -1: 3597 | strcpy (frm[s].desc, ""); 3598 | loop_OK = FALSE; 3599 | abnormal = TRUE; 3600 | break; 3601 | case -2: 3602 | strcpy (frm[s].desc, ""); 3603 | if (s == 0) 3604 | loop_OK = FALSE; 3605 | s--; 3606 | abnormal = TRUE; 3607 | break; 3608 | default: 3609 | s++; 3610 | abnormal = FALSE; 3611 | if (s == j) 3612 | loop_OK = FALSE; 3613 | break; 3614 | } 3615 | } 3616 | } 3617 | else 3618 | while ((u = getkey ()) != FZ4); 3619 | 3620 | return abnormal; 3621 | } 3622 | 3623 | 3624 | void disegna_form () 3625 | { 3626 | int top = 0; 3627 | int left = 0; 3628 | int a = 0, b = 0; 3629 | int inizio = 0, fine = 0; 3630 | int y = 0; 3631 | 3632 | top = 11 - (max_elem_fin / 2); 3633 | left = 39 - (max_lun_fin / 2); 3634 | win (" INSERIMENTO DATI ", top - 1, left - 1, top + max_elem_fin, 3635 | left + max_lun_fin); 3636 | for (a = 0; a < max_elem_fin; a++) 3637 | { 3638 | 3639 | /* ============================================== */ 3640 | inizio = 0; 3641 | fine = 0; 3642 | y = 0; 3643 | 3644 | move (top + a, left); 3645 | printw ("%s", finestra[a]); 3646 | for (b = 0; finestra[a][b] != '\0'; b++) 3647 | { 3648 | if (finestra[a][b] == '<') 3649 | { 3650 | finestra[a][b] = ' '; 3651 | inizio = b + 1; 3652 | } 3653 | 3654 | if (finestra[a][b] == '>') 3655 | { 3656 | finestra[a][b] = ' '; 3657 | fine = b; 3658 | move (top + a, left + inizio - 1); 3659 | printw (" "); 3660 | standout (); 3661 | /* =========== */ 3662 | frm[j].x = top + a; 3663 | frm[j].y = left + inizio; 3664 | frm[j].lun = fine - inizio; 3665 | strcpy (frm[j].desc, ""); 3666 | j++; 3667 | /* =========== */ 3668 | move (top + a, left + inizio); 3669 | for (y = inizio; y != fine; y++) 3670 | printw (" "); 3671 | standend (); 3672 | move (top + a, left + fine); 3673 | printw (" "); 3674 | } 3675 | } 3676 | refresh (); 3677 | /* ============================================== */ 3678 | 3679 | } 3680 | move (top + max_elem_fin, left + 1); 3681 | printw (" F4 - Esce "); 3682 | refresh (); 3683 | } 3684 | 3685 | void pausa () 3686 | { 3687 | int u; 3688 | move (22, 50); 3689 | printw (" Press [F4] to exit "); 3690 | refresh (); 3691 | while ((u = getkey ()) != FZ4); 3692 | } 3693 | -------------------------------------------------------------------------------- /qmenu.cfg: -------------------------------------------------------------------------------- 1 | [Option] 2 | MNU_TIM=1000 3 | LOGFILE_DIM=50000 4 | GRAPH=2 5 | PASSWD_MODE=OFF 6 | MENU_SUPER_PASSWD=MENU 7 | BKS_EXIT=0 8 | 9 | [FileName] 10 | HLP_FILENAME=qmenu.hlp 11 | 12 | [Printers] 13 | PRSUPER=printer0,printer1 14 | PRUSER=printer0,printer1 15 | 16 | [Path] 17 | #MNU_PATH=${HOME}/ 18 | 19 | [PassWord] 20 | #PAROLA_CHIAVE=NOMINATIVO 21 | 22 | -------------------------------------------------------------------------------- /qmenu.frm: -------------------------------------------------------------------------------- 1 | [form1] 2 | 3 | Linux command.: < > 4 | Teo..: < > 5 | 6 | -------------------------------------------------------------------------------- /qmenu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/teopost/qmenu/aaf28e2de74c314c8182886ac9c5e456d74f9a28/qmenu.gif -------------------------------------------------------------------------------- /qmenu.hlp: -------------------------------------------------------------------------------- 1 | [model.mnu:1.] 2 | Questa opzione permette di 3 | ;e;e 4 | 5 | [] 6 | --------------------------------------------------------------------------------