comparison src/dmres.c @ 2261:e286454d305f

Cosmetics.
author Matti Hamalainen <ccr@tnsp.org>
date Mon, 17 Jun 2019 00:55:07 +0300
parents 972d56ad2b78
children f92d4f056587
comparison
equal deleted inserted replaced
2260:972d56ad2b78 2261:e286454d305f
920 return DMERR_OK; 920 return DMERR_OK;
921 921
922 return fh->fops->freset(fh); 922 return fh->fops->freset(fh);
923 } 923 }
924 924
925
925 int dmferror(DMResource *fh) 926 int dmferror(DMResource *fh)
926 { 927 {
927 fh->atime = time(NULL); 928 fh->atime = time(NULL);
928 return fh->fops->ferror(fh); 929 return fh->fops->ferror(fh);
929 } 930 }
930 931
932
931 int dmfseek(DMResource *fh, const off_t offset, const int whence) 933 int dmfseek(DMResource *fh, const off_t offset, const int whence)
932 { 934 {
933 fh->atime = time(NULL); 935 fh->atime = time(NULL);
934 return fh->fops->fseek(fh, offset, whence); 936 return fh->fops->fseek(fh, offset, whence);
935 } 937 }
936 938
939
937 off_t dmfsize(DMResource *fh) 940 off_t dmfsize(DMResource *fh)
938 { 941 {
939 fh->atime = time(NULL); 942 fh->atime = time(NULL);
940 return fh->fops->fsize(fh); 943 return fh->fops->fsize(fh);
941 } 944 }
942 945
946
943 off_t dmftell(DMResource *fh) 947 off_t dmftell(DMResource *fh)
944 { 948 {
945 fh->atime = time(NULL); 949 fh->atime = time(NULL);
946 return fh->fops->ftell(fh); 950 return fh->fops->ftell(fh);
947 } 951 }
948 952
953
949 BOOL dmfeof(DMResource *fh) 954 BOOL dmfeof(DMResource *fh)
950 { 955 {
951 fh->atime = time(NULL); 956 fh->atime = time(NULL);
952 return fh->fops->feof(fh); 957 return fh->fops->feof(fh);
953 } 958 }
954 959
960
955 int dmfgetc(DMResource *fh) 961 int dmfgetc(DMResource *fh)
956 { 962 {
957 fh->atime = time(NULL); 963 fh->atime = time(NULL);
958 return fh->fops->fgetc(fh); 964 return fh->fops->fgetc(fh);
959 } 965 }
960 966
967
961 int dmfputc(const int val, DMResource *fh) 968 int dmfputc(const int val, DMResource *fh)
962 { 969 {
963 fh->atime = time(NULL); 970 fh->atime = time(NULL);
964 return fh->fops->fputc(val, fh); 971 return fh->fops->fputc(val, fh);
965 } 972 }
966 973
974
967 size_t dmfread(void *ptr, size_t size, size_t nmemb, DMResource *fh) 975 size_t dmfread(void *ptr, size_t size, size_t nmemb, DMResource *fh)
968 { 976 {
969 fh->atime = time(NULL); 977 fh->atime = time(NULL);
970 return fh->fops->fread(ptr, size, nmemb, fh); 978 return fh->fops->fread(ptr, size, nmemb, fh);
971 } 979 }
972 980
981
973 size_t dmfwrite(const void *ptr, size_t size, size_t nmemb, DMResource *fh) 982 size_t dmfwrite(const void *ptr, size_t size, size_t nmemb, DMResource *fh)
974 { 983 {
975 fh->atime = time(NULL); 984 fh->atime = time(NULL);
976 return fh->fops->fwrite(ptr, size, nmemb, fh); 985 return fh->fops->fwrite(ptr, size, nmemb, fh);
977 } 986 }
987
978 988
979 char *dmfgets(char *str, const int size, DMResource *fh) 989 char *dmfgets(char *str, const int size, DMResource *fh)
980 { 990 {
981 char *ptr = str, *end = str + size - 1; 991 char *ptr = str, *end = str + size - 1;
982 int c; 992 int c;
993 *ptr = 0; 1003 *ptr = 0;
994 1004
995 return (ptr > str) ? str : NULL; 1005 return (ptr > str) ? str : NULL;
996 } 1006 }
997 1007
1008
998 int dmfputs(const char *str, DMResource *fh) 1009 int dmfputs(const char *str, DMResource *fh)
999 { 1010 {
1000 return dmfwrite(str, strlen(str), 1, fh) == 1 ? 1 : EOF; 1011 return dmfwrite(str, strlen(str), 1, fh) == 1 ? 1 : EOF;
1001 } 1012 }
1013
1002 1014
1003 int dmResourceRef(DMResource *node) 1015 int dmResourceRef(DMResource *node)
1004 { 1016 {
1005 dmLockLibMutex(node->lib); 1017 dmLockLibMutex(node->lib);
1006 node->atime = time(NULL); 1018 node->atime = time(NULL);
1081 1093
1082 // Basic data 1094 // Basic data
1083 lib->mutex = dmCreateMutex(); 1095 lib->mutex = dmCreateMutex();
1084 lib->flags = flags; 1096 lib->flags = flags;
1085 lib->resPath = dm_strdup(path); 1097 lib->resPath = dm_strdup(path);
1086
1087 1098
1088 #ifdef DM_USE_PACKFS 1099 #ifdef DM_USE_PACKFS
1089 if (flags & DRF_USE_PACK) 1100 if (flags & DRF_USE_PACK)
1090 { 1101 {
1091 int ret; 1102 int ret;