All these signals are outlined in the railroads operating rules and are based on current and historic standards.
The whistles that are used regarding approaching stations boards, usually starts with a "long" blast from the engineer (L) and is asking the conductor if they need to stop at the next station. If the conductor responds with a raised hand (proceed), this means no and the engineer will respond with two "short" blasts (B} . If the conductor wants a stop at the next station, they will respond with hand in the lowered position (stop) and the engineer will respond with three "short" blasts (I). This combination (one long and three shorts) also is telling the rear brakeman (flagman) to protect the rear of the train (C). If a helper engine is on the train, the engineer will also respond accordingly so as to indicate they also understand.