If I understand your question correctly, I think you almost have it. You just need PORTB to correspond with a numeric value which corresponds to pin , which is the amount you need to shift by. So you could add something like this:
#define PORTB5 5
#define PORTB4 4
#define PORTB3 3
#define PORTB2 2
#define PORTB1 1
This assumes the mapping of the pins to the shift value. You may have to adjust this order as necessary. Of course adding comments helps out enormously with this sort of thing too.