Пример #1
0
static int loadnpanxx (char *file) {
    Sfio_t *fp;
    char *s, *line, *avs[10];

    SUmessage (1, "loadnpanxx", "loading file %s", file);
    if (!(fp = sfopen (NULL, file, "r"))) {
        SUwarning (1, "loadnpanxx", "open failed for file %s", file);
        return -1;
    }
    while ((line = sfgetr (fp, '\n', 1))) {
        if (line[strlen (line) - 1] == '\r')
            line[strlen (line) - 1] = 0;
        if (tokscan (
            line, &s, "%s:%s:%s:%s\n", &avs[0], &avs[1], &avs[2], &avs[3]
        ) != 4) {
            SUwarning (1, "loadnpanxx", "bad line in file %s, %s", file, line);
            continue;
        }
        if (additem (avs[0], avs[1], avs[2], avs[3]) == -1) {
            SUwarning (1, "loadnpanxx", "additem failed");
            return -1;
        }
    }
    sfclose (fp);
    return 0;
}
Пример #2
0
int moveitem(char *path,int num)
{
        if(inititem(path))
                return 1;
        if(num<=0)
                num=1;
        if(num>=total)
                num=total;
        if(num==index_infile[0]) {
                printf("顺序一样,没有移动");
                return 1;
        }



        char fpath[PATHLEN];
        sprintf(fpath,"%s/.Names",path);
        FILE *fp=fopen(fpath,"w+");
        if(fp==0)
                return 1;
        addtitle(fp,title);
        int j=0;
        int i;
        if(index_infile[0]<num)//后移
                for(i=0;i<total;i++) {
                        if(i==(index_infile[0]-1))
                                continue;
                        additem(fp,a[i].title,a[i].path,++j);
                        if((i+1)==num)
                                additem(fp,a[index_infile[0]-1].title,a[index_infile[0]-1].path,++j);

                }
        else//前移
                for(i=0;i<total;i++) {
                        if(i==(index_infile[0]-1))
                                continue;
                        if((i+1)==num)
                                additem(fp,a[index_infile[0]-1].title,a[index_infile[0]-1].path,++j);
                        additem(fp,a[i].title,a[i].path,++j);
                }
        fclose(fp);
        return 0;
}
Пример #3
0
static int def_handle_credfork(struct provmsg *msg, void *arg)
{
	struct provmsg_credfork *m = (struct provmsg_credfork *) msg;
	struct args *args = (struct args *) arg;
	if (!want_cred(args, msg->cred_id))
		return 0;
	if (args->creds && args->recurse >= 1)
		additem(&args->extracreds, m->forked_cred);
	return 0;
}
Пример #4
0
void pickup(int n, game::dynent *d) {
  int np = 1;
  loopv(players) if (players[i]) np++;
  np = np<3 ? 4 : (np>4 ? 2 : 3);         // spawn times are dependent on number of players
  int ammo = np*2;
  switch (ents[n].type) {
    case I_SHELLS:  additem(n, d->ammo[1], ammo); break;
    case I_BULLETS: additem(n, d->ammo[2], ammo); break;
    case I_ROCKETS: additem(n, d->ammo[3], ammo); break;
    case I_ROUNDS:  additem(n, d->ammo[4], ammo); break;
    case I_HEALTH:  additem(n, d->health,  np*5); break;
    case I_BOOST:   additem(n, d->health,  60);   break;
    case I_GREENARMOUR:
      // (100h/100g only absorbs 166 damage)
      if (d->armourtype==A_YELLOW && d->armour>66) break;
      additem(n, d->armour, 20);
    break;
    case I_YELLOWARMOUR:
      additem(n, d->armour, 20);
    break;
    case I_QUAD:
      additem(n, d->quadmillis, 60);
    break;
    case CARROT:
      ents[n].spawned = false;
      triggertime = int(lastmillis());
      // TODO world::trigger(ents[n].attr1, ents[n].attr2, false);  // needs to go over server for client::multiplayer
    break;
    case TELEPORT: {
      static int lastteleport = 0;
      if (lastmillis()-lastteleport<500) break;
      lastteleport = int(lastmillis());
      teleport(n, d);
    }
    break;
    case JUMPPAD: {
      static int lastjumppad = 0;
      if (lastmillis()-lastjumppad<300) break;
      lastjumppad = int(lastmillis());
      vec3f v((int)(char)ents[n].attr3/10.0f, (int)(char)ents[n].attr2/10.0f, ents[n].attr1/10.0f);
      player1->vel.z = 0;
      player1->vel += v;
      sound::playc(sound::JUMPPAD);
    }
    break;
  }
}
Пример #5
0
/* Try to overwhelm the CPU with computation requests */
void
run_stress_test(pthread_workqueue_t wq, int rounds)
{
	int i = 0;
	work_cnt = rounds;
    for (i = 0; i < rounds; i++) {
        additem(wq, compute, &work_cnt);
    }
	while (work_cnt > 0)
		sleep(1);
}
Пример #6
0
void
run_blocking_test(pthread_workqueue_t wq, int rounds)
{
	long i = 0;
	work_cnt = rounds;
    for (i = 0; i < rounds; i++) {
        additem(wq, lazy, (void *) i);
    }
	while (work_cnt > 0)
		sleep(1);
}
Пример #7
0
int	toggle(int sel)
{
	int	which;

	if ((which=isselected(sel+1))!=0)
	{
		if (which<=defaultmodule)
			defaultmodule--;
		return removeitem(which-1);
	}
	else
		return additem(sel+1);
}
Пример #8
0
int Runadditem(void *arg,int x1,int y1,int l,int h) {
/*************************************************

    Selectmenu1  1 data value

*************************************************/
   int   v0 = 1;
   void* v[1];
   int Pxl,Pyl;
   Parent = (DIALOG *)arg;
   xo = x1;
   yo=y1;
   xl = l;
   yl = h;
   v[0]=(void *)(&v0);
   void *pt=NULL; /* pointer to send any extra information */
   Pxl = Parent->xl;
   Pyl = Parent->yl;
   if( (Pxl < 150)||(Pyl<220)) additem(NULL,v,pt);
   else additem(arg,v,pt );
   return Exit;
}
Пример #9
0
void
run_cond_wait_test(pthread_workqueue_t wq)
{
	const int rounds = 10;
	long i = 0;

	sleep(3);	/* Allow time for the workers to enter pthread_cond_wait() */
	work_cnt = rounds;
    for (i = 0; i < rounds; i++) {
        additem(wq, lazy, (void *) i);
		sleep(1);
    }
	while (work_cnt > 0)
		sleep(1);
}
Пример #10
0
 bool insert(ElemType elem, CountType count)
 {
     if(gps_.find(elem) != gps_.end())
     {
         return update(elem, count);
     }
     else if(size_ >= MAXSIZE_ && count <= th_)
         return true;
     else if(size_ >= MAXSIZE_)
     {
         return replace(elem, count);
     }
     else
     {
         return additem(elem, count);
     }
 }
