
/* taskpres.c
 *
 * Wimp function library
 *  Joseph Heenan, 1998.
 *
 *
 *
 *
 * $Log: taskpres,v $
 * Revision 1.2  1998/05/10 20:13:11  jogu
 * Added names to file headers
 * Added implicit cast for frontend_taskname to wimp_report_error
 *   (it defines 'name' without 'const')
 *
 * Revision 1.1.1.1  1998/05/10 19:56:03  jogu
 * WimpCLib V1.00 (created from newshound c.wimpc rev 1.2)
 *
 *
 */

#include <stdlib.h>
#include <string.h>
#include <stdarg.h>

#include "swis.h"
#include "wimplib.h"

#include "wimpclib.h"


int wimpc_taskpresent(const char *tname)
{
  int index=0;
  _kernel_oserror *e;
  char buffer[30], name[30];
  char *ptr,*out;

  while (index>=0)
  {
    e = _swix(TaskManager_EnumerateTasks, _INR(0,2) | _OUT(0), index, buffer, sizeof(buffer), &index);
    if (e) return 0;
    ptr = (char *) *( (int *) (buffer+4) );
    out = name;
    while ( *ptr >= 32 && ( out < buffer+sizeof(buffer)) )
      *out++=*ptr++;
    *out=0;
    if ( !strcmp(name, tname) ) return 1;
  }

  return 0;
}

