Example #1
0
static unsigned long ExecIO_Read_To_Stem (
   PLL pll)                      /* Pointer to file linked list item  */
   {

   /* Local function variables */
   char *   Stem;                /* Stem variable name                */
   char *   Index;               /* Stem index value (string)         */
   unsigned long ulRc = 0;       /* Return code                       */

   /* process request */
   if (ExecIO_Options.lRcdCnt == 0) {
      return 0;
      }
   Stem = (char *)malloc(strlen(ExecIO_Options.aStem) + 33);
   if (Stem == NULL) {
      return 20;
      }
   strcpy(Stem, ExecIO_Options.aStem);
   Index = Stem + strlen(Stem);
   if (ExecIO_Options.lRcdCnt == -1) {
      /* process an "*" record count */
      while (fgets(szInline, sizeof (szInline), pll -> pFile)) {
         if (*(szInline + strlen(szInline) - 1) == '\n')
            *(szInline + strlen(szInline) - 1) = '\0';
         sprintf(Index, "%ld", ExecIO_Options.lStartRcd);
         SetRexxVar(Stem, szInline, strlen(szInline));
         ExecIO_Options.lStartRcd++;
         }
      }
   else {
      /* process a specific record count */
      while (ExecIO_Options.lRcdCnt > 0) {
         if (fgets(szInline, sizeof(szInline), pll -> pFile)) {
            if (*(szInline + strlen(szInline) - 1) == '\n') {
               *(szInline + strlen(szInline) - 1) = '\0';
               }
            sprintf(Index, "%ld", ExecIO_Options.lStartRcd);
            SetRexxVar(Stem, szInline, strlen(szInline));
            ExecIO_Options.lStartRcd++;
            }
         else {
            ulRc = 2;
            break;
            }
         ExecIO_Options.lRcdCnt--;
         }
      }
   ExecIO_Options.lStartRcd--;
   sprintf(szInline, "%ld", ExecIO_Options.lStartRcd);
   sprintf(Index, "%d", 0);
   SetRexxVar(Stem, szInline, strlen (szInline));
   free(Stem);

   /* return with successful return code */
   return ulRc;
   }
Example #2
0
STATIC LONG MySetRexxVarFromMsg(CONST_STRPTR name, CONST_STRPTR value, struct RexxMsg *message)
{
#ifdef __AMIGAOS4__
	if (IRexxSys) return SetRexxVarFromMsg((char *)name,(char*)value,message);
	return 0;
#else
	return SetRexxVar(message,name,value,strlen(value));
#endif
}
Example #3
0
/*
 * This function will set an error string for the ARexx
 * application in the variable defined as <appname>.LASTERROR
 *
 * Note that this can only happen if there is an ARexx message...
 *
 * This returns TRUE if it worked, FALSE if it did not...
 */
