Ejemplo n.º 1
0
char *ap_os_error_message(int err)
{
  static char result[200];
  char message[HUGE_STRING_LEN];
  ULONG len;
  char *pos;
  int c;
  
  if (DosGetMessage(NULL, 0, message, HUGE_STRING_LEN, err, "OSO001.MSG", &len) == 0) {
      len--;
      message[len] = 0;
      pos = result;
  
      if (len >= sizeof(result))
        len = sizeof(result-1);

      for (c=0; c<len; c++) {
          while (ap_isspace(message[c]) && ap_isspace(message[c+1])) /* skip multiple whitespace */
              c++;
          *(pos++) = ap_isspace(message[c]) ? ' ' : message[c];
      }
  
      *pos = 0;
  } else {
      sprintf(result, "OS/2 error %d", err);
  }
  
  return result;
}
Ejemplo n.º 2
0
void PrintMessage(char **Table, int count, int msgno)
{
    char MsgBuf[MAX_MSGLEN];
    ULONG len;
    char lang[CCHMAXPATH], file[CCHMAXPATH], *langenv, *tmp;

    /* Change to the language directory if it exists */
    if ((langenv=getenv("LANG"))!=NULL) {
        if ((strcpy(lang, langenv))!=NULL) {
            if ((tmp=strchr(lang, '_'))!=NULL) {
                *tmp=0;
            }
        }
    } else {
        strcpy(lang, ".");
    }
    sprintf(file, "%s\\%s", lang, MSGFILE);

    if (DosGetMessage(Table, count, MsgBuf, MAX_MSGLEN, msgno, file, &len)==NO_ERROR) {
        DosPutMessage((HFILE)2, len, MsgBuf);
    } else {
        fprintf(stderr, "IRM%04i\n", msgno);
    }
    return;
}
Ejemplo n.º 3
0
BOOL MSG_Get (PCHAR DestPtr, ULONG DestMaxLength, MSGID MessageID) {
   ULONG  MessageLen = 0;

   if (DosGetMessage(MSG_InsertTable, 5, DestPtr, DestMaxLength, (ULONG)MessageID, MSG_Filename, &MessageLen))
      return FALSE;
   DestPtr[MessageLen] = 0;
   return TRUE;
 }
Ejemplo n.º 4
0
VOID MSG_Print (MSGID MessageID) {
   CHAR   TempBuffer[2048];
   ULONG  MessageLen = 0;

   if (DosGetMessage(MSG_InsertTable, 5, TempBuffer, 2048, (ULONG)MessageID, MSG_Filename, &MessageLen))
      return;
   TempBuffer[MessageLen] = 0;
   printf (TempBuffer);
 }
/*--------------------------------------------------
 * Errors
 *--------------------------------------------------*/
void error( ULONG error_code )
{
  char  msg[2048];
  ULONG len;

  DosGetMessage( 0, 0, msg, sizeof(msg), error_code, "OsO001.msg", &len );
  cerr << msg << endl;

  exit(1);
}
Ejemplo n.º 6
0
void errexit(const char *str, APIRET code) {
   char msgbuf[256];
   ULONG   len = 0;
   msgbuf[0] = 0;
   DosGetMessage(0, 0, msgbuf, 256, code, "OSO001.MSG", &len);
   msgbuf[len] = 0;
   printf("%s (%d): %s\n", str, code, msgbuf);
   if (fout) fclose(fout);
   exit(1);
}
Ejemplo n.º 7
0
VOID MSG_fPrint (HFILE FileHandle, MSGID MessageID) {
   CHAR   TempBuffer[2048];
   ULONG  MessageLen = 0;
   ULONG  Written;

   if (DosGetMessage(MSG_InsertTable, 5, TempBuffer, 2048, (ULONG)MessageID, MSG_Filename, &MessageLen))
      return;
   TempBuffer[MessageLen] = 0;
   DosWrite (FileHandle, &TempBuffer, MessageLen, &Written);
 }