Пример #11
0
void TFileList::scandir ()
{
  char olddir[256];
  DIR *d;
  clearlist ();
  my_getcwd (olddir, 255);
  chdir (path);
  d = opendir (path);
  if (d) {
    struct dirent *ent;
    rewinddir (d);
    while ((ent=readdir(d))!=NULL)
      if (passFilt (ent->d_name))
	additem (ent->d_name);
    closedir (d);
  }
  chdir (olddir);
}
Пример #12
0
/*
 * Ensure that the library is reinitialized after fork(2) is called.
 */
void
run_fork_test(pthread_workqueue_t wq)
{
#if !defined(_WIN32)
    pid_t pid;
    int   rv, status, timeout;

    puts("fork test... ");
    pid = fork();
    if (pid < 0) 
        err(1, "fork");

    if (pid == 0) {
        /* Child */
        wq = NULL;
        rv = pthread_workqueue_create_np(&wq, NULL);
        if (rv < 0)
            errx(1, "pthread_workqueue_create_np");
        work_cnt = 1;
        timeout = 5;
        additem(wq, compute, &work_cnt);
        while (work_cnt > 0) {
            sleep(1);
            if (--timeout == 0)
                errx(1, "work was not completed");
        }
        exit(0);
    } else {
        /* Parent */
        if (wait(&status) != pid) 
            err(1, "waitpid");
        if (WEXITSTATUS(status) != 0) 
            errx(1, "fork test failed");
        puts("ok\n");
    }
#else
    puts("fork test... N/A\n");
#endif
}
Пример #13
0
/* store a record */
int dbm_store(DBM *db, datum key, datum dat, int replace){
  int i;
  datum item, item1;
  char ovfbuf[PBLKSIZ];
  if(dbm_error(db))
    return (-1);
  if(dbm_rdonly(db)){
    errno = EPERM;
    return (-1);
  }
 loop:
  dbm_access(db, dcalchash(key));
  if((i = finddatum(db->dbm_pagbuf, key)) >= 0){
    if(!replace)
      return (1);
    if(!delitem(db->dbm_pagbuf, i)){
      db->dbm_flags |= _DBM_IOERR;
      return (-1);
    }
  }
  if(!additem(db->dbm_pagbuf, key, dat))
    goto split;
  db->dbm_pagbno = db->dbm_blkno;
  (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, SEEK_SET);
  if(write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    return (-1);
  }
  return (0);
 split:
  if(key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    errno = ENOSPC;
    return (-1);
  }
  memset(ovfbuf, 0, PBLKSIZ);
  for(i=0;;){
    item = makdatum(db->dbm_pagbuf, i);
    if(item.dptr == NULL)
      break;
    if(dcalchash(item) & (db->dbm_hmask+1)){
      item1 = makdatum(db->dbm_pagbuf, i+1);
      if(item1.dptr == NULL){
        db->dbm_flags |= _DBM_IOERR;
        break;
      }
      if(!additem(ovfbuf, item, item1) ||
         !delitem(db->dbm_pagbuf, i)){
        db->dbm_flags |= _DBM_IOERR;
        return (-1);
      }
      continue;
    }
    i += 2;
  }
  db->dbm_pagbno = db->dbm_blkno;
  (void) lseek(db->dbm_pagf, db->dbm_blkno*PBLKSIZ, SEEK_SET);
  if(write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    return (-1);
  }
  (void) lseek(db->dbm_pagf, (db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ, SEEK_SET);
  if(write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ){
    db->dbm_flags |= _DBM_IOERR;
    return (-1);
  }
  setbit(db);
  goto loop;
}
Пример #14
0
void
Menu::additem(MenuItemKind kind_, const std::string& text_, int toggle_, Menu* menu_, int id, int* int_p)
{
  additem(MenuItem::create(kind_, text_.c_str(), toggle_, menu_, id, int_p));
}
Пример #15
0
charset *parsecharset(const char *str, errmsg_t errmsg)
{
  charset *cset = NULL;
  buffer *cbuf = NULL;
  const wchar_t *p, * const singleescapes = L"_sbqQx";
  int hex1, hex2;
  wchar_t ch;
  wchar_t *wstr;
      
  wstr = (wchar_t *) malloc((strlen(str) + 1) * sizeof(wchar_t));
  if (!wstr) {
    wcscpy(errmsg,outofmem);
    goto pcserror;
  }
  if ((size_t)(-1) == mbstowcs(wstr, str, strlen(str) + 1)) {
    wcscpy(errmsg,mbserror);
    goto pcserror;
  }
  cset = malloc(sizeof (charset));
  if (!cset) {
    wcscpy(errmsg,outofmem);
    goto pcserror;
  }
  cset->inlist = cset->outlist = NULL;
  cset->flags = 0;

  cbuf = newbuffer(sizeof (wchar_t), errmsg);
  if (*errmsg) goto pcserror;

  for (p = wstr;  *p;  ++p)
    if (*p == L'_') {
      ++p;
      if (appearsin(*p, singleescapes)) {
        if      (*p == L'_') ch = L'_' ;
        else if (*p == L's') ch = L' ' ;
        else if (*p == L'b') ch = L'\\';
        else if (*p == L'q') ch = L'\'';
        else if (*p == L'Q') ch = L'\"';
        else /*  *p == 'x'  */ {
          /* FIXME _x metacharacter should allow wide characters input.*/
          hex1 = hexdigtoint(p[1]);
          hex2 = hexdigtoint(p[2]);
          if (hex1 < 0  ||  hex2 < 0) goto pcsbadstr;
          ch = 16 * hex1 + hex2;
          p += 2;
        }
        if (!ch)
          cset->flags |= CS_NUL;
        else {
          additem(cbuf, &ch, errmsg);
          if (*errmsg) goto pcserror;
        }
      }
      else {
        if      (*p == L'A') cset->flags |= CS_UCASE;
        else if (*p == L'a') cset->flags |= CS_LCASE;
        else if (*p == L'0') cset->flags |= CS_DIGIT;
        else goto pcsbadstr;
      }
    }
    else {
      additem(cbuf, p,errmsg);
      if (*errmsg) goto pcserror;
    }
  ch = '\0';
  additem(cbuf, &ch, errmsg);
  if (*errmsg) goto pcserror;
  cset->inlist = copyitems(cbuf,errmsg);
  if (*errmsg) goto pcserror;

pcscleanup:

  if (cbuf) freebuffer(cbuf);
  if (wstr) free(wstr);
  return cset;

pcsbadstr:

  swprintf(errmsg, errmsg_size, L"Bad charset syntax: %.*s\n", errmsg_size - 22, str);

pcserror:

  if (cset) freecharset(cset);
  cset = NULL;
  goto pcscleanup;
}
Пример #16
0
static charset *csud(
  int u, const charset *cset1, const charset *cset2, errmsg_t errmsg
)
/* Returns the union of cset1 and cset2 if u is 1, or the set    */
/* difference cset1 - cset2 if u is 0.  Returns NULL on failure. */
{
  charset *csu;
  buffer *inbuf = NULL, *outbuf = NULL;
  wchar_t *lists[4], **list, *p, nullchar = L'\0';

  csu = malloc(sizeof (charset));
  if (!csu) {
    wcscpy(errmsg,outofmem);
    goto csuderror;
  }
  inbuf = newbuffer(sizeof (wchar_t), errmsg);
  if (*errmsg) goto csuderror;
  outbuf = newbuffer(sizeof (wchar_t), errmsg);
  if (*errmsg) goto csuderror;
  csu->inlist = csu->outlist = NULL;
  csu->flags =  u  ?  cset1->flags |  cset2->flags
                   :  cset1->flags & ~cset2->flags;

  lists[0] = cset1->inlist;
  lists[1] = cset1->outlist;
  lists[2] = cset2->inlist;
  lists[3] = cset2->outlist;

  for (list = lists;  list < lists + 4;  ++list)
    if (*list) {
      for (p = *list;  *p;  ++p)
        if (u  ?  csmember(*p, cset1) ||  csmember(*p, cset2)
               :  csmember(*p, cset1) && !csmember(*p, cset2)) {
          if (!csmember(*p, csu)) {
            additem(inbuf,p,errmsg);
            if (*errmsg) goto csuderror;
          }
        }
        else
          if (csmember(*p, csu)) {
            additem(outbuf,p,errmsg);
            if (*errmsg) goto csuderror;
          }
    }

  additem(inbuf, &nullchar, errmsg);
  if (*errmsg) goto csuderror;
  additem(outbuf, &nullchar, errmsg);
  if (*errmsg) goto csuderror;
  csu->inlist = copyitems(inbuf,errmsg);
  if (*errmsg) goto csuderror;
  csu->outlist = copyitems(outbuf,errmsg);
  if (*errmsg) goto csuderror;

csudcleanup:

  if (inbuf) freebuffer(inbuf);
  if (outbuf) freebuffer(outbuf);
  return csu;

csuderror:

  if (csu) freecharset(csu);
  csu = NULL;
  goto csudcleanup;
}
Пример #17
0
Exec_stat MCSort::sort_container(MCExecPoint &p_exec_point, Chunk_term p_type, Sort_type p_direction, Sort_type p_form, MCExpression *p_by)
{
	MCSortnode *t_items;
	uint4 t_item_count;
	t_item_count = 0;

	// If sorting items of the container, then we use the current itemDelimiter to split each item,
	// all other forms of search default to the lineDelimiter for now. Note that this is a slight
	// change of behavior as previously sorting containers by line ignored the lineDelimiter and
	// always delimited by ascii 10.
	char t_delimiter;
	if (p_type == CT_ITEM)
		t_delimiter = p_exec_point . getitemdel();
	else
		t_delimiter = p_exec_point . getlinedel();

	if (t_delimiter == '\0')
		return ES_NORMAL;

	// Calculate the number of items we need to sort, store this in t_item_count.
	uint4 t_item_size;
	t_item_size = p_exec_point . getsvalue() . getlength();

	char *t_item_text;
	t_item_text = p_exec_point . getsvalue() . clone();

	char *t_string_pointer;
	t_string_pointer = t_item_text;

	char *t_end_pointer;
	bool t_trailing_delim = false;
	while ((t_end_pointer = strchr(t_string_pointer, t_delimiter)) != NULL)
	{
		// knock out last delim for lines with a trailing return char
		if (p_type != CT_ITEM && t_end_pointer[1] == '\0')
		{
			t_end_pointer[0] = '\0';
			t_trailing_delim = true;
		}
		else
			t_item_count++;
		t_string_pointer = t_end_pointer + 1;
	}

	// OK-2008-12-11: [[Bug 7503]] - If there are 0 items in the string, don't carry out the search,
	// this keeps the behavior consistent with previous versions of Revolution.
	if (t_item_count < 1)
	{
		delete t_item_text;
		return ES_NORMAL;
	}

	// Now we know the item count, we can allocate an array of MCSortnodes to store them.
	t_items = new MCSortnode[t_item_count + 1];
	t_item_count = 0;
	t_string_pointer = t_item_text;

	// Next, populate the MCSortnodes with all the items to be sorted
	MCString t_string;
	do
	{
		if ((t_end_pointer = strchr(t_string_pointer, t_delimiter)) != NULL)
		{
			*t_end_pointer++ = '\0';
			t_string . set(t_string_pointer, t_end_pointer - t_string_pointer - 1);
		}
		else
			t_string . set(t_string_pointer, strlen(t_string_pointer));

		MCExecPoint t_exec_point2(p_exec_point);
		additem(t_exec_point2, t_items, t_item_count, p_form, t_string, p_by);

		t_items[t_item_count - 1] . data = (void *)t_string_pointer;
		t_string_pointer = t_end_pointer;
	}
	while (t_end_pointer != NULL);

	// Sort the array
	MCU_sort(t_items, t_item_count, p_direction, p_form);

	// Build the output string
	char *t_output;
	t_output = new char[t_item_size + 1];
	*t_output = '\0';
	
	uint4 t_length;
	t_length = 0;

	for (unsigned int i = 0; i < t_item_count; i++)
	{
		uint4 t_item_length;
		t_item_length = strlen((const char *)t_items[i] . data);
		strncpy(&t_output[t_length], (const char *)t_items[i] . data, t_item_length);
		t_length = t_length + t_item_length;

		if ((p_form == ST_INTERNATIONAL || p_form == ST_TEXT) && (!p_exec_point . getcasesensitive() || p_by != NULL))
			delete t_items[i] . svalue;

		if (t_trailing_delim || i < t_item_count - 1)
			t_output[t_length++] = t_delimiter;
	}
	t_output[t_length] = '\0';

	p_exec_point . grabbuffer(t_output, t_length);

	delete t_item_text;
	delete t_items;
	return ES_NORMAL;
}
Пример #18
0
int
dbm_store(DBM *db, datum key, datum dat, int replace)
{
	int i;
	datum item, item1;
	char ovfbuf[PBLKSIZ];

	if (dbm_error(db))
		return (-1);
	if (dbm_rdonly(db)) {
		errno = EPERM;
		return (-1);
	}
loop:
	dbm_access(db, dcalchash(key));
	if ((i = finddatum(db->dbm_pagbuf, key)) >= 0) {
		if (!replace)
			return (1);
		if (!delitem(db->dbm_pagbuf, i)) {
			db->dbm_flags |= _DBM_IOERR;
			return (-1);
		}
	}
	if (!additem(db->dbm_pagbuf, key, dat))
		goto split;
	db->dbm_pagbno = db->dbm_blkno;
	if (dbm_defwrite(db)) {
		dbm_setdirty(db);
	}
	else {

		(void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
		if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
			db->dbm_flags |= _DBM_IOERR;
			return (-1);
		}
	}
	return (0);

split:
	if (key.dsize+dat.dsize+3*sizeof(short) >= PBLKSIZ) {
		db->dbm_flags |= _DBM_IOERR;
		errno = ENOSPC;
		return (-1);
	}
	bzero(ovfbuf, PBLKSIZ);
	for (i=0;;) {
		item = makdatum(db->dbm_pagbuf, i);
		if (item.dptr == NULL)
			break;
		if (dcalchash(item) & (db->dbm_hmask+1)) {
			item1 = makdatum(db->dbm_pagbuf, i+1);
			if (item1.dptr == NULL) {
				/*(void) fprintf(stderr, "ndbm: split not paired\n");*/
				db->dbm_flags |= _DBM_IOERR;
				break;
			}
			if (!additem(ovfbuf, item, item1) ||
			    !delitem(db->dbm_pagbuf, i)) {
				db->dbm_flags |= _DBM_IOERR;
				return (-1);
			}
			continue;
		}
		i += 2;
	}
	db->dbm_pagbno = db->dbm_blkno;
	(void) lseek(db->dbm_pagf, (long)(db->dbm_blkno*PBLKSIZ), L_SET);
	if (write(db->dbm_pagf, db->dbm_pagbuf, PBLKSIZ) != PBLKSIZ) {
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	dbm_clrdirty(db); /*clear dirty*/
	(void) lseek(db->dbm_pagf, 
		(long)((db->dbm_blkno+db->dbm_hmask+1)*PBLKSIZ), L_SET);
	if (write(db->dbm_pagf, ovfbuf, PBLKSIZ) != PBLKSIZ) {
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	if (setbit(db) < 0) {
		db->dbm_flags |= _DBM_IOERR;
		return (-1);
	}
	goto loop;
}
Пример #19
0
int main(void)
{
  additem(NULL);
  return 0;
}
Пример #20
0
void makeoptions()
{
	showmouse();

	createwindows(0,5,5,150,75,0,4,"BrUsH CoLoR");
	createlist(0,0,15,25);
	additem(0,0,"Black");
	additem(0,0,"Blue");
	additem(0,0,"Green");
	additem(0,0,"Cyan");
	additem(0,0,"Red");
	additem(0,0,"Magenta");
	additem(0,0,"Brown");
	additem(0,0,"Lt. Gray");
	additem(0,0,"Gray");
	additem(0,0,"Lt. Blue");
	additem(0,0,"Lt. Green");
	additem(0,0,"Lt. Cyan");
	additem(0,0,"Pink");
	additem(0,0,"Lt. Magenta");
	additem(0,0,"Yellow");
	additem(0,0,"White");
	additem(0,0,"Transparent");

	createwindows(1,5,80,175,220,0,4,"BrUsH aTTrIbUtEs");
	createlist(1,0,15,115);
	createlist(1,1,15,185);

	createlabel(1,0,15,100,125,112,4);
	createlabel(1,1,15,170,125,182,4);

	changelabel(1,0,"Brush Type");
	changelabel(1,1,"Brush Width");

	additem(1,0,"Freehand");
	additem(1,0,"Flood Fill");
	additem(1,0,"Line");
	additem(1,0,"Rectangle");

	//additem(1,0,"Circle");
	//additem(1,0,"Filled Circle");

	//additem(1,0,"Filled Rectangle");

	additem(1,1,"1");
	additem(1,1,"2");
	additem(1,1,"3");
	additem(1,1,"4");
	additem(1,1,"5");

	createwindows(2,5,225,290,375,0,4,"FiLe oPtIoNs");
	createtext(2,0,20,265,280,285);
	createlabel(2,0,20,250,170,262,5);
	changelabel(2,0,"Filename:");
	createbutton(2,0,20,290,90,330,3,"Save");
	createbutton(2,1,100,290,170,330,3,"Load");
	createbutton(2,2,20,340,170,360,4,"Quit");

	createwindows(3,300,10,610,400,0,4,"DrAwInG gRiD");
	createbutton(3,0,310,375,410,397,5,"Clear Grid");
	cleargrid();


}
Пример #21
0
void sales()
{	
	system("cls");
	fclose(fsal);
	fclose(fsaldel);	
	fclose(fi1);
	FlushConsoleInputBuffer(GetStdHandle(STD_INPUT_HANDLE)); 
	printBorders(95,31);
	system("color 8f");
	gtc(40,2); printf("S  A  L  E  S"); 			
	printBox(3,4,35,25);
	printsales();
	printBox(42,11,50,8);
	printBox(42,22,50,7);
	printBox(42,4,50,4); gtc(47,6); printf("Add Items"); gtc(60,6); printf("Void Items"); gtc(73,6); printf("Checkout"); gtc(86,6); printf("Exit");
	gtc(53,14);printf("Choose from the options above.");
	gtc(45,6); printf("\xb10");
	int a,b=45;
	while(getch()!=13) //THIS PART OMG.
	{		
		a=getch();

		if (a==0 || a==0xE0) a=getch();
		
		if (a==27) 
			{
			break;
			}
		else if (a==75)
		{
			if(b!=45)
			{
				gtc(b,6);
				printf(" ");
				b-=13;
				gtc(b,6);
				printf("\xb10");
			}
		}
		else if (a==77)
			{
				if(b!=84)
				{
					gtc(b,6);
					printf(" ");
					b+=13;
					gtc(b,6);
					printf("\xb10");
				}

			}		
	}
	switch(b)
	{
		case 45:
			gtc(53,14);printf("                                  ");
			additem();
			break;
		case 58:
			gtc(53,14);printf("                                  ");
			voiditem();
			break;
		case 71:
			gtc(53,14);printf("                                  ");
			checkout();
			break;
		case 84:
			menu();
			exit(0);
			break;
	}
	getch();
	
	
}