short SetARexxLastError(AREXXCONTEXT RexxContext,struct RexxMsg *rmsg,
			char *ErrorString)
{
    register	short	OkFlag=FALSE;

    if (RexxContext) if (rmsg) if (CheckRexxMsg(&rmsg->rm_Node))
    {
	/*
	 * Note that SetRexxVar() has more than just a TRUE/FALSE
	 * return code, but for this "basic" case, we just care if
	 * it works or not.
	 */
	if (!SetRexxVar(&rmsg->rm_Node,RexxContext->ErrorName,ErrorString,
			(long)strlen(ErrorString)))
	{
	    OkFlag=TRUE;
	}
    }
    return(OkFlag);
}
Example #4
0
//***********************************************************************
//* Procedure: SetStem
//* Synopsis:  rc = SetStem(msg, stemstr)
//* Purpose:   Set the appropriate AREXX stem variables based on the
//*            current error message
//* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
//*
//*  This sets the appropriate AREXX stem variables for the return
//*     FILE:   The name of the file to edit
//*     DIR:    The directory that the file is relative to
//*     LINE:   The line number of the file to go to
//*     ARGS:   The REXX arguments associated with the compile command
//*     COL:    The column number in the file
//*     ERRNO:  The error number
//*     STRING: The error message to be printed out
//*     TEXT:   The complete text of the original line
//*     FPATH:  The full pathname of the file
//*
//***********************************************************************
int SetStem(void *rxmsg, char *stem)
{
   char stembuf[40];
   char *p;
   char *str, *t;

   strncpy(stembuf, stem, 32);
   stembuf[32] = 0;
   p = stembuf+strlen(stembuf);

   if (curfile == NULL)      return(5);
   if (curfile->cur == NULL) return(5);

   strcpy(p, ".DIR");
   SetRexxVar(rxmsg, stembuf, curfile->dir, strlen(curfile->dir));

   strcpy(p, ".ARGS");
   SetRexxVar(rxmsg, stembuf, curfile->args, strlen(curfile->args));

   str = curfile->cur->line;   // DC1: "fails.c" L:1 C:1 W:68 expected semicolon

   strcpy(p, ".TEXT");
   SetRexxVar(rxmsg, stembuf, str, strlen(str));

   str = strchr(str, '\"');      // Locate the initial quote for the filename
   if (str == NULL) return(5);   // Skip out if we don't find it.
   str++;                        // Skip over the initial quote
   t = strchr(str, '\"');        // Now look for the terminting quote
   if (t == NULL) return(5);     // and skip out if it is not there
   strcpy(p, ".FILE");
   SetRexxVar(rxmsg, stembuf, str, t-str);

   //
   // Get the full file name also.  For this we need to set the current
   // directory and then use the fullpath routine
   //
   chdir(curfile->dir);
   {
      char c;
      char *path;

      c = *t;                    // Remember the char that terminated the name
      *t = '\0';                 // and replace it with a null
      path = full_path(str);     // so that we can get the full path of the file
      *t = c;                    // Put the original character back
      strcpy(p, ".FPATH");
      if (path)
      {
         SetRexxVar(rxmsg, stembuf, path, strlen(path));
         free(path);
      }
      else
      {
         //
         // We couldn't get a full path, just punt and use what we started with
         //
         SetRexxVar(rxmsg, stembuf, str, t-str);
      }
   }

   str = t + 1;                  // This should either be a NULL or the space

   //
   // Parse out the L:<number> to get the line number
   //
   while (*str == ' ') str++;
   t = str;
   if (str[0] == 'L' && str[1] == ':')
   {
      str += 2;                  // Skip over the 'L:'
      t = str;
      while(*t >= '0' && *t <= '9') t++;
   }
   strcpy(p, ".LINE");
   SetRexxVar(rxmsg, stembuf, str, t-str);
   str = t;

   //
   // Parse out the C:<number> to get the column number
   //
   while (*str == ' ') str++;
   t = str;
   if (str[0] == 'C' && str[1] == ':')
   {
      str += 2;                  // Skip over the 'C:'
      t = str;
      while(*t >= '0' && *t <= '9') t++;
   }
   strcpy(p, ".COL");
   SetRexxVar(rxmsg, stembuf, str, t-str);
   str = t;

   //
   // Save away the error message to be displayed
   //
   while (*str == ' ') str++;
   strcpy(p, ".STRING");
   SetRexxVar(rxmsg, stembuf, str, strlen(str));

   //
   // Lastly look for the remaining colon to get the error number
   //
   while(*str && *str != ':') str++;

   t = str;
   if (str[0] == ':')
   {
      str++;
      t = str;
      while(*t >= '0' && *t <= '9') t++;

   }
   strcpy(p, ".ERRNO");
   SetRexxVar(rxmsg, stembuf, str, t-str);

   return(0);
}
Example #5
0
// Set variable for a REXX message
long LIBFUNC L_SetRexxVarEx(
	REG(a0, struct RexxMsg *msg),
	REG(a1, char *varname),
	REG(d0, char *value),
	REG(d1, long length))
{
	struct RexxStem *var;
	struct List *list;
	short namelen;

	// Invalid varname or message?
	if (!msg || !varname) return 10;

	// Valid value?
	if (value)
	{
		// Need string length?
		if (length==-1) length=strlen(value);
	}
	else length=0;

	// Standard ARexx message?
	if (IsRexxMsg(msg))
	{
		// Pass through to amiga.lib call
		return SetRexxVar((struct RexxMsg *)msg,varname,value,length);
	}

	// Check for valid DOpus ARexx message
	if (msg->rm_Node.mn_Node.ln_Name!=RexxMsgIdentifier) return 10;

	// Get list pointer
	if (!(list=(struct List *)msg->rm_avail)) return 10;

	// See if variable already exists
	if ((var=(struct RexxStem *)L_FindNameI(list,varname)))
	{
		// Remove and free it
		Remove((struct Node *)var);
		FreeVec(var);
	}

	// Invalid value?
	if (!value) return 0;

	// Get variable name length
	namelen=strlen(varname)+1;

	// Allocate variable
	if (!(var=AllocVec(sizeof(struct RexxStem)+namelen+length,MEMF_CLEAR)))
		return 3;

	// Initialise variable
	var->rs_Node.ln_Name=(char *)(var+1)+length;

	// Copy name and value
	strcpy(var->rs_Node.ln_Name,varname);
	strcpy(var->rs_Value,value);

	// Add to list
	AddTail(list,(struct Node *)var);

	return 0;
}