Scippy

SCIP

Solving Constraint Integer Programs

dialog.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2/* */
3/* This file is part of the program and library */
4/* SCIP --- Solving Constraint Integer Programs */
5/* */
6/* Copyright (c) 2002-2025 Zuse Institute Berlin (ZIB) */
7/* */
8/* Licensed under the Apache License, Version 2.0 (the "License"); */
9/* you may not use this file except in compliance with the License. */
10/* You may obtain a copy of the License at */
11/* */
12/* http://www.apache.org/licenses/LICENSE-2.0 */
13/* */
14/* Unless required by applicable law or agreed to in writing, software */
15/* distributed under the License is distributed on an "AS IS" BASIS, */
16/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
17/* See the License for the specific language governing permissions and */
18/* limitations under the License. */
19/* */
20/* You should have received a copy of the Apache-2.0 license */
21/* along with SCIP; see the file LICENSE. If not visit scipopt.org. */
22/* */
23/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
24
25/**@file dialog.c
26 * @ingroup OTHER_CFILES
27 * @brief methods for user interface dialog
28 * @author Tobias Achterberg
29 */
30
31/*---+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0----+----1----+----2*/
32
33#include <assert.h>
34#include <string.h>
35#include <ctype.h>
36
37#include "scip/scip.h"
38#include "scip/def.h"
40#include "scip/set.h"
41#include "scip/pub_misc.h"
42#include "scip/dialog.h"
43
44#include "scip/struct_dialog.h"
45
46#ifdef SCIP_WITH_READLINE
47#include <stdio.h>
48#include <readline/readline.h>
49#include <readline/history.h>
50#endif
51
52
53
54/*
55 * read line methods
56 */
57
58#ifdef SCIP_WITH_READLINE
59
60/** reads a line of input from stdin */
61static
63 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
64 const char* prompt, /**< prompt to display */
65 SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
66 )
67{
68 char* s;
69
70 assert(endoffile != NULL);
71
72 s = readline(prompt);
73 if( s != NULL )
74 {
75 (void)SCIPstrncpy(&dialoghdlr->buffer[dialoghdlr->bufferpos], s, dialoghdlr->buffersize - dialoghdlr->bufferpos);
76 free(s);
77 *endoffile = FALSE;
78 }
79 else
80 *endoffile = TRUE;
81
82 return SCIP_OKAY;
83}
84
85/** puts the given string on the command history */
86static
88 const char* s /**< string to add to the command history */
89 )
90{
91 add_history(s);
92
93 return SCIP_OKAY;
94}
95
96/** returns the current length of the history list */
97static
99 void
100 )
101{
102#ifndef NO_REMOVE_HISTORY
103 return history_length;
104#else
105 return 0;
106#endif
107}
108
109/** removes a single element from the history list */
110static
112 int pos /**< list position of history entry to remove */
113 )
114{
115#ifndef NO_REMOVE_HISTORY
116 HIST_ENTRY* entry;
117
118 entry = remove_history(pos);
119
120 /* Free readline/history storage: there seem to be differences in the versions (and the amount of
121 * data to be freed). The following should be a good approximation; if it doesn't work define
122 * NO_REMOVE_HISTORY - see the INSTALL file. This will produce minor memory leaks.
123 */
124#if RL_VERSION_MAJOR >= 5
125 (void)free_history_entry(entry);
126#else
127 if( entry != NULL )
128 {
129 free((void*)entry->line);
130 free(entry);
131 }
132#endif
133#endif
134
135 return SCIP_OKAY;
136}
137
138/** writes command history into file of the specified name */
139static
141 const char* filename /**< name of file to (over)write history to */
142 )
143{
144 int retval = write_history(filename);
145
146 if( retval == 0 )
147 return SCIP_OKAY;
148 else
150}
151
152#else
153
154/** reads a line of input from stdin */
155static
157 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
158 const char* prompt, /**< prompt to display */
159 SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
160 )
161{
162 char* s;
163
164 assert(dialoghdlr != NULL);
165 assert(dialoghdlr->buffer != NULL);
166 assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
167 assert(dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0');
168 assert(endoffile != NULL);
169
170 /* check for EOF (due to CTRL-D or unexpected end of piped-in file) */
171 if( feof(stdin) )
172 *endoffile = TRUE;
173 else
174 {
175 char* result;
176
177 /* display prompt */
178 printf("%s", prompt);
179
180 /* read line from stdin */
181 result = fgets(&dialoghdlr->buffer[dialoghdlr->bufferpos], dialoghdlr->buffersize - dialoghdlr->bufferpos, stdin);
182 assert(result != NULL);
183 (void) result; /* disable compiler warning [-Wunused-result] */
184
185 /* replace newline with \0 */
186 s = strchr(&dialoghdlr->buffer[dialoghdlr->bufferpos], '\n');
187 if( s != NULL )
188 *s = '\0';
189 *endoffile = FALSE;
190 }
191
192 return SCIP_OKAY;
193}
194
195/** puts the given string on the command history */ /*lint -e715*/
196static
198 const char* s /**< string to add to the command history */
199 )
200{ /*lint --e{715}*/
201 /* nothing to do here */
202 return SCIP_OKAY;
203}
204
205/** returns the current length of the history list */
206static
208 void
209 )
210{
211 return 0;
212}
213
214/** removes a single element from the history list */ /*lint -e715*/
215static
217 int pos /**< list position of history entry to remove */
218 )
219{ /*lint --e{715}*/
220 /* nothing to do here */
221 return SCIP_OKAY;
222}
223
224
225/** writes command history into file of the specified name */
226static
228 const char* filename /**< name of file to (over)write history to */
229 )
230{ /*lint --e{715}*/
231 assert(filename != NULL);
232
233 /* nothing to do here */
234 return SCIP_OKAY;
235}
236
237#endif
238
239/** frees a single linelist entry, but not its successors */
240static
242 SCIP_LINELIST** linelist /**< pointer to line list */
243 )
244{
245 assert(linelist != NULL);
246
247 BMSfreeMemoryArray(&(*linelist)->inputline);
248 BMSfreeMemory(linelist);
249}
250
251/** frees a linelist entry and all of its successors */
252static
254 SCIP_LINELIST** linelist /**< pointer to line list */
255 )
256{
257 assert(linelist != NULL);
258
259 while( *linelist != NULL )
260 {
261 SCIP_LINELIST* nextline;
262
263 nextline = (*linelist)->nextline;
264 linelistFree(linelist);
265 *linelist = nextline;
266 }
267}
268
269/** reads a line of input from stdin or from the stored input lines in the input list */
270static
272 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
273 const char* prompt, /**< prompt to display */
274 SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
275 )
276{
277 assert(dialoghdlr != NULL);
278 assert(dialoghdlr->buffer != NULL);
279 assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
280 assert(dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0');
281 assert(endoffile != NULL);
282
283 *endoffile = FALSE;
284
285 if( dialoghdlr->inputlist == NULL )
286 {
287 /* read a line from stdin */
288 SCIP_CALL( readLine(dialoghdlr, prompt, endoffile) );
289 }
290 else
291 {
292 SCIP_LINELIST* nextline;
293
294 /* copy the next input line into the input buffer */
295 (void)SCIPstrncpy(&dialoghdlr->buffer[dialoghdlr->bufferpos], dialoghdlr->inputlist->inputline, dialoghdlr->buffersize - dialoghdlr->bufferpos);
296
297 /* free the input line */
298 nextline = dialoghdlr->inputlist->nextline;
299 if( dialoghdlr->inputlistptr == &(dialoghdlr->inputlist->nextline) )
300 dialoghdlr->inputlistptr = &dialoghdlr->inputlist;
301 linelistFree(&dialoghdlr->inputlist);
302 dialoghdlr->inputlist = nextline;
303 assert(dialoghdlr->inputlistptr != NULL);
304 assert(*dialoghdlr->inputlistptr == NULL);
305 }
306
307 return SCIP_OKAY;
308}
309
310
311
312
313/*
314 * dialog handler
315 */
316
317/** copies the given dialog to a new scip */
319 SCIP_DIALOG* dialog, /**< dialog */
320 SCIP_SET* set /**< SCIP_SET of SCIP to copy to */
321 )
322{
323 assert(dialog != NULL);
324 assert(set != NULL);
325 assert(set->scip != NULL);
326
327 if( dialog->dialogcopy != NULL )
328 {
329 SCIPsetDebugMsg(set, "including dialog %s in subscip %p\n", SCIPdialogGetName(dialog), (void*)set->scip);
330 SCIP_CALL( dialog->dialogcopy(set->scip, dialog) );
331 }
332 return SCIP_OKAY;
333}
334
335/** creates a dialog handler */
337 SCIP_SET* set, /**< global SCIP settings */
338 SCIP_DIALOGHDLR** dialoghdlr /**< pointer to store dialog handler */
339 )
340{ /*lint --e{715}*/
341#ifdef SCIP_WITH_READLINE
342 char readlineversion[20];
343#endif
344
345 assert(set != NULL);
346 assert(dialoghdlr != NULL);
347
348 SCIP_ALLOC( BMSallocMemory(dialoghdlr) );
349 (*dialoghdlr)->rootdialog = NULL;
350 (*dialoghdlr)->inputlist = NULL;
351 (*dialoghdlr)->inputlistptr = &(*dialoghdlr)->inputlist;
352 (*dialoghdlr)->buffersize = SCIP_MAXSTRLEN;
353 (*dialoghdlr)->nprotectedhistelems = -1;
354 SCIP_ALLOC( BMSallocMemoryArray(&(*dialoghdlr)->buffer, (*dialoghdlr)->buffersize) );
355
356 SCIPdialoghdlrClearBuffer(*dialoghdlr);
357
358#ifdef SCIP_WITH_READLINE
359 (void) SCIPsnprintf(readlineversion, (int)sizeof(readlineversion), "Readline %s", rl_library_version);
360 SCIP_CALL( SCIPsetIncludeExternalCode(set, readlineversion, "GNU library for command line editing (gnu.org/s/readline)") );
361#endif
362
363 return SCIP_OKAY;
364}
365
366/** frees a dialog handler and it's dialog tree */
368 SCIP* scip, /**< SCIP data structure */
369 SCIP_DIALOGHDLR** dialoghdlr /**< pointer to dialog handler */
370 )
371{
372 assert(dialoghdlr != NULL);
373 if( *dialoghdlr == NULL )
374 return SCIP_OKAY;
375
376 SCIP_CALL( SCIPdialoghdlrSetRoot(scip, *dialoghdlr, NULL) );
377 linelistFreeAll(&(*dialoghdlr)->inputlist);
378 BMSfreeMemoryArray(&(*dialoghdlr)->buffer);
379 BMSfreeMemory(dialoghdlr);
380
381 return SCIP_OKAY;
382}
383
384/** executes the root dialog of the dialog handler */
386 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
387 SCIP_SET* set /**< global SCIP settings */
388 )
389{
390 SCIP_DIALOG* dialog;
391
392 assert(dialoghdlr != NULL);
393 assert(dialoghdlr->buffer != NULL);
394
395 /* clear the buffer, start with the root dialog */
396 SCIPdialoghdlrClearBuffer(dialoghdlr);
397 dialog = dialoghdlr->rootdialog;
398
399 /* execute dialogs until a NULL is returned as next dialog */
400 while( dialog != NULL )
401 {
402 SCIP_CALL( SCIPdialogExec(dialog, set, dialoghdlr, &dialog) );
403
404 /* reset buffer, it is was consumed completely */
405 if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0' )
406 SCIPdialoghdlrClearBuffer(dialoghdlr);
407 }
408
409 return SCIP_OKAY;
410}
411
412/** makes given dialog the root dialog of dialog handler; captures dialog and releases former root dialog */
414 SCIP* scip, /**< SCIP data structure */
415 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
416 SCIP_DIALOG* dialog /**< dialog to be the root */
417 )
418{
419 assert(dialoghdlr != NULL);
420
421 if( dialoghdlr->rootdialog != NULL )
422 {
423 SCIP_CALL( SCIPdialogRelease(scip, &dialoghdlr->rootdialog) );
424 }
425 assert(dialoghdlr->rootdialog == NULL);
426
427 dialoghdlr->rootdialog = dialog;
428
429 if( dialog != NULL )
430 SCIPdialogCapture(dialog);
431
432 return SCIP_OKAY;
433}
434
435/** returns the root dialog of the dialog handler */
437 SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */
438 )
439{
440 assert(dialoghdlr != NULL);
441
442 return dialoghdlr->rootdialog;
443}
444
445/** clears the input command buffer of the dialog handler */
447 SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */
448 )
449{
450 assert(dialoghdlr != NULL);
451
452 dialoghdlr->buffer[0] = '\0';
453 dialoghdlr->bufferpos = 0;
454}
455
456/** returns TRUE iff input command buffer is empty */
458 SCIP_DIALOGHDLR* dialoghdlr /**< dialog handler */
459 )
460{
461 assert(dialoghdlr != NULL);
462 assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
463
464 return (dialoghdlr->buffer[dialoghdlr->bufferpos] == '\0');
465}
466
467/** returns the next line in the handler's command buffer; if the buffer is empty, displays the given prompt or the
468 * current dialog's path and asks the user for further input; the user must not free or modify the returned string
469 */
471 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
472 SCIP_DIALOG* dialog, /**< current dialog */
473 const char* prompt, /**< prompt to display, or NULL to display the current dialog's path */
474 char** inputline, /**< pointer to store the complete line in the handler's command buffer */
475 SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
476 )
477{
478 char path[SCIP_MAXSTRLEN+1];
479 char p[SCIP_MAXSTRLEN];
480
481 assert(dialoghdlr != NULL);
482 assert(dialoghdlr->buffer != NULL);
483 assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
484 assert(inputline != NULL);
485
486 /* get input from the user, if the buffer is empty */
487 if( SCIPdialoghdlrIsBufferEmpty(dialoghdlr) )
488 {
489 int len;
490
491 /* clear the buffer */
492 SCIPdialoghdlrClearBuffer(dialoghdlr);
493
494 if( prompt == NULL )
495 {
496 /* use current dialog's path as prompt */
497 SCIPdialogGetPath(dialog, '/', path);
498 (void) SCIPsnprintf(p, SCIP_MAXSTRLEN, "%s> ", path);
499 prompt = p;
500 }
501
502 /* read command line from stdin or from the input line list */
503 SCIP_CALL( readInputLine(dialoghdlr, prompt, endoffile) );
504
505 /* strip trailing spaces */
506 len = (int)strlen(&dialoghdlr->buffer[dialoghdlr->bufferpos]);
507 if( len > 0 )
508 {
509 while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1]) )
510 {
511 dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1] = '\0';
512 len--;
513 }
514 }
515
516 /* insert command in command history */
517 if( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' )
518 {
519 SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, NULL, &dialoghdlr->buffer[dialoghdlr->bufferpos], FALSE) );
520 }
521 }
522
523 /* the last character in the buffer must be a '\0' */
524 dialoghdlr->buffer[dialoghdlr->buffersize-1] = '\0';
525
526 /* skip leading spaces: find start of first word */
527 while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
528 dialoghdlr->bufferpos++;
529
530 /* copy the complete line */
531 *inputline = &dialoghdlr->buffer[dialoghdlr->bufferpos];
532
533 /* go to the end of the line */
534 dialoghdlr->bufferpos += (int)strlen(&dialoghdlr->buffer[dialoghdlr->bufferpos]);
535
536 if( dialoghdlr->buffer[dialoghdlr->buffersize-1] == '\0' )
537 *endoffile = TRUE;
538
539 return SCIP_OKAY;
540}
541
542
543/** returns the next word in the handler's command buffer; if the buffer is empty, displays the given prompt or the
544 * current dialog's path and asks the user for further input; the user must not free or modify the returned string
545 */
547 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
548 SCIP_DIALOG* dialog, /**< current dialog */
549 const char* prompt, /**< prompt to display, or NULL to display the current dialog's path */
550 char** inputword, /**< pointer to store the next word in the handler's command buffer */
551 SCIP_Bool* endoffile /**< pointer to store whether the end of the input file was reached */
552 )
553{
554 char path[SCIP_MAXSTRLEN+1];
555 char p[SCIP_MAXSTRLEN];
556 char* firstword;
557 int pos;
558
559 assert(dialoghdlr != NULL);
560 assert(dialoghdlr->buffer != NULL);
561 assert(dialoghdlr->bufferpos < dialoghdlr->buffersize);
562 assert(inputword != NULL);
563 assert(endoffile != NULL);
564
565 *endoffile = FALSE;
566
567 /* get input from the user, if the buffer is empty */
568 if( SCIPdialoghdlrIsBufferEmpty(dialoghdlr) )
569 {
570 int len;
571
572 /* clear the buffer */
573 SCIPdialoghdlrClearBuffer(dialoghdlr);
574
575 if( prompt == NULL )
576 {
577 /* use current dialog's path as prompt */
578 SCIPdialogGetPath(dialog, '/', path);
579 (void) SCIPsnprintf(p, SCIP_MAXSTRLEN, "%s> ", path);
580 prompt = p;
581 }
582
583 /* read command line from stdin or from the input line list */
584 SCIP_CALL( readInputLine(dialoghdlr, prompt, endoffile) );
585
586 /* strip trailing spaces */
587 len = (int)strlen(&dialoghdlr->buffer[dialoghdlr->bufferpos]);
588 if( len > 0 )
589 {
590 while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1]) )
591 {
592 dialoghdlr->buffer[dialoghdlr->bufferpos + len - 1] = '\0';
593 len--;
594 }
595 }
596
597 /* insert command in command history */
598 if( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' )
599 {
600 SCIP_CALL( SCIPdialoghdlrAddHistory(dialoghdlr, NULL, &dialoghdlr->buffer[dialoghdlr->bufferpos], FALSE) );
601 }
602 }
603
604 /* the last character in the buffer must be a '\0' */
605 dialoghdlr->buffer[dialoghdlr->buffersize-1] = '\0';
606
607 /* skip leading spaces: find start of first word */
608 while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
609 dialoghdlr->bufferpos++;
610 firstword = &dialoghdlr->buffer[dialoghdlr->bufferpos];
611
612 pos = dialoghdlr->bufferpos;
613 while( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' && !isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
614 {
615 assert(pos <= dialoghdlr->bufferpos);
616
617 switch( dialoghdlr->buffer[dialoghdlr->bufferpos] )
618 {
619 case '"':
620 dialoghdlr->bufferpos++;
621 /* read characters as they are until the next " */
622 while( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' && dialoghdlr->buffer[dialoghdlr->bufferpos] != '"' )
623 {
624 /* watch out for \" and \\ which should be treated as " and \, respectively */
625 if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\\'
626 && (dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '"'
627 || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\\') )
628 {
629 dialoghdlr->bufferpos++;
630 }
631 dialoghdlr->buffer[pos] = dialoghdlr->buffer[dialoghdlr->bufferpos];
632 pos++;
633 dialoghdlr->bufferpos++;
634 }
635 if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '"' )
636 dialoghdlr->bufferpos++; /* skip final " */
637 break;
638 case '\'':
639 dialoghdlr->bufferpos++;
640 /* read characters as they are until the next ' */
641 while( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' && dialoghdlr->buffer[dialoghdlr->bufferpos] != '\'' )
642 {
643 /* watch out for \' and \\ which should be treated as ' and \, respectively */
644 if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\\'
645 && (dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\''
646 || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\\') )
647 {
648 dialoghdlr->bufferpos++;
649 }
650 dialoghdlr->buffer[pos] = dialoghdlr->buffer[dialoghdlr->bufferpos];
651 pos++;
652 dialoghdlr->bufferpos++;
653 }
654 if( dialoghdlr->buffer[dialoghdlr->bufferpos] == '\'' )
655 dialoghdlr->bufferpos++; /* skip final ' */
656 break;
657 case '\\':
658 /* if the next character is a space, a ", or a ', read next character as it is;
659 * otherwise, treat the \ as normal character
660 */
661 if( dialoghdlr->buffer[dialoghdlr->bufferpos+1] == ' '
662 || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '"'
663 || dialoghdlr->buffer[dialoghdlr->bufferpos+1] == '\'' )
664 {
665 dialoghdlr->bufferpos++;
666 }
667 /*lint -fallthrough*/
668 default:
669 dialoghdlr->buffer[pos] = dialoghdlr->buffer[dialoghdlr->bufferpos];
670 pos++;
671 dialoghdlr->bufferpos++;
672 break;
673 }
674 }
675 assert(pos <= dialoghdlr->bufferpos);
676
677 /* move buffer to the next position */
678 if( dialoghdlr->buffer[dialoghdlr->bufferpos] != '\0' )
679 dialoghdlr->bufferpos++;
680
681 /* possibly truncate the command word in the buffer */
682 dialoghdlr->buffer[pos] = '\0';
683
684 /* remove additional spaces */
685 while( isspace((unsigned char)dialoghdlr->buffer[dialoghdlr->bufferpos]) )
686 dialoghdlr->bufferpos++;
687
688 *inputword = firstword;
689
690 SCIPdebugMessage("next word: <%s>\n", *inputword);
691
692 return SCIP_OKAY;
693}
694
695/** adds a single line of input to the dialog handler which is treated as if the user entered the command line */
697 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
698 const char* inputline /**< input line to add */
699 )
700{
701 SCIP_LINELIST* linelist;
702 SCIP_RETCODE retcode = SCIP_OKAY;
703
704 assert(dialoghdlr != NULL);
705 assert(dialoghdlr->inputlistptr != NULL);
706 assert(*dialoghdlr->inputlistptr == NULL);
707 assert(inputline != NULL);
708
709 SCIP_ALLOC( BMSallocMemory(&linelist) );
710 SCIP_ALLOC_TERMINATE( retcode, BMSduplicateMemoryArray(&linelist->inputline, inputline, strlen(inputline)+1), TERMINATE );
711 linelist->nextline = NULL;
712 *dialoghdlr->inputlistptr = linelist;
713 dialoghdlr->inputlistptr = &linelist->nextline;
714
715 TERMINATE:
716 if( retcode != SCIP_OKAY )
717 BMSfreeMemory(&linelist);
718
719 return retcode;
720}
721
722/** adds a command to the command history of the dialog handler; if a dialog is given, the command is preceeded
723 * by the dialog's command path; if no command is given, only the path to the dialog is added to the command history
724 */
726 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
727 SCIP_DIALOG* dialog, /**< current dialog, or NULL */
728 const char* command, /**< command string to add to the command history, or NULL */
729 SCIP_Bool escapecommand /**< should special characters in command be prefixed by an escape char? */
730 )
731{
732 char s[SCIP_MAXSTRLEN];
733 char h[SCIP_MAXSTRLEN+1];
734 SCIP_Bool cleanuphistory;
735
736 assert(dialoghdlr != NULL);
737
738 /* the current history list should be cleaned up if a dialog is given (i.e. the command is not partial) */
739 cleanuphistory = (dialog != NULL);
740
741 /* generate the string to add to the history */
742 s[SCIP_MAXSTRLEN-1] = '\0';
743
744 if( command != NULL )
745 {
746 if( escapecommand )
748 else
749 (void)SCIPstrncpy(h, command, SCIP_MAXSTRLEN);
750 }
751 else
752 h[0] = '\0';
753
754 while( dialog != NULL && dialog != dialoghdlr->rootdialog )
755 {
756 if( h[0] == '\0' )
757 (void)SCIPstrncpy(h, dialog->name, SCIP_MAXSTRLEN);
758 else
759 {
760 (void)SCIPsnprintf(s, SCIP_MAXSTRLEN, "%s %s", dialog->name, h);
761 (void)SCIPstrncpy(h, s, SCIP_MAXSTRLEN);
762 }
763 dialog = dialog->parent;
764 }
765
766 /* clean up the unmarked history entries */
767 if( cleanuphistory )
768 {
769 int i;
770
771 for( i = getHistoryLength()-1; i >= dialoghdlr->nprotectedhistelems; --i )
772 {
774 }
775 }
776
777 /* add command to history */
778 if( h[0] != '\0' )
779 {
781 }
782
783 /* if the history string was a full command line, protect the history entry from future cleanups */
784 if( cleanuphistory )
785 {
787 }
788
789 return SCIP_OKAY;
790}
791
792
793
794
795/*
796 * dialog
797 */
798
799/** ensures, that sub-dialogs array can store at least the given number of sub-dialogs */
800static
802 SCIP_DIALOG* dialog, /**< dialog */
803 SCIP_SET* set, /**< global SCIP settings */
804 int num /**< minimal storage size for sub-dialogs */
805 )
806{
807 assert(dialog != NULL);
808
809 if( num > dialog->subdialogssize )
810 {
811 int newsize;
812
813 newsize = SCIPsetCalcMemGrowSize(set, num);
814 SCIP_ALLOC( BMSreallocMemoryArray(&(dialog->subdialogs), newsize) );
815 dialog->subdialogssize = newsize;
816 }
817 assert(num <= dialog->subdialogssize);
818
819 return SCIP_OKAY;
820}
821
822/** creates and captures a user interface dialog */
824 SCIP_DIALOG** dialog, /**< pointer to store the dialog */
825 SCIP_DECL_DIALOGCOPY ((*dialogcopy)), /**< copy method of dialog or NULL if you don't want to copy your plugin into sub-SCIPs */
826 SCIP_DECL_DIALOGEXEC ((*dialogexec)), /**< execution method of dialog */
827 SCIP_DECL_DIALOGDESC ((*dialogdesc)), /**< description output method of dialog, or NULL */
828 SCIP_DECL_DIALOGFREE ((*dialogfree)), /**< destructor of dialog to free user data, or NULL */
829 const char* name, /**< name of dialog: command name appearing in parent's dialog menu */
830 const char* desc, /**< description of dialog used if description output method is NULL */
831 SCIP_Bool issubmenu, /**< is the dialog a sub-menu? */
832 SCIP_DIALOGDATA* dialogdata /**< user defined dialog data */
833 )
834{
835 SCIP_RETCODE retcode;
836
837 assert(dialog != NULL);
838 assert(name != NULL);
839
840 retcode = SCIP_OKAY;
841
842 SCIP_ALLOC( BMSallocMemory(dialog) );
843 (*dialog)->dialogcopy = dialogcopy;
844 (*dialog)->dialogexec = dialogexec;
845 (*dialog)->dialogdesc = dialogdesc;
846 (*dialog)->dialogfree = dialogfree;
847
848 SCIP_ALLOC_TERMINATE( retcode, BMSduplicateMemoryArray(&(*dialog)->name, name, strlen(name)+1), TERMINATE );
849 if( desc != NULL )
850 {
851 SCIP_ALLOC_TERMINATE( retcode, BMSduplicateMemoryArray(&(*dialog)->desc, desc, strlen(desc)+1), TERMINATE );
852 }
853 else
854 (*dialog)->desc = NULL;
855
856 (*dialog)->issubmenu = issubmenu;
857 (*dialog)->parent = NULL;
858 (*dialog)->subdialogs = NULL;
859 (*dialog)->nsubdialogs = 0;
860 (*dialog)->subdialogssize = 0;
861 (*dialog)->nuses = 0;
862 (*dialog)->dialogdata = dialogdata;
863
864 /* capture dialog */
865 SCIPdialogCapture(*dialog);
866
867 TERMINATE:
868 if( retcode != SCIP_OKAY )
869 {
870 BMSfreeMemoryArrayNull(&(*dialog)->name);
871 BMSfreeMemory(dialog);
872 }
873
874 return retcode;
875}
876
877/** frees dialog and all of its sub-dialogs */
878static
880 SCIP* scip, /**< SCIP data structure */
881 SCIP_DIALOG** dialog /**< pointer to dialog */
882 )
883{
884 int i;
885
886 assert(dialog != NULL);
887 assert(*dialog != NULL);
888 assert((*dialog)->nuses == 0);
889
890 /* call destructor of dialog */
891 if( (*dialog)->dialogfree != NULL )
892 {
893 SCIP_CALL( (*dialog)->dialogfree(scip, *dialog) );
894 }
895
896 /* release sub-dialogs */
897 for( i = 0; i < (*dialog)->nsubdialogs; ++i )
898 {
899 SCIP_CALL( SCIPdialogRelease(scip, &(*dialog)->subdialogs[i]) );
900 }
901 BMSfreeMemoryArrayNull(&(*dialog)->subdialogs);
902
903 BMSfreeMemoryArrayNull(&(*dialog)->name);
904 BMSfreeMemoryArrayNull(&(*dialog)->desc);
905 BMSfreeMemory(dialog);
906
907 return SCIP_OKAY;
908}
909
910/** captures a dialog */
912 SCIP_DIALOG* dialog /**< dialog */
913 )
914{
915 assert(dialog != NULL);
916
917 dialog->nuses++;
918}
919
920/** releases a dialog */
922 SCIP* scip, /**< SCIP data structure */
923 SCIP_DIALOG** dialog /**< pointer to dialog */
924 )
925{
926 assert(dialog != NULL);
927
928 (*dialog)->nuses--;
929 if( (*dialog)->nuses == 0 )
930 {
931 SCIP_CALL( dialogFree(scip, dialog) );
932 }
933
934 return SCIP_OKAY;
935}
936
937/** executes dialog */
939 SCIP_DIALOG* dialog, /**< dialog */
940 SCIP_SET* set, /**< global SCIP settings */
941 SCIP_DIALOGHDLR* dialoghdlr, /**< dialog handler */
942 SCIP_DIALOG** nextdialog /**< pointer to store the next dialog to process */
943 )
944{
945 assert(dialog != NULL);
946 assert(dialog->dialogexec != NULL);
947 assert(set != NULL);
948 assert(nextdialog != NULL);
949
950 SCIP_CALL( dialog->dialogexec(set->scip, dialog, dialoghdlr, nextdialog) );
951
952 return SCIP_OKAY;
953}
954
955/** comparison method for sorting dialogs w.r.t. to their name */
956static
958{
959 return strcmp( SCIPdialogGetName((SCIP_DIALOG*)elem1), SCIPdialogGetName((SCIP_DIALOG*)elem2) );
960}
961
962/** adds a sub-dialog to the given dialog as menu entry and captures the sub-dialog */
964 SCIP_DIALOG* dialog, /**< dialog */
965 SCIP_SET* set, /**< global SCIP settings */
966 SCIP_DIALOG* subdialog /**< sub-dialog to add as menu entry in dialog */
967 )
968{
969 assert(dialog != NULL);
970 assert(subdialog != NULL);
971
972 /* check, if sub-dialog already exists */
973 if( SCIPdialogHasEntry(dialog, SCIPdialogGetName(subdialog)) )
974 {
975 SCIPerrorMessage("dialog entry with name <%s> already exists in dialog <%s>\n",
976 SCIPdialogGetName(subdialog), SCIPdialogGetName(dialog));
977 return SCIP_INVALIDDATA;
978 }
979
980 /* resize the sub-dialogs array */
981 SCIP_CALL( ensureSubdialogMem(dialog, set, dialog->nsubdialogs+1) );
982
983 /* link the dialogs as parent-child pair; the sub-dialogs are sorted non-decreasing w.r.t. their name */
984 SCIPsortedvecInsertPtr((void**)dialog->subdialogs, dialogComp, (void*)subdialog, &dialog->nsubdialogs, NULL);
985 subdialog->parent = dialog;
986
987 /* capture sub-dialog */
988 SCIPdialogCapture(subdialog);
989
990 return SCIP_OKAY;
991}
992
993/** returns TRUE iff a dialog entry matching exactly the given name is existing in the given dialog */
995 SCIP_DIALOG* dialog, /**< dialog */
996 const char* entryname /**< name of the dialog entry to find */
997 )
998{
999 SCIP_DIALOG** subdialogs;
1000 int nsubdialogs;
1001 int i;
1002
1003 assert(dialog != NULL);
1004 assert(entryname != NULL);
1005
1006 /* check entryname w.r.t. available dialog options */
1007 subdialogs = SCIPdialogGetSubdialogs(dialog);
1008 nsubdialogs = SCIPdialogGetNSubdialogs(dialog);
1009 for( i = 0; i < nsubdialogs; ++i )
1010 {
1011 /* check, if the sub-dialog's name matches entryname */
1012 if( strcmp(entryname, SCIPdialogGetName(subdialogs[i])) == 0 )
1013 return TRUE;
1014 }
1015
1016 return FALSE;
1017}
1018
1019/** searches the dialog for entries corresponding to the given name;
1020 * If a complete match is found, the entry is returned as "subdialog" and
1021 * the return value is 1.
1022 * If no dialog entry completely matches the given "entryname", the number
1023 * of entries with names beginning with "entryname" is returned. If this
1024 * number is 1, the single match is returned as "subdialog". Otherwise,
1025 * "subdialog" is set to NULL.
1026 */
1028 SCIP_DIALOG* dialog, /**< dialog */
1029 const char* entryname, /**< name of the dialog entry to find */
1030 SCIP_DIALOG** subdialog /**< pointer to store the found dialog entry */
1031 )
1032{
1033 SCIP_DIALOG** subdialogs;
1034 unsigned int namelen;
1035 int nsubdialogs;
1036 int nfound;
1037 int i;
1038
1039 assert(dialog != NULL);
1040 assert(entryname != NULL);
1041 assert(subdialog != NULL);
1042
1043 *subdialog = NULL;
1044
1045 /* check entryname w.r.t. available dialog options */
1046 subdialogs = SCIPdialogGetSubdialogs(dialog);
1047 nsubdialogs = SCIPdialogGetNSubdialogs(dialog);
1048 namelen = (unsigned int) strlen(entryname);
1049 nfound = 0;
1050 for( i = 0; i < nsubdialogs; ++i )
1051 {
1052 /* check, if the beginning of the sub-dialog's name matches entryname */
1053 if( strncmp(entryname, SCIPdialogGetName(subdialogs[i]), namelen) == 0 )
1054 {
1055 *subdialog = subdialogs[i];
1056 nfound++;
1057
1058 /* if entryname exactly matches the sub-dialog's name, use this sub-dialog */
1059 if( namelen == (unsigned int) strlen(SCIPdialogGetName(subdialogs[i])) )
1060 return 1;
1061 }
1062 }
1063
1064 if( nfound != 1 )
1065 *subdialog = NULL;
1066
1067 return nfound;
1068}
1069
1070/** displays the dialog's menu */
1072 SCIP_DIALOG* dialog, /**< dialog */
1073 SCIP* scip /**< SCIP data structure */
1074 )
1075{
1076 int i;
1077
1078 assert(dialog != NULL);
1079
1080 /* display the dialog's sub menus */
1081 for( i = 0; i < dialog->nsubdialogs; ++i )
1082 {
1083 if( SCIPdialogIsSubmenu(dialog->subdialogs[i]) )
1084 {
1086 }
1087 }
1088
1089 /* display the dialog's menu options */
1090 for( i = 0; i < dialog->nsubdialogs; ++i )
1091 {
1092 if( !SCIPdialogIsSubmenu(dialog->subdialogs[i]) )
1093 {
1095 }
1096 }
1097
1098 if( dialog->nsubdialogs == 0 )
1099 SCIPdialogMessage(scip, NULL, "<no options available>\n");
1100
1101 return SCIP_OKAY;
1102}
1103
1104/** displays the entry for the dialog in it's parent's menu */
1106 SCIP_DIALOG* dialog, /**< dialog */
1107 SCIP* scip /**< SCIP data structure */
1108 )
1109{
1110 char name[SCIP_MAXSTRLEN];
1111
1112 assert(dialog != NULL);
1113
1114 /* display the dialog's name */
1115 if( dialog->issubmenu )
1116 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "<%s>", dialog->name);
1117 else
1118 (void) SCIPsnprintf(name, SCIP_MAXSTRLEN, "%s", dialog->name);
1119 SCIPdialogMessage(scip, NULL, " %-21s ", name);
1120 if( strlen(name) > 21 )
1121 {
1122 /* break the line, and start the description in the next line */
1123 SCIPdialogMessage(scip, NULL, "\n --> ");
1124 }
1125
1126 /* display the dialog's description */
1127 if( dialog->dialogdesc != NULL )
1128 {
1129 SCIP_CALL( dialog->dialogdesc(scip, dialog) );
1130 }
1131 else
1132 SCIPdialogMessage(scip, NULL, "%s",dialog->desc);
1133 SCIPdialogMessage(scip, NULL, "\n");
1134
1135 return SCIP_OKAY;
1136}
1137
1138/** displays all dialog entries with names starting with the given "entryname" */
1140 SCIP_DIALOG* dialog, /**< dialog */
1141 SCIP* scip, /**< SCIP data structure */
1142 const char* entryname /**< name of the dialog entry to find */
1143 )
1144{
1145 SCIP_DIALOG** subdialogs;
1146 unsigned int namelen;
1147 int nsubdialogs;
1148 int i;
1149
1150 assert(dialog != NULL);
1151 assert(entryname != NULL);
1152
1153 /* check entryname w.r.t. available dialog options */
1154 subdialogs = SCIPdialogGetSubdialogs(dialog);
1155 nsubdialogs = SCIPdialogGetNSubdialogs(dialog);
1156 namelen = (unsigned int) strlen(entryname);
1157 for( i = 0; i < nsubdialogs; ++i )
1158 {
1159 /* check, if the beginning of the sub-dialog's name matches entryname */
1160 if( strncmp(entryname, SCIPdialogGetName(subdialogs[i]), namelen) == 0 )
1161 {
1162 SCIP_CALL( SCIPdialogDisplayMenuEntry(subdialogs[i], scip) );
1163 }
1164 }
1165
1166 return SCIP_OKAY;
1167}
1168
1169/** gets the name of the current path in the dialog tree, separated by the given character */
1171 SCIP_DIALOG* dialog, /**< dialog */
1172 const char sepchar, /**< separation character to insert in path */
1173 char* path /**< string buffer to store the path */
1174 )
1175{
1176 char s[SCIP_MAXSTRLEN];
1177
1178 assert(dialog != NULL);
1179
1180 (void)SCIPstrncpy(path, dialog->name, SCIP_MAXSTRLEN);
1181
1182 dialog = dialog->parent;
1183 while( dialog != NULL )
1184 {
1185 (void)SCIPsnprintf(s, SCIP_MAXSTRLEN, "%s%c%s", dialog->name, sepchar, path);
1186 (void)SCIPstrncpy(path, s, SCIP_MAXSTRLEN);
1187 dialog = dialog->parent;
1188 }
1189}
1190
1191/** gets the command name of the dialog */
1193 SCIP_DIALOG* dialog /**< dialog */
1194 )
1195{
1196 assert(dialog != NULL);
1197
1198 return dialog->name;
1199}
1200
1201/** gets the description of the dialog */
1203 SCIP_DIALOG* dialog /**< dialog */
1204 )
1205{
1206 assert(dialog != NULL);
1207
1208 return dialog->desc;
1209}
1210
1211/** returns whether the dialog is a sub menu */
1213 SCIP_DIALOG* dialog /**< dialog */
1214 )
1215{
1216 assert(dialog != NULL);
1217
1218 return dialog->issubmenu;
1219}
1220
1221/** gets the parent dialog of the given dialog */
1223 SCIP_DIALOG* dialog /**< dialog */
1224 )
1225{
1226 assert(dialog != NULL);
1227
1228 return dialog->parent;
1229}
1230
1231/** gets the array of sub-dialogs associated with the given dialog */
1233 SCIP_DIALOG* dialog /**< dialog */
1234 )
1235{
1236 assert(dialog != NULL);
1237
1238 return dialog->subdialogs;
1239}
1240
1241/** gets the number of sub-dialogs associated with the given dialog */
1243 SCIP_DIALOG* dialog /**< dialog */
1244 )
1245{
1246 assert(dialog != NULL);
1247
1248 return dialog->nsubdialogs;
1249}
1250
1251/** gets the user defined data associated with the given dialog */
1253 SCIP_DIALOG* dialog /**< dialog */
1254 )
1255{
1256 assert(dialog != NULL);
1257
1258 return dialog->dialogdata;
1259}
1260
1261/** sets user data of dialog; user has to free old data in advance! */
1263 SCIP_DIALOG* dialog, /**< dialog */
1264 SCIP_DIALOGDATA* dialogdata /**< new dialog user data */
1265 )
1266{
1267 assert(dialog != NULL);
1268
1269 dialog->dialogdata = dialogdata;
1270}
1271
1272/** writes command history to specified filename */
1274 const char* filename /**< file name for (over)writing history */
1275 )
1276{
1277 return writeHistory(filename);
1278}
SCIP_VAR * h
Definition: circlepacking.c:68
common defines and data types used in all packages of SCIP
#define NULL
Definition: def.h:262
#define SCIP_MAXSTRLEN
Definition: def.h:283
#define SCIP_Bool
Definition: def.h:91
#define SCIP_ALLOC(x)
Definition: def.h:380
#define SCIP_ALLOC_TERMINATE(retcode, x, TERM)
Definition: def.h:400
#define TRUE
Definition: def.h:93
#define FALSE
Definition: def.h:94
#define SCIP_CALL(x)
Definition: def.h:369
static SCIP_RETCODE readLine(SCIP_DIALOGHDLR *dialoghdlr, const char *prompt, SCIP_Bool *endoffile)
Definition: dialog.c:156
static SCIP_DECL_SORTPTRCOMP(dialogComp)
Definition: dialog.c:957
static SCIP_RETCODE addHistory(const char *s)
Definition: dialog.c:197
void SCIPdialogCapture(SCIP_DIALOG *dialog)
Definition: dialog.c:911
static int getHistoryLength(void)
Definition: dialog.c:207
static SCIP_RETCODE ensureSubdialogMem(SCIP_DIALOG *dialog, SCIP_SET *set, int num)
Definition: dialog.c:801
static void linelistFreeAll(SCIP_LINELIST **linelist)
Definition: dialog.c:253
SCIP_RETCODE SCIPdialogCreate(SCIP_DIALOG **dialog, SCIP_DECL_DIALOGCOPY((*dialogcopy)), SCIP_DECL_DIALOGEXEC((*dialogexec)), SCIP_DECL_DIALOGDESC((*dialogdesc)), SCIP_DECL_DIALOGFREE((*dialogfree)), const char *name, const char *desc, SCIP_Bool issubmenu, SCIP_DIALOGDATA *dialogdata)
Definition: dialog.c:823
SCIP_RETCODE SCIPdialogExec(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG **nextdialog)
Definition: dialog.c:938
SCIP_RETCODE SCIPdialoghdlrCreate(SCIP_SET *set, SCIP_DIALOGHDLR **dialoghdlr)
Definition: dialog.c:336
static SCIP_RETCODE readInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *prompt, SCIP_Bool *endoffile)
Definition: dialog.c:271
static void linelistFree(SCIP_LINELIST **linelist)
Definition: dialog.c:241
SCIP_RETCODE SCIPdialoghdlrFree(SCIP *scip, SCIP_DIALOGHDLR **dialoghdlr)
Definition: dialog.c:367
static SCIP_RETCODE dialogFree(SCIP *scip, SCIP_DIALOG **dialog)
Definition: dialog.c:879
static SCIP_RETCODE removeHistory(int pos)
Definition: dialog.c:216
SCIP_RETCODE SCIPdialogCopyInclude(SCIP_DIALOG *dialog, SCIP_SET *set)
Definition: dialog.c:318
SCIP_RETCODE SCIPdialogAddEntry(SCIP_DIALOG *dialog, SCIP_SET *set, SCIP_DIALOG *subdialog)
Definition: dialog.c:963
static SCIP_RETCODE writeHistory(const char *filename)
Definition: dialog.c:227
SCIP_RETCODE SCIPdialoghdlrExec(SCIP_DIALOGHDLR *dialoghdlr, SCIP_SET *set)
Definition: dialog.c:385
SCIP_RETCODE SCIPdialoghdlrSetRoot(SCIP *scip, SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog)
Definition: dialog.c:413
SCIP_RETCODE SCIPdialogRelease(SCIP *scip, SCIP_DIALOG **dialog)
Definition: dialog.c:921
internal methods for user interface dialog
void SCIPdialogMessage(SCIP *scip, FILE *file, const char *formatstr,...)
Definition: scip_message.c:191
void SCIPdialoghdlrClearBuffer(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:446
SCIP_DIALOG * SCIPdialoghdlrGetRoot(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:436
SCIP_Bool SCIPdialogHasEntry(SCIP_DIALOG *dialog, const char *entryname)
Definition: dialog.c:994
const char * SCIPdialogGetName(SCIP_DIALOG *dialog)
Definition: dialog.c:1192
SCIP_RETCODE SCIPdialoghdlrAddHistory(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *command, SCIP_Bool escapecommand)
Definition: dialog.c:725
SCIP_Bool SCIPdialoghdlrIsBufferEmpty(SCIP_DIALOGHDLR *dialoghdlr)
Definition: dialog.c:457
void SCIPdialogSetData(SCIP_DIALOG *dialog, SCIP_DIALOGDATA *dialogdata)
Definition: dialog.c:1262
SCIP_RETCODE SCIPdialoghdlrAddInputLine(SCIP_DIALOGHDLR *dialoghdlr, const char *inputline)
Definition: dialog.c:696
SCIP_RETCODE SCIPdialoghdlrGetWord(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *prompt, char **inputword, SCIP_Bool *endoffile)
Definition: dialog.c:546
const char * SCIPdialogGetDesc(SCIP_DIALOG *dialog)
Definition: dialog.c:1202
SCIP_DIALOG ** SCIPdialogGetSubdialogs(SCIP_DIALOG *dialog)
Definition: dialog.c:1232
SCIP_DIALOGDATA * SCIPdialogGetData(SCIP_DIALOG *dialog)
Definition: dialog.c:1252
SCIP_RETCODE SCIPdialogDisplayCompletions(SCIP_DIALOG *dialog, SCIP *scip, const char *entryname)
Definition: dialog.c:1139
int SCIPdialogGetNSubdialogs(SCIP_DIALOG *dialog)
Definition: dialog.c:1242
SCIP_RETCODE SCIPdialogDisplayMenuEntry(SCIP_DIALOG *dialog, SCIP *scip)
Definition: dialog.c:1105
SCIP_RETCODE SCIPdialogWriteHistory(const char *filename)
Definition: dialog.c:1273
int SCIPdialogFindEntry(SCIP_DIALOG *dialog, const char *entryname, SCIP_DIALOG **subdialog)
Definition: dialog.c:1027
SCIP_Bool SCIPdialogIsSubmenu(SCIP_DIALOG *dialog)
Definition: dialog.c:1212
SCIP_RETCODE SCIPdialoghdlrGetLine(SCIP_DIALOGHDLR *dialoghdlr, SCIP_DIALOG *dialog, const char *prompt, char **inputline, SCIP_Bool *endoffile)
Definition: dialog.c:470
SCIP_DIALOG * SCIPdialogGetParent(SCIP_DIALOG *dialog)
Definition: dialog.c:1222
SCIP_RETCODE SCIPdialogDisplayMenu(SCIP_DIALOG *dialog, SCIP *scip)
Definition: dialog.c:1071
void SCIPdialogGetPath(SCIP_DIALOG *dialog, const char sepchar, char *path)
Definition: dialog.c:1170
void SCIPsortedvecInsertPtr(void **ptrarray, SCIP_DECL_SORTPTRCOMP((*ptrcomp)), void *keyval, int *len, int *pos)
int SCIPsnprintf(char *t, int len, const char *s,...)
Definition: misc.c:10878
void SCIPescapeString(char *t, int bufsize, const char *s)
Definition: misc.c:10833
int SCIPstrncpy(char *t, const char *s, int size)
Definition: misc.c:10948
memory allocation routines
#define BMSfreeMemory(ptr)
Definition: memory.h:145
#define BMSreallocMemoryArray(ptr, num)
Definition: memory.h:127
#define BMSduplicateMemoryArray(ptr, source, num)
Definition: memory.h:143
#define BMSallocMemoryArray(ptr, num)
Definition: memory.h:123
#define BMSfreeMemoryArray(ptr)
Definition: memory.h:147
#define BMSfreeMemoryArrayNull(ptr)
Definition: memory.h:148
#define BMSallocMemory(ptr)
Definition: memory.h:118
#define SCIPerrorMessage
Definition: pub_message.h:64
#define SCIPdebugMessage
Definition: pub_message.h:96
public data structures and miscellaneous methods
SCIP callable library.
int SCIPsetCalcMemGrowSize(SCIP_SET *set, int num)
Definition: set.c:5764
SCIP_RETCODE SCIPsetIncludeExternalCode(SCIP_SET *set, const char *name, const char *description)
Definition: set.c:5213
internal methods for global SCIP settings
#define SCIPsetDebugMsg
Definition: set.h:1784
SCIP_DIALOG * parent
Definition: struct_dialog.h:53
SCIP_DIALOG ** subdialogs
Definition: struct_dialog.h:54
SCIP_Bool issubmenu
Definition: struct_dialog.h:59
SCIP_DIALOGDATA * dialogdata
Definition: struct_dialog.h:55
int subdialogssize
Definition: struct_dialog.h:57
SCIP_LINELIST * inputlist
Definition: struct_dialog.h:73
SCIP_DIALOG * rootdialog
Definition: struct_dialog.h:72
SCIP_LINELIST ** inputlistptr
Definition: struct_dialog.h:74
SCIP_LINELIST * nextline
Definition: struct_dialog.h:66
char * inputline
Definition: struct_dialog.h:65
data structures for user interface dialog
Definition: heur_padm.c:135
#define SCIP_DECL_DIALOGCOPY(x)
Definition: type_dialog.h:62
#define SCIP_DECL_DIALOGEXEC(x)
Definition: type_dialog.h:96
struct SCIP_DialogData SCIP_DIALOGDATA
Definition: type_dialog.h:51
#define SCIP_DECL_DIALOGFREE(x)
Definition: type_dialog.h:70
#define SCIP_DECL_DIALOGDESC(x)
Definition: type_dialog.h:82
@ SCIP_FILECREATEERROR
Definition: type_retcode.h:48
@ SCIP_INVALIDDATA
Definition: type_retcode.h:52
@ SCIP_OKAY
Definition: type_retcode.h:42
enum SCIP_Retcode SCIP_RETCODE
Definition: type_retcode.h:63