int clip_STRFINDEOL(ClipMachine * ClipMachineMemory) { int i, sl; char *s = _clip_parcl(ClipMachineMemory, 1, &sl); int begpos = _clip_parni(ClipMachineMemory, 2); if (s == NULL) { _clip_retni(ClipMachineMemory, 0); return 0; } if (begpos < 1) begpos = 1; for (i = begpos - 1; i < sl; i++) { if (s[i] == '\n') { i++; break; } } _clip_retni(ClipMachineMemory, i + 1); return 0; }
int clip_STRFINDBOL(ClipMachine * ClipMachineMemory) { int i, sl; char *s = _clip_parcl(ClipMachineMemory, 1, &sl); int begpos = _clip_parni(ClipMachineMemory, 2); if (s == NULL) { _clip_retni(ClipMachineMemory, 0); return 0; } if (begpos < 1 || begpos > sl) begpos = sl + 1; begpos--; if (s[begpos] == '\n') begpos--; for (i = begpos; i >= 0; i--) { if (s[i] == '\n') { i++; break; } } _clip_retni(ClipMachineMemory, i + 1); return 0; }
int clip_COUNTRIGHT(ClipMachine * ClipMachineMemory) { int l1, l2, ret = 0; unsigned char *e; unsigned char *str = (unsigned char *) _clip_parcl(ClipMachineMemory, 1, &l1); unsigned char *s = (unsigned char *) _clip_parcl(ClipMachineMemory, 2, &l2); int ch = _clip_parni(ClipMachineMemory, 2); if (str == NULL || l1 == 0) { _clip_retni(ClipMachineMemory, 0); return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "COUNTRIGHT"); } if (s != NULL) ch = *s; if (ch == 0) ch = ' '; for (ret = 0, e = str + l1 - 1; e > str && *e == ch; e--, ret++); _clip_retni(ClipMachineMemory, ret); return 0; }
int clip_MLPOS(ClipMachine * ClipMachineMemory) { int vl = 0, i, j, len, nstr, ntab, npos = 1, wrap; char *e, *wrappos = NULL; char *vp = _clip_parcl(ClipMachineMemory, 1, &vl); if (vp == NULL) { _clip_retni(ClipMachineMemory, 0); return _clip_trap_err(ClipMachineMemory, EG_ARG, 0, 0, __FILE__, __LINE__, "MLPOS"); } len = _clip_parni(ClipMachineMemory, 2); if (len <= 4) len = 79; nstr = _clip_parni(ClipMachineMemory, 3); if (nstr <= 1) nstr = 1; ntab = _clip_parni(ClipMachineMemory, 4); if (ntab < 1) ntab = 1; if (ntab >= len) ntab = len - 1; if (_clip_parinfo(ClipMachineMemory, 5) == LOGICAL_type_of_ClipVarType) wrap = _clip_parl(ClipMachineMemory, 5); else wrap = 1; for (i = 1, j = 1, e = vp; e < vp + vl; e++, j++) { if (*e == ' ') wrappos = e; if (j >= len || *e == '\n') { if (wrap && wrappos != NULL && e < vp + vl - 1 && *e != '\n') { if (*(e + 1) == ' ') e++; else e = wrappos; } i++; j = 0; } if (*e == '\t') j += ntab - 1; if (*e == '\r') j--; if (i >= nstr && j >= npos) break; } _clip_retni(ClipMachineMemory, e - vp + 1); return 0; }
int clip_SETFATTR(ClipMachine * ClipMachineMemory) /* Sets a file's attributes */ { /* ������������ ��������: ~~~~~~~~~~~~~~~~~~~~~~ 0 NO_DISK_ERR No error found -2 ER_FILE_NOT_FOUND File not found -3 ER_PATH_NOT_FOUND Path not found -5 ER_ACCESS_DENIED Access denied (e.g., in network) ��������������� ��������: ~~~~~~~~~~~~~~~~~~~~~~~~~ 0 FA_NORMAL 1 FA_READONLY READ ONLY (Read-only) 2 FA_HIDDEN HIDDEN (Hidden files) 4 FA_SYSTEM SYSTEM (System files) 32 FA_ARCHIVE ARCHIVE (Changes since last backup) */ char *uname = _get_unix_name(ClipMachineMemory, _clip_parc(ClipMachineMemory, 1)); int fattr = _clip_parni(ClipMachineMemory, 2); mode_t mode = 0; if (uname == NULL) { _clip_retni(ClipMachineMemory, ER_PATH_NOT_FOUND); return 1; } #ifdef OS_MINGW mode = S_IRUSR; #else mode = S_IRUSR | S_IRGRP | S_IROTH; #endif if (!(fattr & FA_READONLY)) { #ifdef OS_MINGW mode = S_IWUSR; #else mode |= S_IWUSR | S_IWGRP | S_IWOTH; #endif } if (chmod(uname, mode) != 0) { _check_error(ClipMachineMemory, uname, 0); /* fail */ } else { _clip_retni(ClipMachineMemory, NO_DISK_ERR); /* success */ } free(uname); return 0; }
int clip_MLCOUNT(ClipMachine * ClipMachineMemory) { int vl = 0, i, j, len, ntab, wrap; char *e, *wrappos = NULL; char *vp = _clip_parcl(ClipMachineMemory, 1, &vl); if (vp == NULL) { _clip_retni(ClipMachineMemory, 0); return 0; } len = _clip_parni(ClipMachineMemory, 2); if (len <= 4) len = 79; ntab = _clip_parni(ClipMachineMemory, 3); if (ntab < 1) ntab = 1; if (ntab >= len) ntab = len - 1; if (_clip_parinfo(ClipMachineMemory, 5) == LOGICAL_type_of_ClipVarType) wrap = _clip_parl(ClipMachineMemory, 5); else wrap = 1; for (i = 0, j = 1, e = vp; e < vp + vl; e++, j++) { if (*e == ' ') wrappos = e; if (j >= len || *e == '\n') { if (wrap && wrappos != NULL && e < vp + vl - 1 && *e != '\n') { if (*(e + 1) == ' ') e++; else { e = wrappos; wrappos = NULL; } } i++; j = 0; } if (*e == '\t') j += ntab - 1; if (*e == '\r') j--; } _clip_retni(ClipMachineMemory, i + (j > 1)); return 0; }
int clip_FCOUNT(ClipMachine * ClipMachineMemory) { DBWorkArea *wa = cur_area(ClipMachineMemory); _clip_retni(ClipMachineMemory, 0); if (!wa) return 0; _clip_retni(ClipMachineMemory, wa->rd->nfields); return 0; }
int clip_REFCOUNT(ClipMachine * ClipMachineMemory) { ClipVar *vp = _clip_par(ClipMachineMemory, 1); if (!vp) _clip_retni(ClipMachineMemory, 0); else _clip_retni(ClipMachineMemory, vp->ClipType_t_of_ClipVar.count_of_ClipType); return 0; }
int clip_HEADER(ClipMachine * ClipMachineMemory) { DBWorkArea *wa = cur_area(ClipMachineMemory); _clip_retni(ClipMachineMemory, 0); if (!wa) return 0; _clip_retni(ClipMachineMemory, wa->rd->hdrsize); return 0; }
int clip_RECSIZE(ClipMachine * ClipMachineMemory) { DBWorkArea *wa = cur_area(ClipMachineMemory); _clip_retni(ClipMachineMemory, 0); if (!wa) return 0; _clip_retni(ClipMachineMemory, wa->rd->recsize); return 0; }
/* Returns the X Font ID for the given font. */ int clip_GDK_FONTID(ClipMachine * cm) { C_object *cfont = _fetch_co_opt(cm); CHECKCOBJOPT(cfont,GDK_IS_FONT(cfont)); if (cfont) _clip_retni(cm,gdk_font_id(GDK_FONT(cfont->object))); else _clip_retni(cm,gdk_font_id(NULL)); return 0; err: return 1; }
int clip_SX_STEP(ClipMachine * ClipMachineMemory) { DBWorkArea *wa = cur_area(ClipMachineMemory); ClipMachineMemory->m6_error = 0; _clip_retni(ClipMachineMemory, 0); if (!wa) return 0; _clip_retni(ClipMachineMemory, wa->rd->os.nInterval); return 0; }
int clip_SX_FILEORDER(ClipMachine * ClipMachineMemory) { DBWorkArea *wa = cur_area(ClipMachineMemory); ClipMachineMemory->m6_error = 0; _clip_retni(ClipMachineMemory, 0); if (!wa) return 0; if (wa->rd->curord != -1) _clip_retni(ClipMachineMemory, wa->rd->orders[wa->rd->curord]->index->indexno + 1); return 0; }
int clip_M6_NEWFILTER(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "M6_NEWFILTER"; int type = _clip_parinfo(ClipMachineMemory, 1); DBWorkArea *wa = cur_area(ClipMachineMemory); RDD_FILTER *fp; int er; ClipMachineMemory->m6_error = 0; CHECKOPT2(1, NUMERIC_type_of_ClipVarType, CHARACTER_type_of_ClipVarType); if (!wa) { _clip_retni(ClipMachineMemory, -1); return 0; } if ((er = rdd_flushbuffer(ClipMachineMemory, wa->rd, __PROC__))) goto err; READLOCK; if (type == NUMERIC_type_of_ClipVarType || type == UNDEF_type_of_ClipVarType) { unsigned int len = _clip_parni(ClipMachineMemory, 1); if ((er = rdd_createuserfilter(ClipMachineMemory, wa->rd, &fp, len, __PROC__))) goto err_unlock; } else if (type == CHARACTER_type_of_ClipVarType) { char *str = _clip_parc(ClipMachineMemory, 1); if ((er = rdd_createfilter(ClipMachineMemory, wa->rd, &fp, NULL, str, NULL, 0, __PROC__))) goto err_unlock; } UNLOCK; _clip_retni(ClipMachineMemory, fp->handle); return 0; err_unlock: wa->rd->vtbl->_ulock(ClipMachineMemory, wa->rd, __PROC__); err: return er; }
int clip_M6_FILTCOPY(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "M6_FILTCOPY"; int h = _clip_parni(ClipMachineMemory, 1); RDD_FILTER *fp; RDD_FILTER *ret; int er; ClipMachineMemory->m6_error = 0; CHECKARG1(1, NUMERIC_type_of_ClipVarType); fp = (RDD_FILTER *) _clip_fetch_c_item(ClipMachineMemory, h, _C_ITEM_TYPE_RYO); if (!fp) { er = rdd_err(ClipMachineMemory, EG_ARG, 0, __FILE__, __LINE__, __PROC__, er_badfilter); goto err; } if ((er = rm_copyfilter(ClipMachineMemory, fp, &ret, __PROC__))) goto err; _clip_retni(ClipMachineMemory, ret->handle); return 0; err: return er; }
/****************************************************************************** * gtk_TreeStoreIterDepth(tree, path_string)-->gint depth ******************************************************************************/ int clip_GTK_TREESTOREITERDEPTH(ClipMachine * ClipMachineMemory) { C_object *cstree = _fetch_co_arg(ClipMachineMemory); gchar *path = _clip_parc(ClipMachineMemory, 2); GtkTreeIter iter; gint ret; CHECKARG2(1, MAP_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); CHECKCOBJ(cstree, GTK_IS_TREE_STORE(cstree->object)); CHECKARG(2, CHARACTER_type_of_ClipVarType); CHECKARG(3, CHARACTER_type_of_ClipVarType); gtk_tree_model_get_iter(GTK_TREE_MODEL(GTK_TREE_STORE(cstree->object)), &iter, gtk_tree_path_new_from_string(path)); ret = gtk_tree_store_iter_depth(GTK_TREE_STORE(cstree->object), &iter); _clip_retni(ClipMachineMemory, ret); return 0; err: return 1; }
void pg_newid(ClipMachine* mp,SQLSTMT* stmt){ char* oidstr = (char*)PQoidStatus(((PG_STMT*)stmt)->res); if(oidstr){ _clip_retni(mp,atoi(oidstr)); } }
int clip_SQLPREPARE(ClipMachine * ClipMachineMemory) { SQLCONN *conn = (SQLCONN *) _clip_fetch_c_item(ClipMachineMemory, _clip_parni(ClipMachineMemory, 1), _C_ITEM_TYPE_SQL); char *sql = _clip_parc(ClipMachineMemory, 2); int res; if (!conn) { _clip_trap_err(ClipMachineMemory, 0, 0, 0, subsys, ER_NOCONNECT, er_noconnect); return 1; } if (!sql) { _clip_trap_err(ClipMachineMemory, 0, 0, 0, subsys, ER_NOSQL, er_nosql); return 1; } if ((res = conn->vtbl->prepare(ClipMachineMemory, conn, sql)) == -1) return 1; _clip_retni(ClipMachineMemory, res); return 0; }
int clip_HS_REMOVE(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "HS_REMOVE"; int h = _clip_parni(ClipMachineMemory, 1); unsigned int rno = _clip_parni(ClipMachineMemory, 2); HIPER *hs; int er; CHECKARG1(1, NUMERIC_type_of_ClipVarType); CHECKARG1(2, NUMERIC_type_of_ClipVarType); hs = _clip_fetch_c_item(ClipMachineMemory, h, _C_ITEM_TYPE_HIPER); if (!hs) { er = rdd_err(ClipMachineMemory, EG_ARG, 0, __FILE__, __LINE__, __PROC__, er_badhiper); goto err; } if ((er = hs_remove(ClipMachineMemory, hs, rno, __PROC__))) goto err; _clip_retni(ClipMachineMemory, 1); return 0; err: return er; }
/* COM_TIMEOUT(<nComPort>,[<nTimeout]) --> nOldTimeout nTimeout in 1/10 sec */ int clip_COM_TIMEOUT(ClipMachine * mp) { v24_port_t *gz; int fd = _clip_parni(mp, 1); int to = _clip_parni(mp, 2); int oto; if (fd < 1 || fd > 32) return EG_ARG; fd = keys[fd]; gz = (v24_port_t *) _clip_fetch_c_item(mp, fd, _C_ITEM_TYPE_COMPORT); if (gz == NULL) { return EG_ARG; } oto = gz->TimeoutValue; if (mp->argc > 1) { v24SetTimeouts(gz, to); } _clip_retni(mp, oto); return 0; }
/* ************************************************************************* */ int pg_lo_seek(ClipMachine* mp, SQLCONN* c, int oid_fd, int offset, int whence){ PG_CONN *conn = (PG_CONN*)c; int rt; if(!conn->at){ _clip_trap_err(mp,0,0,0,subsys,ER_START,er_start); return 1; } switch(whence){ case SQLBLOB_SEEKTOP: whence = SEEK_SET; break; case SQLBLOB_SEEKCURRENT: whence = SEEK_CUR; break; case SQLBLOB_SEEKBOTTOM: whence = SEEK_END; break; default: _clip_trap_err(mp,0,0,0,subsys,ER_START,er_blob_seek); return 1; } rt = lo_lseek(conn->conn, oid_fd, offset, whence); if (rt < 0){ _clip_trap_err(mp,0,0,0,subsys,ER_START,er_blob_seek); return 1; } _clip_retni(mp,(unsigned int) rt); return 0; }
int clip_HS_DELETE(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "HS_DELETE"; int h = _clip_parni(ClipMachineMemory, 1); unsigned int rec = _clip_parni(ClipMachineMemory, 2); HIPER *hs; int er; CHECKARG1(1, NUMERIC_type_of_ClipVarType); CHECKARG1(2, NUMERIC_type_of_ClipVarType); hs = _clip_fetch_c_item(ClipMachineMemory, h, _C_ITEM_TYPE_HIPER); if (!hs) { er = rdd_err(ClipMachineMemory, EG_ARG, 0, __FILE__, __LINE__, __PROC__, er_badhiper); goto err; } _rm_setbit(hs->map, hs->lastrec, rec); _clip_retni(ClipMachineMemory, 1); return 0; err: return er; }
int clip_RDDGETAREAFILTER(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "RDDGETAREAFILTER"; RDD_DATA *rd = _fetch_rdd(ClipMachineMemory, __PROC__); if (!rd) return EG_NOTABLE; if (rd->filter) _clip_retni(ClipMachineMemory, rd->filter->handle); else _clip_retni(ClipMachineMemory, -1); return 0; }
void ms_newid(ClipMachine * mp, SQLSTMT * stmt) { int id = (int) mysql_insert_id(((MS_STMT *) stmt)->conn->conn); _clip_retni(mp, id); }
int clip_TASKVERSION(ClipMachine *mp) { #ifdef USE_TASKS _clip_retni(mp, Task_version()); #endif return 0; }
int clip_SX_VSIGLEN(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "SX_VSIGLEN"; DBWorkArea *wa = cur_area(ClipMachineMemory); int t = _clip_parinfo(ClipMachineMemory, 1); int fno = -1, er; ClipMachineMemory->m6_error = 0; CHECKARG2(1, CHARACTER_type_of_ClipVarType, NUMERIC_type_of_ClipVarType); _clip_retni(ClipMachineMemory, 0); if (!wa) return 0; if (t == CHARACTER_type_of_ClipVarType) { char *fname = _clip_parc(ClipMachineMemory, 1); if (fname) fno = _rdd_fieldno(wa->rd, _clip_casehashword(fname, strlen(fname))); } else { fno = _clip_parni(ClipMachineMemory, 1) - 1; } if (fno < 0 || fno >= wa->rd->nfields) return 0; if (wa->rd->fields[fno].type == 'V' && wa->rd->fields[fno].len != 3 && wa->rd->fields[fno].len != 4) { _clip_retni(ClipMachineMemory, max(wa->rd->fields[fno].len - 6, 0)); } else { _clip_retni(ClipMachineMemory, wa->rd->fields[fno].len); } return 0; err: return er; }
/* Converts a key name to a key value. */ int clip_GDK_KEYVALFROMNAME(ClipMachine * ClipMachineMemory) { gchar *keyval_name = CHAR_OPTION(ClipMachineMemory, 1, ""); _clip_retni(ClipMachineMemory, gdk_keyval_from_name(keyval_name)); return 0; }
int clip_GETSHARE(ClipMachine * ClipMachineMemory) /* Determines the file open (share) mode */ { int *smode = _clip_fetch_item(ClipMachineMemory, CLIP_CA_SHARE_MODE); _clip_retni(ClipMachineMemory, smode ? *smode : LOCK_RDONLY); return 0; }
int clip_GTK_ACCELERATORGETDEFAULTMODMASK(ClipMachine * ClipMachineMemory) { _clip_retni(ClipMachineMemory, (int) gtk_accelerator_get_default_mod_mask()); return 0; //err: // return 1; }
int clip_GETAREA(ClipMachine * ClipMachineMemory) { const char *__PROC__ = "GETAREA"; const char *fname = _clip_parc(ClipMachineMemory, 1); const char *driver = _clip_parc(ClipMachineMemory, 2); RDD_DATA_VTBL *vtbl; char *path = NULL; DBWorkArea *wa; int i, er = EG_UNSUPPORTED; CHECKARG1(1, CHARACTER_type_of_ClipVarType); CHECKOPT1(2, CHARACTER_type_of_ClipVarType); _clip_retni(ClipMachineMemory, 0); if (!(vtbl = rdd_datadriver(ClipMachineMemory, driver, __PROC__))) goto err; if ((er = _rdd_parsepath(ClipMachineMemory, fname, vtbl->suff, &path, NULL, EG_OPEN, __PROC__))) goto err; for (i = 0; i < ClipMachineMemory->areas->count_of_ClipVect; i++) { wa = ClipMachineMemory->areas->items_of_ClipVect[i]; if (!wa || !wa->used) continue; if (strcmp(wa->rd->path, path) == 0) { _clip_retni(ClipMachineMemory, i + 1); break; } } free(path); return 0; err: if (path) free(path); return er; }