int ota_compile(Octstr *ota_doc, Octstr *charset, Octstr **ota_binary) { simple_binary_t *otabxml; int ret; xmlDocPtr pDoc; size_t size; char *ota_c_text; *ota_binary = octstr_create(""); otabxml = simple_binary_create(); octstr_strip_blanks(ota_doc); octstr_shrink_blanks(ota_doc); set_charset(ota_doc, charset); size = octstr_len(ota_doc); ota_c_text = octstr_get_cstr(ota_doc); pDoc = xmlParseMemory(ota_c_text, size); ret = 0; if (pDoc) { ret = parse_document(pDoc, charset, &otabxml); simple_binary_output(*ota_binary, otabxml); xmlFreeDoc(pDoc); } else { xmlFreeDoc(pDoc); octstr_destroy(*ota_binary); simple_binary_destroy(otabxml); error(0, "OTA: No document to parse. Probably an error in OTA source"); return -1; } simple_binary_destroy(otabxml); return ret; }
int si_compile(Octstr *si_doc, Octstr *charset, Octstr **si_binary) { simple_binary_t *sibxml; int ret; xmlDocPtr pDoc; size_t size; char *si_c_text; *si_binary = octstr_create(""); sibxml = simple_binary_create(); octstr_strip_blanks(si_doc); set_charset(si_doc, charset); size = octstr_len(si_doc); si_c_text = octstr_get_cstr(si_doc); pDoc = xmlParseMemory(si_c_text, size); ret = 0; if (pDoc) { ret = parse_document(pDoc, charset, &sibxml); simple_binary_output(*si_binary, sibxml); xmlFreeDoc(pDoc); } else { xmlFreeDoc(pDoc); octstr_destroy(*si_binary); simple_binary_destroy(sibxml); error(0, "SI: No document to parse. Probably an error in SI source"); return -1; } simple_binary_destroy(sibxml); return ret; }
TITANIUM_PROPERTY_SETTER(Buffer, type) { // type property may be Type or CharSet, so we need to check both. const auto type = Titanium::Codec::Constants::to_Type(static_cast<std::string>(argument)); if (type != Titanium::Codec::Type::Unknown) { set_type(Titanium::Codec::Constants::to_Type(static_cast<std::string>(argument))); } else { set_charset(Titanium::Codec::Constants::to_CharSet(static_cast<std::string>(argument))); } return true; }
bool http_pipe::set_charset(const char* from, const char* to) { if (from == NULL || to == NULL || strcasecmp(from, to) == 0) return false; if (conv_ == NULL) conv_ = NEW charset_conv(); if (conv_->update_begin(from, to) == false) { delete conv_; conv_ = NULL; return false; } set_charset(conv_); return true; }
int main( int argc, char **argv ) { char mntpath[MAXPATHLEN]; char fstype[] = "udf"; struct iovec *iov; char *cs_disk, *cs_local, *dev, *dir; int ch, i, iovlen, mntflags, udf_flags, verbose; i = iovlen = mntflags = udf_flags = verbose = 0; cs_disk = cs_local = NULL; iov = NULL; while ( ( ch = getopt( argc, argv, "o:vC:" ) ) != -1 ) switch ( ch ) { case 'o': getmntopts( optarg, mopts, &mntflags, NULL ); break; case 'v': verbose++; break; case 'C': if ( set_charset( &cs_disk, &cs_local, optarg ) == -1 ) err( EX_OSERR, "udf_iconv" ); udf_flags |= UDFMNT_KICONV; break; case '?': default: usage(); } argc -= optind; argv += optind; if ( argc != 2 ) usage(); dev = argv[0]; dir = argv[1]; if ( checkpath( dir, mntpath ) != 0 ) err( EX_USAGE, "%s", mntpath ); (void) rmslashes( dev, dev ); mntflags |= MNT_RDONLY; build_iovec( &iov, &iovlen, "fstype", fstype, ( size_t ) - 1 ); build_iovec( &iov, &iovlen, "fspath", mntpath, ( size_t ) - 1 ); build_iovec( &iov, &iovlen, "from", dev, ( size_t ) - 1 ); build_iovec( &iov, &iovlen, "flags", &udf_flags, sizeof( udf_flags ) ); if ( udf_flags & UDFMNT_KICONV ) { build_iovec( &iov, &iovlen, "cs_disk", cs_disk, ( size_t ) - 1 ); build_iovec( &iov, &iovlen, "cs_local", cs_local, ( size_t ) - 1 ); } if ( nmount( iov, i, mntflags ) < 0 ) err( 1, "%s", dev ); exit( 0 ); }
int main(int argc,char *argv[]) { int er=1,i; signed char *s=NULL; char *tmpp; int mifiles = 5; int nifiles = 0; int verbose = 0; int oldfile = 0; int no_link = 0; char **ifiles; char *ofile; char *efile; char *lfile; char *ifile; char old_e[MAXLINE]; char old_l[MAXLINE]; char old_o[MAXLINE]; tim1=time(NULL); ncmos=0; n65816=0; cmosfl=1; w65816=0; /* default: 6502 only */ altppchar = '#' ; /* i.e., NO alternate char */ if((tmpp = strrchr(argv[0],'/'))) { tmpp++; } else { tmpp = argv[0]; } if( (!strcmp(tmpp,"xa65816")) || (!strcmp(tmpp,"XA65816")) || (!strcmp(tmpp,"xa816")) || (!strcmp(tmpp,"XA816")) ) { w65816 = 1; /* allow 65816 per default */ } /* default output charset for strings in quotes */ set_charset("ASCII"); ifiles = malloc(mifiles*sizeof(char*)); afile = alloc_file(); if (argc <= 1) { usage(w65816, stderr); exit(1); } if (strstr(argv[1], "--help")) { usage(w65816, stdout); exit(0); } if (strstr(argv[1], "--version")) { version(programname, progversion, authors, copyright); exit(0); } ofile="a.o65"; efile=NULL; lfile=NULL; if(pp_init()) { logout("fatal: pp: no memory!"); return 1; } if(b_init()) { logout("fatal: b: no memory!"); return 1; } if(l_init()) { logout("fatal: l: no memory!"); return 1; } i=1; while(i<argc) { if(argv[i][0]=='-') { switch(argv[i][1]) { case 'p': /* intentionally not allowing an argument to follow with a space to avoid - being seen as the alternate preprocessor char! */ if (argv[i][2] == '\0') { fprintf(stderr, "-p requires a character argument\n"); exit(1); } if (argv[i][2] == '#') fprintf(stderr, "using -p# is evidence of stupidity\n"); altppchar = argv[i][2]; if (argv[i][3] != '\0') fprintf(stderr, "warning: extra characters to -p ignored\n"); break; case 'M': masm = 1; /* MASM compatibility mode */ break; case 'O': /* output charset */ { char *name = NULL; if (argv[i][2] == 0) { name = argv[++i]; } else { name = argv[i]+2; } if (set_charset(name) < 0) { fprintf(stderr, "Output charset name '%s' unknown - ignoring! (check case?)\n", name); } } break; case 'A': /* make text segment start so that text relocation is not necessary when _file_ starts at adr */ romable = 2; if(argv[i][2]==0) romaddr = atoi(argv[++i]); else romaddr = atoi(argv[i]+2); break; case 'G': noglob = 1; break; case 'L': /* define global label */ if(argv[i][2]) lg_set(argv[i]+2); break; case 'r': crossref = 1; break; case 'R': relmode = 1; break; case 'D': s = (signed char*)strstr(argv[i]+2,"="); if(s) *s = ' '; pp_define(argv[i]+2); break; case 'c': no_link = 1; fmode |= FM_OBJ; break; case 'v': verbose = 1; break; case 'C': cmosfl = 0; break; case 'W': w65816 = 0; break; case 'w': w65816 = 1; break; case 'B': showblk = 1; break; case 'x': /* old filename behaviour */ oldfile = 1; fprintf(stderr, "Warning: -x is now deprecated and may disappear in future versions!\n"); break; case 'I': if(argv[i][2]==0) { reg_include(argv[++i]); } else { reg_include(argv[i]+2); } break; case 'o': if(argv[i][2]==0) { ofile=argv[++i]; } else { ofile=argv[i]+2; } break; case 'l': if(argv[i][2]==0) { lfile=argv[++i]; } else { lfile=argv[i]+2; } break; case 'e': if(argv[i][2]==0) { efile=argv[++i]; } else { efile=argv[i]+2; } break; case 'b': /* set segment base addresses */ switch(argv[i][2]) { case 't': if(argv[i][3]==0) tbase = atoi(argv[++i]); else tbase = atoi(argv[i]+3); break; case 'd': if(argv[i][3]==0) dbase = atoi(argv[++i]); else dbase = atoi(argv[i]+3); break; case 'b': if(argv[i][3]==0) bbase = atoi(argv[++i]); else bbase = atoi(argv[i]+3); break; case 'z': if(argv[i][3]==0) zbase = atoi(argv[++i]); else zbase = atoi(argv[i]+3); break; default: fprintf(stderr,"unknown segment type '%c' - ignoring!\n", argv[i][2]); break; } break; case 0: fprintf(stderr, "Single dash '-' on command line - ignoring!\n"); break; default: fprintf(stderr, "Unknown option '%c' - ignoring!\n",argv[i][1]); break; } } else { /* no option -> filename */ ifiles[nifiles++] = argv[i]; if(nifiles>=mifiles) { mifiles += 5; ifiles=realloc(ifiles, mifiles*sizeof(char*)); if(!ifiles) { fprintf(stderr, "Oops: couldn't alloc enough mem for filelist table..!\n"); exit(1); } } } i++; } if(!nifiles) { fprintf(stderr, "No input files given!\n"); exit(0); } if(oldfile) { strcpy(old_e, ifiles[0]); strcpy(old_o, ifiles[0]); strcpy(old_l, ifiles[0]); if(setfext(old_e,".err")==0) efile = old_e; if(setfext(old_o,".obj")==0) ofile = old_o; if(setfext(old_l,".lab")==0) lfile = old_l; } fplab= lfile ? xfopen(lfile,"w") : NULL; fperr= efile ? xfopen(efile,"w") : NULL; if(!strcmp(ofile,"-")) { ofile=NULL; fpout = stdout; } else { fpout= xfopen(ofile,"wb"); } if(!fpout) { fprintf(stderr, "Couldn't open output file!\n"); exit(1); } if(verbose) fprintf(stderr, "%s\n",copyright); if(1 /*!m_init()*/) { if(1 /*!b_init()*/) { if(1 /*!l_init()*/) { /*if(!pp_init())*/ { if(!x_init()) { if(fperr) fprintf(fperr,"%s\n",copyright); if(verbose) logout(ctime(&tim1)); /* Pass 1 */ pc[SEG_ABS]= 0; /* abs addressing */ seg_start(fmode, tbase, dbase, bbase, zbase, 0, relmode); if(relmode) { r_mode(RMODE_RELOC); segment = SEG_TEXT; } else { r_mode(RMODE_ABS); } nolink = no_link; for (i=0; i<nifiles; i++) { ifile = ifiles[i]; sprintf(out,"xAss65: Pass 1: %s\n",ifile); if(verbose) logout(out); er=pp_open(ifile); puttmp(0); puttmp(T_FILE); puttmp(0); puttmp(0); puttmps((signed char*)&ifile, sizeof(filep->fname)); if(!er) { er=pass1(); pp_close(); } else { sprintf(out, "Couldn't open source file '%s'!\n", ifile); logout(out); } } if((er=b_depth())) { sprintf(out,"Still %d blocks open at end of file!\n",er); logout(out); } if(tbase & (align-1)) { sprintf(out,"Warning: text segment ($%04x) start address doesn't align to %d!\n", tbase, align); logout(out); } if(dbase & (align-1)) { sprintf(out,"Warning: data segment ($%04x) start address doesn't align to %d!\n", dbase, align); logout(out); } if(bbase & (align-1)) { sprintf(out,"Warning: bss segment ($%04x) start address doesn't align to %d!\n", bbase, align); logout(out); } if(zbase & (align-1)) { sprintf(out,"Warning: zero segment ($%04x) start address doesn't align to %d!\n", zbase, align); logout(out); } if (n65816>0) fmode |= 0x8000; switch(align) { case 1: break; case 2: fmode |= 1; break; case 4: fmode |= 2; break; case 256: fmode |=3; break; } if((!er) && relmode) h_write(fpout, fmode, tlen, dlen, blen, zlen, 0); if(!er) { if(verbose) logout("xAss65: Pass 2:\n"); seg_pass2(); if(!relmode) { r_mode(RMODE_ABS); } else { r_mode(RMODE_RELOC); segment = SEG_TEXT; } er=pass2(); } if(fplab) printllist(fplab); tim2=time(NULL); if(verbose) printstat(); if((!er) && relmode) seg_end(fpout); /* write reloc/label info */ if(fperr) fclose(fperr); if(fplab) fclose(fplab); if(fpout) fclose(fpout); } else { logout("fatal: x: no memory!\n"); } pp_end(); /* } else { logout("fatal: pp: no memory!");*/ } } else { logout("fatal: l: no memory!\n"); } } else { logout("fatal: b: no memory!\n"); } /*m_exit();*/ } else { logout("Not enough memory available!\n"); } if(ner || er) { fprintf(stderr, "Break after %d error%c\n",ner,ner?'s':0); /*unlink();*/ if(ofile) { unlink(ofile); } } free(ifiles); return( (er || ner) ? 1 : 0 ); }
int main(int argc, char **argv) { struct iovec *iov = NULL; int iovlen = 0; struct stat sb; int c, set_gid, set_uid, set_mask, set_dirmask; char *dev, *dir, mntpath[MAXPATHLEN], *csp; char fstype[] = "msdosfs"; char errmsg[255] = {0}; char *cs_dos = NULL; char *cs_local = NULL; mode_t mask = 0, dirmask = 0; uid_t uid = 0; gid_t gid = 0; set_gid = set_uid = set_mask = set_dirmask = 0; while ((c = getopt(argc, argv, "sl9u:g:m:M:o:L:D:W:")) != -1) { switch (c) { case 's': build_iovec(&iov, &iovlen, "shortnames", NULL, (size_t)-1); break; case 'l': build_iovec(&iov, &iovlen, "longnames", NULL, (size_t)-1); break; case '9': build_iovec_argf(&iov, &iovlen, "nowin95", "", (size_t)-1); break; case 'u': uid = a_uid(optarg); set_uid = 1; break; case 'g': gid = a_gid(optarg); set_gid = 1; break; case 'm': mask = a_mask(optarg); set_mask = 1; break; case 'M': dirmask = a_mask(optarg); set_dirmask = 1; break; case 'L': { const char *quirk = NULL; if (setlocale(LC_CTYPE, optarg) == NULL) err(EX_CONFIG, "%s", optarg); csp = strchr(optarg,'.'); if (!csp) err(EX_CONFIG, "%s", optarg); quirk = kiconv_quirkcs(csp + 1, KICONV_VENDOR_MICSFT); build_iovec_argf(&iov, &iovlen, "cs_local", quirk); cs_local = strdup(quirk); } break; case 'D': cs_dos = strdup(optarg); build_iovec_argf(&iov, &iovlen, "cs_dos", cs_dos, (size_t)-1); break; case 'o': { char *p = NULL; char *val = strdup(""); p = strchr(optarg, '='); if (p != NULL) { free(val); *p = '\0'; val = p + 1; } build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); } break; case 'W': if (strcmp(optarg, "iso22dos") == 0) { cs_local = strdup("ISO8859-2"); cs_dos = strdup("CP852"); } else if (strcmp(optarg, "iso72dos") == 0) { cs_local = strdup("ISO8859-7"); cs_dos = strdup("CP737"); } else if (strcmp(optarg, "koi2dos") == 0) { cs_local = strdup("KOI8-R"); cs_dos = strdup("CP866"); } else if (strcmp(optarg, "koi8u2dos") == 0) { cs_local = strdup("KOI8-U"); cs_dos = strdup("CP866"); } else { err(EX_NOINPUT, "%s", optarg); } build_iovec(&iov, &iovlen, "cs_local", cs_local, (size_t)-1); build_iovec(&iov, &iovlen, "cs_dos", cs_dos, (size_t)-1); break; case '?': default: usage(); break; } } if (optind + 2 != argc) usage(); if (set_mask && !set_dirmask) { dirmask = mask; set_dirmask = 1; } else if (set_dirmask && !set_mask) { mask = dirmask; set_mask = 1; } dev = argv[optind]; dir = argv[optind + 1]; if (cs_local != NULL) { if (set_charset(&iov, &iovlen, cs_local, cs_dos) == -1) err(EX_OSERR, "msdosfs_iconv"); build_iovec_argf(&iov, &iovlen, "kiconv", ""); } else if (cs_dos != NULL) { build_iovec_argf(&iov, &iovlen, "cs_local", "ISO8859-1"); if (set_charset(&iov, &iovlen, "ISO8859-1", cs_dos) == -1) err(EX_OSERR, "msdosfs_iconv"); build_iovec_argf(&iov, &iovlen, "kiconv", ""); } /* * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ if (checkpath(dir, mntpath) != 0) err(EX_USAGE, "%s", mntpath); (void)rmslashes(dev, dev); if (!set_gid || !set_uid || !set_mask) { if (stat(mntpath, &sb) == -1) err(EX_OSERR, "stat %s", mntpath); if (!set_uid) uid = sb.st_uid; if (!set_gid) gid = sb.st_gid; if (!set_mask) mask = dirmask = sb.st_mode & (S_IRWXU | S_IRWXG | S_IRWXO); } build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1); build_iovec(&iov, &iovlen, "from", dev, (size_t)-1); build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); build_iovec_argf(&iov, &iovlen, "uid", "%d", uid); build_iovec_argf(&iov, &iovlen, "gid", "%u", gid); build_iovec_argf(&iov, &iovlen, "mask", "%u", mask); build_iovec_argf(&iov, &iovlen, "dirmask", "%u", dirmask); if (nmount(iov, iovlen, 0) < 0) { if (errmsg[0]) err(1, "%s: %s", dev, errmsg); else err(1, "%s", dev); } exit (0); }
int main(int argc, char **argv) { struct iovec *iov; int iovlen; int ch, mntflags; char *dev, *dir, *p, *val, mntpath[MAXPATHLEN]; int verbose; int ssector; /* starting sector, 0 for 1st session */ char fstype[] = "cd9660"; iov = NULL; iovlen = 0; mntflags = verbose = 0; ssector = -1; while ((ch = getopt(argc, argv, "begjo:rs:vC:")) != -1) switch (ch) { case 'b': build_iovec(&iov, &iovlen, "brokenjoliet", NULL, (size_t)-1); break; case 'e': build_iovec(&iov, &iovlen, "extatt", NULL, (size_t)-1); break; case 'g': build_iovec(&iov, &iovlen, "gens", NULL, (size_t)-1); break; case 'j': build_iovec(&iov, &iovlen, "nojoliet", NULL, (size_t)-1); break; case 'o': getmntopts(optarg, mopts, &mntflags, NULL); p = strchr(optarg, '='); val = NULL; if (p != NULL) { *p = '\0'; val = p + 1; } build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); break; case 'r': build_iovec(&iov, &iovlen, "norrip", NULL, (size_t)-1); break; case 's': ssector = atoi(optarg); break; case 'v': verbose++; break; case 'C': if (set_charset(&iov, &iovlen, optarg) == -1) err(EX_OSERR, "cd9660_iconv"); build_iovec(&iov, &iovlen, "kiconv", NULL, (size_t)-1); break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc != 2) usage(); dev = argv[0]; dir = argv[1]; /* * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ if (checkpath(dir, mntpath) != 0) err(1, "%s", mntpath); (void)rmslashes(dev, dev); if (ssector == -1) { /* * The start of the session has not been specified on * the command line. If we can successfully read the * TOC of a CD-ROM, use the last data track we find. * Otherwise, just use 0, in order to mount the very * first session. This is compatible with the * historic behaviour of mount_cd9660(8). If the user * has specified -s <ssector> above, we don't get here * and leave the user's will. */ if ((ssector = get_ssector(dev)) == -1) { if (verbose) printf("could not determine starting sector, " "using very first session\n"); ssector = 0; } else if (verbose) printf("using starting sector %d\n", ssector); } mntflags |= MNT_RDONLY; build_iovec(&iov, &iovlen, "fstype", fstype, (size_t)-1); build_iovec(&iov, &iovlen, "fspath", mntpath, (size_t)-1); build_iovec(&iov, &iovlen, "from", dev, (size_t)-1); build_iovec_argf(&iov, &iovlen, "ssector", "%d", ssector); if (nmount(iov, iovlen, mntflags) < 0) err(1, "%s", dev); exit(0); }
int main(int argc, char **argv) { struct iovec iov[12]; int ch, i, mntflags, opts, udf_flags; char *dev, *dir, mntpath[MAXPATHLEN]; char *cs_disk, *cs_local; int verbose; i = mntflags = opts = udf_flags = verbose = 0; cs_disk = cs_local = NULL; while ((ch = getopt(argc, argv, "o:vC:")) != -1) switch (ch) { case 'o': getmntopts(optarg, mopts, &mntflags, &opts); break; case 'v': verbose++; break; case 'C': if (set_charset(&cs_disk, &cs_local, optarg) == -1) err(EX_OSERR, "udf_iconv"); udf_flags |= UDFMNT_KICONV; break; case '?': default: usage(); } argc -= optind; argv += optind; if (argc != 2) usage(); dev = argv[0]; dir = argv[1]; /* * Resolve the mountpoint with realpath(3) and remove unnecessary * slashes from the devicename if there are any. */ (void)checkpath(dir, mntpath); (void)rmslashes(dev, dev); /* * UDF file systems are not writeable. */ mntflags |= MNT_RDONLY; iov[i].iov_base = "fstype"; iov[i++].iov_len = sizeof("fstype"); iov[i].iov_base = "udf"; iov[i].iov_len = strlen(iov[i].iov_base) + 1; i++; iov[i].iov_base = "fspath"; iov[i++].iov_len = sizeof("fspath"); iov[i].iov_base = mntpath; iov[i++].iov_len = strlen(mntpath) + 1; iov[i].iov_base = "from"; iov[i++].iov_len = sizeof("from"); iov[i].iov_base = dev; iov[i++].iov_len = strlen(dev) + 1; iov[i].iov_base = "flags"; iov[i++].iov_len = sizeof("flags"); iov[i].iov_base = &udf_flags; iov[i++].iov_len = sizeof(udf_flags); if (udf_flags & UDFMNT_KICONV) { iov[i].iov_base = "cs_disk"; iov[i++].iov_len = sizeof("cs_disk"); iov[i].iov_base = cs_disk; iov[i++].iov_len = strlen(cs_disk) + 1; iov[i].iov_base = "cs_local"; iov[i++].iov_len = sizeof("cs_local"); iov[i].iov_base = cs_local; iov[i++].iov_len = strlen(cs_local) + 1; } if (nmount(iov, i, mntflags) < 0) err(1, "%s", dev); exit(0); }
int main( int argc, char **argv ) { struct iovec *iov; int iovlen; int ch, mntflags; char *dev, *dir, *p, *val, mntpath[MAXPATHLEN]; int verbose; int ssector; char fstype[] = "cd9660"; iov = NULL; iovlen = 0; mntflags = verbose = 0; ssector = -1; while ( ( ch = getopt( argc, argv, "begjo:rs:vC:" ) ) != -1 ) switch ( ch ) { case 'b': build_iovec( &iov, &iovlen, "brokenjoliet", NULL, ( size_t ) - 1 ); break; case 'e': build_iovec( &iov, &iovlen, "extatt", NULL, ( size_t ) - 1 ); break; case 'g': build_iovec( &iov, &iovlen, "gens", NULL, ( size_t ) - 1 ); break; case 'j': build_iovec( &iov, &iovlen, "nojoliet", NULL, ( size_t ) - 1 ); break; case 'o': getmntopts( optarg, mopts, &mntflags, NULL ); p = strchr( optarg, '=' ); val = NULL; if ( p != NULL ) { *p = '\0'; val = p + 1; } build_iovec( &iov, &iovlen, optarg, val, ( size_t ) - 1 ); break; case 'r': build_iovec( &iov, &iovlen, "norrip", NULL, ( size_t ) - 1 ); break; case 's': ssector = atoi( optarg ); break; case 'v': verbose++; break; case 'C': if ( set_charset( &iov, &iovlen, optarg ) == -1 ) err( EX_OSERR, "cd9660_iconv" ); build_iovec( &iov, &iovlen, "kiconv", NULL, ( size_t ) - 1 ); break; case '?': default: usage(); } argc -= optind; argv += optind; if ( argc != 2 ) usage(); dev = argv[0]; dir = argv[1]; if ( checkpath( dir, mntpath ) != 0 ) err( 1, "%s", mntpath ); (void) rmslashes( dev, dev ); if ( ssector == -1 ) { if ( ( ssector = get_ssector( dev ) ) == -1 ) { if ( verbose ) printf( "could not determine starting sector, " "using very first session\n" ); ssector = 0; } else if ( verbose ) printf( "using starting sector %d\n", ssector ); } mntflags |= MNT_RDONLY; build_iovec( &iov, &iovlen, "fstype", fstype, ( size_t ) - 1 ); build_iovec( &iov, &iovlen, "fspath", mntpath, ( size_t ) - 1 ); build_iovec( &iov, &iovlen, "from", dev, ( size_t ) - 1 ); build_iovec_argf( &iov, &iovlen, "ssector", "%d", ssector ); if ( nmount( iov, iovlen, mntflags ) < 0 ) err( 1, "%s", dev ); exit( 0 ); }
/* like set_charset() but charset is in form blabla="CharsetName" */ void got_charset(const char *charset) { set_charset(strchr(charset, '=') + 1); }
/* Tokenize input text and save words in the wordhash_t hash table. * * Returns: true if the EOF token has not been read. */ void collect_words(wordhash_t *wh) { if (DEBUG_WORDLIST(2)) fprintf(dbgout, "### collect_words() begins\n"); lexer_init(); for (;;){ wordprop_t *wp; word_t token; token_t cls = get_token( &token ); if (cls == NONE) break; if (cls == BOGO_LEX_LINE) { char *beg = (char *)token.u.text+1; /* skip leading quote mark */ char *end = strchr(beg, '"'); assert(end); token.leng = end - beg; memmove(token.u.text, token.u.text + 1, token.leng + 1); token.u.text[token.leng] = '\0'; /* ensure nul termination */ } wp = wordhash_insert(wh, &token, sizeof(wordprop_t), &wordprop_init); if (wh->type != WH_CNTS) wp->freq = 1; /******* EK **********/ #ifdef CP866 /* mime charset hack */ { static bool hasCharset=false; if (hasCharset) /* prev token == charset */ { if (token.leng > 5 && !strncmp(token.text, "mime:", 5)) set_charset(token.text+5); } hasCharset = 0; if (token.leng == 5+7) { if (!strncmp(token.text, "mime:", 5) && !strncasecmp(token.text+5, "charset", 7)) hasCharset = true; } } #endif /******* end of EK addition **********/ if (DEBUG_WORDLIST(3)) { fprintf(dbgout, "%3d ", (int) wh->count); word_puts(&token, 0, dbgout); fputc('\n', dbgout); } if (cls == BOGO_LEX_LINE) { char *s = (char *)token.u.text; s += token.leng + 2; wp->cnts.bad = atoi(s); s = strchr(s+1, ' ') + 1; wp->cnts.good = atoi(s); wp->cnts.msgs_good = msgs_good; wp->cnts.msgs_bad = msgs_bad; } } if (DEBUG_WORDLIST(2)) fprintf(dbgout, "### collect_words() ends\n"); return; }