/* Read the output of listsessions and extract the notifies: by placing the user id in front The program reads its standard input */ #include #include #include #include #include #include #include #include #include using namespace std; int main (int argc, char *argv[]) { glocal int ret = -1; glocal bool show_geometry = false; glocal bool show_sessionnum = false; glocal bool cnv2lines = false; glocal.ret = (argc,argv); setproginfo ("show-notifies","0.0","..."); setarg ('g',"show-geometry","Present geometry information instead of notifications",glocal.show_geometry,false); setarg ('s',"show-sessionnum","Present the session number",glocal.show_sessionnum,false); setarg ('l',"cnv2lines","Present the notifications one per line",glocal.cnv2lines,false); glocal string userid; glocal string session; int ret = 0; ("-",true); const char *pt = str_skip(line); if (strncmp(line,"000",3)==0){ //printf ("%s\n",line); auto tb = str_splitline(line,' '); if (tb.size() > 3){ glocal.userid=tb[3]; glocal.session=tb[0]; } }else if (is_start_any_of (pt,NONEED,"notifies:") && !glocal.show_geometry){ // We must remove the timestamp and keep the sequence number auto words = str_splitline(pt,' '); for (unsigned i=2; i args; if (str_splitline(w.c_str(),',',args)!=3){ tlmp_error ("Invalid notify item: %s\n",w.c_str()); }else{ w = args[0] + ',' + args[2]; } } if (glocal.show_sessionnum) printf ("%s ",glocal.session.c_str()); printf ("%s",glocal.userid.c_str()); if (glocal.cnv2lines) sort (words.begin(),words.end()); for (auto const &w:words){ if (glocal.cnv2lines){ printf ("\t%s\n",w.c_str()); }else{ printf (" %s",w.c_str()); } } printf ("\n"); }else if (is_start_any_of (pt,NONEED,"id=")){ if (glocal.show_geometry){ if (glocal.show_sessionnum) printf ("%s ",glocal.session.c_str()); printf ("%s %s\n",glocal.userid.c_str(),pt); } } return 0; return ret; return glocal.ret; }