Ejemplo n.º 8
0
/*
 * OS2Error - fatal I/O error encountered
 */
void OS2Error( int error )
{
    #define MAX_MSG 128
    char buffer[MAX_MSG];
    unsigned long len;

    DosGetMessage( NULL, 0, buffer, MAX_MSG, error, "OSO001.MSG", &len );
    buffer[len] = '\0';
    printf( "%s", buffer );
    exit( 1 );

} /* OS2Error */
Ejemplo n.º 9
0
/*@ XMessage::GetMessage( XString* pstrMsg, ULONG msgNum, ULONG varNum = 0, const char** varTexts = NULL )
@group misc
@remarks Loads a message from a message file inserts the given variable texts (if there are any)
         and returns the message.
@parameters XString*     pstrMsg            Pointer to a string object where the message will be stored
            ULONG        msgNum             Message number to load
            ULONG        varNum             Number of variables to replace; there may be up to 9 variables
            const char** varTexts           Texts for the variables
@returns TRUE if the message was loaded, otherwise FALSE
*/
BOOL XMessage::GetMessage( XString* pstrMsg, ULONG msgNum, ULONG varNum, const char** varTexts )
{
        APIRET rc;
        ULONG  msgLen;

        pstrMsg->GetBuffer( 1024 );
        rc = DosGetMessage( (char**)varTexts, varNum,
                            (char*)*pstrMsg, pstrMsg->GetLength(),
                            msgNum, (PSZ) (char*)strFilename, &msgLen     );
        pstrMsg->ReleaseBuffer();

        return (rc == NO_ERROR);
}
Ejemplo n.º 10
0
BOOL MSG_FillInsert (ULONG InsertNo, MSGID MessageID) {
   CHAR   TempBuffer[MSG_INSERTMAXLEN];
   ULONG  MessageLen = 0;

   if ((InsertNo==0) || (InsertNo>5)) return FALSE;
   InsertNo--;
   if (DosGetMessage(MSG_InsertTable, 5, TempBuffer, MSG_INSERTMAXLEN, (ULONG)MessageID, MSG_Filename, &MessageLen)) {
      MSG_Insert[InsertNo][0] = 0;
      return FALSE;
    }
   memcpy (&MSG_Insert[InsertNo], TempBuffer, MessageLen);
   MSG_Insert[InsertNo][MessageLen] = 0;
   return TRUE;
 }
Ejemplo n.º 11
0
PRIVATE
void *
get_help_message ( uint    message_number )
{
    register
    char    *line;
    char    *memory,
            *text_line;
    uint    rc,
            index,
            length;
    bool    no_help = TRUE;

    memory = malloc ( MAX_HELP_MESSAGE_SIZE );

    if ( memory ) {
        rc = DosGetMessage ( NULL, 0, memory, MAX_HELP_MESSAGE_SIZE - 1,
                             message_number, HELP_MESSAGE_FILE, &length );

        if ( rc == 0 ) {
            no_help = FALSE;
            memory [ length ] = '\0';
            text_line = memory;
            index = 0;
            for ( line = memory;  *line;  ++line ) {
                if ( *line == '\r' ) {
                    *line = ' ';
                } else if ( *line == '\n' ) {
                    *line = '\0';
                    if ( index < MAX_HELP_TEXT_LINES ) {
                        Help_panel_text [ index ] = text_line;
                        ++index;
                        text_line = line + 1;
                    }
                }
            }
            Help_panel_text [ index ] = NULL;
        }
    }

    if ( no_help ) {                                     /* no help available */
        Help_panel_text [ 0 ] = " ";
        Help_panel_text [ 1 ] = No_help_available;
        Help_panel_text [ 2 ] = " ";
        Help_panel_text [ 3 ] = 0;
    }

    return  memory;
}
Ejemplo n.º 12
0
  /* --- error handler ---
  **       parameter is disk handle as returned from opendrive()
  **       prints system error message if possible, closes the disk
  **        handle if neccessary, gets a key stroke, and exits.
  */
