Beispiel #1
0
Ipc_Status_t
ipc_transport_terminate_server (void)
{
   char buffer[17000];		/* temp buffer for incoming data           */
   int len;			/* placeholder var to as arg to function   */
   Ipc_Status_t status;		/* value to be returned from function      */
   int max_size;		/* Max length of buffer                    */

   max_size = sizeof (buffer);
   do {
     len = max_size;
     status = ipc_transport_get_line (buffer, &len, IPC_WAIT);
   } while ((status != IPC_STATUS_ERROR) &&
	    (status != IPC_STATUS_EOF));
   return status;
}
Beispiel #2
0
Ipc_Status_t
ipc_get_line (
     char               *str,   /* Text retrieved from IPC channel */
     int                *len,   /* Length of text string */
     Ipc_Wait_t         wait )  /* Select blocking or non-blocking */
     /*
      * Reads one SPICE line from the connection. Strips any control lines
      * which cannot be interpretted by the simulator (e.g. >INQCON) and
      * processes them.  If such a line is read, it is processed and the next
      * line is read.  `ipc_get_line' does not return until a non-interceptable
      * line is read or end of file.
      *
      * If `wait' is IPC_NO_WAIT and there is no data available on the
      * connection, `ipc_get_line' returns IPC_STATUS_NO_DATA. If `wait' is
      * IPC_WAIT, `ipc_get_line' will not return until there is data available
      * or and end of file condition is reached or an error occurs.
      *
      * Intercepts and processes the following commands:
      *    #RETURNI, #MINTIME, #VTRANS,
      *    >PAUSE, >CONT, >STOP, >INQCON, >NETLIST, >ENDNET
      * Other > records are silently ignored.
      *
      * Intercepts old-style .TEMP card generated by MSPICE
      *
      * Returns:
      *    IPC_STATUS_OK                - for successful reads
      *    IPC_STATUS_NO_DATA           - when NO_WAIT and no data available
      *    IPC_STATUS_END_OF_DECK       - at end of deck (>ENDNET seen)
      *    IPC_STATUS_ERROR             - otherwise
      */
{
   Ipc_Status_t status;
   Ipc_Boolean_t need_another = IPC_TRUE;

   do {

      status = ipc_transport_get_line (str, len, wait);
      
      switch (status) {
      case IPC_STATUS_NO_DATA:
      case IPC_STATUS_ERROR:
         need_another = IPC_FALSE;
         break;
      case IPC_STATUS_END_OF_DECK:
         assert (0); /* should never get this from the low-level get-line */
         status = IPC_STATUS_ERROR;
         need_another = IPC_FALSE;
         break;
      case IPC_STATUS_OK:
         /*
          * Got a good line - check to see if it's one of the ones we need to
          * intercept
          */
         if (str[0] == '>') {
            if (kw_match (">STOP", str)) {
               ipc_handle_stop();
            } else if (kw_match (">PAUSE", str)) {
               /* assert (need_another); */
               /*
                * once more around the loop to do a blocking wait for the >CONT
                */
               need_another = IPC_TRUE;
               wait = IPC_WAIT;
            } else if (kw_match (">INQCON", str)) {
               ipc_send_line (">ABRTABL");
               ipc_send_line (">PAUSABL");
               ipc_send_line (">KEEPABL");
               status = ipc_flush ();
               if (IPC_STATUS_OK != status) {
                  need_another = IPC_FALSE;
               }
            } else if (kw_match (">ENDNET", str)) {
               end_of_deck_seen = IPC_TRUE;
               need_another = IPC_FALSE;
               status = IPC_STATUS_END_OF_DECK;
            } else {
               /* silently ignore */
            }
         } else if (str[0] == '#') {
            if (kw_match ("#RETURNI", str)) {
               ipc_handle_returni ();
            } else if (kw_match ("#MINTIME", str)) {
               double d1/*,d2*/;
               if (1 != sscanf (&str[8], "%lg", &d1)) {
                  status = IPC_STATUS_ERROR;
                  need_another = IPC_FALSE;
               } else {
                  ipc_handle_mintime (d1);
               }
            } else if (kw_match ("#VTRANS", str)) {
               char *tok1;
               char *tok2;
               char *tok3;
               
               tok1 = &str[8];
               for (tok2 = tok1; *tok2; tok2++) {
                  if (isspace_c(*tok2)) {
                     *tok2 = '\0';
                     tok2++;
                     break;
                  }
               }
               for(tok3 = tok2; *tok3; tok3++) {
                   if(isspace_c(*tok3)) {
                       *tok3 = '\0';
                       break;
                   }
               }
               ipc_handle_vtrans (tok1, tok2);
            } else {
               /* silently ignore */
            }
         } else if (str[0] == '.') {
            if (kw_match (".TEMP", str)) {
               /* don't pass .TEMP card to caller */
               printf("Old-style .TEMP card found - ignored\n");
            }
            else {
               /* pass all other . cards to the caller */
               need_another = IPC_FALSE;
            }
         } else {
            /*
             * Not a '>' or '#' record - let the caller deal with it
             */
            need_another = IPC_FALSE;
         }
         break;
      default:
         /*
          * some unknown status value!
          */
         assert (0);
         status = IPC_STATUS_ERROR;
         need_another = IPC_FALSE;
         break;
      }
   } while (need_another);

   return status;
}