예제 #1
0
/*__________________________________________________________________________
*/
void dbg_set_tmr(char * argv[], uint32_t tcpRef, void *bufRef) 
{

   int timer_id,val;
   
   if (argv[2] ==NULL)
   {
    uma_dbg_send(tcpRef, bufRef, TRUE, "missing parameter (%s <tmr_idx> <value>)\n",argv[0]);    
    return;     
   }
   errno = 0;
   timer_id = (int) strtol(argv[1], (char **) NULL, 10);   
   if (errno != 0) {
    uma_dbg_send(tcpRef, bufRef, TRUE, "bad tmr_idx (%s <tmr_idx> <value>) %s\n",argv[0],strerror(errno));    
    return;     
   }
   if (timer_id >= TMR_MAX_ENTRY)
   {
    uma_dbg_send(tcpRef, bufRef, TRUE, "invalid tmr_idx (max %d)\n",(TMR_MAX_ENTRY-1));    
    return;           
   }
   errno = 0;
   val = (int) strtol(argv[2], (char **) NULL, 10);   
   if (errno != 0) {
    uma_dbg_send(tcpRef, bufRef, TRUE, "bad value (%s <tmr_idx> <value>)\n",argv[0]);    
    return;     
   }
   if (rozofs_tmr_configure(timer_id,val) < 0)
   {
    uma_dbg_send(tcpRef, bufRef, TRUE, "timer value out of range\n");    
    return;     
   }   
   uma_dbg_send(tcpRef, bufRef, TRUE, "Success\n");
}
예제 #2
0
void dbg_set_tmr(char * argv[], uint32_t tcpRef, void *bufRef)
{
    char           *pChar=uma_dbg_get_buffer();

    int timer_id,val;

    if (argv[2] ==NULL)
    {
        pChar = dbg_set_tmr_help(pChar);
        uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
        return;
    }
    /* Check 1rst a string name */
    timer_id = rozofs_tmr_get_idx_from_name(argv[1]);
    /* Check for an index */
    if (timer_id < 0) {
        errno = 0;
        timer_id = (int) strtol(argv[1], (char **) NULL, 10);
        if (errno != 0) {
            pChar = dbg_set_tmr_help(pChar);
            uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
            return;
        }
    }
    if (timer_id >= TMR_MAX_ENTRY)
    {
        pChar += sprintf(pChar,"invalid timer index (max %d)\n",(TMR_MAX_ENTRY-1));
        pChar = dbg_set_tmr_help(pChar);
        uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
        return;
    }
    errno = 0;
    val = (int) strtol(argv[2], (char **) NULL, 10);
    if (errno != 0) {
        pChar += sprintf(pChar,"bad value %s\n",argv[2]);
        pChar = dbg_set_tmr_help(pChar);
        uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
        return;
    }
    if (rozofs_tmr_configure(timer_id,val) < 0)
    {
        pChar += sprintf(pChar,"timer value out of range\n");
        pChar = dbg_set_tmr_help(pChar);
        uma_dbg_send(tcpRef, bufRef, TRUE, uma_dbg_get_buffer());
        return;
    }
    uma_dbg_send(tcpRef, bufRef, TRUE, "Success\n");
}