void errorexit(HFILE hf)
  {
  USHORT cbBuf;
  CHAR   *msgBuf;

  if (_DosError == DSKCPY_ERROR_WRONG_FORMAT)
    {
    /* Special handling for this non-fatal error */
    fprintf(stderr, "\nThe TARGET disk is not the correct format!");
    fprintf(stderr, "\nStrike any key to return to menu..");
    getch();
    fprintf(stderr, "\n\n");
    return;
    }

#if defined (DSKCPY_ERROR_CANT_FORMAT)
  if (_DosError == DSKCPY_ERROR_CANT_FORMAT)
    {
    /* Special handling for this non-fatal error */
    fprintf(stderr, "\nThe TARGET disk must be preformatted!");
    fprintf(stderr, "\nStrike any key to return to menu..");
    getch();
    fprintf(stderr, "\n\n");
    return;
    }
#endif

  puts("");
  if ((msgBuf = (PCHAR)calloc(BUFSIZE, sizeof(CHAR))) != NULL)
    {
    DosGetMessage(NULL, 0, msgBuf, BUFSIZE, _DosError, "oso001.msg", &cbBuf);
    fputs(msgBuf, stderr);
    free(msgBuf);
    }
  else
    fprintf(stderr, "SYS%04d: error text unavailable\n", _DosError);

  if (hf) DosClose(hf);
  fprintf(stderr, "Strike any key to exit..");
  getch();
  fprintf(stderr, "\n");
  DosExit(EXIT_PROCESS, _DosError);
  }
Ejemplo n.º 13
0
void LocalErrMsg(sys_error code, char *buff)
{
    char        *s;
    char        *d;
    ULONG       msg_len;
    char        ch;

    if (DosGetMessage(NULL, 0, buff, 50, code, "OSO001.MSG",
                      &msg_len) != 0 ) {
        GetDOSErrMsg( code, buff );
        return;
    }
    buff[msg_len] = '\0';
    s = d = buff;
    if (s[0] == 'S' && s[1] == 'Y' && s[2] == 'S') {
        /* Got the SYSxxxx: at the front. Take it off. */
        s += 3;
        for ( ; ; ) {
            ch = *s++;
            if (ch == ':')
                break;
            if (ch < '0' || ch > '9') {
                s = buff;
                break;
            }
        }
    }
    while (*s == ' ')
        ++s;
    for( ; ; ) {
        ch = *s++;
        if (ch == '\0')
            break;
        if (ch == '\n')
            ch = ' ';
        if (ch != '\r')
            *d++ = ch;
    }
    while (d > buff && d[-1] == ' ')
        --d;
    *d = '\0';
}
Ejemplo n.º 14
0
/**
 * Gets the message text for a given error number.
 * @return  Message text. Caller must delete it.
 */
