Exemplo n.º 1
0
Local void processOneBar(struct LOC_musicParagraph *LINK)
{
  paragraph_index0 m, cm;
  voice_index voice, cvoice;
  boolean ignore_voice;
  boolean wrote_repeat = false;
  boolean alone;
  Char STR2[256];
  Char STR3[256];

  if (bar_of_line > 1) {
    sprintf(STR3, "%cBar %s", comment, toString(STR2, bar_no));
    putLine(STR3);
  }
  last_bar = (bar_of_line == nbars && final_paragraph);
  if (last_bar && !strcmp(repeat_sign, "|"))
    *repeat_sign = '\0';
  writeRepeat(repeat_sign);
  *LINK->new_meter = '\0';
  for (voice = nvoices; voice >= 1; voice--) {
    if (musicLineNo(voice) > 0) {
      gotoBar(voice, bar_of_line);
      getMeterChange(voice, LINK->new_meter);
    }
  }
  if (last_bar && *LINK->new_meter == '\0' && nleft > pickup && meternum > 0)
    meterChange(LINK->new_meter, nleft, 64, true);
  if (*LINK->new_meter != '\0')
    putLine(LINK->new_meter);
  for (voice = nvoices; voice >= 1; voice--) {
    ignore_voice = !selected[voice-1];
    cvoice = companion(voice);
    m = musicLineNo(voice);
    cm = musicLineNo(cvoice);
    alone = (voice == cvoice || m > 0 && cm == 0 ||
	     m == 0 && cm == 0 && voice < cvoice || !selected[cvoice-1]);
    if (selected[voice-1]) {
      if (m > 0)
	processLine(voice, bar_of_line);
      else if (alone)
	supplyRests(voice);
      else
	ignore_voice = true;
      if (last_bar && *repeat_sign != '\0' && !wrote_repeat) {
	writeRepeat(repeat_sign);
	wrote_repeat = true;
      }
      if (!ignore_voice) {
	if (alone || voicePos(voice) == 1)
	  putLine(" /");
	else
	  putLine(" //");
      }
    }
  }
  bar_no++;
  pickup = 0;
  putLine("");
}
Exemplo n.º 2
0
Static void topOfPMXfile(void)
{
  Char STR2[24];
  Char STR3[30];

  putLine("---");
  sprintf(STR2, "\\def\\mtxversion{%s}", version);
  putLine(STR2);
  sprintf(STR3, "\\def\\mtxdate{%s}", version_date);
  putLine(STR3);
  putLine("\\input mtx");
}
Exemplo n.º 3
0
Local void output(Char *note_, struct LOC_processLine *LINK)
{
  Char note[256];
  Char STR2[256];

  strcpy(note, note_);
  if (*note != '\0')
  {  /* pretex is saved up until a spacing note or rest comes */
    if (endsWith(note, "\\") && note[1] != '\\') {
      curtail(note, '\\');
      strcat(LINK->pretex, note);
      *note = '\0';
      return;
    }
    if (*LINK->pretex != '\0' && isNoteOrRest(note)) {
      sprintf(note, "%s\\ %s", LINK->pretex, strcpy(STR2, note));
      *LINK->pretex = '\0';
    }
    if (outlen > 0 && note[0] != ' ')
      sprintf(note, " %s", strcpy(STR2, note));
    put(note, nospace);
  }
  if (thisNote(LINK->voice) == nextvoice)
    putLine("");
}
Exemplo n.º 4
0
/**
 * Create
 * Create and return a byte array of an HTTP request, built from the variables of this HTTPRequest
 *
 * @return Byte array of this HTTPRequest to be sent over the wire
 */
