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