char *kError::getText(int iErrorNo)
{
    char *psz;

    if (iErrorNo >= 0 && iErrorNo <= 0x10000)
    {
        char    szErrorMsg[1024];
        ULONG   cbMsg = sizeof(szErrorMsg);
        APIRET  rc;

        rc = DosGetMessage(NULL, 0, &szErrorMsg[0], cbMsg, iErrorNo, "OSO001.MSG", &cbMsg);
        if (rc || cbMsg == 0)
            cbMsg = sprintf(szErrorMsg,
                            "No error message for error %d. (DosGetMessage -> %d)",
                            iErrorNo, rc);
        psz = new char[cbMsg + 1];
        strcpy(psz, szErrorMsg);
    }
    else
    {   /* User defined message */
        char    szErrorMsg[50];
        char *  psz2;

        switch (iErrorNo)
        {

            default:
                sprintf(szErrorMsg, "No error message for error %d.", iErrorNo);
                psz2 = szErrorMsg;
        }
        psz = new char[strlen(psz2) + 1];
        strcpy(psz, psz2);
    }

    return psz;
}
OMessage& OMessage::retrieve(ULONG msgId,
                    PSZ   msgFileName,
                    PSZ   textInsert1,
                    PSZ   textInsert2,
                    PSZ   textInsert3,
                    PSZ   textInsert4,
                    PSZ   textInsert5,
                    PSZ   textInsert6,
                    PSZ   textInsert7,
                    PSZ   textInsert8,
                    PSZ   textInsert9)
{
 APIRET rc = 0;
 ULONG  count = 0;
 PSZ    insertTable[9] = { 0 };

 if (!msgFileName)
   throw OVioException("No message file specified.", OException::unrecoverable);

 if (textInsert1)
  {
   count++;
   insertTable[0] = (PSZ)textInsert1;
   if (textInsert2)
    {
     count++;
     insertTable[1] = (PSZ)textInsert2;
     if (textInsert3)
      {
       count++;
       insertTable[2] = (PSZ)textInsert3;
       if (textInsert4)
        {
         count++;
         insertTable[3] = (PSZ)textInsert4;
         if (textInsert5)
          {
           count++;
           insertTable[4] = (PSZ)textInsert5;
           if (textInsert6)
            {
             count++;
             insertTable[5] = (PSZ)textInsert6;
             if (textInsert7)
              {
               count++;
               insertTable[6] = (PSZ)textInsert7;
               if (textInsert8)
                {
                 count++;
                 insertTable[7] = (PSZ)textInsert8;
                 if (textInsert9)
                  {
                   count++;
                   insertTable[8] = (PSZ)textInsert9;
                  }
                }
              }
            }
          }
        }
      }
    }
  }


 rc = DosGetMessage(insertTable,
                    count,
                    message.getText(),
                    OCL_MAXMESSAGE,
                    msgId,
                    (PSZ)msgFileName,
                    &msglen);

 if (rc != 0)
   throw OVioException("Cannot load message.\n", rc, OException::unrecoverable);
 
 message.getText()[msglen] = '\0';
 message.replace("\r\n", "\n");
 return(*this);
}
Ejemplo n.º 16
0
ULONG   Dos_Error(ULONG ulRc, HWND hwndOwner, ULONG ulWindow, ULONG ulStyle, UCHAR *pucMsg, PSZ pszErrMod, LONG lErrLine)
{
ULONG       ulLength;                   /* Message length */
ULONG       ulClass;                    /* Error class */
ULONG       ulAction;                   /* Error action */
ULONG       ulLocus;                    /* Error location */
USHORT      usResponse;                 /* Message box return value */

static unsigned char   *Err_Class[]={"Out of ressource",
                                     "Temporary situation",
                                     "Authorization failed",
                                     "Internal error",
                                     "Device hardware failure",
                                     "System failure",
                                     "Probable application failure",
                                     "Item not located",
                                     "Bad format for call/data",
                                     "Resource or data locked",
                                     "Incorrect media, CRC check",
                                     "Action already taken or done",
                                     "Unclassified",
                                     "Cannot perform requested action",
                                     "Timeout",
                                     "Error in file \"Error.c\""};
static unsigned char   *Err_Action[]={"Retry immediately",
                                      "Delay and retry",
                                      "Bad user input - get new values",
                                      "Terminate in an orderly manner",
                                      "Terminate immediately",
                                      "Ignore error",
                                      "Retry after user intervention",
                                      "Error in file \"Error.c\""};
static unsigned char   *Err_Locus[]={"Unknown",
                                     "Random access device such as a disk",
                                     "Network",
                                     "Serial device",
                                     "Memory",
                                     "Error in file \"Error.c\""};

if(ulRc)
    {
    if(!pucMsg) pucMsg="";              /* If no special test is given, assume empty string */
    DosErrClass(ulRc, &ulClass, &ulAction, &ulLocus);
                                        /* Get OS/2 message text */
    if(DosGetMessage(NULL, 0, MsgBuffer, sizeof(MsgBuffer), ulRc, "OSO001.MSG", &ulLength))
        MsgBuffer[0]='\0';
    else
        MsgBuffer[ulLength-2]='\0';     /* Remove trailing \r\n */
    sprintf(ErrBuffer, "%s\n\nModule: %s\nLinenumber: %ld\nError reported by OS/2: "\
        "%ld\nClass: %s\nAction: %s\nLocation: %s\n\n\"%s\"", 
        pucMsg, pszErrMod, lErrLine, ulRc, 
        Err_Class[ulClass-1], Err_Action[ulAction-1], Err_Locus[ulLocus-1],
        MsgBuffer);
    memset(Titlebar, ' ', TITLEBAR_LENGTH);
    Titlebar[TITLEBAR_LENGTH-1]='\0';
    memcpy(Titlebar, "PC/2: OS/2 Error Message Information", sizeof("PC/2: OS/2 Error Message Information")-1);
                                        /* If the user requested not to be prompted, don't display the
                                           message if it is just an informational one (in the future we
                                           might log to file) */
    if((pHP!=NULL) && (pHP->ulRuntimeFlag & NOPROMPT) && (ulStyle & MB_INFORMATION))
        return(MB_OK);
                                        /* Signal to user via speaker */
    if((pHP!=NULL) && !(pHP->ulRuntimeFlag & NOPROMPT))
        {
        DosBeep(1000,100);
        DosBeep(300,100);
        DosBeep(1000,200);
        }
    usResponse=WinMessageBox(HWND_DESKTOP, hwndOwner, (PSZ)ErrBuffer,
        Titlebar, (USHORT)ulWindow, (USHORT)ulStyle);
    return(usResponse);
    }
else
    return(MBID_IGNORE);
}
Ejemplo n.º 17
0
void pOS2Err(const size_t lineno,
             const char *fname,
             const char *prefix,
             unsigned int rc)
{
   char buf[BUFSIZ];
   static KWBoolean recursion  = KWFalse;
   size_t l;
   static char sysMsgs[] = "oso001.msg";

   KWBoolean redirect;

#ifdef __OS2__
   ULONG len, xrc;
#else
   USHORT len, xrc;
#endif

/*--------------------------------------------------------------------*/
/*       Determine if we need to echo the error an extra time to      */
/*       the console.                                                 */
/*--------------------------------------------------------------------*/

   if ((logfile != stdout) && !isatty(fileno(stdout)))
      redirect = KWTrue;
   else
      redirect = KWFalse;

/*--------------------------------------------------------------------*/
/*             Override the text for selected error numbers           */
/*--------------------------------------------------------------------*/

   switch( rc )
   {
      case ERROR_TS_WAKEUP:
         strcpy( buf, "Interrupted System Call");
         break;

      case ERROR_GEN_FAILURE:
         strcpy( buf, "Invalid parameter, Port IRQ conflict, or device failure");
         break;

      case ERROR_TIMEOUT:
         strcpy( buf, "Error timeout");   /* DosWaitEventSem reports
                                             this                    */
         break;

      default:
         xrc = DosGetMessage( NULL,
                              0,
                              (PCHAR) buf,
                              sizeof buf,
                              rc,
                              (PSZ) sysMsgs,
                              &len );

         if ( xrc != 0 )
         {

            if ( ! recursion )
            {
               recursion = KWTrue;
               printOS2error( "DosGetMessage", xrc );
               recursion = KWFalse;
            } /* recursion */

            sprintf(buf, "OS/2 API error %d in %s at line %d,"
                         " cannot find message",
                         (int) rc,
                         fname,
                         lineno );

         } /* if ( xrc != 0 ) */
         else {
            size_t column = 0;

            for ( column = 0; column < len; column++ )
            {
               if (iscntrl( buf[ column ] ))
                  buf[column] = ' ';      /* Zap control chars    */
            }

            buf[ len ] = '\0';
         }
         break;

   } /* switch */

/*--------------------------------------------------------------------*/
/*    Drop extra new from error message if we have room in our        */
/*    small buffer                                                    */
/*--------------------------------------------------------------------*/

   l = strlen( buf );

   if (( buf[l-1] == '\n') && (l < sizeof buf ))
      buf[l-1] = '\0';          /* Drop extra newline from string     */

/*--------------------------------------------------------------------*/
/*           Display the message with option file location            */
/*--------------------------------------------------------------------*/

   printmsg(2,"OS/2 API error %d in %s at line %d ...",
            (int) rc, fname, lineno );

   printmsg(0,"%s: %s", prefix, buf);

   if ( redirect )
      fprintf(stdout,"%s: %s\n", prefix, buf);

} /* pOS2Err */
Ejemplo n.º 18
0
int main(INT iArgc, PSZ Argv[])
{
APIRET rc;
ULONG  ulTimeOut = 10L;
ULONG ulParmSize;
ULONG ulDataSize;
FILE *fLog;
BOOL fActive;
BOOL fSilent = FALSE;
BOOL fForce = FALSE;
INT  iArg;

   signal(SIGINT, CtrlCHandler);
   signal(SIGTERM, CtrlCHandler);
   signal(SIGBREAK, CtrlCHandler);

   fActive = 1;
   for (iArg = 1; iArg < iArgc; iArg++)
      {
      if (!stricmp(Argv[iArg], "off"))
         {
         fActive = FALSE;
         break;
         }
      if (isdigit(Argv[iArg][0]))
         fActive = atoi(Argv[iArg]);
      if (!stricmp(Argv[iArg], "/S"))
         fSilent = TRUE;
      if (!stricmp(Argv[iArg], "/F"))
         fForce = TRUE;
      }


   ulParmSize = sizeof fActive;
   rc = DosFSCtl(
      NULL, 0, &ulDataSize,
     (PVOID)&fActive, ulParmSize, &ulParmSize,
      FAT32_SETMESSAGE, "FAT32", -1, FSCTL_FSDNAME);

   if (!fActive)
      return 0;

   rc = DosSetPriority(PRTYS_PROCESS,
      PRTYC_FOREGROUNDSERVER, 0, 0);

   fLog = fopen("FAT32.LOG", "wb");
   for (;;)
      {
      if (kbhit())
         break;
      ulParmSize = sizeof ulTimeOut;
      ulDataSize = sizeof szBuffer;

      rc = DosFSCtl(
         (PVOID)szBuffer, ulDataSize, &ulDataSize,
         (PVOID)&ulTimeOut, ulParmSize, &ulParmSize,
         FAT32_GETLOGDATA, "FAT32", -1, FSCTL_FSDNAME);

      if (rc == ERROR_NOT_SUPPORTED)
         {
         printf("Not supported function\n");
         break;
         }
      if (!rc || rc == 111)
         {
         if (!fSilent)
            printf(szBuffer);
         if (fLog)
            {
            fputs(szBuffer, fLog);
            if (fForce)
               {
               INT iHandle;
               fflush(fLog);
               iHandle = dup(fileno(fLog));
               close(iHandle);
               }
            }
         }
      else if (rc != 0x8001)
         {
         CHAR szMsg[256];
         ULONG ulMsgLength=0;
         rc = DosGetMessage(NULL,0UL,szMsg,sizeof(szMsg),rc,"OSO001.MSG",&ulMsgLength);
         printf("%*s",ulMsgLength,szMsg);
         break;
         }
      }

   fActive = FALSE;
   ulParmSize = sizeof fActive;
   rc = DosFSCtl(
      NULL, 0, &ulDataSize,
     (PVOID)&fActive, ulParmSize, &ulParmSize,
      FAT32_SETMESSAGE, "FAT32", -1, FSCTL_FSDNAME);

   fclose(fLog);
   return 0;
}