int get_rawpub (rawpub *rpub_ptr, dckey *pub) { const char *pub_as_str = (const char *) dcexport (pub); if (skip_str (&pub_as_str, ELGAMAL_STR) || skip_str (&pub_as_str, ":Pub,p=")) return -1; mpz_init (rpub_ptr->p); mpz_init (rpub_ptr->q); mpz_init (rpub_ptr->g); mpz_init (rpub_ptr->y); if (read_mpz (&pub_as_str, rpub_ptr->p) || skip_str (&pub_as_str, ",q=") || read_mpz (&pub_as_str, rpub_ptr->q) || skip_str (&pub_as_str, ",g=") || read_mpz (&pub_as_str, rpub_ptr->g) || skip_str (&pub_as_str, ",y=") || read_mpz (&pub_as_str, rpub_ptr->y)) { return -1; } return 0; }
int get_rawpriv (rawpriv *rpriv_ptr, dckey *priv) { const char *priv_as_str = (const char *) dcexport (priv); if (skip_str (&priv_as_str, ELGAMAL_STR) || skip_str (&priv_as_str, ":Priv,p=")) return -1; mpz_init (rpriv_ptr->p); mpz_init (rpriv_ptr->q); mpz_init (rpriv_ptr->g); mpz_init (rpriv_ptr->x); if (read_mpz (&priv_as_str, rpriv_ptr->p) || skip_str (&priv_as_str, ",q=") || read_mpz (&priv_as_str, rpriv_ptr->q) || skip_str (&priv_as_str, ",g=") || read_mpz (&priv_as_str, rpriv_ptr->g) || skip_str (&priv_as_str, ",x=") || read_mpz (&priv_as_str, rpriv_ptr->x)) { return -1; } return 0; }
static dckey * rw_import_priv (const char *asc) { rw_priv *sk; if (skip_str (&asc, rabin_1.name) || skip_str (&asc, rwak_ppref) || !(sk = malloc (sizeof (*sk)))) return NULL; mpz_init (sk->n); mpz_init (sk->p); mpz_init (sk->q); mpz_init (sk->u); mpz_init (sk->kp); mpz_init (sk->kq); if (read_mpz (&asc, sk->p) || skip_str (&asc, rwak_qpref) || read_mpz (&asc, sk->q) || rw_precompute (sk)) { sk->key.type = PRIVATE; rw_free_priv (&sk->key); return NULL; } return &sk->key; }
void test() { char *str = "abcd\0efg1234"; char *str2 = skip_str(str); printf("str: %s\n", str); printf("str2: %s\n", str2); }
static dckey * rw_import_pub (const char *asc) { rw_pub *pk; if (skip_str (&asc, rabin_1.name) || skip_str (&asc, ":Pub,n=")) return NULL; pk = malloc (sizeof (*pk)); mpz_init (pk->n); if (read_mpz (&asc, pk->n)) { rw_free_pub (&pk->key); return NULL; } pk->key.vptr = &rabin_1; pk->key.type = PUBLIC; pk->nbits = mpz_sizeinbase2 (pk->n) - rw_resvbits; return &pk->key; }
time_t parse_date (const char **a) { const char *d = *a; struct tm raw_time; if (skip_str (&d, "Mon ") && skip_str (&d, "Tue ") && skip_str (&d, "Wed ") && skip_str (&d, "Thu ") && skip_str (&d, "Fri ") && skip_str (&d, "Sat ") && skip_str (&d, "Sun ")) { return (time_t)-1; } /* now get the month */ if (((raw_time.tm_mon = month_to_num (d)) == -1) || (d[3] != ' ')) { return (time_t)-1; } d += 4; /* ... the day */ if (((raw_time.tm_mday = asc_to_num (d, 2)) == -1) || (d[2] != ' ')) { return (time_t)-1; } d += 3; /* ... the hours */ if (((raw_time.tm_hour = asc_to_num (d, 2)) == -1) || (d[2] != ':')) { return (time_t)-1; } d += 3; /* ... the minutes */ if (((raw_time.tm_min = asc_to_num (d, 2)) == -1) || (d[2] != ':')) { return (time_t)-1; } d += 3; /* ... the seconds */ if (((raw_time.tm_sec = asc_to_num (d, 2)) == -1) || (d[2] != ' ')) { return (time_t)-1; } d += 3; /* ... and the year */ if (((raw_time.tm_year = asc_to_num (d, 4)) == -1)) { return (time_t)-1; } d += 4; raw_time.tm_year -= 1900; raw_time.tm_isdst = -1; *a = d; return mktime (&raw_time); }
void _teto_excute_function_others(const char * _Ptr, FUNCTION_LIST *_F_Head) { char *_type, *_name; int string_len_tmp; if (!(_Ptr = SkipWH(_Ptr))) return; // 추가정보 없음. if (!skip_str(_Ptr, TETO_FUNCTION_DETAIL, 2)) return; // 다른용도의 공백이다. _Ptr += 2; if (!(_Ptr = SkipWH(_Ptr))) return; // 추가정보 없음. ///////////////////////////////////////////////////// if (skip_str(_Ptr, "get", 3)) { _Ptr += 3; _F_Head->INJAS = (struct inja *)malloc(sizeof(struct inja)); for (; *_Ptr == ' '; _Ptr++) ; if (*_Ptr++ != '[') ; //error _type = SkipIWH(_Ptr); string_len_tmp = _type - _Ptr; _Ptr = _type; ////////////////////////////////// _Ptr = (char *)malloc(string_len_tmp + 1); PutText(_type, _Ptr, string_len_tmp); _F_Head->INJAS->name = _Ptr; ////////////////////////////////// } else if (skip_str(_Ptr, "set", 3)) ; else if (skip_str(_Ptr, "override", 8)) ; else if (skip_str(_Ptr, "overload", 8)) ; else if (skip_str(_Ptr, "style", 5)) ; else if (skip_str(_Ptr, "import", 6)) ; else if (skip_str(_Ptr, "extend", 6)) ; else ; // 에러 }
int BC_Resources::init_fontconfig(const char *search_path) { if( fontlist ) return 0; fontlist = new ArrayList<BC_FontEntry*>; #define get_str(str,sep,ptr,cond) do { char *out = str; \ while( *ptr && !strchr(sep,*ptr) && (cond) ) *out++ = *ptr++; \ *out = 0; \ } while(0) #define skip_str(sep, ptr) do { \ while( *ptr && strchr(sep,*ptr) ) ++ptr; \ } while(0) char find_command[BCTEXTLEN]; sprintf(find_command, "find %s -name 'fonts.dir' -print -exec cat {} \\;", search_path); FILE *in = popen(find_command, "r"); FT_Library freetype_library = 0; // FT_Face freetype_face = 0; // FT_Init_FreeType(&freetype_library); char line[BCTEXTLEN], current_dir[BCTEXTLEN]; current_dir[0] = 0; while( !feof(in) && fgets(line, BCTEXTLEN, in) ) { if(!strlen(line)) break; char *in_ptr = line; // Get current directory if(line[0] == '/') { get_str(current_dir, "\n", in_ptr,1); for( int i=strlen(current_dir); --i>=0 && current_dir[i]!='/'; ) current_dir[i] = 0; continue; } //printf("TitleMain::build_fonts %s\n", line); BC_FontEntry *entry = new BC_FontEntry; char string[BCTEXTLEN]; // Path get_str(string, "\n", in_ptr, in_ptr[0]!=' ' || in_ptr[1]!='-'); entry->path = cstrcat(2, current_dir, string); // Foundary skip_str(" -", in_ptr); get_str(string, " -\n", in_ptr, 1); if( !string[0] ) { delete entry; continue; } entry->foundry = cstrdup(string); if(*in_ptr == '-') in_ptr++; // Family get_str(string, "-\n", in_ptr, 1); if( !string[0] ) { delete entry; continue; } entry->family = cstrdup(string); if(*in_ptr == '-') in_ptr++; // Weight get_str(string, "-\n", in_ptr, 1); entry->weight = cstrdup(string); if(*in_ptr == '-') in_ptr++; // Slant get_str(string, "-\n", in_ptr, 1); entry->slant = cstrdup(string); if(*in_ptr == '-') in_ptr++; // SWidth get_str(string, "-\n", in_ptr, 1); entry->swidth = cstrdup(string); if(*in_ptr == '-') in_ptr++; // Adstyle get_str(string, "-\n", in_ptr, 1); entry->adstyle = cstrdup(string); if(*in_ptr == '-') in_ptr++; // pixelsize get_str(string, "-\n", in_ptr, 1); entry->pixelsize = atol(string); if(*in_ptr == '-') in_ptr++; // pointsize get_str(string, "-\n", in_ptr, 1); entry->pointsize = atol(string); if(*in_ptr == '-') in_ptr++; // xres get_str(string, "-\n", in_ptr, 1); entry->xres = atol(string); if(*in_ptr == '-') in_ptr++; // yres get_str(string, "-\n", in_ptr, 1); entry->yres = atol(string); if(*in_ptr == '-') in_ptr++; // spacing get_str(string, "-\n", in_ptr, 1); entry->spacing = cstrdup(string); if(*in_ptr == '-') in_ptr++; // avg_width get_str(string, "-\n", in_ptr, 1); entry->avg_width = atol(string); if(*in_ptr == '-') in_ptr++; // registry get_str(string, "-\n", in_ptr, 1); entry->registry = cstrdup(string); if(*in_ptr == '-') in_ptr++; // encoding get_str(string, "-\n", in_ptr, 1); entry->encoding = cstrdup(string); if(*in_ptr == '-') in_ptr++; // Add to list //printf("TitleMain::build_fonts 1 %s\n", entry->path); // This takes a real long time to do. Instead just take all fonts // if(!load_freetype_face(freetype_library, // freetype_face, entry->path) ) // Fix parameters sprintf(line, "%s (%s)", entry->family, entry->foundry); entry->displayname = cstrdup(line); if(!strcasecmp(entry->weight, "demibold")) { entry->fixed_style |= BC_FONT_BOLD; entry->style |= FL_WEIGHT_DEMIBOLD; } else if(!strcasecmp(entry->weight, "bold")) { entry->fixed_style |= BC_FONT_BOLD; entry->style |= FL_WEIGHT_BOLD; } else { entry->style |= FL_WEIGHT_NORMAL; } if(!strcasecmp(entry->slant, "r")) { entry->style |= FL_SLANT_ROMAN; } else if(!strcasecmp(entry->slant, "i")) { entry->style |= FL_SLANT_ITALIC; entry->fixed_style |= BC_FONT_ITALIC; } else if(!strcasecmp(entry->slant, "o")) { entry->style |= FL_SLANT_OBLIQUE; entry->fixed_style |= BC_FONT_ITALIC; } if(!strcasecmp(entry->swidth, "normal")) entry->style = FL_WIDTH_NORMAL; else if(!strcasecmp(entry->swidth, "ultracondensed")) entry->style = FL_WIDTH_ULTRACONDENSED; else if(!strcasecmp(entry->swidth, "extracondensed")) entry->style = FL_WIDTH_EXTRACONDENSED; else if(!strcasecmp(entry->swidth, "condensed")) entry->style = FL_WIDTH_CONDENSED; else if(!strcasecmp(entry->swidth, "semicondensed")) entry->style = FL_WIDTH_SEMICONDENSED; else if(!strcasecmp(entry->swidth, "semiexpanded")) entry->style = FL_WIDTH_SEMIEXPANDED; else if(!strcasecmp(entry->swidth, "expanded")) entry->style = FL_WIDTH_EXPANDED; else if(!strcasecmp(entry->swidth, "extraexpanded")) entry->style = FL_WIDTH_EXTRAEXPANDED; else if(!strcasecmp(entry->swidth, "ultraexpanded")) entry->style = FL_WIDTH_ULTRAEXPANDED; else entry->style = FL_WIDTH_NORMAL; fontlist->append(entry); // printf("TitleMain::build_fonts %s: success\n", entry->path); //printf("TitleMain::build_fonts 2\n"); } pclose(in); // Load all the fonts from fontconfig FcPattern *pat; FcFontSet *fs; FcObjectSet *os; FcChar8 *family, *file, *foundry, *style, *format; int slant, spacing, width, weight; int force_style = 0; // if you want limit search to TrueType put 1 int limit_to_trutype = 1; FcConfig *config; int i; char tmpstring[BCTEXTLEN]; if(!FcInit()) return 1; config = FcConfigGetCurrent(); FcConfigSetRescanInterval(config, 0); pat = FcPatternCreate(); os = FcObjectSetBuild ( FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT, FC_WIDTH, FC_SLANT, FC_FONTFORMAT, FC_SPACING, FC_STYLE, (char *) 0); FcPatternAddBool(pat, FC_SCALABLE, true); if(language[0]) { char langstr[LEN_LANG * 3]; strcpy(langstr, language); if(region[0]) { strcat(langstr, "-"); strcat(langstr, region); } FcLangSet *ls = FcLangSetCreate(); if(FcLangSetAdd(ls, (const FcChar8*)langstr)) if(FcPatternAddLangSet(pat, FC_LANG, ls)) FcLangSetDestroy(ls); } fs = FcFontList(config, pat, os); FcPatternDestroy(pat); FcObjectSetDestroy(os); for (i = 0; fs && i < fs->nfont; i++) { FcPattern *font = fs->fonts[i]; force_style = 0; FcPatternGetString(font, FC_FONTFORMAT, 0, &format); //on this point you can limit font search if(limit_to_trutype && strcmp((char *)format, "TrueType")) continue; sprintf(tmpstring, "%s", format); BC_FontEntry *entry = new BC_FontEntry; if(FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) { entry->path = cstrdup((char*)file); } if(FcPatternGetString(font, FC_FOUNDRY, 0, &foundry) == FcResultMatch) { entry->foundry = cstrdup((char*)foundry); } if(FcPatternGetInteger(font, FC_WEIGHT, 0, &weight) == FcResultMatch) { switch(weight) { case FC_WEIGHT_THIN: case FC_WEIGHT_EXTRALIGHT: case FC_WEIGHT_LIGHT: case FC_WEIGHT_BOOK: force_style = 1; entry->weight = cstrdup("medium"); break; case FC_WEIGHT_NORMAL: case FC_WEIGHT_MEDIUM: default: entry->weight = cstrdup("medium"); break; case FC_WEIGHT_BLACK: case FC_WEIGHT_SEMIBOLD: case FC_WEIGHT_BOLD: entry->weight = cstrdup("bold"); entry->fixed_style |= BC_FONT_BOLD; break; case FC_WEIGHT_EXTRABOLD: case FC_WEIGHT_EXTRABLACK: force_style = 1; entry->weight = cstrdup("bold"); entry->fixed_style |= BC_FONT_BOLD; break; } } if(FcPatternGetString(font, FC_FAMILY, 0, &family) == FcResultMatch) entry->family = cstrdup((char*)family); if(FcPatternGetInteger(font, FC_SLANT, 0, &slant) == FcResultMatch) { switch(slant) { case FC_SLANT_ROMAN: default: entry->slant = cstrdup("r"); entry->style |= FL_SLANT_ROMAN; break; case FC_SLANT_ITALIC: entry->slant = cstrdup("i"); entry->style |= FL_SLANT_ITALIC; entry->fixed_style |= BC_FONT_ITALIC; break; case FC_SLANT_OBLIQUE: entry->slant = cstrdup("o"); entry->style |= FL_SLANT_OBLIQUE; entry->fixed_style |= BC_FONT_ITALIC; break; } } if(FcPatternGetInteger(font, FC_WIDTH, 0, &width) == FcResultMatch) { switch(width) { case FC_WIDTH_ULTRACONDENSED: entry->swidth = cstrdup("ultracondensed"); break; case FC_WIDTH_EXTRACONDENSED: entry->swidth = cstrdup("extracondensed"); break; case FC_WIDTH_CONDENSED: entry->swidth = cstrdup("condensed"); break; case FC_WIDTH_SEMICONDENSED: entry->swidth = cstrdup("semicondensed"); break; case FC_WIDTH_NORMAL: default: entry->swidth = cstrdup("normal"); break; case FC_WIDTH_SEMIEXPANDED: entry->swidth = cstrdup("semiexpanded"); break; case FC_WIDTH_EXPANDED: entry->swidth = cstrdup("expanded"); break; case FC_WIDTH_EXTRAEXPANDED: entry->swidth = cstrdup("extraexpanded"); break; case FC_WIDTH_ULTRAEXPANDED: entry->swidth = cstrdup("ultraexpanded"); break; } } if(FcPatternGetInteger(font, FC_SPACING, 0, &spacing) == FcResultMatch) { switch(spacing) { case 0: default: entry->spacing = cstrdup("p"); break; case 90: entry->spacing = cstrdup("d"); break; case 100: entry->spacing = cstrdup("m"); break; case 110: entry->spacing = cstrdup("c"); break; } } // Add fake stuff for compatibility entry->adstyle = cstrdup(" "); entry->pixelsize = 0; entry->pointsize = 0; entry->xres = 0; entry->yres = 0; entry->avg_width = 0; entry->registry = cstrdup("utf"); entry->encoding = cstrdup("8"); if(!FcPatternGetString(font, FC_STYLE, 0, &style) == FcResultMatch) force_style = 0; // If font has a style unmanaged by titler plugin, force style to be displayed on name // in this way we can shown all available fonts styles. if(force_style) { sprintf(tmpstring, "%s (%s)", entry->family, style); entry->displayname = cstrdup(tmpstring); } else { if(strcmp(entry->foundry, "unknown")) { sprintf(tmpstring, "%s (%s)", entry->family, entry->foundry); entry->displayname = cstrdup(tmpstring); } else { sprintf(tmpstring, "%s", entry->family); entry->displayname = cstrdup(tmpstring); } } fontlist->append(entry); } FcFontSetDestroy(fs); if(freetype_library) FT_Done_FreeType(freetype_library); // for(int i = 0; i < fonts->total; i++) // fonts->values[i]->dump(); FcConfigAppFontAddDir(0, (const FcChar8*)search_path); FcConfigSetRescanInterval(0, 0); os = FcObjectSetBuild(FC_FAMILY, FC_FILE, FC_FOUNDRY, FC_WEIGHT, FC_WIDTH, FC_SLANT, FC_SPACING, FC_STYLE, (char *)0); pat = FcPatternCreate(); FcPatternAddBool(pat, FC_SCALABLE, true); if(language[0]) { char langstr[LEN_LANG * 3]; strcpy(langstr, language); if(region[0]) { strcat(langstr, "-"); strcat(langstr, region); } FcLangSet *ls = FcLangSetCreate(); if(FcLangSetAdd(ls, (const FcChar8*)langstr)) if(FcPatternAddLangSet(pat, FC_LANG, ls)) FcLangSetDestroy(ls); } fs = FcFontList(0, pat, os); FcPatternDestroy(pat); FcObjectSetDestroy(os); for(int i = 0; i < fs->nfont; i++) { FcPattern *font = fs->fonts[i]; BC_FontEntry *entry = new BC_FontEntry; FcChar8 *strvalue; if(FcPatternGetString(font, FC_FILE, 0, &strvalue) == FcResultMatch) { entry->path = new char[strlen((char*)strvalue) + 1]; strcpy(entry->path, (char*)strvalue); } if(FcPatternGetString(font, FC_FOUNDRY, 0, &strvalue) == FcResultMatch) { entry->foundry = new char[strlen((char*)strvalue) + 1]; strcpy(entry->foundry, (char *)strvalue); } if(FcPatternGetString(font, FC_FAMILY, 0, &strvalue) == FcResultMatch) { entry->family = new char[strlen((char*)strvalue) + 2]; strcpy(entry->family, (char*)strvalue); } int intvalue; if(FcPatternGetInteger(font, FC_SLANT, 0, &intvalue) == FcResultMatch) { switch(intvalue) { case FC_SLANT_ROMAN: default: entry->style |= FL_SLANT_ROMAN; break; case FC_SLANT_ITALIC: entry->style |= FL_SLANT_ITALIC; break; case FC_SLANT_OBLIQUE: entry->style |= FL_SLANT_OBLIQUE; break; } } if(FcPatternGetInteger(font, FC_WEIGHT, 0, &intvalue) == FcResultMatch) { switch(intvalue) { case FC_WEIGHT_THIN: entry->style |= FL_WEIGHT_THIN; break; case FC_WEIGHT_EXTRALIGHT: entry->style |= FL_WEIGHT_EXTRALIGHT; break; case FC_WEIGHT_LIGHT: entry->style |= FL_WEIGHT_LIGHT; break; case FC_WEIGHT_BOOK: entry->style |= FL_WEIGHT_BOOK; break; case FC_WEIGHT_NORMAL: default: entry->style |= FL_WEIGHT_NORMAL; break; case FC_WEIGHT_MEDIUM: entry->style |= FL_WEIGHT_MEDIUM; break; case FC_WEIGHT_DEMIBOLD: entry->style |= FL_WEIGHT_DEMIBOLD; break; case FC_WEIGHT_BOLD: entry->style |= FL_WEIGHT_BOLD; break; case FC_WEIGHT_EXTRABOLD: entry->style |= FL_WEIGHT_EXTRABOLD; break; case FC_WEIGHT_BLACK: entry->style |= FL_WEIGHT_BLACK; break; case FC_WEIGHT_EXTRABLACK: entry->style |= FL_WEIGHT_EXTRABLACK; break; } } if(FcPatternGetInteger(font, FC_WIDTH, 0, &intvalue) == FcResultMatch) { switch(intvalue) { case FC_WIDTH_ULTRACONDENSED: entry->style |= FL_WIDTH_ULTRACONDENSED; break; case FC_WIDTH_EXTRACONDENSED: entry->style |= FL_WIDTH_EXTRACONDENSED; break; case FC_WIDTH_CONDENSED: entry->style |= FL_WIDTH_CONDENSED; break; case FC_WIDTH_SEMICONDENSED: entry->style = FL_WIDTH_SEMICONDENSED; break; case FC_WIDTH_NORMAL: default: entry->style |= FL_WIDTH_NORMAL; break; case FC_WIDTH_SEMIEXPANDED: entry->style |= FL_WIDTH_SEMIEXPANDED; break; case FC_WIDTH_EXPANDED: entry->style |= FL_WIDTH_EXPANDED; break; case FC_WIDTH_EXTRAEXPANDED: entry->style |= FL_WIDTH_EXTRAEXPANDED; break; case FC_WIDTH_ULTRAEXPANDED: entry->style |= FL_WIDTH_ULTRAEXPANDED; break; } } if(FcPatternGetInteger(font, FC_SPACING, 0, &intvalue) == FcResultMatch) { switch(intvalue) { case FC_PROPORTIONAL: default: entry->style |= FL_PROPORTIONAL; break; case FC_DUAL: entry->style |= FL_DUAL; break; case FC_MONO: entry->style |= FL_MONO; break; case FC_CHARCELL: entry->style |= FL_CHARCELL; break; } } if(entry->foundry && strcmp(entry->foundry, "unknown")) { char tempstr[BCTEXTLEN]; sprintf(tempstr, "%s (%s)", entry->family, entry->foundry); entry->displayname = new char[strlen(tempstr) + 1]; strcpy(entry->displayname, tempstr); } else { entry->displayname = new char[strlen(entry->family) + 1]; strcpy(entry->displayname, entry->family); } fontlist->append(entry); } FcFontSetDestroy(fs); return 0; }
cert * cert_import (const char *asc) { cert *c = NULL; const char *saved_asc; char *p = NULL; /* first find the version string */ if (skip_str (&asc, CERT_VER) || skip_str (&asc, ":ca=(")) return NULL; c = (cert *) xmalloc (sizeof (cert)); c->version = xstrdup (CERT_VER); c->issuer = c->public_key = NULL; c->identity = c->sig = NULL; /* now find the issuer's public key, which is terminated by ")," */ saved_asc = asc; if (!(asc = strchr (asc, ')')) || skip_str (&asc, "),id=")) { cert_clr (c); return NULL; } /* copy the portion from saved_asc to asc - 6 into a temporary buffer */ p = (char *) xmalloc (asc - 6 - saved_asc + 2); /* extra byte for '\0' */ strncpy (p, saved_asc, asc - 6 - saved_asc + 1); p[asc - 6 - saved_asc + 1] = '\0'; /* import the issuer's public key from this buffer */ if (!(c->issuer = dcimport_pub (p))) { xfree (p); cert_clr(c); return NULL; } xfree (p); p = NULL; /* now read the identity by looking at the next "," */ saved_asc = asc; if (!(asc = strchr (asc, ',')) || skip_str (&asc, ",pk=(")) { cert_clr (c); return NULL; } /* the portion from saved_asc to asc - 6 is the certified identity */ c->identity = (char *) xmalloc (asc - 6 - saved_asc + 2); strncpy (c->identity, saved_asc, asc - 6 - saved_asc + 1); (c->identity)[asc - 6 - saved_asc + 1] = '\0'; /* now find the certified public key, which is again terminated by ")," */ saved_asc = asc; if (!(asc = strchr (asc, ')')) || skip_str (&asc, "),issued=")) { cert_clr (c); return NULL; } /* copy the portion from saved_asc to asc - 10 into a temporary buffer */ p = (char *) xmalloc (asc - 10 - saved_asc + 2); strncpy (p, saved_asc, asc - 10 - saved_asc + 1); p[asc - 10 - saved_asc + 1] = '\0'; /* import the certified public key from this buffer */ if (!(c->public_key = dcimport_pub (p))) { xfree (p); cert_clr(c); return NULL; } xfree (p); p = NULL; /* now read the day this certificate was issued */ if (((c->day_issued = parse_date (&asc)) == -1) || skip_str (&asc, ",expires=")) { cert_clr (c); return NULL; } /* now read the expiration date */ if (!strcmp (asc, "NEVER")) { c->day_expires = c->day_issued; } else if (((c->day_expires = parse_date (&asc)) == -1) || skip_str (&asc, ",sig=")) { cert_clr (c); return NULL; } /* finally, copy the signature */ c->sig = xstrdup (asc); return c; }