示例#1
0
文件: rm.c 项目: AlbertDeFusco/torque
int downrm(

  int *local_errno,
  int  stream)  /* I */

  {
  struct out *op;

  if (simplecom(stream, local_errno, RM_CMD_SHUTDOWN))
    {
    return(-1);
    }

  if ((op = findout(local_errno, stream)) == NULL)
    {
    return -1;
    }

  if (simpleget(local_errno, op->chan))
    {
    return(-1);
    }

  delrm(stream);

  return(0);
  }  /* END downrm() */
示例#2
0
int main()
{
int m,n,i,king;
struct monkey *p1,*p2;
printf("请输入猴子的个数m:\n");
scanf("%d",&m);
printf("每次数猴子的个数n :\n");
scanf("%d",&n);
if(n==1)
{
king=m;
}
else
{
p1=p2=create(m);
for(i=1;i<m;i++)
{
p2=findout(p1,n);
p1=p2;
p2=letout(p1);
p1=p2;
}
king=p2->num;
free(p2);
}
printf("猴王的编号是:%d\n",king);
return 0;
}
示例#3
0
 void recoverTree(TreeNode *root) 
 {
     node1 = node2 = pre = NULL;
     findout(root);
     swap(node1->val, node2->val);
     return;
 }
示例#4
0
 void findout(TreeNode *root)
 {
     if (root->left != NULL) 
         findout(root->left);
     
     if (pre != NULL)
     {
         if (pre->val > root->val)
         {
             if (node1 == NULL) 
                 node1 = pre, node2 = root;
             else 
                 node2 = root;
         }
     }
     
     pre = root;
     if (root->right != NULL) 
         findout(root->right);
 }
示例#5
0
文件: rm.c 项目: AlbertDeFusco/torque
int configrm(

  int   stream,      /* I */
  int  *local_errno, /* O */
  char *file)        /* I */

  {
  int         ret;
  size_t      len;

  struct out *op;

  if ((op = findout(local_errno, stream)) == NULL)
    {
    return(-1);
    }

  op->len = -1;

  /* NOTE:  remove absolute job path check to allow config file staging (CRI) */

  /* NOTE:  remove filename size check (was 'MAXPATHLEN') */

  if ((len = strlen(file)) > (size_t)65536)
    {
    return(-1 * EINVAL);
    }

  if (startcom(op->chan, local_errno, RM_CMD_CONFIG,1) != DIS_SUCCESS)
    {
    return(-1);
    }

    ret = diswcs(op->chan, file, len);


  if (ret != DIS_SUCCESS)
    {
#if defined(ECOMM)
    *local_errno = ECOMM;
#elif defined(ENOCONNECT)
    *local_errno = ENOCONNECT;
#else
    *local_errno = ETXTBSY;
#endif

    DBPRT(("configrm: diswcs %s\n",
           dis_emsg[ret]))

    return(-1);
    }
示例#6
0
文件: rm.c 项目: AlbertDeFusco/torque
static int simplecom(

  int  stream,
  int *local_errno,
  int  com)

  {
  struct out *op;

  if ((op = findout(local_errno, stream)) == NULL)
    {
    return(-1);
    }

  op->len = -1;

  if (startcom(op->chan, local_errno, com,0) != DIS_SUCCESS)
    {
    close(op->chan->sock);

    return(-1);
    }

  if (DIS_tcp_wflush(op->chan) == -1)
    {
    *local_errno = errno;

    DBPRT(("simplecom: flush error %d (%s)\n",
           *local_errno, pbs_strerror(*local_errno)))

    close(op->chan->sock);

    return(-1);
    }

  return(0);
  }  /* END simplecom() */