Пример #1
0
Файл: fold.c Проект: aiju/hdl
static int
constfmt(Fmt *f)
{
	Const *c;
	int rc;
	int s;
	
	c = va_arg(f->args, Const *);
	rc = 0;
	if(c == nil || c->n == nil || c->x == nil)
		return fmtstrcpy(f, "<nil>");
	s = c->n->sign;
	if(s < 0){
		c->n->sign = 1;
		rc += fmtrune(f, '-');
	}
	if(c->sz != 0)
		rc += fmtprint(f, "%d", c->sz);
	if(!is0(c->x)){
		rc += binput(f, c);
	}else if(c->base == 0 || c->base == 10)
		rc += fmtprint(f, c->sz != 0 ? "'d%.10B" : "%.10B", c->n);
	else if(c->base == 16)
		rc += fmtprint(f, "'h%.16B", c->n);
	else
		rc += fmtprint(f, "'b%.2B", c->n);
	c->n->sign = s;
	return rc;
}
Пример #2
0
// fil="" : vérifier si règle déja enregistrée
int checkrobots(robots_wizard* robots,char* adr,char* fil) {
  while(robots) {
    if (strfield2(robots->adr,adr)) {
      if (fil[0]) {
        int ptr=0;
        char line[250];
        if (strnotempty(robots->token)) {
          do {
            ptr+=binput(robots->token+ptr,line,200);
            if (line[0]=='/') {    // absolu
              if (strfield(fil,line)) {                 // commence avec ligne
                return -1;        // interdit
              }
            } else {    // relatif
              if (strstrcase(fil,line)) {
                return -1;
              }
            }
          } while( (strnotempty(line)) && (ptr<(int) strlen(robots->token)) );
        }
      } else {
        return -1;
      }
    }
    robots=robots->next;
  }
  return 0;
}
Пример #3
0
// écrire cookies.txt
// !=0 : erreur
int cookie_save(t_cookie * cookie, char *name) {
  char catbuff[CATBUFF_SIZE];

  if (strnotempty(cookie->data)) {
    char BIGSTK line[8192];
    FILE *fp = fopen(fconv(catbuff, name), "wb");

    if (fp) {
      char *a = cookie->data;

      fprintf(fp,
              "# HTTrack Website Copier Cookie File" LF
              "# This file format is compatible with Netscape cookies" LF);
      do {
        a += binput(a, line, 8000);
        fprintf(fp, "%s" LF, line);
      } while(strnotempty(line));
      fclose(fp);
      return 0;
    }
  } else
    return 0;
  return -1;
}