コード例 #1
0
ファイル: main.c プロジェクト: tm512/ispolin
void get_title (char **link, char **ttag)
{
	int i;
	char *ctag = strcasestr (*ttag, "</title>");

	if (!ctag)
		return;

	// exclude <title>
	*ttag = strstr (*ttag, ">") + 1;

	// null terminate after closing tag
	*ctag = '\0';

	// convert newlines to spaces. Yes, youtube, I'm looking at you
	for (i = 0; (*ttag) [i] != '\0'; i++)
		if ((*ttag) [i] == '\r' || (*ttag) [i] == '\n')
			(*ttag) [i] = ' ';

	// condense spaces, youtube, I'm looking at you again :|
	condense_spaces (*ttag);
	stripw ((*ttag));
	while (isspace (**ttag))
		(*ttag) ++;

	// Convert &amp; type character codes
	if (strstr (*ttag, "&"))
		convertchars (*ttag);

	// Now, we need to strip apart the link
	*link = strstr (*link, "://") + 3;
	if (strstr (*link, "/"))
		strstr (*link, "/") [0] = '\0';

	return;
}
コード例 #2
0
ファイル: assm.c プロジェクト: BigEd/pyldin
void assemble(char *outname)
{
  char *aline;
  int dataoffset, stringsoffset, linkisoffset;
  int datalen, stringslen, linkislen, oldlineno;
  struct export *e, *eo;

  numfuncs = 0;
  numlinkis = 0;
  temptype = -2;
  if(src == NULL)
    return;
  if(verbose)
    fprintf(stderr, "\n%s: Assembling file `%s'\n", progname, src->filename);
  errors = 0;
  makearea(&oheaders);
  makearea(&ostrings);
  makearea(&odata);
  makearea(&olinkis);

  PARENTO = addonestrtoarea(outname);

  /* build header */
  addinttoarea(&oheaders, 0x6a624f51);	/* "QObj" */
  addinttoarea(&oheaders, -1);		/* creator string */
  addinttoarea(&oheaders, -1);		/* num funcs */
  addinttoarea(&oheaders, 60);		/* address func headers */
  addinttoarea(&oheaders, -1);		/* procos */
  addinttoarea(&oheaders, 0);		/* reserved */
  addinttoarea(&oheaders, 2);		/* obj format version */
  addinttoarea(&oheaders, 0);		/* address code/data */
  addinttoarea(&oheaders, 0);		/* length code/data */
  addinttoarea(&oheaders, 0);		/* address strings */
  addinttoarea(&oheaders, 0);		/* length strings */
  addinttoarea(&oheaders, 0);		/* address linkis */
  addinttoarea(&oheaders, 0);		/* length linkis */
  addinttoarea(&oheaders, 0);		/* address debug info */
  addinttoarea(&oheaders, 0);		/* length debug info */
  strcpy(creator, "qas RISC OS ARM Assembler vsn "VERS" © Stu Smith ["__DATE__"]");
  strcpy(procos, "ARM/RISCOS");

  funcheadsoff = oheaders.used;

  /* assemble line-by-line */
  parseinit();
  clearvalues(&llabels);
  clearvalues(&rns);
  clearvalues(&fns);
  clearvalues(&cns);
  clearvalues(&sets);

  while(src) {
    aline = getline();
    decomment(aline);
    stripw(aline);
    if(*aline) {
      assmline(aline);
    }
  }
  endprevfunc();
  placeint(&oheaders, addonestrtoarea(creator), 4);
  placeint(&oheaders, addonestrtoarea(procos), 16);
  placeint(&oheaders, numfuncs, 8);

  /* concat headers-data-strings */
  alignarea(&oheaders);
  alignarea(&odata);
  alignarea(&ostrings);
  dataoffset = addtoarea(&oheaders, odata.mem, odata.used);
  datalen = odata.used;
  droparea(&odata);
  alignarea(&oheaders);
  linkisoffset = addtoarea(&oheaders, olinkis.mem, olinkis.used);
  linkislen = olinkis.used;
  droparea(&olinkis);
  alignarea(&oheaders);
  stringsoffset = addtoarea(&oheaders, ostrings.mem, ostrings.used);
  stringslen = ostrings.used;
  droparea(&ostrings);
  alignarea(&oheaders);

  if(numfuncs == 0)
    error("No symbols defined");

  placeint(&oheaders, dataoffset,    28);
  placeint(&oheaders, datalen,       32);
  placeint(&oheaders, stringsoffset, 36);
  placeint(&oheaders, stringslen,    40);
  placeint(&oheaders, linkisoffset,  44);
  placeint(&oheaders, linkislen,     48);
  placeint(&oheaders, 0,             52);
  placeint(&oheaders, 0,             56);

  e = exportlist;
  while(e) {
    oldlineno = lineno;
    lineno = e->line;
    error("Can't export symbol `%s': not defined", e->symname);
    lineno = oldlineno;
    freemem(e->symname);
    eo = e->next;
    freemem(e);
    e = eo;
  }
  exportlist = NULL;

  /* save object file */
#ifndef DEBUG
  if(errors == 0)
#endif
    saveblock(outname, oheaders.mem, oheaders.used);
  droparea(&oheaders);
}