Listings: different counters for different listing environments
A solution in the spirit of Elenaher's comment:
\newcounter{algorithm}
\lstnewenvironment{algorithm}[2]{
\renewcommand\lstlistingname{Algorithm}
\setcounter{lstlisting}{\value{algorithm}}
\lstset{ ... }
} {\addtocounter{algorithm}{1}}
\newcounter{program}
\lstnewenvironment{program}[2]{
\renewcommand\lstlistingname{Program}
\setcounter{lstlisting}{\value{program}}
\lstset{ ... }
} {\addtocounter{program}{1}}
Then the following:
\begin{algorithm}{Algorithm caption}{alg-label}
...
\end{algorithm}
\begin{algorithm}{Another algorithm caption}{another-alg-label}
...
\end{algorithm}
\begin{program}{Program caption}{prg-label}
...
\end{program}
results in:
Algorithm 1.1
...
Algorithm 1.2
...
Program 1.1
...
Maybe you should try to invoke manually the command setcounter
to change the counter of lstlisting
like that :
\setcounter{lstlisting}{value}
Thus, you will be able to re-initialize the counter for each new environments.
Then you could do more complicated things like automating the invocation of setcounter with the values of the label.