HarwareSerial.h

on my PC this is one of the arduino paths

C:\Program Files (x86)\arduino-0022\hardware\arduino\cores\arduino

and the red part is different depending on IDE version

 need to collect the serial data from the UART directly to a variable, through a software serial port.

Are you familiar with the Serial class? It abstracts the hardware uarts,

if (Serial.available() > 0) x = Serial.read();