HijriDate& HijriDate::operator=(const Date other) { HijriDate mydate(other); this->date_abs = mydate.date_abs; this->date_y = mydate.date_y; this->date_m = mydate.date_m; this->date_d = mydate.date_d; return *this; }
static void write_wikiman(FILE *out, const char *program, int nldesc, const char **desc, int nfile, t_filenm *fnm, int npargs, t_pargs *pa, int nbug, const char **bugs, gmx_bool bHeader, t_linkdata *links) { int i; char buf[256], link[10]; char *tmp, *tmp2; fprintf(out, "<page>\n<title>Manual:%s_%s</title>\n", program, VERSION); fprintf(out, "<revision>\n"); fprintf(out, "<timestamp>%s</timestamp>\n", mydate(buf, 255, TRUE)); fprintf(out, "<text xml:space=\"preserve\">\n"); if (nldesc > 0) { fprintf(out, "== Description ==\n"); print_tty_formatted(out, nldesc, desc, 0, links, program, TRUE); fprintf(out, "\n"); } if (nbug > 0) { fprintf(out, "== Known Problems ==\n"); for (i = 0; i < nbug; i++) { snew(tmp, strlen(bugs[i])+3); strcpy(tmp, "* "); strcpy(tmp+2, bugs[i]); fprintf(out, "%s\n", NWR(tmp)); sfree(tmp); } } if (nfile > 0) { fprintf(out, "\n== Files ==\n"); pr_html_files(out, nfile, fnm, program, links, TRUE); } if (npargs > 0) { fprintf(out, "\n== Options ==\n"); fprintf(out, " %-12s %-6s %-6s %-s\n", "Option", "Type", "Value", "Description"); fprintf(out, " ------------------------------------------------------\n"); for (i = 0; (i < npargs); i++) { tmp = NWR(pargs_print_line(&pa[i], TRUE)); fprintf(out, "%s", tmp); sfree(tmp); } } fprintf(out, "[[category:Manual_Pages_%s|%s]]\n", VERSION, program); fprintf(out, "</text>\n"); fprintf(out, "</revision>\n"); fprintf(out, "</page>\n\n"); }
int main(){ book* newbook; FILE*in,*out; char ans,ans2,c; int num,flag=0,i,ISBN,borrowed; char BookName[50],BorrowerName[50], field[20],date[11]; date dueDate; in=fopen("myfile.txt","r"); if(in==NULL){ printf("No file existing.Please enter the three books:\n"); for(i=0;i<3;i++){ printf("\nPlease enter the book %d:\n",i+1); printf("\nyou want to add a book. enter the new book's ISBN: "); while(!scanf("%d",&ISBN)){ fflush(stdin); printf("Invalid input Please enter another one: "); } fflush(stdin); newbook=searchby_ISBN(ISBN); while(newbook){ printf("\nThe book already exists. Please enter another one: "); scanf("%d",&ISBN); newbook=searchby_ISBN(ISBN); fflush(stdin); } printf("Please enter the name of the book: "); scanf("%s",name); fflush(stdin); printf("Please enter the field: "); scanf("%s",field); fflush(stdin); newbook=create_node(ISBN,name,field,"None","None",0); insert_node(newbook); } } else{ fgets(BookName, 100, in); fgets(line, 100, in); sscanf(line,"%d", &ISBN); fgets(line, 100, in); sscanf(line,"%d", &borrowed); fgets(BorrowerName, 100, in); fgets(date, 11, in); fgets(field, 100, in); insert_node(create_node(ISBN,name,field,BorrowerName,mydate(date),borrowed)); } }
static void write_ttyman(FILE *out, const char *program, int nldesc, const char **desc, int nfile, t_filenm *fnm, int npargs, t_pargs *pa, int nbug, const char **bugs, gmx_bool bHeader, t_linkdata *links) { int i; char buf[256]; char *tmp; if (bHeader) { fprintf(out, "%s\n\n", check_tty(program)); fprintf(out, "%s\n%s\n", GromacsVersion(), mydate(buf, 255, FALSE)); } if (nldesc > 0) { fprintf(out, "DESCRIPTION\n-----------\n"); print_tty_formatted(out, nldesc, desc, 0, links, program, FALSE); } if (nbug > 0) { fprintf(out, "\n"); fprintf(out, "KNOWN PROBLEMS\n----------\n"); for (i = 0; i < nbug; i++) { snew(tmp, strlen(bugs[i])+3); strcpy(tmp, "* "); strcpy(tmp+2, check_tty(bugs[i])); fprintf(out, "%s\n", wrap_lines(tmp, 78, 2, FALSE)); sfree(tmp); } } if (nfile > 0) { fprintf(out, "\n"); pr_fns(out, nfile, fnm); } if (npargs > 0) { print_pargs(out, npargs, pa, FALSE); } }
static void write_ttyman(FILE *out, char *program, int nldesc,char **desc, int nfile,t_filenm *fnm, int npargs,t_pargs *pa, int nbug,char **bugs,bool bHeader) { int i; char *tmp; if (bHeader) { fprintf(out,"%s\n\n",check_tty(program)); fprintf(out,"%s\n%s\n",GromacsVersion(),mydate()); } if (nldesc > 0) { fprintf(out,"DESCRIPTION:\n\n"); print_tty_formatted(out,nldesc,desc); } if (nbug > 0) { fprintf(out,"\n"); for(i=0; i<nbug; i++) { snew(tmp,strlen(bugs[i])+3); strcpy(tmp,"* "); strcpy(tmp+2,bugs[i]); fprintf(out,"%s\n",wrap_lines(tmp,80,2)); sfree(tmp); } } if (nfile > 0) { fprintf(out,"\n"); pr_fns(out,nfile,fnm); } if (npargs > 0) { print_pargs(out,npargs,pa); } }
static void write_xmlman(FILE *out, const char *program, int nldesc,const char **desc, int nfile,t_filenm *fnm, int npargs,t_pargs *pa, int nbug,const char **bugs, t_linkdata *links) { int i; char link[10],buf[256],opt[10]; #define NSR2(s) check_xml(s,program,links) #define FLAG(w,f) (((w) & (f))==(f)) fprintf(out,"<gromacs-manual version=\"%s\" date=\"%s\" www=\"http://www.gromacs.org\">\n",GromacsVersion(),mydate(buf,255,FALSE)); /* fprintf(out,"<LINK rel=stylesheet href=\"style.css\" type=\"text/css\">\n"); */ fprintf(out,"<program name=\"%s\">",program); if (nldesc > 0) { fprintf(out,"\n<description>\n<par>\n"); for(i=0; (i<nldesc); i++) fprintf(out,"%s\n",NSR2(desc[i])); } fprintf(out,"</par>\n</description>\n"); if (nfile > 0) { fprintf(out,"\n<files>\n"); for(i=0; (i<nfile); i++) { strcpy(link,ftp2ext(fnm[i].ftp)); if (strcmp(link,"???")==0) strcpy(link,"files"); if (fnm[i].opt[0]=='-') strcpy(opt,fnm[i].opt+1); else strcpy(opt,fnm[i].opt); fprintf(out, "<file type=\"%s\" typeid=\"%d\">\n" "\t<flags read=\"%d\" write=\"%d\" optional=\"%d\"/>\n" "\t<option>%s</option>\n" "\t<default-name link=\"%s.html\">%s</default-name>\n" "\t<description>%s</description>\n" "</file>\n", ftp2defnm(fnm[i].ftp), /* from gmxlib/filenm.c */ fnm[i].ftp, FLAG(fnm[i].flag,ffREAD), FLAG(fnm[i].flag,ffWRITE), FLAG(fnm[i].flag,ffOPT), opt,link,fnm[i].fn,/*fileopt(fnm[i].flag),*/ NSR(ftp2desc(fnm[i].ftp))); } fprintf(out,"</files>\n"); } if (npargs > 0) { fprintf(out,"\n<options>\n"); for(i=0; (i<npargs); i++) fprintf(out, "<option type=\"%s\" hidden=\"%d\">\n" "\t<name >%s</name>\n" "\t<default-value>%s</default-value>\n" "\t<description>%s</description>\n" "</option>\n", argtp[pa[i].type], is_hidden(&pa[i]), pa[i].option+1, /* +1 - with no trailing '-' */ pa_val(&(pa[i]),buf,255),pa[i].desc); /*argtp[pa[i].type],*/ fprintf(out,"</options>\n"); } if (nbug > 0) { fprintf(out,"\n<bugs>\n"); for(i=0; (i<nbug); i++) fprintf(out,"\t<bug>%s</bug>\n",NSR(bugs[i])); fprintf(out,"</bugs>\n"); } fprintf(out,"\n</program>\n</gromacs-manual>\n"); #undef FLAG }
static void write_htmlman(FILE *out, const char *program, int nldesc,const char **desc, int nfile,t_filenm *fnm, int npargs,t_pargs *pa, int nbug,const char **bugs, t_linkdata *links) { int i; char link[10],tmp[255]; fprintf(out,"<HTML>\n<HEAD>\n<TITLE>%s</TITLE>\n",program); fprintf(out,"<LINK rel=stylesheet href=\"style.css\" type=\"text/css\">\n"); fprintf(out,"<BODY text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#0000FF\" vlink=\"#990000\" alink=\"#FF0000\">\n"); fprintf(out,"<TABLE WIDTH=\"98%%\" NOBORDER >\n<TR><TD WIDTH=400>\n"); fprintf(out,"<TABLE WIDTH=400 NOBORDER>\n<TD WIDTH=116>\n"); fprintf(out,"<a href=\"http://www.gromacs.org/\">" "<img SRC=\"../images/gmxlogo_small.png\"" "BORDER=0 </a></td>\n"); fprintf(out,"<td ALIGN=LEFT VALIGN=TOP WIDTH=280>" "<br><h2>%s</h2>",program); fprintf(out,"<font size=-1><A HREF=\"../online.html\">Main Table of Contents</A></font><br>"); fprintf(out,"<br></td>\n</TABLE></TD><TD WIDTH=\"*\" ALIGN=RIGHT VALIGN=BOTTOM><p><B>%s<br>\n",GromacsVersion()); fprintf(out,"%s</B></td></tr></TABLE>\n<HR>\n",mydate(tmp,255,FALSE)); if (nldesc > 0) { fprintf(out,"<H3>Description</H3>\n<p>\n"); for(i=0; (i<nldesc); i++) fprintf(out,"%s\n",NSR(desc[i])); } if (nfile > 0) { fprintf(out,"<P>\n"); fprintf(out,"<H3>Files</H3>\n"); pr_html_files(out,nfile,fnm,program,links,FALSE); } if (npargs > 0) { fprintf(out,"<P>\n"); fprintf(out,"<H3>Other options</H3>\n"); fprintf(out, "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>\n" "<TR>" "<TH>option</TH>" "<TH>type</TH>" "<TH>default</TH>" "<TH>description</TH>" "</TR>\n"); for(i=0; (i<npargs); i++) fprintf(out, "<TR>" "<TD ALIGN=RIGHT> <b><tt>%s%s</tt></b> </TD>" "<TD ALIGN=RIGHT> %s </TD>" "<TD ALIGN=RIGHT> <tt>%s</tt> </TD>" "<TD> %s </TD>" "</TD>\n", (pa[i].type == etBOOL)?"-[no]":"-",pa[i].option+1, argtp[pa[i].type],pa_val(&(pa[i]),tmp,255),NSR(pa[i].desc)); fprintf(out,"</TABLE>\n"); } if (nbug > 0) { fprintf(out,"<P>\n"); fprintf(out,"<H3>Known problems</H3>\n"); fprintf(out,"<UL>\n"); for(i=0; (i<nbug); i++) fprintf(out,"<LI>%s\n",NSR(bugs[i])); fprintf(out,"</UL>\n"); } fprintf(out,"<P>\n"); fprintf(out,"<hr>\n<div ALIGN=RIGHT>\n"); fprintf(out,"<font size=\"-1\"><a href=\"http://www.gromacs.org\">" "http://www.gromacs.org</a></font><br>\n"); fprintf(out,"<font size=\"-1\"><a href=\"mailto:[email protected]\">" "[email protected]</a></font><br>\n"); fprintf(out,"</div>\n"); fprintf(out,"</BODY>\n"); }
static void write_nroffman(FILE *out, const char *program, int nldesc,const char **desc, int nfile,t_filenm *fnm, int npargs,t_pargs *pa, int nbug,const char **bugs, t_linkdata *links) { int i; char tmp[256]; fprintf(out,".TH %s 1 \"%s\" \"\" \"GROMACS suite, %s\"\n",program,mydate(tmp,255,FALSE),GromacsVersion()); fprintf(out,".SH NAME\n"); fprintf(out,"%s\n",program); fprintf(out,".B %s\n",GromacsVersion()); fprintf(out,".SH SYNOPSIS\n"); fprintf(out,"\\f3%s\\fP\n",program); /* command line arguments */ if (nfile > 0) { for(i=0; (i<nfile); i++) fprintf(out,".BI \"%s\" \" %s \"\n",check_nroff(fnm[i].opt), check_nroff(fnm[i].fns[0])); } if (npargs > 0) { for(i=0; (i<npargs); i++) if (pa[i].type == etBOOL) fprintf(out,".BI \"\\-[no]%s\" \"\"\n",check_nroff(pa[i].option+1)); else fprintf(out,".BI \"%s\" \" %s \"\n",check_nroff(pa[i].option), check_nroff(argtp[pa[i].type])); } /* description */ if (nldesc > 0) { fprintf(out,".SH DESCRIPTION\n"); for(i=0; (i<nldesc); i++) fprintf(out,"\\&%s\n",check_nroff(desc[i])); } /* FILES */ if (nfile > 0) { fprintf(out,".SH FILES\n"); for(i=0; (i<nfile); i++) fprintf(out,".BI \"%s\" \" %s\" \n.B %s\n %s \n\n", check_nroff(fnm[i].opt), check_nroff(fnm[i].fns[0]), check_nroff(fileopt(fnm[i].flag,tmp,255)), check_nroff(ftp2desc(fnm[i].ftp))); } /* other options */ fprintf(out,".SH OTHER OPTIONS\n"); if ( npargs > 0 ) { for(i=0; (i<npargs); i++) { if (pa[i].type == etBOOL) fprintf(out,".BI \"\\-[no]%s\" \"%s\"\n %s\n\n", check_nroff(pa[i].option+1), check_nroff(pa_val(&(pa[i]),tmp,255)), check_nroff(pa[i].desc)); else fprintf(out,".BI \"%s\" \" %s\" \" %s\" \n %s\n\n", check_nroff(pa[i].option), check_nroff(argtp[pa[i].type]), check_nroff(pa_val(&(pa[i]),tmp,255)), check_nroff(pa[i].desc)); } } if (nbug > 0) { fprintf(out,".SH KNOWN PROBLEMS\n"); for(i=0; (i<nbug); i++) fprintf(out,"\\- %s\n\n",check_nroff(bugs[i])); } fprintf(out,".SH SEE ALSO\n.BR gromacs(7)\n\n"); fprintf(out,"More information about \\fBGROMACS\\fR is available at <\\fIhttp://www.gromacs.org/\\fR>.\n"); }
int main(int argc, char** argv) { int count=0, i=0, cmp, j, valid=0; char key[MAX]; //run the shell till user inputs 'quit' or Ctrl-C while(strcmp(cmdline, "quit") != 0) { count = 0; //our shell's prompt printf("afreen@myShell $ "); //get command line input gets(cmdline); //tokenize the CL input delimited by " " using strtok() into args args[count++] = strtok(cmdline, " "); //tokenize the entire string till the next token encountered //does not have a NULL pointer while((args[count++] = strtok(NULL, " "))); count--; //no of arguments (argc) //if user wants to clear screen if(strcmp(args[0], "clear") == 0) { myclear(); } //checking for the input command strcpy(key, args[0]); for(i=0; i<18; i++) //look through our check array for command { if(strcmp(check[i], key) == 0) { valid = -1; switch(i) { case 0: mycat(count, args); break; case 1: mycd(count, args); break; case 2: mycp(count, args); break; case 3: mydate(count, args); break; case 4: myhead(count, args); break; case 5: myls(count, args); break; case 6: myll(count, args); break; case 7: myln(count, args); break; case 8: myld(count, args); break; case 9: mymkdir(count, args); break; case 10: mymv(count, args); break; case 11: mypwd(count, args); break; case 12: myrm(count, args); break; case 13: myrmdir(count, args); break; case 14: mytail(count, args); break; case 15: mytime(count, args); break; case 16: mytouch(count, args); break; case 17: myuname(count, args); break; default: printf("%s: Command not found\n", key); break; } break; } } } return 0; }
static void write_htmlman(FILE *out, char *program, int nldesc,char **desc, int nfile,t_filenm *fnm, int npargs,t_pargs *pa, int nbug,char **bugs) { int i; char link[10]; #define NSR(s) check_html(s,program) fprintf(out,"<HTML>\n<HEAD>\n<TITLE>%s</TITLE>\n",program); fprintf(out,"<LINK rel=stylesheet href=\"style.css\" type=\"text/css\">\n"); fprintf(out,"<BODY text=\"#000000\" bgcolor=\"#FFFFFF\" link=\"#0000FF\" vlink=\"#990000\" alink=\"#FF0000\">\n"); fprintf(out,"<TABLE WIDTH=\"98%%\" NOBORDER >\n<TR><TD WIDTH=400>\n"); fprintf(out,"<TABLE WIDTH=400 NOBORDER>\n<TD WIDTH=116>\n"); fprintf(out,"<a href=\"http://www.gromacs.org/\">" "<img SRC=\"../images/gmxlogo_small.jpg\"" "BORDER=0 height=133 width=116></a></td>\n"); fprintf(out,"<td ALIGN=LEFT VALIGN=TOP WIDTH=280>" "<br><h2>%s</h2>",program); fprintf(out,"<font size=-1><A HREF=\"../online.html\">Main Table of Contents</A></font><br>"); fprintf(out,"<br></td>\n</TABLE></TD><TD WIDTH=\"*\" ALIGN=RIGHT VALIGN=BOTTOM><p><B>%s<br>\n",GromacsVersion()); fprintf(out,"%s</B></td></tr></TABLE>\n<HR>\n",mydate()); if (nldesc > 0) { fprintf(out,"<H3>Description</H3>\n<p>\n"); for(i=0; (i<nldesc); i++) fprintf(out,"%s\n",NSR(desc[i])); } if (nfile > 0) { fprintf(out,"<P>\n"); fprintf(out,"<H3>Files</H3>\n"); fprintf(out, "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>\n" "<TR>" "<TH>option</TH>" "<TH>filename</TH>" "<TH>type</TH>" "<TH>description</TH>" "</TR>\n"); for(i=0; (i<nfile); i++) { strcpy(link,ftp2ext(fnm[i].ftp)); if (strcmp(link,"???")==0) strcpy(link,"files"); fprintf(out, "<TR>" "<TD ALIGN=RIGHT> <b><tt>%s</tt></b> </TD>" "<TD ALIGN=RIGHT> <tt><a href=\"%s.html\">%12s</a></tt> </TD>" "<TD> %s </TD>" "<TD> %s </TD>" "</TR>\n", fnm[i].opt,link,fnm[i].fn,fileopt(fnm[i].flag), NSR(ftp2desc(fnm[i].ftp))); } fprintf(out,"</TABLE>\n"); } if (npargs > 0) { fprintf(out,"<P>\n"); fprintf(out,"<H3>Other options</H3>\n"); fprintf(out, "<TABLE BORDER=1 CELLSPACING=0 CELLPADDING=2>\n" "<TR>" "<TH>option</TH>" "<TH>type</TH>" "<TH>default</TH>" "<TH>description</TH>" "</TR>\n"); for(i=0; (i<npargs); i++) fprintf(out, "<TR>" "<TD ALIGN=RIGHT> <b><tt>%s%s</tt></b> </TD>" "<TD ALIGN=RIGHT> %s </TD>" "<TD ALIGN=RIGHT> <tt>%s</tt> </TD>" "<TD> %s </TD>" "</TD>\n", (pa[i].type == etBOOL)?"-[no]":"-",pa[i].option+1, argtp[pa[i].type],pa_val(&(pa[i])),NSR(pa[i].desc)); fprintf(out,"</TABLE>\n"); } if (nbug > 0) { fprintf(out,"<P>\n"); fprintf(out,"<UL>\n"); for(i=0; (i<nbug); i++) fprintf(out,"<LI>%s\n",NSR(bugs[i])); fprintf(out,"</UL>\n"); } fprintf(out,"<P>\n"); fprintf(out,"<hr>\n<div ALIGN=RIGHT>\n"); fprintf(out,"<font size=\"-1\"><a href=\"http://www.gromacs.org\">" "http://www.gromacs.org</a></font><br>\n"); fprintf(out,"</div>\n"); fprintf(out,"</BODY>\n"); }
static void write_nroffman(FILE *out, char *program, int nldesc,char **desc, int nfile,t_filenm *fnm, int npargs,t_pargs *pa, int nbug,char **bugs) { int i; fprintf(out,".TH %s 1 \"%s\"\n",program,mydate()); fprintf(out,".SH NAME\n"); fprintf(out,"%s\n",program); fprintf(out,".B %s\n",GromacsVersion()); fprintf(out,".SH SYNOPSIS\n"); fprintf(out,"\\f3%s\\fP\n",program); /* command line arguments */ if (nfile > 0) { for(i=0; (i<nfile); i++) fprintf(out,".BI \"%s\" \" %s \"\n",fnm[i].opt, fnm[i].fn); } if (npargs > 0) { for(i=0; (i<npargs); i++) if (pa[i].type == etBOOL) fprintf(out,".BI \"-[no]%s\" \"\"\n",pa[i].option+1); else fprintf(out,".BI \"%s\" \" %s \"\n",pa[i].option, argtp[pa[i].type]); } /* description */ if (nldesc > 0) { fprintf(out,".SH DESCRIPTION\n"); for(i=0; (i<nldesc); i++) fprintf(out,"%s\n",check_nroff(desc[i])); } /* FILES */ if (nfile > 0) { fprintf(out,".SH FILES\n"); for(i=0; (i<nfile); i++) fprintf(out,".BI \"%s\" \" %s\" \n.B %s\n %s \n\n", fnm[i].opt,fnm[i].fn,fileopt(fnm[i].flag), check_nroff(ftp2desc(fnm[i].ftp))); } /* other options */ fprintf(out,".SH OTHER OPTIONS\n"); if ( npargs > 0 ) { for(i=0; (i<npargs); i++) { if (pa[i].type == etBOOL) fprintf(out,".BI \"-[no]%s\" \"%s\"\n %s\n\n", check_nroff(pa[i].option+1), pa_val(&(pa[i])),check_nroff(pa[i].desc)); else fprintf(out,".BI \"%s\" \" %s\" \" %s\" \n %s\n\n", check_nroff(pa[i].option),argtp[pa[i].type], pa_val(&(pa[i])),check_nroff(pa[i].desc)); } } if (nbug > 0) { for(i=0; (i<nbug); i++) fprintf(out,"\\- %s\n\n",check_nroff(bugs[i])); } }