int main(int argc, char **argv, char **env) { AjPList newlist = NULL; AjPList glist; AjPList alpha; AjPList appglist; AjPList applist; AjPList appgroups = NULL; AjPFile outfile = NULL; AjPStr search = NULL; AjBool html; AjBool groups; AjBool emboss; AjBool embassy; AjBool explode; AjBool colon; AjPStr showembassy = NULL; AjPStr package = NULL; embInit("seealso", argc, argv); search = ajAcdGetString("search"); outfile = ajAcdGetOutfile("outfile"); html = ajAcdGetToggle("html"); groups = ajAcdGetBoolean("groups"); emboss = ajAcdGetBoolean("emboss"); embassy = ajAcdGetBoolean("embassy"); showembassy = ajAcdGetString("showembassy"); explode = ajAcdGetBoolean("explode"); colon = ajAcdGetBoolean("colon"); glist = ajListNew(); alpha = ajListNew(); appglist = ajListNew(); applist = ajListNew(); /* is a search string specified - should be tested in seealso.acd */ if(!ajStrGetLen(search)) ajFatal("No application specified."); /* ** get the groups and program information - don't want to ignore ** applications that don't work well under GUIs */ /* everything */ embGrpGetProgGroups(appglist, applist, env, ajTrue, ajTrue, NULL, explode, colon, ajFalse); /* what the user asked for */ embGrpGetProgGroups(glist, alpha, env, emboss, embassy, showembassy, explode, colon, ajFalse); newlist = ajListNew(); embGrpKeySearchSeeAlso(newlist, &appgroups, &package, applist, glist, search); if(appgroups == NULL) { ajErr("No applications match."); ajExitBad(); } if(groups) embGrpOutputGroupsList(outfile, appgroups, ajFalse, html, ajFalse, package); else embGrpOutputGroupsList(outfile, newlist, ajTrue, html, ajFalse, package); embGrpGroupsListDel(&newlist); embGrpGroupsListDel(&glist); embGrpGroupsListDel(&alpha); embGrpGroupsListDel(&appglist); embGrpGroupsListDel(&applist); /* embGrpGroupsListDel(&appgroups); */ /* appgroup points to another list*/ ajFileClose(&outfile); ajStrDel(&search); ajStrDel(&showembassy); ajStrDel(&package); embExit(); return 0; }
ajint ajUserGet(AjPStr* pthis, const char* fmt, ...) { AjPStr thys; const char *cp; char *buff; va_list args; ajint ipos; ajint isize; ajint ilen; ajint jlen; ajint fileBuffSize = ajFileValueBuffsize(); va_start(args, fmt); ajFmtVError(fmt, args); va_end(args); if(ajFileValueRedirectStdin()) { ajUser("(Standard input in use: using default)"); ajStrAssignC(pthis, ""); return ajStrGetLen(*pthis); } ajStrSetRes(pthis, fileBuffSize); buff = ajStrGetuniquePtr(pthis); thys = *pthis; isize = ajStrGetRes(thys); ilen = 0; ipos = 0; /*ajDebug("ajUserGet buffer len: %d res: %d ptr: %x\n", ajStrGetLen(thys), ajStrGetRes(thys), thys->Ptr);*/ while(buff) { #ifndef __ppc__ cp = fgets(&buff[ipos], isize, stdin); #else cp = ajSysFuncFgets(&buff[ipos], isize, stdin); #endif if(!cp && !ipos) { if(feof(stdin)) { ajErr("Unable to get reply from user - end of standard input"); ajExitBad(); } else ajFatal("Error reading from user: '******'\n", strerror(errno)); } jlen = strlen(&buff[ipos]); ilen += jlen; /* ** We need to read again if: ** We have read the entire buffer ** and we don't have a newline at the end ** (must be careful about that - we may just have read enough) */ ajStrSetValidLen(pthis, ilen); thys = *pthis; if((jlen == (isize-1)) && (ajStrGetCharLast(thys) != '\n')) { ajStrSetRes(pthis, ajStrGetRes(thys)+fileBuffSize); thys = *pthis; /*ajDebug("more to do: jlen: %d ipos: %d isize: %d ilen: %d " "Size: %d\n", jlen, ipos, isize, ilen, ajStrGetRes(thys));*/ ipos += jlen; buff = ajStrGetuniquePtr(pthis); isize = ajStrGetRes(thys) - ipos; /* ajDebug("expand to: ipos: %d isize: %d Size: %d\n", ipos, isize, ajStrGetRes(thys)); */ } else buff = NULL; } ajStrSetValidLen(pthis, ilen); if(ajStrGetCharLast(*pthis) == '\n') ajStrCutEnd(pthis, 1); /* PC files have \r\n Macintosh files have just \r : this fixes both */ if(ajStrGetCharLast(*pthis) == '\r') { /*ajDebug("Remove carriage-return characters from PC-style files\n");*/ ajStrCutEnd(pthis, 1); } ajStrTrimWhite(pthis); return ajStrGetLen(*pthis); }
__noreturn void embExitBad (void) { ajExitBad(); }