Changeset 97bc90 in git for modules/modgen
- Timestamp:
- Jul 4, 2002, 4:18:37 PM (22 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'd08f5f0bb3329b8ca19f23b74cb1473686415c3a')
- Children:
- 6415eacb8300baef4c7b10e989667323b85419ff
- Parents:
- 836d9e52635244736d1e7e421ebc385b2de76cb0
- Location:
- modules/modgen
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
modules/modgen/creat_top.cc
r836d9e5 r97bc90 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: creat_top.cc,v 1.1 7 2002-07-03 12:42:49anne Exp $ */4 /* $Id: creat_top.cc,v 1.18 2002-07-04 14:18:36 anne Exp $ */ 5 5 /* 6 6 * ABSTRACT: lib parsing … … 71 71 void write_add_singular_proc(FILE *fp) 72 72 { 73 fprintf(fp, "\nidhdl add_singular_proc(FILE* binfp, char *procname, 74 int line,\n"); 73 fprintf(fp, "\nidhdl add_singular_proc(FILE* binfp, char *procname,int line,\n"); 75 74 fprintf(fp, " long pos, long end, BOOLEAN pstatic)\n"); 76 75 fprintf(fp, "{\n"); … … 110 109 fprintf(fp, " return(h);\n"); 111 110 fprintf(fp, "}\n"); 112 modlineno+= 30;111 modlineno+=40; 113 112 } 114 113 … … 125 124 fprintf(fp, " idhdl h;\n"); 126 125 fprintf(fp, " char * tempstr;\n"); 127 fprintf(fp, " FILE * binfp; \n\n"); 126 fprintf(fp, " FILE * binfp; \n"); 127 fprintf(fp, " int ret;\n"); 128 fprintf(fp, " struct stat sb; \n\n"); 128 129 fprintf(fp, " tempstr = (char *)omAlloc(strlen(currPack->libname)+5);\n"); 129 130 fprintf(fp, " memset(tempstr,0,strlen(currPack->libname)+1);\n"); 130 131 fprintf(fp, " memcpy(tempstr,currPack->libname,strlen(currPack->libname));\n"); 131 132 fprintf(fp, " memcpy(tempstr+strlen(currPack->libname)-3,\".bin\",4);\n"); 132 fprintf(fp, " if ((binfp = fopen(tempstr,\"r\")) == NULL)\n"); 133 fprintf(fp, " return -1;\n\n"); 134 133 fprintf(fp, " ret=stat(tempstr,&sb);\n"); 134 fprintf(fp, " if((ret==0) && ((sb.st_mode & S_IFMT) == S_IFREG)) { \n"); 135 fprintf(fp, " if (crccheck(tempstr)!=crcsum) ret=-1;\n"); 136 fprintf(fp, " if ((binfp = fopen(tempstr,\"r\")) == NULL) return -1;\n"); 137 fprintf(fp, " } \n else { \n ret=-1; \n }\n\n"); 135 138 fprintf(fp, " fill_help_package();\n"); 136 139 fprintf(fp, " fill_example_package();\n\n"); 137 138 140 fprintf(fp, " if(ret==-1) Warn(\"file %%s does not agree with module version - ignoring file\",tempstr);\n"); 139 141 } 140 142 -
modules/modgen/main.cc
r836d9e5 r97bc90 112 112 int c; 113 113 int option_index = 0; 114 unsigned long cksm; 114 115 115 116 while( (c=getopt_long (argc, argv, "dmvi:", … … 163 164 if(module_def.fmtfp != NULL) fclose(module_def.fmtfp); 164 165 if(module_def.modfp != NULL) fclose(module_def.modfp); 165 if(module_def.binfp != NULL) fclose(module_def.binfp); 166 if(module_def.modfp_h != NULL) fclose(module_def.modfp_h); 167 if(module_def.docfp != NULL) fclose(module_def.docfp); 166 if(module_def.docfp != NULL) { 167 fprintf(module_def.docfp,"1;"); 168 fclose(module_def.docfp); 169 } 170 if(module_def.binfp != NULL) { 171 fclose(module_def.binfp); 172 cksm = crccheck(build_filename(&module_def,module_def.targetname,3)); 173 } 174 if(module_def.modfp_h != NULL) { 175 fprintf(module_def.modfp_h,"unsigned long crcsum=%lu;\n",cksm); 176 write_crctable(module_def.modfp_h); 177 fclose(module_def.modfp_h); 178 } 168 179 return 0; 169 180 } -
modules/modgen/misc.cc
r836d9e5 r97bc90 2 2 * Computer Algebra System SINGULAR * 3 3 ****************************************/ 4 /* $Id: misc.cc,v 1.1 8 2002-07-03 14:11:23anne Exp $ */4 /* $Id: misc.cc,v 1.19 2002-07-04 14:18:36 anne Exp $ */ 5 5 /* 6 6 * ABSTRACT: lib parsing … … 272 272 module->version = (char *)malloc(strlen((char *)arg2)+1); 273 273 memset(module->version, '\0', strlen((char *)arg2)+1); 274 274 memcpy(module->version,(char *)arg2,strlen((char *)arg2)); 275 275 break; 276 276 case VAR_CATEGORY: … … 316 316 ver[0]='0'; ver[1]='.'; ver[2]='0'; ver[3]='.'; ver[4]='0'; ver[5]='\0'; 317 317 date[0]='?'; date[1]='\0'; 318 //if(what) sscanf(p,"%*[^=]= %*s %*s %10s %16s",ver,date);319 318 sscanf(p,"%*s %*s %10s %16s",ver,date); 320 319 sscanf(ver, "%d.%d.%d", &module->major, &module->minor, &module->level); … … 503 502 fprintf(fp, "#include <ctype.h>\n"); 504 503 fprintf(fp, "%s\n", DYNAinclude[systyp]); 504 fprintf(fp, "#include <unistd.h>\n"); 505 fprintf(fp, "#include <sys/stat.h>"); 505 506 fprintf(fp, "\n"); 506 507 fprintf(fp, "#include <mod2.h>\n"); … … 518 519 fprintf(fp, "#line %d \"%s.cc\"\n", modlineno++, module); 519 520 write_add_singular_proc(fp); 521 write_crccheck(fp); 520 522 fprintf(fp, "\n"); 521 523 -
modules/modgen/modgen.h
r836d9e5 r97bc90 1 1 /* 2 * $Id: modgen.h,v 1.1 5 2002-07-03 12:42:50anne Exp $2 * $Id: modgen.h,v 1.16 2002-07-04 14:18:36 anne Exp $ 3 3 * 4 4 */ … … 176 176 extern int create_tmpfile(moddefv module_def, int which = 0); 177 177 extern char *build_filename(moddefv module, char *text, int what); 178 extern unsigned long crccheck(char *file); 179 extern void write_crccheck(FILE *fp); 180 extern void write_crctable(FILE *fp); 178 181 179 182 /* from proc_setup.cc */ -
modules/modgen/proc.cc
r836d9e5 r97bc90 1 1 /* 2 * $Id: proc.cc,v 1.2 0 2002-07-03 14:11:24anne Exp $2 * $Id: proc.cc,v 1.21 2002-07-04 14:18:37 anne Exp $ 3 3 */ 4 4 … … 68 68 69 69 case LANG_SINGULAR: 70 fprintf(module->modfp," if(ret!=-1) {\n"); 70 71 fprintf(module->modfp, 71 " h = add_singular_proc(binfp,\"%s\", %d, %ld, %ld, %s);\n",72 " h = add_singular_proc(binfp,\"%s\", %d, %ld, %ld, %s);\n", 72 73 proc->procname, proc->lineno, 73 74 proc->sing_start, proc->sing_end, 74 75 proc->is_static ? "TRUE" : "FALSE"); 76 fprintf(module->modfp," }\n"); 75 77 modlineno+=1; 76 78 break; … … 590 592 (module->targetname!=NULL) ? module->targetname : module->name); 591 593 fprintf(module->docfp, "$version = \"%s\";\n", 592 (module-> version!=NULL) ? module->version : "none");594 (module->revision!=NULL) ? module->revision : "none"); 593 595 fprintf(module->docfp, "$category = <<EOT;\n"); 594 596 fprintf(module->docfp, "%s\nEOT\n", … … 601 603 /* */ 602 604 fprintf(module->docfp, "push(@procs, \"%s\");\n",proc->procname); 603 fprintf(module->docfp, "$help{\"%s\"} = << 605 fprintf(module->docfp, "$help{\"%s\"} = <<EOT;\n",proc->procname); 604 606 fprintf(module->docfp, "%s\nEOT\n", 605 607 (proc->help_string!=NULL) ? proc->help_string : 606 608 "No help available for this command"); 607 609 if(proc->example_string!=NULL) { 608 fprintf(module->docfp, "$example{\"%s\"} = << EOT;\n",proc->procname); 609 fprintf(module->docfp, "%s\nEOT\n\n",proc->example_string); 610 } 610 fprintf(module->docfp, "$example{\"%s\"} = <<EOT;\n",proc->procname); 611 fprintf(module->docfp, "%s\nEOT\n",proc->example_string); 612 } 613 fprintf(module->docfp, "$chksum{\"%s\"} = 0;\n", proc->procname); 611 614 612 615 return 0; -
modules/modgen/utils.cc
r836d9e5 r97bc90 1 1 /* 2 * $Id: utils.cc,v 1.1 2 2002-07-03 12:42:51anne Exp $2 * $Id: utils.cc,v 1.13 2002-07-04 14:18:37 anne Exp $ 3 3 */ 4 4 … … 12 12 #include <fcntl.h> 13 13 #include <unistd.h> 14 #include "crctab.h" 14 15 15 16 int modlineno; /* lineno within module */ … … 132 133 return 2; 133 134 } 135 136 /*========================================================================* 137 * crc checksum of a file - as in POSIX cksum programm * 138 *========================================================================*/ 139 unsigned long crccheck( 140 char *file 141 ) 142 { 143 unsigned char buf[BUFLEN1]; 144 unsigned long crc = 0; 145 long length = 0; 146 long bytes_read; 147 register FILE *fp; 148 149 // open the file 150 fp = fopen (file, "rb"); 151 if (fp == NULL) 152 { 153 return 0; 154 } 155 156 // read the file chunk by chunk, determine the lenght and 157 // start computing the checksum 158 while ((bytes_read = fread (buf, 1, BUFLEN1, fp)) > 0) 159 { 160 unsigned char *cp = buf; 161 length += bytes_read; 162 while (bytes_read--) 163 crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF]; 164 } 165 166 // check if something went wrong and close the file 167 if (ferror (fp)) return 0; 168 if (fclose(fp)==EOF) return 0; 169 170 // second part of checksum computation 171 bytes_read = length; 172 while (bytes_read > 0) 173 { 174 crc = (crc << 8) ^ crctab[((crc >> 24) ^ bytes_read) & 0xFF]; 175 bytes_read >>= 8; 176 } 177 178 crc = ~crc & 0xFFFFFFFF; 179 180 return(crc); 181 } 182 183 /*========================================================================* 184 * write function to compute crc checksum of a file into the automatically* 185 * generated file * 186 *========================================================================*/ 187 void write_crccheck(FILE *fp) 188 { 189 fprintf(fp, "\nunsigned long crccheck(\n"); 190 fprintf(fp, " char *file\n"); 191 fprintf(fp, " ) \n{\n unsigned char buf[BUFLEN1];\n"); 192 fprintf(fp, " unsigned long crc = 0;\n"); 193 fprintf(fp, " long length = 0;\n"); 194 fprintf(fp, " long bytes_read;\n"); 195 fprintf(fp, " register FILE *fp;\n\n"); 196 fprintf(fp, " // open the file\n fp = fopen (file, \"rb\");\n"); 197 fprintf(fp, " if (fp == NULL) return 0;\n\n"); 198 fprintf(fp, " // read the file chunk by chunk, determine the lenght and\n"); 199 fprintf(fp, " // start computing the checksum\n"); 200 fprintf(fp, " while ((bytes_read = fread (buf, 1, BUFLEN1, fp)) > 0)\n"); 201 fprintf(fp, " {\n unsigned char *cp = buf;\n"); 202 fprintf(fp, " length += bytes_read;\n"); 203 fprintf(fp, " while (bytes_read--)\n"); 204 fprintf(fp, " crc = (crc << 8) ^ crctab[((crc >> 24) ^ *(cp++)) & 0xFF];\n"); 205 fprintf(fp, " }\n\n"); 206 fprintf(fp, " // check if something went wrong and close the file\n"); 207 fprintf(fp, " if (ferror (fp)) return 0; \n"); 208 fprintf(fp, " if (fclose(fp)==EOF) return 0;\n\n"); 209 fprintf(fp, " // second part of checksum computation\n"); 210 fprintf(fp, " bytes_read = length;\n"); 211 fprintf(fp, " while (bytes_read > 0) {\n"); 212 fprintf(fp, " crc = (crc << 8) ^ crctab[((crc >> 24) ^ bytes_read) & 0xFF];\n"); 213 fprintf(fp, " bytes_read >>= 8;\n }\n\n"); 214 fprintf(fp, " crc = ~crc & 0xFFFFFFFF;\n\n"); 215 fprintf(fp, " return(crc);\n}\n"); 216 modlineno+=37; 217 } 218 void write_crctable(FILE *fp) 219 { 220 221 fprintf(fp, "/*********************************************************************\n"); 222 fprintf(fp, " * crctab.h crctable necessary for the use of crccheck from utils.cc *\n"); 223 fprintf(fp, " *********************************************************************/\n"); 224 fprintf(fp, "# define BUFLEN1 (1 << 16)\n\n"); 225 226 fprintf(fp, "static unsigned long const crctab[256] =\n"); 227 fprintf(fp, "{\n"); 228 fprintf(fp, " 0x0,\n"); 229 fprintf(fp, " 0x04C11DB7, 0x09823B6E, 0x0D4326D9, 0x130476DC, 0x17C56B6B,\n"); 230 fprintf(fp, " 0x1A864DB2, 0x1E475005, 0x2608EDB8, 0x22C9F00F, 0x2F8AD6D6,\n"); 231 fprintf(fp, " 0x2B4BCB61, 0x350C9B64, 0x31CD86D3, 0x3C8EA00A, 0x384FBDBD,\n"); 232 fprintf(fp, " 0x4C11DB70, 0x48D0C6C7, 0x4593E01E, 0x4152FDA9, 0x5F15ADAC,\n"); 233 fprintf(fp, " 0x5BD4B01B, 0x569796C2, 0x52568B75, 0x6A1936C8, 0x6ED82B7F,\n"); 234 fprintf(fp, " 0x639B0DA6, 0x675A1011, 0x791D4014, 0x7DDC5DA3, 0x709F7B7A,\n"); 235 fprintf(fp, " 0x745E66CD, 0x9823B6E0, 0x9CE2AB57, 0x91A18D8E, 0x95609039,\n"); 236 fprintf(fp, " 0x8B27C03C, 0x8FE6DD8B, 0x82A5FB52, 0x8664E6E5, 0xBE2B5B58,\n"); 237 fprintf(fp, " 0xBAEA46EF, 0xB7A96036, 0xB3687D81, 0xAD2F2D84, 0xA9EE3033,\n"); 238 fprintf(fp, " 0xA4AD16EA, 0xA06C0B5D, 0xD4326D90, 0xD0F37027, 0xDDB056FE,\n"); 239 fprintf(fp, " 0xD9714B49, 0xC7361B4C, 0xC3F706FB, 0xCEB42022, 0xCA753D95,\n"); 240 fprintf(fp, " 0xF23A8028, 0xF6FB9D9F, 0xFBB8BB46, 0xFF79A6F1, 0xE13EF6F4,\n"); 241 fprintf(fp, " 0xE5FFEB43, 0xE8BCCD9A, 0xEC7DD02D, 0x34867077, 0x30476DC0,\n"); 242 fprintf(fp, " 0x3D044B19, 0x39C556AE, 0x278206AB, 0x23431B1C, 0x2E003DC5,\n"); 243 fprintf(fp, " 0x2AC12072, 0x128E9DCF, 0x164F8078, 0x1B0CA6A1, 0x1FCDBB16,\n"); 244 fprintf(fp, " 0x018AEB13, 0x054BF6A4, 0x0808D07D, 0x0CC9CDCA, 0x7897AB07,\n"); 245 fprintf(fp, " 0x7C56B6B0, 0x71159069, 0x75D48DDE, 0x6B93DDDB, 0x6F52C06C,\n"); 246 fprintf(fp, " 0x6211E6B5, 0x66D0FB02, 0x5E9F46BF, 0x5A5E5B08, 0x571D7DD1,\n"); 247 fprintf(fp, " 0x53DC6066, 0x4D9B3063, 0x495A2DD4, 0x44190B0D, 0x40D816BA,\n"); 248 fprintf(fp, " 0xACA5C697, 0xA864DB20, 0xA527FDF9, 0xA1E6E04E, 0xBFA1B04B,\n"); 249 fprintf(fp, " 0xBB60ADFC, 0xB6238B25, 0xB2E29692, 0x8AAD2B2F, 0x8E6C3698,\n"); 250 fprintf(fp, " 0x832F1041, 0x87EE0DF6, 0x99A95DF3, 0x9D684044, 0x902B669D,\n"); 251 fprintf(fp, " 0x94EA7B2A, 0xE0B41DE7, 0xE4750050, 0xE9362689, 0xEDF73B3E,\n"); 252 fprintf(fp, " 0xF3B06B3B, 0xF771768C, 0xFA325055, 0xFEF34DE2, 0xC6BCF05F,\n"); 253 fprintf(fp, " 0xC27DEDE8, 0xCF3ECB31, 0xCBFFD686, 0xD5B88683, 0xD1799B34,\n"); 254 fprintf(fp, " 0xDC3ABDED, 0xD8FBA05A, 0x690CE0EE, 0x6DCDFD59, 0x608EDB80,\n"); 255 fprintf(fp, " 0x644FC637, 0x7A089632, 0x7EC98B85, 0x738AAD5C, 0x774BB0EB,\n"); 256 fprintf(fp, " 0x4F040D56, 0x4BC510E1, 0x46863638, 0x42472B8F, 0x5C007B8A,\n"); 257 fprintf(fp, " 0x58C1663D, 0x558240E4, 0x51435D53, 0x251D3B9E, 0x21DC2629,\n"); 258 fprintf(fp, " 0x2C9F00F0, 0x285E1D47, 0x36194D42, 0x32D850F5, 0x3F9B762C,\n"); 259 fprintf(fp, " 0x3B5A6B9B, 0x0315D626, 0x07D4CB91, 0x0A97ED48, 0x0E56F0FF,\n"); 260 fprintf(fp, " 0x1011A0FA, 0x14D0BD4D, 0x19939B94, 0x1D528623, 0xF12F560E,\n"); 261 fprintf(fp, " 0xF5EE4BB9, 0xF8AD6D60, 0xFC6C70D7, 0xE22B20D2, 0xE6EA3D65,\n"); 262 fprintf(fp, " 0xEBA91BBC, 0xEF68060B, 0xD727BBB6, 0xD3E6A601, 0xDEA580D8,\n"); 263 fprintf(fp, " 0xDA649D6F, 0xC423CD6A, 0xC0E2D0DD, 0xCDA1F604, 0xC960EBB3,\n"); 264 fprintf(fp, " 0xBD3E8D7E, 0xB9FF90C9, 0xB4BCB610, 0xB07DABA7, 0xAE3AFBA2,\n"); 265 fprintf(fp, " 0xAAFBE615, 0xA7B8C0CC, 0xA379DD7B, 0x9B3660C6, 0x9FF77D71,\n"); 266 fprintf(fp, " 0x92B45BA8, 0x9675461F, 0x8832161A, 0x8CF30BAD, 0x81B02D74,\n"); 267 fprintf(fp, " 0x857130C3, 0x5D8A9099, 0x594B8D2E, 0x5408ABF7, 0x50C9B640,\n"); 268 fprintf(fp, " 0x4E8EE645, 0x4A4FFBF2, 0x470CDD2B, 0x43CDC09C, 0x7B827D21,\n"); 269 fprintf(fp, " 0x7F436096, 0x7200464F, 0x76C15BF8, 0x68860BFD, 0x6C47164A,\n"); 270 fprintf(fp, " 0x61043093, 0x65C52D24, 0x119B4BE9, 0x155A565E, 0x18197087,\n"); 271 fprintf(fp, " 0x1CD86D30, 0x029F3D35, 0x065E2082, 0x0B1D065B, 0x0FDC1BEC,\n"); 272 fprintf(fp, " 0x3793A651, 0x3352BBE6, 0x3E119D3F, 0x3AD08088, 0x2497D08D,\n"); 273 fprintf(fp, " 0x2056CD3A, 0x2D15EBE3, 0x29D4F654, 0xC5A92679, 0xC1683BCE,\n"); 274 fprintf(fp, " 0xCC2B1D17, 0xC8EA00A0, 0xD6AD50A5, 0xD26C4D12, 0xDF2F6BCB,\n"); 275 fprintf(fp, " 0xDBEE767C, 0xE3A1CBC1, 0xE760D676, 0xEA23F0AF, 0xEEE2ED18,\n"); 276 fprintf(fp, " 0xF0A5BD1D, 0xF464A0AA, 0xF9278673, 0xFDE69BC4, 0x89B8FD09,\n"); 277 fprintf(fp, " 0x8D79E0BE, 0x803AC667, 0x84FBDBD0, 0x9ABC8BD5, 0x9E7D9662,\n"); 278 fprintf(fp, " 0x933EB0BB, 0x97FFAD0C, 0xAFB010B1, 0xAB710D06, 0xA6322BDF,\n"); 279 fprintf(fp, " 0xA2F33668, 0xBCB4666D, 0xB8757BDA, 0xB5365D03, 0xB1F740B4\n"); 280 fprintf(fp, "};\n"); 281 }
Note: See TracChangeset
for help on using the changeset viewer.