uint8_t* HTTPRequest::create() {
    // Clear the bytebuffer in the event this isn't the first call of create()
	clear();
    
    // Insert the initial line: <method> <path> <version>\r\n
    std::string mstr = "";
    mstr = methodIntToStr(method);
    if(mstr.empty()) {
        printf("Could not create HTTPRequest, unknown method id: %i\n", method);
        return NULL;
    }
    putLine(mstr + " " + requestUri + " " + version);
    
    // Put all headers
    putHeaders();
    
    // If theres body data, add it now
    if((data != NULL) && dataLen > 0) {
        putBytes(data, dataLen);
    }
    
    // Allocate space for the returned byte array and return it
	uint8_t* createRetData = new uint8_t[size()];
	setReadPos(0);
	getBytes(createRetData, size());
    
    return createRetData;
}
Exemplo n.º 5
0
void augmentPreamble(boolean control_para)
{
  paragraph_index i;
  line_type l;
  short s[5];
  paragraph_index FORLIM;

  if (!thisCase())
    return;
  for (l = unknown; l <= plain_line; l = (line_type)((long)l + 1))
    s[(long)l] = 0;
  FORLIM = para_len;
  for (i = 0; i <= FORLIM - 1; i++) {
    line_no = orig_line_no[i];
    l = doCommand(P[i]);
    s[(long)l]++;
    if (l == comment_line && P[i][1] == comment) {
      predelete(P[i], 2);
      putLine(P[i]);
    }
    if (!control_para && l == unknown)
      error("Unidentifiable line", print);
  }
  if (!control_para && s[(long)command_line] > 0 && s[(long)plain_line] > 0)
    error("Mixture of preamble commands and music", !print);
}
Exemplo n.º 6
0
main(int argc, Char *argv[])
{  /* ---- Main program ------------------------ */
  PASCAL_MAIN(argc, argv);
  strcpy(this_version, version);
  strcpy(this_version_date, version_date);
  printf("==> This is M-Tx %s (Music from TeXt) %s\n", version, version_date);

  mtxLevel(version);
  OpenFiles();
  no_commands_yet = true;
  preambleDefaults();
  no_report_errors = false;
  topOfPMXfile();
  do {
    readParagraph(P, orig_line_no, &para_len);
    control_paragraph = isControlParagraph(P, para_len);
    if (control_paragraph) {
      augmentPreamble(no_report_errors);
      no_report_errors = true;
      if (para_len == 0)
	error("No music paragraphs!", !print);
    }
  } while (control_paragraph);
  doPreamble();
  doMusic();
  if (!pmx_preamble_done)
    error("No music paragraphs!", !print);
  putLine("% Coded by M-Tx");
  CloseFiles();
  printf("PrePMX done.  Now run PMX.\n");
  _Escape(0);
  exit(EXIT_SUCCESS);
}
Exemplo n.º 7
0
Static void writeRepeat(Char *bar)
{
  Char repcode[256];
  Char STR1[256];

  if (*bar == '\0')
    return;
  *repcode = '\0';
  if (!strcmp(bar, "||"))
    strcpy(repcode, "Rd");
  else if (!strcmp(bar, "|]"))
    strcpy(repcode, "RD");
  else if (!strcmp(bar, "|:"))
    strcpy(repcode, "Rl");
  else if (!strcmp(bar, ":|:"))
    strcpy(repcode, "Rlr");
  else if (!strcmp(bar, ":|"))
    strcpy(repcode, "Rr");
  else if (last_bar && !strcmp(bar, "|"))
    strcpy(repcode, "Rb");
  if (*repcode != '\0') {
    sprintf(STR1, " %s", repcode);
    putLine(STR1);
  }
  *bar = '\0';
}
Exemplo n.º 8
0
//----------------------------------------------------------------------
bool checkLine(size_t size)
{
  if ( g_bufbeg == NULL )
    return true;
  if ( maxpos - curpos > outcnt + size )
    return true;
  return putLine() != 0;
}
ClientConnection::ClientConnection(Server& server, int sock,
  std::string& nickname) : Connection(sock), server(server), sock(sock)
{
  //Set nickname.
  this->nickname = nickname;
  putLine(std::string("UGOTZANICKNAMES ") + nickname);
  //List all members.
  const std::list<ClientConnection*> clients = server.getClients();
  if (clients.size() > 0)
  {
    std::string members = "WEGOTZTHESEPEOPLEHERE";
    for (std::list<ClientConnection*>::const_iterator i = clients.begin();
         i != clients.end(); ++i)
      members += std::string(" ") + (*i)->getNickname();
    putLine(members);
  }
  //Broadcast join.
  server.broadcastJoin(this);
}
Exemplo n.º 10
0
Arquivo: star.c Projeto: shivae/CPE101
int main(){
   char image[HEIGHT][WIDTH][COLORS];
   char white[COLORS], red[COLORS];
   
   setColor(white, 255, 255, 255);
   setColor(red, 255, 0, 0);

   blankImage(image, white);

   putLine(image, 100, 300, 300, 400, red);
   putLine(image, 300, 400, 200, 150, red);
   putLine(image, 200, 150, 200, 450, red);
   putLine(image, 200, 450, 300, 200, red);
   putLine(image, 300, 200, 100, 300, red);

   drawImage(image);
   
   return 0;
}
Exemplo n.º 11
0
Local void processMBR(struct LOC_musicParagraph *LINK)
{
  short s, bars_of_rest;
  Char mbr[256];
  short FORLIM;
  Char STR1[256];
  Char STR3[256];

  strcpy(mbr, multi_bar_rest);
  predelete(mbr, 2);
  getNum(mbr, &bars_of_rest);
  bar_no += bars_of_rest;
  FORLIM = nstaves;
  for (s = 1; s <= FORLIM; s++) {
    if (pickup > 0)
      put(rests(STR1, pickup, meterdenom, visible), nospace);
    sprintf(STR3, "rm%s /", toString(STR1, bars_of_rest));
    putLine(STR3);
  }
  putLine("");
}
Exemplo n.º 12
0
Local void putPMXlines(struct LOC_musicParagraph *LINK)
{
  paragraph_index i, FORLIM;

  FORLIM = para_len;
  for (i = 0; i <= FORLIM - 1; i++) {
    if (startsWith(P[i], double_comment)) {
      predelete(P[i], 2);
      putLine(P[i]);
      strcpy(P[i], "%");
    }
  }
}
Exemplo n.º 13
0
Static void doTenorClefs(void)
{
  voice_index i;
  Char c;
  voice_index FORLIM;
  Char STR1[256];
  Char STR3[256];

  FORLIM = nclefs;
  for (i = 1; i <= FORLIM; i++) {
    c = clef[i-1];
    if (c == '8' || c == 't') {
      sprintf(STR3, "\\\\mtxTenorClef{%s}\\", toString(STR1, PMXinstr(i)));
      putLine(STR3);
    }
  }
}
Exemplo n.º 14
0
byte* HttpResponse::create() {
    clear();

    std::stringstream sline;
    sline << version << " " << status << " " << reason;
    putLine(sline.str());

    putHeaders();

    if((data != NULL) && dataLen > 0) {
        putBytes(data, dataLen);
    }

    byte* createRetData = new byte[size()];
    setReadPos(0);
    getBytes(createRetData, size());

    return createRetData;
}
Exemplo n.º 15
0
uchar OutUtf8(ushort index, fmt_t mode, color_t color)
{
  size_t size = (maxpos - curpos) - outcnt;

  if ( (int)size <= MIN_ARG_SIZE )
  {
   DEB_ASSERT(((int)size < 0), "OutUtf8");
   size = putLine();
   if ( size == 0 )
     return 1;
  }

  if ( color != COLOR_NONE )
    out_tagon(color);
  ref_pos = get_output_ptr();
  if ( fmtString(index, size, mode, putLine) < 0 )
    return 1;
  outcnt += get_output_ptr() - ref_pos;
  if ( color != COLOR_NONE )
    out_tagoff(color);
  return 0;
}
ApplicationHelpers::Verbose::Verbose(bool showState) 
{ 
  showState_ = showState; 
  if (showState)
    putLine("  Verbose mode turned on");
}
Exemplo n.º 17
0
//----------------------------------------------------------------------
bool checkLine(size_t size)
{
  return((maxpos - curpos > outcnt + size) || putLine());
}
bool ClientConnection::update()
{
  try
  {
    std::string line = getLine();

    //Requesting nickname.
    if (line.substr(0, strlen("CANIHAZNICKNAMES? ")) == "CANIHAZNICKNAMES? ")
    {
      std::string nickname = line.substr(strlen("CANIHAZNICKNAMES? "));
      //Must be greater than 0 characters and contain no space.
      if (nickname.size() > 0 && nickname.find(' ') == std::string::npos)
      {
        //Must not already exist.
        bool already_exists = false;
        const std::list<ClientConnection*> clients = server.getClients();
        for (std::list<ClientConnection*>::const_iterator i = clients.begin();
             i != clients.end(); ++i)
        {
          if ((*i)->getNickname() == nickname)
          {
            already_exists = true;
            break;
          }
        }

        if (!already_exists)
        {
          std::string old_nick = this->nickname;
          this->nickname = nickname;
          putLine(std::string("UGOTZANICKNAMES ") + nickname);
          server.broadcastNickChange(this, old_nick, nickname);
        }
        else
          putLine("NOBECAUSENO");
      }
      else
        putLine("NOBECAUSENO");
    }
    //Quiting
    else if (line == "BYEBYE")
    {
      server.broadcastQuit(this);
      return false;
    }
    //Messaging entire server.
    else if (line.substr(0, strlen("TELLEVERYONEZ ")) == "TELLEVERYONEZ ")
    {
      std::string message = line.substr(strlen("TELLEVERYONEZ "));
      if (message.size() > 0)
        server.sendMessageToAll(this, message);
    }
    //Messaging individual user.
    else if (line.substr(0, strlen("TELLSOMEONEZ ")) == "TELLSOMEONEZ ")
    {
      std::string recipient_and_message = line.substr(strlen("TELLSOMEONEZ "));
      int break_char = recipient_and_message.find(' ');
      std::string recipient = recipient_and_message.substr(0, break_char);
      std::string message = recipient_and_message.substr(break_char + 1);
      if (recipient.size() > 0 && message.size() > 0)
        server.sendMessageTo(this, recipient, message);
    }
    //Shutdown server.
    else if (line.substr(0, strlen("STOPSTOPSTOP! ")) == "STOPSTOPSTOP! ")
    {
      std::string password = line.substr(strlen("STOPSTOPSTOP! "));
      if (password == "turtles")
      {
        server.halt();
      }
    }
  }
  catch (NetworkFailureException& e)
  {
    return false;
  }
  catch (NoLineException& e)
  {
  }
  return true;
}
Exemplo n.º 19
0
void doPMXpreamble(void)
{
  static Char clefcode[9] = "0123456";
  short i, j;
  Char clefs[256];
  Char STR1[256];
  Char STR2[256];
  Char STR3[58];
  short FORLIM;
  Char STR5[256];

  if (*composer_line != '\0')
    putLine(composer_line);
  if (*title_line != '\0') {
    sprintf(STR2, "\\mtxTitleLine{%s}", title_line);
    putLine(STR2);
  }
  putLine("---");
  if (instrumentNames() && !redefined[(long)indent])
    strcpy(fracindent, "0.12");
  fprintf(outfile, "%d", nstaves);
  fprintf(outfile, " %d", -ninstr);
  stave[ninstr] = nstaves + 1;
  for (j = ninstr; j >= 1; j--)
    fprintf(outfile, " %d", stave[j] - stave[j-1]);
  fprintf(outfile, " %s %8.5f %d %d %d %d %s\n",
	  pmxMeter(STR1), xmtrnum0, n_sharps, n_pages, n_systems, musicsize,
	  fracindent);
  FORLIM = ninstr;
  for (i = 1; i <= FORLIM; i++) {
    if (!instrumentNames())
      putLine("");
    else {
      sprintf(STR3, "\\mtxInstrName{%s}", instr_name[ninstr - i]);
      putLine(STR3);
    }
  }
  *clefs = '\0';
  for (i = nclefs - 1; i >= 0; i--)
    sprintf(clefs + strlen(clefs), "%c", clefcode[clefno(clef[i])]);
  putLine(clefs);
  if (*texdir == '\0')
    strcpy(texdir, "./");
  putLine(texdir);

  pmx_preamble_done = true;
  insertTeX();
  respace();

  FORLIM = ngroups;
  for (j = 1; j <= FORLIM; j++)
    fprintf(outfile, "\\\\mtxGroup{%s}{%s}{%s}\\\n",
	    toString(STR1, j), toString(STR2, ninstr - group_start[j-1] + 1),
	    toString(STR5, ninstr - group_stop[j-1] + 1));
  FORLIM = ninstr;
  for (j = 1; j <= FORLIM; j++) {
    if (stave_size[j-1] != unspec) {
      sprintf(STR5, "\\\\mtxSetSize{%s}{%s}\\",
	      toString(STR1, ninstr - j + 1),
	      sizecode(STR2, stave_size[j-1]));
      putLine(STR5);
    }
  }
  if (*part_line != '\0') {
    putLine("Ti");
    putLine(part_line);
  }
  if (*title_line != '\0') {
    putLine("Tt");
    putLine("\\mtxTitle");
  }
  if (*composer_line != '\0') {
    putLine("Tc");
    putLine("\\mtxPoetComposer");
  }
  if (*pmx_line != '\0')
    putLine(pmx_line);
  doTenorClefs();
  if (*cline[(long)width] != '\0')
    putLine(cline[(long)width]);
  wipeCommands();
}
Exemplo n.º 20
0
Static void musicParagraph(void)
{
  struct LOC_musicParagraph V;
  voice_index0 j, nvoice;
  Char lyrassign[256];
  Char STR1[256];
  Char STR2[256];
  Char STR3[256], STR4[256], STR5[256];
  voice_index0 FORLIM;
  short FORLIM1;

  paragraphSetup(&nvoice);
  if (nvoice == 0) {
    nonMusic();
    return;
  }
  if (nvoice > nvoices) {
    if (nvoice == 0)
      error("No voices! Did you remember to to supply a Style?", !print);
    sprintf(STR4, "Paragraph has %s voices but Style allows only %s",
	    toString(STR1, nvoice), toString(STR2, nvoices));
    error(STR4, !print);
    return;
  }
  if (first_paragraph)
    includeStartString();
  if (pmx_preamble_done && (!final_paragraph || nvoice > 0)) {
    sprintf(STR5, "%c Paragraph %s line %s bar %s",
	    comment, toString(STR1, paragraph_no),
	    toString(STR2, orig_line_no[0]), toString(STR3, bar_no));
    putLine(STR5);
  }
  testParagraph();
  rememberDurations();
  if (beVerbose())
    describeParagraph();
  /* ---- Knowing the score, we can start setting music ---------------- */
  if (!pmx_preamble_done) {
    doPMXpreamble();
    sprintf(STR3, "%c Paragraph %s line %s bar ",
	    comment, toString(STR1, paragraph_no),
	    toString(STR2, orig_line_no[0]));
    put(STR3, putspace);
    if (pickup > 0)
      putLine("0");
    else
      putLine("1");
  }
  putPMXlines(&V);
  if (must_restyle)
    restyle();
  if (some_vocal && (nvoice > 0 || !final_paragraph)) {
    FORLIM = ninstr;
    for (j = 1; j <= FORLIM; j++) {
      assignLyrics(j, lyrassign);
      if (*lyrassign != '\0') {
	sprintf(STR2, "\\\\%s\\", lyrassign);
	putLine(STR2);
      }
    }
  }
  if (must_respace)
    respace();
  if (meternum == 0)
    putMeter(meterChange(STR2, beatsPerLine(), meterdenom, true), &V);
  if (nleft > 0)
    nbars++;
  if (nbars == 0 && *multi_bar_rest != '\0')
    processMBR(&V);
  else {
    FORLIM1 = nbars;
    for (bar_of_line = 1; bar_of_line <= FORLIM1; bar_of_line++)
      processOneBar(&V);
  }
  restoreDurations();
}
Exemplo n.º 21
0
Local void putMeter(Char *new_meter_word, struct LOC_musicParagraph *LINK)
{
  if (strcmp(new_meter_word, old_meter_word))
    putLine(new_meter_word);
  strcpy(old_meter_word, new_meter_word);
}