Question : refactoring code

I have a piece of code that looks like this:


    case NGX_MAIL_PARSE_ARGS_COMMAND:
        s->state = 0;
        s->out.len = sizeof(imap_invalid_args_command) - 1;
        s->out.data = imap_invalid_args_command;
        s->mail_state = ngx_imap_start;
        break;

    case NGX_MAIL_PARSE_INVALID_COMMAND:
        s->state = 0;
        s->out.len = sizeof(imap_invalid_command) - 1;
        s->out.data = imap_invalid_command;
        s->mail_state = ngx_imap_start;
        break;
    }

Both the case structures do the exact same thing, ie they compute the size for s->out.len and assign the data to sout.data...

the only thing that changes is the message...in teh first case it is (imap_invalid_args_command and in teh second case it is  imap_invalid_command ...

how can i better write this code so as to avoid code duplication?

should i put the code in a function?
should i write a macro?
can i do something like

case 1:
case2:
same code



Answer : refactoring code

I think the best solution is one presented here by either of the two experts. I would say...

  • Dismount the datastore 
  • Copy the edb and STM 
  • Run your nt backup utility that comes with Windows server. 
  • and mount the datastores again.   

Please keep in mind that this is just an approach that should be done if you know what you are doing.  Here are some places on how to get more information...

http://technet.microsoft.com/en-us/library/aa996179(EXCHG.65).aspx

http://technet.microsoft.com/en-us/library/aa997165(EXCHG.65).aspx

Good luck.

Random Solutions  
 
programming4us programming4us