To make future health care decisions for your friend, if he is lucid and able to make decisions, see if he is willing to sign a durable power of attorney for health care, sometimes called a medical directive giving you authority to make some or all health care decisions for him if he is unable to do so. The exact form varies from state to state, but this is something his health care providers can help you with or direct you to.
I have taken care of two relatives in pain and dying, one with cancer. If your friend has less than 6 months to live, as determined by his doctor, he should be referred to hospice. In hospice, he should have a hospice nurse that is monitoring his pain needs and automatically (with a doctors order) providing him with the appropriate pain medications to keep him comfortable most of the time.
In terms of how long he will have to suffer, if a hospice nurse is monitoring the pain situation and is in place, the answer is none/very little.
How long it will be to the end, is hard to determine and varies from patient to patient. I have found the person who knows the best is the hospice nurse who has been through this before many times, and can give you a good idea how close the end is.
Gene