home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sd386v50.zip / sd386src.zip / ACTION.C < prev    next >
Text File  |  1995-11-30  |  50KB  |  1,246 lines

  1. /*****************************************************************************/
  2. /* File:                                             IBM INTERNAL USE ONLY   */
  3. /*   action.c                                                                */
  4. /*                                                                           */
  5. /* Description:                                                              */
  6. /*                                                                           */
  7. /*   Functions requiring prompt strings from the user.                       */
  8. /*                                                                           */
  9. /*...Release 1.01 (07/10/92)                                                 */
  10. /*...                                                                        */
  11. /*... 10/05/92  707   Selwyn    Function entry/address breaks not getting    */
  12. /*...                           marked.                                      */
  13. /*... 11/16/92  802   Selwyn    Fix browse dialog remaining after "*" entry. */
  14. /*****************************************************************************/
  15.  
  16. #include "all.h"
  17. #include "popups.h"
  18.  
  19. static int iview=0;
  20.  
  21. /*****************************************************************************/
  22. /* Externals.                                                                */
  23. /*****************************************************************************/
  24. extern CmdParms      cmd;               /* pointer to CmdParms structure     */
  25. extern AFILE        *allfps;
  26.  
  27. static char   FindString[MAXPROMPTSTRING];
  28.  
  29. /*****************************************************************************/
  30. /* Data for getfunc popup.                                                   */
  31. /*****************************************************************************/
  32. #define GETFUNCHELP HELP_DLG_GETFUNC
  33. #define GETADDRHELP HELP_DLG_GETADDR
  34.  
  35. static uchar  CantFind[]         = "Can't find that";
  36. static char   GF_Title[]         = " Search for a function ";
  37. static char   GF_Instructions[]  = "Enter the function name";
  38. static char   GA_Title[]         = " Search for an address ";
  39. static char   GA_Instructions[]  = "Enter an address";
  40.  
  41.  
  42. static BUTTON PopButton[] =
  43. {
  44.  {
  45.   POP_BTN_ROW         ,
  46.   POP_BTN_ENTER_COL   ,
  47.   POP_BTN_ENTER_WIDTH ,
  48.   POP_BTN_ENTER_TEXT  ,
  49.   POP_BTN_ENTER_KEY
  50.  },
  51.  {
  52.   POP_BTN_ROW         ,
  53.   POP_BTN_CANCEL_COL  ,
  54.   POP_BTN_CANCEL_WIDTH,
  55.   POP_BTN_CANCEL_TEXT ,
  56.   POP_BTN_CANCEL_KEY
  57.  },
  58.  {
  59.   POP_BTN_ROW         ,
  60.   POP_BTN_HELP_COL    ,
  61.   POP_BTN_HELP_WIDTH  ,
  62.   POP_BTN_HELP_TEXT   ,
  63.   POP_BTN_HELP_KEY
  64.  }
  65. };
  66.  
  67. static POPUPSHELL Popup = {
  68.                            POP_START_ROW   ,
  69.                            POP_START_COL   ,
  70.                            POP_LEN         ,
  71.                            POP_WIDTH       ,
  72.                            POP_BUTTONS     ,
  73.                            NULL            ,
  74.                            NULL            ,
  75.                            0               ,
  76.                            &PopButton[0]
  77.                           };
  78.  
  79. /*****************************************************************************/
  80. /* Data for getfile popup.                                                   */
  81. /*****************************************************************************/
  82. #define GETFILEHELP HELP_DLG_GETFILE
  83.  
  84. static char   GE_Title[]         = " Search for a file ";
  85. static char   GE_Instructions[]  = "Enter a source file name";
  86.  
  87. /*****************************************************************************/
  88. /* Data for find popup.                                                      */
  89. /*****************************************************************************/
  90. #define FINDSTRHELP HELP_DLG_FIND
  91.  
  92. static char   FI_Title[]         = " Search for a string ";
  93. static char   FI_Instructions[]  = "Enter the string ";
  94.  
  95. /*****************************************************************************/
  96. /* Data for browse popup.                                                    */
  97. /*****************************************************************************/
  98. #define BROWSEHELP HELP_DLG_BROWSE
  99.  
  100. static char   BR_Title[]         = " Browse a file ";
  101. static char   BR_Instructions[]  = "Enter the file name ";
  102.  
  103. /*****************************************************************************/
  104. /* Data for browse popup.                                                    */
  105. /*****************************************************************************/
  106. #define CONDBPHELP HELP_DLG_SETCONDBKP
  107.  
  108. static char   CB_Title[]         = " Set a conditional break";
  109. static char   CB_Instructions[]  = "Enter an expression";
  110.  
  111. /*****************************************************************************/
  112. /* Data for Name or Addr popup.                                              */
  113. /*****************************************************************************/
  114. #define IDFUNCHELP  HELP_DLG_FUNCENTRY
  115. #define IDADDRHELP  HELP_DLG_ADDRESS
  116. #define IDDEFRHELP  HELP_DLG_DEFERRED
  117. #define IDLOADHELP  HELP_DLG_ADDRLOAD
  118. #define IDDLLHELP   HELP_DLG_DLLLOAD
  119.  
  120. static char   IF_Title[]         = " Set a function break ";
  121. static char   IF_Instructions[]  = "Enter [dllname.]funcname";
  122.  
  123. static char   IA_Title[]         = " Set an address break ";
  124. static char   IA_Instructions[]  = "Enter an address";
  125.  
  126. static char   ID_Title[]         = " Set a deferred break ";
  127. static char   ID_Instructions[]  = "Enter [dllname.]funcname";
  128.  
  129. static char   IO_Title[]         = " Set a load address break ";
  130. static char   IO_Instructions[]  = "Enter an address";
  131.  
  132. static char   IL_Title[]         = " Set a dll load break ";
  133. static char   IL_Instructions[]  = "Enter dll name(w/o path or extension)";
  134. /*****************************************************************************/
  135. /* Data for GetLineNumber.                                                   */
  136. /*****************************************************************************/
  137. #define LNFUNCHELP  HELP_DLG_GETLINENUMBER
  138.  
  139. static char   LN_Title[]         = " Go to a line number ";
  140. static char   LN_Instructions[]  = "Enter the line number";
  141.  
  142. /*****************************************************************************/
  143. /* Data for getformattype popup.                                             */
  144. /*****************************************************************************/
  145. #define GETTYPEHELP HELP_DLG_GETTYPE
  146.  
  147. static char   GT_Title[]         = " Get Format Type ";
  148. static char   GT_Instructions[]  = "Enter data type";
  149.  
  150. /*****************************************************************************/
  151. /* GetFunction()                                                             */
  152. /*                                                                           */
  153. /* Description:                                                              */
  154. /*                                                                           */
  155. /*   Prompt the user for a function name and then try to build a view        */
  156. /*   for that function.                                                      */
  157. /*                                                                           */
  158. /* Parameters:                                                               */
  159. /*                                                                           */
  160. /*   InitString  -> to a string to use as an initial prompt.                 */
  161. /*                                                                           */
  162. /* Return Value:                                                             */
  163. /*                                                                           */
  164. /*   fp          -> to AFILE structure containing the new view.              */
  165. /*   NULL        couldn't find the specified function. Or, escaped.          */
  166. /*                                                                           */
  167. /*  Assumptions:                                                             */
  168. /*                                                                           */
  169. /*   none                                                                    */
  170. /*                                                                           */
  171. /*****************************************************************************/
  172.  AFILE *
  173. GetFunction( char *InitString , uint func )
  174. {
  175.  char  *hp;
  176.  uint   key;
  177.  char   PromptString[MAXPROMPTSTRING];
  178.  AFILE *fp;
  179.  uchar *SaveArea;
  180.  int    IsAddr;
  181.  static int _iview;
  182.  
  183.  /****************************************************************************/
  184.  /* - copy the initstring ( cursor sensitive prompt ) into the prompt string.*/
  185.  /* - put the title, instructions, and help appropriate for this popup       */
  186.  /*   into the popup structure.                                              */
  187.  /* - save the screen area.                                                  */
  188.  /* - get a function name from the user.                                     */
  189.  /* - handle user string and keys.                                           */
  190.  /* - handle errors.                                                         */
  191.  /* - restore the screen save area.                                          */
  192.  /*                                                                          */
  193.  /****************************************************************************/
  194.  fp = NULL;
  195.  
  196. #if defined(MSH)
  197.  if(commandLine.nparms>1) {
  198.     IsAddr = (func==GETADDRESS)?TRUE:FALSE;
  199.     fp = FindFuncOrAddr(commandLine.parms[1],IsAddr);
  200.     if(fp)
  201.     {
  202. #if defined(SD386LOG)
  203.         SD386Log(STRINGCODE," ");
  204.         SD386Log(STRINGCODE,commandLine.parms[1]);
  205. #endif
  206.         return(fp);
  207.     }
  208.  }
  209. #endif
  210.  _iview=iview; iview=0;
  211.  strcpy(PromptString,InitString);
  212.  Popup.Flags = 0;
  213.  if( func == GETFUNCTION )
  214.  {
  215.   Popup.title = GF_Title;
  216.   Popup.instructions = GF_Instructions;
  217.   Popup.help = GETFUNCHELP;
  218.   Popup.Flags = CLEAR1ST;
  219.  }
  220.  else /* func == GETADDRESS */
  221.  {
  222.   Popup.title = GA_Title;
  223.   Popup.instructions = GA_Instructions;
  224.   Popup.help = GETADDRHELP;
  225.  }
  226.  
  227.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  228.  GetPopArea(SaveArea);
  229.  DisplayPop( &Popup );
  230.  
  231.  /****************************************************************************/
  232.  /* loop to handle user entry/errors.                                        */
  233.  /****************************************************************************/
  234.  for(;;)
  235.  {
  236.   if( func == GETFUNCTION )
  237.    hp = GF_Instructions;
  238.   else
  239.    hp = GA_Instructions;
  240.  
  241.   key = PopPrompt( PromptString, hp);
  242.  
  243.   stripblk(PromptString);
  244.  
  245.  
  246.   if( key == ESC )
  247.   {
  248. #if 0
  249.     SD386Log(STRINGCODE," ");
  250.    SD386Log(KEYCODE|key,"");
  251. #endif
  252.    break;
  253.   }
  254.   else if ( key == ENTER )
  255.   {
  256.    if( strlen(PromptString) == 0 )
  257.     continue;
  258.    IsAddr = (func==GETADDRESS)?TRUE:FALSE;
  259.    fp = FindFuncOrAddr(PromptString,IsAddr);
  260.    if( fp )
  261.    {
  262. #if 0
  263.     SD386Log(STRINGCODE," ");
  264.     SD386Log(STRINGCODE,PromptString);
  265. #endif
  266.     break;
  267.    }
  268.  
  269.    /**************************************************************************/
  270.    /* display an error message and then ask for another name.                */
  271.    /**************************************************************************/
  272.    beep();
  273.    hp = CantFind;
  274.    fmterr( hp);
  275.    continue;
  276.   }
  277.  }
  278.  
  279.  PutPopArea(SaveArea);
  280.  Tfree(SaveArea );
  281.  iview=_iview;
  282.  return(fp);
  283. }
  284. /*****************************************************************************/
  285. /* GetF()                                                                    */
  286. /*                                                                           */
  287. /* Description:                                                              */
  288. /*                                                                           */
  289. /*   Prompt the user for a file name and then try to build a view            */
  290. /*   for that function.                                                      */
  291. /*                                                                           */
  292. /* Parameters:                                                               */
  293. /*                                                                           */
  294. /*   none                                                                    */
  295. /*                                                                           */
  296. /* Return Value:                                                             */
  297. /*                                                                           */
  298. /*   fp          -> to AFILE structure containing the new view.              */
  299. /*   NULL        couldn't find the specified file. Or, escaped.              */
  300. /*                                                                           */
  301. /*  Assumptions:                                                             */
  302. /*                                                                           */
  303. /*                                                                           */
  304. /*****************************************************************************/
  305.  AFILE *
  306. GetF( )
  307. {
  308.  char  *hp;
  309.  uint   key;
  310.  char   PromptString[MAXPROMPTSTRING];
  311.  AFILE *fp;
  312.  uchar *SaveArea;
  313.  
  314.  static int _iview;
  315.  /****************************************************************************/
  316.  /* - put the title, instructions, and help appropriate for this popup       */
  317.  /*   into the popup structure.                                              */
  318.  /* - save the screen area used by the popup if CUA interface.               */
  319.  /* - get a function name from the user.                                     */
  320.  /* - handle user string and keys.                                           */
  321.  /* - handle errors.                                                         */
  322.  /* - restore the screen save area if CUA interface.                         */
  323.  /*                                                                          */
  324.  /****************************************************************************/
  325.  fp = NULL;
  326. #if defined(MSH)
  327.  if(commandLine.nparms>1) {
  328.     fp=GetFile(commandLine.parms[1]);
  329.     if(fp)
  330.     {
  331. #if defined(SD386LOG)
  332.         SD386Log(STRINGCODE," ");
  333.         SD386Log(STRINGCODE,commandLine.parms[1]);
  334. #endif
  335.         return fp;
  336.     }
  337.  }
  338. #endif
  339.  _iview=iview; iview=0;
  340.  *PromptString = '\0';
  341.  
  342.  Popup.title = GE_Title;
  343.  Popup.instructions = GE_Instructions;
  344.  Popup.help = GETFILEHELP;
  345.  
  346.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  347.  GetPopArea(SaveArea);
  348.  DisplayPop( &Popup );
  349.  
  350.  /****************************************************************************/
  351.  /* loop to handle user entry/errors.                                        */
  352.  /****************************************************************************/
  353.  for(;;)
  354.  {
  355.   hp = GE_Instructions;
  356.   key = PopPrompt( PromptString, hp);
  357.  
  358.   stripblk(PromptString);
  359.  
  360.   if( key == ESC )
  361.   {
  362. #if 0
  363.     SD386Log(STRINGCODE," ");
  364.    SD386Log(KEYCODE|key,"");
  365. #endif
  366.    break;
  367.   }
  368.   else if ( key == ENTER )
  369.   {
  370.    if( strlen(PromptString) == 0 )
  371.     continue;
  372.    fp = GetFile(PromptString);
  373.    if( fp )
  374.    {
  375. #if 0
  376.         SD386Log(STRINGCODE," ");
  377.         SD386Log(STRINGCODE,PromptString);
  378. #endif
  379.         break;
  380.    }
  381.  
  382.    /**************************************************************************/
  383.    /* display an error message and then ask for another name.                */
  384.    /**************************************************************************/
  385.    beep();
  386.    hp = CantFind;
  387.    fmterr( hp);
  388.    continue;
  389.   }
  390.  }
  391.  
  392.  PutPopArea(SaveArea);
  393.  Tfree(SaveArea );
  394.  iview=_iview;
  395.  return(fp);
  396. }
  397.  
  398. /*****************************************************************************/
  399. /* FindStr()                                                                 */
  400. /*                                                                           */
  401. /* Description:                                                              */
  402. /*                                                                           */
  403. /*   Get a string to find from the user in the current view.                 */
  404. /*                                                                           */
  405. /* Parameters:                                                               */
  406. /*                                                                           */
  407. /*   fp          -> to the view we're searching in.                          */
  408. /*                                                                           */
  409. /* Return Value:                                                             */
  410. /*                                                                           */
  411. /*   none                                                                    */
  412. /*                                                                           */
  413. /*  Assumptions:                                                             */
  414. /*                                                                           */
  415. /*****************************************************************************/
  416. void FindStr( AFILE *fp )
  417. {
  418.  char  *hp;
  419.  uint   key;
  420.  uchar *SaveArea;
  421.  
  422.  static int _iview;
  423.  /****************************************************************************/
  424.  /* - put the title, instructions, and help appropriate for this popup       */
  425.  /*   into the popup structure.                                              */
  426.  /* - save the screen area used by the popup if CUA interface.               */
  427.  /* - get the string to find from the user.                                  */
  428.  /* - handle user string and keys.                                           */
  429.  /* - handle errors.                                                         */
  430.  /* - restore the screen save area if CUA interface.                         */
  431.  /*                                                                          */
  432.  /****************************************************************************/
  433. #if defined(MSH)
  434.  if(commandLine.nparms>1) {
  435.     strcpy(FindString,commandLine.parms[1]);
  436.     if(ScanStr(fp)) {
  437. #if defined(SD386LOG)
  438.         SD386Log(STRINGCODE," ");
  439.         SD386Log(STRINGCODE,commandLine.parms[1]);
  440. #endif
  441.         return;
  442.     }
  443.  }
  444. #endif
  445.  
  446.  Popup.title = FI_Title;
  447.  Popup.instructions = FI_Instructions;
  448.  Popup.help = FINDSTRHELP;
  449.  Popup.Flags = CLEAR1ST;
  450.  
  451.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  452.  GetPopArea(SaveArea);
  453.  DisplayPop( &Popup );
  454.  
  455.  /****************************************************************************/
  456.  /* - loop to handle user entry/errors.                                      */
  457.  /*                                                                          */
  458.  /*                                                                          */
  459.  /* NOTE:                                                                    */
  460.  /*   FindString is a static variable that will be saved for repeat finds and*/
  461.  /*   subsequent prompts.                                                    */
  462.  /****************************************************************************/
  463.  for(;;)
  464.  {
  465.   hp = FI_Instructions;
  466.   key = PopPrompt( FindString, hp);
  467.  
  468.   stripblk(FindString);
  469.  
  470.   if( key == ESC )
  471.   {
  472. #if 0
  473.     SD386Log(STRINGCODE," ");
  474.     SD386Log(KEYCODE|key,"");
  475. #endif
  476.     break;
  477.   }
  478.   else if ( key == ENTER )
  479.   {
  480.    if( strlen(FindString) == 0 )
  481.     continue;
  482.  
  483.    if( ScanStr(fp) )
  484.    {
  485. #if 0
  486.     SD386Log(STRINGCODE," ");
  487.     SD386Log(KEYCODE|key,"");
  488. #endif
  489.     break;
  490.    }
  491.  
  492.    /**************************************************************************/
  493.    /* display an error message and then ask for another name.                */
  494.    /**************************************************************************/
  495.    beep();
  496.    hp = CantFind;
  497.    fmterr( hp);
  498.    continue;
  499.   }
  500.  }
  501.  
  502.  PutPopArea(SaveArea);
  503.  Tfree(SaveArea );
  504.  iview=_iview;
  505. }
  506.  
  507. /*****************************************************************************/
  508. /* ScanStr()                                                                 */
  509. /*                                                                           */
  510. /* Description:                                                              */
  511. /*                                                                           */
  512. /*   Find a string in the view and modify the view structure to              */
  513. /*   reflect the find.                                                       */
  514. /*                                                                           */
  515. /* Parameters:                                                               */
  516. /*                                                                           */
  517. /*   none                                                                    */
  518. /*                                                                           */
  519. /* Return                                                                    */
  520. /*                                                                           */
  521. /*   rc         1 => success ( I know...it's backwards!! )                   */
  522. /*              0 => failure                                                 */
  523. /*                                                                           */
  524. /* Assumptions:                                                              */
  525. /*                                                                           */
  526. /*   fp != NULL                                                              */
  527. /*                                                                           */
  528. /*****************************************************************************/
  529. extern uint   LinesPer;
  530.  
  531. int ScanStr( AFILE *fp )
  532. {
  533.  uint          delta;
  534.  int           rc = 0;
  535.  
  536.  rc = scan(fp, FindString);
  537.  if( rc )
  538.  {
  539.   delta = fp->csrline - fp->topline;
  540.   if( delta >= LinesPer )
  541.   {
  542.    fp->topline=fp->csrline-LinesPer/2;
  543.    if( (int)fp->topline < 1 )
  544.     fp->topline = 1;
  545.   }
  546.  }
  547.  return(rc);
  548. }
  549.  
  550. /*****************************************************************************/
  551. /* BrowseFile()                                                              */
  552. /*                                                                           */
  553. /* Description:                                                              */
  554. /*                                                                           */
  555. /*   Find a string in the view and update the view.                          */
  556. /*                                                                           */
  557. /* Parameters:                                                               */
  558. /*                                                                           */
  559. /*   none                                                                    */
  560. /*                                                                           */
  561. /* Return Value:                                                             */
  562. /*                                                                           */
  563. /*   none                                                                    */
  564. /*                                                                           */
  565. /*  Assumptions:                                                             */
  566. /*                                                                           */
  567. /*****************************************************************************/
  568.  void
  569. BrowseFile( )
  570. {
  571.  char  *hp;
  572.  uint   key;
  573.  char   PromptString[MAXPROMPTSTRING];
  574.  uchar *SaveArea;
  575.  
  576.  
  577.  static int _iview;
  578.  /****************************************************************************/
  579.  /* - put the title, instructions, and help appropriate for this popup       */
  580.  /*   into the popup structure.                                              */
  581.  /* - save the screen area used by the popup if CUA interface.               */
  582.  /* - get the file to browse from the user.                                  */
  583.  /* - handle user string and keys.                                           */
  584.  /* - handle errors.                                                         */
  585.  /* - restore the screen save area if CUA interface.                         */
  586.  /*                                                                          */
  587.  /****************************************************************************/
  588.  
  589. #if defined(MSH)
  590.  if(commandLine.nparms>1)
  591.  {
  592.    uchar    *fnfull;                    /* fully qualified filespec.         */
  593.    int       fnlen, rc;                 /* filename/filespec buffer length.  */
  594.    fnlen = CCHMAXPATH;
  595.    fnfull = Talloc( fnlen );
  596.    rc = FindExe( commandLine.parms[1], fnfull+1 , fnlen );
  597.    if(!rc) {
  598.        if( !browse(commandLine.parms[1], 0) ) {
  599. #if defined(SD386LOG)
  600.          SD386Log(STRINGCODE," ");
  601.          SD386Log(STRINGCODE,commandLine.parms[1]);
  602. #endif
  603.          return;
  604.        }
  605.     }
  606.  }
  607. #endif
  608.  
  609.  _iview=iview; iview=0;
  610.  *PromptString = '\0';
  611.  
  612.  Popup.title = BR_Title;
  613.  Popup.instructions = BR_Instructions;
  614.  Popup.help = BROWSEHELP;
  615.  
  616.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  617.  GetPopArea(SaveArea);
  618.  DisplayPop( &Popup );
  619.  
  620.  /****************************************************************************/
  621.  /* - loop to handle user entry/errors.                                      */
  622.  /****************************************************************************/
  623.  for(;;)
  624.  {
  625.   hp = BR_Instructions;
  626.   key = PopPrompt( PromptString, hp);
  627.  
  628.   stripblk(PromptString);
  629.  
  630.   if( key == ESC )
  631.   {
  632. #if 0
  633.    SD386Log(STRINGCODE," ");
  634.    SD386Log(KEYCODE|key,"");
  635. #endif
  636.    break;
  637.   }
  638.  
  639.   else if ( key == ENTER )
  640.   {
  641.    uchar    *fnfull;                    /* fully qualified filespec.         */
  642.    int       fnlen, rc;                 /* filename/filespec buffer length.  */
  643.  
  644.    if( strlen(PromptString) == 0 )
  645.     continue;
  646.  
  647.    if( strpbrk( PromptString, "*?" ) )                                  /*802*/
  648.    {                                                                    /*802*/
  649.      hp = CantFind;                                                     /*802*/
  650.      fmterr( hp );                                                      /*802*/
  651.      beep();                                                            /*802*/
  652.      continue;                                                          /*802*/
  653.    }                                                                    /*802*/
  654.  
  655.    fnlen = CCHMAXPATH;
  656.    fnfull = Talloc( fnlen );
  657.    rc = FindExe( PromptString, fnfull+1 , fnlen );
  658.    if( !rc )
  659.    {
  660.     PutPopArea(SaveArea);
  661.     Tfree(SaveArea );
  662.     SaveArea = NULL;
  663.     if( !browse(PromptString, 0) )
  664.     {
  665. #if 0
  666.       SD386Log(STRINGCODE," ");
  667.       SD386Log(STRINGCODE,PromptString);
  668. #endif
  669.       break;
  670.     }
  671.    }
  672.  
  673.    /**************************************************************************/
  674.    /* display an error message and then ask for another name.                */
  675.    /**************************************************************************/
  676.    beep();
  677.    hp = CantFind;
  678.    fmterr( hp);
  679.    continue;
  680.   }
  681.  }
  682.  if( SaveArea != NULL )
  683.  {
  684.   PutPopArea(SaveArea);
  685.   Tfree(SaveArea );
  686.   iview=_iview;
  687.  }
  688. }
  689.  
  690.  
  691. #ifdef MSH
  692. /*****************************************************************************/
  693. /* BrowseMshFile()                                                           */
  694. /*                                                                           */
  695. /* Description:                                                              */
  696. /*                                                                           */
  697. /*   Find a string in the view and update the view.                          */
  698. /*                                                                           */
  699. /* Parameters:                                                               */
  700. /*                                                                           */
  701. /*   none                                                                    */
  702. /*                                                                           */
  703. /* Return Value:                                                             */
  704. /*                                                                           */
  705. /*   none                                                                    */
  706. /*                                                                           */
  707. /*  Assumptions:                                                             */
  708. /*                                                                           */
  709. /*****************************************************************************/
  710. WINDOWEVENT *BrowseMshFile(AFILE *fp)
  711. {
  712.  char *hp;
  713.  static WINDOWEVENT we;
  714.  
  715.  /****************************************************************************/
  716.  /* - put the title, instructions, and help appropriate for this popup       */
  717.  /*   into the popup structure.                                              */
  718.  /* - save the screen area used by the popup if CUA interface.               */
  719.  /* - get the file to browse from the user.                                  */
  720.  /* - handle user string and keys.                                           */
  721.  /* - handle errors.                                                         */
  722.  /* - restore the screen save area if CUA interface.                         */
  723.  /*                                                                          */
  724.  /****************************************************************************/
  725.  
  726.     if( !browsem(0,fp,&we) )
  727.     {
  728. #if defined(SD386LOG)
  729.       SD386Log(STRINGCODE," ");
  730.       SD386Log(STRINGCODE,PromptString);
  731. #endif
  732.       return(&we);
  733.     }
  734.     else {
  735.    /**************************************************************************/
  736.    /* display an error message and then ask for another name.                */
  737.    /**************************************************************************/
  738.    beep();
  739.    hp = CantFind;
  740.    fmterr( hp);
  741.    }
  742. }
  743.  
  744. #endif
  745.  
  746. /*****************************************************************************/
  747. /* SetCondBreak()                                                            */
  748. /*                                                                           */
  749. /* Description:                                                              */
  750. /*                                                                           */
  751. /*   Set a conditional breakpoint.                                           */
  752. /*                                                                           */
  753. /* Parameters:                                                               */
  754. /*                                                                           */
  755. /*   fp             -> to AFILE structure containing the current view.       */
  756. /*   SrcLnNumOfCsr  the source line number that the cursor is currently      */
  757. /*                  on.                                                      */
  758. /*   pSrcLnInBuf    -> to the source line in the source buffer.              */
  759. /*                                                                           */
  760. /* Return                                                                    */
  761. /*                                                                           */
  762. /*   void                                                                    */
  763. /*                                                                           */
  764. /*  Assumptions:                                                             */
  765. /*                                                                           */
  766. /*                                                                           */
  767. /*****************************************************************************/
  768.  void
  769. SetCondBrk( AFILE *fp, uint SrcLnNumOfCsr, uchar *pSrcLnInBuf )
  770. {
  771.  char  *hp;
  772.  uint   key;
  773.  char   PromptString[MAXPROMPTSTRING];
  774.  char  *msg;
  775.  uchar  SrcLnFlag;
  776.  BRK   *pBrk;
  777.  uchar *SaveArea;
  778.  static int _iview;
  779.  
  780. #if defined(MSH)
  781.  if(commandLine.nparms>1) {
  782.     msg = SetLineBRK( fp,SrcLnNumOfCsr,pSrcLnInBuf,BRK_COND,commandLine.parms[1]);
  783. #if defined(SD386LOG)
  784.     SD386Log(STRINGCODE," ");
  785.     SD386Log(STRINGCODE,commandLine.parms[1]);
  786. #endif
  787.  }
  788. #endif
  789.  
  790.  _iview=iview; iview=0;
  791.  *PromptString = '\0';
  792.  /***************************************************************************/
  793.  /* If there is a conditional bp already on this line, then we need to      */
  794.  /* initialize the PromptString to the last prompt.                         */
  795.  /***************************************************************************/
  796.  SrcLnFlag = *(pSrcLnInBuf-1);
  797.  if( (SrcLnFlag & LINE_BP) &&
  798.      (pBrk=IsBrk(fp , SrcLnNumOfCsr) ) &&
  799.       pBrk->cond )
  800.   strcpy(PromptString, pBrk->cond->pCondition);
  801.  
  802.  /****************************************************************************/
  803.  /* - put the title, instructions, and help appropriate for this popup       */
  804.  /*   into the popup structure.                                              */
  805.  /* - save the screen area used by the popup if CUA interface.               */
  806.  /* - get the file to browse from the user.                                  */
  807.  /* - handle user string and keys.                                           */
  808.  /* - handle errors.                                                         */
  809.  /* - restore the screen save area if CUA interface.                         */
  810.  /*                                                                          */
  811.  /****************************************************************************/
  812.  Popup.title = CB_Title;
  813.  Popup.instructions = CB_Instructions;
  814.  Popup.help = CONDBPHELP;
  815.  
  816.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  817.  GetPopArea(SaveArea);
  818.  DisplayPop( &Popup );
  819.  
  820.  /****************************************************************************/
  821.  /* - loop to handle user entry/errors.                                      */
  822.  /****************************************************************************/
  823.  for(;;)
  824.  {
  825.   hp = CB_Instructions;
  826.   key = PopPrompt( PromptString, hp);
  827.  
  828.   stripblk(PromptString);
  829.  
  830.   if( key == ESC )
  831.   {
  832. #if 0
  833.    SD386Log(STRINGCODE," ");
  834.    SD386Log(KEYCODE|key,"");
  835. #endif
  836.    break;
  837.   }
  838.   else if ( key == ENTER )
  839.   {
  840.    if( strlen(PromptString) == 0 )
  841.     continue;
  842.  
  843.    msg = SetLineBRK( fp,SrcLnNumOfCsr,pSrcLnInBuf,BRK_COND,PromptString);
  844.    if( !msg )
  845.    {
  846. #if 0
  847.      SD386Log(STRINGCODE," ");
  848.      SD386Log(STRINGCODE,PromptString);
  849. #endif
  850.     break;
  851.    }
  852.  
  853.    /**************************************************************************/
  854.    /* display an error message and then ask for another name.                */
  855.    /**************************************************************************/
  856.    beep();
  857.    hp = msg;
  858.    fmterr( msg );
  859.    continue;
  860.   }
  861.  }
  862.  
  863.  PutPopArea(SaveArea);
  864.  Tfree(SaveArea );
  865.   iview=_iview;
  866. }
  867.  
  868. /*****************************************************************************/
  869. /* SetNameOrAddrBkpt()                                                       */
  870. /*                                                                           */
  871. /* Description:                                                              */
  872. /*                                                                           */
  873. /*   Set a name or address breakpoint including deferred breaks.             */
  874. /*                                                                           */
  875. /* Parameters:                                                               */
  876. /*                                                                           */
  877. /* Return                                                                    */
  878. /*                                                                           */
  879. /* Assumptions:                                                              */
  880. /*                                                                           */
  881. /*                                                                           */
  882. /*****************************************************************************/
  883. void  SetNameOrAddrBkpt( AFILE *fp , uint func )
  884. {
  885.  char   *hp;
  886.  uint    key;
  887.  char    PromptString[MAXPROMPTSTRING];
  888.  uchar  *SaveArea;
  889.  int     DorI;
  890.  int     DefineType;
  891.  char   *pmsg;
  892.  APIRET  rc;
  893.  static int _iview;
  894.  
  895. #if defined(MSH) && 0
  896.  if(commandLine.nparms>1) {
  897.     msg = SetIDBrk( pnode, commandLine.parms[1], &Brk );                         /*707*/
  898.     if( !msg )
  899.     {
  900.       AFILE *lfp;                                                        /*707*/
  901.  
  902.       for( lfp = allfps; lfp; lfp = lfp->next )                          /*707*/
  903.         if( lfp->mid == Brk.mid )                                        /*707*/
  904.           MarkLineBRKs( lfp );                                           /*707*/
  905. #if defined(SD386LOG)
  906.       SD386Log(STRINGCODE," ");
  907.       SD386Log(STRINGCODE,commandLine.parms[1]);
  908. #endif
  909.       return;
  910.     }
  911.  }
  912. #endif
  913.  
  914.  _iview=iview; iview=0;
  915.  *PromptString = '\0';
  916.  /****************************************************************************/
  917.  /* - put the title, instructions, and help appropriate for this popup       */
  918.  /*   into the popup structure.                                              */
  919.  /* - save the screen area used by the popup if CUA interface.               */
  920.  /* - get the file to browse from the user.                                  */
  921.  /* - handle user string and keys.                                           */
  922.  /* - handle errors.                                                         */
  923.  /* - restore the screen save area if CUA interface.                         */
  924.  /*                                                                          */
  925.  /****************************************************************************/
  926.  switch( func )
  927.  {
  928.   case SETFUNCTIONBKPT:
  929.    Popup.title        = IF_Title;
  930.    Popup.instructions = IF_Instructions;
  931.    Popup.help         = IDFUNCHELP;
  932.    DorI               = BP_IMMEDIATE;
  933.    DefineType         = BP_FUNC_NAME;
  934.    hp                 = IF_Instructions;
  935.    break;
  936.  
  937.   case SETADDRESSBKPT:
  938.    Popup.title        = IA_Title;
  939.    Popup.instructions = IA_Instructions;
  940.    Popup.help         = IDADDRHELP;
  941.    DorI               = BP_IMMEDIATE;
  942.    DefineType         = BP_ADDR;
  943.    hp                 = IA_Instructions;
  944.  
  945.    strcpy( PromptString, "0x" );
  946.    break;
  947.  
  948.   case SETDEFERREDBKPT:
  949.    Popup.title        = ID_Title;
  950.    Popup.instructions = ID_Instructions;
  951.    Popup.help         = IDDEFRHELP;
  952.    DorI               = BP_DEFR;
  953.    DefineType         = BP_FUNC_NAME;
  954.    hp                 = ID_Instructions;
  955.    break;
  956.  
  957.   case  SETADDRLOADBKPT:
  958.    Popup.title        = IO_Title;
  959.    Popup.instructions = IO_Instructions;
  960.    Popup.help         = IDLOADHELP;
  961.    DorI               = BP_DEFR;
  962.    DefineType         = BP_LOAD_ADDR;
  963.    hp                 = IO_Instructions;
  964.  
  965.    strcpy( PromptString, "0x" );
  966.    break;
  967.  
  968.   case  SETDLLLOADBKPT:
  969.    Popup.title        = IL_Title;
  970.    Popup.instructions = IL_Instructions;
  971.    Popup.help         = IDDLLHELP;
  972.    DorI               = BP_DEFR;
  973.    DefineType         = BP_DLL_LOAD;
  974.    hp                 = IL_Instructions;
  975.    break;
  976.  }
  977.  
  978.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  979.  GetPopArea(SaveArea);
  980.  DisplayPop( &Popup );
  981.  
  982.  /****************************************************************************/
  983.  /* - loop to handle user entry/errors.                                      */
  984.  /****************************************************************************/
  985.  for(;;)
  986.  {
  987.  
  988.   key = PopPrompt( PromptString, hp);
  989.  
  990.   stripblk(PromptString);
  991.  
  992.   if( key == ESC )
  993.   {
  994. #if 0
  995.    SD386Log(STRINGCODE," ");
  996.    SD386Log(KEYCODE|key,"");
  997. #endif
  998.    break;
  999.   }
  1000.   else if ( key == ENTER )
  1001.   {
  1002.    if( strlen(PromptString) == 0 )
  1003.     continue;
  1004.  
  1005.    pmsg = NULL;
  1006.    rc = SetIDBrk( PromptString, DorI, DefineType, &pmsg );
  1007.  
  1008.    if( rc )
  1009.    {
  1010.     beep();
  1011.     hp = pmsg;
  1012.     fmterr( pmsg );
  1013.     continue;
  1014.  
  1015. #if 0
  1016.      AFILE *lfp;                                                        /*707*/
  1017.      SD386Log(STRINGCODE," ");
  1018.      SD386Log(STRINGCODE,PromptString);
  1019.  
  1020.      for( lfp = allfps; lfp; lfp = lfp->next )                          /*707*/
  1021.        if( lfp->mid == Brk.mid )                                        /*707*/
  1022.          MarkLineBRKs( lfp );                                           /*707*/
  1023. #endif
  1024.    }
  1025.    break;
  1026.    /**************************************************************************/
  1027.    /* display an error message and then ask for another name.                */
  1028.    /**************************************************************************/
  1029.   }
  1030.  }
  1031.  
  1032.  PutPopArea(SaveArea);
  1033.  Tfree(SaveArea );
  1034.   iview=_iview;
  1035. }
  1036.  
  1037. /*****************************************************************************/
  1038. /* PopPrompt                                                                 */
  1039. /*                                                                           */
  1040. /* Description:                                                              */
  1041. /*                                                                           */
  1042. /*   Get a popup string and return a key( alias mouse event )                */
  1043. /*                                                                           */
  1044. /* Parameters:                                                               */
  1045. /*                                                                           */
  1046. /*   PromptString   where the prompt string will be put.                     */
  1047. /*   msg            -> for compatibility with old prompt method.             */
  1048. /*                                                                           */
  1049. /* Return                                                                    */
  1050. /*                                                                           */
  1051. /*   key        a key code                                                   */
  1052. /*                                                                           */
  1053. /*****************************************************************************/
  1054. uint PopPrompt( char *PromptString, char *msg )
  1055. {
  1056.  uint   key;
  1057.  static int _iview;
  1058.  _iview=iview; iview=0;
  1059.  key = GetPopStr( &Popup, POP_PROMPT_START_ROW, POP_PROMPT_START_COL,
  1060.                    POP_PROMPT_LENGTH, PromptString);
  1061.  iview=_iview;
  1062.  
  1063.  return(key);
  1064. }
  1065.  
  1066. /*****************************************************************************/
  1067. /* GetLineNumber()                                                           */
  1068. /*                                                                           */
  1069. /* Description:                                                              */
  1070. /*                                                                           */
  1071. /*   Prompt the user for a source line number within the current view.       */
  1072. /*                                                                           */
  1073. /* Parameters:                                                               */
  1074. /*                                                                           */
  1075. /*   InitString  -> to a string to use as an initial prompt.                 */
  1076. /*                                                                           */
  1077. /* Return Value:                                                             */
  1078. /*                                                                           */
  1079. /*   int         a line number.                                              */
  1080. /*                                                                           */
  1081. /*  Assumptions:                                                             */
  1082. /*                                                                           */
  1083. /*   none                                                                    */
  1084. /*                                                                           */
  1085. /*****************************************************************************/
  1086. int GetLineNumber( char c )
  1087. {
  1088.  char  *hp;
  1089.  uint   key;
  1090.  char   PromptString[MAXPROMPTSTRING];
  1091.  uchar *SaveArea;
  1092.  int    LineNumber;
  1093.  static int _iview;
  1094.  
  1095.  LineNumber = 0;
  1096.  sprintf(PromptString,"%c",c);
  1097.  Popup.title = LN_Title;
  1098.  Popup.instructions = LN_Instructions;
  1099.  Popup.help = LNFUNCHELP;
  1100.  
  1101.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  1102.  GetPopArea(SaveArea);
  1103.  DisplayPop( &Popup );
  1104.  
  1105.  /****************************************************************************/
  1106.  /* loop to handle user entry/errors.                                        */
  1107.  /****************************************************************************/
  1108.  for(;;)
  1109.  {
  1110.   hp = LN_Instructions;
  1111.  
  1112.   key = PopPrompt( PromptString, hp);
  1113.  
  1114.   stripblk(PromptString);
  1115.  
  1116.   if( key == ESC )
  1117.    break;
  1118.   else if ( key == ENTER )
  1119.   {
  1120.    if( strlen(PromptString) == 0 )
  1121.     continue;
  1122.    LineNumber = atoi(PromptString);
  1123.    break;
  1124.   }
  1125.  }
  1126.  
  1127.  PutPopArea(SaveArea);
  1128.  Tfree(SaveArea );
  1129.   iview=_iview;
  1130.  return(LineNumber);
  1131. }
  1132.  
  1133. /*****************************************************************************/
  1134. /* GetFormatType()                                                           */
  1135. /*                                                                           */
  1136. /* Description:                                                              */
  1137. /*                                                                           */
  1138. /*   Prompt the user for a file name and then try to build a view            */
  1139. /*   for that function.                                                      */
  1140. /*                                                                           */
  1141. /* Parameters:                                                               */
  1142. /*                                                                           */
  1143. /*   none                                                                    */
  1144. /*                                                                           */
  1145. /* Return Value:                                                             */
  1146. /*                                                                           */
  1147. /*   fp          -> to AFILE structure containing the new view.              */
  1148. /*   NULL        couldn't find the specified file. Or, escaped.              */
  1149. /*                                                                           */
  1150. /*  Assumptions:                                                             */
  1151. /*                                                                           */
  1152. /*                                                                           */
  1153. /*****************************************************************************/
  1154. UINT GetFormatType( DFILE *dfp )
  1155. {
  1156.  char  *hp;
  1157.  uint   key;
  1158.  char   PromptString[MAXPROMPTSTRING];
  1159.  uchar *SaveArea;
  1160.  int    LeaveLoop;
  1161.  static int _iview;
  1162.  
  1163.  /****************************************************************************/
  1164.  /* - put the title, instructions, and help appropriate for this popup       */
  1165.  /*   into the popup structure.                                              */
  1166.  /* - save the screen area used by the popup if CUA interface.               */
  1167.  /* - get a function name from the user.                                     */
  1168.  /* - handle user string and keys.                                           */
  1169.  /* - handle errors.                                                         */
  1170.  /* - restore the screen save area if CUA interface.                         */
  1171.  /*                                                                          */
  1172.  /****************************************************************************/
  1173.  _iview=iview; iview=0;
  1174.  *PromptString = '\0';
  1175.  
  1176.  Popup.title = GT_Title;
  1177.  Popup.instructions = GT_Instructions;
  1178.  Popup.help = GETTYPEHELP;
  1179.  
  1180.  SaveArea = (uchar *)Talloc(Popup.length * Popup.width * 2);
  1181.  GetPopArea(SaveArea);
  1182.  DisplayPop( &Popup );
  1183.  
  1184.  /****************************************************************************/
  1185.  /* loop to handle user entry/errors.                                        */
  1186.  /****************************************************************************/
  1187.  for( LeaveLoop=FALSE; LeaveLoop==FALSE;)
  1188.  {
  1189.   hp = GT_Instructions;
  1190.   key = PopPrompt( PromptString, hp);
  1191.  
  1192.   stripblk(PromptString);
  1193.  
  1194.   if(  (key == ESC) ||
  1195.        ( (key == ENTER) && (strlen(PromptString)==0) )
  1196.     )
  1197.    LeaveLoop = TRUE;
  1198.   else
  1199.   {
  1200.    switch( key )
  1201.    {
  1202.     case ENTER:
  1203.     case PADENTER:
  1204.     {
  1205.      UINT    mid4type = 0;
  1206.      USHORT  typeno;
  1207.      UCHAR  *hp;
  1208.      UCHAR   buffer[PROMAX+2];
  1209.  
  1210.      memset(buffer, 0, sizeof(buffer));
  1211.      strcpy(buffer+2, PromptString);
  1212.  
  1213.      *(USHORT*)buffer = (USHORT)strlen(PromptString);
  1214.  
  1215.      typeno = QtypeNumber(dfp->mid, buffer, &mid4type );
  1216.  
  1217.      if( mid4type != 0 )
  1218.       dfp->mid = mid4type;
  1219.  
  1220.      if(typeno)
  1221.      {
  1222.       SetShowType( dfp, (UINT)typeno );
  1223.       LeaveLoop = TRUE;
  1224.      }
  1225.      else
  1226.      {
  1227.       beep();
  1228.       hp = "Incorrect type name";
  1229.       fmterr( hp);
  1230.      }
  1231.     }
  1232.     break;
  1233.  
  1234.     case ESC:
  1235.      LeaveLoop = TRUE;
  1236.      break;
  1237.    }
  1238.   }
  1239.  }
  1240.  
  1241.  PutPopArea(SaveArea);
  1242.  Tfree(SaveArea );
  1243.   iview=_iview;
  1244.  return(0);
  1245. }
  1246.